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

Unified Diff: src/core/SkPictureShader.cpp

Issue 2415673002: Fix double-accounting of SkPictureShader bitmap memory (Closed)
Patch Set: Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPictureShader.cpp
diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp
index 3349558b7face2d21673bf61678dbf55377db66f..c7ceb766209b46a8ed083e0b6302f7594afa245a 100644
--- a/src/core/SkPictureShader.cpp
+++ b/src/core/SkPictureShader.cpp
@@ -11,6 +11,7 @@
#include "SkBitmapProcShader.h"
#include "SkCanvas.h"
#include "SkImage.h"
+#include "SkImageShader.h"
#include "SkMatrixUtils.h"
#include "SkPicture.h"
#include "SkReadBuffer.h"
@@ -63,10 +64,9 @@ private:
};
struct BitmapShaderRec : public SkResourceCache::Rec {
- BitmapShaderRec(const BitmapShaderKey& key, SkShader* tileShader, size_t bitmapBytes)
+ BitmapShaderRec(const BitmapShaderKey& key, SkShader* tileShader)
: fKey(key)
- , fShader(SkRef(tileShader))
- , fBitmapBytes(bitmapBytes) {}
+ , fShader(SkRef(tileShader)) {}
BitmapShaderKey fKey;
SkAutoTUnref<SkShader> fShader;
@@ -74,7 +74,8 @@ struct BitmapShaderRec : public SkResourceCache::Rec {
const Key& getKey() const override { return fKey; }
size_t bytesUsed() const override {
- return sizeof(fKey) + sizeof(SkShader) + fBitmapBytes;
+ // Just the record overhead -- the actual pixels are accounted by SkImageCacherator.
+ return sizeof(fKey) + sizeof(SkImageShader);
}
const char* getCategory() const override { return "bitmap-shader"; }
SkDiscardableMemory* diagnostic_only_getDiscardable() const override { return nullptr; }
@@ -233,9 +234,7 @@ sk_sp<SkShader> SkPictureShader::refBitmapShader(const SkMatrix& viewMatrix, con
shaderMatrix.preScale(1 / tileScale.width(), 1 / tileScale.height());
tileShader = tileImage->makeShader(fTmx, fTmy, &shaderMatrix);
- const SkImageInfo tileInfo = SkImageInfo::MakeN32Premul(tileSize);
- SkResourceCache::Add(new BitmapShaderRec(key, tileShader.get(),
- tileInfo.getSafeSize(tileInfo.minRowBytes())));
+ SkResourceCache::Add(new BitmapShaderRec(key, tileShader.get()));
}
return tileShader;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698