From 18981294a58c411a4a33ebb22caf9c75ba639691 Mon Sep 17 00:00:00 2001 From: Leon Scroggins III Date: Wed, 17 Dec 2014 11:30:31 -0500 Subject: Make SkiaCanvas creation call ref() on SkCanvas. There are two callers of SkiaCanvas::create_canvas(SkCanvas*). In both cases, we were calling ref() first. It is necessary to call ref() in both cases, since we have an SkCanvas returned by SkPictureRecorder::beginRecording, which does not increment the ref count to account for the caller. (i.e. the SkPictureRecorder has the only ref until you call ref()). Rather than leave the ref up to the caller, since the SkiaCanvas does the unref(), it should also do the ref(). Update it to do so and document its behavior. Also, make SkiaCanvas' constructors explicit. Change-Id: I894d0a71a87587cf8c2b26deb2384dc49ae090ef --- include/private/graphics/Canvas.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include/private') diff --git a/include/private/graphics/Canvas.h b/include/private/graphics/Canvas.h index 3cd57f4..2eda6a4 100644 --- a/include/private/graphics/Canvas.h +++ b/include/private/graphics/Canvas.h @@ -28,6 +28,16 @@ public: virtual ~Canvas() {}; static Canvas* create_canvas(SkBitmap* bitmap); + + /** + * Create a new Canvas object which delegates to an SkCanvas. + * + * @param skiaCanvas Must not be NULL. All drawing calls will be + * delegated to this object. This function will call ref() on the + * SkCanvas, and the returned Canvas will unref() it upon + * destruction. + * @return new Canvas object. Will not return NULL. + */ static Canvas* create_canvas(SkCanvas* skiaCanvas); // TODO: enable HWUI to either create similar canvas wrapper or subclass -- cgit v1.1