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

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

Issue 1262923003: cache private readback for gpu-images (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: address items in #4 Created 5 years, 4 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
« no previous file with comments | « src/core/SkBitmapCache.h ('k') | src/core/SkPixelRef.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 "SkResourceCache.h" 9 #include "SkResourceCache.h"
10 #include "SkMipMap.h" 10 #include "SkMipMap.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 return false; 135 return false;
136 } else { 136 } else {
137 BitmapRec* rec = SkNEW_ARGS(BitmapRec, (pr->getGenerationID(), 1, 1, sub set, result)); 137 BitmapRec* rec = SkNEW_ARGS(BitmapRec, (pr->getGenerationID(), 1, 1, sub set, result));
138 138
139 CHECK_LOCAL(localCache, add, Add, rec); 139 CHECK_LOCAL(localCache, add, Add, rec);
140 pr->notifyAddedToCache(); 140 pr->notifyAddedToCache();
141 return true; 141 return true;
142 } 142 }
143 } 143 }
144 144
145 bool SkBitmapCache::Find(uint32_t genID, SkBitmap* result, SkResourceCache* loca lCache) {
146 BitmapKey key(genID, SK_Scalar1, SK_Scalar1, SkIRect::MakeEmpty());
147
148 return CHECK_LOCAL(localCache, find, Find, key, BitmapRec::Finder, result);
149 }
150
151 void SkBitmapCache::Add(uint32_t genID, const SkBitmap& result, SkResourceCache* localCache) {
152 SkASSERT(result.isImmutable());
153
154 BitmapRec* rec = SkNEW_ARGS(BitmapRec, (genID, 1, 1, SkIRect::MakeEmpty(), r esult));
155
156 CHECK_LOCAL(localCache, add, Add, rec);
157 }
158
145 //////////////////////////////////////////////////////////////////////////////// ////////// 159 //////////////////////////////////////////////////////////////////////////////// //////////
146 //////////////////////////////////////////////////////////////////////////////// ////////// 160 //////////////////////////////////////////////////////////////////////////////// //////////
147 161
148 namespace { 162 namespace {
149 static unsigned gMipMapKeyNamespaceLabel; 163 static unsigned gMipMapKeyNamespaceLabel;
150 164
151 struct MipMapKey : public SkResourceCache::Key { 165 struct MipMapKey : public SkResourceCache::Key {
152 public: 166 public:
153 MipMapKey(uint32_t genID, const SkIRect& bounds) : fGenID(genID), fBounds(bo unds) { 167 MipMapKey(uint32_t genID, const SkIRect& bounds) : fGenID(genID), fBounds(bo unds) {
154 this->init(&gMipMapKeyNamespaceLabel, SkMakeResourceCacheSharedIDForBitm ap(genID), 168 this->init(&gMipMapKeyNamespaceLabel, SkMakeResourceCacheSharedIDForBitm ap(genID),
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 225
212 const SkMipMap* SkMipMapCache::AddAndRef(const SkBitmap& src, SkResourceCache* l ocalCache) { 226 const SkMipMap* SkMipMapCache::AddAndRef(const SkBitmap& src, SkResourceCache* l ocalCache) {
213 SkMipMap* mipmap = SkMipMap::Build(src, get_fact(localCache)); 227 SkMipMap* mipmap = SkMipMap::Build(src, get_fact(localCache));
214 if (mipmap) { 228 if (mipmap) {
215 MipMapRec* rec = SkNEW_ARGS(MipMapRec, (src, mipmap)); 229 MipMapRec* rec = SkNEW_ARGS(MipMapRec, (src, mipmap));
216 CHECK_LOCAL(localCache, add, Add, rec); 230 CHECK_LOCAL(localCache, add, Add, rec);
217 src.pixelRef()->notifyAddedToCache(); 231 src.pixelRef()->notifyAddedToCache();
218 } 232 }
219 return mipmap; 233 return mipmap;
220 } 234 }
OLDNEW
« no previous file with comments | « src/core/SkBitmapCache.h ('k') | src/core/SkPixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698