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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 public: | 54 public: |
55 static const GrGLfloat kJPEGConversionMatrix[16]; | 55 static const GrGLfloat kJPEGConversionMatrix[16]; |
56 static const GrGLfloat kRec601ConversionMatrix[16]; | 56 static const GrGLfloat kRec601ConversionMatrix[16]; |
57 static const GrGLfloat kRec709ConversionMatrix[16]; | 57 static const GrGLfloat kRec709ConversionMatrix[16]; |
58 | 58 |
59 // this class always generates the same code. | 59 // this class always generates the same code. |
60 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKey Builder*) {} | 60 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKey Builder*) {} |
61 | 61 |
62 GLProcessor(const GrProcessor&) {} | 62 GLProcessor(const GrProcessor&) {} |
63 | 63 |
64 virtual void emitCode(GrGLFPBuilder* builder, | 64 virtual void emitCode(EmitArgs& args) override { |
65 const GrFragmentProcessor&, | 65 GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBui lder(); |
66 const char* outputColor, | |
67 const char* inputColor, | |
68 const TransformedCoordsArray& coords, | |
69 const TextureSamplerArray& samplers) override { | |
70 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder() ; | |
71 | 66 |
72 const char* yuvMatrix = NULL; | 67 const char* yuvMatrix = NULL; |
73 fMatrixUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visib ility, | 68 fMatrixUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment _Visibility, |
74 kMat44f_GrSLType, kDefault_GrSLPrec ision, | 69 kMat44f_GrSLType, kDefault_GrSLPrec ision, |
75 "YUVMatrix", &yuvMatrix); | 70 "YUVMatrix", &yuvMatrix); |
76 fsBuilder->codeAppendf("\t%s = vec4(\n\t\t", outputColor); | 71 fsBuilder->codeAppendf("\t%s = vec4(\n\t\t", args.fOutputColor); |
77 fsBuilder->appendTextureLookup(samplers[0], coords[0].c_str(), coord s[0].getType()); | 72 fsBuilder->appendTextureLookup(args.fSamplers[0], args.fCoords[0].c_ str(), args.fCoords[0].getType()); |
joshualitt
2015/07/22 19:34:06
line wrap @100
| |
78 fsBuilder->codeAppend(".r,\n\t\t"); | 73 fsBuilder->codeAppend(".r,\n\t\t"); |
79 fsBuilder->appendTextureLookup(samplers[1], coords[1].c_str(), coord s[1].getType()); | 74 fsBuilder->appendTextureLookup(args.fSamplers[1], args.fCoords[1].c_ str(), args.fCoords[1].getType()); |
joshualitt
2015/07/22 19:34:05
line wrap @100
| |
80 fsBuilder->codeAppend(".r,\n\t\t"); | 75 fsBuilder->codeAppend(".r,\n\t\t"); |
81 fsBuilder->appendTextureLookup(samplers[2], coords[2].c_str(), coord s[2].getType()); | 76 fsBuilder->appendTextureLookup(args.fSamplers[2], args.fCoords[2].c_ str(), args.fCoords[2].getType()); |
joshualitt
2015/07/22 19:34:06
line wrap @100
| |
82 fsBuilder->codeAppendf(".r,\n\t\t1.0) * %s;\n", yuvMatrix); | 77 fsBuilder->codeAppendf(".r,\n\t\t1.0) * %s;\n", yuvMatrix); |
83 } | 78 } |
84 | 79 |
85 virtual void setData(const GrGLProgramDataManager& pdman, | 80 virtual void setData(const GrGLProgramDataManager& pdman, |
86 const GrProcessor& processor) override { | 81 const GrProcessor& processor) override { |
87 const YUVtoRGBEffect& yuvEffect = processor.cast<YUVtoRGBEffect>(); | 82 const YUVtoRGBEffect& yuvEffect = processor.cast<YUVtoRGBEffect>(); |
88 switch (yuvEffect.getColorSpace()) { | 83 switch (yuvEffect.getColorSpace()) { |
89 case kJPEG_SkYUVColorSpace: | 84 case kJPEG_SkYUVColorSpace: |
90 pdman.setMatrix4f(fMatrixUni, kJPEGConversionMatrix); | 85 pdman.setMatrix4f(fMatrixUni, kJPEGConversionMatrix); |
91 break; | 86 break; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 | 169 |
175 ////////////////////////////////////////////////////////////////////////////// | 170 ////////////////////////////////////////////////////////////////////////////// |
176 | 171 |
177 GrFragmentProcessor* | 172 GrFragmentProcessor* |
178 GrYUVtoRGBEffect::Create(GrProcessorDataManager* procDataManager, GrTexture* yTe xture, | 173 GrYUVtoRGBEffect::Create(GrProcessorDataManager* procDataManager, GrTexture* yTe xture, |
179 GrTexture* uTexture, GrTexture* vTexture, const SkISize sizes[3], | 174 GrTexture* uTexture, GrTexture* vTexture, const SkISize sizes[3], |
180 SkYUVColorSpace colorSpace) { | 175 SkYUVColorSpace colorSpace) { |
181 SkASSERT(procDataManager && yTexture && uTexture && vTexture && sizes); | 176 SkASSERT(procDataManager && yTexture && uTexture && vTexture && sizes); |
182 return YUVtoRGBEffect::Create(procDataManager, yTexture, uTexture, vTexture, sizes, colorSpace); | 177 return YUVtoRGBEffect::Create(procDataManager, yTexture, uTexture, vTexture, sizes, colorSpace); |
183 } | 178 } |
OLD | NEW |