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

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

Issue 507483002: retool image cache to be generic cache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 3 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
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 "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
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698