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 "GrYUVtoRGBEffect.h" | 8 #include "GrYUVtoRGBEffect.h" |
9 | 9 |
10 #include "GrCoordTransform.h" | 10 #include "GrCoordTransform.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 w[1] = SkIntToScalar(sizes[1].fWidth) / SkIntToScalar(uTexture->width()
); | 26 w[1] = SkIntToScalar(sizes[1].fWidth) / SkIntToScalar(uTexture->width()
); |
27 h[1] = SkIntToScalar(sizes[1].fHeight) / SkIntToScalar(uTexture->height(
)); | 27 h[1] = SkIntToScalar(sizes[1].fHeight) / SkIntToScalar(uTexture->height(
)); |
28 w[2] = SkIntToScalar(sizes[2].fWidth) / SkIntToScalar(vTexture->width()
); | 28 w[2] = SkIntToScalar(sizes[2].fWidth) / SkIntToScalar(vTexture->width()
); |
29 h[2] = SkIntToScalar(sizes[2].fHeight) / SkIntToScalar(vTexture->height(
)); | 29 h[2] = SkIntToScalar(sizes[2].fHeight) / SkIntToScalar(vTexture->height(
)); |
30 SkMatrix yuvMatrix[3]; | 30 SkMatrix yuvMatrix[3]; |
31 yuvMatrix[0] = GrCoordTransform::MakeDivByTextureWHMatrix(yTexture); | 31 yuvMatrix[0] = GrCoordTransform::MakeDivByTextureWHMatrix(yTexture); |
32 yuvMatrix[1] = yuvMatrix[0]; | 32 yuvMatrix[1] = yuvMatrix[0]; |
33 yuvMatrix[1].preScale(w[1] / w[0], h[1] / h[0]); | 33 yuvMatrix[1].preScale(w[1] / w[0], h[1] / h[0]); |
34 yuvMatrix[2] = yuvMatrix[0]; | 34 yuvMatrix[2] = yuvMatrix[0]; |
35 yuvMatrix[2].preScale(w[2] / w[0], h[2] / h[0]); | 35 yuvMatrix[2].preScale(w[2] / w[0], h[2] / h[0]); |
36 GrTextureParams::FilterMode uvFilterMode = | 36 return SkNEW_ARGS(YUVtoRGBEffect, (yTexture, uTexture, vTexture, yuvMatr
ix, colorSpace)); |
37 ((sizes[1].fWidth != sizes[0].fWidth) || | |
38 (sizes[1].fHeight != sizes[0].fHeight) || | |
39 (sizes[2].fWidth != sizes[0].fWidth) || | |
40 (sizes[2].fHeight != sizes[0].fHeight)) ? | |
41 GrTextureParams::kBilerp_FilterMode : | |
42 GrTextureParams::kNone_FilterMode; | |
43 return SkNEW_ARGS(YUVtoRGBEffect, (yTexture, uTexture, vTexture, yuvMatr
ix, | |
44 uvFilterMode, colorSpace)); | |
45 } | 37 } |
46 | 38 |
47 const char* name() const SK_OVERRIDE { return "YUV to RGB"; } | 39 const char* name() const SK_OVERRIDE { return "YUV to RGB"; } |
48 | 40 |
49 SkYUVColorSpace getColorSpace() const { | 41 SkYUVColorSpace getColorSpace() const { |
50 return fColorSpace; | 42 return fColorSpace; |
51 } | 43 } |
52 | 44 |
53 class GLProcessor : public GrGLFragmentProcessor { | 45 class GLProcessor : public GrGLFragmentProcessor { |
54 public: | 46 public: |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 GrProcessorKeyBuilder* b) const SK_OVERRIDE { | 96 GrProcessorKeyBuilder* b) const SK_OVERRIDE { |
105 GLProcessor::GenKey(*this, caps, b); | 97 GLProcessor::GenKey(*this, caps, b); |
106 } | 98 } |
107 | 99 |
108 GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE { | 100 GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE { |
109 return SkNEW_ARGS(GLProcessor, (*this)); | 101 return SkNEW_ARGS(GLProcessor, (*this)); |
110 } | 102 } |
111 | 103 |
112 private: | 104 private: |
113 YUVtoRGBEffect(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture
, | 105 YUVtoRGBEffect(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture
, |
114 SkMatrix yuvMatrix[3], GrTextureParams::FilterMode uvFilterMo
de, | 106 SkMatrix yuvMatrix[3], SkYUVColorSpace colorSpace) |
115 SkYUVColorSpace colorSpace) | |
116 : fYTransform(kLocal_GrCoordSet, yuvMatrix[0], yTexture, GrTextureParams::kN
one_FilterMode) | 107 : fYTransform(kLocal_GrCoordSet, yuvMatrix[0], yTexture, GrTextureParams::kN
one_FilterMode) |
117 , fYAccess(yTexture) | 108 , fYAccess(yTexture) |
118 , fUTransform(kLocal_GrCoordSet, yuvMatrix[1], uTexture, uvFilterMode) | 109 , fUTransform(kLocal_GrCoordSet, yuvMatrix[1], uTexture, GrTextureParams::kN
one_FilterMode) |
119 , fUAccess(uTexture, uvFilterMode) | 110 , fUAccess(uTexture) |
120 , fVTransform(kLocal_GrCoordSet, yuvMatrix[2], vTexture, uvFilterMode) | 111 , fVTransform(kLocal_GrCoordSet, yuvMatrix[2], vTexture, GrTextureParams::kN
one_FilterMode) |
121 , fVAccess(vTexture, uvFilterMode) | 112 , fVAccess(vTexture) |
122 , fColorSpace(colorSpace) { | 113 , fColorSpace(colorSpace) { |
123 this->initClassID<YUVtoRGBEffect>(); | 114 this->initClassID<YUVtoRGBEffect>(); |
124 this->addCoordTransform(&fYTransform); | 115 this->addCoordTransform(&fYTransform); |
125 this->addTextureAccess(&fYAccess); | 116 this->addTextureAccess(&fYAccess); |
126 this->addCoordTransform(&fUTransform); | 117 this->addCoordTransform(&fUTransform); |
127 this->addTextureAccess(&fUAccess); | 118 this->addTextureAccess(&fUAccess); |
128 this->addCoordTransform(&fVTransform); | 119 this->addCoordTransform(&fVTransform); |
129 this->addTextureAccess(&fVAccess); | 120 this->addTextureAccess(&fVAccess); |
130 } | 121 } |
131 | 122 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 } | 155 } |
165 | 156 |
166 ////////////////////////////////////////////////////////////////////////////// | 157 ////////////////////////////////////////////////////////////////////////////// |
167 | 158 |
168 GrFragmentProcessor* | 159 GrFragmentProcessor* |
169 GrYUVtoRGBEffect::Create(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vT
exture, | 160 GrYUVtoRGBEffect::Create(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vT
exture, |
170 SkISize sizes[3], SkYUVColorSpace colorSpace) { | 161 SkISize sizes[3], SkYUVColorSpace colorSpace) { |
171 SkASSERT(yTexture && uTexture && vTexture && sizes); | 162 SkASSERT(yTexture && uTexture && vTexture && sizes); |
172 return YUVtoRGBEffect::Create(yTexture, uTexture, vTexture, sizes, colorSpac
e); | 163 return YUVtoRGBEffect::Create(yTexture, uTexture, vTexture, sizes, colorSpac
e); |
173 } | 164 } |
OLD | NEW |