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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 static const float kJPEGConversionMatrix[16]; | 57 static const float kJPEGConversionMatrix[16]; |
58 static const float kRec601ConversionMatrix[16]; | 58 static const float kRec601ConversionMatrix[16]; |
59 static const float kRec709ConversionMatrix[16]; | 59 static const float kRec709ConversionMatrix[16]; |
60 | 60 |
61 // this class always generates the same code. | 61 // this class always generates the same code. |
62 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKey
Builder*) {} | 62 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKey
Builder*) {} |
63 | 63 |
64 GLSLProcessor(const GrProcessor&) {} | 64 GLSLProcessor(const GrProcessor&) {} |
65 | 65 |
66 virtual void emitCode(EmitArgs& args) override { | 66 virtual void emitCode(EmitArgs& args) override { |
67 GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderB
uilder(); | 67 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; |
68 | 68 |
69 const char* yuvMatrix = nullptr; | 69 const char* yuvMatrix = nullptr; |
70 fMatrixUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragme
nt_Visibility, | 70 fMatrixUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragme
nt_Visibility, |
71 kMat44f_GrSLType, kDefault_Gr
SLPrecision, | 71 kMat44f_GrSLType, kDefault_Gr
SLPrecision, |
72 "YUVMatrix", &yuvMatrix); | 72 "YUVMatrix", &yuvMatrix); |
73 fsBuilder->codeAppendf("\t%s = vec4(\n\t\t", args.fOutputColor); | 73 fragBuilder->codeAppendf("\t%s = vec4(\n\t\t", args.fOutputColor); |
74 fsBuilder->appendTextureLookup(args.fSamplers[0], args.fCoords[0].c_
str(), | 74 fragBuilder->appendTextureLookup(args.fSamplers[0], args.fCoords[0].
c_str(), |
75 args.fCoords[0].getType()); | 75 args.fCoords[0].getType()); |
76 fsBuilder->codeAppend(".r,\n\t\t"); | 76 fragBuilder->codeAppend(".r,\n\t\t"); |
77 fsBuilder->appendTextureLookup(args.fSamplers[1], args.fCoords[1].c_
str(), | 77 fragBuilder->appendTextureLookup(args.fSamplers[1], args.fCoords[1].
c_str(), |
78 args.fCoords[1].getType()); | 78 args.fCoords[1].getType()); |
79 fsBuilder->codeAppend(".r,\n\t\t"); | 79 fragBuilder->codeAppend(".r,\n\t\t"); |
80 fsBuilder->appendTextureLookup(args.fSamplers[2], args.fCoords[2].c_
str(), | 80 fragBuilder->appendTextureLookup(args.fSamplers[2], args.fCoords[2].
c_str(), |
81 args.fCoords[2].getType()); | 81 args.fCoords[2].getType()); |
82 fsBuilder->codeAppendf(".r,\n\t\t1.0) * %s;\n", yuvMatrix); | 82 fragBuilder->codeAppendf(".r,\n\t\t1.0) * %s;\n", yuvMatrix); |
83 } | 83 } |
84 | 84 |
85 protected: | 85 protected: |
86 virtual void onSetData(const GrGLSLProgramDataManager& pdman, | 86 virtual void onSetData(const GrGLSLProgramDataManager& pdman, |
87 const GrProcessor& processor) override { | 87 const GrProcessor& processor) override { |
88 const YUVtoRGBEffect& yuvEffect = processor.cast<YUVtoRGBEffect>(); | 88 const YUVtoRGBEffect& yuvEffect = processor.cast<YUVtoRGBEffect>(); |
89 switch (yuvEffect.getColorSpace()) { | 89 switch (yuvEffect.getColorSpace()) { |
90 case kJPEG_SkYUVColorSpace: | 90 case kJPEG_SkYUVColorSpace: |
91 pdman.setMatrix4f(fMatrixUni, kJPEGConversionMatrix); | 91 pdman.setMatrix4f(fMatrixUni, kJPEGConversionMatrix); |
92 break; | 92 break; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 } | 174 } |
175 | 175 |
176 ////////////////////////////////////////////////////////////////////////////// | 176 ////////////////////////////////////////////////////////////////////////////// |
177 | 177 |
178 GrFragmentProcessor* | 178 GrFragmentProcessor* |
179 GrYUVtoRGBEffect::Create(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vT
exture, | 179 GrYUVtoRGBEffect::Create(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vT
exture, |
180 const SkISize sizes[3], SkYUVColorSpace colorSpace) { | 180 const SkISize sizes[3], SkYUVColorSpace colorSpace) { |
181 SkASSERT(yTexture && uTexture && vTexture && sizes); | 181 SkASSERT(yTexture && uTexture && vTexture && sizes); |
182 return YUVtoRGBEffect::Create(yTexture, uTexture, vTexture, sizes, colorSpac
e); | 182 return YUVtoRGBEffect::Create(yTexture, uTexture, vTexture, sizes, colorSpac
e); |
183 } | 183 } |
OLD | NEW |