aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2015-10-06 07:38:23 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-10-06 07:38:23 -0700
commit2d70dcbe5cf4b1d26bb03070d4f8cffd756dd509 (patch)
tree0350c5d1e7d441337489a6cbbeb1f6ecd55dc540 /include
parentb0cd8b714629352638f17154cfc05ade03fff8f5 (diff)
Dynamically allocate the GrDrawContexts
This CL moves the allocation and storage of the GrTextContexts into the DrawingManager. The GrDrawContexts now just get their GrTextContext from the DrawingManager. Review URL: https://codereview.chromium.org/1375153007
Diffstat (limited to 'include')
-rw-r--r--include/gpu/GrContext.h23
-rw-r--r--include/gpu/GrDrawContext.h6
2 files changed, 18 insertions, 11 deletions
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index 59ce867efd..51879e0626 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -183,6 +183,10 @@ public:
return fDrawingMgr.drawContext(surfaceProps);
}
+ GrTextContext* textContext(const SkSurfaceProps& surfaceProps, GrRenderTarget* rt) {
+ return fDrawingMgr.textContext(surfaceProps, rt);
+ }
+
///////////////////////////////////////////////////////////////////////////
// Misc.
@@ -410,17 +414,19 @@ private:
GrContext(); // init must be called after the constructor.
bool init(GrBackend, GrBackendContext, const GrContextOptions& options);
- // Currently the DrawingMgr stores a separate GrDrawContext for each
+ // 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 user's request.
- // All of the GrDrawContexts still land in the same GrDrawTarget!
+ // 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() : fDrawTarget(NULL) {
- sk_bzero(fDrawContext, sizeof(fDrawContext));
+ DrawingMgr() : fDrawTarget(nullptr), fNVPRTextContext(nullptr) {
+ sk_bzero(fTextContexts, sizeof(fTextContexts));
}
~DrawingMgr();
@@ -433,10 +439,12 @@ private:
void reset();
void flush();
- // 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.
GrDrawContext* drawContext(const SkSurfaceProps* surfaceProps);
+ GrTextContext* textContext(const SkSurfaceProps& props, GrRenderTarget* rt);
+
private:
void cleanup();
@@ -448,7 +456,8 @@ private:
GrContext* fContext;
GrDrawTarget* fDrawTarget;
- GrDrawContext* fDrawContext[kNumPixelGeometries][kNumDFTOptions];
+ GrTextContext* fNVPRTextContext;
+ GrTextContext* fTextContexts[kNumPixelGeometries][kNumDFTOptions];
};
DrawingMgr fDrawingMgr;
diff --git a/include/gpu/GrDrawContext.h b/include/gpu/GrDrawContext.h
index 97cb72a7f2..9365021dfa 100644
--- a/include/gpu/GrDrawContext.h
+++ b/include/gpu/GrDrawContext.h
@@ -263,9 +263,7 @@ private:
friend class GrAtlasTextContext; // for access to drawBatch
friend class GrContext; // for ctor
- GrDrawContext(GrContext*, GrDrawTarget*, const SkSurfaceProps&);
-
- GrTextContext* createTextContext(GrRenderTarget*, const SkSurfaceProps&);
+ GrDrawContext(GrContext*, GrDrawTarget*, const SkSurfaceProps* surfaceProps);
// Checks if the context has been abandoned and if the rendertarget is owned by this context
bool prepareToDraw(GrRenderTarget* rt);
@@ -284,7 +282,7 @@ private:
GrContext* fContext; // owning context -> no ref
GrDrawTarget* fDrawTarget;
- GrTextContext* fTextContext; // lazily created
+ GrTextContext* fTextContext; // lazily gotten from GrContext::DrawingMgr
SkSurfaceProps fSurfaceProps;
};