OLD | NEW |
---|---|
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 "SkBitmapProcState.h" | 8 #include "SkBitmapProcState.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkFilterProc.h" | 10 #include "SkFilterProc.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 // 2 bits from each to store our 4bit subpixel data | 89 // 2 bits from each to store our 4bit subpixel data |
90 return (dimension & ~0x3FFF) == 0; | 90 return (dimension & ~0x3FFF) == 0; |
91 } | 91 } |
92 | 92 |
93 // TODO -- we may want to pass the clip into this function so we only scale | 93 // TODO -- we may want to pass the clip into this function so we only scale |
94 // the portion of the image that we're going to need. This will complicate | 94 // the portion of the image that we're going to need. This will complicate |
95 // the interface to the cache, but might be well worth it. | 95 // the interface to the cache, but might be well worth it. |
96 | 96 |
97 void SkBitmapProcState::possiblyScaleImage() { | 97 void SkBitmapProcState::possiblyScaleImage() { |
98 | 98 |
99 if (fFilterQuality != kHQ_BitmapFilter) { | 99 if (fFilterLevel <= SkPaint::kLow_FilterLevel) { |
100 // none or low (bilerp) does not need to look any further | |
100 return; | 101 return; |
101 } | 102 } |
102 | 103 |
103 // STEP 1: UPSAMPLE? | 104 // STEP 1: UPSAMPLE? |
104 | 105 |
105 // Check to see if the transformation matrix is scaling up, and if | 106 // Check to see if the transformation matrix is scaling up, and if |
106 // the matrix is simple, and if we're doing high quality scaling. | 107 // the matrix is simple, and if we're doing high quality scaling. |
107 // If so, do the bitmap scale here and remove the scaling component from the matrix. | 108 // If so, do the bitmap scale here and remove the scaling component from the matrix. |
108 | 109 |
109 if (fInvMatrix.getType() <= (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Ma sk) && | 110 if (SkPaint::kHigh_FilterLevel == fFilterLevel && |
humper
2013/07/19 18:20:26
This logic needs to be more sophisticated, because
reed1
2013/07/19 18:29:16
Not sure I agree. It may be more logical to have L
| |
111 fInvMatrix.getType() <= (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Ma sk) && | |
110 (fInvMatrix.getScaleX() < 1 || fInvMatrix.getScaleY() < 1) && | 112 (fInvMatrix.getScaleX() < 1 || fInvMatrix.getScaleY() < 1) && |
111 fOrigBitmap.config() == SkBitmap::kARGB_8888_Config) { | 113 fOrigBitmap.config() == SkBitmap::kARGB_8888_Config) { |
112 | 114 |
113 // All the criteria are met; let's make a new bitmap. | 115 // All the criteria are met; let's make a new bitmap. |
114 fScaledBitmap.setConfig(SkBitmap::kARGB_8888_Config, | 116 fScaledBitmap.setConfig(SkBitmap::kARGB_8888_Config, |
115 (int)(fOrigBitmap.width() / fInvMatrix.getScaleX ()), | 117 (int)(fOrigBitmap.width() / fInvMatrix.getScaleX ()), |
116 (int)(fOrigBitmap.height() / fInvMatrix.getScale Y())); | 118 (int)(fOrigBitmap.height() / fInvMatrix.getScale Y())); |
117 fScaledBitmap.allocPixels(); | 119 fScaledBitmap.allocPixels(); |
118 fOrigBitmap.scale(&fScaledBitmap); | 120 fOrigBitmap.scale(&fScaledBitmap); |
119 fBitmap = &fScaledBitmap; | 121 fBitmap = &fScaledBitmap; |
120 | 122 |
121 // set the inv matrix type to translate-only; | 123 // set the inv matrix type to translate-only; |
122 | 124 |
123 fInvMatrix.setTranslate( 1/fInvMatrix.getScaleX() * fInvMatrix.getTransl ateX(), | 125 fInvMatrix.setTranslate( 1/fInvMatrix.getScaleX() * fInvMatrix.getTransl ateX(), |
124 1/fInvMatrix.getScaleY() * fInvMatrix.getTransl ateY() ); | 126 1/fInvMatrix.getScaleY() * fInvMatrix.getTransl ateY() ); |
125 | 127 |
126 // no need for any further filtering; we just did it! | 128 // no need for any further filtering; we just did it! |
127 | 129 |
128 fFilterQuality = kNone_BitmapFilter; | 130 fFilterLevel = SkPaint::kNone_FilterLevel; |
129 | 131 |
130 return; | 132 return; |
131 } | 133 } |
132 | 134 |
135 // If we get here, they are asking for a mipmap (if we're scaling down) | |
humper
2013/07/19 18:20:26
Sort of -- the HQ downscaler isn't a mipmap. The
| |
133 if (!fOrigBitmap.hasMipMap()) { | 136 if (!fOrigBitmap.hasMipMap()) { |
134 | 137 |
135 // STEP 2: DOWNSAMPLE | 138 // STEP 2: DOWNSAMPLE |
136 | 139 |
137 // Check to see if the transformation matrix is scaling *down*. | 140 // Check to see if the transformation matrix is scaling *down*. |
138 // If so, automatically build mipmaps. | 141 // If so, automatically build mipmaps. |
139 | 142 |
140 SkPoint v1, v2; | 143 SkPoint v1, v2; |
141 | 144 |
142 // conservatively estimate if the matrix is scaling down by seeing | 145 // conservatively estimate if the matrix is scaling down by seeing |
143 // what its upper left 2x2 portion does to two unit vectors. | 146 // what its upper left 2x2 portion does to two unit vectors. |
144 | 147 |
145 v1.fX = fInvMatrix.getScaleX(); | 148 v1.fX = fInvMatrix.getScaleX(); |
146 v1.fY = fInvMatrix.getSkewY(); | 149 v1.fY = fInvMatrix.getSkewY(); |
147 | 150 |
148 v2.fX = fInvMatrix.getSkewX(); | 151 v2.fX = fInvMatrix.getSkewX(); |
149 v2.fY = fInvMatrix.getScaleY(); | 152 v2.fY = fInvMatrix.getScaleY(); |
150 | 153 |
151 if (v1.fX * v1.fX + v1.fY * v1.fY > 1 || | 154 if (v1.fX * v1.fX + v1.fY * v1.fY > 1 || |
152 v2.fX * v2.fX + v2.fY * v2.fY > 1) { | 155 v2.fX * v2.fX + v2.fY * v2.fY > 1) { |
153 fOrigBitmap.buildMipMap(); | 156 fOrigBitmap.buildMipMap(); |
154 | 157 |
155 // Now that we've built the mipmaps and we know we're downsampling, | 158 // Now that we've built the mipmaps and we know we're downsampling, |
156 // downgrade to bilinear interpolation for the mip level. | 159 // downgrade to bilinear interpolation for the mip level. |
157 | 160 |
158 fFilterQuality = kBilerp_BitmapFilter; | 161 fFilterLevel = SkPaint::kLow_FilterLevel; |
159 } | 162 } |
160 } | 163 } |
161 | 164 |
162 if (fOrigBitmap.hasMipMap()) { | 165 if (fOrigBitmap.hasMipMap()) { |
163 | 166 |
164 // STEP 3: We've got mipmaps, let's choose the closest level as our rend er | 167 // STEP 3: We've got mipmaps, let's choose the closest level as our rend er |
165 // source and adjust the matrix accordingly. | 168 // source and adjust the matrix accordingly. |
166 | 169 |
167 int shift = fOrigBitmap.extractMipLevel(&fScaledBitmap, | 170 int shift = fOrigBitmap.extractMipLevel(&fScaledBitmap, |
168 SkScalarToFixed(fInvMatrix.getSc aleX()), | 171 SkScalarToFixed(fInvMatrix.getSc aleX()), |
(...skipping 26 matching lines...) Expand all Loading... | |
195 if (!(clampClamp || trivialMatrix)) { | 198 if (!(clampClamp || trivialMatrix)) { |
196 fInvMatrix.postIDiv(fOrigBitmap.width(), fOrigBitmap.height()); | 199 fInvMatrix.postIDiv(fOrigBitmap.width(), fOrigBitmap.height()); |
197 } | 200 } |
198 | 201 |
199 fBitmap = &fOrigBitmap; | 202 fBitmap = &fOrigBitmap; |
200 | 203 |
201 // initialize our filter quality to the one requested by the caller. | 204 // initialize our filter quality to the one requested by the caller. |
202 // We may downgrade it later if we determine that we either don't need | 205 // We may downgrade it later if we determine that we either don't need |
203 // or can't provide as high a quality filtering as the user requested. | 206 // or can't provide as high a quality filtering as the user requested. |
204 | 207 |
205 fFilterQuality = kNone_BitmapFilter; | 208 fFilterLevel = paint.getFilterLevel(); |
206 if (paint.isFilterBitmap()) { | |
207 if (paint.getFlags() & SkPaint::kHighQualityFilterBitmap_Flag) { | |
208 fFilterQuality = kHQ_BitmapFilter; | |
209 } else { | |
210 fFilterQuality = kBilerp_BitmapFilter; | |
211 } | |
212 } | |
213 | 209 |
214 #ifndef SK_IGNORE_IMAGE_PRESCALE | 210 #ifndef SK_IGNORE_IMAGE_PRESCALE |
215 // possiblyScaleImage will look to see if it can rescale the image as a | 211 // possiblyScaleImage will look to see if it can rescale the image as a |
216 // preprocess; either by scaling up to the target size, or by selecting | 212 // preprocess; either by scaling up to the target size, or by selecting |
217 // a nearby mipmap level. If it does, it will adjust the working | 213 // a nearby mipmap level. If it does, it will adjust the working |
218 // matrix as well as the working bitmap. It may also adjust the filter | 214 // matrix as well as the working bitmap. It may also adjust the filter |
219 // quality to avoid re-filtering an already perfectly scaled image. | 215 // quality to avoid re-filtering an already perfectly scaled image. |
220 | 216 |
221 this->possiblyScaleImage(); | 217 this->possiblyScaleImage(); |
222 #endif | 218 #endif |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
254 fShaderProc32 = NULL; | 250 fShaderProc32 = NULL; |
255 fShaderProc16 = NULL; | 251 fShaderProc16 = NULL; |
256 fSampleProc32 = NULL; | 252 fSampleProc32 = NULL; |
257 fSampleProc16 = NULL; | 253 fSampleProc16 = NULL; |
258 | 254 |
259 // recompute the triviality of the matrix here because we may have | 255 // recompute the triviality of the matrix here because we may have |
260 // changed it! | 256 // changed it! |
261 | 257 |
262 trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0; | 258 trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0; |
263 | 259 |
264 if (kHQ_BitmapFilter == fFilterQuality) { | 260 if (SkPaint::kHigh_FilterLevel == fFilterLevel) { |
humper
2013/07/19 18:20:26
What about poor medium level
reed1
2013/07/19 18:29:16
again: depends on our (new) definition of what Med
| |
265 // If this is still set, that means we wanted HQ sampling | 261 // If this is still set, that means we wanted HQ sampling |
266 // but couldn't do it as a preprocess. Let's try to install | 262 // but couldn't do it as a preprocess. Let's try to install |
267 // the scanline version of the HQ sampler. If that process fails, | 263 // the scanline version of the HQ sampler. If that process fails, |
268 // downgrade to bilerp. | 264 // downgrade to bilerp. |
269 | 265 |
270 // NOTE: Might need to be careful here in the future when we want | 266 // NOTE: Might need to be careful here in the future when we want |
271 // to have the platform proc have a shot at this; it's possible that | 267 // to have the platform proc have a shot at this; it's possible that |
272 // the chooseBitmapFilterProc will fail to install a shader but a | 268 // the chooseBitmapFilterProc will fail to install a shader but a |
273 // platform-specific one might succeed, so it might be premature here | 269 // platform-specific one might succeed, so it might be premature here |
274 // to fall back to bilerp. This needs thought. | 270 // to fall back to bilerp. This needs thought. |
275 | 271 |
276 SkASSERT(fInvType > SkMatrix::kTranslate_Mask); | 272 SkASSERT(fInvType > SkMatrix::kTranslate_Mask); |
277 | 273 |
278 fShaderProc32 = this->chooseBitmapFilterProc(); | 274 fShaderProc32 = this->chooseBitmapFilterProc(); |
279 if (!fShaderProc32) { | 275 if (!fShaderProc32) { |
280 fFilterQuality = kBilerp_BitmapFilter; | 276 fFilterLevel = SkPaint::kLow_FilterLevel; |
281 } | 277 } |
282 } | 278 } |
283 | 279 |
284 if (kBilerp_BitmapFilter == fFilterQuality) { | 280 if (SkPaint::kLow_FilterLevel == fFilterLevel) { |
285 // Only try bilerp if the matrix is "interesting" and | 281 // Only try bilerp if the matrix is "interesting" and |
286 // the image has a suitable size. | 282 // the image has a suitable size. |
287 | 283 |
288 if (fInvType <= SkMatrix::kTranslate_Mask || | 284 if (fInvType <= SkMatrix::kTranslate_Mask || |
289 !valid_for_filtering(fBitmap->width() | fBitmap->height())) { | 285 !valid_for_filtering(fBitmap->width() | fBitmap->height())) { |
290 fFilterQuality = kNone_BitmapFilter; | 286 fFilterLevel = SkPaint::kNone_FilterLevel; |
291 } | 287 } |
292 } | 288 } |
293 | 289 |
294 // At this point, we know exactly what kind of sampling the per-scanline | 290 // At this point, we know exactly what kind of sampling the per-scanline |
295 // shader will perform. | 291 // shader will perform. |
296 | 292 |
297 fMatrixProc = this->chooseMatrixProc(trivialMatrix); | 293 fMatrixProc = this->chooseMatrixProc(trivialMatrix); |
298 if (NULL == fMatrixProc) { | 294 if (NULL == fMatrixProc) { |
299 return false; | 295 return false; |
300 } | 296 } |
301 | 297 |
302 /////////////////////////////////////////////////////////////////////// | 298 /////////////////////////////////////////////////////////////////////// |
303 | 299 |
304 // No need to do this if we're doing HQ sampling; if filter quality is | 300 // No need to do this if we're doing HQ sampling; if filter quality is |
305 // still set to HQ by the time we get here, then we must have installed | 301 // still set to HQ by the time we get here, then we must have installed |
306 // the shader proc above and can skip all this. | 302 // the shader proc above and can skip all this. |
307 | 303 |
308 if (fFilterQuality < kHQ_BitmapFilter) { | 304 if (fFilterLevel < SkPaint::kHigh_FilterLevel) { |
309 | 305 |
310 int index = 0; | 306 int index = 0; |
311 if (fAlphaScale < 256) { // note: this distinction is not used for D16 | 307 if (fAlphaScale < 256) { // note: this distinction is not used for D16 |
312 index |= 1; | 308 index |= 1; |
313 } | 309 } |
314 if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { | 310 if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { |
315 index |= 2; | 311 index |= 2; |
316 } | 312 } |
317 if (fFilterQuality != kNone_BitmapFilter) { | 313 if (fFilterLevel > SkPaint::kNone_FilterLevel) { |
318 index |= 4; | 314 index |= 4; |
319 } | 315 } |
320 // bits 3,4,5 encoding the source bitmap format | 316 // bits 3,4,5 encoding the source bitmap format |
321 switch (fBitmap->config()) { | 317 switch (fBitmap->config()) { |
322 case SkBitmap::kARGB_8888_Config: | 318 case SkBitmap::kARGB_8888_Config: |
323 index |= 0; | 319 index |= 0; |
324 break; | 320 break; |
325 case SkBitmap::kRGB_565_Config: | 321 case SkBitmap::kRGB_565_Config: |
326 index |= 8; | 322 index |= 8; |
327 break; | 323 break; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
438 return true; | 434 return true; |
439 } | 435 } |
440 | 436 |
441 static void Clamp_S32_D32_nofilter_trans_shaderproc(const SkBitmapProcState& s, | 437 static void Clamp_S32_D32_nofilter_trans_shaderproc(const SkBitmapProcState& s, |
442 int x, int y, | 438 int x, int y, |
443 SkPMColor* SK_RESTRICT color s, | 439 SkPMColor* SK_RESTRICT color s, |
444 int count) { | 440 int count) { |
445 SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0); | 441 SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0); |
446 SkASSERT(s.fInvKy == 0); | 442 SkASSERT(s.fInvKy == 0); |
447 SkASSERT(count > 0 && colors != NULL); | 443 SkASSERT(count > 0 && colors != NULL); |
448 SkASSERT(SkBitmapProcState::kNone_BitmapFilter == s.fFilterQuality); | 444 SkASSERT(SkPaint::kNone_FilterLevel == s.fFilterLevel); |
449 | 445 |
450 const int maxX = s.fBitmap->width() - 1; | 446 const int maxX = s.fBitmap->width() - 1; |
451 const int maxY = s.fBitmap->height() - 1; | 447 const int maxY = s.fBitmap->height() - 1; |
452 int ix = s.fFilterOneX + x; | 448 int ix = s.fFilterOneX + x; |
453 int iy = SkClampMax(s.fFilterOneY + y, maxY); | 449 int iy = SkClampMax(s.fFilterOneY + y, maxY); |
454 #ifdef SK_DEBUG | 450 #ifdef SK_DEBUG |
455 { | 451 { |
456 SkPoint pt; | 452 SkPoint pt; |
457 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, | 453 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, |
458 SkIntToScalar(y) + SK_ScalarHalf, &pt); | 454 SkIntToScalar(y) + SK_ScalarHalf, &pt); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
512 return x; | 508 return x; |
513 } | 509 } |
514 | 510 |
515 static void Repeat_S32_D32_nofilter_trans_shaderproc(const SkBitmapProcState& s, | 511 static void Repeat_S32_D32_nofilter_trans_shaderproc(const SkBitmapProcState& s, |
516 int x, int y, | 512 int x, int y, |
517 SkPMColor* SK_RESTRICT colo rs, | 513 SkPMColor* SK_RESTRICT colo rs, |
518 int count) { | 514 int count) { |
519 SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0); | 515 SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0); |
520 SkASSERT(s.fInvKy == 0); | 516 SkASSERT(s.fInvKy == 0); |
521 SkASSERT(count > 0 && colors != NULL); | 517 SkASSERT(count > 0 && colors != NULL); |
522 SkASSERT(SkBitmapProcState::kNone_BitmapFilter == s.fFilterQuality); | 518 SkASSERT(SkPaint::kNone_FilterLevel == s.fFilterLevel); |
523 | 519 |
524 const int stopX = s.fBitmap->width(); | 520 const int stopX = s.fBitmap->width(); |
525 const int stopY = s.fBitmap->height(); | 521 const int stopY = s.fBitmap->height(); |
526 int ix = s.fFilterOneX + x; | 522 int ix = s.fFilterOneX + x; |
527 int iy = sk_int_mod(s.fFilterOneY + y, stopY); | 523 int iy = sk_int_mod(s.fFilterOneY + y, stopY); |
528 #ifdef SK_DEBUG | 524 #ifdef SK_DEBUG |
529 { | 525 { |
530 SkPoint pt; | 526 SkPoint pt; |
531 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, | 527 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, |
532 SkIntToScalar(y) + SK_ScalarHalf, &pt); | 528 SkIntToScalar(y) + SK_ScalarHalf, &pt); |
(...skipping 25 matching lines...) Expand all Loading... | |
558 int count) { | 554 int count) { |
559 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) == 0); | 555 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) == 0); |
560 SkASSERT(s.fInvKy == 0); | 556 SkASSERT(s.fInvKy == 0); |
561 SkASSERT(count > 0 && colors != NULL); | 557 SkASSERT(count > 0 && colors != NULL); |
562 SkASSERT(1 == s.fBitmap->width()); | 558 SkASSERT(1 == s.fBitmap->width()); |
563 | 559 |
564 int iY0; | 560 int iY0; |
565 int iY1 SK_INIT_TO_AVOID_WARNING; | 561 int iY1 SK_INIT_TO_AVOID_WARNING; |
566 int iSubY SK_INIT_TO_AVOID_WARNING; | 562 int iSubY SK_INIT_TO_AVOID_WARNING; |
567 | 563 |
568 if (s.fFilterQuality != SkBitmapProcState::kNone_BitmapFilter) { | 564 if (SkPaint::kNone_FilterLevel != s.fFilterLevel) { |
569 SkBitmapProcState::MatrixProc mproc = s.getMatrixProc(); | 565 SkBitmapProcState::MatrixProc mproc = s.getMatrixProc(); |
570 uint32_t xy[2]; | 566 uint32_t xy[2]; |
571 | 567 |
572 mproc(s, xy, 1, x, y); | 568 mproc(s, xy, 1, x, y); |
573 | 569 |
574 iY0 = xy[0] >> 18; | 570 iY0 = xy[0] >> 18; |
575 iY1 = xy[0] & 0x3FFF; | 571 iY1 = xy[0] & 0x3FFF; |
576 iSubY = (xy[0] >> 14) & 0xF; | 572 iSubY = (xy[0] >> 14) & 0xF; |
577 } else { | 573 } else { |
578 int yTemp; | 574 int yTemp; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
639 } | 635 } |
640 | 636 |
641 SkASSERT(iY0 == iY2); | 637 SkASSERT(iY0 == iY2); |
642 } | 638 } |
643 #endif | 639 #endif |
644 } | 640 } |
645 | 641 |
646 const SkPMColor* row0 = s.fBitmap->getAddr32(0, iY0); | 642 const SkPMColor* row0 = s.fBitmap->getAddr32(0, iY0); |
647 SkPMColor color; | 643 SkPMColor color; |
648 | 644 |
649 if (s.fFilterQuality != SkBitmapProcState::kNone_BitmapFilter) { | 645 if (SkPaint::kNone_FilterLevel != s.fFilterLevel) { |
650 const SkPMColor* row1 = s.fBitmap->getAddr32(0, iY1); | 646 const SkPMColor* row1 = s.fBitmap->getAddr32(0, iY1); |
651 | 647 |
652 if (s.fAlphaScale < 256) { | 648 if (s.fAlphaScale < 256) { |
653 Filter_32_alpha(iSubY, *row0, *row1, &color, s.fAlphaScale); | 649 Filter_32_alpha(iSubY, *row0, *row1, &color, s.fAlphaScale); |
654 } else { | 650 } else { |
655 Filter_32_opaque(iSubY, *row0, *row1, &color); | 651 Filter_32_opaque(iSubY, *row0, *row1, &color); |
656 } | 652 } |
657 } else { | 653 } else { |
658 if (s.fAlphaScale < 256) { | 654 if (s.fAlphaScale < 256) { |
659 color = SkAlphaMulQ(*row0, s.fAlphaScale); | 655 color = SkAlphaMulQ(*row0, s.fAlphaScale); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
695 | 691 |
696 SkBitmapProcState::ShaderProc32 SkBitmapProcState::chooseShaderProc32() { | 692 SkBitmapProcState::ShaderProc32 SkBitmapProcState::chooseShaderProc32() { |
697 | 693 |
698 if (SkBitmap::kARGB_8888_Config != fBitmap->config()) { | 694 if (SkBitmap::kARGB_8888_Config != fBitmap->config()) { |
699 return NULL; | 695 return NULL; |
700 } | 696 } |
701 | 697 |
702 static const unsigned kMask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_M ask; | 698 static const unsigned kMask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_M ask; |
703 | 699 |
704 if (1 == fBitmap->width() && 0 == (fInvType & ~kMask)) { | 700 if (1 == fBitmap->width() && 0 == (fInvType & ~kMask)) { |
705 if (kNone_BitmapFilter == fFilterQuality && | 701 if (SkPaint::kNone_FilterLevel == fFilterLevel && |
706 fInvType <= SkMatrix::kTranslate_Mask && | 702 fInvType <= SkMatrix::kTranslate_Mask && |
707 !this->setupForTranslate()) { | 703 !this->setupForTranslate()) { |
708 return DoNothing_shaderproc; | 704 return DoNothing_shaderproc; |
709 } | 705 } |
710 return S32_D32_constX_shaderproc; | 706 return S32_D32_constX_shaderproc; |
711 } | 707 } |
712 | 708 |
713 if (fAlphaScale < 256) { | 709 if (fAlphaScale < 256) { |
714 return NULL; | 710 return NULL; |
715 } | 711 } |
716 if (fInvType > SkMatrix::kTranslate_Mask) { | 712 if (fInvType > SkMatrix::kTranslate_Mask) { |
717 return NULL; | 713 return NULL; |
718 } | 714 } |
719 if (fFilterQuality != kNone_BitmapFilter) { | 715 if (SkPaint::kNone_FilterLevel != fFilterLevel) { |
720 return NULL; | 716 return NULL; |
721 } | 717 } |
722 | 718 |
723 SkShader::TileMode tx = (SkShader::TileMode)fTileModeX; | 719 SkShader::TileMode tx = (SkShader::TileMode)fTileModeX; |
724 SkShader::TileMode ty = (SkShader::TileMode)fTileModeY; | 720 SkShader::TileMode ty = (SkShader::TileMode)fTileModeY; |
725 | 721 |
726 if (SkShader::kClamp_TileMode == tx && SkShader::kClamp_TileMode == ty) { | 722 if (SkShader::kClamp_TileMode == tx && SkShader::kClamp_TileMode == ty) { |
727 if (this->setupForTranslate()) { | 723 if (this->setupForTranslate()) { |
728 return Clamp_S32_D32_nofilter_trans_shaderproc; | 724 return Clamp_S32_D32_nofilter_trans_shaderproc; |
729 } | 725 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
805 SkASSERT(count > 0); | 801 SkASSERT(count > 0); |
806 | 802 |
807 state.fMatrixProc(state, bitmapXY, count, x, y); | 803 state.fMatrixProc(state, bitmapXY, count, x, y); |
808 | 804 |
809 void (*proc)(uint32_t bitmapXY[], int count, unsigned mx, unsigned my); | 805 void (*proc)(uint32_t bitmapXY[], int count, unsigned mx, unsigned my); |
810 | 806 |
811 // There are four formats possible: | 807 // There are four formats possible: |
812 // scale -vs- affine | 808 // scale -vs- affine |
813 // filter -vs- nofilter | 809 // filter -vs- nofilter |
814 if (state.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { | 810 if (state.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { |
815 proc = state.fFilterQuality != kNone_BitmapFilter ? check_scale_filter : check_scale_nofilter; | 811 proc = state.fFilterLevel != SkPaint::kNone_FilterLevel ? check_scale_fi lter : check_scale_nofilter; |
816 } else { | 812 } else { |
817 proc = state.fFilterQuality != kNone_BitmapFilter ? check_affine_filter : check_affine_nofilter; | 813 proc = state.fFilterLevel != SkPaint::kNone_FilterLevel ? check_affine_f ilter : check_affine_nofilter; |
818 } | 814 } |
819 proc(bitmapXY, count, state.fBitmap->width(), state.fBitmap->height()); | 815 proc(bitmapXY, count, state.fBitmap->width(), state.fBitmap->height()); |
820 } | 816 } |
821 | 817 |
822 SkBitmapProcState::MatrixProc SkBitmapProcState::getMatrixProc() const { | 818 SkBitmapProcState::MatrixProc SkBitmapProcState::getMatrixProc() const { |
823 return DebugMatrixProc; | 819 return DebugMatrixProc; |
824 } | 820 } |
825 | 821 |
826 #endif | 822 #endif |
827 | 823 |
(...skipping 14 matching lines...) Expand all Loading... | |
842 if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { | 838 if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { |
843 size -= 4; // the shared Y (or YY) coordinate | 839 size -= 4; // the shared Y (or YY) coordinate |
844 if (size < 0) { | 840 if (size < 0) { |
845 size = 0; | 841 size = 0; |
846 } | 842 } |
847 size >>= 1; | 843 size >>= 1; |
848 } else { | 844 } else { |
849 size >>= 2; | 845 size >>= 2; |
850 } | 846 } |
851 | 847 |
852 if (fFilterQuality != kNone_BitmapFilter) { | 848 if (fFilterLevel != SkPaint::kNone_FilterLevel) { |
853 size >>= 1; | 849 size >>= 1; |
854 } | 850 } |
855 | 851 |
856 return size; | 852 return size; |
857 } | 853 } |
OLD | NEW |