Line data Source code
1 : /*
2 : * Copyright 2016 Google Inc.
3 : *
4 : * Use of this source code is governed by a BSD-style license that can be
5 : * found in the LICENSE file.
6 : */
7 :
8 : #ifndef GrColorSpaceXform_DEFINED
9 : #define GrColorSpaceXform_DEFINED
10 :
11 : #include "GrColor.h"
12 : #include "SkMatrix44.h"
13 : #include "SkRefCnt.h"
14 :
15 : class SkColorSpace;
16 :
17 : /**
18 : * Represents a color gamut transformation (as a 4x4 color matrix)
19 : */
20 0 : class GrColorSpaceXform : public SkRefCnt {
21 : public:
22 : GrColorSpaceXform(const SkMatrix44& srcToDst);
23 :
24 : static sk_sp<GrColorSpaceXform> Make(const SkColorSpace* src, const SkColorSpace* dst);
25 :
26 0 : const SkMatrix44& srcToDst() const { return fSrcToDst; }
27 :
28 : /**
29 : * GrGLSLFragmentProcessor::GenKey() must call this and include the returned value in its
30 : * computed key.
31 : */
32 0 : static uint32_t XformKey(const GrColorSpaceXform* xform) {
33 : // Code generation changes if there is an xform, but it otherwise constant
34 0 : return SkToBool(xform) ? 1 : 0;
35 : }
36 :
37 : static bool Equals(const GrColorSpaceXform* a, const GrColorSpaceXform* b);
38 :
39 : GrColor4f apply(const GrColor4f& srcColor);
40 :
41 : private:
42 : SkMatrix44 fSrcToDst;
43 : };
44 :
45 : #endif
|