diff options
author | reed <reed@google.com> | 2015-09-14 10:27:57 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-09-14 10:27:57 -0700 |
commit | 995b4bddd9a1eef933b0acb3ff03c98e7864a8f9 (patch) | |
tree | 60b0e5fb83727fc746305cf76c48891be8ab80b9 | |
parent | a22eabedef0cc1256f8c60e58e7a1cbd0bd1db9b (diff) |
be sure to use cached bitmap when we need to upload something to make a texture
BUG=skia:4334
Review URL: https://codereview.chromium.org/1338373002
-rw-r--r-- | src/core/SkBitmapCache.cpp | 11 | ||||
-rw-r--r-- | src/core/SkImageCacherator.cpp | 5 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/core/SkBitmapCache.cpp b/src/core/SkBitmapCache.cpp index 9f985e5a3e..dfa387bb39 100644 --- a/src/core/SkBitmapCache.cpp +++ b/src/core/SkBitmapCache.cpp @@ -58,6 +58,11 @@ public: sizeof(fGenID) + sizeof(fWidth) + sizeof(fHeight) + sizeof(fBounds)); } + void dump() const { + SkDebugf("-- add [%d %d] %d [%d %d %d %d]\n", fWidth, fHeight, fGenID, + fBounds.x(), fBounds.y(), fBounds.width(), fBounds.height()); + } + const uint32_t fGenID; const int fWidth; const int fHeight; @@ -69,7 +74,11 @@ struct BitmapRec : public SkResourceCache::Rec { const SkBitmap& result) : fKey(genID, width, height, bounds) , fBitmap(result) - {} + { +#ifdef TRACE_NEW_BITMAP_CACHE_RECS + fKey.dump(); +#endif + } const Key& getKey() const override { return fKey; } size_t bytesUsed() const override { return sizeof(fKey) + fBitmap.getSize(); } diff --git a/src/core/SkImageCacherator.cpp b/src/core/SkImageCacherator.cpp index b138853e61..dcc5c676f6 100644 --- a/src/core/SkImageCacherator.cpp +++ b/src/core/SkImageCacherator.cpp @@ -78,6 +78,9 @@ static bool check_output_bitmap(const SkBitmap& bitmap, uint32_t expectedID) { return true; } +// Note, this returns a new, mutable, bitmap, with a new genID. +// If you want the immutable bitmap with the same ID as our cacherator, call tryLockAsBitmap() +// bool SkImageCacherator::generateBitmap(SkBitmap* bitmap) { ScopedGenerator generator(this); const SkImageInfo& genInfo = generator->getInfo(); @@ -264,7 +267,7 @@ GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, SkImageUsageType usa // 5. Ask the generator to return RGB(A) data, which the GPU can convert SkBitmap bitmap; - if (this->generateBitmap(&bitmap)) { + if (this->tryLockAsBitmap(&bitmap)) { return GrRefCachedBitmapTexture(ctx, bitmap, usage); } #endif |