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 "SkBitmapProcState.h" | 9 #include "SkBitmapProcState.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 // Check to see if the transformation matrix is simple, and if we're | 137 // Check to see if the transformation matrix is simple, and if we're |
138 // doing high quality scaling. If so, do the bitmap scale here and | 138 // doing high quality scaling. If so, do the bitmap scale here and |
139 // remove the (non-fractional) scaling component from the matrix. | 139 // remove the (non-fractional) scaling component from the matrix. |
140 | 140 |
141 SkScalar invScaleX = fInvMatrix.getScaleX(); | 141 SkScalar invScaleX = fInvMatrix.getScaleX(); |
142 SkScalar invScaleY = fInvMatrix.getScaleY(); | 142 SkScalar invScaleY = fInvMatrix.getScaleY(); |
143 | 143 |
144 float trueDestWidth = fOrigBitmap.width() / invScaleX; | 144 float trueDestWidth = fOrigBitmap.width() / invScaleX; |
145 float trueDestHeight = fOrigBitmap.height() / invScaleY; | 145 float trueDestHeight = fOrigBitmap.height() / invScaleY; |
146 | 146 |
147 #ifndef SK_IGNORE_PROPER_FRACTIONAL_SCALING | |
148 float roundedDestWidth = SkScalarRoundToScalar(trueDestWidth); | 147 float roundedDestWidth = SkScalarRoundToScalar(trueDestWidth); |
reed1
2014/10/29 17:35:03
future nit: these should be SkScalar instead of fl
| |
149 float roundedDestHeight = SkScalarRoundToScalar(trueDestHeight); | 148 float roundedDestHeight = SkScalarRoundToScalar(trueDestHeight); |
150 #else | |
151 float roundedDestWidth = trueDestWidth; | |
152 float roundedDestHeight = trueDestHeight; | |
153 #endif | |
154 | 149 |
155 if (SkPaint::kHigh_FilterLevel == fFilterLevel && | 150 if (SkPaint::kHigh_FilterLevel == fFilterLevel && |
156 fInvMatrix.getType() <= (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Ma sk) && | 151 fInvMatrix.getType() <= (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Ma sk) && |
157 kN32_SkColorType == fOrigBitmap.colorType() && | 152 kN32_SkColorType == fOrigBitmap.colorType() && |
158 cache_size_okay(fOrigBitmap, fInvMatrix)) { | 153 cache_size_okay(fOrigBitmap, fInvMatrix)) { |
159 | 154 |
160 if (SkScalarNearlyEqual(invScaleX,1.0f) && | 155 if (SkScalarNearlyEqual(invScaleX,1.0f) && |
161 SkScalarNearlyEqual(invScaleY,1.0f)) { | 156 SkScalarNearlyEqual(invScaleY,1.0f)) { |
162 // short-circuit identity scaling; the output is supposed to | 157 // short-circuit identity scaling; the output is supposed to |
163 // be the same as the input, so we might as well go fast. | 158 // be the same as the input, so we might as well go fast. |
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1067 fx += dx; | 1062 fx += dx; |
1068 } | 1063 } |
1069 } else { | 1064 } else { |
1070 for (int i = 0; i < count; ++i) { | 1065 for (int i = 0; i < count; ++i) { |
1071 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; | 1066 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; |
1072 fx += dx; | 1067 fx += dx; |
1073 } | 1068 } |
1074 } | 1069 } |
1075 } | 1070 } |
1076 | 1071 |
OLD | NEW |