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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user