Index: src/gpu/GrContext.cpp |
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp |
index 9e33340930b78216160de8273b729131ba632b72..64f4cb3deca237649047db0ababf9954813ca01e 100755 |
--- a/src/gpu/GrContext.cpp |
+++ b/src/gpu/GrContext.cpp |
@@ -9,6 +9,7 @@ |
#include "GrContext.h" |
#include "GrAARectRenderer.h" |
+#include "GrAtlasTextContext.h" |
#include "GrBatch.h" |
#include "GrBatchFontCache.h" |
#include "GrBatchTarget.h" |
@@ -31,6 +32,7 @@ |
#include "GrResourceCache.h" |
#include "GrResourceProvider.h" |
#include "GrSoftwarePathRenderer.h" |
+#include "GrStencilAndCoverTextContext.h" |
#include "GrStrokeInfo.h" |
#include "GrSurfacePriv.h" |
#include "GrTextBlobCache.h" |
@@ -60,33 +62,24 @@ |
//////////////////////////////////////////////////////////////////////////////// |
void GrContext::DrawingMgr::init(GrContext* context) { |
- fContext = context; |
- |
#ifdef IMMEDIATE_MODE |
fDrawTarget = SkNEW_ARGS(GrImmediateDrawTarget, (context)); |
#else |
fDrawTarget = SkNEW_ARGS(GrInOrderDrawBuffer, (context)); |
#endif |
+ |
+ fDrawContext = SkNEW_ARGS(GrDrawContext, (context, fDrawTarget)); |
} |
GrContext::DrawingMgr::~DrawingMgr() { |
SkSafeUnref(fDrawTarget); |
- for (int i = 0; i < kNumPixelGeometries; ++i) { |
- SkSafeUnref(fDrawContext[i][0]); |
- SkSafeUnref(fDrawContext[i][1]); |
- } |
+ SkSafeUnref(fDrawContext); |
} |
void GrContext::DrawingMgr::abandon() { |
SkSafeSetNull(fDrawTarget); |
- for (int i = 0; i < kNumPixelGeometries; ++i) { |
- for (int j = 0; j < kNumDFTOptions; ++j) { |
- if (fDrawContext[i][j]) { |
- SkSafeSetNull(fDrawContext[i][j]->fDrawTarget); |
- SkSafeSetNull(fDrawContext[i][j]); |
- } |
- } |
- } |
+ SkSafeSetNull(fDrawContext->fDrawTarget); |
+ SkSafeSetNull(fDrawContext); |
} |
void GrContext::DrawingMgr::purgeResources() { |
@@ -107,29 +100,11 @@ |
} |
} |
-GrDrawContext* GrContext::DrawingMgr::drawContext(const SkDeviceProperties* devProps, bool useDFT) { |
+GrDrawContext* GrContext::DrawingMgr::drawContext() { |
if (this->abandoned()) { |
return NULL; |
} |
- |
- const SkDeviceProperties defProps; |
- if (!devProps) { |
- devProps = &defProps; |
- } |
- |
- SkASSERT(devProps->pixelGeometry() < kNumPixelGeometries); |
- if (!fDrawContext[devProps->pixelGeometry()][useDFT]) { |
- fDrawContext[devProps->pixelGeometry()][useDFT] = |
- SkNEW_ARGS(GrDrawContext, (fContext, fDrawTarget, *devProps, useDFT)); |
- } |
- |
- SkASSERT(fDrawContext[devProps->pixelGeometry()][useDFT]->fDevProps->pixelGeometry() == |
- devProps->pixelGeometry()); |
- SkASSERT(fDrawContext[devProps->pixelGeometry()][useDFT]->fDevProps->gamma() == |
- devProps->gamma()); |
- SkASSERT(fDrawContext[devProps->pixelGeometry()][useDFT]->fUseDFT == useDFT); |
- |
- return fDrawContext[devProps->pixelGeometry()][useDFT]; |
+ return fDrawContext; |
} |
//////////////////////////////////////////////////////////////////////////////// |
@@ -269,6 +244,21 @@ |
if (resourceBytes) { |
*resourceBytes = fResourceCache->getBudgetedResourceBytes(); |
} |
+} |
+ |
+GrTextContext* GrContext::createTextContext(GrRenderTarget* renderTarget, |
+ const SkDeviceProperties& |
+ leakyProperties, |
+ bool enableDistanceFieldFonts) { |
+ if (fGpu->caps()->shaderCaps()->pathRenderingSupport() && |
+ renderTarget->isStencilBufferMultisampled()) { |
+ GrStencilAttachment* sb = renderTarget->renderTargetPriv().attachStencilAttachment(); |
+ if (sb) { |
+ return GrStencilAndCoverTextContext::Create(this, leakyProperties); |
+ } |
+ } |
+ |
+ return GrAtlasTextContext::Create(this, leakyProperties, enableDistanceFieldFonts); |
} |
//////////////////////////////////////////////////////////////////////////////// |