OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "gl/builders/GrGLProgramBuilder.h" | 8 #include "gl/builders/GrGLProgramBuilder.h" |
9 #include "GrYUVtoRGBEffect.h" | 9 #include "GrYUVtoRGBEffect.h" |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 GrTexture* vTexture, SkYUVColorSpace colo
rSpace) { | 21 GrTexture* vTexture, SkYUVColorSpace colo
rSpace) { |
22 return SkNEW_ARGS(YUVtoRGBEffect, (yTexture, uTexture, vTexture, colorSp
ace)); | 22 return SkNEW_ARGS(YUVtoRGBEffect, (yTexture, uTexture, vTexture, colorSp
ace)); |
23 } | 23 } |
24 | 24 |
25 static const char* Name() { return "YUV to RGB"; } | 25 static const char* Name() { return "YUV to RGB"; } |
26 | 26 |
27 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE { | 27 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE { |
28 return GrTBackendFragmentProcessorFactory<YUVtoRGBEffect>::getInstance()
; | 28 return GrTBackendFragmentProcessorFactory<YUVtoRGBEffect>::getInstance()
; |
29 } | 29 } |
30 | 30 |
31 virtual void getConstantColorComponents(GrColor* color, | |
32 uint32_t* validFlags) const SK_OVERR
IDE { | |
33 // YUV is opaque | |
34 *color = 0xFF; | |
35 *validFlags = kA_GrColorComponentFlag; | |
36 } | |
37 | |
38 SkYUVColorSpace getColorSpace() const { | 31 SkYUVColorSpace getColorSpace() const { |
39 return fColorSpace; | 32 return fColorSpace; |
40 } | 33 } |
41 | 34 |
42 class GLProcessor : public GrGLFragmentProcessor { | 35 class GLProcessor : public GrGLFragmentProcessor { |
43 public: | 36 public: |
44 static const GrGLfloat kJPEGConversionMatrix[16]; | 37 static const GrGLfloat kJPEGConversionMatrix[16]; |
45 static const GrGLfloat kRec601ConversionMatrix[16]; | 38 static const GrGLfloat kRec601ConversionMatrix[16]; |
46 | 39 |
47 // this class always generates the same code. | 40 // this class always generates the same code. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 } | 103 } |
111 | 104 |
112 virtual bool onIsEqual(const GrProcessor& sBase) const { | 105 virtual bool onIsEqual(const GrProcessor& sBase) const { |
113 const YUVtoRGBEffect& s = sBase.cast<YUVtoRGBEffect>(); | 106 const YUVtoRGBEffect& s = sBase.cast<YUVtoRGBEffect>(); |
114 return fYAccess.getTexture() == s.fYAccess.getTexture() && | 107 return fYAccess.getTexture() == s.fYAccess.getTexture() && |
115 fUAccess.getTexture() == s.fUAccess.getTexture() && | 108 fUAccess.getTexture() == s.fUAccess.getTexture() && |
116 fVAccess.getTexture() == s.fVAccess.getTexture() && | 109 fVAccess.getTexture() == s.fVAccess.getTexture() && |
117 fColorSpace == s.getColorSpace(); | 110 fColorSpace == s.getColorSpace(); |
118 } | 111 } |
119 | 112 |
| 113 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR
IDE { |
| 114 // YUV is opaque |
| 115 inout->fColor = 0xFF; |
| 116 inout->fValidFlags = kA_GrColorComponentFlag; |
| 117 inout->fIsSingleComponent = false; |
| 118 } |
| 119 |
120 GrCoordTransform fCoordTransform; | 120 GrCoordTransform fCoordTransform; |
121 GrTextureAccess fYAccess; | 121 GrTextureAccess fYAccess; |
122 GrTextureAccess fUAccess; | 122 GrTextureAccess fUAccess; |
123 GrTextureAccess fVAccess; | 123 GrTextureAccess fVAccess; |
124 SkYUVColorSpace fColorSpace; | 124 SkYUVColorSpace fColorSpace; |
125 | 125 |
126 typedef GrFragmentProcessor INHERITED; | 126 typedef GrFragmentProcessor INHERITED; |
127 }; | 127 }; |
128 | 128 |
129 const GrGLfloat YUVtoRGBEffect::GLProcessor::kJPEGConversionMatrix[16] = { | 129 const GrGLfloat YUVtoRGBEffect::GLProcessor::kJPEGConversionMatrix[16] = { |
130 1.0f, 0.0f, 1.402f, -0.701f, | 130 1.0f, 0.0f, 1.402f, -0.701f, |
131 1.0f, -0.34414f, -0.71414f, 0.529f, | 131 1.0f, -0.34414f, -0.71414f, 0.529f, |
132 1.0f, 1.772f, 0.0f, -0.886f, | 132 1.0f, 1.772f, 0.0f, -0.886f, |
133 0.0f, 0.0f, 0.0f, 1.0}; | 133 0.0f, 0.0f, 0.0f, 1.0}; |
134 const GrGLfloat YUVtoRGBEffect::GLProcessor::kRec601ConversionMatrix[16] = { | 134 const GrGLfloat YUVtoRGBEffect::GLProcessor::kRec601ConversionMatrix[16] = { |
135 1.164f, 0.0f, 1.596f, -0.87075f, | 135 1.164f, 0.0f, 1.596f, -0.87075f, |
136 1.164f, -0.391f, -0.813f, 0.52925f, | 136 1.164f, -0.391f, -0.813f, 0.52925f, |
137 1.164f, 2.018f, 0.0f, -1.08175f, | 137 1.164f, 2.018f, 0.0f, -1.08175f, |
138 0.0f, 0.0f, 0.0f, 1.0}; | 138 0.0f, 0.0f, 0.0f, 1.0}; |
139 } | 139 } |
140 | 140 |
141 ////////////////////////////////////////////////////////////////////////////// | 141 ////////////////////////////////////////////////////////////////////////////// |
142 | 142 |
143 GrFragmentProcessor* | 143 GrFragmentProcessor* |
144 GrYUVtoRGBEffect::Create(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vT
exture, | 144 GrYUVtoRGBEffect::Create(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vT
exture, |
145 SkYUVColorSpace colorSpace) { | 145 SkYUVColorSpace colorSpace) { |
146 return YUVtoRGBEffect::Create(yTexture, uTexture, vTexture, colorSpace); | 146 return YUVtoRGBEffect::Create(yTexture, uTexture, vTexture, colorSpace); |
147 } | 147 } |
OLD | NEW |