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

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

Issue 2339203002: Stop flattening GrCoordTransforms in parent GrFragmentProcessors. (Closed)
Patch Set: Fix issue of taking ref to a temporary Created 4 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 | « include/gpu/GrFragmentProcessor.h ('k') | src/gpu/GrFragmentProcessor.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"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 &fViewMatrixUniform); 92 &fViewMatrixUniform);
93 93
94 if (gp.hasExplicitLocalCoords()) { 94 if (gp.hasExplicitLocalCoords()) {
95 // emit transforms with explicit local coords 95 // emit transforms with explicit local coords
96 this->emitTransforms(vertBuilder, 96 this->emitTransforms(vertBuilder,
97 varyingHandler, 97 varyingHandler,
98 uniformHandler, 98 uniformHandler,
99 gpArgs->fPositionVar, 99 gpArgs->fPositionVar,
100 gp.inLocalCoords()->fName, 100 gp.inLocalCoords()->fName,
101 gp.localMatrix(), 101 gp.localMatrix(),
102 args.fTransformsIn, 102 args.fFPCoordTransformHandler);
103 args.fTransformsOut);
104 } else { 103 } else {
105 // emit transforms with position 104 // emit transforms with position
106 this->emitTransforms(vertBuilder, 105 this->emitTransforms(vertBuilder,
107 varyingHandler, 106 varyingHandler,
108 uniformHandler, 107 uniformHandler,
109 gpArgs->fPositionVar, 108 gpArgs->fPositionVar,
110 gp.inPosition()->fName, 109 gp.inPosition()->fName,
111 gp.localMatrix(), 110 gp.localMatrix(),
112 args.fTransformsIn, 111 args.fFPCoordTransformHandler);
113 args.fTransformsOut);
114 } 112 }
115 113
116 // Setup coverage as pass through 114 // Setup coverage as pass through
117 if (!gp.coverageWillBeIgnored()) { 115 if (!gp.coverageWillBeIgnored()) {
118 if (gp.hasVertexCoverage()) { 116 if (gp.hasVertexCoverage()) {
119 fragBuilder->codeAppendf("float alpha = 1.0;"); 117 fragBuilder->codeAppendf("float alpha = 1.0;");
120 varyingHandler->addPassThroughAttribute(gp.inCoverage(), "al pha"); 118 varyingHandler->addPassThroughAttribute(gp.inCoverage(), "al pha");
121 fragBuilder->codeAppendf("%s = vec4(alpha);", args.fOutputCo verage); 119 fragBuilder->codeAppendf("%s = vec4(alpha);", args.fOutputCo verage);
122 } else if (gp.coverage() == 0xff) { 120 } else if (gp.coverage() == 0xff) {
123 fragBuilder->codeAppendf("%s = vec4(1);", args.fOutputCovera ge); 121 fragBuilder->codeAppendf("%s = vec4(1);", args.fOutputCovera ge);
(...skipping 19 matching lines...) Expand all
143 key |= def.hasVertexColor() << 10; 141 key |= def.hasVertexColor() << 10;
144 key |= def.hasVertexCoverage() << 11; 142 key |= def.hasVertexCoverage() << 11;
145 key |= def.coverage() == 0xff ? 0x1 << 12 : 0; 143 key |= def.coverage() == 0xff ? 0x1 << 12 : 0;
146 key |= def.localCoordsWillBeRead() && def.localMatrix().hasPerspecti ve() ? 0x1 << 24 : 144 key |= def.localCoordsWillBeRead() && def.localMatrix().hasPerspecti ve() ? 0x1 << 24 :
147 0x0; 145 0x0;
148 key |= ComputePosKey(def.viewMatrix()) << 25; 146 key |= ComputePosKey(def.viewMatrix()) << 25;
149 b->add32(key); 147 b->add32(key);
150 } 148 }
151 149
152 void setData(const GrGLSLProgramDataManager& pdman, 150 void setData(const GrGLSLProgramDataManager& pdman,
153 const GrPrimitiveProcessor& gp) override { 151 const GrPrimitiveProcessor& gp,
152 FPCoordTransformIter&& transformIter) override {
154 const DefaultGeoProc& dgp = gp.cast<DefaultGeoProc>(); 153 const DefaultGeoProc& dgp = gp.cast<DefaultGeoProc>();
155 154
156 if (!dgp.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dgp. viewMatrix())) { 155 if (!dgp.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dgp. viewMatrix())) {
157 fViewMatrix = dgp.viewMatrix(); 156 fViewMatrix = dgp.viewMatrix();
158 float viewMatrix[3 * 3]; 157 float viewMatrix[3 * 3];
159 GrGLSLGetMatrix<3>(viewMatrix, fViewMatrix); 158 GrGLSLGetMatrix<3>(viewMatrix, fViewMatrix);
160 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); 159 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
161 } 160 }
162 161
163 if (dgp.color() != fColor && !dgp.hasVertexColor()) { 162 if (dgp.color() != fColor && !dgp.hasVertexColor()) {
164 float c[4]; 163 float c[4];
165 GrColorToRGBAFloat(dgp.color(), c); 164 GrColorToRGBAFloat(dgp.color(), c);
166 pdman.set4fv(fColorUniform, 1, c); 165 pdman.set4fv(fColorUniform, 1, c);
167 fColor = dgp.color(); 166 fColor = dgp.color();
168 } 167 }
169 168
170 if (!dgp.coverageWillBeIgnored() && 169 if (!dgp.coverageWillBeIgnored() &&
171 dgp.coverage() != fCoverage && !dgp.hasVertexCoverage()) { 170 dgp.coverage() != fCoverage && !dgp.hasVertexCoverage()) {
172 pdman.set1f(fCoverageUniform, GrNormalizeByteToFloat(dgp.coverag e())); 171 pdman.set1f(fCoverageUniform, GrNormalizeByteToFloat(dgp.coverag e()));
173 fCoverage = dgp.coverage(); 172 fCoverage = dgp.coverage();
174 } 173 }
175 } 174 this->setTransformDataHelper(dgp.fLocalMatrix, pdman, &transformIter );
176
177 void setTransformData(const GrPrimitiveProcessor& primProc,
178 const GrGLSLProgramDataManager& pdman,
179 int index,
180 const SkTArray<const GrCoordTransform*, true>& tra nsforms) override {
181 this->setTransformDataHelper(primProc.cast<DefaultGeoProc>().fLocalM atrix, pdman, index,
182 transforms);
183 } 175 }
184 176
185 private: 177 private:
186 SkMatrix fViewMatrix; 178 SkMatrix fViewMatrix;
187 GrColor fColor; 179 GrColor fColor;
188 uint8_t fCoverage; 180 uint8_t fCoverage;
189 UniformHandle fViewMatrixUniform; 181 UniformHandle fViewMatrixUniform;
190 UniformHandle fColorUniform; 182 UniformHandle fColorUniform;
191 UniformHandle fCoverageUniform; 183 UniformHandle fCoverageUniform;
192 184
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 } 307 }
316 308
317 if (localCoords.hasLocalMatrix()) { 309 if (localCoords.hasLocalMatrix()) {
318 invert.preConcat(*localCoords.fMatrix); 310 invert.preConcat(*localCoords.fMatrix);
319 } 311 }
320 } 312 }
321 313
322 LocalCoords inverted(LocalCoords::kUsePosition_Type, &invert); 314 LocalCoords inverted(LocalCoords::kUsePosition_Type, &invert);
323 return Make(color, coverage, inverted, SkMatrix::I()); 315 return Make(color, coverage, inverted, SkMatrix::I());
324 } 316 }
OLDNEW
« no previous file with comments | « include/gpu/GrFragmentProcessor.h ('k') | src/gpu/GrFragmentProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698