Enable generating SkImage with the same uniqueID in SkImageGenerator subclass
Enable reusing uniqueID when instantiating SkImageGenerator subclasses enables using uniqueID in client code to cache generated bitmaps with no need to keep the reference to SkImageGenerator. This is a bug fix for out of memory cause in chromium and 100% CPU usage described in issue 165750#13: - cache uses SkImage::uniqueID() to cache decoded bitmaps. - every animation loop creates new SkImage instances. - after decoding, bitmap copies are added to cache, filling it up with duplicates of previous loops frames. BUG=165750 Blink patch that depends on this: https://codereview.chromium.org/1925533003/ "High CPU and increased memory usage fix for high-res (GIF, WEBP...) animations." Review-Url: https://codereview.chromium.org/1928403002
This commit is contained in:
parent
83906aedb9
commit
9516775857
@ -251,7 +251,11 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
SkImageGenerator(const SkImageInfo& info);
|
||||
enum {
|
||||
kNeedNewImageUniqueID = 0
|
||||
};
|
||||
|
||||
SkImageGenerator(const SkImageInfo& info, uint32_t uniqueId = kNeedNewImageUniqueID);
|
||||
|
||||
virtual SkData* onRefEncodedData(SK_REFENCODEDDATA_CTXPARAM);
|
||||
|
||||
|
@ -8,9 +8,9 @@
|
||||
#include "SkImageGenerator.h"
|
||||
#include "SkNextID.h"
|
||||
|
||||
SkImageGenerator::SkImageGenerator(const SkImageInfo& info)
|
||||
SkImageGenerator::SkImageGenerator(const SkImageInfo& info, uint32_t uniqueID)
|
||||
: fInfo(info)
|
||||
, fUniqueID(SkNextID::ImageID())
|
||||
, fUniqueID(kNeedNewImageUniqueID == uniqueID ? SkNextID::ImageID() : uniqueID)
|
||||
{}
|
||||
|
||||
bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
|
||||
|
Loading…
Reference in New Issue
Block a user