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

Unified Diff: src/core/SkColorSpace_XYZTRC.cpp

Issue 2389983002: Refactored SkColorSpace and added in a Lab PCS GM (Closed)
Patch Set: multiplied the matrix for the temporary XYZTRC profile from an A2B0 profile code to match what woul… 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 side-by-side diff with in-line comments
Download patch
Index: src/core/SkColorSpace_XYZTRC.cpp
diff --git a/src/core/SkColorSpace_XYZTRC.cpp b/src/core/SkColorSpace_XYZTRC.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..dfcc983a08ed577039f0a91cae61c3f04fe2c034
--- /dev/null
+++ b/src/core/SkColorSpace_XYZTRC.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkColorSpace_XYZTRC.h"
+
+static constexpr float gSRGB_toXYZD50[] {
+ 0.4358f, 0.3853f, 0.1430f, // Rx, Gx, Bx
+ 0.2224f, 0.7170f, 0.0606f, // Ry, Gy, Gz
+ 0.0139f, 0.0971f, 0.7139f, // Rz, Gz, Bz
+};
+
+SkColorSpace_XYZTRC::SkColorSpace_XYZTRC(SkGammaNamed gammaNamed, const SkMatrix44& toXYZD50)
+ : INHERITED(nullptr, SkColorSpace_Base::Type::kXYZTRC)
+ , fGammaNamed(gammaNamed)
+ , fGammas(nullptr)
+ , fToXYZD50(toXYZD50)
+ , fFromXYZD50(SkMatrix44::kUninitialized_Constructor)
+{}
+
+SkColorSpace_XYZTRC::SkColorSpace_XYZTRC(SkGammaNamed gammaNamed, sk_sp<SkGammas> gammas,
+ const SkMatrix44& toXYZD50, sk_sp<SkData> profileData)
+ : INHERITED(std::move(profileData), SkColorSpace_Base::Type::kXYZTRC)
+ , fGammaNamed(gammaNamed)
+ , fGammas(std::move(gammas))
+ , fToXYZD50(toXYZD50)
+ , fFromXYZD50(SkMatrix44::kUninitialized_Constructor)
+{}
+
+const SkMatrix44& SkColorSpace_XYZTRC::fromXYZD50() const {
+ fFromXYZOnce([this] {
+ if (!fToXYZD50.invert(&fFromXYZD50)) {
+ // If a client gives us a dst gamut with a transform that we can't invert, we will
+ // simply give them back a transform to sRGB gamut.
+ SkDEBUGFAIL("Non-invertible XYZ matrix, defaulting to sRGB");
+ SkMatrix44 srgbToxyzD50(SkMatrix44::kUninitialized_Constructor);
+ srgbToxyzD50.set3x3RowMajorf(gSRGB_toXYZD50);
+ srgbToxyzD50.invert(&fFromXYZD50);
+ }
+ });
+ return fFromXYZD50;
+}

Powered by Google App Engine
This is Rietveld 408576698