| Index: src/gpu/GrContext.cpp
|
| diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
|
| index 065d61bb954a5d937712d6b8bf68b6aee86356d1..b1959bb9fda3f9ffc599acfaadf823097f5826c6 100644
|
| --- a/src/gpu/GrContext.cpp
|
| +++ b/src/gpu/GrContext.cpp
|
| @@ -28,6 +28,7 @@
|
| #include "GrResourceCache.h"
|
| #include "GrResourceProvider.h"
|
| #include "GrSoftwarePathRenderer.h"
|
| +#include "GrStencilAndCoverTextContext.h"
|
| #include "GrStrokeInfo.h"
|
| #include "GrSurfacePriv.h"
|
| #include "GrTextBlobCache.h"
|
| @@ -44,6 +45,7 @@
|
| #include "SkTLS.h"
|
| #include "SkTraceEvent.h"
|
|
|
| +
|
| #include "batches/GrBatch.h"
|
|
|
| #include "effects/GrConfigConversionEffect.h"
|
| @@ -65,9 +67,13 @@ void GrContext::DrawingMgr::init(GrContext* context) {
|
|
|
| void GrContext::DrawingMgr::cleanup() {
|
| SkSafeSetNull(fDrawTarget);
|
| + delete fNVPRTextContext;
|
| + fNVPRTextContext = nullptr;
|
| for (int i = 0; i < kNumPixelGeometries; ++i) {
|
| - SkSafeSetNull(fDrawContext[i][0]);
|
| - SkSafeSetNull(fDrawContext[i][1]);
|
| + delete fTextContexts[i][0];
|
| + fTextContexts[i][0] = nullptr;
|
| + delete fTextContexts[i][1];
|
| + fTextContexts[i][1] = nullptr;
|
| }
|
| }
|
|
|
| @@ -76,15 +82,7 @@ GrContext::DrawingMgr::~DrawingMgr() {
|
| }
|
|
|
| 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]);
|
| - }
|
| - }
|
| - }
|
| + this->cleanup();
|
| }
|
|
|
| void GrContext::DrawingMgr::reset() {
|
| @@ -99,21 +97,40 @@ void GrContext::DrawingMgr::flush() {
|
| }
|
| }
|
|
|
| -GrDrawContext* GrContext::DrawingMgr::drawContext(const SkSurfaceProps* surfaceProps) {
|
| +GrTextContext* GrContext::DrawingMgr::textContext(const SkSurfaceProps& props,
|
| + GrRenderTarget* rt) {
|
| if (this->abandoned()) {
|
| return nullptr;
|
| }
|
|
|
| - const SkSurfaceProps props(SkSurfacePropsCopyOrDefault(surfaceProps));
|
| -
|
| SkASSERT(props.pixelGeometry() < kNumPixelGeometries);
|
| - if (!fDrawContext[props.pixelGeometry()][props.isUseDeviceIndependentFonts()]) {
|
| - fDrawContext[props.pixelGeometry()][props.isUseDeviceIndependentFonts()] =
|
| - new GrDrawContext(fContext, fDrawTarget, props);
|
| + bool useDIF = props.isUseDeviceIndependentFonts();
|
| +
|
| + if (useDIF && fContext->caps()->shaderCaps()->pathRenderingSupport() &&
|
| + rt->isStencilBufferMultisampled()) {
|
| + GrStencilAttachment* sb = fContext->resourceProvider()->attachStencilAttachment(rt);
|
| + if (sb) {
|
| + if (!fNVPRTextContext) {
|
| + fNVPRTextContext = GrStencilAndCoverTextContext::Create(fContext, props);
|
| + }
|
| +
|
| + return fNVPRTextContext;
|
| + }
|
| + }
|
| +
|
| + if (!fTextContexts[props.pixelGeometry()][useDIF]) {
|
| + fTextContexts[props.pixelGeometry()][useDIF] = GrAtlasTextContext::Create(fContext, props);
|
| + }
|
| +
|
| + return fTextContexts[props.pixelGeometry()][useDIF];
|
| +}
|
| +
|
| +GrDrawContext* GrContext::DrawingMgr::drawContext(const SkSurfaceProps* surfaceProps) {
|
| + if (this->abandoned()) {
|
| + return nullptr;
|
| }
|
|
|
| - // For now, everyone gets a faux creation ref
|
| - return SkRef(fDrawContext[props.pixelGeometry()][props.isUseDeviceIndependentFonts()]);
|
| + return new GrDrawContext(fContext, fDrawTarget, surfaceProps);
|
| }
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
|
|