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

Unified Diff: src/core/SkBitmapProvider.h

Issue 2424813002: Avoid SkImage ref churn in short lived SkBitmapProvider (Closed)
Patch Set: whitespace cleanup 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/SkBitmapProvider.h
diff --git a/src/core/SkBitmapProvider.h b/src/core/SkBitmapProvider.h
index 9901c0fc1a054ed9af43dfc77b22d1bed2eac1e3..2080104b8792b3149af2b790f3035093e391abd1 100644
--- a/src/core/SkBitmapProvider.h
+++ b/src/core/SkBitmapProvider.h
@@ -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
« 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