2017-02-22 19:00:42 +00:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
|
2017-08-30 19:14:04 +00:00
|
|
|
#include "GrTypesPriv.h"
|
2017-02-22 19:00:42 +00:00
|
|
|
#include "SkCommandLineFlags.h"
|
|
|
|
#include "SkTypes.h"
|
|
|
|
|
|
|
|
DECLARE_string(pr);
|
|
|
|
|
2017-03-06 16:29:48 +00:00
|
|
|
#define DEFINE_pathrenderer_flag \
|
2017-08-29 19:18:34 +00:00
|
|
|
DEFINE_string(pr, "default", \
|
2017-03-06 16:29:48 +00:00
|
|
|
"Set of enabled gpu path renderers. Defined as a list of: " \
|
2017-08-30 18:41:12 +00:00
|
|
|
"[[~]all [~]default [~]dashline [~]nvpr [~]msaa [~]aaconvex " \
|
2017-08-29 19:18:34 +00:00
|
|
|
"[~]aalinearizing [~]small [~]tess]")
|
2017-02-22 19:00:42 +00:00
|
|
|
|
2017-08-30 19:14:04 +00:00
|
|
|
inline GpuPathRenderers get_named_pathrenderers_flags(const char* name) {
|
2017-02-22 19:00:42 +00:00
|
|
|
if (!strcmp(name, "all")) {
|
|
|
|
return GpuPathRenderers::kAll;
|
2017-08-29 19:18:34 +00:00
|
|
|
} else if (!strcmp(name, "default")) {
|
|
|
|
return GpuPathRenderers::kDefault;
|
2017-02-22 19:00:42 +00:00
|
|
|
} 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, "aaconvex")) {
|
|
|
|
return GpuPathRenderers::kAAConvex;
|
|
|
|
} else if (!strcmp(name, "aalinearizing")) {
|
|
|
|
return GpuPathRenderers::kAALinearizing;
|
2017-03-16 12:45:39 +00:00
|
|
|
} else if (!strcmp(name, "small")) {
|
|
|
|
return GpuPathRenderers::kSmall;
|
2017-07-14 21:17:41 +00:00
|
|
|
} else if (!strcmp(name, "ccpr")) {
|
|
|
|
return GpuPathRenderers::kCoverageCounting;
|
2017-02-22 19:00:42 +00:00
|
|
|
} else if (!strcmp(name, "tess")) {
|
2017-03-01 19:59:05 +00:00
|
|
|
return GpuPathRenderers::kTessellating;
|
2017-08-22 13:47:50 +00:00
|
|
|
} else if (!strcmp(name, "none")) {
|
|
|
|
return GpuPathRenderers::kNone;
|
2017-02-22 19:00:42 +00:00
|
|
|
}
|
|
|
|
SK_ABORT(SkStringPrintf("error: unknown named path renderer \"%s\"\n", name).c_str());
|
|
|
|
return GpuPathRenderers::kNone;
|
|
|
|
}
|
|
|
|
|
2017-08-30 19:14:04 +00:00
|
|
|
inline GpuPathRenderers CollectGpuPathRenderersFromFlags() {
|
2017-02-22 19:00:42 +00:00
|
|
|
if (FLAGS_pr.isEmpty()) {
|
2017-08-29 19:18:34 +00:00
|
|
|
return GpuPathRenderers::kDefault;
|
2017-02-22 19:00:42 +00:00
|
|
|
}
|
|
|
|
GpuPathRenderers gpuPathRenderers = '~' == FLAGS_pr[0][0] ?
|
2017-08-29 19:18:34 +00:00
|
|
|
GpuPathRenderers::kDefault : GpuPathRenderers::kNone;
|
2017-02-22 19:00:42 +00:00
|
|
|
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
|