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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 v2.fX = mat.getSkewX(); | 107 v2.fX = mat.getSkewX(); |
108 v2.fY = mat.getScaleY(); | 108 v2.fY = mat.getScaleY(); |
109 | 109 |
110 return SkMaxScalar(v1.lengthSqd(), v2.lengthSqd()); | 110 return SkMaxScalar(v1.lengthSqd(), v2.lengthSqd()); |
111 } | 111 } |
112 | 112 |
113 // Check to see that the size of the bitmap that would be produced by | 113 // Check to see that the size of the bitmap that would be produced by |
114 // scaling by the given inverted matrix is less than the maximum allowed. | 114 // scaling by the given inverted matrix is less than the maximum allowed. |
115 static inline bool cache_size_okay(const SkBitmap& bm, const SkMatrix& invMat) { | 115 static inline bool cache_size_okay(const SkBitmap& bm, const SkMatrix& invMat) { |
116 size_t maximumAllocation = SkResourceCache::GetSingleAllocationByteLimit(); | 116 size_t maximumAllocation = SkResourceCache::GetEffectiveSingleAllocationByte
Limit(); |
117 if (0 == maximumAllocation) { | 117 if (0 == maximumAllocation) { |
118 return true; | 118 return true; |
119 } | 119 } |
120 // float matrixScaleFactor = 1.0 / (invMat.scaleX * invMat.scaleY); | 120 // float matrixScaleFactor = 1.0 / (invMat.scaleX * invMat.scaleY); |
121 // return ((origBitmapSize * matrixScaleFactor) < maximumAllocationSize); | 121 // return ((origBitmapSize * matrixScaleFactor) < maximumAllocationSize); |
122 // Skip the division step: | 122 // Skip the division step: |
123 return bm.info().getSafeSize(bm.info().minRowBytes()) | 123 return bm.info().getSafeSize(bm.info().minRowBytes()) |
124 < (maximumAllocation * invMat.getScaleX() * invMat.getScaleY()); | 124 < (maximumAllocation * invMat.getScaleX() * invMat.getScaleY()); |
125 } | 125 } |
126 | 126 |
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1035 fx += dx; | 1035 fx += dx; |
1036 } | 1036 } |
1037 } else { | 1037 } else { |
1038 for (int i = 0; i < count; ++i) { | 1038 for (int i = 0; i < count; ++i) { |
1039 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; | 1039 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; |
1040 fx += dx; | 1040 fx += dx; |
1041 } | 1041 } |
1042 } | 1042 } |
1043 } | 1043 } |
1044 | 1044 |
OLD | NEW |