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

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

Issue 571163002: removing GrDrawEffect (Closed) Base URL: https://skia.googlesource.com/skia.git@gp3
Patch Set: rebase after revert Created 6 years, 3 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/GrTextureDomain.cpp ('k') | src/gpu/gl/GrGLEffect.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 "gl/builders/GrGLProgramBuilder.h" 8 #include "gl/builders/GrGLProgramBuilder.h"
9 #include "GrYUVtoRGBEffect.h" 9 #include "GrYUVtoRGBEffect.h"
10 10
(...skipping 27 matching lines...) Expand all
38 SkYUVColorSpace getColorSpace() const { 38 SkYUVColorSpace getColorSpace() const {
39 return fColorSpace; 39 return fColorSpace;
40 } 40 }
41 41
42 class GLEffect : public GrGLEffect { 42 class GLEffect : public GrGLEffect {
43 public: 43 public:
44 static const GrGLfloat kJPEGConversionMatrix[16]; 44 static const GrGLfloat kJPEGConversionMatrix[16];
45 static const GrGLfloat kRec601ConversionMatrix[16]; 45 static const GrGLfloat kRec601ConversionMatrix[16];
46 46
47 // this class always generates the same code. 47 // this class always generates the same code.
48 static void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuil der*) {} 48 static void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder* ) {}
49 49
50 GLEffect(const GrBackendEffectFactory& factory, 50 GLEffect(const GrBackendEffectFactory& factory,
51 const GrDrawEffect&) 51 const GrEffect&)
52 : INHERITED(factory) { 52 : INHERITED(factory) {
53 } 53 }
54 54
55 virtual void emitCode(GrGLProgramBuilder* builder, 55 virtual void emitCode(GrGLProgramBuilder* builder,
56 const GrDrawEffect& drawEffect, 56 const GrEffect&,
57 const GrEffectKey&, 57 const GrEffectKey&,
58 const char* outputColor, 58 const char* outputColor,
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].type());
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].type());
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].type());
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 GrDrawEffect& drawEffect) SK_OVERRIDE { 78 const GrEffect& effect) SK_OVERRIDE {
79 const YUVtoRGBEffect& yuvEffect = drawEffect.castEffect<YUVtoRGBEffe ct>(); 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;
84 case kRec601_SkYUVColorSpace: 84 case kRec601_SkYUVColorSpace:
85 pdman.setMatrix4f(fMatrixUni, kRec601ConversionMatrix); 85 pdman.setMatrix4f(fMatrixUni, kRec601ConversionMatrix);
86 break; 86 break;
87 } 87 }
88 } 88 }
89 89
(...skipping 13 matching lines...) Expand all
103 , fVAccess(vTexture) 103 , fVAccess(vTexture)
104 , fColorSpace(colorSpace) { 104 , fColorSpace(colorSpace) {
105 this->addCoordTransform(&fCoordTransform); 105 this->addCoordTransform(&fCoordTransform);
106 this->addTextureAccess(&fYAccess); 106 this->addTextureAccess(&fYAccess);
107 this->addTextureAccess(&fUAccess); 107 this->addTextureAccess(&fUAccess);
108 this->addTextureAccess(&fVAccess); 108 this->addTextureAccess(&fVAccess);
109 this->setWillNotUseInputColor(); 109 this->setWillNotUseInputColor();
110 } 110 }
111 111
112 virtual bool onIsEqual(const GrEffect& sBase) const { 112 virtual bool onIsEqual(const GrEffect& sBase) const {
113 const YUVtoRGBEffect& s = CastEffect<YUVtoRGBEffect>(sBase); 113 const YUVtoRGBEffect& s = sBase.cast<YUVtoRGBEffect>();
114 return fYAccess.getTexture() == s.fYAccess.getTexture() && 114 return fYAccess.getTexture() == s.fYAccess.getTexture() &&
115 fUAccess.getTexture() == s.fUAccess.getTexture() && 115 fUAccess.getTexture() == s.fUAccess.getTexture() &&
116 fVAccess.getTexture() == s.fVAccess.getTexture() && 116 fVAccess.getTexture() == s.fVAccess.getTexture() &&
117 fColorSpace == s.getColorSpace(); 117 fColorSpace == s.getColorSpace();
118 } 118 }
119 119
120 GrCoordTransform fCoordTransform; 120 GrCoordTransform fCoordTransform;
121 GrTextureAccess fYAccess; 121 GrTextureAccess fYAccess;
122 GrTextureAccess fUAccess; 122 GrTextureAccess fUAccess;
123 GrTextureAccess fVAccess; 123 GrTextureAccess fVAccess;
(...skipping 13 matching lines...) Expand all
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 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrTextureDomain.cpp ('k') | src/gpu/gl/GrGLEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698