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

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

Issue 2389983002: Refactored SkColorSpace and added in a Lab PCS GM (Closed)
Patch Set: Responding to comments Created 4 years, 2 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
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 "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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 return true; 274 return true;
275 } 275 }
276 276
277 SkTArray<SkString> commands; 277 SkTArray<SkString> commands;
278 SkStrSplit(value.c_str(), "_", &commands); 278 SkStrSplit(value.c_str(), "_", &commands);
279 if (commands.count() < 1 || commands.count() > 2) { 279 if (commands.count() < 1 || commands.count() > 2) {
280 return false; 280 return false;
281 } 281 }
282 282
283 // First, figure out color gamut that we'll work in (default to sRGB) 283 // First, figure out color gamut that we'll work in (default to sRGB)
284 sk_sp<SkColorSpace> colorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_ Named); 284 const bool linearGamma = commands[0].equals("f16");
285 *outColorSpace = SkColorSpace::NewNamed(linearGamma ? SkColorSpace::kSRGBLin ear_Named
286 : SkColorSpace::kSRGB_Na med);
285 if (commands.count() == 2) { 287 if (commands.count() == 2) {
286 if (commands[1].equals("srgb")) { 288 if (commands[1].equals("srgb")) {
287 // sRGB gamut (which is our default) 289 // sRGB gamut (which is our default)
288 } else if (commands[1].equals("wide")) { 290 } else if (commands[1].equals("wide")) {
289 // WideGamut RGB 291 // WideGamut RGB
290 const float gWideGamutRGB_toXYZD50[]{ 292 const float gWideGamutRGB_toXYZD50[]{
291 0.7161046f, 0.1009296f, 0.1471858f, // -> X 293 0.7161046f, 0.1009296f, 0.1471858f, // -> X
292 0.2581874f, 0.7249378f, 0.0168748f, // -> Y 294 0.2581874f, 0.7249378f, 0.0168748f, // -> Y
293 0.0000000f, 0.0517813f, 0.7734287f, // -> Z 295 0.0000000f, 0.0517813f, 0.7734287f, // -> Z
294 }; 296 };
295 SkMatrix44 wideGamutRGBMatrix(SkMatrix44::kUninitialized_Constructor ); 297 SkMatrix44 wideGamutRGBMatrix(SkMatrix44::kUninitialized_Constructor );
296 wideGamutRGBMatrix.set3x3RowMajorf(gWideGamutRGB_toXYZD50); 298 wideGamutRGBMatrix.set3x3RowMajorf(gWideGamutRGB_toXYZD50);
297 colorSpace = SkColorSpace::NewRGB(SkColorSpace::kSRGB_RenderTargetGa mma, 299 *outColorSpace = SkColorSpace::NewRGB(linearGamma
298 wideGamutRGBMatrix); 300 ? SkColorSpace::kLinea r_RenderTargetGamma
301 : SkColorSpace::kSRGB_ RenderTargetGamma,
302 wideGamutRGBMatrix);
299 } else { 303 } else {
300 // Unknown color gamut 304 // Unknown color gamut
301 return false; 305 return false;
302 } 306 }
303 } 307 }
304 308
305 // Now pick a color type 309 // Now pick a color type
306 if (commands[0].equals("f16")) { 310 if (commands[0].equals("f16")) {
307 *outColorType = kRGBA_F16_SkColorType; 311 *outColorType = kRGBA_F16_SkColorType;
308 *outColorSpace = as_CSB(colorSpace)->makeLinearGamma();
309 return true; 312 return true;
310 } 313 }
311 if (commands[0].equals("srgb")) { 314 if (commands[0].equals("srgb")) {
312 *outColorType = kRGBA_8888_SkColorType; 315 *outColorType = kRGBA_8888_SkColorType;
313 *outColorSpace = colorSpace;
314 return true; 316 return true;
315 } 317 }
316 return false; 318 return false;
317 } 319 }
318 320
319 SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag, 321 SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag,
320 const SkTArray<SkString>& vias, 322 const SkTArray<SkString>& vias,
321 const SkString& options) { 323 const SkString& options) {
322 // Defaults for GPU backend. 324 // Defaults for GPU backend.
323 bool seenAPI = false; 325 bool seenAPI = false;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 if (extendedBackend.equals("gpu")) { 423 if (extendedBackend.equals("gpu")) {
422 parsedConfig = parse_command_line_config_gpu(tag, vias, extendedOpti ons); 424 parsedConfig = parse_command_line_config_gpu(tag, vias, extendedOpti ons);
423 } 425 }
424 #endif 426 #endif
425 if (!parsedConfig) { 427 if (!parsedConfig) {
426 parsedConfig = new SkCommandLineConfig(tag, simpleBackend, vias); 428 parsedConfig = new SkCommandLineConfig(tag, simpleBackend, vias);
427 } 429 }
428 outResult->emplace_back(parsedConfig); 430 outResult->emplace_back(parsedConfig);
429 } 431 }
430 } 432 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698