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

Unified Diff: ui/gfx/color_space.cc

Issue 2727063002: cc: Specify rasterization color space (Closed)
Patch Set: Add comment Created 3 years, 10 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 | « ui/gfx/color_space.h ('k') | no next file » | 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 a20f011a9a11fcfb9491ae9086446a4f64f8dcb7..8b311a718b76a6e90c66a7015108bd9406e4b97a 100644
--- a/ui/gfx/color_space.cc
+++ b/ui/gfx/color_space.cc
@@ -367,6 +367,37 @@ sk_sp<SkColorSpace> ColorSpace::ToSkColorSpace() const {
return SkColorSpace::MakeRGB(fn, to_xyz_d50);
}
+sk_sp<SkColorSpace> ColorSpace::ToNonlinearBlendedSkColorSpace() const {
+ if (!IsValid()) {
+ DLOG(ERROR) << "Cannot create SkColorSpace for invalid space.";
+ return nullptr;
+ }
+ if (matrix_ != MatrixID::RGB) {
+ DLOG(ERROR) << "Not creating non-RGB SkColorSpace";
+ return nullptr;
+ }
+ if (range_ != RangeID::FULL) {
+ DLOG(ERROR) << "Not creating non-full-range SkColorSpace";
+ return nullptr;
+ }
+
+ SkMatrix44 primaries;
+ GetPrimaryMatrix(&primaries);
+ SkColorSpaceTransferFn tr_fn;
+ bool get_tr_fn_result = GetTransferFunction(&tr_fn);
+ if (!get_tr_fn_result) {
+ DLOG(ERROR) << "Failed to parameterize transfer function for SkColorSpace";
+ CreateSRGB().GetTransferFunction(&tr_fn);
+ }
+ sk_sp<SkColorSpace> result = SkColorSpace::MakeRGB(
+ tr_fn, primaries, SkColorSpace::kNonLinearBlending_ColorSpaceFlag);
+ if (!result) {
+ DLOG(ERROR) << "Failed to create nonlinearly blended SkColorSpace";
+ CreateSRGB().GetTransferFunction(&tr_fn);
+ }
+ return result;
+}
+
bool ColorSpace::GetICCProfile(ICCProfile* icc_profile) const {
if (!IsValid())
return false;
« no previous file with comments | « ui/gfx/color_space.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698