Fix double-accounting of SkPictureShader bitmap memory
The pixels RAM is accounted via SkImageGenerator/SkImageCacherator, we don't need to report it as part of SkPictureShader's BitmapShaderRec. R=reed@google.com BUG=chromium:619929 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2415673002 Review-Url: https://codereview.chromium.org/2415673002
This commit is contained in:
parent
d301683716
commit
c9a9ca934b
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user