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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 GrColorToRGBAFloat(local.fColor, c); | 43 GrColorToRGBAFloat(local.fColor, c); |
44 pdman.set4fv(fColorUniform, 1, c); | 44 pdman.set4fv(fColorUniform, 1, c); |
45 fColor = local.fColor; | 45 fColor = local.fColor; |
46 } | 46 } |
47 if (0xff != local.fCoverageScale && fCoverageScale != local.fCoverageSca
le) { | 47 if (0xff != local.fCoverageScale && fCoverageScale != local.fCoverageSca
le) { |
48 pdman.set1f(fCoverageScaleUniform, GrNormalizeByteToFloat(local.fCov
erageScale)); | 48 pdman.set1f(fCoverageScaleUniform, GrNormalizeByteToFloat(local.fCov
erageScale)); |
49 fCoverageScale = local.fCoverageScale; | 49 fCoverageScale = local.fCoverageScale; |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
| 53 void setTransformData(const GrPrimitiveProcessor& primProc, |
| 54 const GrGLProgramDataManager& pdman, |
| 55 int index, |
| 56 const SkTArray<const GrCoordTransform*, true>& transfo
rms) override { |
| 57 this->setTransformDataHelper<GrConicEffect>(primProc, pdman, index, tran
sforms); |
| 58 } |
| 59 |
53 private: | 60 private: |
54 GrColor fColor; | 61 GrColor fColor; |
55 uint8_t fCoverageScale; | 62 uint8_t fCoverageScale; |
56 GrPrimitiveEdgeType fEdgeType; | 63 GrPrimitiveEdgeType fEdgeType; |
57 UniformHandle fColorUniform; | 64 UniformHandle fColorUniform; |
58 UniformHandle fCoverageScaleUniform; | 65 UniformHandle fCoverageScaleUniform; |
59 | 66 |
60 typedef GrGLGeometryProcessor INHERITED; | 67 typedef GrGLGeometryProcessor INHERITED; |
61 }; | 68 }; |
62 | 69 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 170 |
164 void GrGLConicEffect::GenKey(const GrGeometryProcessor& gp, | 171 void GrGLConicEffect::GenKey(const GrGeometryProcessor& gp, |
165 const GrBatchTracker& bt, | 172 const GrBatchTracker& bt, |
166 const GrGLSLCaps&, | 173 const GrGLSLCaps&, |
167 GrProcessorKeyBuilder* b) { | 174 GrProcessorKeyBuilder* b) { |
168 const GrConicEffect& ce = gp.cast<GrConicEffect>(); | 175 const GrConicEffect& ce = gp.cast<GrConicEffect>(); |
169 const ConicBatchTracker& local = bt.cast<ConicBatchTracker>(); | 176 const ConicBatchTracker& local = bt.cast<ConicBatchTracker>(); |
170 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; | 177 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; |
171 key |= kUniform_GrGPInput == local.fInputColorType ? 0x4 : 0x0; | 178 key |= kUniform_GrGPInput == local.fInputColorType ? 0x4 : 0x0; |
172 key |= 0xff != local.fCoverageScale ? 0x8 : 0x0; | 179 key |= 0xff != local.fCoverageScale ? 0x8 : 0x0; |
173 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x10 :
0x0; | 180 key |= local.fUsesLocalCoords && ce.localMatrix().hasPerspective() ? 0x10 :
0x0; |
174 key |= ComputePosKey(ce.viewMatrix()) << 5; | 181 key |= ComputePosKey(ce.viewMatrix()) << 5; |
175 b->add32(key); | 182 b->add32(key); |
176 } | 183 } |
177 | 184 |
178 ////////////////////////////////////////////////////////////////////////////// | 185 ////////////////////////////////////////////////////////////////////////////// |
179 | 186 |
180 GrConicEffect::~GrConicEffect() {} | 187 GrConicEffect::~GrConicEffect() {} |
181 | 188 |
182 void GrConicEffect::getGLProcessorKey(const GrBatchTracker& bt, | 189 void GrConicEffect::getGLProcessorKey(const GrBatchTracker& bt, |
183 const GrGLSLCaps& caps, | 190 const GrGLSLCaps& caps, |
184 GrProcessorKeyBuilder* b) const { | 191 GrProcessorKeyBuilder* b) const { |
185 GrGLConicEffect::GenKey(*this, bt, caps, b); | 192 GrGLConicEffect::GenKey(*this, bt, caps, b); |
186 } | 193 } |
187 | 194 |
188 GrGLPrimitiveProcessor* GrConicEffect::createGLInstance(const GrBatchTracker& bt
, | 195 GrGLPrimitiveProcessor* GrConicEffect::createGLInstance(const GrBatchTracker& bt
, |
189 const GrGLSLCaps&) const
{ | 196 const GrGLSLCaps&) const
{ |
190 return SkNEW_ARGS(GrGLConicEffect, (*this, bt)); | 197 return SkNEW_ARGS(GrGLConicEffect, (*this, bt)); |
191 } | 198 } |
192 | 199 |
193 GrConicEffect::GrConicEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t
coverage, | 200 GrConicEffect::GrConicEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t
coverage, |
194 GrPrimitiveEdgeType edgeType, const SkMatrix& local
Matrix) | 201 GrPrimitiveEdgeType edgeType, const SkMatrix& local
Matrix) |
195 : INHERITED(localMatrix) | 202 : fColor(color) |
196 , fColor(color) | |
197 , fViewMatrix(viewMatrix) | 203 , fViewMatrix(viewMatrix) |
| 204 , fLocalMatrix(viewMatrix) |
198 , fCoverageScale(coverage) | 205 , fCoverageScale(coverage) |
199 , fEdgeType(edgeType) { | 206 , fEdgeType(edgeType) { |
200 this->initClassID<GrConicEffect>(); | 207 this->initClassID<GrConicEffect>(); |
201 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); | 208 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); |
202 fInConicCoeffs = &this->addVertexAttrib(Attribute("inConicCoeffs", | 209 fInConicCoeffs = &this->addVertexAttrib(Attribute("inConicCoeffs", |
203 kVec4f_GrVertexAttribTyp
e)); | 210 kVec4f_GrVertexAttribTyp
e)); |
204 } | 211 } |
205 | 212 |
206 void GrConicEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& i
nit) const { | 213 void GrConicEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& i
nit) const { |
207 ConicBatchTracker* local = bt->cast<ConicBatchTracker>(); | 214 ConicBatchTracker* local = bt->cast<ConicBatchTracker>(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 GrColorToRGBAFloat(local.fColor, c); | 271 GrColorToRGBAFloat(local.fColor, c); |
265 pdman.set4fv(fColorUniform, 1, c); | 272 pdman.set4fv(fColorUniform, 1, c); |
266 fColor = local.fColor; | 273 fColor = local.fColor; |
267 } | 274 } |
268 if (0xff != local.fCoverageScale && local.fCoverageScale != fCoverageSca
le) { | 275 if (0xff != local.fCoverageScale && local.fCoverageScale != fCoverageSca
le) { |
269 pdman.set1f(fCoverageScaleUniform, GrNormalizeByteToFloat(local.fCov
erageScale)); | 276 pdman.set1f(fCoverageScaleUniform, GrNormalizeByteToFloat(local.fCov
erageScale)); |
270 fCoverageScale = local.fCoverageScale; | 277 fCoverageScale = local.fCoverageScale; |
271 } | 278 } |
272 } | 279 } |
273 | 280 |
| 281 void setTransformData(const GrPrimitiveProcessor& primProc, |
| 282 const GrGLProgramDataManager& pdman, |
| 283 int index, |
| 284 const SkTArray<const GrCoordTransform*, true>& transfo
rms) override { |
| 285 this->setTransformDataHelper<GrQuadEffect>(primProc, pdman, index, trans
forms); |
| 286 } |
| 287 |
274 private: | 288 private: |
275 GrColor fColor; | 289 GrColor fColor; |
276 uint8_t fCoverageScale; | 290 uint8_t fCoverageScale; |
277 GrPrimitiveEdgeType fEdgeType; | 291 GrPrimitiveEdgeType fEdgeType; |
278 UniformHandle fColorUniform; | 292 UniformHandle fColorUniform; |
279 UniformHandle fCoverageScaleUniform; | 293 UniformHandle fCoverageScaleUniform; |
280 | 294 |
281 typedef GrGLGeometryProcessor INHERITED; | 295 typedef GrGLGeometryProcessor INHERITED; |
282 }; | 296 }; |
283 | 297 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 | 384 |
371 void GrGLQuadEffect::GenKey(const GrGeometryProcessor& gp, | 385 void GrGLQuadEffect::GenKey(const GrGeometryProcessor& gp, |
372 const GrBatchTracker& bt, | 386 const GrBatchTracker& bt, |
373 const GrGLSLCaps&, | 387 const GrGLSLCaps&, |
374 GrProcessorKeyBuilder* b) { | 388 GrProcessorKeyBuilder* b) { |
375 const GrQuadEffect& ce = gp.cast<GrQuadEffect>(); | 389 const GrQuadEffect& ce = gp.cast<GrQuadEffect>(); |
376 const QuadBatchTracker& local = bt.cast<QuadBatchTracker>(); | 390 const QuadBatchTracker& local = bt.cast<QuadBatchTracker>(); |
377 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; | 391 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; |
378 key |= kUniform_GrGPInput == local.fInputColorType ? 0x4 : 0x0; | 392 key |= kUniform_GrGPInput == local.fInputColorType ? 0x4 : 0x0; |
379 key |= 0xff != local.fCoverageScale ? 0x8 : 0x0; | 393 key |= 0xff != local.fCoverageScale ? 0x8 : 0x0; |
380 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x10 :
0x0; | 394 key |= local.fUsesLocalCoords && ce.localMatrix().hasPerspective() ? 0x10 :
0x0; |
381 key |= ComputePosKey(ce.viewMatrix()) << 5; | 395 key |= ComputePosKey(ce.viewMatrix()) << 5; |
382 b->add32(key); | 396 b->add32(key); |
383 } | 397 } |
384 | 398 |
385 ////////////////////////////////////////////////////////////////////////////// | 399 ////////////////////////////////////////////////////////////////////////////// |
386 | 400 |
387 GrQuadEffect::~GrQuadEffect() {} | 401 GrQuadEffect::~GrQuadEffect() {} |
388 | 402 |
389 void GrQuadEffect::getGLProcessorKey(const GrBatchTracker& bt, | 403 void GrQuadEffect::getGLProcessorKey(const GrBatchTracker& bt, |
390 const GrGLSLCaps& caps, | 404 const GrGLSLCaps& caps, |
391 GrProcessorKeyBuilder* b) const { | 405 GrProcessorKeyBuilder* b) const { |
392 GrGLQuadEffect::GenKey(*this, bt, caps, b); | 406 GrGLQuadEffect::GenKey(*this, bt, caps, b); |
393 } | 407 } |
394 | 408 |
395 GrGLPrimitiveProcessor* GrQuadEffect::createGLInstance(const GrBatchTracker& bt, | 409 GrGLPrimitiveProcessor* GrQuadEffect::createGLInstance(const GrBatchTracker& bt, |
396 const GrGLSLCaps&) const
{ | 410 const GrGLSLCaps&) const
{ |
397 return SkNEW_ARGS(GrGLQuadEffect, (*this, bt)); | 411 return SkNEW_ARGS(GrGLQuadEffect, (*this, bt)); |
398 } | 412 } |
399 | 413 |
400 GrQuadEffect::GrQuadEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t co
verage, | 414 GrQuadEffect::GrQuadEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t co
verage, |
401 GrPrimitiveEdgeType edgeType, const SkMatrix& localMa
trix) | 415 GrPrimitiveEdgeType edgeType, const SkMatrix& localMa
trix) |
402 : INHERITED(localMatrix) | 416 : fColor(color) |
403 , fColor(color) | |
404 , fViewMatrix(viewMatrix) | 417 , fViewMatrix(viewMatrix) |
| 418 , fLocalMatrix(localMatrix) |
405 , fCoverageScale(coverage) | 419 , fCoverageScale(coverage) |
406 , fEdgeType(edgeType) { | 420 , fEdgeType(edgeType) { |
407 this->initClassID<GrQuadEffect>(); | 421 this->initClassID<GrQuadEffect>(); |
408 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); | 422 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex
AttribType)); |
409 fInHairQuadEdge = &this->addVertexAttrib(Attribute("inHairQuadEdge", | 423 fInHairQuadEdge = &this->addVertexAttrib(Attribute("inHairQuadEdge", |
410 kVec4f_GrVertexAttribTyp
e)); | 424 kVec4f_GrVertexAttribTyp
e)); |
411 } | 425 } |
412 | 426 |
413 void GrQuadEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& in
it) const { | 427 void GrQuadEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& in
it) const { |
414 QuadBatchTracker* local = bt->cast<QuadBatchTracker>(); | 428 QuadBatchTracker* local = bt->cast<QuadBatchTracker>(); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inCubicCoeffs()->fName); | 516 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inCubicCoeffs()->fName); |
503 | 517 |
504 // Setup pass through color | 518 // Setup pass through color |
505 this->setupColorPassThrough(args.fPB, local.fInputColorType, args.fOutputCol
or, NULL, | 519 this->setupColorPassThrough(args.fPB, local.fInputColorType, args.fOutputCol
or, NULL, |
506 &fColorUniform); | 520 &fColorUniform); |
507 | 521 |
508 // Setup position | 522 // Setup position |
509 this->setupPosition(args.fPB, gpArgs, gp.inPosition()->fName, gp.viewMatrix(
)); | 523 this->setupPosition(args.fPB, gpArgs, gp.inPosition()->fName, gp.viewMatrix(
)); |
510 | 524 |
511 // emit transforms with position | 525 // emit transforms with position |
512 this->emitTransforms(args.fPB, gpArgs->fPositionVar, gp.inPosition()->fName,
gp.localMatrix(), | 526 this->emitTransforms(args.fPB, gpArgs->fPositionVar, gp.inPosition()->fName,
args.fTransformsIn, |
513 args.fTransformsIn, args.fTransformsOut); | 527 args.fTransformsOut); |
514 | 528 |
515 GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 529 GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
516 | 530 |
517 GrGLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, kHigh_GrSLPrecision
); | 531 GrGLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, kHigh_GrSLPrecision
); |
518 GrGLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, kHigh_GrSLPrecision); | 532 GrGLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, kHigh_GrSLPrecision); |
519 GrGLShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, kHigh_GrSLPrecision); | 533 GrGLShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, kHigh_GrSLPrecision); |
520 GrGLShaderVar dfdx("dfdx", kFloat_GrSLType, 0, kHigh_GrSLPrecision); | 534 GrGLShaderVar dfdx("dfdx", kFloat_GrSLType, 0, kHigh_GrSLPrecision); |
521 GrGLShaderVar dfdy("dfdy", kFloat_GrSLType, 0, kHigh_GrSLPrecision); | 535 GrGLShaderVar dfdy("dfdy", kFloat_GrSLType, 0, kHigh_GrSLPrecision); |
522 GrGLShaderVar gF("gF", kVec2f_GrSLType, 0, kHigh_GrSLPrecision); | 536 GrGLShaderVar gF("gF", kVec2f_GrSLType, 0, kHigh_GrSLPrecision); |
523 GrGLShaderVar gFM("gFM", kFloat_GrSLType, 0, kHigh_GrSLPrecision); | 537 GrGLShaderVar gFM("gFM", kFloat_GrSLType, 0, kHigh_GrSLPrecision); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 } | 614 } |
601 | 615 |
602 void GrGLCubicEffect::GenKey(const GrGeometryProcessor& gp, | 616 void GrGLCubicEffect::GenKey(const GrGeometryProcessor& gp, |
603 const GrBatchTracker& bt, | 617 const GrBatchTracker& bt, |
604 const GrGLSLCaps&, | 618 const GrGLSLCaps&, |
605 GrProcessorKeyBuilder* b) { | 619 GrProcessorKeyBuilder* b) { |
606 const GrCubicEffect& ce = gp.cast<GrCubicEffect>(); | 620 const GrCubicEffect& ce = gp.cast<GrCubicEffect>(); |
607 const CubicBatchTracker& local = bt.cast<CubicBatchTracker>(); | 621 const CubicBatchTracker& local = bt.cast<CubicBatchTracker>(); |
608 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; | 622 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; |
609 key |= kUniform_GrGPInput == local.fInputColorType ? 0x4 : 0x8; | 623 key |= kUniform_GrGPInput == local.fInputColorType ? 0x4 : 0x8; |
610 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x10 :
0x0; | |
611 key |= ComputePosKey(ce.viewMatrix()) << 5; | 624 key |= ComputePosKey(ce.viewMatrix()) << 5; |
612 b->add32(key); | 625 b->add32(key); |
613 } | 626 } |
614 | 627 |
615 ////////////////////////////////////////////////////////////////////////////// | 628 ////////////////////////////////////////////////////////////////////////////// |
616 | 629 |
617 GrCubicEffect::~GrCubicEffect() {} | 630 GrCubicEffect::~GrCubicEffect() {} |
618 | 631 |
619 void GrCubicEffect::getGLProcessorKey(const GrBatchTracker& bt, | 632 void GrCubicEffect::getGLProcessorKey(const GrBatchTracker& bt, |
620 const GrGLSLCaps& caps, | 633 const GrGLSLCaps& caps, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 GrGeometryProcessor* gp; | 668 GrGeometryProcessor* gp; |
656 do { | 669 do { |
657 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( | 670 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( |
658 random->nextULessThan(kGrPro
cessorEdgeTypeCnt)); | 671 random->nextULessThan(kGrPro
cessorEdgeTypeCnt)); |
659 gp = GrCubicEffect::Create(GrRandomColor(random), | 672 gp = GrCubicEffect::Create(GrRandomColor(random), |
660 GrTest::TestMatrix(random), edgeType, caps); | 673 GrTest::TestMatrix(random), edgeType, caps); |
661 } while (NULL == gp); | 674 } while (NULL == gp); |
662 return gp; | 675 return gp; |
663 } | 676 } |
664 | 677 |
OLD | NEW |