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

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

Issue 1605193002: change kMedium_SkFilterQuality to never pop if we're scaling (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 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 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 "SkBitmapController.h" 9 #include "SkBitmapController.h"
10 #include "SkBitmapProcState.h" 10 #include "SkBitmapProcState.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 * - else we downgrade to the next lower level and try again. 126 * - else we downgrade to the next lower level and try again.
127 * We can always fulfill requests for Low and None 127 * We can always fulfill requests for Low and None
128 * - sometimes we will "ignore" Low and give None, but this is likely a legacy perf hack 128 * - sometimes we will "ignore" Low and give None, but this is likely a legacy perf hack
129 * and may be removed. 129 * and may be removed.
130 */ 130 */
131 bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { 131 bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) {
132 fPixmap.reset(); 132 fPixmap.reset();
133 fInvMatrix = inv; 133 fInvMatrix = inv;
134 fFilterLevel = paint.getFilterQuality(); 134 fFilterLevel = paint.getFilterQuality();
135 135
136 const int origW = fProvider.info().width();
137 const int origH = fProvider.info().height();
138 bool allow_ignore_fractional_translate = true; // historical default
139 #ifndef SK_SUPPORT_LEGACY_TRANSLATEROUNDHACK
140 if (kMedium_SkFilterQuality == fFilterLevel) {
141 allow_ignore_fractional_translate = false;
142 }
143 #endif
144
136 SkDefaultBitmapController controller; 145 SkDefaultBitmapController controller;
137 fBMState = controller.requestBitmap(fProvider, inv, paint.getFilterQuality() , 146 fBMState = controller.requestBitmap(fProvider, inv, paint.getFilterQuality() ,
138 fBMStateStorage.get(), fBMStateStorage.s ize()); 147 fBMStateStorage.get(), fBMStateStorage.s ize());
139 // Note : we allow the controller to return an empty (zero-dimension) result . Should we? 148 // Note : we allow the controller to return an empty (zero-dimension) result . Should we?
140 if (nullptr == fBMState || fBMState->pixmap().info().isEmpty()) { 149 if (nullptr == fBMState || fBMState->pixmap().info().isEmpty()) {
141 return false; 150 return false;
142 } 151 }
143 fPixmap = fBMState->pixmap(); 152 fPixmap = fBMState->pixmap();
144 fInvMatrix = fBMState->invMatrix(); 153 fInvMatrix = fBMState->invMatrix();
145 fFilterLevel = fBMState->quality(); 154 fFilterLevel = fBMState->quality();
(...skipping 18 matching lines...) Expand all
164 // to see if we're really close to a no-scale matrix. If so, explicitly 173 // to see if we're really close to a no-scale matrix. If so, explicitly
165 // set it to be so. Subsequent code may inspect this matrix to choose 174 // set it to be so. Subsequent code may inspect this matrix to choose
166 // a faster path in this case. 175 // a faster path in this case.
167 176
168 // This code will only execute if the matrix has some scale component; 177 // This code will only execute if the matrix has some scale component;
169 // if it's already pure translate then we won't do this inversion. 178 // if it's already pure translate then we won't do this inversion.
170 179
171 if (matrix_only_scale_translate(fInvMatrix)) { 180 if (matrix_only_scale_translate(fInvMatrix)) {
172 SkMatrix forward; 181 SkMatrix forward;
173 if (fInvMatrix.invert(&forward)) { 182 if (fInvMatrix.invert(&forward)) {
174 if (clampClamp ? just_trans_clamp(forward, fPixmap) 183 if ((clampClamp && allow_ignore_fractional_translate)
184 ? just_trans_clamp(forward, fPixmap)
175 : just_trans_general(forward)) { 185 : just_trans_general(forward)) {
176 #ifdef SK_SUPPORT_LEGACY_TRANSLATEROUNDHACK 186 #ifdef SK_SUPPORT_LEGACY_TRANSLATEROUNDHACK
177 SkScalar tx = -SkScalarRoundToScalar(forward.getTranslateX()); 187 SkScalar tx = -SkScalarRoundToScalar(forward.getTranslateX());
178 SkScalar ty = -SkScalarRoundToScalar(forward.getTranslateY()); 188 SkScalar ty = -SkScalarRoundToScalar(forward.getTranslateY());
179 fInvMatrix.setTranslate(tx, ty); 189 fInvMatrix.setTranslate(tx, ty);
180 #else 190 #else
181 fInvMatrix.setTranslate(-forward.getTranslateX(), -forward.getTr anslateY()); 191 fInvMatrix.setTranslate(-forward.getTranslateX(), -forward.getTr anslateY());
182 #endif 192 #endif
183 } 193 }
184 } 194 }
(...skipping 10 matching lines...) Expand all
195 205
196 fShaderProc32 = nullptr; 206 fShaderProc32 = nullptr;
197 fShaderProc16 = nullptr; 207 fShaderProc16 = nullptr;
198 fSampleProc32 = nullptr; 208 fSampleProc32 = nullptr;
199 209
200 // recompute the triviality of the matrix here because we may have 210 // recompute the triviality of the matrix here because we may have
201 // changed it! 211 // changed it!
202 212
203 trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0; 213 trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0;
204 214
205 if (kLow_SkFilterQuality == fFilterLevel) { 215 // If our target pixmap is the same as the original, then we revert back to legacy behavior
216 // and allow the code to ignore fractional translate.
217 //
218 // The width/height check allows allow_ignore_fractional_translate to stay f alse if we
219 // previously set it that way (e.g. we started in kMedium).
220 //
221 if (fPixmap.width() == origW && fPixmap.height() == origH) {
222 allow_ignore_fractional_translate = true;
223 }
224
225 if (kLow_SkFilterQuality == fFilterLevel && allow_ignore_fractional_translat e) {
206 // Only try bilerp if the matrix is "interesting" and 226 // Only try bilerp if the matrix is "interesting" and
207 // the image has a suitable size. 227 // the image has a suitable size.
208 228
209 if (fInvType <= SkMatrix::kTranslate_Mask || 229 if (fInvType <= SkMatrix::kTranslate_Mask ||
210 !valid_for_filtering(fPixmap.width() | fPixmap.height())) 230 !valid_for_filtering(fPixmap.width() | fPixmap.height()))
211 { 231 {
212 fFilterLevel = kNone_SkFilterQuality; 232 fFilterLevel = kNone_SkFilterQuality;
213 } 233 }
214 } 234 }
215 235
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 fx += dx; 823 fx += dx;
804 } 824 }
805 } else { 825 } else {
806 for (int i = 0; i < count; ++i) { 826 for (int i = 0; i < count; ++i) {
807 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; 827 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)];
808 fx += dx; 828 fx += dx;
809 } 829 }
810 } 830 }
811 } 831 }
812 832
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