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

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

Issue 1668033002: don't get dismayed by negative scales for HQ (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add guard Created 4 years, 10 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
« 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 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkBitmapController.h" 9 #include "SkBitmapController.h"
10 #include "SkBitmapProvider.h" 10 #include "SkBitmapProvider.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 // scaling by the given inverted matrix is less than the maximum allowed. 58 // scaling by the given inverted matrix is less than the maximum allowed.
59 static inline bool cache_size_okay(const SkBitmapProvider& provider, const SkMat rix& invMat) { 59 static inline bool cache_size_okay(const SkBitmapProvider& provider, const SkMat rix& invMat) {
60 size_t maximumAllocation = SkResourceCache::GetEffectiveSingleAllocationByte Limit(); 60 size_t maximumAllocation = SkResourceCache::GetEffectiveSingleAllocationByte Limit();
61 if (0 == maximumAllocation) { 61 if (0 == maximumAllocation) {
62 return true; 62 return true;
63 } 63 }
64 // float matrixScaleFactor = 1.0 / (invMat.scaleX * invMat.scaleY); 64 // float matrixScaleFactor = 1.0 / (invMat.scaleX * invMat.scaleY);
65 // return ((origBitmapSize * matrixScaleFactor) < maximumAllocationSize); 65 // return ((origBitmapSize * matrixScaleFactor) < maximumAllocationSize);
66 // Skip the division step: 66 // Skip the division step:
67 const size_t size = provider.info().getSafeSize(provider.info().minRowBytes( )); 67 const size_t size = provider.info().getSafeSize(provider.info().minRowBytes( ));
68 return size < (maximumAllocation * invMat.getScaleX() * invMat.getScaleY()); 68 SkScalar invScaleSqr = invMat.getScaleX() * invMat.getScaleY();
vmpstr 2016/02/04 17:56:07 I forgot to mention this, but there's another smal
69 #ifndef SK_SUPPORT_LEGACY_NEG_SCALE_HQ
70 invScaleSqr = SkScalarAbs(invScaleSqr);
71 #endif
72 return size < (maximumAllocation * invScaleSqr);
69 } 73 }
70 74
71 /* 75 /*
72 * High quality is implemented by performing up-right scale-only filtering and then 76 * High quality is implemented by performing up-right scale-only filtering and then
73 * using bilerp for any remaining transformations. 77 * using bilerp for any remaining transformations.
74 */ 78 */
75 bool SkDefaultBitmapControllerState::processHQRequest(const SkBitmapProvider& pr ovider) { 79 bool SkDefaultBitmapControllerState::processHQRequest(const SkBitmapProvider& pr ovider) {
76 if (fQuality != kHigh_SkFilterQuality) { 80 if (fQuality != kHigh_SkFilterQuality) {
77 return false; 81 return false;
78 } 82 }
(...skipping 11 matching lines...) Expand all
90 SkScalar invScaleX = fInvMatrix.getScaleX(); 94 SkScalar invScaleX = fInvMatrix.getScaleX();
91 SkScalar invScaleY = fInvMatrix.getScaleY(); 95 SkScalar invScaleY = fInvMatrix.getScaleY();
92 if (fInvMatrix.getType() & SkMatrix::kAffine_Mask) { 96 if (fInvMatrix.getType() & SkMatrix::kAffine_Mask) {
93 SkSize scale; 97 SkSize scale;
94 if (!fInvMatrix.decomposeScale(&scale)) { 98 if (!fInvMatrix.decomposeScale(&scale)) {
95 return false; 99 return false;
96 } 100 }
97 invScaleX = scale.width(); 101 invScaleX = scale.width();
98 invScaleY = scale.height(); 102 invScaleY = scale.height();
99 } 103 }
104 #ifndef SK_SUPPORT_LEGACY_NEG_SCALE_HQ
105 invScaleX = SkScalarAbs(invScaleX);
106 invScaleY = SkScalarAbs(invScaleY);
107 #endif
108
100 if (SkScalarNearlyEqual(invScaleX, 1) && SkScalarNearlyEqual(invScaleY, 1)) { 109 if (SkScalarNearlyEqual(invScaleX, 1) && SkScalarNearlyEqual(invScaleY, 1)) {
101 return false; // no need for HQ 110 return false; // no need for HQ
102 } 111 }
103 112
104 #ifndef SK_SUPPORT_LEGACY_HQ_DOWNSAMPLING 113 #ifndef SK_SUPPORT_LEGACY_HQ_DOWNSAMPLING
105 if (invScaleX > 1 || invScaleY > 1) { 114 if (invScaleX > 1 || invScaleY > 1) {
106 return false; // only use HQ when upsampling 115 return false; // only use HQ when upsampling
107 } 116 }
108 #endif 117 #endif
109 118
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 fResultBitmap.getColorTable()); 229 fResultBitmap.getColorTable());
221 } 230 }
222 231
223 SkBitmapController::State* SkDefaultBitmapController::onRequestBitmap(const SkBi tmapProvider& bm, 232 SkBitmapController::State* SkDefaultBitmapController::onRequestBitmap(const SkBi tmapProvider& bm,
224 const SkMa trix& inverse, 233 const SkMa trix& inverse,
225 SkFilterQu ality quality, 234 SkFilterQu ality quality,
226 void* stor age, size_t size) { 235 void* stor age, size_t size) {
227 return SkInPlaceNewCheck<SkDefaultBitmapControllerState>(storage, size, bm, inverse, quality); 236 return SkInPlaceNewCheck<SkDefaultBitmapControllerState>(storage, size, bm, inverse, quality);
228 } 237 }
229 238
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