Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/core/SkBitmapDevice.cpp

Issue 203993002: hide Config8888 entirely (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/core/SkDevice.h ('k') | src/core/SkConfig8888.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBitmapDevice.h" 8 #include "SkBitmapDevice.h"
9 #include "SkConfig8888.h" 9 #include "SkConfig8888.h"
10 #include "SkDraw.h" 10 #include "SkDraw.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 int rowCount) { 214 int rowCount) {
215 SkASSERT(bytesPerRow <= srcRB); 215 SkASSERT(bytesPerRow <= srcRB);
216 SkASSERT(bytesPerRow <= dstRB); 216 SkASSERT(bytesPerRow <= dstRB);
217 for (int i = 0; i < rowCount; ++i) { 217 for (int i = 0; i < rowCount; ++i) {
218 memcpy(dst, src, bytesPerRow); 218 memcpy(dst, src, bytesPerRow);
219 dst = (char*)dst + dstRB; 219 dst = (char*)dst + dstRB;
220 src = (const char*)src + srcRB; 220 src = (const char*)src + srcRB;
221 } 221 }
222 } 222 }
223 223
224 static bool info2config8888(const SkImageInfo& info, SkCanvas::Config8888* confi g) { 224 #include "SkConfig8888.h"
225 bool pre;
226 switch (info.alphaType()) {
227 case kPremul_SkAlphaType:
228 case kOpaque_SkAlphaType:
229 pre = true;
230 break;
231 case kUnpremul_SkAlphaType:
232 pre = false;
233 break;
234 default:
235 return false;
236 }
237 switch (info.colorType()) {
238 case kRGBA_8888_SkColorType:
239 *config = pre ? SkCanvas::kRGBA_Premul_Config8888 : SkCanvas::kRGBA_ Unpremul_Config8888;
240 return true;
241 case kBGRA_8888_SkColorType:
242 *config = pre ? SkCanvas::kBGRA_Premul_Config8888 : SkCanvas::kBGRA_ Unpremul_Config8888;
243 return true;
244 default:
245 return false;
246 }
247 }
248 225
249 // TODO: make this guy real, and not rely on legacy config8888 utility
250 #include "SkConfig8888.h"
251 static bool copy_pixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstR owBytes, 226 static bool copy_pixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstR owBytes,
252 const SkImageInfo& srcInfo, const void* srcPixels, size_ t srcRowBytes) { 227 const SkImageInfo& srcInfo, const void* srcPixels, size_ t srcRowBytes) {
253 if (srcInfo.dimensions() != dstInfo.dimensions()) { 228 if (srcInfo.dimensions() != dstInfo.dimensions()) {
254 return false; 229 return false;
255 } 230 }
256 if (4 == srcInfo.bytesPerPixel() && 4 == dstInfo.bytesPerPixel()) { 231 if (4 == srcInfo.bytesPerPixel() && 4 == dstInfo.bytesPerPixel()) {
257 SkCanvas::Config8888 srcConfig, dstConfig; 232 SkDstPixelInfo dstPI;
258 if (!info2config8888(srcInfo, &srcConfig) || !info2config8888(dstInfo, & dstConfig)) { 233 dstPI.fColorType = dstInfo.colorType();
259 return false; 234 dstPI.fAlphaType = dstInfo.alphaType();
260 } 235 dstPI.fPixels = dstPixels;
261 SkConvertConfig8888Pixels((uint32_t*)dstPixels, dstRowBytes, dstConfig, 236 dstPI.fRowBytes = dstRowBytes;
262 (const uint32_t*)srcPixels, srcRowBytes, srcCo nfig, 237
263 srcInfo.width(), srcInfo.height()); 238 SkSrcPixelInfo srcPI;
264 return true; 239 srcPI.fColorType = srcInfo.colorType();
240 srcPI.fAlphaType = srcInfo.alphaType();
241 srcPI.fPixels = srcPixels;
242 srcPI.fRowBytes = srcRowBytes;
243
244 return srcPI.convertPixelsTo(&dstPI, srcInfo.width(), srcInfo.height());
265 } 245 }
266 if (srcInfo.colorType() == dstInfo.colorType()) { 246 if (srcInfo.colorType() == dstInfo.colorType()) {
267 switch (srcInfo.colorType()) { 247 switch (srcInfo.colorType()) {
268 case kRGB_565_SkColorType: 248 case kRGB_565_SkColorType:
269 case kAlpha_8_SkColorType: 249 case kAlpha_8_SkColorType:
270 break; 250 break;
271 case kARGB_4444_SkColorType: 251 case kARGB_4444_SkColorType:
272 if (srcInfo.alphaType() != dstInfo.alphaType()) { 252 if (srcInfo.alphaType() != dstInfo.alphaType()) {
273 return false; 253 return false;
274 } 254 }
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 paint.getStyle() != SkPaint::kFill_Style || 519 paint.getStyle() != SkPaint::kFill_Style ||
540 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) { 520 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) {
541 // turn off lcd 521 // turn off lcd
542 flags->fFlags = paint.getFlags() & ~SkPaint::kLCDRenderText_Flag; 522 flags->fFlags = paint.getFlags() & ~SkPaint::kLCDRenderText_Flag;
543 flags->fHinting = paint.getHinting(); 523 flags->fHinting = paint.getHinting();
544 return true; 524 return true;
545 } 525 }
546 // we're cool with the paint as is 526 // we're cool with the paint as is
547 return false; 527 return false;
548 } 528 }
OLDNEW
« no previous file with comments | « include/core/SkDevice.h ('k') | src/core/SkConfig8888.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698