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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 SkASSERT(valid_for_bitmap_device(bitmap.info(), NULL)); | 61 SkASSERT(valid_for_bitmap_device(bitmap.info(), NULL)); |
62 } | 62 } |
63 | 63 |
64 SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties&
deviceProperties) | 64 SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties&
deviceProperties) |
65 : SkBaseDevice(deviceProperties) | 65 : SkBaseDevice(deviceProperties) |
66 , fBitmap(bitmap) | 66 , fBitmap(bitmap) |
67 { | 67 { |
68 SkASSERT(valid_for_bitmap_device(bitmap.info(), NULL)); | 68 SkASSERT(valid_for_bitmap_device(bitmap.info(), NULL)); |
69 } | 69 } |
70 | 70 |
71 #ifdef SK_SUPPORT_LEGACY_COMPATIBLEDEVICE_CONFIG | |
72 void SkBitmapDevice::init(SkBitmap::Config config, int width, int height, bool i
sOpaque) { | |
73 fBitmap.setConfig(config, width, height, 0, isOpaque ? | |
74 kOpaque_SkAlphaType : kPremul_SkAlphaType); | |
75 | |
76 if (SkBitmap::kNo_Config != config) { | |
77 if (!fBitmap.allocPixels()) { | |
78 // indicate failure by zeroing our bitmap | |
79 fBitmap.setConfig(config, 0, 0, 0, isOpaque ? | |
80 kOpaque_SkAlphaType : kPremul_SkAlphaType); | |
81 } else if (!isOpaque) { | |
82 fBitmap.eraseColor(SK_ColorTRANSPARENT); | |
83 } | |
84 } | |
85 } | |
86 | |
87 SkBitmapDevice::SkBitmapDevice(SkBitmap::Config config, int width, int height, b
ool isOpaque) { | |
88 this->init(config, width, height, isOpaque); | |
89 } | |
90 | |
91 SkBitmapDevice::SkBitmapDevice(SkBitmap::Config config, int width, int height, b
ool isOpaque, | |
92 const SkDeviceProperties& deviceProperties) | |
93 : SkBaseDevice(deviceProperties) | |
94 { | |
95 this->init(config, width, height, isOpaque); | |
96 } | |
97 #endif | |
98 SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& origInfo, | 71 SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& origInfo, |
99 const SkDeviceProperties* props) { | 72 const SkDeviceProperties* props) { |
100 SkImageInfo info = origInfo; | 73 SkImageInfo info = origInfo; |
101 if (!valid_for_bitmap_device(info, &info.fAlphaType)) { | 74 if (!valid_for_bitmap_device(info, &info.fAlphaType)) { |
102 return NULL; | 75 return NULL; |
103 } | 76 } |
104 | 77 |
105 SkBitmap bitmap; | 78 SkBitmap bitmap; |
106 | 79 |
107 if (kUnknown_SkColorType == info.colorType()) { | 80 if (kUnknown_SkColorType == info.colorType()) { |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 paint.getStyle() != SkPaint::kFill_Style || | 464 paint.getStyle() != SkPaint::kFill_Style || |
492 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) { | 465 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) { |
493 // turn off lcd | 466 // turn off lcd |
494 flags->fFlags = paint.getFlags() & ~SkPaint::kLCDRenderText_Flag; | 467 flags->fFlags = paint.getFlags() & ~SkPaint::kLCDRenderText_Flag; |
495 flags->fHinting = paint.getHinting(); | 468 flags->fHinting = paint.getHinting(); |
496 return true; | 469 return true; |
497 } | 470 } |
498 // we're cool with the paint as is | 471 // we're cool with the paint as is |
499 return false; | 472 return false; |
500 } | 473 } |
OLD | NEW |