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(), |
| 73 args.fCoords[0].getType()); |
78 fsBuilder->codeAppend(".r,\n\t\t"); | 74 fsBuilder->codeAppend(".r,\n\t\t"); |
79 fsBuilder->appendTextureLookup(samplers[1], coords[1].c_str(), coord
s[1].getType()); | 75 fsBuilder->appendTextureLookup(args.fSamplers[1], args.fCoords[1].c_
str(), |
| 76 args.fCoords[1].getType()); |
80 fsBuilder->codeAppend(".r,\n\t\t"); | 77 fsBuilder->codeAppend(".r,\n\t\t"); |
81 fsBuilder->appendTextureLookup(samplers[2], coords[2].c_str(), coord
s[2].getType()); | 78 fsBuilder->appendTextureLookup(args.fSamplers[2], args.fCoords[2].c_
str(), |
| 79 args.fCoords[2].getType()); |
82 fsBuilder->codeAppendf(".r,\n\t\t1.0) * %s;\n", yuvMatrix); | 80 fsBuilder->codeAppendf(".r,\n\t\t1.0) * %s;\n", yuvMatrix); |
83 } | 81 } |
84 | 82 |
85 virtual void setData(const GrGLProgramDataManager& pdman, | 83 virtual void setData(const GrGLProgramDataManager& pdman, |
86 const GrProcessor& processor) override { | 84 const GrProcessor& processor) override { |
87 const YUVtoRGBEffect& yuvEffect = processor.cast<YUVtoRGBEffect>(); | 85 const YUVtoRGBEffect& yuvEffect = processor.cast<YUVtoRGBEffect>(); |
88 switch (yuvEffect.getColorSpace()) { | 86 switch (yuvEffect.getColorSpace()) { |
89 case kJPEG_SkYUVColorSpace: | 87 case kJPEG_SkYUVColorSpace: |
90 pdman.setMatrix4f(fMatrixUni, kJPEGConversionMatrix); | 88 pdman.setMatrix4f(fMatrixUni, kJPEGConversionMatrix); |
91 break; | 89 break; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 | 172 |
175 ////////////////////////////////////////////////////////////////////////////// | 173 ////////////////////////////////////////////////////////////////////////////// |
176 | 174 |
177 GrFragmentProcessor* | 175 GrFragmentProcessor* |
178 GrYUVtoRGBEffect::Create(GrProcessorDataManager* procDataManager, GrTexture* yTe
xture, | 176 GrYUVtoRGBEffect::Create(GrProcessorDataManager* procDataManager, GrTexture* yTe
xture, |
179 GrTexture* uTexture, GrTexture* vTexture, const SkISize
sizes[3], | 177 GrTexture* uTexture, GrTexture* vTexture, const SkISize
sizes[3], |
180 SkYUVColorSpace colorSpace) { | 178 SkYUVColorSpace colorSpace) { |
181 SkASSERT(procDataManager && yTexture && uTexture && vTexture && sizes); | 179 SkASSERT(procDataManager && yTexture && uTexture && vTexture && sizes); |
182 return YUVtoRGBEffect::Create(procDataManager, yTexture, uTexture, vTexture,
sizes, colorSpace); | 180 return YUVtoRGBEffect::Create(procDataManager, yTexture, uTexture, vTexture,
sizes, colorSpace); |
183 } | 181 } |
OLD | NEW |