Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: include/gpu/GrContext.h

Issue 1175553002: Make GrTextContext be owned by the GrDrawContext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix nvpr config Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | include/gpu/GrDrawContext.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/gpu/GrContext.h
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index acd7b1ad911ee3e1ce92d5f40a8e846fdc66f243..31cb4d0eb102e9a5abfac1129c78e8b1407d1d94 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -43,7 +43,6 @@ class GrTextureParams;
class GrVertexBuffer;
class GrStrokeInfo;
class GrSoftwarePathRenderer;
-class SkGpuDevice;
class SK_API GrContext : public SkRefCnt {
public:
@@ -174,11 +173,16 @@ public:
/**
* 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 devProps the device properties (mainly defines text drawing)
+ * @param uesDFT should Distance Field Text be used?
*
* @return a draw context
*/
- GrDrawContext* drawContext() {
- return fDrawingMgr.drawContext();
+ GrDrawContext* drawContext(const SkDeviceProperties* devProps = NULL, bool useDFT = false) {
+ return fDrawingMgr.drawContext(devProps, useDFT);
}
///////////////////////////////////////////////////////////////////////////
@@ -390,15 +394,17 @@ private:
GrContext(); // init must be called after the constructor.
bool init(GrBackend, GrBackendContext, const GrContextOptions& options);
- // Currently the DrawingMgr just wraps the single GrDrawTarget in a single
- // GrDrawContext and hands it out. In the future this class will allocate
- // a new GrDrawContext for each GrRenderTarget/GrDrawTarget and manage
- // the DAG.
+ // Currently the DrawingMgr stores a separate GrDrawContext 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!
+ //
+ // In the future this class will allocate a new GrDrawContext for
+ // each GrRenderTarget/GrDrawTarget and manage the DAG.
class DrawingMgr {
public:
- DrawingMgr()
- : fDrawTarget(NULL)
- , fDrawContext(NULL) {
+ DrawingMgr() : fDrawTarget(NULL) {
+ sk_bzero(fDrawContext, sizeof(fDrawContext));
}
~DrawingMgr();
@@ -414,14 +420,20 @@ private:
// Callers should take a ref if they rely on the GrDrawContext sticking around.
// NULL will be returned if the context has been abandoned.
- GrDrawContext* drawContext();
+ GrDrawContext* drawContext(const SkDeviceProperties* devProps, bool useDFT);
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;
GrDrawTarget* fDrawTarget;
- GrDrawContext* fDrawContext;
+ GrDrawContext* fDrawContext[kNumPixelGeometries][kNumDFTOptions];
};
DrawingMgr fDrawingMgr;
@@ -430,18 +442,6 @@ private:
void initCommon();
/**
- * Creates a new text rendering context that is optimal for the
- * render target and the context. Caller assumes the ownership
- * of the returned object. The returned object must be deleted
- * before the context is destroyed.
- * TODO bury this behind context!
- */
- GrTextContext* createTextContext(GrRenderTarget*,
- const SkDeviceProperties&,
- bool enableDistanceFieldFonts);
-
-
- /**
* These functions create premul <-> unpremul effects if it is possible to generate a pair
* of effects that make a readToUPM->writeToPM->readToUPM cycle invariant. Otherwise, they
* return NULL.
@@ -461,9 +461,6 @@ private:
*/
static void TextBlobCacheOverBudgetCB(void* data);
- // TODO see note on createTextContext
- friend class SkGpuDevice;
-
typedef SkRefCnt INHERITED;
};
« no previous file with comments | « no previous file | include/gpu/GrDrawContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698