| 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 22 matching lines...) Expand all Loading... |
| 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 GrTextureParams::FilterMode uvFilterMode = |
| 37 ((sizes[1].fWidth != sizes[0].fWidth) || | 37 ((sizes[1].fWidth != sizes[0].fWidth) || |
| 38 (sizes[1].fHeight != sizes[0].fHeight) || | 38 (sizes[1].fHeight != sizes[0].fHeight) || |
| 39 (sizes[2].fWidth != sizes[0].fWidth) || | 39 (sizes[2].fWidth != sizes[0].fWidth) || |
| 40 (sizes[2].fHeight != sizes[0].fHeight)) ? | 40 (sizes[2].fHeight != sizes[0].fHeight)) ? |
| 41 GrTextureParams::kBilerp_FilterMode : | 41 GrTextureParams::kBilerp_FilterMode : |
| 42 GrTextureParams::kNone_FilterMode; | 42 GrTextureParams::kNone_FilterMode; |
| 43 return SkNEW_ARGS(YUVtoRGBEffect, (procDataManager, yTexture, uTexture,
vTexture, yuvMatrix, | 43 return new YUVtoRGBEffect(procDataManager, yTexture, uTexture, vTexture,
yuvMatrix, |
| 44 uvFilterMode, colorSpace)); | 44 uvFilterMode, colorSpace); |
| 45 } | 45 } |
| 46 | 46 |
| 47 const char* name() const override { return "YUV to RGB"; } | 47 const char* name() const override { return "YUV to RGB"; } |
| 48 | 48 |
| 49 SkYUVColorSpace getColorSpace() const { | 49 SkYUVColorSpace getColorSpace() const { |
| 50 return fColorSpace; | 50 return fColorSpace; |
| 51 } | 51 } |
| 52 | 52 |
| 53 class GLProcessor : public GrGLFragmentProcessor { | 53 class GLProcessor : public GrGLFragmentProcessor { |
| 54 public: | 54 public: |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 , fColorSpace(colorSpace) { | 116 , fColorSpace(colorSpace) { |
| 117 this->initClassID<YUVtoRGBEffect>(); | 117 this->initClassID<YUVtoRGBEffect>(); |
| 118 this->addCoordTransform(&fYTransform); | 118 this->addCoordTransform(&fYTransform); |
| 119 this->addTextureAccess(&fYAccess); | 119 this->addTextureAccess(&fYAccess); |
| 120 this->addCoordTransform(&fUTransform); | 120 this->addCoordTransform(&fUTransform); |
| 121 this->addTextureAccess(&fUAccess); | 121 this->addTextureAccess(&fUAccess); |
| 122 this->addCoordTransform(&fVTransform); | 122 this->addCoordTransform(&fVTransform); |
| 123 this->addTextureAccess(&fVAccess); | 123 this->addTextureAccess(&fVAccess); |
| 124 } | 124 } |
| 125 | 125 |
| 126 GrGLFragmentProcessor* onCreateGLInstance() const override { | 126 GrGLFragmentProcessor* onCreateGLInstance() const override { return new GLPr
ocessor(*this); } |
| 127 return SkNEW_ARGS(GLProcessor, (*this)); | |
| 128 } | |
| 129 | 127 |
| 130 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, | 128 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, |
| 131 GrProcessorKeyBuilder* b) const override { | 129 GrProcessorKeyBuilder* b) const override { |
| 132 GLProcessor::GenKey(*this, caps, b); | 130 GLProcessor::GenKey(*this, caps, b); |
| 133 } | 131 } |
| 134 | 132 |
| 135 bool onIsEqual(const GrFragmentProcessor& sBase) const override { | 133 bool onIsEqual(const GrFragmentProcessor& sBase) const override { |
| 136 const YUVtoRGBEffect& s = sBase.cast<YUVtoRGBEffect>(); | 134 const YUVtoRGBEffect& s = sBase.cast<YUVtoRGBEffect>(); |
| 137 return fColorSpace == s.getColorSpace(); | 135 return fColorSpace == s.getColorSpace(); |
| 138 } | 136 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 171 |
| 174 ////////////////////////////////////////////////////////////////////////////// | 172 ////////////////////////////////////////////////////////////////////////////// |
| 175 | 173 |
| 176 GrFragmentProcessor* | 174 GrFragmentProcessor* |
| 177 GrYUVtoRGBEffect::Create(GrProcessorDataManager* procDataManager, GrTexture* yTe
xture, | 175 GrYUVtoRGBEffect::Create(GrProcessorDataManager* procDataManager, GrTexture* yTe
xture, |
| 178 GrTexture* uTexture, GrTexture* vTexture, const SkISize
sizes[3], | 176 GrTexture* uTexture, GrTexture* vTexture, const SkISize
sizes[3], |
| 179 SkYUVColorSpace colorSpace) { | 177 SkYUVColorSpace colorSpace) { |
| 180 SkASSERT(procDataManager && yTexture && uTexture && vTexture && sizes); | 178 SkASSERT(procDataManager && yTexture && uTexture && vTexture && sizes); |
| 181 return YUVtoRGBEffect::Create(procDataManager, yTexture, uTexture, vTexture,
sizes, colorSpace); | 179 return YUVtoRGBEffect::Create(procDataManager, yTexture, uTexture, vTexture,
sizes, colorSpace); |
| 182 } | 180 } |
| OLD | NEW |