| Index: src/gpu/GrDrawContext.cpp
|
| diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp
|
| index 1aec92ec4c49349b7af103a2169d489dc7602461..f57be9bf967eae652a060ac5b554e0b86f074c58 100644
|
| --- a/src/gpu/GrDrawContext.cpp
|
| +++ b/src/gpu/GrDrawContext.cpp
|
| @@ -23,28 +23,30 @@
|
| #include "batches/GrDrawVerticesBatch.h"
|
| #include "batches/GrRectBatchFactory.h"
|
|
|
| -#define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fContext)
|
| -#define RETURN_IF_ABANDONED if (fContext->abandoned()) { return; }
|
| -#define RETURN_FALSE_IF_ABANDONED if (fContext->abandoned()) { return false; }
|
| -#define RETURN_NULL_IF_ABANDONED if (fContext->abandoned()) { return nullptr; }
|
| +#define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fDrawingMgr->getContext())
|
| +#define RETURN_IF_ABANDONED if (fDrawingMgr->abandoned()) { return; }
|
| +#define RETURN_FALSE_IF_ABANDONED if (fDrawingMgr->abandoned()) { return false; }
|
| +#define RETURN_NULL_IF_ABANDONED if (fDrawingMgr->abandoned()) { return nullptr; }
|
|
|
| class AutoCheckFlush {
|
| public:
|
| - AutoCheckFlush(GrContext* context) : fContext(context) { SkASSERT(context); }
|
| - ~AutoCheckFlush() { fContext->flushIfNecessary(); }
|
| + AutoCheckFlush(GrContext::DrawingMgr* drawingMgr) : fDrawingMgr(drawingMgr) {
|
| + SkASSERT(fDrawingMgr);
|
| + }
|
| + ~AutoCheckFlush() { fDrawingMgr->getContext()->flushIfNecessary(); }
|
|
|
| private:
|
| - GrContext* fContext;
|
| + GrContext::DrawingMgr* fDrawingMgr;
|
| };
|
|
|
| // In MDB mode the reffing of the 'getLastDrawTarget' call's result allows in-progress
|
| // drawTargets to be picked up and added to by drawContexts lower in the call
|
| // stack. When this occurs with a closed drawTarget, a new one will be allocated
|
| // when the drawContext attempts to use it (via getDrawTarget).
|
| -GrDrawContext::GrDrawContext(GrContext* context,
|
| +GrDrawContext::GrDrawContext(GrContext::DrawingMgr* drawingMgr,
|
| GrRenderTarget* rt,
|
| const SkSurfaceProps* surfaceProps)
|
| - : fContext(context)
|
| + : fDrawingMgr(drawingMgr)
|
| , fRenderTarget(rt)
|
| , fDrawTarget(SkSafeRef(rt->getLastDrawTarget()))
|
| , fTextContext(nullptr)
|
| @@ -71,7 +73,7 @@ GrDrawTarget* GrDrawContext::getDrawTarget() {
|
| SkDEBUGCODE(this->validate();)
|
|
|
| if (!fDrawTarget || fDrawTarget->isClosed()) {
|
| - fDrawTarget = fContext->newDrawTarget(fRenderTarget);
|
| + fDrawTarget = fDrawingMgr->newDrawTarget(fRenderTarget);
|
| fRenderTarget->setLastDrawTarget(fDrawTarget);
|
| }
|
|
|
| @@ -95,7 +97,7 @@ void GrDrawContext::drawText(const GrClip& clip, const GrPaint& grPaint,
|
| SkDEBUGCODE(this->validate();)
|
|
|
| if (!fTextContext) {
|
| - fTextContext = fContext->textContext(fSurfaceProps, fRenderTarget);
|
| + fTextContext = fDrawingMgr->textContext(fSurfaceProps, fRenderTarget);
|
| }
|
|
|
| fTextContext->drawText(this, fRenderTarget, clip, grPaint, skPaint, viewMatrix,
|
| @@ -112,7 +114,7 @@ void GrDrawContext::drawPosText(const GrClip& clip, const GrPaint& grPaint,
|
| SkDEBUGCODE(this->validate();)
|
|
|
| if (!fTextContext) {
|
| - fTextContext = fContext->textContext(fSurfaceProps, fRenderTarget);
|
| + fTextContext = fDrawingMgr->textContext(fSurfaceProps, fRenderTarget);
|
| }
|
|
|
| fTextContext->drawPosText(this, fRenderTarget, clip, grPaint, skPaint, viewMatrix, text, byteLength,
|
| @@ -127,7 +129,7 @@ void GrDrawContext::drawTextBlob(const GrClip& clip, const SkPaint& skPaint,
|
| SkDEBUGCODE(this->validate();)
|
|
|
| if (!fTextContext) {
|
| - fTextContext = fContext->textContext(fSurfaceProps, fRenderTarget);
|
| + fTextContext = fDrawingMgr->textContext(fSurfaceProps, fRenderTarget);
|
| }
|
|
|
| fTextContext->drawTextBlob(this, fRenderTarget,
|
| @@ -152,7 +154,7 @@ void GrDrawContext::discard() {
|
| RETURN_IF_ABANDONED
|
| SkDEBUGCODE(this->validate();)
|
|
|
| - AutoCheckFlush acf(fContext);
|
| + AutoCheckFlush acf(fDrawingMgr);
|
| this->getDrawTarget()->discard(fRenderTarget);
|
| }
|
|
|
| @@ -162,7 +164,7 @@ void GrDrawContext::clear(const SkIRect* rect,
|
| RETURN_IF_ABANDONED
|
| SkDEBUGCODE(this->validate();)
|
|
|
| - AutoCheckFlush acf(fContext);
|
| + AutoCheckFlush acf(fDrawingMgr);
|
| this->getDrawTarget()->clear(rect, color, canIgnoreRect, fRenderTarget);
|
| }
|
|
|
| @@ -206,7 +208,7 @@ void GrDrawContext::drawPaint(const GrClip& clip,
|
| return;
|
| }
|
|
|
| - AutoCheckFlush acf(fContext);
|
| + AutoCheckFlush acf(fDrawingMgr);
|
|
|
| GrPipelineBuilder pipelineBuilder(*paint, fRenderTarget, clip);
|
| this->getDrawTarget()->drawNonAARect(pipelineBuilder,
|
| @@ -238,7 +240,7 @@ void GrDrawContext::drawRect(const GrClip& clip,
|
| return;
|
| }
|
|
|
| - AutoCheckFlush acf(fContext);
|
| + AutoCheckFlush acf(fDrawingMgr);
|
|
|
| GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
|
|
|
| @@ -327,7 +329,7 @@ void GrDrawContext::drawNonAARectToRect(const GrClip& clip,
|
| RETURN_IF_ABANDONED
|
| SkDEBUGCODE(this->validate();)
|
|
|
| - AutoCheckFlush acf(fContext);
|
| + AutoCheckFlush acf(fDrawingMgr);
|
|
|
| GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
|
| this->getDrawTarget()->drawNonAARect(pipelineBuilder,
|
| @@ -345,7 +347,7 @@ void GrDrawContext::drawNonAARectWithLocalMatrix(const GrClip& clip,
|
| RETURN_IF_ABANDONED
|
| SkDEBUGCODE(this->validate();)
|
|
|
| - AutoCheckFlush acf(fContext);
|
| + AutoCheckFlush acf(fDrawingMgr);
|
|
|
| GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
|
| this->getDrawTarget()->drawNonAARect(pipelineBuilder,
|
| @@ -368,7 +370,7 @@ void GrDrawContext::drawVertices(const GrClip& clip,
|
| RETURN_IF_ABANDONED
|
| SkDEBUGCODE(this->validate();)
|
|
|
| - AutoCheckFlush acf(fContext);
|
| + AutoCheckFlush acf(fDrawingMgr);
|
|
|
| GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
|
|
|
| @@ -409,7 +411,7 @@ void GrDrawContext::drawAtlas(const GrClip& clip,
|
| RETURN_IF_ABANDONED
|
| SkDEBUGCODE(this->validate();)
|
|
|
| - AutoCheckFlush acf(fContext);
|
| + AutoCheckFlush acf(fDrawingMgr);
|
|
|
| GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
|
|
|
| @@ -443,7 +445,7 @@ void GrDrawContext::drawRRect(const GrClip& clip,
|
| return;
|
| }
|
|
|
| - AutoCheckFlush acf(fContext);
|
| + AutoCheckFlush acf(fDrawingMgr);
|
|
|
| GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
|
| GrColor color = paint.getColor();
|
| @@ -477,7 +479,7 @@ void GrDrawContext::drawDRRect(const GrClip& clip,
|
| return;
|
| }
|
|
|
| - AutoCheckFlush acf(fContext);
|
| + AutoCheckFlush acf(fDrawingMgr);
|
|
|
| GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
|
| GrColor color = paint.getColor();
|
| @@ -522,7 +524,7 @@ void GrDrawContext::drawOval(const GrClip& clip,
|
| return;
|
| }
|
|
|
| - AutoCheckFlush acf(fContext);
|
| + AutoCheckFlush acf(fDrawingMgr);
|
|
|
| GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
|
| GrColor color = paint.getColor();
|
| @@ -597,7 +599,7 @@ void GrDrawContext::drawBatch(const GrClip& clip,
|
| RETURN_IF_ABANDONED
|
| SkDEBUGCODE(this->validate();)
|
|
|
| - AutoCheckFlush acf(fContext);
|
| + AutoCheckFlush acf(fDrawingMgr);
|
|
|
| GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
|
| this->getDrawTarget()->drawBatch(pipelineBuilder, batch);
|
| @@ -625,7 +627,7 @@ void GrDrawContext::drawPath(const GrClip& clip,
|
| // cache. This presents a potential hazard for buffered drawing. However,
|
| // the writePixels that uploads to the scratch will perform a flush so we're
|
| // OK.
|
| - AutoCheckFlush acf(fContext);
|
| + AutoCheckFlush acf(fDrawingMgr);
|
|
|
| GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
|
| if (!strokeInfo.isDashed()) {
|
| @@ -689,8 +691,9 @@ void GrDrawContext::internalDrawPath(GrDrawTarget* target,
|
| const GrStrokeInfo* strokeInfoPtr = &strokeInfo;
|
|
|
| // Try a 1st time without stroking the path and without allowing the SW renderer
|
| - GrPathRenderer* pr = fContext->getPathRenderer(target, pipelineBuilder, viewMatrix, *pathPtr,
|
| - *strokeInfoPtr, false, type);
|
| + GrPathRenderer* pr = fDrawingMgr->getContext()->getPathRenderer(target, pipelineBuilder,
|
| + viewMatrix, *pathPtr,
|
| + *strokeInfoPtr, false, type);
|
|
|
| GrStrokeInfo dashlessStrokeInfo(strokeInfo, false);
|
| if (nullptr == pr && strokeInfo.isDashed()) {
|
| @@ -703,8 +706,9 @@ void GrDrawContext::internalDrawPath(GrDrawTarget* target,
|
| return;
|
| }
|
| strokeInfoPtr = &dashlessStrokeInfo;
|
| - pr = fContext->getPathRenderer(target, pipelineBuilder, viewMatrix, *pathPtr, *strokeInfoPtr,
|
| - false, type);
|
| + pr = fDrawingMgr->getContext()->getPathRenderer(target, pipelineBuilder, viewMatrix,
|
| + *pathPtr, *strokeInfoPtr,
|
| + false, type);
|
| }
|
|
|
| if (nullptr == pr) {
|
| @@ -727,8 +731,9 @@ void GrDrawContext::internalDrawPath(GrDrawTarget* target,
|
| }
|
|
|
| // This time, allow SW renderer
|
| - pr = fContext->getPathRenderer(target, pipelineBuilder, viewMatrix, *pathPtr, *strokeInfoPtr,
|
| - true, type);
|
| + pr = fDrawingMgr->getContext()->getPathRenderer(target, pipelineBuilder, viewMatrix,
|
| + *pathPtr, *strokeInfoPtr,
|
| + true, type);
|
| }
|
|
|
| if (nullptr == pr) {
|
| @@ -740,7 +745,7 @@ void GrDrawContext::internalDrawPath(GrDrawTarget* target,
|
|
|
| GrPathRenderer::DrawPathArgs args;
|
| args.fTarget = target;
|
| - args.fResourceProvider = fContext->resourceProvider();
|
| + args.fResourceProvider = fDrawingMgr->getContext()->resourceProvider();
|
| args.fPipelineBuilder = pipelineBuilder;
|
| args.fColor = color;
|
| args.fViewMatrix = &viewMatrix;
|
|
|