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

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

Issue 1709153002: Add more specialized fragment builders (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Make MSVC happy Created 4 years, 10 months 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/glsl/GrGLSLFragmentProcessor.h » ('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 "GrYUVEffect.h" 8 #include "GrYUVEffect.h"
9 9
10 #include "GrCoordTransform.h" 10 #include "GrCoordTransform.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 const char* name() const override { return "YUV to RGB"; } 92 const char* name() const override { return "YUV to RGB"; }
93 93
94 SkYUVColorSpace getColorSpace() const { return fColorSpace; } 94 SkYUVColorSpace getColorSpace() const { return fColorSpace; }
95 95
96 class GLSLProcessor : public GrGLSLFragmentProcessor { 96 class GLSLProcessor : public GrGLSLFragmentProcessor {
97 public: 97 public:
98 // this class always generates the same code. 98 // this class always generates the same code.
99 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKey Builder*) {} 99 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKey Builder*) {}
100 100
101 void emitCode(EmitArgs& args) override { 101 void emitCode(EmitArgs& args) override {
102 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; 102 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
103 103
104 const char* colorSpaceMatrix = nullptr; 104 const char* colorSpaceMatrix = nullptr;
105 fMatrixUni = args.fUniformHandler->addUniform(kFragment_GrShaderFlag , 105 fMatrixUni = args.fUniformHandler->addUniform(kFragment_GrShaderFlag ,
106 kMat44f_GrSLType, kDef ault_GrSLPrecision, 106 kMat44f_GrSLType, kDef ault_GrSLPrecision,
107 "ColorSpaceMatrix", &c olorSpaceMatrix); 107 "ColorSpaceMatrix", &c olorSpaceMatrix);
108 fragBuilder->codeAppendf("%s = vec4(", args.fOutputColor); 108 fragBuilder->codeAppendf("%s = vec4(", args.fOutputColor);
109 fragBuilder->appendTextureLookup(args.fSamplers[0], args.fCoords[0]. c_str(), 109 fragBuilder->appendTextureLookup(args.fSamplers[0], args.fCoords[0]. c_str(),
110 args.fCoords[0].getType()); 110 args.fCoords[0].getType());
111 fragBuilder->codeAppend(".r,"); 111 fragBuilder->codeAppend(".r,");
112 fragBuilder->appendTextureLookup(args.fSamplers[1], args.fCoords[1]. c_str(), 112 fragBuilder->appendTextureLookup(args.fSamplers[1], args.fCoords[1]. c_str(),
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 218
219 SkYUVColorSpace getColorSpace() const { return fColorSpace; } 219 SkYUVColorSpace getColorSpace() const { return fColorSpace; }
220 220
221 OutputChannels outputChannels() const { return fOutputChannels; } 221 OutputChannels outputChannels() const { return fOutputChannels; }
222 222
223 class GLSLProcessor : public GrGLSLFragmentProcessor { 223 class GLSLProcessor : public GrGLSLFragmentProcessor {
224 public: 224 public:
225 GLSLProcessor() : fLastColorSpace(-1), fLastOutputChannels(-1) {} 225 GLSLProcessor() : fLastColorSpace(-1), fLastOutputChannels(-1) {}
226 226
227 void emitCode(EmitArgs& args) override { 227 void emitCode(EmitArgs& args) override {
228 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; 228 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
229 OutputChannels oc = args.fFp.cast<RGBToYUVEffect>().outputChannels() ; 229 OutputChannels oc = args.fFp.cast<RGBToYUVEffect>().outputChannels() ;
230 230
231 SkString outputColor("rgbColor"); 231 SkString outputColor("rgbColor");
232 this->emitChild(0, args.fInputColor, &outputColor, args); 232 this->emitChild(0, args.fInputColor, &outputColor, args);
233 233
234 const char* uniName; 234 const char* uniName;
235 switch (oc) { 235 switch (oc) {
236 case kYUV_OutputChannels: 236 case kYUV_OutputChannels:
237 fRGBToYUVUni = args.fUniformHandler->addUniformArray( 237 fRGBToYUVUni = args.fUniformHandler->addUniformArray(
238 kFragment_GrShaderFlag, 238 kFragment_GrShaderFlag,
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 GrYUVEffect::CreateRGBToU(const GrFragmentProcessor* rgbFP, SkYUVColorSpace colo rSpace) { 379 GrYUVEffect::CreateRGBToU(const GrFragmentProcessor* rgbFP, SkYUVColorSpace colo rSpace) {
380 SkASSERT(rgbFP); 380 SkASSERT(rgbFP);
381 return new RGBToYUVEffect(rgbFP, colorSpace, RGBToYUVEffect::kU_OutputChanne ls); 381 return new RGBToYUVEffect(rgbFP, colorSpace, RGBToYUVEffect::kU_OutputChanne ls);
382 } 382 }
383 383
384 const GrFragmentProcessor* 384 const GrFragmentProcessor*
385 GrYUVEffect::CreateRGBToV(const GrFragmentProcessor* rgbFP, SkYUVColorSpace colo rSpace) { 385 GrYUVEffect::CreateRGBToV(const GrFragmentProcessor* rgbFP, SkYUVColorSpace colo rSpace) {
386 SkASSERT(rgbFP); 386 SkASSERT(rgbFP);
387 return new RGBToYUVEffect(rgbFP, colorSpace, RGBToYUVEffect::kV_OutputChanne ls); 387 return new RGBToYUVEffect(rgbFP, colorSpace, RGBToYUVEffect::kV_OutputChanne ls);
388 } 388 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrXfermodeFragmentProcessor.cpp ('k') | src/gpu/glsl/GrGLSLFragmentProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698