| 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 SkScaledImageCache::Unlock(fScaledCacheID); | 274 SkScaledImageCache::Unlock(fScaledCacheID); |
| 275 } | 275 } |
| 276 SkDELETE(fBitmapFilter); | 276 SkDELETE(fBitmapFilter); |
| 277 } | 277 } |
| 278 | 278 |
| 279 bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { | 279 bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { |
| 280 if (fOrigBitmap.width() == 0 || fOrigBitmap.height() == 0) { | 280 if (fOrigBitmap.width() == 0 || fOrigBitmap.height() == 0) { |
| 281 return false; | 281 return false; |
| 282 } | 282 } |
| 283 | 283 |
| 284 bool trivialMatrix = (inv.getType() & ~SkMatrix::kTranslate_Mask) == 0; | 284 fBitmap = &fOrigBitmap; |
| 285 bool clampClamp = SkShader::kClamp_TileMode == fTileModeX && | |
| 286 SkShader::kClamp_TileMode == fTileModeY; | |
| 287 | |
| 288 fInvMatrix = inv; | 285 fInvMatrix = inv; |
| 289 if (!(clampClamp || trivialMatrix)) { | |
| 290 fInvMatrix.postIDiv(fOrigBitmap.width(), fOrigBitmap.height()); | |
| 291 } | |
| 292 | |
| 293 fBitmap = &fOrigBitmap; | |
| 294 | 286 |
| 295 // initialize our filter quality to the one requested by the caller. | 287 // initialize our filter quality to the one requested by the caller. |
| 296 // We may downgrade it later if we determine that we either don't need | 288 // We may downgrade it later if we determine that we either don't need |
| 297 // or can't provide as high a quality filtering as the user requested. | 289 // or can't provide as high a quality filtering as the user requested. |
| 298 | 290 |
| 299 fFilterLevel = paint.getFilterLevel(); | 291 fFilterLevel = paint.getFilterLevel(); |
| 300 | 292 |
| 301 #ifndef SK_IGNORE_IMAGE_PRESCALE | 293 #ifndef SK_IGNORE_IMAGE_PRESCALE |
| 302 // possiblyScaleImage will look to see if it can rescale the image as a | 294 // possiblyScaleImage will look to see if it can rescale the image as a |
| 303 // preprocess; either by scaling up to the target size, or by selecting | 295 // preprocess; either by scaling up to the target size, or by selecting |
| 304 // a nearby mipmap level. If it does, it will adjust the working | 296 // a nearby mipmap level. If it does, it will adjust the working |
| 305 // matrix as well as the working bitmap. It may also adjust the filter | 297 // matrix as well as the working bitmap. It may also adjust the filter |
| 306 // quality to avoid re-filtering an already perfectly scaled image. | 298 // quality to avoid re-filtering an already perfectly scaled image. |
| 307 | 299 |
| 308 this->possiblyScaleImage(); | 300 this->possiblyScaleImage(); |
| 309 #endif | 301 #endif |
| 310 | 302 |
| 303 bool trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) ==
0; |
| 304 bool clampClamp = SkShader::kClamp_TileMode == fTileModeX && |
| 305 SkShader::kClamp_TileMode == fTileModeY; |
| 306 |
| 307 if (!(clampClamp || trivialMatrix)) { |
| 308 fInvMatrix.postIDiv(fOrigBitmap.width(), fOrigBitmap.height()); |
| 309 } |
| 310 |
| 311 // Now that all possible changes to the matrix have taken place, check | 311 // Now that all possible changes to the matrix have taken place, check |
| 312 // to see if we're really close to a no-scale matrix. If so, explicitly | 312 // to see if we're really close to a no-scale matrix. If so, explicitly |
| 313 // set it to be so. Subsequent code may inspect this matrix to choose | 313 // set it to be so. Subsequent code may inspect this matrix to choose |
| 314 // a faster path in this case. | 314 // a faster path in this case. |
| 315 | 315 |
| 316 // This code will only execute if the matrix has some scale component; | 316 // This code will only execute if the matrix has some scale component; |
| 317 // if it's already pure translate then we won't do this inversion. | 317 // if it's already pure translate then we won't do this inversion. |
| 318 | 318 |
| 319 if (matrix_only_scale_translate(fInvMatrix)) { | 319 if (matrix_only_scale_translate(fInvMatrix)) { |
| 320 SkMatrix forward; | 320 SkMatrix forward; |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 } else { | 934 } else { |
| 935 size >>= 2; | 935 size >>= 2; |
| 936 } | 936 } |
| 937 | 937 |
| 938 if (fFilterLevel != SkPaint::kNone_FilterLevel) { | 938 if (fFilterLevel != SkPaint::kNone_FilterLevel) { |
| 939 size >>= 1; | 939 size >>= 1; |
| 940 } | 940 } |
| 941 | 941 |
| 942 return size; | 942 return size; |
| 943 } | 943 } |
| OLD | NEW |