From a106c627532ad669cf7d879955ae8ea6a53233c1 Mon Sep 17 00:00:00 2001 From: robertphillips Date: Fri, 16 Oct 2015 09:07:06 -0700 Subject: Loosen requirement that there be only one GrDrawTarget BUG=skia:4094 Review URL: https://codereview.chromium.org/1406173003 --- include/gpu/GrContext.h | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'include/gpu/GrContext.h') diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index 91ae2d1001..904a0413ec 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -188,6 +188,12 @@ public: return fDrawingMgr.textContext(surfaceProps, rt); } + // The caller automatically gets a ref on the returned drawTarget. It must + // be balanced by an unref call. + GrDrawTarget* newDrawTarget(GrRenderTarget* rt) { + return fDrawingMgr.newDrawTarget(rt); + } + /////////////////////////////////////////////////////////////////////////// // Misc. @@ -426,7 +432,10 @@ private: // each GrRenderTarget/GrDrawTarget and manage the DAG. class DrawingMgr { public: - DrawingMgr() : fDrawTarget(nullptr), fNVPRTextContext(nullptr) { + DrawingMgr() + : fContext(nullptr) + , fAbandoned(false) + , fNVPRTextContext(nullptr) { sk_bzero(fTextContexts, sizeof(fTextContexts)); } @@ -435,7 +444,7 @@ private: void init(GrContext* context); void abandon(); - bool abandoned() const { return NULL == fDrawTarget; } + bool abandoned() const { return fAbandoned; } void reset(); void flush(); @@ -445,6 +454,8 @@ private: GrDrawContext* drawContext(GrRenderTarget* rt, const SkSurfaceProps* surfaceProps); GrTextContext* textContext(const SkSurfaceProps& props, GrRenderTarget* rt); + + GrDrawTarget* newDrawTarget(GrRenderTarget* rt); private: void cleanup(); @@ -455,7 +466,9 @@ private: static const int kNumDFTOptions = 2; // DFT or no DFT GrContext* fContext; - GrDrawTarget* fDrawTarget; + + bool fAbandoned; + SkTDArray fDrawTargets; GrTextContext* fNVPRTextContext; GrTextContext* fTextContexts[kNumPixelGeometries][kNumDFTOptions]; -- cgit v1.2.3