Index: src/gpu/GrDrawingManager.cpp |
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp |
index 0dbd476c791df31aa83d1e8bca44ead9f7de7af1..0a487daf4146fadb7f7869f8144454d702188ec5 100644 |
--- a/src/gpu/GrDrawingManager.cpp |
+++ b/src/gpu/GrDrawingManager.cpp |
@@ -10,6 +10,7 @@ |
#include "GrDrawingManager.h" |
#include "GrDrawTarget.h" |
#include "GrResourceProvider.h" |
+#include "GrSoftwarePathRenderer.h" |
#include "GrStencilAndCoverTextContext.h" |
#include "SkTTopoSort.h" |
@@ -29,6 +30,9 @@ void GrDrawingManager::cleanup() { |
delete fTextContexts[i][1]; |
fTextContexts[i][1] = nullptr; |
} |
+ |
+ SkSafeSetNull(fPathRendererChain); |
+ SkSafeSetNull(fSoftwarePathRenderer); |
} |
GrDrawingManager::~GrDrawingManager() { |
@@ -40,6 +44,12 @@ void GrDrawingManager::abandon() { |
this->cleanup(); |
} |
+void GrDrawingManager::freeGpuResources() { |
+ // a path renderer may be holding onto resources |
+ SkSafeSetNull(fPathRendererChain); |
+ SkSafeSetNull(fSoftwarePathRenderer); |
+} |
+ |
void GrDrawingManager::reset() { |
for (int i = 0; i < fDrawTargets.count(); ++i) { |
fDrawTargets[i]->reset(); |
@@ -114,7 +124,33 @@ GrDrawTarget* GrDrawingManager::newDrawTarget(GrRenderTarget* rt) { |
return SkRef(dt); |
} |
-GrDrawContext* GrDrawingManager::drawContext(GrRenderTarget* rt, |
+/* |
+ * 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* GrDrawingManager::getPathRenderer(const GrPathRenderer::CanDrawPathArgs& args, |
+ bool allowSW, |
+ GrPathRendererChain::DrawType drawType, |
+ GrPathRenderer::StencilSupport* stencilSupport) { |
+ |
+ if (!fPathRendererChain) { |
+ fPathRendererChain = new GrPathRendererChain(fContext); |
+ } |
+ |
+ GrPathRenderer* pr = fPathRendererChain->getPathRenderer(args, drawType, stencilSupport); |
+ if (!pr && allowSW) { |
+ if (!fSoftwarePathRenderer) { |
+ fSoftwarePathRenderer = new GrSoftwarePathRenderer(fContext); |
+ } |
+ pr = fSoftwarePathRenderer; |
+ } |
+ |
+ return pr; |
+} |
+ |
+GrDrawContext* GrDrawingManager::drawContext(GrRenderTarget* rt, |
const SkSurfaceProps* surfaceProps) { |
if (this->abandoned()) { |
return nullptr; |