From 60f42494f5d45c38e260ce089cdddfb600f799b2 Mon Sep 17 00:00:00 2001 From: Chris Dalton Date: Mon, 4 Sep 2017 01:47:11 -0600 Subject: Improve GrPathRendererChain heuristics Changes GrPathRenderer::canDrawPath to return a 'CanDrawPath' enum, which contains a new kAsBackup value that means "I'm better than SW, but give the path renderers below me a chance first." Bug: skia: Change-Id: I45aac5462ca1bc0bc839eb1c315db9493901a07e Reviewed-on: https://skia-review.googlesource.com/42222 Reviewed-by: Brian Osman Reviewed-by: Brian Salomon Commit-Queue: Chris Dalton --- src/gpu/GrPathRendererChain.cpp | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'src/gpu/GrPathRendererChain.cpp') diff --git a/src/gpu/GrPathRendererChain.cpp b/src/gpu/GrPathRendererChain.cpp index 354d086a22..4a39f256fe 100644 --- a/src/gpu/GrPathRendererChain.cpp +++ b/src/gpu/GrPathRendererChain.cpp @@ -96,18 +96,29 @@ GrPathRenderer* GrPathRendererChain::getPathRenderer( } } - for (int i = 0; i < fChain.count(); ++i) { - if (fChain[i]->canDrawPath(args)) { - if (GrPathRenderer::kNoSupport_StencilSupport != minStencilSupport) { - GrPathRenderer::StencilSupport support = fChain[i]->getStencilSupport(*args.fShape); - if (support < minStencilSupport) { - continue; - } else if (stencilSupport) { - *stencilSupport = support; - } + GrPathRenderer* bestPathRenderer = nullptr; + for (const sk_sp& pr : fChain) { + GrPathRenderer::StencilSupport support = GrPathRenderer::kNoSupport_StencilSupport; + if (GrPathRenderer::kNoSupport_StencilSupport != minStencilSupport) { + support = pr->getStencilSupport(*args.fShape); + if (support < minStencilSupport) { + continue; } - return fChain[i].get(); + } + GrPathRenderer::CanDrawPath canDrawPath = pr->canDrawPath(args); + if (GrPathRenderer::CanDrawPath::kNo == canDrawPath) { + continue; + } + if (GrPathRenderer::CanDrawPath::kAsBackup == canDrawPath && bestPathRenderer) { + continue; + } + if (stencilSupport) { + *stencilSupport = support; + } + bestPathRenderer = pr.get(); + if (GrPathRenderer::CanDrawPath::kYes == canDrawPath) { + break; } } - return nullptr; + return bestPathRenderer; } -- cgit v1.2.3