Chromium Code Reviews| 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/GrGLFragmentProcessor.h" | 10 #include "gl/GrGLFragmentProcessor.h" |
| 11 #include "gl/GrGLGeometryProcessor.h" | 11 #include "gl/GrGLGeometryProcessor.h" |
| 12 #include "gl/builders/GrGLProgramBuilder.h" | 12 #include "gl/builders/GrGLProgramBuilder.h" |
| 13 | 13 |
| 14 class GrGLConicEffect : public GrGLGeometryProcessor { | 14 class GrGLConicEffect : public GrGLGeometryProcessor { |
| 15 public: | 15 public: |
| 16 GrGLConicEffect(const GrGeometryProcessor&, | 16 GrGLConicEffect(const GrGeometryProcessor&); |
| 17 const GrBatchTracker&); | |
| 18 | 17 |
| 19 void onEmitCode(EmitArgs&, GrGPArgs*) override; | 18 void onEmitCode(EmitArgs&, GrGPArgs*) override; |
| 20 | 19 |
| 21 static inline void GenKey(const GrGeometryProcessor&, | 20 static inline void GenKey(const GrGeometryProcessor&, |
| 22 const GrBatchTracker&, | |
| 23 const GrGLSLCaps&, | 21 const GrGLSLCaps&, |
| 24 GrProcessorKeyBuilder*); | 22 GrProcessorKeyBuilder*); |
| 25 | 23 |
| 26 virtual void setData(const GrGLProgramDataManager& pdman, | 24 virtual void setData(const GrGLProgramDataManager& pdman, |
|
bsalomon
2015/09/10 18:55:31
-virtual?
joshualitt
2015/09/10 20:08:05
Acknowledged.
| |
| 27 const GrPrimitiveProcessor& primProc, | 25 const GrPrimitiveProcessor& primProc) override { |
| 28 const GrBatchTracker& bt) override { | |
| 29 const GrConicEffect& ce = primProc.cast<GrConicEffect>(); | 26 const GrConicEffect& ce = primProc.cast<GrConicEffect>(); |
| 30 | 27 |
| 31 if (!ce.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(ce.viewMa trix())) { | 28 if (!ce.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(ce.viewMa trix())) { |
| 32 fViewMatrix = ce.viewMatrix(); | 29 fViewMatrix = ce.viewMatrix(); |
| 33 GrGLfloat viewMatrix[3 * 3]; | 30 GrGLfloat viewMatrix[3 * 3]; |
| 34 GrGLGetMatrix<3>(viewMatrix, fViewMatrix); | 31 GrGLGetMatrix<3>(viewMatrix, fViewMatrix); |
| 35 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); | 32 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); |
| 36 } | 33 } |
| 37 | 34 |
| 38 if (ce.color() != fColor) { | 35 if (ce.color() != fColor) { |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 60 GrColor fColor; | 57 GrColor fColor; |
| 61 uint8_t fCoverageScale; | 58 uint8_t fCoverageScale; |
| 62 GrPrimitiveEdgeType fEdgeType; | 59 GrPrimitiveEdgeType fEdgeType; |
| 63 UniformHandle fColorUniform; | 60 UniformHandle fColorUniform; |
| 64 UniformHandle fCoverageScaleUniform; | 61 UniformHandle fCoverageScaleUniform; |
| 65 UniformHandle fViewMatrixUniform; | 62 UniformHandle fViewMatrixUniform; |
| 66 | 63 |
| 67 typedef GrGLGeometryProcessor INHERITED; | 64 typedef GrGLGeometryProcessor INHERITED; |
| 68 }; | 65 }; |
| 69 | 66 |
| 70 GrGLConicEffect::GrGLConicEffect(const GrGeometryProcessor& processor, | 67 GrGLConicEffect::GrGLConicEffect(const GrGeometryProcessor& processor) |
| 71 const GrBatchTracker& bt) | |
| 72 : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor_ILLEGAL), fCoverage Scale(0xff) { | 68 : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor_ILLEGAL), fCoverage Scale(0xff) { |
| 73 const GrConicEffect& ce = processor.cast<GrConicEffect>(); | 69 const GrConicEffect& ce = processor.cast<GrConicEffect>(); |
| 74 fEdgeType = ce.getEdgeType(); | 70 fEdgeType = ce.getEdgeType(); |
| 75 } | 71 } |
| 76 | 72 |
| 77 void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { | 73 void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { |
| 78 GrGLGPBuilder* pb = args.fPB; | 74 GrGLGPBuilder* pb = args.fPB; |
| 79 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 75 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
| 80 const GrConicEffect& gp = args.fGP.cast<GrConicEffect>(); | 76 const GrConicEffect& gp = args.fGP.cast<GrConicEffect>(); |
| 81 | 77 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 kDefault_GrSLPrecision, | 159 kDefault_GrSLPrecision, |
| 164 "Coverage", | 160 "Coverage", |
| 165 &coverageScale); | 161 &coverageScale); |
| 166 fsBuilder->codeAppendf("%s = vec4(%s * edgeAlpha);", args.fOutputCoverag e, coverageScale); | 162 fsBuilder->codeAppendf("%s = vec4(%s * edgeAlpha);", args.fOutputCoverag e, coverageScale); |
| 167 } else { | 163 } else { |
| 168 fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage); | 164 fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage); |
| 169 } | 165 } |
| 170 } | 166 } |
| 171 | 167 |
| 172 void GrGLConicEffect::GenKey(const GrGeometryProcessor& gp, | 168 void GrGLConicEffect::GenKey(const GrGeometryProcessor& gp, |
| 173 const GrBatchTracker& bt, | |
| 174 const GrGLSLCaps&, | 169 const GrGLSLCaps&, |
| 175 GrProcessorKeyBuilder* b) { | 170 GrProcessorKeyBuilder* b) { |
| 176 const GrConicEffect& ce = gp.cast<GrConicEffect>(); | 171 const GrConicEffect& ce = gp.cast<GrConicEffect>(); |
| 177 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; | 172 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; |
| 178 key |= GrColor_ILLEGAL != ce.color() ? 0x4 : 0x0; | 173 key |= GrColor_ILLEGAL != ce.color() ? 0x4 : 0x0; |
| 179 key |= 0xff != ce.coverageScale() ? 0x8 : 0x0; | 174 key |= 0xff != ce.coverageScale() ? 0x8 : 0x0; |
| 180 key |= ce.usesLocalCoords() && ce.localMatrix().hasPerspective() ? 0x10 : 0x 0; | 175 key |= ce.usesLocalCoords() && ce.localMatrix().hasPerspective() ? 0x10 : 0x 0; |
| 181 key |= ComputePosKey(ce.viewMatrix()) << 5; | 176 key |= ComputePosKey(ce.viewMatrix()) << 5; |
| 182 b->add32(key); | 177 b->add32(key); |
| 183 } | 178 } |
| 184 | 179 |
| 185 ////////////////////////////////////////////////////////////////////////////// | 180 ////////////////////////////////////////////////////////////////////////////// |
| 186 | 181 |
| 187 GrConicEffect::~GrConicEffect() {} | 182 GrConicEffect::~GrConicEffect() {} |
| 188 | 183 |
| 189 void GrConicEffect::getGLProcessorKey(const GrBatchTracker& bt, | 184 void GrConicEffect::getGLProcessorKey(const GrGLSLCaps& caps, |
| 190 const GrGLSLCaps& caps, | |
| 191 GrProcessorKeyBuilder* b) const { | 185 GrProcessorKeyBuilder* b) const { |
| 192 GrGLConicEffect::GenKey(*this, bt, caps, b); | 186 GrGLConicEffect::GenKey(*this, caps, b); |
| 193 } | 187 } |
| 194 | 188 |
| 195 GrGLPrimitiveProcessor* GrConicEffect::createGLInstance(const GrBatchTracker& bt , | 189 GrGLPrimitiveProcessor* GrConicEffect::createGLInstance(const GrGLSLCaps&) const { |
| 196 const GrGLSLCaps&) const { | 190 return new GrGLConicEffect(*this); |
| 197 return new GrGLConicEffect(*this, bt); | |
| 198 } | 191 } |
| 199 | 192 |
| 200 GrConicEffect::GrConicEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t coverage, | 193 GrConicEffect::GrConicEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t coverage, |
| 201 GrPrimitiveEdgeType edgeType, const SkMatrix& local Matrix, | 194 GrPrimitiveEdgeType edgeType, const SkMatrix& local Matrix, |
| 202 bool usesLocalCoords) | 195 bool usesLocalCoords) |
| 203 : fColor(color) | 196 : fColor(color) |
| 204 , fViewMatrix(viewMatrix) | 197 , fViewMatrix(viewMatrix) |
| 205 , fLocalMatrix(viewMatrix) | 198 , fLocalMatrix(viewMatrix) |
| 206 , fUsesLocalCoords(usesLocalCoords) | 199 , fUsesLocalCoords(usesLocalCoords) |
| 207 , fCoverageScale(coverage) | 200 , fCoverageScale(coverage) |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 229 } while (nullptr == gp); | 222 } while (nullptr == gp); |
| 230 return gp; | 223 return gp; |
| 231 } | 224 } |
| 232 | 225 |
| 233 ////////////////////////////////////////////////////////////////////////////// | 226 ////////////////////////////////////////////////////////////////////////////// |
| 234 // Quad | 227 // Quad |
| 235 ////////////////////////////////////////////////////////////////////////////// | 228 ////////////////////////////////////////////////////////////////////////////// |
| 236 | 229 |
| 237 class GrGLQuadEffect : public GrGLGeometryProcessor { | 230 class GrGLQuadEffect : public GrGLGeometryProcessor { |
| 238 public: | 231 public: |
| 239 GrGLQuadEffect(const GrGeometryProcessor&, | 232 GrGLQuadEffect(const GrGeometryProcessor&); |
| 240 const GrBatchTracker&); | |
| 241 | 233 |
| 242 void onEmitCode(EmitArgs&, GrGPArgs*) override; | 234 void onEmitCode(EmitArgs&, GrGPArgs*) override; |
| 243 | 235 |
| 244 static inline void GenKey(const GrGeometryProcessor&, | 236 static inline void GenKey(const GrGeometryProcessor&, |
| 245 const GrBatchTracker&, | |
| 246 const GrGLSLCaps&, | 237 const GrGLSLCaps&, |
| 247 GrProcessorKeyBuilder*); | 238 GrProcessorKeyBuilder*); |
| 248 | 239 |
| 249 virtual void setData(const GrGLProgramDataManager& pdman, | 240 virtual void setData(const GrGLProgramDataManager& pdman, |
|
bsalomon
2015/09/10 18:55:31
-virtual?
joshualitt
2015/09/10 20:08:05
Acknowledged.
| |
| 250 const GrPrimitiveProcessor& primProc, | 241 const GrPrimitiveProcessor& primProc) override { |
| 251 const GrBatchTracker& bt) override { | |
| 252 const GrQuadEffect& qe = primProc.cast<GrQuadEffect>(); | 242 const GrQuadEffect& qe = primProc.cast<GrQuadEffect>(); |
| 253 | 243 |
| 254 if (!qe.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(qe.viewMa trix())) { | 244 if (!qe.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(qe.viewMa trix())) { |
| 255 fViewMatrix = qe.viewMatrix(); | 245 fViewMatrix = qe.viewMatrix(); |
| 256 GrGLfloat viewMatrix[3 * 3]; | 246 GrGLfloat viewMatrix[3 * 3]; |
| 257 GrGLGetMatrix<3>(viewMatrix, fViewMatrix); | 247 GrGLGetMatrix<3>(viewMatrix, fViewMatrix); |
| 258 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); | 248 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); |
| 259 } | 249 } |
| 260 | 250 |
| 261 if (qe.color() != fColor) { | 251 if (qe.color() != fColor) { |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 283 GrColor fColor; | 273 GrColor fColor; |
| 284 uint8_t fCoverageScale; | 274 uint8_t fCoverageScale; |
| 285 GrPrimitiveEdgeType fEdgeType; | 275 GrPrimitiveEdgeType fEdgeType; |
| 286 UniformHandle fColorUniform; | 276 UniformHandle fColorUniform; |
| 287 UniformHandle fCoverageScaleUniform; | 277 UniformHandle fCoverageScaleUniform; |
| 288 UniformHandle fViewMatrixUniform; | 278 UniformHandle fViewMatrixUniform; |
| 289 | 279 |
| 290 typedef GrGLGeometryProcessor INHERITED; | 280 typedef GrGLGeometryProcessor INHERITED; |
| 291 }; | 281 }; |
| 292 | 282 |
| 293 GrGLQuadEffect::GrGLQuadEffect(const GrGeometryProcessor& processor, | 283 GrGLQuadEffect::GrGLQuadEffect(const GrGeometryProcessor& processor) |
| 294 const GrBatchTracker& bt) | |
| 295 : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor_ILLEGAL), fCoverage Scale(0xff) { | 284 : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor_ILLEGAL), fCoverage Scale(0xff) { |
| 296 const GrQuadEffect& ce = processor.cast<GrQuadEffect>(); | 285 const GrQuadEffect& ce = processor.cast<GrQuadEffect>(); |
| 297 fEdgeType = ce.getEdgeType(); | 286 fEdgeType = ce.getEdgeType(); |
| 298 } | 287 } |
| 299 | 288 |
| 300 void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { | 289 void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { |
| 301 GrGLGPBuilder* pb = args.fPB; | 290 GrGLGPBuilder* pb = args.fPB; |
| 302 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 291 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
| 303 const GrQuadEffect& gp = args.fGP.cast<GrQuadEffect>(); | 292 const GrQuadEffect& gp = args.fGP.cast<GrQuadEffect>(); |
| 304 | 293 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 371 kDefault_GrSLPrecision, | 360 kDefault_GrSLPrecision, |
| 372 "Coverage", | 361 "Coverage", |
| 373 &coverageScale); | 362 &coverageScale); |
| 374 fsBuilder->codeAppendf("%s = vec4(%s * edgeAlpha);", args.fOutputCoverag e, coverageScale); | 363 fsBuilder->codeAppendf("%s = vec4(%s * edgeAlpha);", args.fOutputCoverag e, coverageScale); |
| 375 } else { | 364 } else { |
| 376 fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage); | 365 fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage); |
| 377 } | 366 } |
| 378 } | 367 } |
| 379 | 368 |
| 380 void GrGLQuadEffect::GenKey(const GrGeometryProcessor& gp, | 369 void GrGLQuadEffect::GenKey(const GrGeometryProcessor& gp, |
| 381 const GrBatchTracker& bt, | |
| 382 const GrGLSLCaps&, | 370 const GrGLSLCaps&, |
| 383 GrProcessorKeyBuilder* b) { | 371 GrProcessorKeyBuilder* b) { |
| 384 const GrQuadEffect& ce = gp.cast<GrQuadEffect>(); | 372 const GrQuadEffect& ce = gp.cast<GrQuadEffect>(); |
| 385 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; | 373 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; |
| 386 key |= ce.color() != GrColor_ILLEGAL ? 0x4 : 0x0; | 374 key |= ce.color() != GrColor_ILLEGAL ? 0x4 : 0x0; |
| 387 key |= ce.coverageScale() != 0xff ? 0x8 : 0x0; | 375 key |= ce.coverageScale() != 0xff ? 0x8 : 0x0; |
| 388 key |= ce.usesLocalCoords() && ce.localMatrix().hasPerspective() ? 0x10 : 0x 0; | 376 key |= ce.usesLocalCoords() && ce.localMatrix().hasPerspective() ? 0x10 : 0x 0; |
| 389 key |= ComputePosKey(ce.viewMatrix()) << 5; | 377 key |= ComputePosKey(ce.viewMatrix()) << 5; |
| 390 b->add32(key); | 378 b->add32(key); |
| 391 } | 379 } |
| 392 | 380 |
| 393 ////////////////////////////////////////////////////////////////////////////// | 381 ////////////////////////////////////////////////////////////////////////////// |
| 394 | 382 |
| 395 GrQuadEffect::~GrQuadEffect() {} | 383 GrQuadEffect::~GrQuadEffect() {} |
| 396 | 384 |
| 397 void GrQuadEffect::getGLProcessorKey(const GrBatchTracker& bt, | 385 void GrQuadEffect::getGLProcessorKey(const GrGLSLCaps& caps, |
| 398 const GrGLSLCaps& caps, | |
| 399 GrProcessorKeyBuilder* b) const { | 386 GrProcessorKeyBuilder* b) const { |
| 400 GrGLQuadEffect::GenKey(*this, bt, caps, b); | 387 GrGLQuadEffect::GenKey(*this, caps, b); |
| 401 } | 388 } |
| 402 | 389 |
| 403 GrGLPrimitiveProcessor* GrQuadEffect::createGLInstance(const GrBatchTracker& bt, | 390 GrGLPrimitiveProcessor* GrQuadEffect::createGLInstance(const GrGLSLCaps&) const { |
| 404 const GrGLSLCaps&) const { | 391 return new GrGLQuadEffect(*this); |
| 405 return new GrGLQuadEffect(*this, bt); | |
| 406 } | 392 } |
| 407 | 393 |
| 408 GrQuadEffect::GrQuadEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t co verage, | 394 GrQuadEffect::GrQuadEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t co verage, |
| 409 GrPrimitiveEdgeType edgeType, const SkMatrix& localMa trix, | 395 GrPrimitiveEdgeType edgeType, const SkMatrix& localMa trix, |
| 410 bool usesLocalCoords) | 396 bool usesLocalCoords) |
| 411 : fColor(color) | 397 : fColor(color) |
| 412 , fViewMatrix(viewMatrix) | 398 , fViewMatrix(viewMatrix) |
| 413 , fLocalMatrix(localMatrix) | 399 , fLocalMatrix(localMatrix) |
| 414 , fUsesLocalCoords(usesLocalCoords) | 400 , fUsesLocalCoords(usesLocalCoords) |
| 415 , fCoverageScale(coverage) | 401 , fCoverageScale(coverage) |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 438 } while (nullptr == gp); | 424 } while (nullptr == gp); |
| 439 return gp; | 425 return gp; |
| 440 } | 426 } |
| 441 | 427 |
| 442 ////////////////////////////////////////////////////////////////////////////// | 428 ////////////////////////////////////////////////////////////////////////////// |
| 443 // Cubic | 429 // Cubic |
| 444 ////////////////////////////////////////////////////////////////////////////// | 430 ////////////////////////////////////////////////////////////////////////////// |
| 445 | 431 |
| 446 class GrGLCubicEffect : public GrGLGeometryProcessor { | 432 class GrGLCubicEffect : public GrGLGeometryProcessor { |
| 447 public: | 433 public: |
| 448 GrGLCubicEffect(const GrGeometryProcessor&, | 434 GrGLCubicEffect(const GrGeometryProcessor&); |
| 449 const GrBatchTracker&); | |
| 450 | 435 |
| 451 void onEmitCode(EmitArgs&, GrGPArgs*) override; | 436 void onEmitCode(EmitArgs&, GrGPArgs*) override; |
| 452 | 437 |
| 453 static inline void GenKey(const GrGeometryProcessor&, | 438 static inline void GenKey(const GrGeometryProcessor&, |
| 454 const GrBatchTracker&, | |
| 455 const GrGLSLCaps&, | 439 const GrGLSLCaps&, |
| 456 GrProcessorKeyBuilder*); | 440 GrProcessorKeyBuilder*); |
| 457 | 441 |
| 458 virtual void setData(const GrGLProgramDataManager& pdman, | 442 virtual void setData(const GrGLProgramDataManager& pdman, |
| 459 const GrPrimitiveProcessor& primProc, | 443 const GrPrimitiveProcessor& primProc) override { |
|
bsalomon
2015/09/10 18:55:31
-virtual?
joshualitt
2015/09/10 20:08:05
Acknowledged.
| |
| 460 const GrBatchTracker& bt) override { | |
| 461 const GrCubicEffect& ce = primProc.cast<GrCubicEffect>(); | 444 const GrCubicEffect& ce = primProc.cast<GrCubicEffect>(); |
| 462 | 445 |
| 463 if (!ce.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(ce.viewMa trix())) { | 446 if (!ce.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(ce.viewMa trix())) { |
| 464 fViewMatrix = ce.viewMatrix(); | 447 fViewMatrix = ce.viewMatrix(); |
| 465 GrGLfloat viewMatrix[3 * 3]; | 448 GrGLfloat viewMatrix[3 * 3]; |
| 466 GrGLGetMatrix<3>(viewMatrix, fViewMatrix); | 449 GrGLGetMatrix<3>(viewMatrix, fViewMatrix); |
| 467 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); | 450 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); |
| 468 } | 451 } |
| 469 | 452 |
| 470 if (ce.color() != fColor) { | 453 if (ce.color() != fColor) { |
| 471 GrGLfloat c[4]; | 454 GrGLfloat c[4]; |
| 472 GrColorToRGBAFloat(ce.color(), c); | 455 GrColorToRGBAFloat(ce.color(), c); |
| 473 pdman.set4fv(fColorUniform, 1, c); | 456 pdman.set4fv(fColorUniform, 1, c); |
| 474 fColor = ce.color(); | 457 fColor = ce.color(); |
| 475 } | 458 } |
| 476 } | 459 } |
| 477 | 460 |
| 478 private: | 461 private: |
| 479 SkMatrix fViewMatrix; | 462 SkMatrix fViewMatrix; |
| 480 GrColor fColor; | 463 GrColor fColor; |
| 481 GrPrimitiveEdgeType fEdgeType; | 464 GrPrimitiveEdgeType fEdgeType; |
| 482 UniformHandle fColorUniform; | 465 UniformHandle fColorUniform; |
| 483 UniformHandle fViewMatrixUniform; | 466 UniformHandle fViewMatrixUniform; |
| 484 | 467 |
| 485 typedef GrGLGeometryProcessor INHERITED; | 468 typedef GrGLGeometryProcessor INHERITED; |
| 486 }; | 469 }; |
| 487 | 470 |
| 488 GrGLCubicEffect::GrGLCubicEffect(const GrGeometryProcessor& processor, | 471 GrGLCubicEffect::GrGLCubicEffect(const GrGeometryProcessor& processor) |
| 489 const GrBatchTracker&) | |
| 490 : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor_ILLEGAL) { | 472 : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor_ILLEGAL) { |
| 491 const GrCubicEffect& ce = processor.cast<GrCubicEffect>(); | 473 const GrCubicEffect& ce = processor.cast<GrCubicEffect>(); |
| 492 fEdgeType = ce.getEdgeType(); | 474 fEdgeType = ce.getEdgeType(); |
| 493 } | 475 } |
| 494 | 476 |
| 495 void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { | 477 void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { |
| 496 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 478 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
| 497 const GrCubicEffect& gp = args.fGP.cast<GrCubicEffect>(); | 479 const GrCubicEffect& gp = args.fGP.cast<GrCubicEffect>(); |
| 498 | 480 |
| 499 // emit attributes | 481 // emit attributes |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 597 } | 579 } |
| 598 default: | 580 default: |
| 599 SkFAIL("Shouldn't get here"); | 581 SkFAIL("Shouldn't get here"); |
| 600 } | 582 } |
| 601 | 583 |
| 602 | 584 |
| 603 fsBuilder->codeAppendf("%s = vec4(%s);", args.fOutputCoverage, edgeAlpha.c_s tr()); | 585 fsBuilder->codeAppendf("%s = vec4(%s);", args.fOutputCoverage, edgeAlpha.c_s tr()); |
| 604 } | 586 } |
| 605 | 587 |
| 606 void GrGLCubicEffect::GenKey(const GrGeometryProcessor& gp, | 588 void GrGLCubicEffect::GenKey(const GrGeometryProcessor& gp, |
| 607 const GrBatchTracker& bt, | |
| 608 const GrGLSLCaps&, | 589 const GrGLSLCaps&, |
| 609 GrProcessorKeyBuilder* b) { | 590 GrProcessorKeyBuilder* b) { |
| 610 const GrCubicEffect& ce = gp.cast<GrCubicEffect>(); | 591 const GrCubicEffect& ce = gp.cast<GrCubicEffect>(); |
| 611 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; | 592 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; |
| 612 key |= ce.color() != GrColor_ILLEGAL ? 0x4 : 0x8; | 593 key |= ce.color() != GrColor_ILLEGAL ? 0x4 : 0x8; |
| 613 key |= ComputePosKey(ce.viewMatrix()) << 5; | 594 key |= ComputePosKey(ce.viewMatrix()) << 5; |
| 614 b->add32(key); | 595 b->add32(key); |
| 615 } | 596 } |
| 616 | 597 |
| 617 ////////////////////////////////////////////////////////////////////////////// | 598 ////////////////////////////////////////////////////////////////////////////// |
| 618 | 599 |
| 619 GrCubicEffect::~GrCubicEffect() {} | 600 GrCubicEffect::~GrCubicEffect() {} |
| 620 | 601 |
| 621 void GrCubicEffect::getGLProcessorKey(const GrBatchTracker& bt, | 602 void GrCubicEffect::getGLProcessorKey(const GrGLSLCaps& caps, |
|
bsalomon
2015/09/10 18:55:31
one line?
joshualitt
2015/09/10 20:08:05
Acknowledged.
| |
| 622 const GrGLSLCaps& caps, | |
| 623 GrProcessorKeyBuilder* b) const { | 603 GrProcessorKeyBuilder* b) const { |
| 624 GrGLCubicEffect::GenKey(*this, bt, caps, b); | 604 GrGLCubicEffect::GenKey(*this, caps, b); |
| 625 } | 605 } |
| 626 | 606 |
| 627 GrGLPrimitiveProcessor* GrCubicEffect::createGLInstance(const GrBatchTracker& bt , | 607 GrGLPrimitiveProcessor* GrCubicEffect::createGLInstance(const GrGLSLCaps&) const { |
| 628 const GrGLSLCaps&) const { | 608 return new GrGLCubicEffect(*this); |
| 629 return new GrGLCubicEffect(*this, bt); | |
| 630 } | 609 } |
| 631 | 610 |
| 632 GrCubicEffect::GrCubicEffect(GrColor color, const SkMatrix& viewMatrix, | 611 GrCubicEffect::GrCubicEffect(GrColor color, const SkMatrix& viewMatrix, |
| 633 GrPrimitiveEdgeType edgeType) | 612 GrPrimitiveEdgeType edgeType) |
| 634 : fColor(color) | 613 : fColor(color) |
| 635 , fViewMatrix(viewMatrix) | 614 , fViewMatrix(viewMatrix) |
| 636 , fEdgeType(edgeType) { | 615 , fEdgeType(edgeType) { |
| 637 this->initClassID<GrCubicEffect>(); | 616 this->initClassID<GrCubicEffect>(); |
| 638 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType, | 617 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertex AttribType, |
| 639 kHigh_GrSLPrecision)); | 618 kHigh_GrSLPrecision)); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 650 do { | 629 do { |
| 651 GrPrimitiveEdgeType edgeType = | 630 GrPrimitiveEdgeType edgeType = |
| 652 static_cast<GrPrimitiveEdgeType>( | 631 static_cast<GrPrimitiveEdgeType>( |
| 653 d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt)); | 632 d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt)); |
| 654 gp = GrCubicEffect::Create(GrRandomColor(d->fRandom), | 633 gp = GrCubicEffect::Create(GrRandomColor(d->fRandom), |
| 655 GrTest::TestMatrix(d->fRandom), edgeType, *d- >fCaps); | 634 GrTest::TestMatrix(d->fRandom), edgeType, *d- >fCaps); |
| 656 } while (nullptr == gp); | 635 } while (nullptr == gp); |
| 657 return gp; | 636 return gp; |
| 658 } | 637 } |
| 659 | 638 |
| OLD | NEW |