Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(402)

Side by Side Diff: tools/flags/SkCommonFlagsConfig.cpp

Issue 1755553003: Revert of Progress on gamma-correctness in the GPU backend. Fixed conversion of color and profile type to pix… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/flags/SkCommonFlagsConfig.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkCommonFlagsConfig.h" 8 #include "SkCommonFlagsConfig.h"
9 9
10 #include <stdlib.h> 10 #include <stdlib.h>
11 11
12 static const char defaultConfigs[] = 12 static const char defaultConfigs[] =
13 "565 8888 gpu nonrendering" 13 "565 8888 gpu nonrendering"
14 #if SK_ANGLE 14 #if SK_ANGLE
15 #ifdef SK_BUILD_FOR_WIN 15 #ifdef SK_BUILD_FOR_WIN
16 " angle" 16 " angle"
17 #endif 17 #endif
18 #endif 18 #endif
19 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK 19 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
20 " hwui" 20 " hwui"
21 #endif 21 #endif
22 ; 22 ;
23 23
24 static const char configHelp[] = 24 static const char configHelp[] =
25 "Options: 565 8888 debug gpu gpudebug gpudft gpunull " 25 "Options: 565 8888 debug gpu gpudebug gpudft gpunull "
26 "msaa16 msaa4 gpuf16 gpusrgb nonrendering null nullgpu nvprmsaa16 nvprmsaa4 " 26 "msaa16 msaa4 nonrendering null nullgpu nvprmsaa16 nvprmsaa4 "
27 "pdf pdf_poppler skp svg xps" 27 "pdf pdf_poppler skp svg xps"
28 #if SK_ANGLE 28 #if SK_ANGLE
29 #ifdef SK_BUILD_FOR_WIN 29 #ifdef SK_BUILD_FOR_WIN
30 " angle anglesrgb" 30 " angle"
31 #endif 31 #endif
32 " angle-gl" 32 " angle-gl"
33 #endif 33 #endif
34 #if SK_COMMAND_BUFFER 34 #if SK_COMMAND_BUFFER
35 " commandbuffer" 35 " commandbuffer"
36 #endif 36 #endif
37 #if SK_MESA 37 #if SK_MESA
38 " mesa" 38 " mesa"
39 #endif 39 #endif
40 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK 40 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
41 " hwui" 41 " hwui"
42 #endif 42 #endif
43 " or use extended form 'backend(option=value,...)'.\n"; 43 " or use extended form 'backend(option=value,...)'.\n";
44 44
45 static const char configExtendedHelp[] = 45 static const char configExtendedHelp[] =
46 "Extended form: 'backend(option=value,...)'\n\n" 46 "Extended form: 'backend(option=value,...)'\n\n"
47 "Possible backends and options:\n" 47 "Possible backends and options:\n"
48 #if SK_SUPPORT_GPU 48 #if SK_SUPPORT_GPU
49 "\n" 49 "\n"
50 "gpu(api=string,color=string,dit=bool,nvpr=bool,samples=int)\tGPU backend\n" 50 "gpu(api=string,dit=bool,nvpr=bool,samples=int)\tGPU backend\n"
51 "\tapi\ttype: string\tdefault: native.\n" 51 "\tapi\ttype: string\tdefault: native.\n"
52 "\t Select graphics API to use with gpu backend.\n" 52 "\t Select graphics API to use with gpu backend.\n"
53 "\t Options:\n" 53 "\t Options:\n"
54 "\t\tnative\t\t\tUse platform default OpenGL or OpenGL ES backend.\n" 54 "\t\tnative\t\t\tUse platform default OpenGL or OpenGL ES backend.\n"
55 "\t\tgl \t\t\tUse OpenGL.\n" 55 "\t\tgl \t\t\tUse OpenGL.\n"
56 "\t\tgles \t\t\tUse OpenGL ES.\n" 56 "\t\tgles \t\t\tUse OpenGL ES.\n"
57 "\t\tdebug \t\t\tUse debug OpenGL.\n" 57 "\t\tdebug \t\t\tUse debug OpenGL.\n"
58 "\t\tnull \t\t\tUse null OpenGL.\n" 58 "\t\tnull \t\t\tUse null OpenGL.\n"
59 #if SK_ANGLE 59 #if SK_ANGLE
60 #ifdef SK_BUILD_FOR_WIN 60 #ifdef SK_BUILD_FOR_WIN
61 "\t\tangle\t\t\tUse ANGLE DirectX.\n" 61 "\t\tangle\t\t\tUse ANGLE DirectX.\n"
62 #endif 62 #endif
63 "\t\tangle-gl\t\t\tUse ANGLE OpenGL.\n" 63 "\t\tangle-gl\t\t\tUse ANGLE OpenGL.\n"
64 #endif 64 #endif
65 #if SK_COMMAND_BUFFER 65 #if SK_COMMAND_BUFFER
66 "\t\tcommandbuffer\t\tUse command buffer.\n" 66 "\t\tcommandbuffer\t\tUse command buffer.\n"
67 "\t\tcommandbuffer3\t\tUse command buffer ES 3.0 (experimental).\n" 67 "\t\tcommandbuffer3\t\tUse command buffer ES 3.0 (experimental).\n"
68 #endif 68 #endif
69 #if SK_MESA 69 #if SK_MESA
70 "\t\tmesa\t\t\tUse MESA.\n" 70 "\t\tmesa\t\t\tUse MESA.\n"
71 #endif 71 #endif
72 "\tcolor\ttype: string\tdefault: 8888.\n"
73 "\t Select framebuffer color format.\n"
74 "\t Options:\n"
75 "\t\t8888\t\t\tLinear 8888.\n"
76 "\t\tf16 \t\t\tLinear 16-bit floating point.\n"
77 "\t\tsrgb\t\t\tsRGB 8888.\n"
78 "\tdit\ttype: bool\tdefault: false.\n" 72 "\tdit\ttype: bool\tdefault: false.\n"
79 "\t Use device independent text.\n" 73 "\t Use device independent text.\n"
80 "\tnvpr\ttype: bool\tdefault: false.\n" 74 "\tnvpr\ttype: bool\tdefault: false.\n"
81 "\t Use NV_path_rendering OpenGL and OpenGL ES extension.\n" 75 "\t Use NV_path_rendering OpenGL and OpenGL ES extension.\n"
82 "\tsamples\ttype: int\tdefault: 0.\n" 76 "\tsamples\ttype: int\tdefault: 0.\n"
83 "\t Use multisampling with N samples.\n" 77 "\t Use multisampling with N samples.\n"
84 "\n" 78 "\n"
85 "Predefined configs:\n\n" 79 "Predefined configs:\n\n"
86 "\tgpu \t= gpu()\n" 80 "\tgpu \t= gpu()\n"
87 "\tmsaa4 \t= gpu(samples=4)\n" 81 "\tmsaa4 \t= gpu(samples=4)\n"
88 "\tmsaa16 \t= gpu(samples=16)\n" 82 "\tmsaa16 \t= gpu(samples=16)\n"
89 "\tnvprmsaa4\t= gpu(nvpr=true,samples=4)\n" 83 "\tnvprmsaa4\t= gpu(nvpr=true,samples=4)\n"
90 "\tnvprmsaa16\t= gpu(nvpr=true,samples=16)\n" 84 "\tnvprmsaa16\t= gpu(nvpr=true,samples=16)\n"
91 "\tgpuf16 \t= gpu(color=f16)\n"
92 "\tgpusrgb \t= gpu(color=srgb)\n"
93 "\tgpudft \t= gpu(dit=true)\n" 85 "\tgpudft \t= gpu(dit=true)\n"
94 "\tgpudebug \t= gpu(api=debug)\n" 86 "\tgpudebug \t= gpu(api=debug)\n"
95 "\tgpunull \t= gpu(api=null)\n" 87 "\tgpunull \t= gpu(api=null)\n"
96 "\tdebug \t= gpu(api=debug)\n" 88 "\tdebug \t= gpu(api=debug)\n"
97 "\tnullgpu \t= gpu(api=null)\n" 89 "\tnullgpu \t= gpu(api=null)\n"
98 #if SK_ANGLE 90 #if SK_ANGLE
99 #ifdef SK_BUILD_FOR_WIN 91 #ifdef SK_BUILD_FOR_WIN
100 "\tangle \t= gpu(api=angle)\n" 92 "\tangle \t= gpu(api=angle)\n"
101 "\tanglesrgb \t= gpu(api=angle,color=srgb)\n"
102 #endif 93 #endif
103 "\tangle-gl \t= gpu(api=angle-gl)\n" 94 "\tangle-gl \t= gpu(api=angle-gl)\n"
104 #endif 95 #endif
105 #if SK_COMMAND_BUFFER 96 #if SK_COMMAND_BUFFER
106 "\tcommandbuffer\t= gpu(api=commandbuffer)\n" 97 "\tcommandbuffer\t= gpu(api=commandbuffer)\n"
107 #endif 98 #endif
108 #if SK_MESA 99 #if SK_MESA
109 "\tmesa \t= gpu(api=mesa)\n" 100 "\tmesa \t= gpu(api=mesa)\n"
110 #endif 101 #endif
111 #endif 102 #endif
112 ; 103 ;
113 104
114 DEFINE_extended_string(config, defaultConfigs, configHelp, configExtendedHelp); 105 DEFINE_extended_string(config, defaultConfigs, configHelp, configExtendedHelp);
115 106
116 static const struct { 107 static const struct {
117 const char* predefinedConfig; 108 const char* predefinedConfig;
118 const char* backend; 109 const char* backend;
119 const char* options; 110 const char* options;
120 } gPredefinedConfigs[] = { 111 } gPredefinedConfigs[] = {
121 #if SK_SUPPORT_GPU 112 #if SK_SUPPORT_GPU
122 { "gpu", "gpu", "" }, 113 { "gpu", "gpu", "" },
123 { "msaa4", "gpu", "samples=4" }, 114 { "msaa4", "gpu", "samples=4" },
124 { "msaa16", "gpu", "samples=16" }, 115 { "msaa16", "gpu", "samples=16" },
125 { "nvprmsaa4", "gpu", "nvpr=true,samples=4,dit=true" }, 116 { "nvprmsaa4", "gpu", "nvpr=true,samples=4,dit=true" },
126 { "nvprmsaa16", "gpu", "nvpr=true,samples=16,dit=true" }, 117 { "nvprmsaa16", "gpu", "nvpr=true,samples=16,dit=true" },
127 { "gpuf16", "gpu", "color=f16" },
128 { "gpusrgb", "gpu", "color=srgb" },
129 { "gpudft", "gpu", "dit=true" }, 118 { "gpudft", "gpu", "dit=true" },
130 { "gpudebug", "gpu", "api=debug" }, 119 { "gpudebug", "gpu", "api=debug" },
131 { "gpunull", "gpu", "api=null" }, 120 { "gpunull", "gpu", "api=null" },
132 { "debug", "gpu", "api=debug" }, 121 { "debug", "gpu", "api=debug" },
133 { "nullgpu", "gpu", "api=null" } 122 { "nullgpu", "gpu", "api=null" }
134 #if SK_ANGLE 123 #if SK_ANGLE
135 #ifdef SK_BUILD_FOR_WIN 124 #ifdef SK_BUILD_FOR_WIN
136 , { "angle", "gpu", "api=angle" } 125 , { "angle", "gpu", "api=angle" }
137 , { "anglesrgb", "gpu", "api=angle,color=srgb" }
138 #endif 126 #endif
139 , { "angle-gl", "gpu", "api=angle-gl" } 127 , { "angle-gl", "gpu", "api=angle-gl" }
140 #endif 128 #endif
141 #if SK_COMMAND_BUFFER 129 #if SK_COMMAND_BUFFER
142 , { "commandbuffer", "gpu", "api=commandbuffer" } 130 , { "commandbuffer", "gpu", "api=commandbuffer" }
143 #endif 131 #endif
144 #if SK_MESA 132 #if SK_MESA
145 , { "mesa", "gpu", "api=mesa" } 133 , { "mesa", "gpu", "api=mesa" }
146 #endif 134 #endif
147 #else 135 #else
148 { "", "", "" } 136 { "", "", "" }
149 #endif 137 #endif
150 }; 138 };
151 139
152 SkCommandLineConfig::SkCommandLineConfig(const SkString& tag, const SkString& ba ckend, 140 SkCommandLineConfig::SkCommandLineConfig(const SkString& tag, const SkString& ba ckend,
153 const SkTArray<SkString>& viaParts) 141 const SkTArray<SkString>& viaParts)
154 : fTag(tag) 142 : fTag(tag)
155 , fBackend(backend) 143 , fBackend(backend)
156 , fViaParts(viaParts) { 144 , fViaParts(viaParts) {
157 } 145 }
158 SkCommandLineConfig::~SkCommandLineConfig() { 146 SkCommandLineConfig::~SkCommandLineConfig() {
159 } 147 }
160 148
161 #if SK_SUPPORT_GPU 149 #if SK_SUPPORT_GPU
162 SkCommandLineConfigGpu::SkCommandLineConfigGpu( 150 SkCommandLineConfigGpu::SkCommandLineConfigGpu(
163 const SkString& tag, const SkTArray<SkString>& viaParts, 151 const SkString& tag, const SkTArray<SkString>& viaParts,
164 ContextType contextType, bool useNVPR, bool useDIText, int samples, 152 ContextType contextType, bool useNVPR, bool useDIText, int samples)
165 SkColorType colorType, SkColorProfileType profileType)
166 : SkCommandLineConfig(tag, SkString("gpu"), viaParts) 153 : SkCommandLineConfig(tag, SkString("gpu"), viaParts)
167 , fContextType(contextType) 154 , fContextType(contextType)
168 , fUseNVPR(useNVPR) 155 , fUseNVPR(useNVPR)
169 , fUseDIText(useDIText) 156 , fUseDIText(useDIText)
170 , fSamples(samples) 157 , fSamples(samples) {
171 , fColorType(colorType)
172 , fProfileType(profileType) {
173 } 158 }
174 static bool parse_option_int(const SkString& value, int* outInt) { 159 static bool parse_option_int(const SkString& value, int* outInt) {
175 if (value.isEmpty()) { 160 if (value.isEmpty()) {
176 return false; 161 return false;
177 } 162 }
178 char* endptr = nullptr; 163 char* endptr = nullptr;
179 long intValue = strtol(value.c_str(), &endptr, 10); 164 long intValue = strtol(value.c_str(), &endptr, 10);
180 if (*endptr != '\0') { 165 if (*endptr != '\0') {
181 return false; 166 return false;
182 } 167 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 } 224 }
240 #endif 225 #endif
241 #if SK_MESA 226 #if SK_MESA
242 if (value.equals("mesa")) { 227 if (value.equals("mesa")) {
243 *outContextType = GrContextFactory::kMESA_GLContextType; 228 *outContextType = GrContextFactory::kMESA_GLContextType;
244 return true; 229 return true;
245 } 230 }
246 #endif 231 #endif
247 return false; 232 return false;
248 } 233 }
249 static bool parse_option_gpu_color(const SkString& value,
250 SkColorType* outColorType,
251 SkColorProfileType* outProfileType) {
252 if (value.equals("8888")) {
253 *outColorType = kN32_SkColorType;
254 *outProfileType = kLinear_SkColorProfileType;
255 return true;
256 }
257 if (value.equals("f16")) {
258 *outColorType = kRGBA_F16_SkColorType;
259 *outProfileType = kLinear_SkColorProfileType;
260 return true;
261 }
262 if (value.equals("srgb")) {
263 *outColorType = kN32_SkColorType;
264 *outProfileType = kSRGB_SkColorProfileType;
265 return true;
266 }
267 return false;
268 }
269 234
270 SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag, 235 SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag,
271 const SkTArray<SkString>& vias, 236 const SkTArray<SkString>& vias,
272 const SkString& options) { 237 const SkString& options) {
273 // Defaults for GPU backend. 238 // Defaults for GPU backend.
274 bool seenAPI = false; 239 bool seenAPI = false;
275 SkCommandLineConfigGpu::ContextType contextType = GrContextFactory::kNative_ GLContextType; 240 SkCommandLineConfigGpu::ContextType contextType = GrContextFactory::kNative_ GLContextType;
276 bool seenUseNVPR = false; 241 bool seenUseNVPR = false;
277 bool useNVPR = false; 242 bool useNVPR = false;
278 bool seenUseDIText =false; 243 bool seenUseDIText =false;
279 bool useDIText = false; 244 bool useDIText = false;
280 bool seenSamples = false; 245 bool seenSamples = false;
281 int samples = 0; 246 int samples = 0;
282 bool seenColor = false;
283 SkColorType colorType = kN32_SkColorType;
284 SkColorProfileType profileType = kLinear_SkColorProfileType;
285 247
286 SkTArray<SkString> optionParts; 248 SkTArray<SkString> optionParts;
287 SkStrSplit(options.c_str(), ",", kStrict_SkStrSplitMode, &optionParts); 249 SkStrSplit(options.c_str(), ",", kStrict_SkStrSplitMode, &optionParts);
288 for (int i = 0; i < optionParts.count(); ++i) { 250 for (int i = 0; i < optionParts.count(); ++i) {
289 SkTArray<SkString> keyValueParts; 251 SkTArray<SkString> keyValueParts;
290 SkStrSplit(optionParts[i].c_str(), "=", kStrict_SkStrSplitMode, &keyValu eParts); 252 SkStrSplit(optionParts[i].c_str(), "=", kStrict_SkStrSplitMode, &keyValu eParts);
291 if (keyValueParts.count() != 2) { 253 if (keyValueParts.count() != 2) {
292 return nullptr; 254 return nullptr;
293 } 255 }
294 const SkString& key = keyValueParts[0]; 256 const SkString& key = keyValueParts[0];
295 const SkString& value = keyValueParts[1]; 257 const SkString& value = keyValueParts[1];
296 bool valueOk = false; 258 bool valueOk = false;
297 if (key.equals("api") && !seenAPI) { 259 if (key.equals("api") && !seenAPI) {
298 valueOk = parse_option_gpu_api(value, &contextType); 260 valueOk = parse_option_gpu_api(value, &contextType);
299 seenAPI = true; 261 seenAPI = true;
300 } else if (key.equals("nvpr") && !seenUseNVPR) { 262 } else if (key.equals("nvpr") && !seenUseNVPR) {
301 valueOk = parse_option_bool(value, &useNVPR); 263 valueOk = parse_option_bool(value, &useNVPR);
302 seenUseNVPR = true; 264 seenUseNVPR = true;
303 } else if (key.equals("dit") && !seenUseDIText) { 265 } else if (key.equals("dit") && !seenUseDIText) {
304 valueOk = parse_option_bool(value, &useDIText); 266 valueOk = parse_option_bool(value, &useDIText);
305 seenUseDIText = true; 267 seenUseDIText = true;
306 } else if (key.equals("samples") && !seenSamples) { 268 } else if (key.equals("samples") && !seenSamples) {
307 valueOk = parse_option_int(value, &samples); 269 valueOk = parse_option_int(value, &samples);
308 seenSamples = true; 270 seenSamples = true;
309 } else if (key.equals("color") && !seenColor) {
310 valueOk = parse_option_gpu_color(value, &colorType, &profileType);
311 seenColor = true;
312 } 271 }
313 if (!valueOk) { 272 if (!valueOk) {
314 return nullptr; 273 return nullptr;
315 } 274 }
316 } 275 }
317 return new SkCommandLineConfigGpu(tag, vias, contextType, useNVPR, useDIText , samples, 276 return new SkCommandLineConfigGpu(tag, vias, contextType, useNVPR, useDIText , samples);
318 colorType, profileType);
319 } 277 }
320 #endif 278 #endif
321 279
322 void ParseConfigs(const SkCommandLineFlags::StringArray& configs, 280 void ParseConfigs(const SkCommandLineFlags::StringArray& configs,
323 SkCommandLineConfigArray* outResult) { 281 SkCommandLineConfigArray* outResult) {
324 outResult->reset(); 282 outResult->reset();
325 for (int i = 0; i < configs.count(); ++i) { 283 for (int i = 0; i < configs.count(); ++i) {
326 SkString extendedBackend; 284 SkString extendedBackend;
327 SkString extendedOptions; 285 SkString extendedOptions;
328 SkString simpleBackend; 286 SkString simpleBackend;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 if (extendedBackend.equals("gpu")) { 332 if (extendedBackend.equals("gpu")) {
375 parsedConfig = parse_command_line_config_gpu(tag, vias, extendedOpti ons); 333 parsedConfig = parse_command_line_config_gpu(tag, vias, extendedOpti ons);
376 } 334 }
377 #endif 335 #endif
378 if (!parsedConfig) { 336 if (!parsedConfig) {
379 parsedConfig = new SkCommandLineConfig(tag, simpleBackend, vias); 337 parsedConfig = new SkCommandLineConfig(tag, simpleBackend, vias);
380 } 338 }
381 outResult->emplace_back(parsedConfig); 339 outResult->emplace_back(parsedConfig);
382 } 340 }
383 } 341 }
OLDNEW
« no previous file with comments | « tools/flags/SkCommonFlagsConfig.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698