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

Unified Diff: ui/gfx/canvas.h

Issue 2476113002: Change call-sites now that SkCanvas is not ref-counted (Closed)
Patch Set: try fixing win again 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..521a1567f4a9835c2eb90992823fe550004a4941 100644
--- a/ui/gfx/canvas.h
+++ b/ui/gfx/canvas.h
@@ -89,7 +89,9 @@ 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.
- Canvas(sk_sp<SkCanvas> sk_canvas, float image_scale);
+ // Note: the caller must ensure that sk_canvas outlives this object, or until
+ // RecreateBackingCanvas is called.
+ Canvas(SkCanvas* sk_canvas, float image_scale);
virtual ~Canvas();
@@ -481,7 +483,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 +511,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.
+ std::unique_ptr<SkCanvas> canvas_owner_;
+ SkCanvas* canvas_;
DISALLOW_COPY_AND_ASSIGN(Canvas);
};

Powered by Google App Engine
This is Rietveld 408576698