OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "GrOvalRenderer.h" | 8 #include "GrOvalRenderer.h" |
9 | 9 |
10 #include "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
11 #include "GrBatchTest.h" | 11 #include "GrBatchTest.h" |
12 #include "GrDrawTarget.h" | 12 #include "GrDrawTarget.h" |
13 #include "GrGeometryProcessor.h" | 13 #include "GrGeometryProcessor.h" |
14 #include "GrInvariantOutput.h" | 14 #include "GrInvariantOutput.h" |
15 #include "GrPipelineBuilder.h" | 15 #include "GrPipelineBuilder.h" |
16 #include "GrProcessor.h" | 16 #include "GrProcessor.h" |
17 #include "GrResourceProvider.h" | 17 #include "GrResourceProvider.h" |
18 #include "GrVertexBuffer.h" | 18 #include "GrVertexBuffer.h" |
19 #include "SkRRect.h" | 19 #include "SkRRect.h" |
20 #include "SkStrokeRec.h" | 20 #include "SkStrokeRec.h" |
21 #include "SkTLazy.h" | 21 #include "SkTLazy.h" |
22 #include "batches/GrVertexBatch.h" | 22 #include "batches/GrVertexBatch.h" |
23 #include "effects/GrRRectEffect.h" | 23 #include "effects/GrRRectEffect.h" |
24 #include "gl/GrGLGeometryProcessor.h" | |
25 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 24 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
| 25 #include "glsl/GrGLSLGeometryProcessor.h" |
26 #include "glsl/GrGLSLProgramBuilder.h" | 26 #include "glsl/GrGLSLProgramBuilder.h" |
27 #include "glsl/GrGLSLProgramDataManager.h" | 27 #include "glsl/GrGLSLProgramDataManager.h" |
28 #include "glsl/GrGLSLVertexShaderBuilder.h" | 28 #include "glsl/GrGLSLVertexShaderBuilder.h" |
29 #include "glsl/GrGLSLUtil.h" | 29 #include "glsl/GrGLSLUtil.h" |
30 | 30 |
31 // TODO(joshualitt) - Break this file up during GrBatch post implementation clea
nup | 31 // TODO(joshualitt) - Break this file up during GrBatch post implementation clea
nup |
32 | 32 |
33 namespace { | 33 namespace { |
34 // TODO(joshualitt) add per vertex colors | 34 // TODO(joshualitt) add per vertex colors |
35 struct CircleVertex { | 35 struct CircleVertex { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 GrColor color() const { return fColor; } | 83 GrColor color() const { return fColor; } |
84 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } | 84 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } |
85 const SkMatrix& localMatrix() const { return fLocalMatrix; } | 85 const SkMatrix& localMatrix() const { return fLocalMatrix; } |
86 bool usesLocalCoords() const { return fUsesLocalCoords; } | 86 bool usesLocalCoords() const { return fUsesLocalCoords; } |
87 virtual ~CircleEdgeEffect() {} | 87 virtual ~CircleEdgeEffect() {} |
88 | 88 |
89 const char* name() const override { return "CircleEdge"; } | 89 const char* name() const override { return "CircleEdge"; } |
90 | 90 |
91 inline bool isStroked() const { return fStroke; } | 91 inline bool isStroked() const { return fStroke; } |
92 | 92 |
93 class GLProcessor : public GrGLGeometryProcessor { | 93 class GLProcessor : public GrGLSLGeometryProcessor { |
94 public: | 94 public: |
95 GLProcessor() | 95 GLProcessor() |
96 : fColor(GrColor_ILLEGAL) {} | 96 : fColor(GrColor_ILLEGAL) {} |
97 | 97 |
98 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{ | 98 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{ |
99 const CircleEdgeEffect& ce = args.fGP.cast<CircleEdgeEffect>(); | 99 const CircleEdgeEffect& ce = args.fGP.cast<CircleEdgeEffect>(); |
100 GrGLSLGPBuilder* pb = args.fPB; | 100 GrGLSLGPBuilder* pb = args.fPB; |
101 GrGLSLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 101 GrGLSLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
102 | 102 |
103 // emit attributes | 103 // emit attributes |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 void setTransformData(const GrPrimitiveProcessor& primProc, | 155 void setTransformData(const GrPrimitiveProcessor& primProc, |
156 const GrGLSLProgramDataManager& pdman, | 156 const GrGLSLProgramDataManager& pdman, |
157 int index, | 157 int index, |
158 const SkTArray<const GrCoordTransform*, true>& tra
nsforms) override { | 158 const SkTArray<const GrCoordTransform*, true>& tra
nsforms) override { |
159 this->setTransformDataHelper<CircleEdgeEffect>(primProc, pdman, inde
x, transforms); | 159 this->setTransformDataHelper<CircleEdgeEffect>(primProc, pdman, inde
x, transforms); |
160 } | 160 } |
161 | 161 |
162 private: | 162 private: |
163 GrColor fColor; | 163 GrColor fColor; |
164 UniformHandle fColorUniform; | 164 UniformHandle fColorUniform; |
165 typedef GrGLGeometryProcessor INHERITED; | 165 typedef GrGLSLGeometryProcessor INHERITED; |
166 }; | 166 }; |
167 | 167 |
168 void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) con
st override { | 168 void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) con
st override { |
169 GLProcessor::GenKey(*this, caps, b); | 169 GLProcessor::GenKey(*this, caps, b); |
170 } | 170 } |
171 | 171 |
172 GrGLPrimitiveProcessor* createGLInstance(const GrGLSLCaps&) const override { | 172 GrGLSLPrimitiveProcessor* createGLInstance(const GrGLSLCaps&) const override
{ |
173 return new GLProcessor(); | 173 return new GLProcessor(); |
174 } | 174 } |
175 | 175 |
176 private: | 176 private: |
177 CircleEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix, bo
ol usesLocalCoords) | 177 CircleEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix, bo
ol usesLocalCoords) |
178 : fColor(color) | 178 : fColor(color) |
179 , fLocalMatrix(localMatrix) | 179 , fLocalMatrix(localMatrix) |
180 , fUsesLocalCoords(usesLocalCoords) { | 180 , fUsesLocalCoords(usesLocalCoords) { |
181 this->initClassID<CircleEdgeEffect>(); | 181 this->initClassID<CircleEdgeEffect>(); |
182 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType, | 182 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 const Attribute* inPosition() const { return fInPosition; } | 231 const Attribute* inPosition() const { return fInPosition; } |
232 const Attribute* inEllipseOffset() const { return fInEllipseOffset; } | 232 const Attribute* inEllipseOffset() const { return fInEllipseOffset; } |
233 const Attribute* inEllipseRadii() const { return fInEllipseRadii; } | 233 const Attribute* inEllipseRadii() const { return fInEllipseRadii; } |
234 GrColor color() const { return fColor; } | 234 GrColor color() const { return fColor; } |
235 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } | 235 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } |
236 const SkMatrix& localMatrix() const { return fLocalMatrix; } | 236 const SkMatrix& localMatrix() const { return fLocalMatrix; } |
237 bool usesLocalCoords() const { return fUsesLocalCoords; } | 237 bool usesLocalCoords() const { return fUsesLocalCoords; } |
238 | 238 |
239 inline bool isStroked() const { return fStroke; } | 239 inline bool isStroked() const { return fStroke; } |
240 | 240 |
241 class GLProcessor : public GrGLGeometryProcessor { | 241 class GLProcessor : public GrGLSLGeometryProcessor { |
242 public: | 242 public: |
243 GLProcessor() | 243 GLProcessor() |
244 : fColor(GrColor_ILLEGAL) {} | 244 : fColor(GrColor_ILLEGAL) {} |
245 | 245 |
246 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{ | 246 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{ |
247 const EllipseEdgeEffect& ee = args.fGP.cast<EllipseEdgeEffect>(); | 247 const EllipseEdgeEffect& ee = args.fGP.cast<EllipseEdgeEffect>(); |
248 GrGLSLGPBuilder* pb = args.fPB; | 248 GrGLSLGPBuilder* pb = args.fPB; |
249 GrGLSLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 249 GrGLSLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
250 | 250 |
251 // emit attributes | 251 // emit attributes |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 const GrGLSLProgramDataManager& pdman, | 324 const GrGLSLProgramDataManager& pdman, |
325 int index, | 325 int index, |
326 const SkTArray<const GrCoordTransform*, true>& tra
nsforms) override { | 326 const SkTArray<const GrCoordTransform*, true>& tra
nsforms) override { |
327 this->setTransformDataHelper<EllipseEdgeEffect>(primProc, pdman, ind
ex, transforms); | 327 this->setTransformDataHelper<EllipseEdgeEffect>(primProc, pdman, ind
ex, transforms); |
328 } | 328 } |
329 | 329 |
330 private: | 330 private: |
331 GrColor fColor; | 331 GrColor fColor; |
332 UniformHandle fColorUniform; | 332 UniformHandle fColorUniform; |
333 | 333 |
334 typedef GrGLGeometryProcessor INHERITED; | 334 typedef GrGLSLGeometryProcessor INHERITED; |
335 }; | 335 }; |
336 | 336 |
337 void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) con
st override { | 337 void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) con
st override { |
338 GLProcessor::GenKey(*this, caps, b); | 338 GLProcessor::GenKey(*this, caps, b); |
339 } | 339 } |
340 | 340 |
341 GrGLPrimitiveProcessor* createGLInstance(const GrGLSLCaps&) const override { | 341 GrGLSLPrimitiveProcessor* createGLInstance(const GrGLSLCaps&) const override
{ |
342 return new GLProcessor(); | 342 return new GLProcessor(); |
343 } | 343 } |
344 | 344 |
345 private: | 345 private: |
346 EllipseEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix, | 346 EllipseEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix, |
347 bool usesLocalCoords) | 347 bool usesLocalCoords) |
348 : fColor(color) | 348 : fColor(color) |
349 , fLocalMatrix(localMatrix) | 349 , fLocalMatrix(localMatrix) |
350 , fUsesLocalCoords(usesLocalCoords) { | 350 , fUsesLocalCoords(usesLocalCoords) { |
351 this->initClassID<EllipseEdgeEffect>(); | 351 this->initClassID<EllipseEdgeEffect>(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 const Attribute* inPosition() const { return fInPosition; } | 406 const Attribute* inPosition() const { return fInPosition; } |
407 const Attribute* inEllipseOffsets0() const { return fInEllipseOffsets0; } | 407 const Attribute* inEllipseOffsets0() const { return fInEllipseOffsets0; } |
408 const Attribute* inEllipseOffsets1() const { return fInEllipseOffsets1; } | 408 const Attribute* inEllipseOffsets1() const { return fInEllipseOffsets1; } |
409 GrColor color() const { return fColor; } | 409 GrColor color() const { return fColor; } |
410 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } | 410 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } |
411 const SkMatrix& viewMatrix() const { return fViewMatrix; } | 411 const SkMatrix& viewMatrix() const { return fViewMatrix; } |
412 bool usesLocalCoords() const { return fUsesLocalCoords; } | 412 bool usesLocalCoords() const { return fUsesLocalCoords; } |
413 | 413 |
414 inline Mode getMode() const { return fMode; } | 414 inline Mode getMode() const { return fMode; } |
415 | 415 |
416 class GLProcessor : public GrGLGeometryProcessor { | 416 class GLProcessor : public GrGLSLGeometryProcessor { |
417 public: | 417 public: |
418 GLProcessor() | 418 GLProcessor() |
419 : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor_ILLEGAL) {} | 419 : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor_ILLEGAL) {} |
420 | 420 |
421 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { | 421 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { |
422 const DIEllipseEdgeEffect& ee = args.fGP.cast<DIEllipseEdgeEffect>()
; | 422 const DIEllipseEdgeEffect& ee = args.fGP.cast<DIEllipseEdgeEffect>()
; |
423 GrGLSLGPBuilder* pb = args.fPB; | 423 GrGLSLGPBuilder* pb = args.fPB; |
424 GrGLSLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 424 GrGLSLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
425 | 425 |
426 // emit attributes | 426 // emit attributes |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 fColor = dee.color(); | 518 fColor = dee.color(); |
519 } | 519 } |
520 } | 520 } |
521 | 521 |
522 private: | 522 private: |
523 SkMatrix fViewMatrix; | 523 SkMatrix fViewMatrix; |
524 GrColor fColor; | 524 GrColor fColor; |
525 UniformHandle fColorUniform; | 525 UniformHandle fColorUniform; |
526 UniformHandle fViewMatrixUniform; | 526 UniformHandle fViewMatrixUniform; |
527 | 527 |
528 typedef GrGLGeometryProcessor INHERITED; | 528 typedef GrGLSLGeometryProcessor INHERITED; |
529 }; | 529 }; |
530 | 530 |
531 void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) con
st override { | 531 void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) con
st override { |
532 GLProcessor::GenKey(*this, caps, b); | 532 GLProcessor::GenKey(*this, caps, b); |
533 } | 533 } |
534 | 534 |
535 GrGLPrimitiveProcessor* createGLInstance(const GrGLSLCaps&) const override { | 535 GrGLSLPrimitiveProcessor* createGLInstance(const GrGLSLCaps&) const override
{ |
536 return new GLProcessor(); | 536 return new GLProcessor(); |
537 } | 537 } |
538 | 538 |
539 private: | 539 private: |
540 DIEllipseEdgeEffect(GrColor color, const SkMatrix& viewMatrix, Mode mode, | 540 DIEllipseEdgeEffect(GrColor color, const SkMatrix& viewMatrix, Mode mode, |
541 bool usesLocalCoords) | 541 bool usesLocalCoords) |
542 : fColor(color) | 542 : fColor(color) |
543 , fViewMatrix(viewMatrix) | 543 , fViewMatrix(viewMatrix) |
544 , fUsesLocalCoords(usesLocalCoords) { | 544 , fUsesLocalCoords(usesLocalCoords) { |
545 this->initClassID<DIEllipseEdgeEffect>(); | 545 this->initClassID<DIEllipseEdgeEffect>(); |
(...skipping 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2032 } | 2032 } |
2033 | 2033 |
2034 DRAW_BATCH_TEST_DEFINE(RRectBatch) { | 2034 DRAW_BATCH_TEST_DEFINE(RRectBatch) { |
2035 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); | 2035 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); |
2036 GrColor color = GrRandomColor(random); | 2036 GrColor color = GrRandomColor(random); |
2037 const SkRRect& rrect = GrTest::TestRRectSimple(random); | 2037 const SkRRect& rrect = GrTest::TestRRectSimple(random); |
2038 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra
ndom)); | 2038 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra
ndom)); |
2039 } | 2039 } |
2040 | 2040 |
2041 #endif | 2041 #endif |
OLD | NEW |