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