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 "GrBezierEffect.h" | 8 #include "GrBezierEffect.h" |
9 | 9 |
10 #include "gl/GrGLGeometryProcessor.h" | 10 #include "glsl/GrGLSLGeometryProcessor.h" |
11 #include "glsl/GrGLSLFragmentProcessor.h" | |
12 #include "glsl/GrGLSLProgramBuilder.h" | 11 #include "glsl/GrGLSLProgramBuilder.h" |
13 #include "glsl/GrGLSLProgramDataManager.h" | 12 #include "glsl/GrGLSLProgramDataManager.h" |
14 #include "glsl/GrGLSLUtil.h" | 13 #include "glsl/GrGLSLUtil.h" |
15 | 14 |
16 class GrGLConicEffect : public GrGLGeometryProcessor { | 15 class GrGLConicEffect : public GrGLSLGeometryProcessor { |
17 public: | 16 public: |
18 GrGLConicEffect(const GrGeometryProcessor&); | 17 GrGLConicEffect(const GrGeometryProcessor&); |
19 | 18 |
20 void onEmitCode(EmitArgs&, GrGPArgs*) override; | 19 void onEmitCode(EmitArgs&, GrGPArgs*) override; |
21 | 20 |
22 static inline void GenKey(const GrGeometryProcessor&, | 21 static inline void GenKey(const GrGeometryProcessor&, |
23 const GrGLSLCaps&, | 22 const GrGLSLCaps&, |
24 GrProcessorKeyBuilder*); | 23 GrProcessorKeyBuilder*); |
25 | 24 |
26 void setData(const GrGLSLProgramDataManager& pdman, | 25 void setData(const GrGLSLProgramDataManager& pdman, |
(...skipping 29 matching lines...) Expand all Loading... |
56 | 55 |
57 private: | 56 private: |
58 SkMatrix fViewMatrix; | 57 SkMatrix fViewMatrix; |
59 GrColor fColor; | 58 GrColor fColor; |
60 uint8_t fCoverageScale; | 59 uint8_t fCoverageScale; |
61 GrPrimitiveEdgeType fEdgeType; | 60 GrPrimitiveEdgeType fEdgeType; |
62 UniformHandle fColorUniform; | 61 UniformHandle fColorUniform; |
63 UniformHandle fCoverageScaleUniform; | 62 UniformHandle fCoverageScaleUniform; |
64 UniformHandle fViewMatrixUniform; | 63 UniformHandle fViewMatrixUniform; |
65 | 64 |
66 typedef GrGLGeometryProcessor INHERITED; | 65 typedef GrGLSLGeometryProcessor INHERITED; |
67 }; | 66 }; |
68 | 67 |
69 GrGLConicEffect::GrGLConicEffect(const GrGeometryProcessor& processor) | 68 GrGLConicEffect::GrGLConicEffect(const GrGeometryProcessor& processor) |
70 : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor_ILLEGAL), fCoverage
Scale(0xff) { | 69 : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor_ILLEGAL), fCoverage
Scale(0xff) { |
71 const GrConicEffect& ce = processor.cast<GrConicEffect>(); | 70 const GrConicEffect& ce = processor.cast<GrConicEffect>(); |
72 fEdgeType = ce.getEdgeType(); | 71 fEdgeType = ce.getEdgeType(); |
73 } | 72 } |
74 | 73 |
75 void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { | 74 void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { |
76 GrGLSLGPBuilder* pb = args.fPB; | 75 GrGLSLGPBuilder* pb = args.fPB; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 | 180 |
182 ////////////////////////////////////////////////////////////////////////////// | 181 ////////////////////////////////////////////////////////////////////////////// |
183 | 182 |
184 GrConicEffect::~GrConicEffect() {} | 183 GrConicEffect::~GrConicEffect() {} |
185 | 184 |
186 void GrConicEffect::getGLProcessorKey(const GrGLSLCaps& caps, | 185 void GrConicEffect::getGLProcessorKey(const GrGLSLCaps& caps, |
187 GrProcessorKeyBuilder* b) const { | 186 GrProcessorKeyBuilder* b) const { |
188 GrGLConicEffect::GenKey(*this, caps, b); | 187 GrGLConicEffect::GenKey(*this, caps, b); |
189 } | 188 } |
190 | 189 |
191 GrGLPrimitiveProcessor* GrConicEffect::createGLInstance(const GrGLSLCaps&) const
{ | 190 GrGLSLPrimitiveProcessor* GrConicEffect::createGLInstance(const GrGLSLCaps&) con
st { |
192 return new GrGLConicEffect(*this); | 191 return new GrGLConicEffect(*this); |
193 } | 192 } |
194 | 193 |
195 GrConicEffect::GrConicEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t
coverage, | 194 GrConicEffect::GrConicEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t
coverage, |
196 GrPrimitiveEdgeType edgeType, const SkMatrix& local
Matrix, | 195 GrPrimitiveEdgeType edgeType, const SkMatrix& local
Matrix, |
197 bool usesLocalCoords) | 196 bool usesLocalCoords) |
198 : fColor(color) | 197 : fColor(color) |
199 , fViewMatrix(viewMatrix) | 198 , fViewMatrix(viewMatrix) |
200 , fLocalMatrix(viewMatrix) | 199 , fLocalMatrix(viewMatrix) |
201 , fUsesLocalCoords(usesLocalCoords) | 200 , fUsesLocalCoords(usesLocalCoords) |
(...skipping 20 matching lines...) Expand all Loading... |
222 edgeType, *d->fCaps, | 221 edgeType, *d->fCaps, |
223 GrTest::TestMatrix(d->fRandom), d->fRandom->n
extBool()); | 222 GrTest::TestMatrix(d->fRandom), d->fRandom->n
extBool()); |
224 } while (nullptr == gp); | 223 } while (nullptr == gp); |
225 return gp; | 224 return gp; |
226 } | 225 } |
227 | 226 |
228 ////////////////////////////////////////////////////////////////////////////// | 227 ////////////////////////////////////////////////////////////////////////////// |
229 // Quad | 228 // Quad |
230 ////////////////////////////////////////////////////////////////////////////// | 229 ////////////////////////////////////////////////////////////////////////////// |
231 | 230 |
232 class GrGLQuadEffect : public GrGLGeometryProcessor { | 231 class GrGLQuadEffect : public GrGLSLGeometryProcessor { |
233 public: | 232 public: |
234 GrGLQuadEffect(const GrGeometryProcessor&); | 233 GrGLQuadEffect(const GrGeometryProcessor&); |
235 | 234 |
236 void onEmitCode(EmitArgs&, GrGPArgs*) override; | 235 void onEmitCode(EmitArgs&, GrGPArgs*) override; |
237 | 236 |
238 static inline void GenKey(const GrGeometryProcessor&, | 237 static inline void GenKey(const GrGeometryProcessor&, |
239 const GrGLSLCaps&, | 238 const GrGLSLCaps&, |
240 GrProcessorKeyBuilder*); | 239 GrProcessorKeyBuilder*); |
241 | 240 |
242 void setData(const GrGLSLProgramDataManager& pdman, | 241 void setData(const GrGLSLProgramDataManager& pdman, |
(...skipping 29 matching lines...) Expand all Loading... |
272 | 271 |
273 private: | 272 private: |
274 SkMatrix fViewMatrix; | 273 SkMatrix fViewMatrix; |
275 GrColor fColor; | 274 GrColor fColor; |
276 uint8_t fCoverageScale; | 275 uint8_t fCoverageScale; |
277 GrPrimitiveEdgeType fEdgeType; | 276 GrPrimitiveEdgeType fEdgeType; |
278 UniformHandle fColorUniform; | 277 UniformHandle fColorUniform; |
279 UniformHandle fCoverageScaleUniform; | 278 UniformHandle fCoverageScaleUniform; |
280 UniformHandle fViewMatrixUniform; | 279 UniformHandle fViewMatrixUniform; |
281 | 280 |
282 typedef GrGLGeometryProcessor INHERITED; | 281 typedef GrGLSLGeometryProcessor INHERITED; |
283 }; | 282 }; |
284 | 283 |
285 GrGLQuadEffect::GrGLQuadEffect(const GrGeometryProcessor& processor) | 284 GrGLQuadEffect::GrGLQuadEffect(const GrGeometryProcessor& processor) |
286 : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor_ILLEGAL), fCoverage
Scale(0xff) { | 285 : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor_ILLEGAL), fCoverage
Scale(0xff) { |
287 const GrQuadEffect& ce = processor.cast<GrQuadEffect>(); | 286 const GrQuadEffect& ce = processor.cast<GrQuadEffect>(); |
288 fEdgeType = ce.getEdgeType(); | 287 fEdgeType = ce.getEdgeType(); |
289 } | 288 } |
290 | 289 |
291 void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { | 290 void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { |
292 GrGLSLGPBuilder* pb = args.fPB; | 291 GrGLSLGPBuilder* pb = args.fPB; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 | 381 |
383 ////////////////////////////////////////////////////////////////////////////// | 382 ////////////////////////////////////////////////////////////////////////////// |
384 | 383 |
385 GrQuadEffect::~GrQuadEffect() {} | 384 GrQuadEffect::~GrQuadEffect() {} |
386 | 385 |
387 void GrQuadEffect::getGLProcessorKey(const GrGLSLCaps& caps, | 386 void GrQuadEffect::getGLProcessorKey(const GrGLSLCaps& caps, |
388 GrProcessorKeyBuilder* b) const { | 387 GrProcessorKeyBuilder* b) const { |
389 GrGLQuadEffect::GenKey(*this, caps, b); | 388 GrGLQuadEffect::GenKey(*this, caps, b); |
390 } | 389 } |
391 | 390 |
392 GrGLPrimitiveProcessor* GrQuadEffect::createGLInstance(const GrGLSLCaps&) const
{ | 391 GrGLSLPrimitiveProcessor* GrQuadEffect::createGLInstance(const GrGLSLCaps&) cons
t { |
393 return new GrGLQuadEffect(*this); | 392 return new GrGLQuadEffect(*this); |
394 } | 393 } |
395 | 394 |
396 GrQuadEffect::GrQuadEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t co
verage, | 395 GrQuadEffect::GrQuadEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t co
verage, |
397 GrPrimitiveEdgeType edgeType, const SkMatrix& localMa
trix, | 396 GrPrimitiveEdgeType edgeType, const SkMatrix& localMa
trix, |
398 bool usesLocalCoords) | 397 bool usesLocalCoords) |
399 : fColor(color) | 398 : fColor(color) |
400 , fViewMatrix(viewMatrix) | 399 , fViewMatrix(viewMatrix) |
401 , fLocalMatrix(localMatrix) | 400 , fLocalMatrix(localMatrix) |
402 , fUsesLocalCoords(usesLocalCoords) | 401 , fUsesLocalCoords(usesLocalCoords) |
(...skipping 21 matching lines...) Expand all Loading... |
424 GrTest::TestMatrix(d->fRandom), | 423 GrTest::TestMatrix(d->fRandom), |
425 d->fRandom->nextBool()); | 424 d->fRandom->nextBool()); |
426 } while (nullptr == gp); | 425 } while (nullptr == gp); |
427 return gp; | 426 return gp; |
428 } | 427 } |
429 | 428 |
430 ////////////////////////////////////////////////////////////////////////////// | 429 ////////////////////////////////////////////////////////////////////////////// |
431 // Cubic | 430 // Cubic |
432 ////////////////////////////////////////////////////////////////////////////// | 431 ////////////////////////////////////////////////////////////////////////////// |
433 | 432 |
434 class GrGLCubicEffect : public GrGLGeometryProcessor { | 433 class GrGLCubicEffect : public GrGLSLGeometryProcessor { |
435 public: | 434 public: |
436 GrGLCubicEffect(const GrGeometryProcessor&); | 435 GrGLCubicEffect(const GrGeometryProcessor&); |
437 | 436 |
438 void onEmitCode(EmitArgs&, GrGPArgs*) override; | 437 void onEmitCode(EmitArgs&, GrGPArgs*) override; |
439 | 438 |
440 static inline void GenKey(const GrGeometryProcessor&, | 439 static inline void GenKey(const GrGeometryProcessor&, |
441 const GrGLSLCaps&, | 440 const GrGLSLCaps&, |
442 GrProcessorKeyBuilder*); | 441 GrProcessorKeyBuilder*); |
443 | 442 |
444 void setData(const GrGLSLProgramDataManager& pdman, | 443 void setData(const GrGLSLProgramDataManager& pdman, |
(...skipping 15 matching lines...) Expand all Loading... |
460 } | 459 } |
461 } | 460 } |
462 | 461 |
463 private: | 462 private: |
464 SkMatrix fViewMatrix; | 463 SkMatrix fViewMatrix; |
465 GrColor fColor; | 464 GrColor fColor; |
466 GrPrimitiveEdgeType fEdgeType; | 465 GrPrimitiveEdgeType fEdgeType; |
467 UniformHandle fColorUniform; | 466 UniformHandle fColorUniform; |
468 UniformHandle fViewMatrixUniform; | 467 UniformHandle fViewMatrixUniform; |
469 | 468 |
470 typedef GrGLGeometryProcessor INHERITED; | 469 typedef GrGLSLGeometryProcessor INHERITED; |
471 }; | 470 }; |
472 | 471 |
473 GrGLCubicEffect::GrGLCubicEffect(const GrGeometryProcessor& processor) | 472 GrGLCubicEffect::GrGLCubicEffect(const GrGeometryProcessor& processor) |
474 : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor_ILLEGAL) { | 473 : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor_ILLEGAL) { |
475 const GrCubicEffect& ce = processor.cast<GrCubicEffect>(); | 474 const GrCubicEffect& ce = processor.cast<GrCubicEffect>(); |
476 fEdgeType = ce.getEdgeType(); | 475 fEdgeType = ce.getEdgeType(); |
477 } | 476 } |
478 | 477 |
479 void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { | 478 void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { |
480 GrGLSLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 479 GrGLSLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 } | 597 } |
599 | 598 |
600 ////////////////////////////////////////////////////////////////////////////// | 599 ////////////////////////////////////////////////////////////////////////////// |
601 | 600 |
602 GrCubicEffect::~GrCubicEffect() {} | 601 GrCubicEffect::~GrCubicEffect() {} |
603 | 602 |
604 void GrCubicEffect::getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuil
der* b) const { | 603 void GrCubicEffect::getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuil
der* b) const { |
605 GrGLCubicEffect::GenKey(*this, caps, b); | 604 GrGLCubicEffect::GenKey(*this, caps, b); |
606 } | 605 } |
607 | 606 |
608 GrGLPrimitiveProcessor* GrCubicEffect::createGLInstance(const GrGLSLCaps&) const
{ | 607 GrGLSLPrimitiveProcessor* GrCubicEffect::createGLInstance(const GrGLSLCaps&) con
st { |
609 return new GrGLCubicEffect(*this); | 608 return new GrGLCubicEffect(*this); |
610 } | 609 } |
611 | 610 |
612 GrCubicEffect::GrCubicEffect(GrColor color, const SkMatrix& viewMatrix, | 611 GrCubicEffect::GrCubicEffect(GrColor color, const SkMatrix& viewMatrix, |
613 GrPrimitiveEdgeType edgeType) | 612 GrPrimitiveEdgeType edgeType) |
614 : fColor(color) | 613 : fColor(color) |
615 , fViewMatrix(viewMatrix) | 614 , fViewMatrix(viewMatrix) |
616 , fEdgeType(edgeType) { | 615 , fEdgeType(edgeType) { |
617 this->initClassID<GrCubicEffect>(); | 616 this->initClassID<GrCubicEffect>(); |
618 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType, | 617 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType, |
(...skipping 11 matching lines...) Expand all Loading... |
630 do { | 629 do { |
631 GrPrimitiveEdgeType edgeType = | 630 GrPrimitiveEdgeType edgeType = |
632 static_cast<GrPrimitiveEdgeType>( | 631 static_cast<GrPrimitiveEdgeType>( |
633 d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt)); | 632 d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt)); |
634 gp = GrCubicEffect::Create(GrRandomColor(d->fRandom), | 633 gp = GrCubicEffect::Create(GrRandomColor(d->fRandom), |
635 GrTest::TestMatrix(d->fRandom), edgeType, *d-
>fCaps); | 634 GrTest::TestMatrix(d->fRandom), edgeType, *d-
>fCaps); |
636 } while (nullptr == gp); | 635 } while (nullptr == gp); |
637 return gp; | 636 return gp; |
638 } | 637 } |
639 | 638 |
OLD | NEW |