OLD | NEW |
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 "SkColorSpace_Base.h" | 8 #include "SkColorSpace_Base.h" |
9 #include "SkCommonFlagsConfig.h" | 9 #include "SkCommonFlagsConfig.h" |
10 #include "SkImageInfo.h" | 10 #include "SkImageInfo.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 "\t Select framebuffer color format.\n" | 126 "\t Select framebuffer color format.\n" |
127 "\t Options:\n" | 127 "\t Options:\n" |
128 "\t\t8888\t\t\tLinear 8888.\n" | 128 "\t\t8888\t\t\tLinear 8888.\n" |
129 "\t\tf16{_gamut}\t\tLinear 16-bit floating point.\n" | 129 "\t\tf16{_gamut}\t\tLinear 16-bit floating point.\n" |
130 "\t\tsrgb{_gamut}\t\tsRGB 8888.\n" | 130 "\t\tsrgb{_gamut}\t\tsRGB 8888.\n" |
131 "\t gamut\ttype: string\tdefault: srgb.\n" | 131 "\t gamut\ttype: string\tdefault: srgb.\n" |
132 "\t Select color gamut for f16 or sRGB format buffers.\n" | 132 "\t Select color gamut for f16 or sRGB format buffers.\n" |
133 "\t Options:\n" | 133 "\t Options:\n" |
134 "\t\tsrgb\t\t\tsRGB gamut.\n" | 134 "\t\tsrgb\t\t\tsRGB gamut.\n" |
135 "\t\twide\t\t\tWide Gamut RGB.\n" | 135 "\t\twide\t\t\tWide Gamut RGB.\n" |
136 "\t\tnarrow\t\t\tNarrow Gamut RGB.\n" | |
137 "\tdit\ttype: bool\tdefault: false.\n" | 136 "\tdit\ttype: bool\tdefault: false.\n" |
138 "\t Use device independent text.\n" | 137 "\t Use device independent text.\n" |
139 "\tnvpr\ttype: bool\tdefault: false.\n" | 138 "\tnvpr\ttype: bool\tdefault: false.\n" |
140 "\t Use NV_path_rendering OpenGL and OpenGL ES extension.\n" | 139 "\t Use NV_path_rendering OpenGL and OpenGL ES extension.\n" |
141 "\tsamples\ttype: int\tdefault: 0.\n" | 140 "\tsamples\ttype: int\tdefault: 0.\n" |
142 "\t Use multisampling with N samples.\n" | 141 "\t Use multisampling with N samples.\n" |
143 "\n" | 142 "\n" |
144 "Predefined configs:\n\n" | 143 "Predefined configs:\n\n" |
145 // Help text for pre-defined configs is auto-generated from gPredefinedConfi
gs | 144 // Help text for pre-defined configs is auto-generated from gPredefinedConfi
gs |
146 #endif | 145 #endif |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 return true; | 275 return true; |
277 } | 276 } |
278 | 277 |
279 SkTArray<SkString> commands; | 278 SkTArray<SkString> commands; |
280 SkStrSplit(value.c_str(), "_", &commands); | 279 SkStrSplit(value.c_str(), "_", &commands); |
281 if (commands.count() < 1 || commands.count() > 2) { | 280 if (commands.count() < 1 || commands.count() > 2) { |
282 return false; | 281 return false; |
283 } | 282 } |
284 | 283 |
285 // First, figure out color gamut that we'll work in (default to sRGB) | 284 // First, figure out color gamut that we'll work in (default to sRGB) |
286 sk_sp<SkColorSpace> colorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_
Named); | 285 const bool linearGamma = commands[0].equals("f16"); |
| 286 *outColorSpace = SkColorSpace::NewNamed(linearGamma ? SkColorSpace::kSRGBLin
ear_Named |
| 287 : SkColorSpace::kSRGB_Na
med); |
287 if (commands.count() == 2) { | 288 if (commands.count() == 2) { |
288 if (commands[1].equals("srgb")) { | 289 if (commands[1].equals("srgb")) { |
289 // sRGB gamut (which is our default) | 290 // sRGB gamut (which is our default) |
290 } else if (commands[1].equals("wide")) { | 291 } else if (commands[1].equals("wide")) { |
291 // WideGamut RGB | 292 // WideGamut RGB |
292 const float gWideGamutRGB_toXYZD50[]{ | 293 const float gWideGamutRGB_toXYZD50[]{ |
293 0.7161046f, 0.1009296f, 0.1471858f, // -> X | 294 0.7161046f, 0.1009296f, 0.1471858f, // -> X |
294 0.2581874f, 0.7249378f, 0.0168748f, // -> Y | 295 0.2581874f, 0.7249378f, 0.0168748f, // -> Y |
295 0.0000000f, 0.0517813f, 0.7734287f, // -> Z | 296 0.0000000f, 0.0517813f, 0.7734287f, // -> Z |
296 }; | 297 }; |
297 SkMatrix44 wideGamutRGBMatrix(SkMatrix44::kUninitialized_Constructor
); | 298 SkMatrix44 wideGamutRGBMatrix(SkMatrix44::kUninitialized_Constructor
); |
298 wideGamutRGBMatrix.set3x3RowMajorf(gWideGamutRGB_toXYZD50); | 299 wideGamutRGBMatrix.set3x3RowMajorf(gWideGamutRGB_toXYZD50); |
299 colorSpace = SkColorSpace::NewRGB(SkColorSpace::kSRGB_RenderTargetGa
mma, | 300 *outColorSpace = SkColorSpace::NewRGB(linearGamma |
300 wideGamutRGBMatrix); | 301 ? SkColorSpace::kLinea
r_RenderTargetGamma |
| 302 : SkColorSpace::kSRGB_
RenderTargetGamma, |
| 303 wideGamutRGBMatrix); |
301 } else if (commands[1].equals("narrow")) { | 304 } else if (commands[1].equals("narrow")) { |
302 // NarrowGamut RGB (an artifically smaller than sRGB gamut) | 305 // NarrowGamut RGB (an artifically smaller than sRGB gamut) |
303 SkColorSpacePrimaries primaries ={ | 306 SkColorSpacePrimaries primaries ={ |
304 0.54f, 0.33f, // Rx, Ry | 307 0.54f, 0.33f, // Rx, Ry |
305 0.33f, 0.50f, // Gx, Gy | 308 0.33f, 0.50f, // Gx, Gy |
306 0.25f, 0.20f, // Bx, By | 309 0.25f, 0.20f, // Bx, By |
307 0.3127f, 0.3290f, // Wx, Wy | 310 0.3127f, 0.3290f, // Wx, Wy |
308 }; | 311 }; |
309 SkMatrix44 narrowGamutRGBMatrix(SkMatrix44::kUninitialized_Construct
or); | 312 SkMatrix44 narrowGamutRGBMatrix(SkMatrix44::kUninitialized_Construct
or); |
310 primaries.toXYZD50(&narrowGamutRGBMatrix); | 313 primaries.toXYZD50(&narrowGamutRGBMatrix); |
311 colorSpace = SkColorSpace::NewRGB(SkColorSpace::kSRGB_RenderTargetGa
mma, | 314 *outColorSpace = SkColorSpace::NewRGB(linearGamma |
312 narrowGamutRGBMatrix); | 315 ? SkColorSpace::kLinea
r_RenderTargetGamma |
| 316 : SkColorSpace::kSRGB_
RenderTargetGamma, |
| 317 narrowGamutRGBMatrix); |
313 } else { | 318 } else { |
314 // Unknown color gamut | 319 // Unknown color gamut |
315 return false; | 320 return false; |
316 } | 321 } |
317 } | 322 } |
318 | 323 |
319 // Now pick a color type | 324 // Now pick a color type |
320 if (commands[0].equals("f16")) { | 325 if (commands[0].equals("f16")) { |
321 *outColorType = kRGBA_F16_SkColorType; | 326 *outColorType = kRGBA_F16_SkColorType; |
322 *outColorSpace = as_CSB(colorSpace)->makeLinearGamma(); | |
323 return true; | 327 return true; |
324 } | 328 } |
325 if (commands[0].equals("srgb")) { | 329 if (commands[0].equals("srgb")) { |
326 *outColorType = kRGBA_8888_SkColorType; | 330 *outColorType = kRGBA_8888_SkColorType; |
327 *outColorSpace = colorSpace; | |
328 return true; | 331 return true; |
329 } | 332 } |
330 return false; | 333 return false; |
331 } | 334 } |
332 | 335 |
333 SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag, | 336 SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag, |
334 const SkTArray<SkString>&
vias, | 337 const SkTArray<SkString>&
vias, |
335 const SkString& options) { | 338 const SkString& options) { |
336 // Defaults for GPU backend. | 339 // Defaults for GPU backend. |
337 bool seenAPI = false; | 340 bool seenAPI = false; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 if (extendedBackend.equals("gpu")) { | 438 if (extendedBackend.equals("gpu")) { |
436 parsedConfig = parse_command_line_config_gpu(tag, vias, extendedOpti
ons); | 439 parsedConfig = parse_command_line_config_gpu(tag, vias, extendedOpti
ons); |
437 } | 440 } |
438 #endif | 441 #endif |
439 if (!parsedConfig) { | 442 if (!parsedConfig) { |
440 parsedConfig = new SkCommandLineConfig(tag, simpleBackend, vias); | 443 parsedConfig = new SkCommandLineConfig(tag, simpleBackend, vias); |
441 } | 444 } |
442 outResult->emplace_back(parsedConfig); | 445 outResult->emplace_back(parsedConfig); |
443 } | 446 } |
444 } | 447 } |
OLD | NEW |