Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/gpu/effects/GrYUVtoRGBEffect.cpp

Issue 1438003003: Move all ShaderBuilder files to GLSL (Closed) Base URL: https://skia.googlesource.com/skia.git@glslProgBuild
Patch Set: nits Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/effects/GrXfermodeFragmentProcessor.cpp ('k') | src/gpu/gl/GrGLFragmentProcessor.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "GrInvariantOutput.h" 11 #include "GrInvariantOutput.h"
12 #include "GrProcessor.h" 12 #include "GrProcessor.h"
13 #include "gl/GrGLFragmentProcessor.h" 13 #include "gl/GrGLFragmentProcessor.h"
14 #include "gl/builders/GrGLProgramBuilder.h" 14 #include "glsl/GrGLSLFragmentShaderBuilder.h"
15 #include "glsl/GrGLSLProgramBuilder.h"
15 #include "glsl/GrGLSLProgramDataManager.h" 16 #include "glsl/GrGLSLProgramDataManager.h"
16 17
17 namespace { 18 namespace {
18 19
19 class YUVtoRGBEffect : public GrFragmentProcessor { 20 class YUVtoRGBEffect : public GrFragmentProcessor {
20 public: 21 public:
21 static GrFragmentProcessor* Create(GrTexture* yTexture, GrTexture* uTexture, 22 static GrFragmentProcessor* Create(GrTexture* yTexture, GrTexture* uTexture,
22 GrTexture* vTexture, const SkISize sizes[ 3], 23 GrTexture* vTexture, const SkISize sizes[ 3],
23 SkYUVColorSpace colorSpace) { 24 SkYUVColorSpace colorSpace) {
24 SkScalar w[3], h[3]; 25 SkScalar w[3], h[3];
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 static const float kJPEGConversionMatrix[16]; 57 static const float kJPEGConversionMatrix[16];
57 static const float kRec601ConversionMatrix[16]; 58 static const float kRec601ConversionMatrix[16];
58 static const float kRec709ConversionMatrix[16]; 59 static const float kRec709ConversionMatrix[16];
59 60
60 // this class always generates the same code. 61 // this class always generates the same code.
61 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKey Builder*) {} 62 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKey Builder*) {}
62 63
63 GLProcessor(const GrProcessor&) {} 64 GLProcessor(const GrProcessor&) {}
64 65
65 virtual void emitCode(EmitArgs& args) override { 66 virtual void emitCode(EmitArgs& args) override {
66 GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBui lder(); 67 GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderB uilder();
67 68
68 const char* yuvMatrix = nullptr; 69 const char* yuvMatrix = nullptr;
69 fMatrixUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment _Visibility, 70 fMatrixUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragme nt_Visibility,
70 kMat44f_GrSLType, kDefault_GrSLPrec ision, 71 kMat44f_GrSLType, kDefault_Gr SLPrecision,
71 "YUVMatrix", &yuvMatrix); 72 "YUVMatrix", &yuvMatrix);
72 fsBuilder->codeAppendf("\t%s = vec4(\n\t\t", args.fOutputColor); 73 fsBuilder->codeAppendf("\t%s = vec4(\n\t\t", args.fOutputColor);
73 fsBuilder->appendTextureLookup(args.fSamplers[0], args.fCoords[0].c_ str(), 74 fsBuilder->appendTextureLookup(args.fSamplers[0], args.fCoords[0].c_ str(),
74 args.fCoords[0].getType()); 75 args.fCoords[0].getType());
75 fsBuilder->codeAppend(".r,\n\t\t"); 76 fsBuilder->codeAppend(".r,\n\t\t");
76 fsBuilder->appendTextureLookup(args.fSamplers[1], args.fCoords[1].c_ str(), 77 fsBuilder->appendTextureLookup(args.fSamplers[1], args.fCoords[1].c_ str(),
77 args.fCoords[1].getType()); 78 args.fCoords[1].getType());
78 fsBuilder->codeAppend(".r,\n\t\t"); 79 fsBuilder->codeAppend(".r,\n\t\t");
79 fsBuilder->appendTextureLookup(args.fSamplers[2], args.fCoords[2].c_ str(), 80 fsBuilder->appendTextureLookup(args.fSamplers[2], args.fCoords[2].c_ str(),
80 args.fCoords[2].getType()); 81 args.fCoords[2].getType());
81 fsBuilder->codeAppendf(".r,\n\t\t1.0) * %s;\n", yuvMatrix); 82 fsBuilder->codeAppendf(".r,\n\t\t1.0) * %s;\n", yuvMatrix);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 172 }
172 173
173 ////////////////////////////////////////////////////////////////////////////// 174 //////////////////////////////////////////////////////////////////////////////
174 175
175 GrFragmentProcessor* 176 GrFragmentProcessor*
176 GrYUVtoRGBEffect::Create(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vT exture, 177 GrYUVtoRGBEffect::Create(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vT exture,
177 const SkISize sizes[3], SkYUVColorSpace colorSpace) { 178 const SkISize sizes[3], SkYUVColorSpace colorSpace) {
178 SkASSERT(yTexture && uTexture && vTexture && sizes); 179 SkASSERT(yTexture && uTexture && vTexture && sizes);
179 return YUVtoRGBEffect::Create(yTexture, uTexture, vTexture, sizes, colorSpac e); 180 return YUVtoRGBEffect::Create(yTexture, uTexture, vTexture, sizes, colorSpac e);
180 } 181 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrXfermodeFragmentProcessor.cpp ('k') | src/gpu/gl/GrGLFragmentProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698