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

Unified Diff: ui/gfx/canvas.h

Issue 2476113002: Change call-sites now that SkCanvas is not ref-counted (Closed)
Patch Set: no need for unique check on unique_ptr Created 4 years, 1 month 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
Index: ui/gfx/canvas.h
diff --git a/ui/gfx/canvas.h b/ui/gfx/canvas.h
index ec85eb5374681b91ab0f1fbcfd71c1fb0ab8b0b3..66b2c2b1dbbd602c576cb1bd5e21c6d0fdbadb83 100644
--- a/ui/gfx/canvas.h
+++ b/ui/gfx/canvas.h
@@ -89,7 +89,7 @@ class GFX_EXPORT Canvas {
// Creates a Canvas backed by an |sk_canvas| with |image_scale_|.
// |sk_canvas| is assumed to be already scaled based on |image_scale|
// so no additional scaling is applied.
danakj 2016/11/14 19:35:15 Can you mention that it must outlive the Canvas?
reed1 2016/11/14 20:50:08 Done.
- Canvas(sk_sp<SkCanvas> sk_canvas, float image_scale);
+ Canvas(SkCanvas* sk_canvas, float image_scale);
virtual ~Canvas();
@@ -481,7 +481,7 @@ class GFX_EXPORT Canvas {
const Rect& display_rect,
int flags);
- SkCanvas* sk_canvas() { return canvas_.get(); }
+ SkCanvas* sk_canvas() { return canvas_; }
float image_scale() const { return image_scale_; }
private:
@@ -509,7 +509,12 @@ class GFX_EXPORT Canvas {
// Canvas::Scale() does not affect |image_scale_|.
float image_scale_;
- sk_sp<SkCanvas> canvas_;
+ // canvas_ is our active canvas object. Sometimes we are also the owner,
+ // in which case canvas_owner_ will be set. Other times we are just
+ // borrowing someone else's canvas, in which case canvas_ will point there
+ // but canvas_owner_ will be null.
+ SkCanvas* canvas_;
+ std::unique_ptr<SkCanvas> canvas_owner_;
DISALLOW_COPY_AND_ASSIGN(Canvas);
};

Powered by Google App Engine
This is Rietveld 408576698