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

Side by Side Diff: src/gpu/GrColorSpaceXform.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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 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 "GrColorSpaceXform.h" 8 #include "GrColorSpaceXform.h"
9 #include "SkColorSpace.h" 9 #include "SkColorSpace.h"
10 #include "SkColorSpace_Base.h" 10 #include "SkColorSpace_Base.h"
11 #include "SkColorSpace_XYZTRC.h"
11 #include "SkMatrix44.h" 12 #include "SkMatrix44.h"
12 13
13 static inline bool sk_float_almost_equals(float x, float y, float tol) { 14 static inline bool sk_float_almost_equals(float x, float y, float tol) {
14 return sk_float_abs(x - y) <= tol; 15 return sk_float_abs(x - y) <= tol;
15 } 16 }
16 17
17 static inline bool matrix_is_almost_identity(const SkMatrix44& m, 18 static inline bool matrix_is_almost_identity(const SkMatrix44& m,
18 SkMScalar tol = SK_MScalar1 / (1 << 12)) { 19 SkMScalar tol = SK_MScalar1 / (1 << 12)) {
19 return 20 return
20 sk_float_almost_equals(m.getFloat(0, 0), 1.0f, tol) && 21 sk_float_almost_equals(m.getFloat(0, 0), 1.0f, tol) &&
(...skipping 22 matching lines...) Expand all
43 // Invalid 44 // Invalid
44 return nullptr; 45 return nullptr;
45 } 46 }
46 47
47 if (src == dst) { 48 if (src == dst) {
48 // Quick equality check - no conversion needed in this case 49 // Quick equality check - no conversion needed in this case
49 return nullptr; 50 return nullptr;
50 } 51 }
51 52
52 SkMatrix44 srcToDst(SkMatrix44::kUninitialized_Constructor); 53 SkMatrix44 srcToDst(SkMatrix44::kUninitialized_Constructor);
53 srcToDst.setConcat(as_CSB(dst)->fromXYZD50(), as_CSB(src)->toXYZD50()); 54 srcToDst.setConcat(as_CSXYZ(dst)->fromXYZD50(), as_CSXYZ(src)->toXYZD50());
msarett 2016/10/05 19:05:53 Can we expose these functions on SkColorSpace_Base
54 55
55 if (matrix_is_almost_identity(srcToDst)) { 56 if (matrix_is_almost_identity(srcToDst)) {
56 return nullptr; 57 return nullptr;
57 } 58 }
58 59
59 return sk_make_sp<GrColorSpaceXform>(srcToDst); 60 return sk_make_sp<GrColorSpaceXform>(srcToDst);
60 } 61 }
61 62
62 bool GrColorSpaceXform::Equals(const GrColorSpaceXform* a, const GrColorSpaceXfo rm* b) { 63 bool GrColorSpaceXform::Equals(const GrColorSpaceXform* a, const GrColorSpaceXfo rm* b) {
63 if (a == b) { 64 if (a == b) {
64 return true; 65 return true;
65 } 66 }
66 67
67 if (!a || !b) { 68 if (!a || !b) {
68 return false; 69 return false;
69 } 70 }
70 71
71 return a->fSrcToDst == b->fSrcToDst; 72 return a->fSrcToDst == b->fSrcToDst;
72 } 73 }
73 74
74 GrColor4f GrColorSpaceXform::apply(const GrColor4f& srcColor) { 75 GrColor4f GrColorSpaceXform::apply(const GrColor4f& srcColor) {
75 GrColor4f result; 76 GrColor4f result;
76 fSrcToDst.mapScalars(srcColor.fRGBA, result.fRGBA); 77 fSrcToDst.mapScalars(srcColor.fRGBA, result.fRGBA);
77 return result; 78 return result;
78 } 79 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698