diff options
author | 2017-02-22 12:00:42 -0700 | |
---|---|---|
committer | 2017-02-22 20:29:56 +0000 | |
commit | 008b9d80ab9adbf2656eceaf54d11cd15e4dda05 (patch) | |
tree | 06d4863dc3f65dcdb6704ec65f31800e544ea181 /src/gpu | |
parent | 19eec39c90a357ff3476d65f2c672096f55518e3 (diff) |
Add the ability to enable/disable GPU path renderers
Adds a bitfield to GrContextOptions that masks out path renderers.
Adds commandline flags support to set this bitfield in tools apps.
Removes GrGLInterfaceRemoveNVPR since we can now accomplish the same
thing in the context options.
BUG=skia:
Change-Id: Icf2a4df36374b3ba2f69ebf0db56e8aedd6cf65f
Reviewed-on: https://skia-review.googlesource.com/8786
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrContext.cpp | 3 | ||||
-rw-r--r-- | src/gpu/GrPathRendererChain.cpp | 69 | ||||
-rw-r--r-- | src/gpu/GrPathRendererChain.h | 12 | ||||
-rw-r--r-- | src/gpu/gl/GrGLCaps.cpp | 4 | ||||
-rw-r--r-- | src/gpu/gl/GrGLInterface.cpp | 31 |
5 files changed, 45 insertions, 74 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 8460702a44..4b1324e33e 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -99,9 +99,8 @@ void GrContext::initCommon(const GrContextOptions& options) { rtOpListOptions.fMaxOpCombineLookback = options.fMaxOpCombineLookback; rtOpListOptions.fMaxOpCombineLookahead = options.fMaxOpCombineLookahead; GrPathRendererChain::Options prcOptions; - prcOptions.fDisableDistanceFieldRenderer = options.fDisableDistanceFieldPaths; prcOptions.fAllowPathMaskCaching = options.fAllowPathMaskCaching; - prcOptions.fDisableAllPathRenderers = options.fForceSWPathMasks; + prcOptions.fGpuPathRenderers = options.fGpuPathRenderers; fDrawingManager.reset(new GrDrawingManager(this, rtOpListOptions, prcOptions, options.fImmediateMode, &fSingleOwner)); diff --git a/src/gpu/GrPathRendererChain.cpp b/src/gpu/GrPathRendererChain.cpp index c0cac80dff..4b4ae26d6a 100644 --- a/src/gpu/GrPathRendererChain.cpp +++ b/src/gpu/GrPathRendererChain.cpp @@ -26,44 +26,49 @@ #include "ops/GrTessellatingPathRenderer.h" GrPathRendererChain::GrPathRendererChain(GrContext* context, const Options& options) { - if (!options.fDisableAllPathRenderers) { - const GrCaps& caps = *context->caps(); - this->addPathRenderer(new GrDashLinePathRenderer)->unref(); - - if (GrPathRenderer* pr = GrStencilAndCoverPathRenderer::Create(context->resourceProvider(), - caps)) { - this->addPathRenderer(pr)->unref(); + using GpuPathRenderers = GrContextOptions::GpuPathRenderers; + const GrCaps& caps = *context->caps(); + if (options.fGpuPathRenderers & GpuPathRenderers::kDashLine) { + fChain.push_back(sk_make_sp<GrDashLinePathRenderer>()); + } + if (options.fGpuPathRenderers & GpuPathRenderers::kStencilAndCover) { + sk_sp<GrPathRenderer> pr( + GrStencilAndCoverPathRenderer::Create(context->resourceProvider(), caps)); + if (pr) { + fChain.push_back(std::move(pr)); } - #ifndef SK_BUILD_FOR_ANDROID_FRAMEWORK + } +#ifndef SK_BUILD_FOR_ANDROID_FRAMEWORK + if (options.fGpuPathRenderers & GpuPathRenderers::kMSAA) { if (caps.sampleShadingSupport()) { - this->addPathRenderer(new GrMSAAPathRenderer)->unref(); + fChain.push_back(sk_make_sp<GrMSAAPathRenderer>()); } - #endif - this->addPathRenderer(new GrAAHairLinePathRenderer)->unref(); - this->addPathRenderer(new GrAAConvexPathRenderer)->unref(); - this->addPathRenderer(new GrAALinearizingConvexPathRenderer)->unref(); + } +#endif + if (options.fGpuPathRenderers & GpuPathRenderers::kAAHairline) { + fChain.push_back(sk_make_sp<GrAAHairLinePathRenderer>()); + } + if (options.fGpuPathRenderers & GpuPathRenderers::kAAConvex) { + fChain.push_back(sk_make_sp<GrAAConvexPathRenderer>()); + } + if (options.fGpuPathRenderers & GpuPathRenderers::kAALinearizing) { + fChain.push_back(sk_make_sp<GrAALinearizingConvexPathRenderer>()); + } + if (options.fGpuPathRenderers & GpuPathRenderers::kPLS) { if (caps.shaderCaps()->plsPathRenderingSupport()) { - this->addPathRenderer(new GrPLSPathRenderer)->unref(); - } - if (!options.fDisableDistanceFieldRenderer) { - this->addPathRenderer(new GrAADistanceFieldPathRenderer)->unref(); + fChain.push_back(sk_make_sp<GrPLSPathRenderer>()); } - this->addPathRenderer(new GrTessellatingPathRenderer)->unref(); - this->addPathRenderer(new GrDefaultPathRenderer(caps.twoSidedStencilSupport(), - caps.stencilWrapOpsSupport()))->unref(); } -} - -GrPathRendererChain::~GrPathRendererChain() { - for (int i = 0; i < fChain.count(); ++i) { - fChain[i]->unref(); + if (options.fGpuPathRenderers & GpuPathRenderers::kDistanceField) { + fChain.push_back(sk_make_sp<GrAADistanceFieldPathRenderer>()); + } + if (options.fGpuPathRenderers & GpuPathRenderers::kTesselating) { + fChain.push_back(sk_make_sp<GrTessellatingPathRenderer>()); + } + if (options.fGpuPathRenderers & GpuPathRenderers::kDefault) { + fChain.push_back(sk_make_sp<GrDefaultPathRenderer>(caps.twoSidedStencilSupport(), + caps.stencilWrapOpsSupport())); } -} - -GrPathRenderer* GrPathRendererChain::addPathRenderer(GrPathRenderer* pr) { - fChain.push_back() = pr; - pr->ref(); - return pr; } GrPathRenderer* GrPathRendererChain::getPathRenderer( @@ -99,7 +104,7 @@ GrPathRenderer* GrPathRendererChain::getPathRenderer( *stencilSupport = support; } } - return fChain[i]; + return fChain[i].get(); } } return nullptr; diff --git a/src/gpu/GrPathRendererChain.h b/src/gpu/GrPathRendererChain.h index 9a1a8fe108..c0a0ee39f5 100644 --- a/src/gpu/GrPathRendererChain.h +++ b/src/gpu/GrPathRendererChain.h @@ -10,6 +10,7 @@ #include "GrPathRenderer.h" +#include "GrContextOptions.h" #include "SkTypes.h" #include "SkTArray.h" @@ -24,14 +25,12 @@ class GrContext; class GrPathRendererChain : public SkNoncopyable { public: struct Options { - bool fDisableDistanceFieldRenderer = false; + using GpuPathRenderers = GrContextOptions::GpuPathRenderers; bool fAllowPathMaskCaching = false; - bool fDisableAllPathRenderers = false; + GpuPathRenderers fGpuPathRenderers = GpuPathRenderers::kAll; }; GrPathRendererChain(GrContext* context, const Options&); - ~GrPathRendererChain(); - /** Documents how the caller plans to use a GrPathRenderer to draw a path. It affects the PR returned by getPathRenderer */ enum class DrawType { @@ -49,13 +48,10 @@ public: GrPathRenderer::StencilSupport* stencilSupport); private: - // takes a ref and unrefs in destructor - GrPathRenderer* addPathRenderer(GrPathRenderer* pr); - enum { kPreAllocCount = 8, }; - SkSTArray<kPreAllocCount, GrPathRenderer*, true> fChain; + SkSTArray<kPreAllocCount, sk_sp<GrPathRenderer>> fChain; }; #endif diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index 4c252215a9..370fb0713b 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -258,7 +258,9 @@ void GrGLCaps::init(const GrContextOptions& contextOptions, this->initGLSL(ctxInfo); GrShaderCaps* shaderCaps = fShaderCaps.get(); - shaderCaps->fPathRenderingSupport = this->hasPathRenderingSupport(ctxInfo, gli); + if (!contextOptions.fSuppressPathRendering) { + shaderCaps->fPathRenderingSupport = this->hasPathRenderingSupport(ctxInfo, gli); + } // For now these two are equivalent but we could have dst read in shader via some other method. // Before setting this, initGLSL() must have been called. diff --git a/src/gpu/gl/GrGLInterface.cpp b/src/gpu/gl/GrGLInterface.cpp index 45d84add8d..3714dcb86e 100644 --- a/src/gpu/gl/GrGLInterface.cpp +++ b/src/gpu/gl/GrGLInterface.cpp @@ -29,37 +29,6 @@ const GrGLInterface* GrGLInterfaceAddTestDebugMarker(const GrGLInterface* interf return newInterface; } -const GrGLInterface* GrGLInterfaceRemoveNVPR(const GrGLInterface* interface) { - GrGLInterface* newInterface = GrGLInterface::NewClone(interface); - - newInterface->fExtensions.remove("GL_NV_path_rendering"); - newInterface->fExtensions.remove("GL_CHROMIUM_path_rendering"); - newInterface->fFunctions.fMatrixLoadf = nullptr; - newInterface->fFunctions.fMatrixLoadIdentity = nullptr; - newInterface->fFunctions.fPathCommands = nullptr; - newInterface->fFunctions.fPathParameteri = nullptr; - newInterface->fFunctions.fPathParameterf = nullptr; - newInterface->fFunctions.fGenPaths = nullptr; - newInterface->fFunctions.fDeletePaths = nullptr; - newInterface->fFunctions.fIsPath = nullptr; - newInterface->fFunctions.fPathStencilFunc = nullptr; - newInterface->fFunctions.fStencilFillPath = nullptr; - newInterface->fFunctions.fStencilStrokePath = nullptr; - newInterface->fFunctions.fStencilFillPathInstanced = nullptr; - newInterface->fFunctions.fStencilStrokePathInstanced = nullptr; - newInterface->fFunctions.fCoverFillPath = nullptr; - newInterface->fFunctions.fCoverStrokePath = nullptr; - newInterface->fFunctions.fCoverFillPathInstanced = nullptr; - newInterface->fFunctions.fCoverStrokePathInstanced = nullptr; - newInterface->fFunctions.fStencilThenCoverFillPath = nullptr; - newInterface->fFunctions.fStencilThenCoverStrokePath = nullptr; - newInterface->fFunctions.fStencilThenCoverFillPathInstanced = nullptr; - newInterface->fFunctions.fStencilThenCoverStrokePathInstanced = nullptr; - newInterface->fFunctions.fProgramPathFragmentInputGen = nullptr; - newInterface->fFunctions.fBindFragmentInputLocation = nullptr; - return newInterface; -} - GrGLInterface::GrGLInterface() { fStandard = kNone_GrGLStandard; } |