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

Side by Side Diff: src/gpu/GrColorSpaceXform.cpp

Issue 2180803005: Add color gamut xform helpers to GrGLSLShaderBuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@xform-storage
Patch Set: Rebase 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 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 "SkMatrix44.h" 10 #include "SkMatrix44.h"
(...skipping 16 matching lines...) Expand all
27 sk_float_almost_equals(m.getFloat(2, 0), 0.0f, tol) && 27 sk_float_almost_equals(m.getFloat(2, 0), 0.0f, tol) &&
28 sk_float_almost_equals(m.getFloat(2, 1), 0.0f, tol) && 28 sk_float_almost_equals(m.getFloat(2, 1), 0.0f, tol) &&
29 sk_float_almost_equals(m.getFloat(2, 2), 1.0f, tol) && 29 sk_float_almost_equals(m.getFloat(2, 2), 1.0f, tol) &&
30 sk_float_almost_equals(m.getFloat(2, 3), 0.0f, tol) && 30 sk_float_almost_equals(m.getFloat(2, 3), 0.0f, tol) &&
31 sk_float_almost_equals(m.getFloat(3, 0), 0.0f, tol) && 31 sk_float_almost_equals(m.getFloat(3, 0), 0.0f, tol) &&
32 sk_float_almost_equals(m.getFloat(3, 1), 0.0f, tol) && 32 sk_float_almost_equals(m.getFloat(3, 1), 0.0f, tol) &&
33 sk_float_almost_equals(m.getFloat(3, 2), 0.0f, tol) && 33 sk_float_almost_equals(m.getFloat(3, 2), 0.0f, tol) &&
34 sk_float_almost_equals(m.getFloat(3, 3), 1.0f, tol); 34 sk_float_almost_equals(m.getFloat(3, 3), 1.0f, tol);
35 } 35 }
36 36
37 GrColorSpaceXform::GrColorSpaceXform(const SkMatrix44& srcToDst) { 37 GrColorSpaceXform::GrColorSpaceXform(const SkMatrix44& srcToDst, SkAlphaType src AlphaType)
38 : fSrcAlphaType(srcAlphaType) {
38 srcToDst.asColMajorf(fSrcToDst); 39 srcToDst.asColMajorf(fSrcToDst);
39 } 40 }
40 41
41 sk_sp<GrColorSpaceXform> GrColorSpaceXform::Make(SkColorSpace* src, SkColorSpace * dst) { 42 sk_sp<GrColorSpaceXform> GrColorSpaceXform::Make(SkColorSpace* src, SkColorSpace * dst,
43 SkAlphaType srcAlphaType) {
42 if (!src || !dst) { 44 if (!src || !dst) {
43 // Invalid 45 // Invalid
44 return nullptr; 46 return nullptr;
45 } 47 }
46 48
47 if (src == dst) { 49 if (src == dst) {
48 // Quick equality check - no conversion needed in this case 50 // Quick equality check - no conversion needed in this case
49 return nullptr; 51 return nullptr;
50 } 52 }
51 53
52 SkMatrix44 srcToDst(SkMatrix44::kUninitialized_Constructor); 54 SkMatrix44 srcToDst(SkMatrix44::kUninitialized_Constructor);
53 if (!dst->xyz().invert(&srcToDst)) { 55 if (!dst->xyz().invert(&srcToDst)) {
54 return nullptr; 56 return nullptr;
55 } 57 }
56 srcToDst.postConcat(src->xyz()); 58 srcToDst.postConcat(src->xyz());
57 59
58 if (matrix_is_almost_identity(srcToDst)) { 60 if (matrix_is_almost_identity(srcToDst)) {
59 return nullptr; 61 return nullptr;
60 } 62 }
61 63
62 return sk_make_sp<GrColorSpaceXform>(srcToDst); 64 return sk_make_sp<GrColorSpaceXform>(srcToDst, srcAlphaType);
63 } 65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698