OLD | NEW |
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 #ifndef GrGLSLColorSpaceXformHelper_DEFINED | 8 #ifndef GrGLSLColorSpaceXformHelper_DEFINED |
9 #define GrGLSLColorSpaceXformHelper_DEFINED | 9 #define GrGLSLColorSpaceXformHelper_DEFINED |
10 | 10 |
11 #include "GrColorSpaceXform.h" | 11 #include "GrColorSpaceXform.h" |
12 #include "GrGLSLUniformHandler.h" | 12 #include "GrGLSLUniformHandler.h" |
13 | 13 |
14 /** | 14 /** |
15 * Stack helper class to assist with using GrColorSpaceXform within an FP's emit
Code function. | 15 * Stack helper class to assist with using GrColorSpaceXform within an FP's emit
Code function. |
16 * This injects the uniform declaration, and stores the information needed to ge
nerate correct | 16 * This injects the uniform declaration, and stores the information needed to ge
nerate correct |
17 * gamut-transformation shader code. | 17 * gamut-transformation shader code. |
18 */ | 18 */ |
19 class GrGLSLColorSpaceXformHelper : public SkNoncopyable { | 19 class GrGLSLColorSpaceXformHelper : public SkNoncopyable { |
20 public: | 20 public: |
21 GrGLSLColorSpaceXformHelper(GrGLSLUniformHandler* uniformHandler, | 21 GrGLSLColorSpaceXformHelper(GrGLSLUniformHandler* uniformHandler, |
22 GrColorSpaceXform* colorSpaceXform, | 22 GrColorSpaceXform* colorSpaceXform, |
23 GrGLSLProgramDataManager::UniformHandle* handle)
{ | 23 GrGLSLProgramDataManager::UniformHandle* handle)
{ |
24 SkASSERT(uniformHandler && handle); | 24 SkASSERT(uniformHandler && handle); |
25 if (colorSpaceXform) { | 25 if (colorSpaceXform) { |
26 *handle = uniformHandler->addUniform(kFragment_GrShaderFlag, kMat44f
_GrSLType, | 26 *handle = uniformHandler->addUniform(kFragment_GrShaderFlag, kMat44f
_GrSLType, |
27 kDefault_GrSLPrecision, "ColorX
form", | 27 kDefault_GrSLPrecision, "ColorX
form", |
28 &fXformMatrix); | 28 &fXformMatrix); |
29 fAlphaType = colorSpaceXform->alphaType(); | |
30 } else { | 29 } else { |
31 fXformMatrix = nullptr; | 30 fXformMatrix = nullptr; |
32 } | 31 } |
33 } | 32 } |
34 | 33 |
35 const char* getXformMatrix() const { return fXformMatrix; } | 34 const char* getXformMatrix() const { return fXformMatrix; } |
36 SkAlphaType alphaType() const { return fAlphaType; } | |
37 | 35 |
38 private: | 36 private: |
39 const char* fXformMatrix; | 37 const char* fXformMatrix; |
40 SkAlphaType fAlphaType; | |
41 }; | 38 }; |
42 | 39 |
43 #endif | 40 #endif |
OLD | NEW |