• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2017 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SK_COMMON_FLAGS_GPU_H
9 #define SK_COMMON_FLAGS_GPU_H
10 
11 #include "GrTypesPriv.h"
12 #include "SkCommandLineFlags.h"
13 #include "SkTypes.h"
14 
15 DECLARE_int32(gpuThreads);
16 DECLARE_bool(cachePathMasks);
17 DECLARE_bool(noGS);
18 DECLARE_string(pr);
19 DECLARE_bool(disableExplicitAlloc);
20 DECLARE_bool(reduceOpListSplitting);
21 
get_named_pathrenderers_flags(const char * name)22 inline GpuPathRenderers get_named_pathrenderers_flags(const char* name) {
23     if (!strcmp(name, "none")) {
24         return GpuPathRenderers::kNone;
25     } else if (!strcmp(name, "dashline")) {
26         return GpuPathRenderers::kDashLine;
27     } else if (!strcmp(name, "nvpr")) {
28         return GpuPathRenderers::kStencilAndCover;
29     } else if (!strcmp(name, "ccpr")) {
30         return GpuPathRenderers::kCoverageCounting;
31     } else if (!strcmp(name, "aahairline")) {
32         return GpuPathRenderers::kAAHairline;
33     } else if (!strcmp(name, "aaconvex")) {
34         return GpuPathRenderers::kAAConvex;
35     } else if (!strcmp(name, "aalinearizing")) {
36         return GpuPathRenderers::kAALinearizing;
37     } else if (!strcmp(name, "small")) {
38         return GpuPathRenderers::kSmall;
39     } else if (!strcmp(name, "tess")) {
40         return GpuPathRenderers::kTessellating;
41     } else if (!strcmp(name, "all")) {
42         return GpuPathRenderers::kAll;
43     }
44     SK_ABORT(SkStringPrintf("error: unknown named path renderer \"%s\"\n", name).c_str());
45     return GpuPathRenderers::kNone;
46 }
47 
CollectGpuPathRenderersFromFlags()48 inline GpuPathRenderers CollectGpuPathRenderersFromFlags() {
49     if (FLAGS_pr.isEmpty()) {
50         return GpuPathRenderers::kAll;
51     }
52     GpuPathRenderers gpuPathRenderers = '~' == FLAGS_pr[0][0]
53             ? GpuPathRenderers::kAll : GpuPathRenderers::kNone;
54     for (int i = 0; i < FLAGS_pr.count(); ++i) {
55         const char* name = FLAGS_pr[i];
56         if (name[0] == '~') {
57             gpuPathRenderers &= ~get_named_pathrenderers_flags(&name[1]);
58         } else {
59             gpuPathRenderers |= get_named_pathrenderers_flags(name);
60         }
61     }
62     return gpuPathRenderers;
63 }
64 
65 /**
66  *  Helper to set GrContextOptions from common GPU flags.
67  */
68 void SetCtxOptionsFromCommonFlags(struct GrContextOptions*);
69 
70 #endif
71