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

Side by Side Diff: src/gpu/batches/GrAnalyticRectBatch.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 | « src/gpu/batches/GrAAConvexPathRenderer.cpp ('k') | src/gpu/batches/GrMSAAPathRenderer.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 2016 Google Inc. 2 * Copyright 2016 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 "GrAnalyticRectBatch.h" 8 #include "GrAnalyticRectBatch.h"
9 9
10 #include "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
11 #include "GrBatchTest.h" 11 #include "GrBatchTest.h"
12 #include "GrGeometryProcessor.h" 12 #include "GrGeometryProcessor.h"
13 #include "GrInvariantOutput.h" 13 #include "GrInvariantOutput.h"
14 #include "GrProcessor.h" 14 #include "GrProcessor.h"
15 #include "GrResourceProvider.h" 15 #include "GrResourceProvider.h"
16 #include "SkRRect.h" 16 #include "SkRRect.h"
17 #include "SkStrokeRec.h" 17 #include "SkStrokeRec.h"
18 #include "batches/GrVertexBatch.h" 18 #include "batches/GrVertexBatch.h"
19 #include "glsl/GrGLSLFragmentShaderBuilder.h" 19 #include "glsl/GrGLSLFragmentShaderBuilder.h"
20 #include "glsl/GrGLSLGeometryProcessor.h" 20 #include "glsl/GrGLSLGeometryProcessor.h"
21 #include "glsl/GrGLSLGeometryProcessor.h"
21 #include "glsl/GrGLSLProgramDataManager.h" 22 #include "glsl/GrGLSLProgramDataManager.h"
22 #include "glsl/GrGLSLVarying.h" 23 #include "glsl/GrGLSLVarying.h"
23 #include "glsl/GrGLSLVertexShaderBuilder.h" 24 #include "glsl/GrGLSLVertexShaderBuilder.h"
24 #include "glsl/GrGLSLUniformHandler.h" 25 #include "glsl/GrGLSLUniformHandler.h"
25 #include "glsl/GrGLSLUtil.h" 26 #include "glsl/GrGLSLUtil.h"
26 27
27 namespace { 28 namespace {
28 29
29 struct RectVertex { 30 struct RectVertex {
30 SkPoint fPos; 31 SkPoint fPos;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 // Setup position 114 // Setup position
114 this->setupPosition(vertBuilder, gpArgs, rgp.inPosition()->fName); 115 this->setupPosition(vertBuilder, gpArgs, rgp.inPosition()->fName);
115 116
116 // emit transforms 117 // emit transforms
117 this->emitTransforms(vertBuilder, 118 this->emitTransforms(vertBuilder,
118 varyingHandler, 119 varyingHandler,
119 uniformHandler, 120 uniformHandler,
120 gpArgs->fPositionVar, 121 gpArgs->fPositionVar,
121 rgp.inPosition()->fName, 122 rgp.inPosition()->fName,
122 rgp.localMatrix(), 123 rgp.localMatrix(),
123 args.fTransformsIn, 124 args.fFPCoordTransformHandler);
124 args.fTransformsOut);
125 125
126 // TODO: compute all these offsets, spans, and scales in the VS 126 // TODO: compute all these offsets, spans, and scales in the VS
127 fragBuilder->codeAppendf("float insetW = min(1.0, %s.x) - 0.5;", 127 fragBuilder->codeAppendf("float insetW = min(1.0, %s.x) - 0.5;",
128 widthHeightVary.fsIn()); 128 widthHeightVary.fsIn());
129 fragBuilder->codeAppendf("float insetH = min(1.0, %s.y) - 0.5;", 129 fragBuilder->codeAppendf("float insetH = min(1.0, %s.y) - 0.5;",
130 widthHeightVary.fsIn()); 130 widthHeightVary.fsIn());
131 fragBuilder->codeAppend("float outset = 0.5;"); 131 fragBuilder->codeAppend("float outset = 0.5;");
132 // For rects > 1 pixel wide and tall the span's are noops (i.e., 1.0 ). For rects 132 // For rects > 1 pixel wide and tall the span's are noops (i.e., 1.0 ). For rects
133 // < 1 pixel wide or tall they serve to normalize the < 1 ramp to a 0 .. 1 range. 133 // < 1 pixel wide or tall they serve to normalize the < 1 ramp to a 0 .. 1 range.
134 fragBuilder->codeAppend("float spanW = insetW + outset;"); 134 fragBuilder->codeAppend("float spanW = insetW + outset;");
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 187
188 } 188 }
189 } 189 }
190 190
191 static void GenKey(const GrGeometryProcessor& gp, 191 static void GenKey(const GrGeometryProcessor& gp,
192 const GrGLSLCaps&, 192 const GrGLSLCaps&,
193 GrProcessorKeyBuilder* b) { 193 GrProcessorKeyBuilder* b) {
194 b->add32(0x0); 194 b->add32(0x0);
195 } 195 }
196 196
197 void setData(const GrGLSLProgramDataManager& pdman, 197 void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitivePro cessor& primProc,
198 const GrPrimitiveProcessor& gp) override {} 198 FPCoordTransformIter&& transformIter) override {
199 199 const RectGeometryProcessor& rgp = primProc.cast<RectGeometryProcess or>();
200 void setTransformData(const GrPrimitiveProcessor& primProc, 200 this->setTransformDataHelper(rgp.fLocalMatrix, pdman,&transformIter) ;
201 const GrGLSLProgramDataManager& pdman,
202 int index,
203 const SkTArray<const GrCoordTransform*, true>& tra nsforms) override {
204 this->setTransformDataHelper(primProc.cast<RectGeometryProcessor>(). fLocalMatrix, pdman,
205 index, transforms);
206 } 201 }
207 202
208 private: 203 private:
209 typedef GrGLSLGeometryProcessor INHERITED; 204 typedef GrGLSLGeometryProcessor INHERITED;
210 }; 205 };
211 206
212 void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c onst override { 207 void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c onst override {
213 GLSLProcessor::GenKey(*this, caps, b); 208 GLSLProcessor::GenKey(*this, caps, b);
214 } 209 }
215 210
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 DRAW_BATCH_TEST_DEFINE(AnalyticRectBatch) { 400 DRAW_BATCH_TEST_DEFINE(AnalyticRectBatch) {
406 SkMatrix viewMatrix = GrTest::TestMatrix(random); 401 SkMatrix viewMatrix = GrTest::TestMatrix(random);
407 GrColor color = GrRandomColor(random); 402 GrColor color = GrRandomColor(random);
408 SkRect rect = GrTest::TestSquare(random); 403 SkRect rect = GrTest::TestSquare(random);
409 SkRect croppedRect = GrTest::TestSquare(random); 404 SkRect croppedRect = GrTest::TestSquare(random);
410 SkRect bounds = GrTest::TestSquare(random); 405 SkRect bounds = GrTest::TestSquare(random);
411 return new AnalyticRectBatch(color, viewMatrix, rect, croppedRect, bounds); 406 return new AnalyticRectBatch(color, viewMatrix, rect, croppedRect, bounds);
412 } 407 }
413 408
414 #endif 409 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrAAConvexPathRenderer.cpp ('k') | src/gpu/batches/GrMSAAPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698