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

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

Issue 18978014: Working plumb of image scaling: (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Rework plumb to have filter quality as an enum, avoid allocating new purgable bitmap Created 7 years, 5 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
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 "SkBitmapProcState.h" 8 #include "SkBitmapProcState.h"
9 #include "SkColorPriv.h" 9 #include "SkColorPriv.h"
10 #include "SkFilterProc.h" 10 #include "SkFilterProc.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 84
85 /////////////////////////////////////////////////////////////////////////////// 85 ///////////////////////////////////////////////////////////////////////////////
86 86
87 static bool valid_for_filtering(unsigned dimension) { 87 static bool valid_for_filtering(unsigned dimension) {
88 // for filtering, width and height must fit in 14bits, since we use steal 88 // for filtering, width and height must fit in 14bits, since we use steal
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 void SkBitmapProcState::endContext() {
94 SkDELETE(fBitmapFilter);
95 }
96
93 bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { 97 bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) {
94 if (fOrigBitmap.width() == 0 || fOrigBitmap.height() == 0) { 98 if (fOrigBitmap.width() == 0 || fOrigBitmap.height() == 0) {
95 return false; 99 return false;
96 } 100 }
97 101
98 const SkMatrix* m; 102 const SkMatrix* m;
99 bool trivial_matrix = (inv.getType() & ~SkMatrix::kTranslate_Mask) == 0; 103 bool trivial_matrix = (inv.getType() & ~SkMatrix::kTranslate_Mask) == 0;
100 bool clamp_clamp = SkShader::kClamp_TileMode == fTileModeX && 104 bool clamp_clamp = SkShader::kClamp_TileMode == fTileModeX &&
101 SkShader::kClamp_TileMode == fTileModeY; 105 SkShader::kClamp_TileMode == fTileModeY;
102 106
103 if (clamp_clamp || trivial_matrix) { 107 if (clamp_clamp || trivial_matrix) {
104 m = &inv; 108 m = &inv;
105 } else { 109 } else {
106 fUnitInvMatrix = inv; 110 fUnitInvMatrix = inv;
107 fUnitInvMatrix.postIDiv(fOrigBitmap.width(), fOrigBitmap.height()); 111 fUnitInvMatrix.postIDiv(fOrigBitmap.width(), fOrigBitmap.height());
108 m = &fUnitInvMatrix; 112 m = &fUnitInvMatrix;
109 } 113 }
110 114
111 fBitmap = &fOrigBitmap; 115 fBitmap = &fOrigBitmap;
112 if (fOrigBitmap.hasMipMap()) { 116
113 int shift = fOrigBitmap.extractMipLevel(&fMipBitmap, 117 // Check to see if the transformation matrix is scaling up, and if
118 // the matrix is simple, and if the paint has high quality scaling
119 // turned on. If so, do the bitmap scale here and remove the scaling compon ent from the matrix.
120
121 uint32_t hqUpsampleMask = SkPaint::kFilterBitmap_Flag
122 | SkPaint::kHighQualityFilterBitmap_Flag
123 ;
124 if (inv.getType() == (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask) &&
125 (inv.getScaleX() < 1 || inv.getScaleY() < 1) &&
126 ((paint.getFlags() & hqUpsampleMask) == hqUpsampleMask) &&
127 fOrigBitmap.config() == SkBitmap::kARGB_8888_Config) {
128
129 // All the criteria are met; let's make a new bitmap.
130 fScaledBitmap.setConfig(SkBitmap::kARGB_8888_Config, fOrigBitmap.width() / inv.getScaleX(), fOrigBitmap.height() / inv.getScaleY());
reed1 2013/07/11 15:43:42 nit: line-wrap
reed1 2013/07/11 15:49:08 grrrr, this is tricky, since we have one predicate
humper 2013/07/11 16:03:03 Done.
131 fScaledBitmap.allocPixels();
132 fOrigBitmap.scale(&fScaledBitmap);
133 fBitmap = &fScaledBitmap;
134
135 // Now get rid of the scale factor from the matrix
136
137 if (m != &fUnitInvMatrix) {
138 fUnitInvMatrix = *m;
139 m = &fUnitInvMatrix;
140 }
141
142 // set the inv matrix type to translate-only; this should have
143 // the side-effect of disabling bitmap filtering also.
144
145 fUnitInvMatrix.setTranslate( 1/m->getScaleX() * m->getTranslateX(), 1/m- >getScaleY() * m->getTranslateY() );
reed1 2013/07/11 15:43:42 nit: line-wrap
humper 2013/07/11 16:03:03 Done.
146 } else if (!fBitmap->hasMipMap()) {
147 // Check to see if the transformation matrix is scaling *down*.
148 // If so, automatically build mipmaps
149
150 SkPoint v1, v2;
151
152 // guess if the matrix is scaling down by seeing what it does to two uni t vectors.
153
154 v1.fX = inv.getScaleX();
155 v1.fY = inv.getSkewY();
156
157 v2.fX = inv.getSkewX();
158 v2.fY = inv.getScaleY();
159
160 if (v1.fX * v1.fX + v1.fY * v1.fY > 1 ||
161 v2.fX * v2.fX + v2.fY * v2.fY > 1) {
162 fBitmap->buildMipMap();
163 }
164 }
165
166 if (fBitmap->hasMipMap()) {
167 int shift = fBitmap->extractMipLevel(&fMipBitmap,
114 SkScalarToFixed(m->getScaleX()), 168 SkScalarToFixed(m->getScaleX()),
115 SkScalarToFixed(m->getSkewY())); 169 SkScalarToFixed(m->getSkewY()));
116 170
117 if (shift > 0) { 171 if (shift > 0) {
118 if (m != &fUnitInvMatrix) { 172 if (m != &fUnitInvMatrix) {
119 fUnitInvMatrix = *m; 173 fUnitInvMatrix = *m;
120 m = &fUnitInvMatrix; 174 m = &fUnitInvMatrix;
121 } 175 }
122 176
123 SkScalar scale = SkFixedToScalar(SK_Fixed1 >> shift); 177 SkScalar scale = SkFixedToScalar(SK_Fixed1 >> shift);
(...skipping 25 matching lines...) Expand all
149 203
150 fInvMatrix = m; 204 fInvMatrix = m;
151 fInvProc = m->getMapXYProc(); 205 fInvProc = m->getMapXYProc();
152 fInvType = m->getType(); 206 fInvType = m->getType();
153 fInvSx = SkScalarToFixed(m->getScaleX()); 207 fInvSx = SkScalarToFixed(m->getScaleX());
154 fInvSxFractionalInt = SkScalarToFractionalInt(m->getScaleX()); 208 fInvSxFractionalInt = SkScalarToFractionalInt(m->getScaleX());
155 fInvKy = SkScalarToFixed(m->getSkewY()); 209 fInvKy = SkScalarToFixed(m->getSkewY());
156 fInvKyFractionalInt = SkScalarToFractionalInt(m->getSkewY()); 210 fInvKyFractionalInt = SkScalarToFractionalInt(m->getSkewY());
157 211
158 fAlphaScale = SkAlpha255To256(paint.getAlpha()); 212 fAlphaScale = SkAlpha255To256(paint.getAlpha());
213
214 fShaderProc32 = NULL;
215 fShaderProc16 = NULL;
216 fSampleProc32 = NULL;
217 fSampleProc16 = NULL;
159 218
160 // pick-up filtering from the paint, but only if the matrix is 219 // pick-up filtering from the paint, but only if the matrix is
161 // more complex than identity/translate (i.e. no need to pay the cost 220 // more complex than identity/translate (i.e. no need to pay the cost
162 // of filtering if we're not scaled etc.). 221 // of filtering if we're not scaled etc.).
163 // note: we explicitly check inv, since m might be scaled due to unitinv 222 // note: we explicitly check inv, since m might be scaled due to unitinv
164 // trickery, but we don't want to see that for this test 223 // trickery, but we don't want to see that for this test
165 fDoFilter = paint.isFilterBitmap() && 224
166 (fInvType > SkMatrix::kTranslate_Mask && 225 fFilterQuality = kNone_BitmapFilter;
167 valid_for_filtering(fBitmap->width() | fBitmap->height())); 226
168 227 if (paint.isFilterBitmap()) {
169 fShaderProc32 = NULL; 228 if ((paint.getFlags() & hqUpsampleMask) == hqUpsampleMask) {
170 fShaderProc16 = NULL; 229 // The paint wants high quality sampling, so let's try to do it.
171 fSampleProc32 = NULL; 230 fFilterQuality = kHQ_BitmapFilter;
172 fSampleProc16 = NULL; 231 fShaderProc32 = this->chooseBitmapFilterProc();
232 }
233
234 if (!fShaderProc32) {
235 // if no shader proc is set, either the caller didn't ask
236 // for high quality filtering (so we didn't try at all),
237 // or our attempt to install an HQ sampler failed.
238 // Attempt to use bilerp in either case.
239
240 // Only install bilerp if the matrix is "interesting" and
241 // the image has a suitable size.
242
243 if (fInvType > SkMatrix::kTranslate_Mask &&
reed1 2013/07/11 15:43:42 Shouldn't we perform this (not scaled enough to ju
reed1 2013/07/11 15:49:08 Ah, I see that you are *re*calling this logic afte
humper 2013/07/11 16:03:03 the valid_for_filtering function actually checks t
244 valid_for_filtering(fBitmap->width() | fBitmap->height())) {
245 fFilterQuality = kBilerp_BitmapFilter;
246 }
247 }
248 }
173 249
174 fMatrixProc = this->chooseMatrixProc(trivial_matrix); 250 fMatrixProc = this->chooseMatrixProc(trivial_matrix);
175 if (NULL == fMatrixProc) { 251 if (NULL == fMatrixProc) {
176 return false; 252 return false;
177 } 253 }
178 254
179 /////////////////////////////////////////////////////////////////////// 255 ///////////////////////////////////////////////////////////////////////
180 256
181 int index = 0; 257 int index = 0;
182 if (fAlphaScale < 256) { // note: this distinction is not used for D16 258 if (fAlphaScale < 256) { // note: this distinction is not used for D16
183 index |= 1; 259 index |= 1;
184 } 260 }
185 if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { 261 if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) {
186 index |= 2; 262 index |= 2;
187 } 263 }
188 if (fDoFilter) { 264 if (fFilterQuality != kNone_BitmapFilter) {
189 index |= 4; 265 index |= 4;
190 } 266 }
191 // bits 3,4,5 encoding the source bitmap format 267 // bits 3,4,5 encoding the source bitmap format
192 switch (fBitmap->config()) { 268 switch (fBitmap->config()) {
193 case SkBitmap::kARGB_8888_Config: 269 case SkBitmap::kARGB_8888_Config:
194 index |= 0; 270 index |= 0;
195 break; 271 break;
196 case SkBitmap::kRGB_565_Config: 272 case SkBitmap::kRGB_565_Config:
197 index |= 8; 273 index |= 8;
198 break; 274 break;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 fShaderProc16 = SK_ARM_NEON_WRAP(Repeat_S16_D16_filter_DX_shaderproc ); 371 fShaderProc16 = SK_ARM_NEON_WRAP(Repeat_S16_D16_filter_DX_shaderproc );
296 } 372 }
297 } else if (SK_ARM_NEON_WRAP(SI8_opaque_D32_filter_DX) == fSampleProc32 && cl amp_clamp) { 373 } else if (SK_ARM_NEON_WRAP(SI8_opaque_D32_filter_DX) == fSampleProc32 && cl amp_clamp) {
298 fShaderProc32 = SK_ARM_NEON_WRAP(Clamp_SI8_opaque_D32_filter_DX_shaderpr oc); 374 fShaderProc32 = SK_ARM_NEON_WRAP(Clamp_SI8_opaque_D32_filter_DX_shaderpr oc);
299 } 375 }
300 376
301 if (NULL == fShaderProc32) { 377 if (NULL == fShaderProc32) {
302 fShaderProc32 = this->chooseShaderProc32(); 378 fShaderProc32 = this->chooseShaderProc32();
303 } 379 }
304 380
305 if (NULL == fShaderProc32) {
306 fShaderProc32 = this->chooseBitmapFilterProc(paint);
307 }
308
309 // see if our platform has any accelerated overrides 381 // see if our platform has any accelerated overrides
310 this->platformProcs(); 382 this->platformProcs();
311 383
312 return true; 384 return true;
313 } 385 }
314 386
315 static void Clamp_S32_D32_nofilter_trans_shaderproc(const SkBitmapProcState& s, 387 static void Clamp_S32_D32_nofilter_trans_shaderproc(const SkBitmapProcState& s,
316 int x, int y, 388 int x, int y,
317 SkPMColor* SK_RESTRICT color s, 389 SkPMColor* SK_RESTRICT color s,
318 int count) { 390 int count) {
319 SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0); 391 SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0);
320 SkASSERT(s.fInvKy == 0); 392 SkASSERT(s.fInvKy == 0);
321 SkASSERT(count > 0 && colors != NULL); 393 SkASSERT(count > 0 && colors != NULL);
322 SkASSERT(!s.fDoFilter); 394 SkASSERT(s.fFilterQuality == kNone_BitmapFilter);
323 395
324 const int maxX = s.fBitmap->width() - 1; 396 const int maxX = s.fBitmap->width() - 1;
325 const int maxY = s.fBitmap->height() - 1; 397 const int maxY = s.fBitmap->height() - 1;
326 int ix = s.fFilterOneX + x; 398 int ix = s.fFilterOneX + x;
327 int iy = SkClampMax(s.fFilterOneY + y, maxY); 399 int iy = SkClampMax(s.fFilterOneY + y, maxY);
328 #ifdef SK_DEBUG 400 #ifdef SK_DEBUG
329 { 401 {
330 SkPoint pt; 402 SkPoint pt;
331 s.fInvProc(*s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, 403 s.fInvProc(*s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
332 SkIntToScalar(y) + SK_ScalarHalf, &pt); 404 SkIntToScalar(y) + SK_ScalarHalf, &pt);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 return x; 458 return x;
387 } 459 }
388 460
389 static void Repeat_S32_D32_nofilter_trans_shaderproc(const SkBitmapProcState& s, 461 static void Repeat_S32_D32_nofilter_trans_shaderproc(const SkBitmapProcState& s,
390 int x, int y, 462 int x, int y,
391 SkPMColor* SK_RESTRICT colo rs, 463 SkPMColor* SK_RESTRICT colo rs,
392 int count) { 464 int count) {
393 SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0); 465 SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0);
394 SkASSERT(s.fInvKy == 0); 466 SkASSERT(s.fInvKy == 0);
395 SkASSERT(count > 0 && colors != NULL); 467 SkASSERT(count > 0 && colors != NULL);
396 SkASSERT(!s.fDoFilter); 468 SkASSERT(s.fFilterQuality == kNone_BitmapFilter);
reed1 2013/07/11 15:43:42 nit: skia likes to place the literal on the left (
397 469
398 const int stopX = s.fBitmap->width(); 470 const int stopX = s.fBitmap->width();
399 const int stopY = s.fBitmap->height(); 471 const int stopY = s.fBitmap->height();
400 int ix = s.fFilterOneX + x; 472 int ix = s.fFilterOneX + x;
401 int iy = sk_int_mod(s.fFilterOneY + y, stopY); 473 int iy = sk_int_mod(s.fFilterOneY + y, stopY);
402 #ifdef SK_DEBUG 474 #ifdef SK_DEBUG
403 { 475 {
404 SkPoint pt; 476 SkPoint pt;
405 s.fInvProc(*s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, 477 s.fInvProc(*s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
406 SkIntToScalar(y) + SK_ScalarHalf, &pt); 478 SkIntToScalar(y) + SK_ScalarHalf, &pt);
(...skipping 25 matching lines...) Expand all
432 int count) { 504 int count) {
433 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) == 0); 505 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) == 0);
434 SkASSERT(s.fInvKy == 0); 506 SkASSERT(s.fInvKy == 0);
435 SkASSERT(count > 0 && colors != NULL); 507 SkASSERT(count > 0 && colors != NULL);
436 SkASSERT(1 == s.fBitmap->width()); 508 SkASSERT(1 == s.fBitmap->width());
437 509
438 int iY0; 510 int iY0;
439 int iY1 SK_INIT_TO_AVOID_WARNING; 511 int iY1 SK_INIT_TO_AVOID_WARNING;
440 int iSubY SK_INIT_TO_AVOID_WARNING; 512 int iSubY SK_INIT_TO_AVOID_WARNING;
441 513
442 if (s.fDoFilter) { 514 if (s.fFilterQuality != SkBitmapProcState::kNone_BitmapFilter) {
443 SkBitmapProcState::MatrixProc mproc = s.getMatrixProc(); 515 SkBitmapProcState::MatrixProc mproc = s.getMatrixProc();
444 uint32_t xy[2]; 516 uint32_t xy[2];
445 517
446 mproc(s, xy, 1, x, y); 518 mproc(s, xy, 1, x, y);
447 519
448 iY0 = xy[0] >> 18; 520 iY0 = xy[0] >> 18;
449 iY1 = xy[0] & 0x3FFF; 521 iY1 = xy[0] & 0x3FFF;
450 iSubY = (xy[0] >> 14) & 0xF; 522 iSubY = (xy[0] >> 14) & 0xF;
451 } else { 523 } else {
452 int yTemp; 524 int yTemp;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 } 585 }
514 586
515 SkASSERT(iY0 == iY2); 587 SkASSERT(iY0 == iY2);
516 } 588 }
517 #endif 589 #endif
518 } 590 }
519 591
520 const SkPMColor* row0 = s.fBitmap->getAddr32(0, iY0); 592 const SkPMColor* row0 = s.fBitmap->getAddr32(0, iY0);
521 SkPMColor color; 593 SkPMColor color;
522 594
523 if (s.fDoFilter) { 595 if (s.fFilterQuality != SkBitmapProcState::kNone_BitmapFilter) {
524 const SkPMColor* row1 = s.fBitmap->getAddr32(0, iY1); 596 const SkPMColor* row1 = s.fBitmap->getAddr32(0, iY1);
525 597
526 if (s.fAlphaScale < 256) { 598 if (s.fAlphaScale < 256) {
527 Filter_32_alpha(iSubY, *row0, *row1, &color, s.fAlphaScale); 599 Filter_32_alpha(iSubY, *row0, *row1, &color, s.fAlphaScale);
528 } else { 600 } else {
529 Filter_32_opaque(iSubY, *row0, *row1, &color); 601 Filter_32_opaque(iSubY, *row0, *row1, &color);
530 } 602 }
531 } else { 603 } else {
532 if (s.fAlphaScale < 256) { 604 if (s.fAlphaScale < 256) {
533 color = SkAlphaMulQ(*row0, s.fAlphaScale); 605 color = SkAlphaMulQ(*row0, s.fAlphaScale);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 641
570 SkBitmapProcState::ShaderProc32 SkBitmapProcState::chooseShaderProc32() { 642 SkBitmapProcState::ShaderProc32 SkBitmapProcState::chooseShaderProc32() {
571 643
572 if (SkBitmap::kARGB_8888_Config != fBitmap->config()) { 644 if (SkBitmap::kARGB_8888_Config != fBitmap->config()) {
573 return NULL; 645 return NULL;
574 } 646 }
575 647
576 static const unsigned kMask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_M ask; 648 static const unsigned kMask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_M ask;
577 649
578 if (1 == fBitmap->width() && 0 == (fInvType & ~kMask)) { 650 if (1 == fBitmap->width() && 0 == (fInvType & ~kMask)) {
579 if (!fDoFilter && fInvType <= SkMatrix::kTranslate_Mask && !this->setupF orTranslate()) { 651 if (fFilterQuality == kNone_BitmapFilter &&
652 fInvType <= SkMatrix::kTranslate_Mask &&
653 !this->setupForTranslate()) {
580 return DoNothing_shaderproc; 654 return DoNothing_shaderproc;
581 } 655 }
582 return S32_D32_constX_shaderproc; 656 return S32_D32_constX_shaderproc;
583 } 657 }
584 658
585 if (fAlphaScale < 256) { 659 if (fAlphaScale < 256) {
586 return NULL; 660 return NULL;
587 } 661 }
588 if (fInvType > SkMatrix::kTranslate_Mask) { 662 if (fInvType > SkMatrix::kTranslate_Mask) {
589 return NULL; 663 return NULL;
590 } 664 }
591 if (fDoFilter) { 665 if (fFilterQuality != kNone_BitmapFilter) {
592 return NULL; 666 return NULL;
593 } 667 }
594 668
595 SkShader::TileMode tx = (SkShader::TileMode)fTileModeX; 669 SkShader::TileMode tx = (SkShader::TileMode)fTileModeX;
596 SkShader::TileMode ty = (SkShader::TileMode)fTileModeY; 670 SkShader::TileMode ty = (SkShader::TileMode)fTileModeY;
597 671
598 if (SkShader::kClamp_TileMode == tx && SkShader::kClamp_TileMode == ty) { 672 if (SkShader::kClamp_TileMode == tx && SkShader::kClamp_TileMode == ty) {
599 if (this->setupForTranslate()) { 673 if (this->setupForTranslate()) {
600 return Clamp_S32_D32_nofilter_trans_shaderproc; 674 return Clamp_S32_D32_nofilter_trans_shaderproc;
601 } 675 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 SkASSERT(count > 0); 751 SkASSERT(count > 0);
678 752
679 state.fMatrixProc(state, bitmapXY, count, x, y); 753 state.fMatrixProc(state, bitmapXY, count, x, y);
680 754
681 void (*proc)(uint32_t bitmapXY[], int count, unsigned mx, unsigned my); 755 void (*proc)(uint32_t bitmapXY[], int count, unsigned mx, unsigned my);
682 756
683 // There are four formats possible: 757 // There are four formats possible:
684 // scale -vs- affine 758 // scale -vs- affine
685 // filter -vs- nofilter 759 // filter -vs- nofilter
686 if (state.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { 760 if (state.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) {
687 proc = state.fDoFilter ? check_scale_filter : check_scale_nofilter; 761 proc = state.fFilterQuality != kNone_BitmapFilter ? check_scale_filter : check_scale_nofilter;
688 } else { 762 } else {
689 proc = state.fDoFilter ? check_affine_filter : check_affine_nofilter; 763 proc = state.fFilterQuality != kNone_BitmapFilter ? check_affine_filter : check_affine_nofilter;
690 } 764 }
691 proc(bitmapXY, count, state.fBitmap->width(), state.fBitmap->height()); 765 proc(bitmapXY, count, state.fBitmap->width(), state.fBitmap->height());
692 } 766 }
693 767
694 SkBitmapProcState::MatrixProc SkBitmapProcState::getMatrixProc() const { 768 SkBitmapProcState::MatrixProc SkBitmapProcState::getMatrixProc() const {
695 return DebugMatrixProc; 769 return DebugMatrixProc;
696 } 770 }
697 771
698 #endif 772 #endif
699 773
(...skipping 14 matching lines...) Expand all
714 if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { 788 if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) {
715 size -= 4; // the shared Y (or YY) coordinate 789 size -= 4; // the shared Y (or YY) coordinate
716 if (size < 0) { 790 if (size < 0) {
717 size = 0; 791 size = 0;
718 } 792 }
719 size >>= 1; 793 size >>= 1;
720 } else { 794 } else {
721 size >>= 2; 795 size >>= 2;
722 } 796 }
723 797
724 if (fDoFilter) { 798 if (fFilterQuality != kNone_BitmapFilter) {
725 size >>= 1; 799 size >>= 1;
726 } 800 }
727 801
728 return size; 802 return size;
729 } 803 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698