Avoid SkImage ref churn in short lived SkBitmapProvider
SkBitmapProvider is always stack-allocated and tightly-scoped. It should be safe to store a SkImage rawptr instead of a ref object. R=reed@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2424813002 Review-Url: https://codereview.chromium.org/2424813002
This commit is contained in:
parent
dc87a7d8ea
commit
862a387608
@ -15,10 +15,10 @@
|
||||
class SkBitmapProvider {
|
||||
public:
|
||||
explicit SkBitmapProvider(const SkBitmap& bm) : fBitmap(bm) {}
|
||||
explicit SkBitmapProvider(const SkImage* img) : fImage(SkSafeRef(img)) {}
|
||||
explicit SkBitmapProvider(const SkImage* img) : fImage(img) {}
|
||||
SkBitmapProvider(const SkBitmapProvider& other)
|
||||
: fBitmap(other.fBitmap)
|
||||
, fImage(SkSafeRef(other.fImage.get()))
|
||||
, fImage(other.fImage)
|
||||
{}
|
||||
|
||||
int width() const;
|
||||
@ -38,8 +38,14 @@ public:
|
||||
bool asBitmap(SkBitmap*) const;
|
||||
|
||||
private:
|
||||
SkBitmap fBitmap;
|
||||
SkAutoTUnref<const SkImage> fImage;
|
||||
// Stack-allocated only.
|
||||
void* operator new(size_t) = delete;
|
||||
void* operator new(size_t, void*) = delete;
|
||||
|
||||
SkBitmap fBitmap;
|
||||
// SkBitmapProvider is always short-lived/stack allocated, and the source image is guaranteed
|
||||
// to outlive its scope => we can store a raw ptr to avoid ref churn.
|
||||
const SkImage* fImage;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user