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

Side by Side Diff: src/gpu/GrDefaultGeoProcFactory.cpp

Issue 1462123003: Create GrGLSLVaryingHandler class for program building (Closed) Base URL: https://skia.googlesource.com/skia.git@putCapsOnArgs
Patch Set: fix release builder 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 | « gyp/gpu.gypi ('k') | src/gpu/GrOvalRenderer.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 "GrDefaultGeoProcFactory.h" 8 #include "GrDefaultGeoProcFactory.h"
9 9
10 #include "GrInvariantOutput.h" 10 #include "GrInvariantOutput.h"
11 #include "glsl/GrGLSLFragmentShaderBuilder.h" 11 #include "glsl/GrGLSLFragmentShaderBuilder.h"
12 #include "glsl/GrGLSLGeometryProcessor.h" 12 #include "glsl/GrGLSLGeometryProcessor.h"
13 #include "glsl/GrGLSLProgramBuilder.h" 13 #include "glsl/GrGLSLProgramBuilder.h"
14 #include "glsl/GrGLSLVertexShaderBuilder.h" 14 #include "glsl/GrGLSLVertexShaderBuilder.h"
15 #include "glsl/GrGLSLVarying.h"
15 #include "glsl/GrGLSLUtil.h" 16 #include "glsl/GrGLSLUtil.h"
16 17
17 /* 18 /*
18 * The default Geometry Processor simply takes position and multiplies it by the uniform view 19 * The default Geometry Processor simply takes position and multiplies it by the uniform view
19 * matrix. It also leaves coverage untouched. Behind the scenes, we may add per vertex color or 20 * matrix. It also leaves coverage untouched. Behind the scenes, we may add per vertex color or
20 * local coords. 21 * local coords.
21 */ 22 */
22 23
23 enum GPFlag { 24 enum GPFlag {
24 kColor_GPFlag = 0x1, 25 kColor_GPFlag = 0x1,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 class GLSLProcessor : public GrGLSLGeometryProcessor { 60 class GLSLProcessor : public GrGLSLGeometryProcessor {
60 public: 61 public:
61 GLSLProcessor() 62 GLSLProcessor()
62 : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor_ILLEGAL), f Coverage(0xff) {} 63 : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor_ILLEGAL), f Coverage(0xff) {}
63 64
64 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { 65 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
65 const DefaultGeoProc& gp = args.fGP.cast<DefaultGeoProc>(); 66 const DefaultGeoProc& gp = args.fGP.cast<DefaultGeoProc>();
66 GrGLSLGPBuilder* pb = args.fPB; 67 GrGLSLGPBuilder* pb = args.fPB;
67 GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder; 68 GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
68 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; 69 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
70 GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
69 71
70 // emit attributes 72 // emit attributes
71 vertBuilder->emitAttributes(gp); 73 varyingHandler->emitAttributes(gp);
72 74
73 // Setup pass through color 75 // Setup pass through color
74 if (!gp.colorIgnored()) { 76 if (!gp.colorIgnored()) {
75 if (gp.hasVertexColor()) { 77 if (gp.hasVertexColor()) {
76 pb->addPassThroughAttribute(gp.inColor(), args.fOutputColor) ; 78 varyingHandler->addPassThroughAttribute(gp.inColor(), args.f OutputColor);
77 } else { 79 } else {
78 this->setupUniformColor(pb, fragBuilder, args.fOutputColor, &fColorUniform); 80 this->setupUniformColor(pb, fragBuilder, args.fOutputColor, &fColorUniform);
79 } 81 }
80 } 82 }
81 83
82 // Setup position 84 // Setup position
83 this->setupPosition(pb, 85 this->setupPosition(pb,
84 vertBuilder, 86 vertBuilder,
85 gpArgs, 87 gpArgs,
86 gp.inPosition()->fName, 88 gp.inPosition()->fName,
87 gp.viewMatrix(), 89 gp.viewMatrix(),
88 &fViewMatrixUniform); 90 &fViewMatrixUniform);
89 91
90 if (gp.hasExplicitLocalCoords()) { 92 if (gp.hasExplicitLocalCoords()) {
91 // emit transforms with explicit local coords 93 // emit transforms with explicit local coords
92 this->emitTransforms(pb, 94 this->emitTransforms(pb,
93 vertBuilder, 95 vertBuilder,
96 varyingHandler,
94 gpArgs->fPositionVar, 97 gpArgs->fPositionVar,
95 gp.inLocalCoords()->fName, 98 gp.inLocalCoords()->fName,
96 gp.localMatrix(), 99 gp.localMatrix(),
97 args.fTransformsIn, 100 args.fTransformsIn,
98 args.fTransformsOut); 101 args.fTransformsOut);
99 } else if(gp.hasTransformedLocalCoords()) { 102 } else if(gp.hasTransformedLocalCoords()) {
100 // transforms have already been applied to vertex attributes on the cpu 103 // transforms have already been applied to vertex attributes on the cpu
101 this->emitTransforms(pb, 104 this->emitTransforms(pb,
102 vertBuilder, 105 vertBuilder,
106 varyingHandler,
103 gp.inLocalCoords()->fName, 107 gp.inLocalCoords()->fName,
104 args.fTransformsIn, 108 args.fTransformsIn,
105 args.fTransformsOut); 109 args.fTransformsOut);
106 } else { 110 } else {
107 // emit transforms with position 111 // emit transforms with position
108 this->emitTransforms(pb, 112 this->emitTransforms(pb,
109 vertBuilder, 113 vertBuilder,
114 varyingHandler,
110 gpArgs->fPositionVar, 115 gpArgs->fPositionVar,
111 gp.inPosition()->fName, 116 gp.inPosition()->fName,
112 gp.localMatrix(), 117 gp.localMatrix(),
113 args.fTransformsIn, 118 args.fTransformsIn,
114 args.fTransformsOut); 119 args.fTransformsOut);
115 } 120 }
116 121
117 // Setup coverage as pass through 122 // Setup coverage as pass through
118 if (!gp.coverageWillBeIgnored()) { 123 if (!gp.coverageWillBeIgnored()) {
119 if (gp.hasVertexCoverage()) { 124 if (gp.hasVertexCoverage()) {
120 fragBuilder->codeAppendf("float alpha = 1.0;"); 125 fragBuilder->codeAppendf("float alpha = 1.0;");
121 args.fPB->addPassThroughAttribute(gp.inCoverage(), "alpha"); 126 varyingHandler->addPassThroughAttribute(gp.inCoverage(), "al pha");
122 fragBuilder->codeAppendf("%s = vec4(alpha);", args.fOutputCo verage); 127 fragBuilder->codeAppendf("%s = vec4(alpha);", args.fOutputCo verage);
123 } else if (gp.coverage() == 0xff) { 128 } else if (gp.coverage() == 0xff) {
124 fragBuilder->codeAppendf("%s = vec4(1);", args.fOutputCovera ge); 129 fragBuilder->codeAppendf("%s = vec4(1);", args.fOutputCovera ge);
125 } else { 130 } else {
126 const char* fragCoverage; 131 const char* fragCoverage;
127 fCoverageUniform = pb->addUniform(GrGLSLProgramBuilder::kFra gment_Visibility, 132 fCoverageUniform = pb->addUniform(GrGLSLProgramBuilder::kFra gment_Visibility,
128 kFloat_GrSLType, 133 kFloat_GrSLType,
129 kDefault_GrSLPrecision, 134 kDefault_GrSLPrecision,
130 "Coverage", 135 "Coverage",
131 &fragCoverage); 136 &fragCoverage);
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 } 334 }
330 335
331 if (localCoords.hasLocalMatrix()) { 336 if (localCoords.hasLocalMatrix()) {
332 invert.preConcat(*localCoords.fMatrix); 337 invert.preConcat(*localCoords.fMatrix);
333 } 338 }
334 } 339 }
335 340
336 LocalCoords inverted(LocalCoords::kUsePosition_Type, &invert); 341 LocalCoords inverted(LocalCoords::kUsePosition_Type, &invert);
337 return Create(color, coverage, inverted, SkMatrix::I()); 342 return Create(color, coverage, inverted, SkMatrix::I());
338 } 343 }
OLDNEW
« no previous file with comments | « gyp/gpu.gypi ('k') | src/gpu/GrOvalRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698