OLD | NEW |
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" | |
22 #include "glsl/GrGLSLProgramDataManager.h" | 21 #include "glsl/GrGLSLProgramDataManager.h" |
23 #include "glsl/GrGLSLVarying.h" | 22 #include "glsl/GrGLSLVarying.h" |
24 #include "glsl/GrGLSLVertexShaderBuilder.h" | 23 #include "glsl/GrGLSLVertexShaderBuilder.h" |
25 #include "glsl/GrGLSLUniformHandler.h" | 24 #include "glsl/GrGLSLUniformHandler.h" |
26 #include "glsl/GrGLSLUtil.h" | 25 #include "glsl/GrGLSLUtil.h" |
27 | 26 |
28 namespace { | 27 namespace { |
29 | 28 |
30 struct RectVertex { | 29 struct RectVertex { |
31 SkPoint fPos; | 30 SkPoint fPos; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 // Setup position | 113 // Setup position |
115 this->setupPosition(vertBuilder, gpArgs, rgp.inPosition()->fName); | 114 this->setupPosition(vertBuilder, gpArgs, rgp.inPosition()->fName); |
116 | 115 |
117 // emit transforms | 116 // emit transforms |
118 this->emitTransforms(vertBuilder, | 117 this->emitTransforms(vertBuilder, |
119 varyingHandler, | 118 varyingHandler, |
120 uniformHandler, | 119 uniformHandler, |
121 gpArgs->fPositionVar, | 120 gpArgs->fPositionVar, |
122 rgp.inPosition()->fName, | 121 rgp.inPosition()->fName, |
123 rgp.localMatrix(), | 122 rgp.localMatrix(), |
124 args.fFPCoordTransformHandler); | 123 args.fTransformsIn, |
| 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 Loading... |
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, const GrPrimitivePro
cessor& primProc, | 197 void setData(const GrGLSLProgramDataManager& pdman, |
198 FPCoordTransformIter&& transformIter) override { | 198 const GrPrimitiveProcessor& gp) override {} |
199 const RectGeometryProcessor& rgp = primProc.cast<RectGeometryProcess
or>(); | 199 |
200 this->setTransformDataHelper(rgp.fLocalMatrix, pdman,&transformIter)
; | 200 void setTransformData(const GrPrimitiveProcessor& primProc, |
| 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); |
201 } | 206 } |
202 | 207 |
203 private: | 208 private: |
204 typedef GrGLSLGeometryProcessor INHERITED; | 209 typedef GrGLSLGeometryProcessor INHERITED; |
205 }; | 210 }; |
206 | 211 |
207 void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override { | 212 void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override { |
208 GLSLProcessor::GenKey(*this, caps, b); | 213 GLSLProcessor::GenKey(*this, caps, b); |
209 } | 214 } |
210 | 215 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 DRAW_BATCH_TEST_DEFINE(AnalyticRectBatch) { | 405 DRAW_BATCH_TEST_DEFINE(AnalyticRectBatch) { |
401 SkMatrix viewMatrix = GrTest::TestMatrix(random); | 406 SkMatrix viewMatrix = GrTest::TestMatrix(random); |
402 GrColor color = GrRandomColor(random); | 407 GrColor color = GrRandomColor(random); |
403 SkRect rect = GrTest::TestSquare(random); | 408 SkRect rect = GrTest::TestSquare(random); |
404 SkRect croppedRect = GrTest::TestSquare(random); | 409 SkRect croppedRect = GrTest::TestSquare(random); |
405 SkRect bounds = GrTest::TestSquare(random); | 410 SkRect bounds = GrTest::TestSquare(random); |
406 return new AnalyticRectBatch(color, viewMatrix, rect, croppedRect, bounds); | 411 return new AnalyticRectBatch(color, viewMatrix, rect, croppedRect, bounds); |
407 } | 412 } |
408 | 413 |
409 #endif | 414 #endif |
OLD | NEW |