Chromium Code Reviews| 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" |
| 11 #include "SkRasterClip.h" | 11 #include "SkRasterClip.h" |
| 12 #include "SkShader.h" | 12 #include "SkShader.h" |
| 13 | 13 |
| 14 SK_DEFINE_INST_COUNT(SkBitmapDevice) | 14 SK_DEFINE_INST_COUNT(SkBitmapDevice) |
| 15 | 15 |
| 16 #define CHECK_FOR_NODRAW_ANNOTATION(paint) \ | 16 #define CHECK_FOR_NODRAW_ANNOTATION(paint) \ |
| 17 do { if (paint.isNoDrawAnnotation()) { return; } } while (0) | 17 do { if (paint.isNoDrawAnnotation()) { return; } } while (0) |
| 18 | 18 |
| 19 SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap) | 19 SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap) |
| 20 : fBitmap(bitmap) { | 20 : fBitmap(bitmap) { |
| 21 SkASSERT(SkBitmap::kARGB_4444_Config != bitmap.config()); | 21 SkASSERT(SkBitmap::kARGB_4444_Config != bitmap.config()); |
| 22 } | 22 } |
| 23 | 23 |
| 24 SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties) | 24 SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties) |
| 25 : SkBaseDevice(deviceProperties) | 25 : SkBaseDevice(deviceProperties) |
| 26 , fBitmap(bitmap) { | 26 , fBitmap(bitmap) { |
| 27 } | 27 } |
| 28 | 28 |
| 29 SkBitmapDevice::SkBitmapDevice(SkBitmap::Config config, int width, int height, b ool isOpaque) { | 29 SkBitmapDevice::SkBitmapDevice(SkBitmap::Config config, int width, int height, b ool isOpaque) { |
| 30 fBitmap.setConfig(config, width, height); | 30 fBitmap.setConfig(config, width, height, 0, isOpaque ? |
|
scroggo
2013/10/18 20:04:34
Should we update the parameter or perhaps add a TO
reed1
2013/10/18 21:37:35
Actually, the renderers (SW and GPU) can only supp
| |
| 31 kOpaque_SkAlphaType : kPremul_SkAlphaType); | |
| 31 fBitmap.allocPixels(); | 32 fBitmap.allocPixels(); |
| 32 fBitmap.setIsOpaque(isOpaque); | |
| 33 if (!isOpaque) { | 33 if (!isOpaque) { |
| 34 fBitmap.eraseColor(SK_ColorTRANSPARENT); | 34 fBitmap.eraseColor(SK_ColorTRANSPARENT); |
| 35 } | 35 } |
| 36 } | 36 } |
| 37 | 37 |
| 38 SkBitmapDevice::SkBitmapDevice(SkBitmap::Config config, int width, int height, b ool isOpaque, | 38 SkBitmapDevice::SkBitmapDevice(SkBitmap::Config config, int width, int height, b ool isOpaque, |
| 39 const SkDeviceProperties& deviceProperties) | 39 const SkDeviceProperties& deviceProperties) |
| 40 : SkBaseDevice(deviceProperties) { | 40 : SkBaseDevice(deviceProperties) { |
| 41 | 41 |
| 42 fBitmap.setConfig(config, width, height); | 42 fBitmap.setConfig(config, width, height, 0, isOpaque ? |
| 43 kOpaque_SkAlphaType : kPremul_SkAlphaType); | |
| 43 fBitmap.allocPixels(); | 44 fBitmap.allocPixels(); |
| 44 fBitmap.setIsOpaque(isOpaque); | |
| 45 if (!isOpaque) { | 45 if (!isOpaque) { |
| 46 fBitmap.eraseColor(SK_ColorTRANSPARENT); | 46 fBitmap.eraseColor(SK_ColorTRANSPARENT); |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 | 49 |
| 50 SkBitmapDevice::~SkBitmapDevice() { | 50 SkBitmapDevice::~SkBitmapDevice() { |
| 51 } | 51 } |
| 52 | 52 |
| 53 void SkBitmapDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) { | 53 void SkBitmapDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) { |
| 54 SkASSERT(bm.width() == fBitmap.width()); | 54 SkASSERT(bm.width() == fBitmap.width()); |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 400 paint.getStyle() != SkPaint::kFill_Style || | 400 paint.getStyle() != SkPaint::kFill_Style || |
| 401 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) { | 401 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) { |
| 402 // turn off lcd | 402 // turn off lcd |
| 403 flags->fFlags = paint.getFlags() & ~SkPaint::kLCDRenderText_Flag; | 403 flags->fFlags = paint.getFlags() & ~SkPaint::kLCDRenderText_Flag; |
| 404 flags->fHinting = paint.getHinting(); | 404 flags->fHinting = paint.getHinting(); |
| 405 return true; | 405 return true; |
| 406 } | 406 } |
| 407 // we're cool with the paint as is | 407 // we're cool with the paint as is |
| 408 return false; | 408 return false; |
| 409 } | 409 } |
| OLD | NEW |