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

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

Issue 491673002: Initial refactor of shaderbuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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 "GrYUVtoRGBEffect.h" 9 #include "GrYUVtoRGBEffect.h"
9 10
10 #include "GrCoordTransform.h" 11 #include "GrCoordTransform.h"
11 #include "GrEffect.h" 12 #include "GrEffect.h"
12 #include "gl/GrGLEffect.h" 13 #include "gl/GrGLEffect.h"
13 #include "gl/GrGLShaderBuilder.h"
14 #include "GrTBackendEffectFactory.h" 14 #include "GrTBackendEffectFactory.h"
15 15
16 namespace { 16 namespace {
17 17
18 class YUVtoRGBEffect : public GrEffect { 18 class YUVtoRGBEffect : public GrEffect {
19 public: 19 public:
20 static GrEffect* Create(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture) { 20 static GrEffect* Create(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture) {
21 return SkNEW_ARGS(YUVtoRGBEffect, (yTexture, uTexture, vTexture)); 21 return SkNEW_ARGS(YUVtoRGBEffect, (yTexture, uTexture, vTexture));
22 } 22 }
23 23
(...skipping 13 matching lines...) Expand all
37 class GLEffect : public GrGLEffect { 37 class GLEffect : public GrGLEffect {
38 public: 38 public:
39 // this class always generates the same code. 39 // this class always generates the same code.
40 static void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuil der*) {} 40 static void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuil der*) {}
41 41
42 GLEffect(const GrBackendEffectFactory& factory, 42 GLEffect(const GrBackendEffectFactory& factory,
43 const GrDrawEffect&) 43 const GrDrawEffect&)
44 : INHERITED(factory) { 44 : INHERITED(factory) {
45 } 45 }
46 46
47 virtual void emitCode(GrGLShaderBuilder* builder, 47 virtual void emitCode(GrGLProgramBuilder* builder,
48 const GrDrawEffect&, 48 const GrDrawEffect&,
49 const GrEffectKey&, 49 const GrEffectKey&,
50 const char* outputColor, 50 const char* outputColor,
51 const char* inputColor, 51 const char* inputColor,
52 const TransformedCoordsArray& coords, 52 const TransformedCoordsArray& coords,
53 const TextureSamplerArray& samplers) SK_OVERRIDE { 53 const TextureSamplerArray& samplers) SK_OVERRIDE {
54 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBui lder();
54 const char* yuvMatrix = "yuvMatrix"; 55 const char* yuvMatrix = "yuvMatrix";
55 builder->fsCodeAppendf("\tconst mat4 %s = mat4(1.0, 0.0, 1.402, -0.701,\n\t\t\t" 56 fsBuilder->codeAppendf("\tconst mat4 %s = mat4(1.0, 0.0, 1.402, -0.701,\n\t\t\t"
56 "1.0, -0.344, -0.714, 0.529,\n\t\t\t" 57 "1.0, -0.344, -0.714, 0.529,\n\t\t\t"
57 "1.0, 1.772, 0.0, -0.886,\n\t\t\t" 58 "1.0, 1.772, 0.0, -0.886,\n\t\t\t"
58 "0.0, 0.0, 0.0, 1.0);\n", 59 "0.0, 0.0, 0.0, 1.0);\n",
59 yuvMatrix); 60 yuvMatrix);
60 builder->fsCodeAppendf("\t%s = vec4(\n\t\t", outputColor); 61 fsBuilder->codeAppendf("\t%s = vec4(\n\t\t", outputColor);
61 builder->fsAppendTextureLookup(samplers[0], coords[0].c_str(), coord s[0].type()); 62 fsBuilder->appendTextureLookup(samplers[0], coords[0].c_str(), coord s[0].type());
62 builder->fsCodeAppend(".r,\n\t\t"); 63 fsBuilder->codeAppend(".r,\n\t\t");
63 builder->fsAppendTextureLookup(samplers[1], coords[0].c_str(), coord s[0].type()); 64 fsBuilder->appendTextureLookup(samplers[1], coords[0].c_str(), coord s[0].type());
64 builder->fsCodeAppend(".r,\n\t\t"); 65 fsBuilder->codeAppend(".r,\n\t\t");
65 builder->fsAppendTextureLookup(samplers[2], coords[0].c_str(), coord s[0].type()); 66 fsBuilder->appendTextureLookup(samplers[2], coords[0].c_str(), coord s[0].type());
66 builder->fsCodeAppendf(".r,\n\t\t1.0) * %s;\n", yuvMatrix); 67 fsBuilder->codeAppendf(".r,\n\t\t1.0) * %s;\n", yuvMatrix);
67 } 68 }
68 69
69 typedef GrGLEffect INHERITED; 70 typedef GrGLEffect INHERITED;
70 }; 71 };
71 72
72 private: 73 private:
73 YUVtoRGBEffect(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture ) 74 YUVtoRGBEffect(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture )
74 : fCoordTransform(kLocal_GrCoordSet, MakeDivByTextureWHMatrix(yTexture), yTe xture) 75 : fCoordTransform(kLocal_GrCoordSet, MakeDivByTextureWHMatrix(yTexture), yTe xture)
75 , fYAccess(yTexture) 76 , fYAccess(yTexture)
76 , fUAccess(uTexture) 77 , fUAccess(uTexture)
(...skipping 20 matching lines...) Expand all
97 typedef GrEffect INHERITED; 98 typedef GrEffect INHERITED;
98 }; 99 };
99 100
100 } 101 }
101 102
102 ////////////////////////////////////////////////////////////////////////////// 103 //////////////////////////////////////////////////////////////////////////////
103 104
104 GrEffect* GrYUVtoRGBEffect::Create(GrTexture* yTexture, GrTexture* uTexture, GrT exture* vTexture) { 105 GrEffect* GrYUVtoRGBEffect::Create(GrTexture* yTexture, GrTexture* uTexture, GrT exture* vTexture) {
105 return YUVtoRGBEffect::Create(yTexture, uTexture, vTexture); 106 return YUVtoRGBEffect::Create(yTexture, uTexture, vTexture);
106 } 107 }
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