diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp index 3349558b7f..c7ceb76620 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 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 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;