aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/GrContext.cpp')
-rwxr-xr-xsrc/gpu/GrContext.cpp58
1 files changed, 24 insertions, 34 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 9e33340930..64f4cb3dec 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 @@ void GrContext::DrawingMgr::flush() {
}
}
-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;
}
////////////////////////////////////////////////////////////////////////////////
@@ -271,6 +246,21 @@ void GrContext::getResourceCacheUsage(int* resourceCount, size_t* resourceBytes)
}
}
+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);
+}
+
////////////////////////////////////////////////////////////////////////////////
void GrContext::OverBudgetCB(void* data) {