OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkBitmapCache.h" | 8 #include "SkBitmapCache.h" |
9 #include "SkBitmapProcState.h" | 9 #include "SkBitmapProcState.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } | 136 } |
137 scale->set(sx, sy); | 137 scale->set(sx, sy); |
138 return true; | 138 return true; |
139 } | 139 } |
140 | 140 |
141 /* | 141 /* |
142 * High quality is implemented by performing up-right scale-only filtering and
then | 142 * High quality is implemented by performing up-right scale-only filtering and
then |
143 * using bilerp for any remaining transformations. | 143 * using bilerp for any remaining transformations. |
144 */ | 144 */ |
145 void SkBitmapProcState::processHQRequest() { | 145 void SkBitmapProcState::processHQRequest() { |
146 SkASSERT(SkPaint::kHigh_FilterLevel == fFilterLevel); | 146 SkASSERT(kHigh_SkFilterQuality == fFilterLevel); |
147 | 147 |
148 // Our default return state is to downgrade the request to Medium, w/ or w/o
setting fBitmap | 148 // Our default return state is to downgrade the request to Medium, w/ or w/o
setting fBitmap |
149 // to a valid bitmap. If we succeed, we will set this to Low instead. | 149 // to a valid bitmap. If we succeed, we will set this to Low instead. |
150 fFilterLevel = SkPaint::kMedium_FilterLevel; | 150 fFilterLevel = kMedium_SkFilterQuality; |
151 | 151 |
152 if (kN32_SkColorType != fOrigBitmap.colorType() || !cache_size_okay(fOrigBit
map, fInvMatrix) || | 152 if (kN32_SkColorType != fOrigBitmap.colorType() || !cache_size_okay(fOrigBit
map, fInvMatrix) || |
153 fInvMatrix.hasPerspective()) | 153 fInvMatrix.hasPerspective()) |
154 { | 154 { |
155 return; // can't handle the reqeust | 155 return; // can't handle the reqeust |
156 } | 156 } |
157 | 157 |
158 SkScalar invScaleX = fInvMatrix.getScaleX(); | 158 SkScalar invScaleX = fInvMatrix.getScaleX(); |
159 SkScalar invScaleY = fInvMatrix.getScaleY(); | 159 SkScalar invScaleY = fInvMatrix.getScaleY(); |
160 if (fInvMatrix.getType() & SkMatrix::kAffine_Mask) { | 160 if (fInvMatrix.getType() & SkMatrix::kAffine_Mask) { |
(...skipping 26 matching lines...) Expand all Loading... |
187 SkASSERT(fScaledBitmap.getPixels()); | 187 SkASSERT(fScaledBitmap.getPixels()); |
188 fScaledBitmap.setImmutable(); | 188 fScaledBitmap.setImmutable(); |
189 SkBitmapCache::Add(fOrigBitmap, roundedDestWidth, roundedDestHeight, fSc
aledBitmap); | 189 SkBitmapCache::Add(fOrigBitmap, roundedDestWidth, roundedDestHeight, fSc
aledBitmap); |
190 } | 190 } |
191 | 191 |
192 SkASSERT(fScaledBitmap.getPixels()); | 192 SkASSERT(fScaledBitmap.getPixels()); |
193 fBitmap = &fScaledBitmap; | 193 fBitmap = &fScaledBitmap; |
194 | 194 |
195 fInvMatrix.postScale(roundedDestWidth / fOrigBitmap.width(), | 195 fInvMatrix.postScale(roundedDestWidth / fOrigBitmap.width(), |
196 roundedDestHeight / fOrigBitmap.height()); | 196 roundedDestHeight / fOrigBitmap.height()); |
197 fFilterLevel = SkPaint::kLow_FilterLevel; | 197 fFilterLevel = kLow_SkFilterQuality; |
198 } | 198 } |
199 | 199 |
200 /* | 200 /* |
201 * Modulo internal errors, this should always succeed *if* the matrix is downsc
aling | 201 * Modulo internal errors, this should always succeed *if* the matrix is downsc
aling |
202 * (in this case, we have the inverse, so it succeeds if fInvMatrix is upscalin
g) | 202 * (in this case, we have the inverse, so it succeeds if fInvMatrix is upscalin
g) |
203 */ | 203 */ |
204 void SkBitmapProcState::processMediumRequest() { | 204 void SkBitmapProcState::processMediumRequest() { |
205 SkASSERT(SkPaint::kMedium_FilterLevel == fFilterLevel); | 205 SkASSERT(kMedium_SkFilterQuality == fFilterLevel); |
206 | 206 |
207 // Our default return state is to downgrade the request to Low, w/ or w/o se
tting fBitmap | 207 // Our default return state is to downgrade the request to Low, w/ or w/o se
tting fBitmap |
208 // to a valid bitmap. | 208 // to a valid bitmap. |
209 fFilterLevel = SkPaint::kLow_FilterLevel; | 209 fFilterLevel = kLow_SkFilterQuality; |
210 | 210 |
211 SkScalar invScale = effective_matrix_scale(fInvMatrix); | 211 SkScalar invScale = effective_matrix_scale(fInvMatrix); |
212 | 212 |
213 if (invScale > SK_Scalar1) { | 213 if (invScale > SK_Scalar1) { |
214 fCurrMip.reset(SkMipMapCache::FindAndRef(fOrigBitmap)); | 214 fCurrMip.reset(SkMipMapCache::FindAndRef(fOrigBitmap)); |
215 if (NULL == fCurrMip.get()) { | 215 if (NULL == fCurrMip.get()) { |
216 fCurrMip.reset(SkMipMapCache::AddAndRef(fOrigBitmap)); | 216 fCurrMip.reset(SkMipMapCache::AddAndRef(fOrigBitmap)); |
217 if (NULL == fCurrMip.get()) { | 217 if (NULL == fCurrMip.get()) { |
218 return; | 218 return; |
219 } | 219 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 * - sometimes we will "ignore" Low and give None, but this is likely a legacy
perf hack | 282 * - sometimes we will "ignore" Low and give None, but this is likely a legacy
perf hack |
283 * and may be removed. | 283 * and may be removed. |
284 */ | 284 */ |
285 bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { | 285 bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { |
286 if (!valid_for_drawing(fOrigBitmap)) { | 286 if (!valid_for_drawing(fOrigBitmap)) { |
287 return false; | 287 return false; |
288 } | 288 } |
289 | 289 |
290 fBitmap = NULL; | 290 fBitmap = NULL; |
291 fInvMatrix = inv; | 291 fInvMatrix = inv; |
292 fFilterLevel = paint.getFilterLevel(); | 292 fFilterLevel = paint.getFilterQuality(); |
293 | 293 |
294 if (SkPaint::kHigh_FilterLevel == fFilterLevel) { | 294 if (kHigh_SkFilterQuality == fFilterLevel) { |
295 this->processHQRequest(); | 295 this->processHQRequest(); |
296 } | 296 } |
297 SkASSERT(fFilterLevel < SkPaint::kHigh_FilterLevel); | 297 SkASSERT(fFilterLevel < kHigh_SkFilterQuality); |
298 | 298 |
299 if (SkPaint::kMedium_FilterLevel == fFilterLevel) { | 299 if (kMedium_SkFilterQuality == fFilterLevel) { |
300 this->processMediumRequest(); | 300 this->processMediumRequest(); |
301 } | 301 } |
302 SkASSERT(fFilterLevel < SkPaint::kMedium_FilterLevel); | 302 SkASSERT(fFilterLevel < kMedium_SkFilterQuality); |
303 | 303 |
304 if (NULL == fBitmap) { | 304 if (NULL == fBitmap) { |
305 if (!this->lockBaseBitmap()) { | 305 if (!this->lockBaseBitmap()) { |
306 return false; | 306 return false; |
307 } | 307 } |
308 } | 308 } |
309 SkASSERT(fBitmap); | 309 SkASSERT(fBitmap); |
310 | 310 |
311 bool trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) ==
0; | 311 bool trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) ==
0; |
312 bool clampClamp = SkShader::kClamp_TileMode == fTileModeX && | 312 bool clampClamp = SkShader::kClamp_TileMode == fTileModeX && |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 fShaderProc32 = NULL; | 355 fShaderProc32 = NULL; |
356 fShaderProc16 = NULL; | 356 fShaderProc16 = NULL; |
357 fSampleProc32 = NULL; | 357 fSampleProc32 = NULL; |
358 fSampleProc16 = NULL; | 358 fSampleProc16 = NULL; |
359 | 359 |
360 // recompute the triviality of the matrix here because we may have | 360 // recompute the triviality of the matrix here because we may have |
361 // changed it! | 361 // changed it! |
362 | 362 |
363 trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0; | 363 trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0; |
364 | 364 |
365 if (SkPaint::kLow_FilterLevel == fFilterLevel) { | 365 if (kLow_SkFilterQuality == fFilterLevel) { |
366 // Only try bilerp if the matrix is "interesting" and | 366 // Only try bilerp if the matrix is "interesting" and |
367 // the image has a suitable size. | 367 // the image has a suitable size. |
368 | 368 |
369 if (fInvType <= SkMatrix::kTranslate_Mask || | 369 if (fInvType <= SkMatrix::kTranslate_Mask || |
370 !valid_for_filtering(fBitmap->width() | fBitmap->height())) | 370 !valid_for_filtering(fBitmap->width() | fBitmap->height())) |
371 { | 371 { |
372 fFilterLevel = SkPaint::kNone_FilterLevel; | 372 fFilterLevel = kNone_SkFilterQuality; |
373 } | 373 } |
374 } | 374 } |
375 | 375 |
376 return this->chooseScanlineProcs(trivialMatrix, clampClamp, paint); | 376 return this->chooseScanlineProcs(trivialMatrix, clampClamp, paint); |
377 } | 377 } |
378 | 378 |
379 bool SkBitmapProcState::chooseScanlineProcs(bool trivialMatrix, bool clampClamp, | 379 bool SkBitmapProcState::chooseScanlineProcs(bool trivialMatrix, bool clampClamp, |
380 const SkPaint& paint) { | 380 const SkPaint& paint) { |
381 fMatrixProc = this->chooseMatrixProc(trivialMatrix); | 381 fMatrixProc = this->chooseMatrixProc(trivialMatrix); |
382 // TODO(dominikg): SkASSERT(fMatrixProc) instead? chooseMatrixProc never ret
urns NULL. | 382 // TODO(dominikg): SkASSERT(fMatrixProc) instead? chooseMatrixProc never ret
urns NULL. |
383 if (NULL == fMatrixProc) { | 383 if (NULL == fMatrixProc) { |
384 return false; | 384 return false; |
385 } | 385 } |
386 | 386 |
387 /////////////////////////////////////////////////////////////////////// | 387 /////////////////////////////////////////////////////////////////////// |
388 | 388 |
389 const SkAlphaType at = fBitmap->alphaType(); | 389 const SkAlphaType at = fBitmap->alphaType(); |
390 | 390 |
391 // No need to do this if we're doing HQ sampling; if filter quality is | 391 // No need to do this if we're doing HQ sampling; if filter quality is |
392 // still set to HQ by the time we get here, then we must have installed | 392 // still set to HQ by the time we get here, then we must have installed |
393 // the shader procs above and can skip all this. | 393 // the shader procs above and can skip all this. |
394 | 394 |
395 if (fFilterLevel < SkPaint::kHigh_FilterLevel) { | 395 if (fFilterLevel < kHigh_SkFilterQuality) { |
396 | 396 |
397 int index = 0; | 397 int index = 0; |
398 if (fAlphaScale < 256) { // note: this distinction is not used for D16 | 398 if (fAlphaScale < 256) { // note: this distinction is not used for D16 |
399 index |= 1; | 399 index |= 1; |
400 } | 400 } |
401 if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { | 401 if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { |
402 index |= 2; | 402 index |= 2; |
403 } | 403 } |
404 if (fFilterLevel > SkPaint::kNone_FilterLevel) { | 404 if (fFilterLevel > kNone_SkFilterQuality) { |
405 index |= 4; | 405 index |= 4; |
406 } | 406 } |
407 // bits 3,4,5 encoding the source bitmap format | 407 // bits 3,4,5 encoding the source bitmap format |
408 switch (fBitmap->colorType()) { | 408 switch (fBitmap->colorType()) { |
409 case kN32_SkColorType: | 409 case kN32_SkColorType: |
410 if (kPremul_SkAlphaType != at && kOpaque_SkAlphaType != at) { | 410 if (kPremul_SkAlphaType != at && kOpaque_SkAlphaType != at) { |
411 return false; | 411 return false; |
412 } | 412 } |
413 index |= 0; | 413 index |= 0; |
414 break; | 414 break; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 return true; | 537 return true; |
538 } | 538 } |
539 | 539 |
540 static void Clamp_S32_D32_nofilter_trans_shaderproc(const SkBitmapProcState& s, | 540 static void Clamp_S32_D32_nofilter_trans_shaderproc(const SkBitmapProcState& s, |
541 int x, int y, | 541 int x, int y, |
542 SkPMColor* SK_RESTRICT color
s, | 542 SkPMColor* SK_RESTRICT color
s, |
543 int count) { | 543 int count) { |
544 SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0); | 544 SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0); |
545 SkASSERT(s.fInvKy == 0); | 545 SkASSERT(s.fInvKy == 0); |
546 SkASSERT(count > 0 && colors != NULL); | 546 SkASSERT(count > 0 && colors != NULL); |
547 SkASSERT(SkPaint::kNone_FilterLevel == s.fFilterLevel); | 547 SkASSERT(kNone_SkFilterQuality == s.fFilterLevel); |
548 | 548 |
549 const int maxX = s.fBitmap->width() - 1; | 549 const int maxX = s.fBitmap->width() - 1; |
550 const int maxY = s.fBitmap->height() - 1; | 550 const int maxY = s.fBitmap->height() - 1; |
551 int ix = s.fFilterOneX + x; | 551 int ix = s.fFilterOneX + x; |
552 int iy = SkClampMax(s.fFilterOneY + y, maxY); | 552 int iy = SkClampMax(s.fFilterOneY + y, maxY); |
553 #ifdef SK_DEBUG | 553 #ifdef SK_DEBUG |
554 { | 554 { |
555 SkPoint pt; | 555 SkPoint pt; |
556 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, | 556 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, |
557 SkIntToScalar(y) + SK_ScalarHalf, &pt); | 557 SkIntToScalar(y) + SK_ScalarHalf, &pt); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 return x; | 611 return x; |
612 } | 612 } |
613 | 613 |
614 static void Repeat_S32_D32_nofilter_trans_shaderproc(const SkBitmapProcState& s, | 614 static void Repeat_S32_D32_nofilter_trans_shaderproc(const SkBitmapProcState& s, |
615 int x, int y, | 615 int x, int y, |
616 SkPMColor* SK_RESTRICT colo
rs, | 616 SkPMColor* SK_RESTRICT colo
rs, |
617 int count) { | 617 int count) { |
618 SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0); | 618 SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0); |
619 SkASSERT(s.fInvKy == 0); | 619 SkASSERT(s.fInvKy == 0); |
620 SkASSERT(count > 0 && colors != NULL); | 620 SkASSERT(count > 0 && colors != NULL); |
621 SkASSERT(SkPaint::kNone_FilterLevel == s.fFilterLevel); | 621 SkASSERT(kNone_SkFilterQuality == s.fFilterLevel); |
622 | 622 |
623 const int stopX = s.fBitmap->width(); | 623 const int stopX = s.fBitmap->width(); |
624 const int stopY = s.fBitmap->height(); | 624 const int stopY = s.fBitmap->height(); |
625 int ix = s.fFilterOneX + x; | 625 int ix = s.fFilterOneX + x; |
626 int iy = sk_int_mod(s.fFilterOneY + y, stopY); | 626 int iy = sk_int_mod(s.fFilterOneY + y, stopY); |
627 #ifdef SK_DEBUG | 627 #ifdef SK_DEBUG |
628 { | 628 { |
629 SkPoint pt; | 629 SkPoint pt; |
630 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, | 630 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, |
631 SkIntToScalar(y) + SK_ScalarHalf, &pt); | 631 SkIntToScalar(y) + SK_ScalarHalf, &pt); |
(...skipping 25 matching lines...) Expand all Loading... |
657 int count) { | 657 int count) { |
658 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask))
== 0); | 658 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask))
== 0); |
659 SkASSERT(s.fInvKy == 0); | 659 SkASSERT(s.fInvKy == 0); |
660 SkASSERT(count > 0 && colors != NULL); | 660 SkASSERT(count > 0 && colors != NULL); |
661 SkASSERT(1 == s.fBitmap->width()); | 661 SkASSERT(1 == s.fBitmap->width()); |
662 | 662 |
663 int iY0; | 663 int iY0; |
664 int iY1 SK_INIT_TO_AVOID_WARNING; | 664 int iY1 SK_INIT_TO_AVOID_WARNING; |
665 int iSubY SK_INIT_TO_AVOID_WARNING; | 665 int iSubY SK_INIT_TO_AVOID_WARNING; |
666 | 666 |
667 if (SkPaint::kNone_FilterLevel != s.fFilterLevel) { | 667 if (kNone_SkFilterQuality != s.fFilterLevel) { |
668 SkBitmapProcState::MatrixProc mproc = s.getMatrixProc(); | 668 SkBitmapProcState::MatrixProc mproc = s.getMatrixProc(); |
669 uint32_t xy[2]; | 669 uint32_t xy[2]; |
670 | 670 |
671 mproc(s, xy, 1, x, y); | 671 mproc(s, xy, 1, x, y); |
672 | 672 |
673 iY0 = xy[0] >> 18; | 673 iY0 = xy[0] >> 18; |
674 iY1 = xy[0] & 0x3FFF; | 674 iY1 = xy[0] & 0x3FFF; |
675 iSubY = (xy[0] >> 14) & 0xF; | 675 iSubY = (xy[0] >> 14) & 0xF; |
676 } else { | 676 } else { |
677 int yTemp; | 677 int yTemp; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 } | 738 } |
739 | 739 |
740 SkASSERT(iY0 == iY2); | 740 SkASSERT(iY0 == iY2); |
741 } | 741 } |
742 #endif | 742 #endif |
743 } | 743 } |
744 | 744 |
745 const SkPMColor* row0 = s.fBitmap->getAddr32(0, iY0); | 745 const SkPMColor* row0 = s.fBitmap->getAddr32(0, iY0); |
746 SkPMColor color; | 746 SkPMColor color; |
747 | 747 |
748 if (SkPaint::kNone_FilterLevel != s.fFilterLevel) { | 748 if (kNone_SkFilterQuality != s.fFilterLevel) { |
749 const SkPMColor* row1 = s.fBitmap->getAddr32(0, iY1); | 749 const SkPMColor* row1 = s.fBitmap->getAddr32(0, iY1); |
750 | 750 |
751 if (s.fAlphaScale < 256) { | 751 if (s.fAlphaScale < 256) { |
752 Filter_32_alpha(iSubY, *row0, *row1, &color, s.fAlphaScale); | 752 Filter_32_alpha(iSubY, *row0, *row1, &color, s.fAlphaScale); |
753 } else { | 753 } else { |
754 Filter_32_opaque(iSubY, *row0, *row1, &color); | 754 Filter_32_opaque(iSubY, *row0, *row1, &color); |
755 } | 755 } |
756 } else { | 756 } else { |
757 if (s.fAlphaScale < 256) { | 757 if (s.fAlphaScale < 256) { |
758 color = SkAlphaMulQ(*row0, s.fAlphaScale); | 758 color = SkAlphaMulQ(*row0, s.fAlphaScale); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 | 794 |
795 SkBitmapProcState::ShaderProc32 SkBitmapProcState::chooseShaderProc32() { | 795 SkBitmapProcState::ShaderProc32 SkBitmapProcState::chooseShaderProc32() { |
796 | 796 |
797 if (kN32_SkColorType != fBitmap->colorType()) { | 797 if (kN32_SkColorType != fBitmap->colorType()) { |
798 return NULL; | 798 return NULL; |
799 } | 799 } |
800 | 800 |
801 static const unsigned kMask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_M
ask; | 801 static const unsigned kMask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_M
ask; |
802 | 802 |
803 if (1 == fBitmap->width() && 0 == (fInvType & ~kMask)) { | 803 if (1 == fBitmap->width() && 0 == (fInvType & ~kMask)) { |
804 if (SkPaint::kNone_FilterLevel == fFilterLevel && | 804 if (kNone_SkFilterQuality == fFilterLevel && |
805 fInvType <= SkMatrix::kTranslate_Mask && | 805 fInvType <= SkMatrix::kTranslate_Mask && |
806 !this->setupForTranslate()) { | 806 !this->setupForTranslate()) { |
807 return DoNothing_shaderproc; | 807 return DoNothing_shaderproc; |
808 } | 808 } |
809 return S32_D32_constX_shaderproc; | 809 return S32_D32_constX_shaderproc; |
810 } | 810 } |
811 | 811 |
812 if (fAlphaScale < 256) { | 812 if (fAlphaScale < 256) { |
813 return NULL; | 813 return NULL; |
814 } | 814 } |
815 if (fInvType > SkMatrix::kTranslate_Mask) { | 815 if (fInvType > SkMatrix::kTranslate_Mask) { |
816 return NULL; | 816 return NULL; |
817 } | 817 } |
818 if (SkPaint::kNone_FilterLevel != fFilterLevel) { | 818 if (kNone_SkFilterQuality != fFilterLevel) { |
819 return NULL; | 819 return NULL; |
820 } | 820 } |
821 | 821 |
822 SkShader::TileMode tx = (SkShader::TileMode)fTileModeX; | 822 SkShader::TileMode tx = (SkShader::TileMode)fTileModeX; |
823 SkShader::TileMode ty = (SkShader::TileMode)fTileModeY; | 823 SkShader::TileMode ty = (SkShader::TileMode)fTileModeY; |
824 | 824 |
825 if (SkShader::kClamp_TileMode == tx && SkShader::kClamp_TileMode == ty) { | 825 if (SkShader::kClamp_TileMode == tx && SkShader::kClamp_TileMode == ty) { |
826 if (this->setupForTranslate()) { | 826 if (this->setupForTranslate()) { |
827 return Clamp_S32_D32_nofilter_trans_shaderproc; | 827 return Clamp_S32_D32_nofilter_trans_shaderproc; |
828 } | 828 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 SkASSERT(count > 0); | 904 SkASSERT(count > 0); |
905 | 905 |
906 state.fMatrixProc(state, bitmapXY, count, x, y); | 906 state.fMatrixProc(state, bitmapXY, count, x, y); |
907 | 907 |
908 void (*proc)(uint32_t bitmapXY[], int count, unsigned mx, unsigned my); | 908 void (*proc)(uint32_t bitmapXY[], int count, unsigned mx, unsigned my); |
909 | 909 |
910 // There are four formats possible: | 910 // There are four formats possible: |
911 // scale -vs- affine | 911 // scale -vs- affine |
912 // filter -vs- nofilter | 912 // filter -vs- nofilter |
913 if (state.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { | 913 if (state.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { |
914 proc = state.fFilterLevel != SkPaint::kNone_FilterLevel ? check_scale_fi
lter : check_scale_nofilter; | 914 proc = state.fFilterLevel != kNone_SkFilterQuality ? check_scale_filter
: check_scale_nofilter; |
915 } else { | 915 } else { |
916 proc = state.fFilterLevel != SkPaint::kNone_FilterLevel ? check_affine_f
ilter : check_affine_nofilter; | 916 proc = state.fFilterLevel != kNone_SkFilterQuality ? check_affine_filter
: check_affine_nofilter; |
917 } | 917 } |
918 proc(bitmapXY, count, state.fBitmap->width(), state.fBitmap->height()); | 918 proc(bitmapXY, count, state.fBitmap->width(), state.fBitmap->height()); |
919 } | 919 } |
920 | 920 |
921 SkBitmapProcState::MatrixProc SkBitmapProcState::getMatrixProc() const { | 921 SkBitmapProcState::MatrixProc SkBitmapProcState::getMatrixProc() const { |
922 return DebugMatrixProc; | 922 return DebugMatrixProc; |
923 } | 923 } |
924 | 924 |
925 #endif | 925 #endif |
926 | 926 |
(...skipping 14 matching lines...) Expand all Loading... |
941 if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { | 941 if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { |
942 size -= 4; // the shared Y (or YY) coordinate | 942 size -= 4; // the shared Y (or YY) coordinate |
943 if (size < 0) { | 943 if (size < 0) { |
944 size = 0; | 944 size = 0; |
945 } | 945 } |
946 size >>= 1; | 946 size >>= 1; |
947 } else { | 947 } else { |
948 size >>= 2; | 948 size >>= 2; |
949 } | 949 } |
950 | 950 |
951 if (fFilterLevel != SkPaint::kNone_FilterLevel) { | 951 if (fFilterLevel != kNone_SkFilterQuality) { |
952 size >>= 1; | 952 size >>= 1; |
953 } | 953 } |
954 | 954 |
955 return size; | 955 return size; |
956 } | 956 } |
957 | 957 |
958 /////////////////////// | 958 /////////////////////// |
959 | 959 |
960 void Clamp_S32_opaque_D32_nofilter_DX_shaderproc(const SkBitmapProcState& s, in
t x, int y, | 960 void Clamp_S32_opaque_D32_nofilter_DX_shaderproc(const SkBitmapProcState& s, in
t x, int y, |
961 SkPMColor* SK_RESTRICT dst, in
t count) { | 961 SkPMColor* SK_RESTRICT dst, in
t count) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1002 fx += dx; | 1002 fx += dx; |
1003 } | 1003 } |
1004 } else { | 1004 } else { |
1005 for (int i = 0; i < count; ++i) { | 1005 for (int i = 0; i < count; ++i) { |
1006 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; | 1006 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; |
1007 fx += dx; | 1007 fx += dx; |
1008 } | 1008 } |
1009 } | 1009 } |
1010 } | 1010 } |
1011 | 1011 |
OLD | NEW |