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

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

Issue 1338373002: be sure to use cached bitmap when we need to upload something to make a texture (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | src/core/SkImageCacherator.cpp » ('j') | src/core/SkImageCacherator.cpp » ('J')
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 BitmapKey(uint32_t genID, int width, int height, const SkIRect& bounds) 51 BitmapKey(uint32_t genID, int width, int height, const SkIRect& bounds)
52 : fGenID(genID) 52 : fGenID(genID)
53 , fWidth(width) 53 , fWidth(width)
54 , fHeight(height) 54 , fHeight(height)
55 , fBounds(bounds) 55 , fBounds(bounds)
56 { 56 {
57 this->init(&gBitmapKeyNamespaceLabel, SkMakeResourceCacheSharedIDForBitm ap(genID), 57 this->init(&gBitmapKeyNamespaceLabel, SkMakeResourceCacheSharedIDForBitm ap(genID),
58 sizeof(fGenID) + sizeof(fWidth) + sizeof(fHeight) + sizeof(fB ounds)); 58 sizeof(fGenID) + sizeof(fWidth) + sizeof(fHeight) + sizeof(fB ounds));
59 } 59 }
60 60
61 void dump() const {
62 SkDebugf("-- add [%d %d] %d [%d %d %d %d]\n", fWidth, fHeight, fGenID,
63 fBounds.x(), fBounds.y(), fBounds.width(), fBounds.height());
64 }
65
61 const uint32_t fGenID; 66 const uint32_t fGenID;
62 const int fWidth; 67 const int fWidth;
63 const int fHeight; 68 const int fHeight;
64 const SkIRect fBounds; 69 const SkIRect fBounds;
65 }; 70 };
66 71
67 struct BitmapRec : public SkResourceCache::Rec { 72 struct BitmapRec : public SkResourceCache::Rec {
68 BitmapRec(uint32_t genID, int width, int height, const SkIRect& bounds, 73 BitmapRec(uint32_t genID, int width, int height, const SkIRect& bounds,
69 const SkBitmap& result) 74 const SkBitmap& result)
70 : fKey(genID, width, height, bounds) 75 : fKey(genID, width, height, bounds)
71 , fBitmap(result) 76 , fBitmap(result)
72 {} 77 {
78 #ifdef TRACE_NEW_BITMAP_CACHE_RECS
79 fKey.dump();
80 #endif
81 }
73 82
74 const Key& getKey() const override { return fKey; } 83 const Key& getKey() const override { return fKey; }
75 size_t bytesUsed() const override { return sizeof(fKey) + fBitmap.getSize(); } 84 size_t bytesUsed() const override { return sizeof(fKey) + fBitmap.getSize(); }
76 85
77 const char* getCategory() const override { return "bitmap"; } 86 const char* getCategory() const override { return "bitmap"; }
78 SkDiscardableMemory* diagnostic_only_getDiscardable() const override { 87 SkDiscardableMemory* diagnostic_only_getDiscardable() const override {
79 return fBitmap.pixelRef()->diagnostic_only_getDiscardable(); 88 return fBitmap.pixelRef()->diagnostic_only_getDiscardable();
80 } 89 }
81 90
82 static bool Finder(const SkResourceCache::Rec& baseRec, void* contextBitmap) { 91 static bool Finder(const SkResourceCache::Rec& baseRec, void* contextBitmap) {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 243
235 const SkMipMap* SkMipMapCache::AddAndRef(const SkBitmap& src, SkResourceCache* l ocalCache) { 244 const SkMipMap* SkMipMapCache::AddAndRef(const SkBitmap& src, SkResourceCache* l ocalCache) {
236 SkMipMap* mipmap = SkMipMap::Build(src, get_fact(localCache)); 245 SkMipMap* mipmap = SkMipMap::Build(src, get_fact(localCache));
237 if (mipmap) { 246 if (mipmap) {
238 MipMapRec* rec = new MipMapRec(src, mipmap); 247 MipMapRec* rec = new MipMapRec(src, mipmap);
239 CHECK_LOCAL(localCache, add, Add, rec); 248 CHECK_LOCAL(localCache, add, Add, rec);
240 src.pixelRef()->notifyAddedToCache(); 249 src.pixelRef()->notifyAddedToCache();
241 } 250 }
242 return mipmap; 251 return mipmap;
243 } 252 }
OLDNEW
« no previous file with comments | « no previous file | src/core/SkImageCacherator.cpp » ('j') | src/core/SkImageCacherator.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698