diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-05-23 13:19:12 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-05-23 13:19:12 +0000 |
commit | 72176b2d38db005863a54e3dd6657bbabd068bb6 (patch) | |
tree | 8534886e5cbe2b06864048fd4ef787a063fdd5fa | |
parent | 87baf8985a6a88c2459fc9f9e61411995e0f4f69 (diff) |
Removed SoftwarePathRenderer from GrContext's path renderer chain
http://codereview.appspot.com/6221065/
git-svn-id: http://skia.googlecode.com/svn/trunk@4036 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | include/gpu/GrContext.h | 5 | ||||
-rw-r--r-- | src/gpu/GrAddPathRenderers_default.cpp | 1 | ||||
-rw-r--r-- | src/gpu/GrClipMaskManager.cpp | 11 | ||||
-rw-r--r-- | src/gpu/GrContext.cpp | 31 |
4 files changed, 37 insertions, 11 deletions
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index e05c48a8c4..c9c15dfcac 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -32,6 +32,7 @@ class GrResourceCache; class GrStencilBuffer; class GrVertexBuffer; class GrVertexBufferAllocPool; +class GrSoftwarePathRenderer; class GR_API GrContext : public GrRefCnt { public: @@ -695,7 +696,8 @@ public: GrPathRenderer* getPathRenderer(const SkPath& path, GrPathFill fill, const GrDrawTarget* target, - bool antiAlias); + bool antiAlias, + bool allowSW); private: // used to keep track of when we need to flush the draw buffer @@ -712,6 +714,7 @@ private: GrFontCache* fFontCache; GrPathRendererChain* fPathRendererChain; + GrSoftwarePathRenderer* fSoftwarePathRenderer; GrVertexBufferAllocPool* fDrawBufferVBAllocPool; GrIndexBufferAllocPool* fDrawBufferIBAllocPool; diff --git a/src/gpu/GrAddPathRenderers_default.cpp b/src/gpu/GrAddPathRenderers_default.cpp index 47c08b993b..2c175e2042 100644 --- a/src/gpu/GrAddPathRenderers_default.cpp +++ b/src/gpu/GrAddPathRenderers_default.cpp @@ -20,6 +20,5 @@ void GrPathRenderer::AddPathRenderers(GrContext* ctx, chain->addPathRenderer(pr)->unref(); } chain->addPathRenderer(new GrAAConvexPathRenderer())->unref(); - chain->addPathRenderer(new GrSoftwarePathRenderer(ctx))->unref(); } } diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp index d930c06b37..c1a5bd1cc7 100644 --- a/src/gpu/GrClipMaskManager.cpp +++ b/src/gpu/GrClipMaskManager.cpp @@ -393,9 +393,6 @@ void setup_boolean_blendcoeffs(GrDrawState* drawState, SkRegion::Op op) { } } -} - -namespace { //////////////////////////////////////////////////////////////////////////////// bool draw_path(GrContext* context, GrGpu* gpu, @@ -403,7 +400,7 @@ bool draw_path(GrContext* context, GrPathFill fill, bool doAA) { - GrPathRenderer* pr = context->getPathRenderer(path, fill, gpu, doAA); + GrPathRenderer* pr = context->getPathRenderer(path, fill, gpu, doAA, true); if (NULL == pr) { return false; } @@ -411,7 +408,8 @@ bool draw_path(GrContext* context, pr->drawPath(path, fill, NULL, gpu, 0, doAA); return true; } -}; + +} //////////////////////////////////////////////////////////////////////////////// bool GrClipMaskManager::drawClipShape(GrGpu* gpu, @@ -796,7 +794,8 @@ bool GrClipMaskManager::createStencilClipMask(GrGpu* gpu, fill = GrNonInvertedFill(fill); clipPath = &clipCopy.getPath(c); pr = this->getContext()->getPathRenderer(*clipPath, - fill, gpu, false); + fill, gpu, false, + true); if (NULL == pr) { fClipMaskInStencil = false; gpu->setClip(clipCopy); // restore to the original diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index b45970bdad..80dd25ebee 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -18,6 +18,7 @@ #include "GrPathRenderer.h" #include "GrPathUtils.h" #include "GrResourceCache.h" +#include "GrSoftwarePathRenderer.h" #include "GrStencilBuffer.h" #include "GrTextStrike.h" #include "SkTLazy.h" @@ -82,6 +83,7 @@ GrContext::~GrContext() { GrSafeUnref(fAAStrokeRectIndexBuffer); fGpu->unref(); GrSafeUnref(fPathRendererChain); + GrSafeUnref(fSoftwarePathRenderer); fDrawState->unref(); } @@ -98,6 +100,7 @@ void GrContext::contextDestroyed() { // a path renderer may be holding onto resources that // are now unusable GrSafeSetNull(fPathRendererChain); + GrSafeSetNull(fSoftwarePathRenderer); delete fDrawBuffer; fDrawBuffer = NULL; @@ -129,6 +132,7 @@ void GrContext::freeGpuResources() { fFontCache->freeAll(); // a path renderer may be holding onto resources GrSafeSetNull(fPathRendererChain); + GrSafeSetNull(fSoftwarePathRenderer); } size_t GrContext::getGpuTextureCacheBytes() const { @@ -1454,7 +1458,7 @@ void GrContext::internalDrawPath(const GrPaint& paint, const SkPath& path, prAA = false; } - GrPathRenderer* pr = this->getPathRenderer(path, fill, target, prAA); + GrPathRenderer* pr = this->getPathRenderer(path, fill, target, prAA, true); if (NULL == pr) { #if GR_DEBUG GrPrintf("Unable to find path renderer compatible with path.\n"); @@ -1916,15 +1920,35 @@ GrDrawTarget* GrContext::prepareToDraw(const GrPaint& paint, return target; } +/* + * This method finds a path renderer that can draw the specified path on + * the provided target. + * Due to its expense, the software path renderer has split out so it can + * can be individually allowed/disallowed via the "allowSW" boolean. + */ GrPathRenderer* GrContext::getPathRenderer(const SkPath& path, GrPathFill fill, const GrDrawTarget* target, - bool antiAlias) { + bool antiAlias, + bool allowSW) { if (NULL == fPathRendererChain) { fPathRendererChain = new GrPathRendererChain(this, GrPathRendererChain::kNone_UsageFlag); } - return fPathRendererChain->getPathRenderer(path, fill, target, antiAlias); + + GrPathRenderer* pr = fPathRendererChain->getPathRenderer(path, fill, + target, + antiAlias); + + if (NULL == pr && allowSW) { + if (NULL == fSoftwarePathRenderer) { + fSoftwarePathRenderer = new GrSoftwarePathRenderer(this); + } + + pr = fSoftwarePathRenderer; + } + + return pr; } //////////////////////////////////////////////////////////////////////////////// @@ -1992,6 +2016,7 @@ GrContext::GrContext(GrGpu* gpu) { fGpu->setDrawState(fDrawState); fPathRendererChain = NULL; + fSoftwarePathRenderer = NULL; fTextureCache = new GrResourceCache(MAX_TEXTURE_CACHE_COUNT, MAX_TEXTURE_CACHE_BYTES); |