diff options
author | Brian Osman <brianosman@google.com> | 2017-03-01 14:59:05 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-03-01 20:43:38 +0000 |
commit | 8a9de3d828a7bb042c31aa52a2338c70716a590a (patch) | |
tree | fbd2bf85921ae35be2ec11d232e0ad7c83b851fe /tools/viewer | |
parent | 5ff3a5c13e579d6840e49e6ccd75b586f76582a6 (diff) |
Add path renderer options to viewer GUI
BUG=skia:
Change-Id: I248ba081f0229d7fcf2071009076acc88b80b076
Reviewed-on: https://skia-review.googlesource.com/9088
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'tools/viewer')
-rw-r--r-- | tools/viewer/Viewer.cpp | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp index 0bdeeb4867..99d56cac5b 100644 --- a/tools/viewer/Viewer.cpp +++ b/tools/viewer/Viewer.cpp @@ -256,7 +256,7 @@ Viewer::Viewer(int argc, char** argv, void* platformData) gPathRendererNames[GpuPathRenderers::kMSAA] = "Sample shading"; gPathRendererNames[GpuPathRenderers::kPLS] = "Pixel local storage"; gPathRendererNames[GpuPathRenderers::kDistanceField] = "Distance field (small paths only)"; - gPathRendererNames[GpuPathRenderers::kTesselating] = "Tessellating"; + gPathRendererNames[GpuPathRenderers::kTessellating] = "Tessellating"; gPathRendererNames[GpuPathRenderers::kDefault] = "Original Ganesh path renderer"; gPathRendererNames[GpuPathRenderers::kNone] = "Software masks"; }); @@ -978,6 +978,51 @@ void Viewer::drawImGui(SkCanvas* canvas) { this->setBackend(static_cast<sk_app::Window::BackendType>(newBackend)); }); } + + if (ImGui::TreeNode("Path Renderers")) { + const GrContext* ctx = fWindow->getGrContext(); + DisplayParams params = fWindow->getRequestedDisplayParams(); + GpuPathRenderers prevPr = params.fGrContextOptions.fGpuPathRenderers; + GpuPathRenderers newPr = prevPr; + auto prButton = [&](GpuPathRenderers x) { + if (ImGui::RadioButton(gPathRendererNames[x].c_str(), prevPr == x)) { + newPr = x; + } + }; + + if (!ctx) { + ImGui::RadioButton("Software", true); + } else if (fWindow->sampleCount()) { + prButton(GpuPathRenderers::kAll); + if (ctx->caps()->shaderCaps()->pathRenderingSupport()) { + prButton(GpuPathRenderers::kStencilAndCover); + } + if (ctx->caps()->sampleShadingSupport()) { + prButton(GpuPathRenderers::kMSAA); + } + prButton(GpuPathRenderers::kTessellating); + prButton(GpuPathRenderers::kDefault); + prButton(GpuPathRenderers::kNone); + } else { + prButton(GpuPathRenderers::kAll); + if (ctx->caps()->shaderCaps()->plsPathRenderingSupport()) { + prButton(GpuPathRenderers::kPLS); + } + prButton(GpuPathRenderers::kDistanceField); + prButton(GpuPathRenderers::kTessellating); + prButton(GpuPathRenderers::kNone); + } + + if (newPr != prevPr) { + params.fGrContextOptions.fGpuPathRenderers = newPr; + fDeferredActions.push_back([=]() { + fWindow->setRequestedDisplayParams(params); + fWindow->inval(); + this->updateTitle(); + }); + } + ImGui::TreePop(); + } } if (ImGui::CollapsingHeader("Slide")) { @@ -1189,7 +1234,7 @@ void Viewer::updateUIState() { if (ctx->caps()->sampleShadingSupport()) { prState[kOptions].append(gPathRendererNames[GpuPathRenderers::kMSAA]); } - prState[kOptions].append(gPathRendererNames[GpuPathRenderers::kTesselating]); + prState[kOptions].append(gPathRendererNames[GpuPathRenderers::kTessellating]); prState[kOptions].append(gPathRendererNames[GpuPathRenderers::kDefault]); prState[kOptions].append(gPathRendererNames[GpuPathRenderers::kNone]); } else { @@ -1198,7 +1243,7 @@ void Viewer::updateUIState() { prState[kOptions].append(gPathRendererNames[GpuPathRenderers::kPLS]); } prState[kOptions].append(gPathRendererNames[GpuPathRenderers::kDistanceField]); - prState[kOptions].append(gPathRendererNames[GpuPathRenderers::kTesselating]); + prState[kOptions].append(gPathRendererNames[GpuPathRenderers::kTessellating]); prState[kOptions].append(gPathRendererNames[GpuPathRenderers::kNone]); } |