From d4fa90feea567505e05aba5773a9c37f04b61678 Mon Sep 17 00:00:00 2001 From: joshualitt Date: Wed, 15 Jul 2015 06:18:57 -0700 Subject: [PATCH] Fix VisualBench to hold onto a surface BUG=skia: Review URL: https://codereview.chromium.org/1236723003 --- tools/VisualBench/VisualBench.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/VisualBench/VisualBench.cpp b/tools/VisualBench/VisualBench.cpp index 6501aa36b2..136162aece 100644 --- a/tools/VisualBench/VisualBench.cpp +++ b/tools/VisualBench/VisualBench.cpp @@ -74,8 +74,13 @@ void VisualBench::setTitle() { } SkSurface* VisualBench::createSurface() { - SkSurfaceProps props(INHERITED::getSurfaceProps()); - return SkSurface::NewRenderTargetDirect(fRenderTarget, &props); + if (!fSurface) { + SkSurfaceProps props(INHERITED::getSurfaceProps()); + fSurface.reset(SkSurface::NewRenderTargetDirect(fRenderTarget, &props)); + } + + // The caller will wrap the SkSurface in an SkAutoTUnref + return SkRef(fSurface.get()); } bool VisualBench::setupBackend() {