Index: include/gpu/GrContext.h |
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h |
index 904a0413ec7af72f0d8784cc61adeb1f65b7b57b..406d168f5d88c87645ce079b0b4ec16cb8217070 100644 |
--- a/include/gpu/GrContext.h |
+++ b/include/gpu/GrContext.h |
@@ -170,30 +170,6 @@ public: |
*/ |
int getRecommendedSampleCount(GrPixelConfig config, SkScalar dpi) const; |
- /** |
- * Returns a helper object to orchestrate draws. |
- * Callers should take a ref if they rely on the GrDrawContext sticking around. |
- * NULL will be returned if the context has been abandoned. |
- * |
- * @param rt the render target receiving the draws |
- * @param surfaceProps the surface properties (mainly defines text drawing) |
- * |
- * @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); |
- } |
- |
/////////////////////////////////////////////////////////////////////////// |
// Misc. |
@@ -373,6 +349,76 @@ public: |
/** Enumerates all cached GPU resources and dumps their memory to traceMemoryDump. */ |
void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const; |
+ // 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 { |
bsalomon
2015/10/16 17:54:53
Don't we want this to be private?
|
+ public: |
+ bool abandoned() const { return fAbandoned; } |
+ |
+ |
+ /** |
+ * Returns a helper object to orchestrate draws. |
+ * 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 |
+ * @param surfaceProps the surface properties (mainly defines text drawing) |
+ * |
+ * @return a draw context |
+ */ |
+ GrDrawContext* drawContext(GrRenderTarget* rt, |
+ const SkSurfaceProps* surfaceProps = nullptr) const; |
+ |
+ GrTextContext* textContext(const SkSurfaceProps& props, GrRenderTarget* rt); |
+ |
+ // The caller automatically gets a ref on the returned drawTarget. It must |
+ // be balanced by an unref call. |
+ GrDrawTarget* newDrawTarget(GrRenderTarget* rt); |
+ |
+ GrContext* getContext() { return fContext; } |
+ |
+ private: |
+ DrawingMgr() |
+ : fContext(nullptr) |
+ , fAbandoned(false) |
+ , fNVPRTextContext(nullptr) { |
+ sk_bzero(fTextContexts, sizeof(fTextContexts)); |
+ } |
+ |
+ ~DrawingMgr(); |
+ |
+ void init(GrContext* context); |
+ |
+ void abandon(); |
+ void cleanup(); |
+ void reset(); |
+ void flush(); |
+ |
+ friend class GrContext; // for access to: ctor, init, abandon, reset & flush |
+ |
+ 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]; |
+ }; |
+ |
+ // This returns a const DrawingMgr which only confers the ability to call |
+ // drawContext and abandoned |
+ const DrawingMgr& drawingMgr() { return fDrawingMgr; } |
+ |
private: |
GrGpu* fGpu; |
const GrCaps* fCaps; |
@@ -421,59 +467,6 @@ private: |
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(); |