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

Unified Diff: src/core/SkColorSpaceXform.cpp

Issue 2323003002: Cache the inverse matrix on SkColorSpace. Rename xyz() to toXYZ(). (Closed)
Patch Set: Remove xyz() again Created 4 years, 3 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 | « src/core/SkColorSpace.cpp ('k') | src/core/SkColorSpace_Base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkColorSpaceXform.cpp
diff --git a/src/core/SkColorSpaceXform.cpp b/src/core/SkColorSpaceXform.cpp
index f20886af7b11bd80e29e986b2df521ac41463f8e..136b4da6b922522c72fb6e8de955061304fa3e02 100644
--- a/src/core/SkColorSpaceXform.cpp
+++ b/src/core/SkColorSpaceXform.cpp
@@ -446,14 +446,10 @@ static void build_gamma_tables(const T* outGammaTables[3], T* gammaTableStorage,
///////////////////////////////////////////////////////////////////////////////////////////////////
-static inline bool compute_gamut_xform(SkMatrix44* srcToDst, const SkMatrix44& srcToXYZ,
- const SkMatrix44& dstToXYZ) {
- if (!dstToXYZ.invert(srcToDst)) {
- return false;
- }
-
- srcToDst->postConcat(srcToXYZ);
- return true;
+static inline void compute_gamut_xform(SkMatrix44* srcToDst, const SkColorSpace* src,
+ const SkColorSpace* dst) {
+ *srcToDst = as_CSB(dst)->fromXYZD50();
+ srcToDst->postConcat(src->toXYZD50());
}
static inline bool is_almost_identity(const SkMatrix44& srcToDst) {
@@ -482,11 +478,13 @@ std::unique_ptr<SkColorSpaceXform> SkColorSpaceXform::New(const sk_sp<SkColorSpa
if (SkColorSpace::Equals(srcSpace.get(), dstSpace.get())) {
srcToDst.setIdentity();
csm = kFull_ColorSpaceMatch;
- } else if (!compute_gamut_xform(&srcToDst, srcSpace->xyz(), dstSpace->xyz())) {
- return nullptr;
- } else if (is_almost_identity(srcToDst)) {
- srcToDst.setIdentity();
- csm = kGamut_ColorSpaceMatch;
+ } else {
+ compute_gamut_xform(&srcToDst, srcSpace.get(), dstSpace.get());
+
+ if (is_almost_identity(srcToDst)) {
+ srcToDst.setIdentity();
+ csm = kGamut_ColorSpaceMatch;
+ }
}
switch (csm) {
« no previous file with comments | « src/core/SkColorSpace.cpp ('k') | src/core/SkColorSpace_Base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698