| OLD | NEW |
| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(); | 136 const int origW = fProvider.info().width(); |
| 137 const int origH = fProvider.info().height(); | 137 const int origH = fProvider.info().height(); |
| 138 bool allow_ignore_fractional_translate = true; // historical default | 138 bool allow_ignore_fractional_translate = true; // historical default |
| 139 #ifndef SK_SUPPORT_LEGACY_TRANSLATEROUNDHACK | |
| 140 if (kMedium_SkFilterQuality == fFilterLevel) { | 139 if (kMedium_SkFilterQuality == fFilterLevel) { |
| 141 allow_ignore_fractional_translate = false; | 140 allow_ignore_fractional_translate = false; |
| 142 } | 141 } |
| 143 #endif | |
| 144 | 142 |
| 145 SkDefaultBitmapController controller; | 143 SkDefaultBitmapController controller; |
| 146 fBMState = controller.requestBitmap(fProvider, inv, paint.getFilterQuality()
, | 144 fBMState = controller.requestBitmap(fProvider, inv, paint.getFilterQuality()
, |
| 147 fBMStateStorage.get(), fBMStateStorage.s
ize()); | 145 fBMStateStorage.get(), fBMStateStorage.s
ize()); |
| 148 // Note : we allow the controller to return an empty (zero-dimension) result
. Should we? | 146 // Note : we allow the controller to return an empty (zero-dimension) result
. Should we? |
| 149 if (nullptr == fBMState || fBMState->pixmap().info().isEmpty()) { | 147 if (nullptr == fBMState || fBMState->pixmap().info().isEmpty()) { |
| 150 return false; | 148 return false; |
| 151 } | 149 } |
| 152 fPixmap = fBMState->pixmap(); | 150 fPixmap = fBMState->pixmap(); |
| 153 fInvMatrix = fBMState->invMatrix(); | 151 fInvMatrix = fBMState->invMatrix(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 176 | 174 |
| 177 // This code will only execute if the matrix has some scale component; | 175 // This code will only execute if the matrix has some scale component; |
| 178 // if it's already pure translate then we won't do this inversion. | 176 // if it's already pure translate then we won't do this inversion. |
| 179 | 177 |
| 180 if (matrix_only_scale_translate(fInvMatrix)) { | 178 if (matrix_only_scale_translate(fInvMatrix)) { |
| 181 SkMatrix forward; | 179 SkMatrix forward; |
| 182 if (fInvMatrix.invert(&forward)) { | 180 if (fInvMatrix.invert(&forward)) { |
| 183 if ((clampClamp && allow_ignore_fractional_translate) | 181 if ((clampClamp && allow_ignore_fractional_translate) |
| 184 ? just_trans_clamp(forward, fPixmap) | 182 ? just_trans_clamp(forward, fPixmap) |
| 185 : just_trans_general(forward)) { | 183 : just_trans_general(forward)) { |
| 186 #ifdef SK_SUPPORT_LEGACY_TRANSLATEROUNDHACK | |
| 187 SkScalar tx = -SkScalarRoundToScalar(forward.getTranslateX()); | |
| 188 SkScalar ty = -SkScalarRoundToScalar(forward.getTranslateY()); | |
| 189 fInvMatrix.setTranslate(tx, ty); | |
| 190 #else | |
| 191 fInvMatrix.setTranslate(-forward.getTranslateX(), -forward.getTr
anslateY()); | 184 fInvMatrix.setTranslate(-forward.getTranslateX(), -forward.getTr
anslateY()); |
| 192 #endif | |
| 193 } | 185 } |
| 194 } | 186 } |
| 195 } | 187 } |
| 196 | 188 |
| 197 fInvProc = fInvMatrix.getMapXYProc(); | 189 fInvProc = fInvMatrix.getMapXYProc(); |
| 198 fInvType = fInvMatrix.getType(); | 190 fInvType = fInvMatrix.getType(); |
| 199 fInvSx = SkScalarToFixed(fInvMatrix.getScaleX()); | 191 fInvSx = SkScalarToFixed(fInvMatrix.getScaleX()); |
| 200 fInvSxFractionalInt = SkScalarToFractionalInt(fInvMatrix.getScaleX()); | 192 fInvSxFractionalInt = SkScalarToFractionalInt(fInvMatrix.getScaleX()); |
| 201 fInvKy = SkScalarToFixed(fInvMatrix.getSkewY()); | 193 fInvKy = SkScalarToFixed(fInvMatrix.getSkewY()); |
| 202 fInvKyFractionalInt = SkScalarToFractionalInt(fInvMatrix.getSkewY()); | 194 fInvKyFractionalInt = SkScalarToFractionalInt(fInvMatrix.getSkewY()); |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 fx += dx; | 815 fx += dx; |
| 824 } | 816 } |
| 825 } else { | 817 } else { |
| 826 for (int i = 0; i < count; ++i) { | 818 for (int i = 0; i < count; ++i) { |
| 827 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; | 819 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; |
| 828 fx += dx; | 820 fx += dx; |
| 829 } | 821 } |
| 830 } | 822 } |
| 831 } | 823 } |
| 832 | 824 |
| OLD | NEW |