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

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

Issue 173893002: use colortype instead of config (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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 | « src/core/SkBitmapFilter.cpp ('k') | src/core/SkBitmapScaler.cpp » ('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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SkColorPriv.h" 8 #include "SkColorPriv.h"
9 #include "SkReadBuffer.h" 9 #include "SkReadBuffer.h"
10 #include "SkWriteBuffer.h" 10 #include "SkWriteBuffer.h"
11 #include "SkPixelRef.h" 11 #include "SkPixelRef.h"
12 #include "SkErrorInternals.h" 12 #include "SkErrorInternals.h"
13 #include "SkBitmapProcShader.h" 13 #include "SkBitmapProcShader.h"
14 14
15 #if SK_SUPPORT_GPU 15 #if SK_SUPPORT_GPU
16 #include "effects/GrSimpleTextureEffect.h" 16 #include "effects/GrSimpleTextureEffect.h"
17 #include "effects/GrBicubicEffect.h" 17 #include "effects/GrBicubicEffect.h"
18 #endif 18 #endif
19 19
20 bool SkBitmapProcShader::CanDo(const SkBitmap& bm, TileMode tx, TileMode ty) { 20 bool SkBitmapProcShader::CanDo(const SkBitmap& bm, TileMode tx, TileMode ty) {
21 switch (bm.config()) { 21 switch (bm.colorType()) {
22 case SkBitmap::kA8_Config: 22 case kAlpha_8_SkColorType:
23 case SkBitmap::kRGB_565_Config: 23 case kRGB_565_SkColorType:
24 case SkBitmap::kIndex8_Config: 24 case kIndex_8_SkColorType:
25 case SkBitmap::kARGB_8888_Config: 25 case kPMColor_SkColorType:
26 // if (tx == ty && (kClamp_TileMode == tx || kRepeat_TileMode == tx)) 26 // if (tx == ty && (kClamp_TileMode == tx || kRepeat_TileMode == tx))
27 return true; 27 return true;
28 default: 28 default:
29 break; 29 break;
30 } 30 }
31 return false; 31 return false;
32 } 32 }
33 33
34 SkBitmapProcShader::SkBitmapProcShader(const SkBitmap& src, 34 SkBitmapProcShader::SkBitmapProcShader(const SkBitmap& src,
35 TileMode tmx, TileMode tmy) { 35 TileMode tmx, TileMode tmy) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 return fRawBitmap.isOpaque(); 81 return fRawBitmap.isOpaque();
82 } 82 }
83 83
84 static bool valid_for_drawing(const SkBitmap& bm) { 84 static bool valid_for_drawing(const SkBitmap& bm) {
85 if (0 == bm.width() || 0 == bm.height()) { 85 if (0 == bm.width() || 0 == bm.height()) {
86 return false; // nothing to draw 86 return false; // nothing to draw
87 } 87 }
88 if (NULL == bm.pixelRef()) { 88 if (NULL == bm.pixelRef()) {
89 return false; // no pixels to read 89 return false; // no pixels to read
90 } 90 }
91 if (SkBitmap::kIndex8_Config == bm.config()) { 91 if (kIndex_8_SkColorType == bm.colorType()) {
92 // ugh, I have to lock-pixels to inspect the colortable 92 // ugh, I have to lock-pixels to inspect the colortable
93 SkAutoLockPixels alp(bm); 93 SkAutoLockPixels alp(bm);
94 if (!bm.getColorTable()) { 94 if (!bm.getColorTable()) {
95 return false; 95 return false;
96 } 96 }
97 } 97 }
98 return true; 98 return true;
99 } 99 }
100 100
101 bool SkBitmapProcShader::setContext(const SkBitmap& device, 101 bool SkBitmapProcShader::setContext(const SkBitmap& device,
(...skipping 16 matching lines...) Expand all
118 118
119 const SkBitmap& bitmap = *fState.fBitmap; 119 const SkBitmap& bitmap = *fState.fBitmap;
120 bool bitmapIsOpaque = bitmap.isOpaque(); 120 bool bitmapIsOpaque = bitmap.isOpaque();
121 121
122 // update fFlags 122 // update fFlags
123 uint32_t flags = 0; 123 uint32_t flags = 0;
124 if (bitmapIsOpaque && (255 == this->getPaintAlpha())) { 124 if (bitmapIsOpaque && (255 == this->getPaintAlpha())) {
125 flags |= kOpaqueAlpha_Flag; 125 flags |= kOpaqueAlpha_Flag;
126 } 126 }
127 127
128 switch (bitmap.config()) { 128 switch (bitmap.colorType()) {
129 case SkBitmap::kRGB_565_Config: 129 case kRGB_565_SkColorType:
130 flags |= (kHasSpan16_Flag | kIntrinsicly16_Flag); 130 flags |= (kHasSpan16_Flag | kIntrinsicly16_Flag);
131 break; 131 break;
132 case SkBitmap::kIndex8_Config: 132 case kIndex_8_SkColorType:
133 case SkBitmap::kARGB_8888_Config: 133 case kPMColor_SkColorType:
134 if (bitmapIsOpaque) { 134 if (bitmapIsOpaque) {
135 flags |= kHasSpan16_Flag; 135 flags |= kHasSpan16_Flag;
136 } 136 }
137 break; 137 break;
138 case SkBitmap::kA8_Config: 138 case kAlpha_8_SkColorType:
139 break; // never set kHasSpan16_Flag 139 break; // never set kHasSpan16_Flag
140 default: 140 default:
141 break; 141 break;
142 } 142 }
143 143
144 if (paint.isDither() && bitmap.config() != SkBitmap::kRGB_565_Config) { 144 if (paint.isDither() && bitmap.colorType() != kRGB_565_SkColorType) {
145 // gradients can auto-dither in their 16bit sampler, but we don't so 145 // gradients can auto-dither in their 16bit sampler, but we don't so
146 // we clear the flag here. 146 // we clear the flag here.
147 flags &= ~kHasSpan16_Flag; 147 flags &= ~kHasSpan16_Flag;
148 } 148 }
149 149
150 // if we're only 1-pixel high, and we don't rotate, then we can claim this 150 // if we're only 1-pixel high, and we don't rotate, then we can claim this
151 if (1 == bitmap.height() && 151 if (1 == bitmap.height() &&
152 only_scale_and_translate(this->getTotalInverse())) { 152 only_scale_and_translate(this->getTotalInverse())) {
153 flags |= kConstInY32_Flag; 153 flags |= kConstInY32_Flag;
154 if (flags & kHasSpan16_Flag) { 154 if (flags & kHasSpan16_Flag) {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 static bool canUseColorShader(const SkBitmap& bm, SkColor* color) { 271 static bool canUseColorShader(const SkBitmap& bm, SkColor* color) {
272 if (1 != bm.width() || 1 != bm.height()) { 272 if (1 != bm.width() || 1 != bm.height()) {
273 return false; 273 return false;
274 } 274 }
275 275
276 SkAutoLockPixels alp(bm); 276 SkAutoLockPixels alp(bm);
277 if (!bm.readyToDraw()) { 277 if (!bm.readyToDraw()) {
278 return false; 278 return false;
279 } 279 }
280 280
281 switch (bm.config()) { 281 switch (bm.colorType()) {
282 case SkBitmap::kARGB_8888_Config: 282 case kPMColor_SkColorType:
283 *color = SkUnPreMultiply::PMColorToColor(*bm.getAddr32(0, 0)); 283 *color = SkUnPreMultiply::PMColorToColor(*bm.getAddr32(0, 0));
284 return true; 284 return true;
285 case SkBitmap::kRGB_565_Config: 285 case kRGB_565_SkColorType:
286 *color = SkPixel16ToColor(*bm.getAddr16(0, 0)); 286 *color = SkPixel16ToColor(*bm.getAddr16(0, 0));
287 return true; 287 return true;
288 case SkBitmap::kIndex8_Config: 288 case kIndex_8_SkColorType:
289 *color = SkUnPreMultiply::PMColorToColor(bm.getIndex8Color(0, 0)); 289 *color = SkUnPreMultiply::PMColorToColor(bm.getIndex8Color(0, 0));
290 return true; 290 return true;
291 default: // just skip the other configs for now 291 default: // just skip the other configs for now
292 break; 292 break;
293 } 293 }
294 return false; 294 return false;
295 } 295 }
296 296
297 #include "SkTemplatesPriv.h" 297 #include "SkTemplatesPriv.h"
298 298
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 GrEffectRef* effect = NULL; 437 GrEffectRef* effect = NULL;
438 if (paintFilterLevel == SkPaint::kHigh_FilterLevel) { 438 if (paintFilterLevel == SkPaint::kHigh_FilterLevel) {
439 effect = GrBicubicEffect::Create(texture, matrix, tm); 439 effect = GrBicubicEffect::Create(texture, matrix, tm);
440 } else { 440 } else {
441 effect = GrSimpleTextureEffect::Create(texture, matrix, params); 441 effect = GrSimpleTextureEffect::Create(texture, matrix, params);
442 } 442 }
443 GrUnlockAndUnrefCachedBitmapTexture(texture); 443 GrUnlockAndUnrefCachedBitmapTexture(texture);
444 return effect; 444 return effect;
445 } 445 }
446 #endif 446 #endif
OLDNEW
« no previous file with comments | « src/core/SkBitmapFilter.cpp ('k') | src/core/SkBitmapScaler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698