OLD | NEW |
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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 return nullptr; | 88 return nullptr; |
89 } | 89 } |
90 | 90 |
91 const SkImageInfo info = origInfo.makeAlphaType(newAT); | 91 const SkImageInfo info = origInfo.makeAlphaType(newAT); |
92 SkBitmap bitmap; | 92 SkBitmap bitmap; |
93 | 93 |
94 if (kUnknown_SkColorType == info.colorType()) { | 94 if (kUnknown_SkColorType == info.colorType()) { |
95 if (!bitmap.setInfo(info)) { | 95 if (!bitmap.setInfo(info)) { |
96 return nullptr; | 96 return nullptr; |
97 } | 97 } |
98 } else if (bitmap.info().isOpaque()) { | 98 } else if (info.isOpaque()) { |
99 // If this bitmap is opaque, we don't have any sensible default color, | 99 // If this bitmap is opaque, we don't have any sensible default color, |
100 // so we just return uninitialized pixels. | 100 // so we just return uninitialized pixels. |
101 if (!bitmap.tryAllocPixels(info)) { | 101 if (!bitmap.tryAllocPixels(info)) { |
102 return nullptr; | 102 return nullptr; |
103 } | 103 } |
104 } else { | 104 } else { |
105 // This bitmap has transparency, so we'll zero the pixels (to transparen
t). | 105 // This bitmap has transparency, so we'll zero the pixels (to transparen
t). |
106 // We use a ZeroedPRFactory as a faster alloc-then-eraseColor(SK_ColorTR
ANSPARENT). | 106 // We use a ZeroedPRFactory as a faster alloc-then-eraseColor(SK_ColorTR
ANSPARENT). |
107 SkMallocPixelRef::ZeroedPRFactory factory; | 107 SkMallocPixelRef::ZeroedPRFactory factory; |
108 if (!bitmap.tryAllocPixels(info, &factory, nullptr/*color table*/)) { | 108 if (!bitmap.tryAllocPixels(info, &factory, nullptr/*color table*/)) { |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 paint.getRasterizer() || | 387 paint.getRasterizer() || |
388 paint.getPathEffect() || | 388 paint.getPathEffect() || |
389 paint.isFakeBoldText() || | 389 paint.isFakeBoldText() || |
390 paint.getStyle() != SkPaint::kFill_Style || | 390 paint.getStyle() != SkPaint::kFill_Style || |
391 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) | 391 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) |
392 { | 392 { |
393 return true; | 393 return true; |
394 } | 394 } |
395 return false; | 395 return false; |
396 } | 396 } |
OLD | NEW |