diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp index 9d7ce95b07..3e6a903eab 100644 --- a/src/effects/SkLightingImageFilter.cpp +++ b/src/effects/SkLightingImageFilter.cpp @@ -15,9 +15,11 @@ #include "SkTypes.h" #if SK_SUPPORT_GPU +#include "GrContext.h" #include "GrDrawContext.h" #include "GrFragmentProcessor.h" #include "GrInvariantOutput.h" +#include "GrPaint.h" #include "effects/GrSingleTextureEffect.h" #include "gl/GrGLProcessor.h" #include "gl/builders/GrGLProgramBuilder.h" diff --git a/src/gpu/GrAARectRenderer.cpp b/src/gpu/GrAARectRenderer.cpp index a52a701e10..1c5b6d8616 100644 --- a/src/gpu/GrAARectRenderer.cpp +++ b/src/gpu/GrAARectRenderer.cpp @@ -11,6 +11,7 @@ #include "GrBatchTest.h" #include "GrContext.h" #include "GrDefaultGeoProcFactory.h" +#include "GrDrawTarget.h" #include "GrGeometryProcessor.h" #include "GrInvariantOutput.h" #include "GrResourceKey.h" diff --git a/src/gpu/GrBatchFontCache.cpp b/src/gpu/GrBatchFontCache.cpp index 39c6d5a0fd..aa0526007d 100644 --- a/src/gpu/GrBatchFontCache.cpp +++ b/src/gpu/GrBatchFontCache.cpp @@ -6,6 +6,7 @@ */ #include "GrBatchFontCache.h" +#include "GrContext.h" #include "GrFontAtlasSizes.h" #include "GrGpu.h" #include "GrRectanizer.h" diff --git a/src/gpu/GrBatchTarget.h b/src/gpu/GrBatchTarget.h index 8d83d2cbd6..80a8b9bad3 100644 --- a/src/gpu/GrBatchTarget.h +++ b/src/gpu/GrBatchTarget.h @@ -10,6 +10,7 @@ #include "GrBatchAtlas.h" #include "GrBufferAllocPool.h" +#include "GrContext.h" #include "GrPendingProgramElement.h" #include "GrPipeline.h" #include "GrTRecorder.h" diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp index 7fc1491eca..4d6f5d6238 100644 --- a/src/gpu/GrGpu.cpp +++ b/src/gpu/GrGpu.cpp @@ -13,6 +13,7 @@ #include "GrContext.h" #include "GrGpuResourcePriv.h" #include "GrIndexBuffer.h" +#include "GrPathRendering.h" #include "GrResourceCache.h" #include "GrRenderTargetPriv.h" #include "GrStencilAttachment.h" @@ -300,29 +301,3 @@ void GrGpu::draw(const DrawArgs& args, const GrVertices& vertices) { this->onDraw(args, *verts); } while ((verts = iter.next())); } - -void GrGpu::stencilPath(const GrPath* path, const StencilPathState& state) { - this->handleDirtyContext(); - this->onStencilPath(path, state); -} - -void GrGpu::drawPath(const DrawArgs& args, - const GrPath* path, - const GrStencilSettings& stencilSettings) { - this->handleDirtyContext(); - this->onDrawPath(args, path, stencilSettings); -} - -void GrGpu::drawPaths(const DrawArgs& args, - const GrPathRange* pathRange, - const void* indices, - GrDrawTarget::PathIndexType indexType, - const float transformValues[], - GrDrawTarget::PathTransformType transformType, - int count, - const GrStencilSettings& stencilSettings) { - this->handleDirtyContext(); - pathRange->willDrawPaths(indices, indexType, count); - this->onDrawPaths(args, pathRange, indices, indexType, transformValues, - transformType, count, stencilSettings); -} diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h index 539a6a7a60..c5cec154eb 100644 --- a/src/gpu/GrGpu.h +++ b/src/gpu/GrGpu.h @@ -8,21 +8,30 @@ #ifndef GrGpu_DEFINED #define GrGpu_DEFINED -#include "GrDrawTarget.h" -#include "GrPathRendering.h" +#include "GrPipelineBuilder.h" #include "GrProgramDesc.h" +#include "GrStencil.h" +#include "GrTraceMarker.h" +#include "GrXferProcessor.h" #include "SkPath.h" +class GrBatchTracker; class GrContext; struct GrGLInterface; +class GrIndexBuffer; class GrNonInstancedVertices; class GrPath; class GrPathRange; class GrPathRenderer; class GrPathRendererChain; +class GrPathRendering; class GrPipeline; class GrPrimitiveProcessor; +class GrRenderTarget; class GrStencilAttachment; +class GrSurface; +class GrTexture; +class GrVertexBuffer; class GrVertices; class GrGpu : public SkRefCnt { @@ -47,7 +56,7 @@ public: */ const GrCaps* caps() const { return fCaps.get(); } - GrPathRendering* pathRendering() { return fPathRendering.get(); } + GrPathRendering* pathRendering() { return fPathRendering.get(); } // Called by GrContext when the underlying backend context has been destroyed. // GrGpu should use this to ensure that no backend API calls will be made from @@ -299,27 +308,6 @@ public: void draw(const DrawArgs&, const GrVertices&); - /** None of these params are optional, pointers used just to avoid making copies. */ - struct StencilPathState { - bool fUseHWAA; - GrRenderTarget* fRenderTarget; - const SkMatrix* fViewMatrix; - const GrStencilSettings* fStencil; - const GrScissorState* fScissor; - }; - - void stencilPath(const GrPath*, const StencilPathState&); - - void drawPath(const DrawArgs&, const GrPath*, const GrStencilSettings&); - void drawPaths(const DrawArgs&, - const GrPathRange*, - const void* indices, - GrDrawTarget::PathIndexType, - const float transformValues[], - GrDrawTarget::PathTransformType, - int count, - const GrStencilSettings&); - /////////////////////////////////////////////////////////////////////////// // Debugging and Stats @@ -439,19 +427,7 @@ private: // overridden by backend-specific derived class to perform the draw call. virtual void onDraw(const DrawArgs&, const GrNonInstancedVertices&) = 0; - virtual void onStencilPath(const GrPath*, const StencilPathState&) = 0; - virtual void onDrawPath(const DrawArgs&, const GrPath*, const GrStencilSettings&) = 0; - virtual void onDrawPaths(const DrawArgs&, - const GrPathRange*, - const void* indices, - GrDrawTarget::PathIndexType, - const float transformValues[], - GrDrawTarget::PathTransformType, - int count, - const GrStencilSettings&) = 0; - - // overridden by backend-specific derived class to perform the read pixels. virtual bool onReadPixels(GrRenderTarget* target, int left, int top, int width, int height, GrPixelConfig, @@ -502,6 +478,7 @@ private: // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. GrContext* fContext; + friend class GrPathRendering; typedef SkRefCnt INHERITED; }; diff --git a/src/gpu/GrGpuResource.cpp b/src/gpu/GrGpuResource.cpp index 52fe1e57d6..c2d93620d5 100644 --- a/src/gpu/GrGpuResource.cpp +++ b/src/gpu/GrGpuResource.cpp @@ -7,6 +7,7 @@ */ #include "GrGpuResource.h" +#include "GrContext.h" #include "GrResourceCache.h" #include "GrGpu.h" #include "GrGpuResourcePriv.h" diff --git a/src/gpu/GrLayerCache.cpp b/src/gpu/GrLayerCache.cpp index a023e6536e..3948d7e05a 100644 --- a/src/gpu/GrLayerCache.cpp +++ b/src/gpu/GrLayerCache.cpp @@ -6,6 +6,7 @@ */ #include "GrAtlas.h" +#include "GrContext.h" #include "GrDrawContext.h" #include "GrGpu.h" #include "GrLayerCache.h" diff --git a/src/gpu/GrPathRange.h b/src/gpu/GrPathRange.h index 035837fc36..6820ada21b 100644 --- a/src/gpu/GrPathRange.h +++ b/src/gpu/GrPathRange.h @@ -83,7 +83,7 @@ protected: private: // Notify when paths will be drawn in case this is a lazy-loaded path range. - friend class GrGpu; + friend class GrPathRendering; void willDrawPaths(const void* indices, PathIndexType, int count) const; template void willDrawPaths(const void* indices, int count) const; diff --git a/src/gpu/GrPathRendering.h b/src/gpu/GrPathRendering.h index e198d694db..ea276f3179 100644 --- a/src/gpu/GrPathRendering.h +++ b/src/gpu/GrPathRendering.h @@ -9,12 +9,12 @@ #define GrPathRendering_DEFINED #include "SkPath.h" +#include "GrGpu.h" #include "GrPathRange.h" class SkDescriptor; class SkTypeface; class GrPath; -class GrGpu; class GrStencilSettings; class GrStrokeInfo; @@ -127,14 +127,67 @@ public: virtual GrPathRange* createGlyphs(const SkTypeface*, const SkDescriptor*, const GrStrokeInfo&) = 0; - virtual void stencilPath(const GrPath*, const GrStencilSettings&) = 0; - virtual void drawPath(const GrPath*, const GrStencilSettings&) = 0; - virtual void drawPaths(const GrPathRange*, const void* indices, PathIndexType, - const float transformValues[], PathTransformType, int count, - const GrStencilSettings&) = 0; -protected: - GrPathRendering() { } + /** None of these params are optional, pointers used just to avoid making copies. */ + struct StencilPathArgs { + StencilPathArgs(bool useHWAA, + GrRenderTarget* renderTarget, + const SkMatrix* viewMatrix, + const GrScissorState* scissor, + const GrStencilSettings* stencil) + : fUseHWAA(useHWAA) + , fRenderTarget(renderTarget) + , fViewMatrix(viewMatrix) + , fScissor(scissor) + , fStencil(stencil) { + } + bool fUseHWAA; + GrRenderTarget* fRenderTarget; + const SkMatrix* fViewMatrix; + const GrScissorState* fScissor; + const GrStencilSettings* fStencil; + }; + void stencilPath(const StencilPathArgs& args, const GrPath* path) { + fGpu->handleDirtyContext(); + this->onStencilPath(args, path); + } + + struct DrawPathArgs : public GrGpu::DrawArgs { + DrawPathArgs(const GrPrimitiveProcessor* primProc, + const GrPipeline* pipeline, + const GrProgramDesc* desc, + const GrBatchTracker* batchTracker, + const GrStencilSettings* stencil) + : DrawArgs(primProc, pipeline, desc, batchTracker) + , fStencil(stencil) { + } + + const GrStencilSettings* fStencil; + }; + + void drawPath(const DrawPathArgs& args, const GrPath* path) { + fGpu->handleDirtyContext(); + this->onDrawPath(args, path); + } + + void drawPaths(const DrawPathArgs& args, const GrPathRange* pathRange, const void* indices, + PathIndexType indexType, const float transformValues[], + PathTransformType transformType, int count) { + fGpu->handleDirtyContext(); + pathRange->willDrawPaths(indices, indexType, count); + this->onDrawPaths(args, pathRange, indices, indexType, transformValues, transformType, + count); + } +protected: + GrPathRendering(GrGpu* gpu) + : fGpu(gpu) { + } + virtual void onStencilPath(const StencilPathArgs&, const GrPath*) = 0; + virtual void onDrawPath(const DrawPathArgs&, const GrPath*) = 0; + virtual void onDrawPaths(const DrawPathArgs&, const GrPathRange*, const void*, PathIndexType, + const float[], PathTransformType, int) = 0; + + GrGpu* fGpu; private: GrPathRendering& operator=(const GrPathRendering&); }; diff --git a/src/gpu/GrPipeline.h b/src/gpu/GrPipeline.h index 4b979f0310..2de9ba0846 100644 --- a/src/gpu/GrPipeline.h +++ b/src/gpu/GrPipeline.h @@ -11,6 +11,7 @@ #include "GrColor.h" #include "GrGpu.h" #include "GrPendingFragmentStage.h" +#include "GrPrimitiveProcessor.h" #include "GrProgramDesc.h" #include "GrStencil.h" #include "GrTypesPriv.h" diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp index 8ac5a3a844..4b9d265129 100644 --- a/src/gpu/GrResourceProvider.cpp +++ b/src/gpu/GrResourceProvider.cpp @@ -8,6 +8,8 @@ #include "GrResourceProvider.h" #include "GrGpu.h" +#include "GrIndexBuffer.h" +#include "GrPathRendering.h" #include "GrResourceCache.h" #include "GrResourceKey.h" #include "GrVertexBuffer.h" diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp index cc5fb00653..c13d2d839d 100644 --- a/src/gpu/GrSWMaskHelper.cpp +++ b/src/gpu/GrSWMaskHelper.cpp @@ -9,6 +9,7 @@ #include "GrPipelineBuilder.h" #include "GrCaps.h" +#include "GrDrawTarget.h" #include "GrGpu.h" #include "SkData.h" diff --git a/src/gpu/GrTargetCommands.cpp b/src/gpu/GrTargetCommands.cpp index 096d429dea..84dbf9346e 100644 --- a/src/gpu/GrTargetCommands.cpp +++ b/src/gpu/GrTargetCommands.cpp @@ -55,14 +55,9 @@ void GrTargetCommands::flush(GrInOrderDrawBuffer* iodb) { } void GrTargetCommands::StencilPath::execute(GrGpu* gpu) { - GrGpu::StencilPathState state; - state.fRenderTarget = fRenderTarget.get(); - state.fScissor = &fScissor; - state.fStencil = &fStencil; - state.fUseHWAA = fUseHWAA; - state.fViewMatrix = &fViewMatrix; - - gpu->stencilPath(this->path(), state); + GrPathRendering::StencilPathArgs args(fUseHWAA, fRenderTarget.get(), &fViewMatrix, &fScissor, + &fStencil); + gpu->pathRendering()->stencilPath(args, this->path()); } void GrTargetCommands::DrawPath::execute(GrGpu* gpu) { @@ -71,9 +66,9 @@ void GrTargetCommands::DrawPath::execute(GrGpu* gpu) { fState->fBatchTracker); fState->fCompiled = true; } - DrawArgs args(fState->fPrimitiveProcessor.get(), fState->getPipeline(), - &fState->fDesc, &fState->fBatchTracker); - gpu->drawPath(args, this->path(), fStencilSettings); + GrPathRendering::DrawPathArgs args(fState->fPrimitiveProcessor.get(), fState->getPipeline(), + &fState->fDesc, &fState->fBatchTracker, &fStencilSettings); + gpu->pathRendering()->drawPath(args, this->path()); } void GrTargetCommands::DrawPaths::execute(GrGpu* gpu) { @@ -82,12 +77,10 @@ void GrTargetCommands::DrawPaths::execute(GrGpu* gpu) { fState->fBatchTracker); fState->fCompiled = true; } - DrawArgs args(fState->fPrimitiveProcessor.get(), fState->getPipeline(), - &fState->fDesc, &fState->fBatchTracker); - gpu->drawPaths(args, this->pathRange(), - fIndices, fIndexType, - fTransforms, fTransformType, - fCount, fStencilSettings); + GrPathRendering::DrawPathArgs args(fState->fPrimitiveProcessor.get(), fState->getPipeline(), + &fState->fDesc, &fState->fBatchTracker, &fStencilSettings); + gpu->pathRendering()->drawPaths(args, this->pathRange(), fIndices, fIndexType, fTransforms, + fTransformType, fCount); } void GrTargetCommands::DrawBatch::execute(GrGpu*) { diff --git a/src/gpu/GrTest.cpp b/src/gpu/GrTest.cpp index 449a76300a..7416ccf14c 100644 --- a/src/gpu/GrTest.cpp +++ b/src/gpu/GrTest.cpp @@ -201,19 +201,6 @@ private: void onDraw(const DrawArgs&, const GrNonInstancedVertices&) override {} - void onStencilPath(const GrPath* path, const StencilPathState& state) override {} - - void onDrawPath(const DrawArgs&, const GrPath*, const GrStencilSettings&) override {} - - void onDrawPaths(const DrawArgs&, - const GrPathRange*, - const void* indices, - GrDrawTarget::PathIndexType, - const float transformValues[], - GrDrawTarget::PathTransformType, - int count, - const GrStencilSettings&) override {} - bool onReadPixels(GrRenderTarget* target, int left, int top, int width, int height, GrPixelConfig, diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 2afda5f19d..021b89b1de 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -1951,43 +1951,6 @@ void GrGLGpu::onDraw(const DrawArgs& args, const GrNonInstancedVertices& vertice #endif } -void GrGLGpu::onStencilPath(const GrPath* path, const StencilPathState& state) { - this->flushColorWrite(false); - this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); - - GrGLRenderTarget* rt = static_cast(state.fRenderTarget); - SkISize size = SkISize::Make(rt->width(), rt->height()); - this->glPathRendering()->setProjectionMatrix(*state.fViewMatrix, size, rt->origin()); - this->flushScissor(*state.fScissor, rt->getViewport(), rt->origin()); - this->flushHWAAState(rt, state.fUseHWAA); - this->flushRenderTarget(rt, NULL); - - fPathRendering->stencilPath(path, *state.fStencil); -} - -void GrGLGpu::onDrawPath(const DrawArgs& args, const GrPath* path, - const GrStencilSettings& stencil) { - if (!this->flushGLState(args)) { - return; - } - fPathRendering->drawPath(path, stencil); -} - -void GrGLGpu::onDrawPaths(const DrawArgs& args, - const GrPathRange* pathRange, - const void* indices, - GrDrawTarget::PathIndexType indexType, - const float transformValues[], - GrDrawTarget::PathTransformType transformType, - int count, - const GrStencilSettings& stencil) { - if (!this->flushGLState(args)) { - return; - } - fPathRendering->drawPaths(pathRange, indices, indexType, transformValues, - transformType, count, stencil); -} - void GrGLGpu::onResolveRenderTarget(GrRenderTarget* target) { GrGLRenderTarget* rt = static_cast(target); if (rt->needsResolve()) { diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index cd9496c7a0..6fd77fbe92 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -157,16 +157,6 @@ private: void onResolveRenderTarget(GrRenderTarget* target) override; void onDraw(const DrawArgs&, const GrNonInstancedVertices&) override; - void onStencilPath(const GrPath*, const StencilPathState&) override; - void onDrawPath(const DrawArgs&, const GrPath*, const GrStencilSettings&) override; - void onDrawPaths(const DrawArgs&, - const GrPathRange*, - const void* indices, - GrDrawTarget::PathIndexType, - const float transformValues[], - GrDrawTarget::PathTransformType, - int count, - const GrStencilSettings&) override; void clearStencil(GrRenderTarget*) override; diff --git a/src/gpu/gl/GrGLPathRendering.cpp b/src/gpu/gl/GrGLPathRendering.cpp index e000f03102..ae83395740 100644 --- a/src/gpu/gl/GrGLPathRendering.cpp +++ b/src/gpu/gl/GrGLPathRendering.cpp @@ -17,8 +17,8 @@ #include "SkStream.h" #include "SkTypeface.h" -#define GL_CALL(X) GR_GL_CALL(fGpu->glInterface(), X) -#define GL_CALL_RET(RET, X) GR_GL_CALL_RET(fGpu->glInterface(), RET, X) +#define GL_CALL(X) GR_GL_CALL(this->gpu()->glInterface(), X) +#define GL_CALL_RET(RET, X) GR_GL_CALL_RET(this->gpu()->glInterface(), RET, X) static const GrGLenum gIndexType2GLType[] = { @@ -60,7 +60,7 @@ static GrGLenum gr_stencil_op_to_gl_path_rendering_fill_mode(GrStencilOp op) { } GrGLPathRendering::GrGLPathRendering(GrGLGpu* gpu) - : fGpu(gpu) { + : GrPathRendering(gpu) { const GrGLInterface* glInterface = gpu->glInterface(); fCaps.stencilThenCoverSupport = NULL != glInterface->fFunctions.fStencilThenCoverFillPath && @@ -92,12 +92,12 @@ void GrGLPathRendering::resetContext() { } GrPath* GrGLPathRendering::createPath(const SkPath& inPath, const GrStrokeInfo& stroke) { - return SkNEW_ARGS(GrGLPath, (fGpu, inPath, stroke)); + return SkNEW_ARGS(GrGLPath, (this->gpu(), inPath, stroke)); } GrPathRange* GrGLPathRendering::createPathRange(GrPathRange::PathGenerator* pathGenerator, const GrStrokeInfo& stroke) { - return SkNEW_ARGS(GrGLPathRange, (fGpu, pathGenerator, stroke)); + return SkNEW_ARGS(GrGLPathRange, (this->gpu(), pathGenerator, stroke)); } GrPathRange* GrGLPathRendering::createGlyphs(const SkTypeface* typeface, @@ -133,7 +133,7 @@ GrPathRange* GrGLPathRendering::createGlyphs(const SkTypeface* typeface, const GrGLuint basePathID = this->genPaths(numPaths); // Init the basePathID as the template path. - GrGLPath::InitPathObject(fGpu, basePathID, SkPath(), stroke); + GrGLPath::InitPathObject(this->gpu(), basePathID, SkPath(), stroke); GrGLenum status; GL_CALL_RET(status, PathMemoryGlyphIndexArray(basePathID, GR_GL_STANDARD_FONT_FORMAT, @@ -150,13 +150,25 @@ GrPathRange* GrGLPathRendering::createGlyphs(const SkTypeface* typeface, // a pseudo PathGenerator whose sole purpose is to track the approximate gpu // memory size. const size_t gpuMemorySize = fontDataLength / 4; - return SkNEW_ARGS(GrGLPathRange, (fGpu, basePathID, numPaths, gpuMemorySize, stroke)); + return SkNEW_ARGS(GrGLPathRange, (this->gpu(), basePathID, numPaths, gpuMemorySize, stroke)); } -void GrGLPathRendering::stencilPath(const GrPath* path, const GrStencilSettings& stencilSettings) { +void GrGLPathRendering::onStencilPath(const StencilPathArgs& args, const GrPath* path) { + GrGLGpu* gpu = this->gpu(); + SkASSERT(gpu->caps()->shaderCaps()->pathRenderingSupport()); + gpu->flushColorWrite(false); + gpu->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); + + GrGLRenderTarget* rt = static_cast(args.fRenderTarget); + SkISize size = SkISize::Make(rt->width(), rt->height()); + this->setProjectionMatrix(*args.fViewMatrix, size, rt->origin()); + gpu->flushScissor(*args.fScissor, rt->getViewport(), rt->origin()); + gpu->flushHWAAState(rt, args.fUseHWAA); + gpu->flushRenderTarget(rt, NULL); + const GrGLPath* glPath = static_cast(path); - this->flushPathStencilSettings(stencilSettings); + this->flushPathStencilSettings(*args.fStencil); SkASSERT(!fHWPathStencilSettings.isTwoSided()); GrGLenum fillMode = gr_stencil_op_to_gl_path_rendering_fill_mode( @@ -171,10 +183,13 @@ void GrGLPathRendering::stencilPath(const GrPath* path, const GrStencilSettings& } } -void GrGLPathRendering::drawPath(const GrPath* path, const GrStencilSettings& stencilSettings) { +void GrGLPathRendering::onDrawPath(const DrawPathArgs& args, const GrPath* path) { + if (!this->gpu()->flushGLState(args)) { + return; + } const GrGLPath* glPath = static_cast(path); - this->flushPathStencilSettings(stencilSettings); + this->flushPathStencilSettings(*args.fStencil); SkASSERT(!fHWPathStencilSettings.isTwoSided()); GrGLenum fillMode = gr_stencil_op_to_gl_path_rendering_fill_mode( @@ -191,17 +206,19 @@ void GrGLPathRendering::drawPath(const GrPath* path, const GrStencilSettings& st } } -void GrGLPathRendering::drawPaths(const GrPathRange* pathRange, - const void* indices, PathIndexType indexType, - const float transformValues[], PathTransformType transformType, - int count, const GrStencilSettings& stencilSettings) { - SkASSERT(fGpu->caps()->shaderCaps()->pathRenderingSupport()); +void GrGLPathRendering::onDrawPaths(const DrawPathArgs& args, const GrPathRange* pathRange, + const void* indices, PathIndexType indexType, + const float transformValues[], PathTransformType transformType, + int count) { + if (!this->gpu()->flushGLState(args)) { + return; + } + this->flushPathStencilSettings(*args.fStencil); + SkASSERT(!fHWPathStencilSettings.isTwoSided()); + const GrGLPathRange* glPathRange = static_cast(pathRange); - this->flushPathStencilSettings(stencilSettings); - SkASSERT(!fHWPathStencilSettings.isTwoSided()); - GrGLenum fillMode = gr_stencil_op_to_gl_path_rendering_fill_mode( fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face)); @@ -257,7 +274,7 @@ void GrGLPathRendering::setProjectionMatrix(const SkMatrix& matrix, const SkISize& renderTargetSize, GrSurfaceOrigin renderTargetOrigin) { - SkASSERT(fGpu->glCaps().shaderCaps()->pathRenderingSupport()); + SkASSERT(this->gpu()->glCaps().shaderCaps()->pathRenderingSupport()); if (renderTargetOrigin == fHWProjectionMatrixState.fRenderTargetOrigin && renderTargetSize == fHWProjectionMatrixState.fRenderTargetSize && @@ -389,3 +406,7 @@ inline void GrGLPathRendering::stencilThenCoverStrokePathInstanced( GL_CALL(CoverStrokePathInstanced(numPaths, pathNameType, paths, pathBase, coverMode, transformType, transformValues)); } + +inline GrGLGpu* GrGLPathRendering::gpu() { + return static_cast(fGpu); +} diff --git a/src/gpu/gl/GrGLPathRendering.h b/src/gpu/gl/GrGLPathRendering.h index 84bac6c117..aa6747098b 100644 --- a/src/gpu/gl/GrGLPathRendering.h +++ b/src/gpu/gl/GrGLPathRendering.h @@ -39,11 +39,6 @@ public: virtual GrPathRange* createGlyphs(const SkTypeface*, const SkDescriptor*, const GrStrokeInfo&) override; - void stencilPath(const GrPath*, const GrStencilSettings&) override; - void drawPath(const GrPath*, const GrStencilSettings&) override; - virtual void drawPaths(const GrPathRange*, const void* indices, PathIndexType, - const float transformValues[], PathTransformType, int count, - const GrStencilSettings&) override; /* Called when the 3D context state is unknown. */ void resetContext(); @@ -67,6 +62,11 @@ public: GrGLuint genPaths(GrGLsizei range); GrGLvoid deletePaths(GrGLuint path, GrGLsizei range); +protected: + void onStencilPath(const StencilPathArgs&, const GrPath*) override; + void onDrawPath(const DrawPathArgs&, const GrPath*) override; + void onDrawPaths(const DrawPathArgs&, const GrPathRange*, const void* indices, PathIndexType, + const float transformValues[], PathTransformType, int count) override; private: /** * Mark certain functionality as not supported if the driver version is too @@ -129,8 +129,8 @@ private: GrGLGetMatrix(destMatrix, combined); } }; + GrGLGpu* gpu(); - GrGLGpu* fGpu; SkAutoTDelete fPathNameAllocator; Caps fCaps; MatrixState fHWProjectionMatrixState; diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp index da242aa563..3a4ac980ed 100644 --- a/src/gpu/gl/GrGLProgram.cpp +++ b/src/gpu/gl/GrGLProgram.cpp @@ -17,6 +17,7 @@ #include "GrGLShaderVar.h" #include "GrGLSL.h" #include "GrGLXferProcessor.h" +#include "GrPathProcessor.h" #include "GrPipeline.h" #include "GrXferProcessor.h" #include "SkXfermode.h"