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

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

Issue 23470005: move decision to smash invmatrix into unit-space (for faster repeat/mirror to after the call to pos… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 7 years, 3 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 | « no previous file | no next file » | 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 "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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698