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

Unified Diff: ui/gfx/color_space.cc

Issue 2826513002: color: Use named gamuts in ToSkColorSpace (Closed)
Patch Set: Add named gamut parametric trfn Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/gfx/color_space_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/color_space.cc
diff --git a/ui/gfx/color_space.cc b/ui/gfx/color_space.cc
index 27a0f54364ac73b8e6a28919253bb1cf5f783e99..ef58e58039468528d7b56fd2683f8f2926a03bb7 100644
--- a/ui/gfx/color_space.cc
+++ b/ui/gfx/color_space.cc
@@ -427,25 +427,57 @@ sk_sp<SkColorSpace> ColorSpace::ToSkColorSpace() const {
return SkColorSpace::MakeSRGBLinear();
}
- SkMatrix44 to_xyz_d50;
- GetPrimaryMatrix(&to_xyz_d50);
-
- // Use the named sRGB and linear transfer functions.
- if (transfer_ == TransferID::IEC61966_2_1) {
- return SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma,
- to_xyz_d50);
+ // Prefer to used the named gamma and gamut, if possible.
+ bool has_named_gamma = true;
+ SkColorSpace::RenderTargetGamma named_gamma =
+ SkColorSpace::kSRGB_RenderTargetGamma;
+ switch (transfer_) {
+ case TransferID::IEC61966_2_1:
+ break;
+ case TransferID::LINEAR:
+ case TransferID::LINEAR_HDR:
+ named_gamma = SkColorSpace::kLinear_RenderTargetGamma;
+ break;
+ default:
+ has_named_gamma = false;
+ break;
}
- if (transfer_ == TransferID::LINEAR || transfer_ == TransferID::LINEAR_HDR) {
- return SkColorSpace::MakeRGB(SkColorSpace::kLinear_RenderTargetGamma,
- to_xyz_d50);
+ bool has_named_gamut = true;
+ SkColorSpace::Gamut named_gamut = SkColorSpace::kSRGB_Gamut;
+ switch (primaries_) {
+ case PrimaryID::BT709:
+ break;
+ case PrimaryID::ADOBE_RGB:
+ named_gamut = SkColorSpace::kAdobeRGB_Gamut;
+ break;
+ case PrimaryID::SMPTEST432_1:
+ named_gamut = SkColorSpace::kDCIP3_D65_Gamut;
+ break;
+ case PrimaryID::BT2020:
+ named_gamut = SkColorSpace::kRec2020_Gamut;
+ break;
+ default:
+ has_named_gamut = false;
+ break;
}
+ if (has_named_gamut && has_named_gamma)
+ return SkColorSpace::MakeRGB(named_gamma, named_gamut);
+
+ // Use named gamma with custom primaries, if possible.
+ SkMatrix44 to_xyz_d50;
+ GetPrimaryMatrix(&to_xyz_d50);
+ if (has_named_gamma)
+ return SkColorSpace::MakeRGB(named_gamma, to_xyz_d50);
- // Use the parametric transfer function if no other option is available.
+ // Use the parametric transfer function if there is no named transfer
+ // function.
SkColorSpaceTransferFn fn;
if (!GetTransferFunction(&fn)) {
DLOG(ERROR) << "Failed to parameterize transfer function for SkColorSpace";
return nullptr;
}
+ if (has_named_gamut)
+ return SkColorSpace::MakeRGB(fn, named_gamut);
return SkColorSpace::MakeRGB(fn, to_xyz_d50);
}
« no previous file with comments | « no previous file | ui/gfx/color_space_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698