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/GrGLProcessor.h" | 10 #include "gl/GrGLProcessor.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 void GrConicEffect::getGLProcessorKey(const GrBatchTracker& bt, | 132 void GrConicEffect::getGLProcessorKey(const GrBatchTracker& bt, |
133 const GrGLCaps& caps, | 133 const GrGLCaps& caps, |
134 GrProcessorKeyBuilder* b) const { | 134 GrProcessorKeyBuilder* b) const { |
135 GrGLConicEffect::GenKey(*this, bt, caps, b); | 135 GrGLConicEffect::GenKey(*this, bt, caps, b); |
136 } | 136 } |
137 | 137 |
138 GrGLGeometryProcessor* GrConicEffect::createGLInstance(const GrBatchTracker& bt)
const { | 138 GrGLGeometryProcessor* GrConicEffect::createGLInstance(const GrBatchTracker& bt)
const { |
139 return SkNEW_ARGS(GrGLConicEffect, (*this, bt)); | 139 return SkNEW_ARGS(GrGLConicEffect, (*this, bt)); |
140 } | 140 } |
141 | 141 |
142 GrConicEffect::GrConicEffect(GrPrimitiveEdgeType edgeType) | 142 GrConicEffect::GrConicEffect(GrColor color, uint8_t coverage, GrPrimitiveEdgeTyp
e edgeType) |
143 : fEdgeType(edgeType) { | 143 : INHERITED(color, coverage), fEdgeType(edgeType) { |
144 this->initClassID<GrConicEffect>(); | 144 this->initClassID<GrConicEffect>(); |
145 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert
exAttribType)); | 145 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert
exAttribType)); |
146 fInConicCoeffs = &this->addVertexAttrib(GrAttribute("inConicCoeffs", | 146 fInConicCoeffs = &this->addVertexAttrib(GrAttribute("inConicCoeffs", |
147 kVec4f_GrVertexAttribTyp
e)); | 147 kVec4f_GrVertexAttribTyp
e)); |
148 } | 148 } |
149 | 149 |
150 bool GrConicEffect::onIsEqual(const GrGeometryProcessor& other) const { | 150 bool GrConicEffect::onIsEqual(const GrGeometryProcessor& other) const { |
151 const GrConicEffect& ce = other.cast<GrConicEffect>(); | 151 const GrConicEffect& ce = other.cast<GrConicEffect>(); |
152 return (ce.fEdgeType == fEdgeType); | 152 return (ce.fEdgeType == fEdgeType); |
153 } | 153 } |
154 | 154 |
155 ////////////////////////////////////////////////////////////////////////////// | 155 ////////////////////////////////////////////////////////////////////////////// |
156 | 156 |
157 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrConicEffect); | 157 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrConicEffect); |
158 | 158 |
159 GrGeometryProcessor* GrConicEffect::TestCreate(SkRandom* random, | 159 GrGeometryProcessor* GrConicEffect::TestCreate(SkRandom* random, |
160 GrContext*, | 160 GrContext*, |
161 const GrDrawTargetCaps& caps, | 161 const GrDrawTargetCaps& caps, |
162 GrTexture*[]) { | 162 GrTexture*[]) { |
163 GrGeometryProcessor* gp; | 163 GrGeometryProcessor* gp; |
164 do { | 164 do { |
165 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( | 165 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( |
166 random->nextULessThan(kGrPro
cessorEdgeTypeCnt)); | 166 random->nextULessThan(kGrPro
cessorEdgeTypeCnt)); |
167 gp = GrConicEffect::Create(edgeType, caps); | 167 gp = GrConicEffect::Create(GrRandomColor(random), edgeType, caps); |
168 } while (NULL == gp); | 168 } while (NULL == gp); |
169 return gp; | 169 return gp; |
170 } | 170 } |
171 | 171 |
172 ////////////////////////////////////////////////////////////////////////////// | 172 ////////////////////////////////////////////////////////////////////////////// |
173 // Quad | 173 // Quad |
174 ////////////////////////////////////////////////////////////////////////////// | 174 ////////////////////////////////////////////////////////////////////////////// |
175 | 175 |
176 class GrGLQuadEffect : public GrGLGeometryProcessor { | 176 class GrGLQuadEffect : public GrGLGeometryProcessor { |
177 public: | 177 public: |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 void GrQuadEffect::getGLProcessorKey(const GrBatchTracker& bt, | 279 void GrQuadEffect::getGLProcessorKey(const GrBatchTracker& bt, |
280 const GrGLCaps& caps, | 280 const GrGLCaps& caps, |
281 GrProcessorKeyBuilder* b) const { | 281 GrProcessorKeyBuilder* b) const { |
282 GrGLQuadEffect::GenKey(*this, bt, caps, b); | 282 GrGLQuadEffect::GenKey(*this, bt, caps, b); |
283 } | 283 } |
284 | 284 |
285 GrGLGeometryProcessor* GrQuadEffect::createGLInstance(const GrBatchTracker& bt)
const { | 285 GrGLGeometryProcessor* GrQuadEffect::createGLInstance(const GrBatchTracker& bt)
const { |
286 return SkNEW_ARGS(GrGLQuadEffect, (*this, bt)); | 286 return SkNEW_ARGS(GrGLQuadEffect, (*this, bt)); |
287 } | 287 } |
288 | 288 |
289 GrQuadEffect::GrQuadEffect(GrPrimitiveEdgeType edgeType) | 289 GrQuadEffect::GrQuadEffect(GrColor color, uint8_t coverage, GrPrimitiveEdgeType
edgeType) |
290 : fEdgeType(edgeType) { | 290 : INHERITED(color, coverage), fEdgeType(edgeType) { |
291 this->initClassID<GrQuadEffect>(); | 291 this->initClassID<GrQuadEffect>(); |
292 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert
exAttribType)); | 292 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert
exAttribType)); |
293 fInHairQuadEdge = &this->addVertexAttrib(GrAttribute("inHairQuadEdge", | 293 fInHairQuadEdge = &this->addVertexAttrib(GrAttribute("inHairQuadEdge", |
294 kVec4f_GrVertexAttribTyp
e)); | 294 kVec4f_GrVertexAttribTyp
e)); |
295 } | 295 } |
296 | 296 |
297 bool GrQuadEffect::onIsEqual(const GrGeometryProcessor& other) const { | 297 bool GrQuadEffect::onIsEqual(const GrGeometryProcessor& other) const { |
298 const GrQuadEffect& ce = other.cast<GrQuadEffect>(); | 298 const GrQuadEffect& ce = other.cast<GrQuadEffect>(); |
299 return (ce.fEdgeType == fEdgeType); | 299 return (ce.fEdgeType == fEdgeType); |
300 } | 300 } |
301 | 301 |
302 ////////////////////////////////////////////////////////////////////////////// | 302 ////////////////////////////////////////////////////////////////////////////// |
303 | 303 |
304 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrQuadEffect); | 304 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrQuadEffect); |
305 | 305 |
306 GrGeometryProcessor* GrQuadEffect::TestCreate(SkRandom* random, | 306 GrGeometryProcessor* GrQuadEffect::TestCreate(SkRandom* random, |
307 GrContext*, | 307 GrContext*, |
308 const GrDrawTargetCaps& caps, | 308 const GrDrawTargetCaps& caps, |
309 GrTexture*[]) { | 309 GrTexture*[]) { |
310 GrGeometryProcessor* gp; | 310 GrGeometryProcessor* gp; |
311 do { | 311 do { |
312 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( | 312 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( |
313 random->nextULessThan(kGrProcessorEdgeTypeCnt)); | 313 random->nextULessThan(kGrProcessorEdgeTypeCnt)); |
314 gp = GrQuadEffect::Create(edgeType, caps); | 314 gp = GrQuadEffect::Create(GrRandomColor(random), edgeType, caps); |
315 } while (NULL == gp); | 315 } while (NULL == gp); |
316 return gp; | 316 return gp; |
317 } | 317 } |
318 | 318 |
319 ////////////////////////////////////////////////////////////////////////////// | 319 ////////////////////////////////////////////////////////////////////////////// |
320 // Cubic | 320 // Cubic |
321 ////////////////////////////////////////////////////////////////////////////// | 321 ////////////////////////////////////////////////////////////////////////////// |
322 | 322 |
323 class GrGLCubicEffect : public GrGLGeometryProcessor { | 323 class GrGLCubicEffect : public GrGLGeometryProcessor { |
324 public: | 324 public: |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 void GrCubicEffect::getGLProcessorKey(const GrBatchTracker& bt, | 467 void GrCubicEffect::getGLProcessorKey(const GrBatchTracker& bt, |
468 const GrGLCaps& caps, | 468 const GrGLCaps& caps, |
469 GrProcessorKeyBuilder* b) const { | 469 GrProcessorKeyBuilder* b) const { |
470 GrGLCubicEffect::GenKey(*this, bt, caps, b); | 470 GrGLCubicEffect::GenKey(*this, bt, caps, b); |
471 } | 471 } |
472 | 472 |
473 GrGLGeometryProcessor* GrCubicEffect::createGLInstance(const GrBatchTracker& bt)
const { | 473 GrGLGeometryProcessor* GrCubicEffect::createGLInstance(const GrBatchTracker& bt)
const { |
474 return SkNEW_ARGS(GrGLCubicEffect, (*this, bt)); | 474 return SkNEW_ARGS(GrGLCubicEffect, (*this, bt)); |
475 } | 475 } |
476 | 476 |
477 GrCubicEffect::GrCubicEffect(GrPrimitiveEdgeType edgeType) | 477 GrCubicEffect::GrCubicEffect(GrColor color, GrPrimitiveEdgeType edgeType) |
478 : fEdgeType(edgeType) { | 478 : INHERITED(color), fEdgeType(edgeType) { |
479 this->initClassID<GrCubicEffect>(); | 479 this->initClassID<GrCubicEffect>(); |
480 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert
exAttribType)); | 480 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert
exAttribType)); |
481 fInCubicCoeffs = &this->addVertexAttrib(GrAttribute("inCubicCoeffs", | 481 fInCubicCoeffs = &this->addVertexAttrib(GrAttribute("inCubicCoeffs", |
482 kVec4f_GrVertexAttribTyp
e)); | 482 kVec4f_GrVertexAttribTyp
e)); |
483 } | 483 } |
484 | 484 |
485 bool GrCubicEffect::onIsEqual(const GrGeometryProcessor& other) const { | 485 bool GrCubicEffect::onIsEqual(const GrGeometryProcessor& other) const { |
486 const GrCubicEffect& ce = other.cast<GrCubicEffect>(); | 486 const GrCubicEffect& ce = other.cast<GrCubicEffect>(); |
487 return (ce.fEdgeType == fEdgeType); | 487 return (ce.fEdgeType == fEdgeType); |
488 } | 488 } |
489 | 489 |
490 ////////////////////////////////////////////////////////////////////////////// | 490 ////////////////////////////////////////////////////////////////////////////// |
491 | 491 |
492 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrCubicEffect); | 492 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrCubicEffect); |
493 | 493 |
494 GrGeometryProcessor* GrCubicEffect::TestCreate(SkRandom* random, | 494 GrGeometryProcessor* GrCubicEffect::TestCreate(SkRandom* random, |
495 GrContext*, | 495 GrContext*, |
496 const GrDrawTargetCaps& caps, | 496 const GrDrawTargetCaps& caps, |
497 GrTexture*[]) { | 497 GrTexture*[]) { |
498 GrGeometryProcessor* gp; | 498 GrGeometryProcessor* gp; |
499 do { | 499 do { |
500 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( | 500 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( |
501 random->nextULessThan(kGrPro
cessorEdgeTypeCnt)); | 501 random->nextULessThan(kGrPro
cessorEdgeTypeCnt)); |
502 gp = GrCubicEffect::Create(edgeType, caps); | 502 gp = GrCubicEffect::Create(GrRandomColor(random), edgeType, caps); |
503 } while (NULL == gp); | 503 } while (NULL == gp); |
504 return gp; | 504 return gp; |
505 } | 505 } |
506 | 506 |
OLD | NEW |