diff options
author | 2015-10-17 07:43:27 -0700 | |
---|---|---|
committer | 2015-10-17 07:43:27 -0700 | |
commit | 77a2e52c7d5c77de73ecab5fec79072ee4460706 (patch) | |
tree | 165c7d8957b1e8415ecd98b57016db576e5b14a2 /include/gpu | |
parent | 1ed348aea37e34dd0ad3bde33cd28bcbd1c2a587 (diff) |
Remove DrawingMgr shims from GrContext
BUG=skia:4094
Review URL: https://codereview.chromium.org/1413673002
Diffstat (limited to 'include/gpu')
-rw-r--r-- | include/gpu/GrContext.h | 76 | ||||
-rw-r--r-- | include/gpu/GrDrawContext.h | 15 |
2 files changed, 14 insertions, 77 deletions
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index 904a0413ec..7136ce4ff5 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -23,6 +23,7 @@ struct GrBatchAtlasConfig; class GrBatchFontCache; class GrCaps; struct GrContextOptions; +class GrDrawingManager; class GrDrawContext; class GrDrawTarget; class GrFragmentProcessor; @@ -172,7 +173,7 @@ public: /** * Returns a helper object to orchestrate draws. - * Callers should take a ref if they rely on the GrDrawContext sticking around. + * Callers assume the creation ref of the drawContext * NULL will be returned if the context has been abandoned. * * @param rt the render target receiving the draws @@ -180,19 +181,7 @@ public: * * @return a draw context */ - GrDrawContext* drawContext(GrRenderTarget* rt, const SkSurfaceProps* surfaceProps = NULL) { - return fDrawingMgr.drawContext(rt, surfaceProps); - } - - GrTextContext* textContext(const SkSurfaceProps& surfaceProps, GrRenderTarget* rt) { - 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); - } + GrDrawContext* drawContext(GrRenderTarget* rt, const SkSurfaceProps* surfaceProps = NULL); /////////////////////////////////////////////////////////////////////////// // Misc. @@ -336,7 +325,7 @@ public: GrBatchFontCache* getBatchFontCache() { return fBatchFontCache; } GrLayerCache* getLayerCache() { return fLayerCache.get(); } GrTextBlobCache* getTextBlobCache() { return fTextBlobCache; } - bool abandoned() const { return fDrawingMgr.abandoned(); } + bool abandoned() const; GrResourceProvider* resourceProvider() { return fResourceProvider; } const GrResourceProvider* resourceProvider() const { return fResourceProvider; } GrResourceCache* getResourceCache() { return fResourceCache; } @@ -418,64 +407,11 @@ private: const uint32_t fUniqueID; + SkAutoTDelete<GrDrawingManager> fDrawingManager; + GrContext(); // init must be called after the constructor. bool init(GrBackend, GrBackendContext, const GrContextOptions& options); - // Currently the DrawingMgr creates a separate GrTextContext for each - // combination of text drawing options (pixel geometry x DFT use) - // and hands the appropriate one back given the DrawContext's request. - // - // It allocates a new GrDrawContext for each GrRenderTarget - // but all of them still land in the same GrDrawTarget! - // - // In the future this class will allocate a new GrDrawContext for - // each GrRenderTarget/GrDrawTarget and manage the DAG. - class DrawingMgr { - public: - DrawingMgr() - : fContext(nullptr) - , fAbandoned(false) - , fNVPRTextContext(nullptr) { - sk_bzero(fTextContexts, sizeof(fTextContexts)); - } - - ~DrawingMgr(); - - void init(GrContext* context); - - void abandon(); - bool abandoned() const { return fAbandoned; } - - void reset(); - void flush(); - - // Callers assume the creation ref of the drawContext! - // NULL will be returned if the context has been abandoned. - GrDrawContext* drawContext(GrRenderTarget* rt, const SkSurfaceProps* surfaceProps); - - GrTextContext* textContext(const SkSurfaceProps& props, GrRenderTarget* rt); - - GrDrawTarget* newDrawTarget(GrRenderTarget* rt); - - private: - void cleanup(); - - friend class GrContext; // for access to fDrawTarget for testing - - static const int kNumPixelGeometries = 5; // The different pixel geometries - static const int kNumDFTOptions = 2; // DFT or no DFT - - GrContext* fContext; - - bool fAbandoned; - SkTDArray<GrDrawTarget*> fDrawTargets; - - GrTextContext* fNVPRTextContext; - GrTextContext* fTextContexts[kNumPixelGeometries][kNumDFTOptions]; - }; - - DrawingMgr fDrawingMgr; - void initMockContext(); void initCommon(); diff --git a/include/gpu/GrDrawContext.h b/include/gpu/GrDrawContext.h index 86a0efe0ac..5986da9504 100644 --- a/include/gpu/GrDrawContext.h +++ b/include/gpu/GrDrawContext.h @@ -15,6 +15,7 @@ class GrClip; class GrContext; class GrDrawBatch; +class GrDrawingManager; class GrDrawTarget; class GrPaint; class GrPathProcessor; @@ -252,11 +253,11 @@ public: private: friend class GrAtlasTextContext; // for access to drawBatch - friend class GrContext; // for ctor + friend class GrDrawingManager; // for ctor SkDEBUGCODE(void validate() const;) - GrDrawContext(GrContext*, GrRenderTarget*, const SkSurfaceProps* surfaceProps); + GrDrawContext(GrDrawingManager*, GrRenderTarget*, const SkSurfaceProps* surfaceProps); void internalDrawPath(GrDrawTarget*, GrPipelineBuilder*, @@ -272,15 +273,15 @@ private: GrDrawTarget* getDrawTarget(); - GrContext* fContext; // owning context -> no ref - GrRenderTarget* fRenderTarget; + GrDrawingManager* fDrawingManager; + GrRenderTarget* fRenderTarget; // In MDB-mode the drawTarget can be closed by some other drawContext that has picked // it up. For this reason, the drawTarget should only ever be accessed via 'getDrawTarget'. - GrDrawTarget* fDrawTarget; - GrTextContext* fTextContext; // lazily gotten from GrContext::DrawingMgr + GrDrawTarget* fDrawTarget; + GrTextContext* fTextContext; // lazily gotten from GrContext::DrawingManager - SkSurfaceProps fSurfaceProps; + SkSurfaceProps fSurfaceProps; }; #endif |