From f530586c417800d086e6e727ecb1b31e678f4183 Mon Sep 17 00:00:00 2001 From: Florin Malita Date: Tue, 15 Nov 2016 10:03:32 -0500 Subject: Resurrect SkDebugger Can't let go . R=robertphillips@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4793 Change-Id: Ida5936d17af2ef60c3f50e27b4f4987a79165fa5 Reviewed-on: https://skia-review.googlesource.com/4793 Reviewed-by: Robert Phillips Commit-Queue: Florin Malita --- debugger/SkDebugger.cpp | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'debugger/SkDebugger.cpp') diff --git a/debugger/SkDebugger.cpp b/debugger/SkDebugger.cpp index 6639d2c829..197a27ff8a 100644 --- a/debugger/SkDebugger.cpp +++ b/debugger/SkDebugger.cpp @@ -7,31 +7,24 @@ */ #include "SkDebugger.h" +#include "SkMakeUnique.h" #include "SkPictureRecorder.h" #include "SkString.h" SkDebugger::SkDebugger() - : fPicture(nullptr) - , fIndex(-1) { - // Create this some other dynamic way? - fDebugCanvas = new SkDebugCanvas(0, 0); -} + : fDebugCanvas(skstd::make_unique(0, 0)) + , fIndex(-1) { } -SkDebugger::~SkDebugger() { - // Need to inherit from SkRef object in order for following to work - SkSafeUnref(fDebugCanvas); - SkSafeUnref(fPicture); -} +SkDebugger::~SkDebugger() {} void SkDebugger::loadPicture(SkPicture* picture) { - SkRefCnt_SafeAssign(fPicture, picture); - - delete fDebugCanvas; - fDebugCanvas = new SkDebugCanvas(SkScalarCeilToInt(this->pictureCull().width()), - SkScalarCeilToInt(this->pictureCull().height())); + fPicture = sk_ref_sp(picture); + fDebugCanvas = skstd::make_unique( + SkScalarCeilToInt(this->pictureCull().width()), + SkScalarCeilToInt(this->pictureCull().height())); fDebugCanvas->setPicture(picture); - picture->playback(fDebugCanvas); + picture->playback(fDebugCanvas.get()); fDebugCanvas->setPicture(nullptr); fIndex = fDebugCanvas->getSize() - 1; } -- cgit v1.2.3