| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 v1.fY = mat.getSkewY(); | 102 v1.fY = mat.getSkewY(); |
| 103 | 103 |
| 104 v2.fX = mat.getSkewX(); | 104 v2.fX = mat.getSkewX(); |
| 105 v2.fY = mat.getScaleY(); | 105 v2.fY = mat.getScaleY(); |
| 106 | 106 |
| 107 return SkMaxScalar(v1.lengthSqd(), v2.lengthSqd()); | 107 return SkMaxScalar(v1.lengthSqd(), v2.lengthSqd()); |
| 108 } | 108 } |
| 109 | 109 |
| 110 class AutoScaledCacheUnlocker { | 110 class AutoScaledCacheUnlocker { |
| 111 public: | 111 public: |
| 112 AutoScaledCacheUnlocker(SkScaledImageCache::ID** idPtr) : fIDPtr(idPtr) {} | 112 AutoScaledCacheUnlocker(SkScaledImageCache::ID* idPtr) : fIDPtr(idPtr) {} |
| 113 ~AutoScaledCacheUnlocker() { | 113 ~AutoScaledCacheUnlocker() { |
| 114 if (fIDPtr && *fIDPtr) { | 114 if (fIDPtr && *fIDPtr) { |
| 115 SkScaledImageCache::Unlock(*fIDPtr); | 115 SkScaledImageCache::Unlock(*fIDPtr); |
| 116 *fIDPtr = NULL; | 116 *fIDPtr = NULL; |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 // forgets the ID, so it won't call Unlock | 120 // forgets the ID, so it won't call Unlock |
| 121 void release() { | 121 void release() { |
| 122 fIDPtr = NULL; | 122 fIDPtr = NULL; |
| 123 } | 123 } |
| 124 | 124 |
| 125 private: | 125 private: |
| 126 SkScaledImageCache::ID** fIDPtr; | 126 SkScaledImageCache::ID* fIDPtr; |
| 127 }; | 127 }; |
| 128 #define AutoScaledCacheUnlocker(...) SK_REQUIRE_LOCAL_VAR(AutoScaledCacheUnlocke
r) | 128 #define AutoScaledCacheUnlocker(...) SK_REQUIRE_LOCAL_VAR(AutoScaledCacheUnlocke
r) |
| 129 | 129 |
| 130 // Check to see that the size of the bitmap that would be produced by | 130 // Check to see that the size of the bitmap that would be produced by |
| 131 // scaling by the given inverted matrix is less than the maximum allowed. | 131 // scaling by the given inverted matrix is less than the maximum allowed. |
| 132 static inline bool cache_size_okay(const SkBitmap& bm, const SkMatrix& invMat) { | 132 static inline bool cache_size_okay(const SkBitmap& bm, const SkMatrix& invMat) { |
| 133 size_t maximumAllocation | 133 size_t maximumAllocation |
| 134 = SkScaledImageCache::GetSingleAllocationByteLimit(); | 134 = SkScaledImageCache::GetSingleAllocationByteLimit(); |
| 135 if (0 == maximumAllocation) { | 135 if (0 == maximumAllocation) { |
| 136 return true; | 136 return true; |
| (...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 } else { | 1065 } else { |
| 1066 size >>= 2; | 1066 size >>= 2; |
| 1067 } | 1067 } |
| 1068 | 1068 |
| 1069 if (fFilterLevel != SkPaint::kNone_FilterLevel) { | 1069 if (fFilterLevel != SkPaint::kNone_FilterLevel) { |
| 1070 size >>= 1; | 1070 size >>= 1; |
| 1071 } | 1071 } |
| 1072 | 1072 |
| 1073 return size; | 1073 return size; |
| 1074 } | 1074 } |
| OLD | NEW |