| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 break; | 95 break; |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 | 98 |
| 99 private: | 99 private: |
| 100 GrGLProgramDataManager::UniformHandle fMatrixUni; | 100 GrGLProgramDataManager::UniformHandle fMatrixUni; |
| 101 | 101 |
| 102 typedef GrGLFragmentProcessor INHERITED; | 102 typedef GrGLFragmentProcessor INHERITED; |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 virtual void getGLProcessorKey(const GrGLSLCaps& caps, | |
| 106 GrProcessorKeyBuilder* b) const override { | |
| 107 GLProcessor::GenKey(*this, caps, b); | |
| 108 } | |
| 109 | |
| 110 GrGLFragmentProcessor* createGLInstance() const override { | 105 GrGLFragmentProcessor* createGLInstance() const override { |
| 111 return SkNEW_ARGS(GLProcessor, (*this)); | 106 return SkNEW_ARGS(GLProcessor, (*this)); |
| 112 } | 107 } |
| 113 | 108 |
| 114 private: | 109 private: |
| 115 YUVtoRGBEffect(GrProcessorDataManager*, GrTexture* yTexture, GrTexture* uTex
ture, | 110 YUVtoRGBEffect(GrProcessorDataManager*, GrTexture* yTexture, GrTexture* uTex
ture, |
| 116 GrTexture* vTexture, const SkMatrix yuvMatrix[3], | 111 GrTexture* vTexture, const SkMatrix yuvMatrix[3], |
| 117 GrTextureParams::FilterMode uvFilterMode, SkYUVColorSpace col
orSpace) | 112 GrTextureParams::FilterMode uvFilterMode, SkYUVColorSpace col
orSpace) |
| 118 : fYTransform(kLocal_GrCoordSet, yuvMatrix[0], yTexture, GrTextureParams::kN
one_FilterMode) | 113 : fYTransform(kLocal_GrCoordSet, yuvMatrix[0], yTexture, GrTextureParams::kN
one_FilterMode) |
| 119 , fYAccess(yTexture) | 114 , fYAccess(yTexture) |
| 120 , fUTransform(kLocal_GrCoordSet, yuvMatrix[1], uTexture, uvFilterMode) | 115 , fUTransform(kLocal_GrCoordSet, yuvMatrix[1], uTexture, uvFilterMode) |
| 121 , fUAccess(uTexture, uvFilterMode) | 116 , fUAccess(uTexture, uvFilterMode) |
| 122 , fVTransform(kLocal_GrCoordSet, yuvMatrix[2], vTexture, uvFilterMode) | 117 , fVTransform(kLocal_GrCoordSet, yuvMatrix[2], vTexture, uvFilterMode) |
| 123 , fVAccess(vTexture, uvFilterMode) | 118 , fVAccess(vTexture, uvFilterMode) |
| 124 , fColorSpace(colorSpace) { | 119 , fColorSpace(colorSpace) { |
| 125 this->initClassID<YUVtoRGBEffect>(); | 120 this->initClassID<YUVtoRGBEffect>(); |
| 126 this->addCoordTransform(&fYTransform); | 121 this->addCoordTransform(&fYTransform); |
| 127 this->addTextureAccess(&fYAccess); | 122 this->addTextureAccess(&fYAccess); |
| 128 this->addCoordTransform(&fUTransform); | 123 this->addCoordTransform(&fUTransform); |
| 129 this->addTextureAccess(&fUAccess); | 124 this->addTextureAccess(&fUAccess); |
| 130 this->addCoordTransform(&fVTransform); | 125 this->addCoordTransform(&fVTransform); |
| 131 this->addTextureAccess(&fVAccess); | 126 this->addTextureAccess(&fVAccess); |
| 132 } | 127 } |
| 133 | 128 |
| 129 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, |
| 130 GrProcessorKeyBuilder* b) const override { |
| 131 GLProcessor::GenKey(*this, caps, b); |
| 132 } |
| 133 |
| 134 bool onIsEqual(const GrFragmentProcessor& sBase) const override { | 134 bool onIsEqual(const GrFragmentProcessor& sBase) const override { |
| 135 const YUVtoRGBEffect& s = sBase.cast<YUVtoRGBEffect>(); | 135 const YUVtoRGBEffect& s = sBase.cast<YUVtoRGBEffect>(); |
| 136 return fColorSpace == s.getColorSpace(); | 136 return fColorSpace == s.getColorSpace(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { | 139 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { |
| 140 // YUV is opaque | 140 // YUV is opaque |
| 141 inout->setToOther(kA_GrColorComponentFlag, 0xFF << GrColor_SHIFT_A, | 141 inout->setToOther(kA_GrColorComponentFlag, 0xFF << GrColor_SHIFT_A, |
| 142 GrInvariantOutput::kWillNot_ReadInput); | 142 GrInvariantOutput::kWillNot_ReadInput); |
| 143 } | 143 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 172 | 172 |
| 173 ////////////////////////////////////////////////////////////////////////////// | 173 ////////////////////////////////////////////////////////////////////////////// |
| 174 | 174 |
| 175 GrFragmentProcessor* | 175 GrFragmentProcessor* |
| 176 GrYUVtoRGBEffect::Create(GrProcessorDataManager* procDataManager, GrTexture* yTe
xture, | 176 GrYUVtoRGBEffect::Create(GrProcessorDataManager* procDataManager, GrTexture* yTe
xture, |
| 177 GrTexture* uTexture, GrTexture* vTexture, const SkISize
sizes[3], | 177 GrTexture* uTexture, GrTexture* vTexture, const SkISize
sizes[3], |
| 178 SkYUVColorSpace colorSpace) { | 178 SkYUVColorSpace colorSpace) { |
| 179 SkASSERT(procDataManager && yTexture && uTexture && vTexture && sizes); | 179 SkASSERT(procDataManager && yTexture && uTexture && vTexture && sizes); |
| 180 return YUVtoRGBEffect::Create(procDataManager, yTexture, uTexture, vTexture,
sizes, colorSpace); | 180 return YUVtoRGBEffect::Create(procDataManager, yTexture, uTexture, vTexture,
sizes, colorSpace); |
| 181 } | 181 } |
| OLD | NEW |