| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 args.fCoords[0].getType()); | 73 args.fCoords[0].getType()); |
| 74 fsBuilder->codeAppend(".r,\n\t\t"); | 74 fsBuilder->codeAppend(".r,\n\t\t"); |
| 75 fsBuilder->appendTextureLookup(args.fSamplers[1], args.fCoords[1].c_
str(), | 75 fsBuilder->appendTextureLookup(args.fSamplers[1], args.fCoords[1].c_
str(), |
| 76 args.fCoords[1].getType()); | 76 args.fCoords[1].getType()); |
| 77 fsBuilder->codeAppend(".r,\n\t\t"); | 77 fsBuilder->codeAppend(".r,\n\t\t"); |
| 78 fsBuilder->appendTextureLookup(args.fSamplers[2], args.fCoords[2].c_
str(), | 78 fsBuilder->appendTextureLookup(args.fSamplers[2], args.fCoords[2].c_
str(), |
| 79 args.fCoords[2].getType()); | 79 args.fCoords[2].getType()); |
| 80 fsBuilder->codeAppendf(".r,\n\t\t1.0) * %s;\n", yuvMatrix); | 80 fsBuilder->codeAppendf(".r,\n\t\t1.0) * %s;\n", yuvMatrix); |
| 81 } | 81 } |
| 82 | 82 |
| 83 virtual void setData(const GrGLProgramDataManager& pdman, | 83 protected: |
| 84 virtual void onSetData(const GrGLProgramDataManager& pdman, |
| 84 const GrProcessor& processor) override { | 85 const GrProcessor& processor) override { |
| 85 const YUVtoRGBEffect& yuvEffect = processor.cast<YUVtoRGBEffect>(); | 86 const YUVtoRGBEffect& yuvEffect = processor.cast<YUVtoRGBEffect>(); |
| 86 switch (yuvEffect.getColorSpace()) { | 87 switch (yuvEffect.getColorSpace()) { |
| 87 case kJPEG_SkYUVColorSpace: | 88 case kJPEG_SkYUVColorSpace: |
| 88 pdman.setMatrix4f(fMatrixUni, kJPEGConversionMatrix); | 89 pdman.setMatrix4f(fMatrixUni, kJPEGConversionMatrix); |
| 89 break; | 90 break; |
| 90 case kRec601_SkYUVColorSpace: | 91 case kRec601_SkYUVColorSpace: |
| 91 pdman.setMatrix4f(fMatrixUni, kRec601ConversionMatrix); | 92 pdman.setMatrix4f(fMatrixUni, kRec601ConversionMatrix); |
| 92 break; | 93 break; |
| 93 case kRec709_SkYUVColorSpace: | 94 case kRec709_SkYUVColorSpace: |
| 94 pdman.setMatrix4f(fMatrixUni, kRec709ConversionMatrix); | 95 pdman.setMatrix4f(fMatrixUni, kRec709ConversionMatrix); |
| 95 break; | 96 break; |
| 96 } | 97 } |
| 97 } | 98 } |
| 98 | 99 |
| 99 private: | 100 private: |
| 100 GrGLProgramDataManager::UniformHandle fMatrixUni; | 101 GrGLProgramDataManager::UniformHandle fMatrixUni; |
| 101 | 102 |
| 102 typedef GrGLFragmentProcessor INHERITED; | 103 typedef GrGLFragmentProcessor INHERITED; |
| 103 }; | 104 }; |
| 104 | 105 |
| 105 GrGLFragmentProcessor* createGLInstance() const override { | |
| 106 return SkNEW_ARGS(GLProcessor, (*this)); | |
| 107 } | |
| 108 | |
| 109 private: | 106 private: |
| 110 YUVtoRGBEffect(GrProcessorDataManager*, GrTexture* yTexture, GrTexture* uTex
ture, | 107 YUVtoRGBEffect(GrProcessorDataManager*, GrTexture* yTexture, GrTexture* uTex
ture, |
| 111 GrTexture* vTexture, const SkMatrix yuvMatrix[3], | 108 GrTexture* vTexture, const SkMatrix yuvMatrix[3], |
| 112 GrTextureParams::FilterMode uvFilterMode, SkYUVColorSpace col
orSpace) | 109 GrTextureParams::FilterMode uvFilterMode, SkYUVColorSpace col
orSpace) |
| 113 : fYTransform(kLocal_GrCoordSet, yuvMatrix[0], yTexture, GrTextureParams::kN
one_FilterMode) | 110 : fYTransform(kLocal_GrCoordSet, yuvMatrix[0], yTexture, GrTextureParams::kN
one_FilterMode) |
| 114 , fYAccess(yTexture) | 111 , fYAccess(yTexture) |
| 115 , fUTransform(kLocal_GrCoordSet, yuvMatrix[1], uTexture, uvFilterMode) | 112 , fUTransform(kLocal_GrCoordSet, yuvMatrix[1], uTexture, uvFilterMode) |
| 116 , fUAccess(uTexture, uvFilterMode) | 113 , fUAccess(uTexture, uvFilterMode) |
| 117 , fVTransform(kLocal_GrCoordSet, yuvMatrix[2], vTexture, uvFilterMode) | 114 , fVTransform(kLocal_GrCoordSet, yuvMatrix[2], vTexture, uvFilterMode) |
| 118 , fVAccess(vTexture, uvFilterMode) | 115 , fVAccess(vTexture, uvFilterMode) |
| 119 , fColorSpace(colorSpace) { | 116 , fColorSpace(colorSpace) { |
| 120 this->initClassID<YUVtoRGBEffect>(); | 117 this->initClassID<YUVtoRGBEffect>(); |
| 121 this->addCoordTransform(&fYTransform); | 118 this->addCoordTransform(&fYTransform); |
| 122 this->addTextureAccess(&fYAccess); | 119 this->addTextureAccess(&fYAccess); |
| 123 this->addCoordTransform(&fUTransform); | 120 this->addCoordTransform(&fUTransform); |
| 124 this->addTextureAccess(&fUAccess); | 121 this->addTextureAccess(&fUAccess); |
| 125 this->addCoordTransform(&fVTransform); | 122 this->addCoordTransform(&fVTransform); |
| 126 this->addTextureAccess(&fVAccess); | 123 this->addTextureAccess(&fVAccess); |
| 127 } | 124 } |
| 128 | 125 |
| 126 GrGLFragmentProcessor* onCreateGLInstance() const override { |
| 127 return SkNEW_ARGS(GLProcessor, (*this)); |
| 128 } |
| 129 |
| 129 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, | 130 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, |
| 130 GrProcessorKeyBuilder* b) const override { | 131 GrProcessorKeyBuilder* b) const override { |
| 131 GLProcessor::GenKey(*this, caps, b); | 132 GLProcessor::GenKey(*this, caps, b); |
| 132 } | 133 } |
| 133 | 134 |
| 134 bool onIsEqual(const GrFragmentProcessor& sBase) const override { | 135 bool onIsEqual(const GrFragmentProcessor& sBase) const override { |
| 135 const YUVtoRGBEffect& s = sBase.cast<YUVtoRGBEffect>(); | 136 const YUVtoRGBEffect& s = sBase.cast<YUVtoRGBEffect>(); |
| 136 return fColorSpace == s.getColorSpace(); | 137 return fColorSpace == s.getColorSpace(); |
| 137 } | 138 } |
| 138 | 139 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 173 |
| 173 ////////////////////////////////////////////////////////////////////////////// | 174 ////////////////////////////////////////////////////////////////////////////// |
| 174 | 175 |
| 175 GrFragmentProcessor* | 176 GrFragmentProcessor* |
| 176 GrYUVtoRGBEffect::Create(GrProcessorDataManager* procDataManager, GrTexture* yTe
xture, | 177 GrYUVtoRGBEffect::Create(GrProcessorDataManager* procDataManager, GrTexture* yTe
xture, |
| 177 GrTexture* uTexture, GrTexture* vTexture, const SkISize
sizes[3], | 178 GrTexture* uTexture, GrTexture* vTexture, const SkISize
sizes[3], |
| 178 SkYUVColorSpace colorSpace) { | 179 SkYUVColorSpace colorSpace) { |
| 179 SkASSERT(procDataManager && yTexture && uTexture && vTexture && sizes); | 180 SkASSERT(procDataManager && yTexture && uTexture && vTexture && sizes); |
| 180 return YUVtoRGBEffect::Create(procDataManager, yTexture, uTexture, vTexture,
sizes, colorSpace); | 181 return YUVtoRGBEffect::Create(procDataManager, yTexture, uTexture, vTexture,
sizes, colorSpace); |
| 181 } | 182 } |
| OLD | NEW |