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 "gl/builders/GrGLProgramBuilder.h" | 8 #include "gl/builders/GrGLProgramBuilder.h" |
9 #include "GrYUVtoRGBEffect.h" | 9 #include "GrYUVtoRGBEffect.h" |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 const char* inputColor, | 59 const char* inputColor, |
60 const TransformedCoordsArray& coords, | 60 const TransformedCoordsArray& coords, |
61 const TextureSamplerArray& samplers) SK_OVERRIDE { | 61 const TextureSamplerArray& samplers) SK_OVERRIDE { |
62 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBui
lder(); | 62 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBui
lder(); |
63 | 63 |
64 const char* yuvMatrix = NULL; | 64 const char* yuvMatrix = NULL; |
65 fMatrixUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visib
ility, | 65 fMatrixUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visib
ility, |
66 kMat44f_GrSLType, "YUVMatrix", | 66 kMat44f_GrSLType, "YUVMatrix", |
67 &yuvMatrix); | 67 &yuvMatrix); |
68 fsBuilder->codeAppendf("\t%s = vec4(\n\t\t", outputColor); | 68 fsBuilder->codeAppendf("\t%s = vec4(\n\t\t", outputColor); |
69 fsBuilder->appendTextureLookup(samplers[0], coords[0].c_str(), coord
s[0].type()); | 69 fsBuilder->appendTextureLookup(samplers[0], coords[0].c_str(), coord
s[0].getType()); |
70 fsBuilder->codeAppend(".r,\n\t\t"); | 70 fsBuilder->codeAppend(".r,\n\t\t"); |
71 fsBuilder->appendTextureLookup(samplers[1], coords[0].c_str(), coord
s[0].type()); | 71 fsBuilder->appendTextureLookup(samplers[1], coords[0].c_str(), coord
s[0].getType()); |
72 fsBuilder->codeAppend(".r,\n\t\t"); | 72 fsBuilder->codeAppend(".r,\n\t\t"); |
73 fsBuilder->appendTextureLookup(samplers[2], coords[0].c_str(), coord
s[0].type()); | 73 fsBuilder->appendTextureLookup(samplers[2], coords[0].c_str(), coord
s[0].getType()); |
74 fsBuilder->codeAppendf(".r,\n\t\t1.0) * %s;\n", yuvMatrix); | 74 fsBuilder->codeAppendf(".r,\n\t\t1.0) * %s;\n", yuvMatrix); |
75 } | 75 } |
76 | 76 |
77 virtual void setData(const GrGLProgramDataManager& pdman, | 77 virtual void setData(const GrGLProgramDataManager& pdman, |
78 const GrEffect& effect) SK_OVERRIDE { | 78 const GrEffect& effect) SK_OVERRIDE { |
79 const YUVtoRGBEffect& yuvEffect = effect.cast<YUVtoRGBEffect>(); | 79 const YUVtoRGBEffect& yuvEffect = effect.cast<YUVtoRGBEffect>(); |
80 switch (yuvEffect.getColorSpace()) { | 80 switch (yuvEffect.getColorSpace()) { |
81 case kJPEG_SkYUVColorSpace: | 81 case kJPEG_SkYUVColorSpace: |
82 pdman.setMatrix4f(fMatrixUni, kJPEGConversionMatrix); | 82 pdman.setMatrix4f(fMatrixUni, kJPEGConversionMatrix); |
83 break; | 83 break; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 1.164f, 2.018f, 0.0f, -1.08175f, | 137 1.164f, 2.018f, 0.0f, -1.08175f, |
138 0.0f, 0.0f, 0.0f, 1.0}; | 138 0.0f, 0.0f, 0.0f, 1.0}; |
139 } | 139 } |
140 | 140 |
141 ////////////////////////////////////////////////////////////////////////////// | 141 ////////////////////////////////////////////////////////////////////////////// |
142 | 142 |
143 GrEffect* GrYUVtoRGBEffect::Create(GrTexture* yTexture, GrTexture* uTexture, GrT
exture* vTexture, | 143 GrEffect* GrYUVtoRGBEffect::Create(GrTexture* yTexture, GrTexture* uTexture, GrT
exture* vTexture, |
144 SkYUVColorSpace colorSpace) { | 144 SkYUVColorSpace colorSpace) { |
145 return YUVtoRGBEffect::Create(yTexture, uTexture, vTexture, colorSpace); | 145 return YUVtoRGBEffect::Create(yTexture, uTexture, vTexture, colorSpace); |
146 } | 146 } |
OLD | NEW |