skia2/tools/flags/SkCommonFlagsPathRenderer.h
Chris Dalton 1a325d25b9 Coverage counting path renderer
Initial implementation of a GPU path renderer that draws antialiased
paths by counting coverage in an offscreen buffer.

Initially disabled until it has had time to soak.

Bug: skia:
Change-Id: I003d8cfdf8dc62641581b5ea2dc4f0aa00108df6
Reviewed-on: https://skia-review.googlesource.com/21541
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2017-07-14 21:45:35 +00:00

75 lines
2.7 KiB
C

/*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SK_COMMON_FLAGS_PATH_RENDERER_H
#define SK_COMMON_FLAGS_PATH_RENDERER_H
#if SK_SUPPORT_GPU
#include "GrContextOptions.h"
#include "SkCommandLineFlags.h"
#include "SkTypes.h"
DECLARE_string(pr);
#define DEFINE_pathrenderer_flag \
DEFINE_string(pr, "all", \
"Set of enabled gpu path renderers. Defined as a list of: " \
"[[~]all [~]dashline [~]nvpr [~]msaa [~]aahairline [~]aaconvex " \
"[~]aalinearizing [~]small [~]tess [~]grdefault]")
inline GrContextOptions::GpuPathRenderers get_named_pathrenderers_flags(const char* name) {
using GpuPathRenderers = GrContextOptions::GpuPathRenderers;
if (!strcmp(name, "all")) {
return GpuPathRenderers::kAll;
} else if (!strcmp(name, "dashline")) {
return GpuPathRenderers::kDashLine;
} else if (!strcmp(name, "nvpr")) {
return GpuPathRenderers::kStencilAndCover;
} else if (!strcmp(name, "msaa")) {
return GpuPathRenderers::kMSAA;
} else if (!strcmp(name, "aahairline")) {
return GpuPathRenderers::kAAHairline;
} else if (!strcmp(name, "aaconvex")) {
return GpuPathRenderers::kAAConvex;
} else if (!strcmp(name, "aalinearizing")) {
return GpuPathRenderers::kAALinearizing;
} else if (!strcmp(name, "small")) {
return GpuPathRenderers::kSmall;
} else if (!strcmp(name, "ccpr")) {
return GpuPathRenderers::kCoverageCounting;
} else if (!strcmp(name, "tess")) {
return GpuPathRenderers::kTessellating;
} else if (!strcmp(name, "grdefault")) {
return GpuPathRenderers::kDefault;
}
SK_ABORT(SkStringPrintf("error: unknown named path renderer \"%s\"\n", name).c_str());
return GpuPathRenderers::kNone;
}
inline GrContextOptions::GpuPathRenderers CollectGpuPathRenderersFromFlags() {
using GpuPathRenderers = GrContextOptions::GpuPathRenderers;
if (FLAGS_pr.isEmpty()) {
return GpuPathRenderers::kAll;
}
GpuPathRenderers gpuPathRenderers = '~' == FLAGS_pr[0][0] ?
GpuPathRenderers::kAll : GpuPathRenderers::kNone;
for (int i = 0; i < FLAGS_pr.count(); ++i) {
const char* name = FLAGS_pr[i];
if (name[0] == '~') {
gpuPathRenderers &= ~get_named_pathrenderers_flags(&name[1]);
} else {
gpuPathRenderers |= get_named_pathrenderers_flags(name);
}
}
return gpuPathRenderers;
}
#endif // SK_SUPPORT_GPU
#endif