OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "GrDrawState.h" | 8 #include "GrDrawState.h" |
9 | 9 |
10 #include "GrOptDrawState.h" | 10 #include "GrOptDrawState.h" |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 | 282 |
283 bool GrDrawState::validateVertexAttribs() const { | 283 bool GrDrawState::validateVertexAttribs() const { |
284 // check consistency of effects and attributes | 284 // check consistency of effects and attributes |
285 GrSLType slTypes[kMaxVertexAttribCnt]; | 285 GrSLType slTypes[kMaxVertexAttribCnt]; |
286 for (int i = 0; i < kMaxVertexAttribCnt; ++i) { | 286 for (int i = 0; i < kMaxVertexAttribCnt; ++i) { |
287 slTypes[i] = static_cast<GrSLType>(-1); | 287 slTypes[i] = static_cast<GrSLType>(-1); |
288 } | 288 } |
289 | 289 |
290 if (this->hasGeometryProcessor()) { | 290 if (this->hasGeometryProcessor()) { |
291 const GrGeometryStage& stage = *this->getGeometryProcessor(); | 291 const GrGeometryStage& stage = *this->getGeometryProcessor(); |
292 const GrGeometryProcessor* gp = stage.getGeometryProcessor(); | 292 const GrGeometryProcessor* gp = stage.getProcessor(); |
293 SkASSERT(gp); | 293 SkASSERT(gp); |
294 // make sure that any attribute indices have the correct binding type, t
hat the attrib | 294 // make sure that any attribute indices have the correct binding type, t
hat the attrib |
295 // type and effect's shader lang type are compatible, and that attribute
s shared by | 295 // type and effect's shader lang type are compatible, and that attribute
s shared by |
296 // multiple effects use the same shader lang type. | 296 // multiple effects use the same shader lang type. |
297 const GrGeometryProcessor::VertexAttribArray& s = gp->getVertexAttribs()
; | 297 const GrGeometryProcessor::VertexAttribArray& s = gp->getVertexAttribs()
; |
298 | 298 |
299 int effectIndex = 0; | 299 int effectIndex = 0; |
300 for (int index = 0; index < fVACount; index++) { | 300 for (int index = 0; index < fVACount; index++) { |
301 if (kGeometryProcessor_GrVertexAttribBinding != fVAPtr[index].fBindi
ng) { | 301 if (kGeometryProcessor_GrVertexAttribBinding != fVAPtr[index].fBindi
ng) { |
302 // we only care about effect bindings | 302 // we only care about effect bindings |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 // Initialize to an unknown starting coverage if per-vertex coverage is spec
ified. | 426 // Initialize to an unknown starting coverage if per-vertex coverage is spec
ified. |
427 if (this->hasCoverageVertexAttribute()) { | 427 if (this->hasCoverageVertexAttribute()) { |
428 validComponentFlags = 0; | 428 validComponentFlags = 0; |
429 } else { | 429 } else { |
430 coverage = fCoverage; | 430 coverage = fCoverage; |
431 validComponentFlags = kRGBA_GrColorComponentFlags; | 431 validComponentFlags = kRGBA_GrColorComponentFlags; |
432 } | 432 } |
433 | 433 |
434 // Run through the coverage stages and see if the coverage will be all ones
at the end. | 434 // Run through the coverage stages and see if the coverage will be all ones
at the end. |
435 if (this->hasGeometryProcessor()) { | 435 if (this->hasGeometryProcessor()) { |
436 const GrGeometryProcessor* gp = fGeometryProcessor->getGeometryProcessor
(); | 436 const GrGeometryProcessor* gp = fGeometryProcessor->getProcessor(); |
437 gp->getConstantColorComponents(&coverage, &validComponentFlags); | 437 gp->getConstantColorComponents(&coverage, &validComponentFlags); |
438 } | 438 } |
439 for (int s = 0; s < this->numCoverageStages(); ++s) { | 439 for (int s = 0; s < this->numCoverageStages(); ++s) { |
440 const GrProcessor* processor = this->getCoverageStage(s).getProcessor(); | 440 const GrProcessor* processor = this->getCoverageStage(s).getProcessor(); |
441 processor->getConstantColorComponents(&coverage, &validComponentFlags); | 441 processor->getConstantColorComponents(&coverage, &validComponentFlags); |
442 } | 442 } |
443 return (kRGBA_GrColorComponentFlags == validComponentFlags) && (0xffffffff =
= coverage); | 443 return (kRGBA_GrColorComponentFlags == validComponentFlags) && (0xffffffff =
= coverage); |
444 } | 444 } |
445 | 445 |
446 ////////////////////////////////////////////////////////////////////////////// | 446 ////////////////////////////////////////////////////////////////////////////// |
447 | 447 |
448 GrDrawState::AutoVertexAttribRestore::AutoVertexAttribRestore(GrDrawState* drawS
tate) { | 448 GrDrawState::AutoVertexAttribRestore::AutoVertexAttribRestore(GrDrawState* drawS
tate) { |
449 SkASSERT(drawState); | 449 SkASSERT(drawState); |
450 fDrawState = drawState; | 450 fDrawState = drawState; |
451 fVAPtr = drawState->fVAPtr; | 451 fVAPtr = drawState->fVAPtr; |
452 fVACount = drawState->fVACount; | 452 fVACount = drawState->fVACount; |
453 fVAStride = drawState->fVAStride; | 453 fVAStride = drawState->fVAStride; |
454 fDrawState->setDefaultVertexAttribs(); | 454 fDrawState->setDefaultVertexAttribs(); |
455 } | 455 } |
456 | 456 |
457 //////////////////////////////////////////////////////////////////////////////s | 457 //////////////////////////////////////////////////////////////////////////////s |
458 | 458 |
459 bool GrDrawState::willEffectReadDstColor() const { | 459 bool GrDrawState::willEffectReadDstColor() const { |
460 if (!this->isColorWriteDisabled()) { | 460 if (!this->isColorWriteDisabled()) { |
461 for (int s = 0; s < this->numColorStages(); ++s) { | 461 for (int s = 0; s < this->numColorStages(); ++s) { |
462 if (this->getColorStage(s).getFragmentProcessor()->willReadDstColor(
)) { | 462 if (this->getColorStage(s).getProcessor()->willReadDstColor()) { |
463 return true; | 463 return true; |
464 } | 464 } |
465 } | 465 } |
466 } | 466 } |
467 for (int s = 0; s < this->numCoverageStages(); ++s) { | 467 for (int s = 0; s < this->numCoverageStages(); ++s) { |
468 if (this->getCoverageStage(s).getFragmentProcessor()->willReadDstColor()
) { | 468 if (this->getCoverageStage(s).getProcessor()->willReadDstColor()) { |
469 return true; | 469 return true; |
470 } | 470 } |
471 } | 471 } |
472 return false; | 472 return false; |
473 } | 473 } |
474 | 474 |
475 void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) { | 475 void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) { |
476 if (fDrawState) { | 476 if (fDrawState) { |
477 // See the big comment on the class definition about GPs. | 477 // See the big comment on the class definition about GPs. |
478 if (SK_InvalidUniqueID == fOriginalGPID) { | 478 if (SK_InvalidUniqueID == fOriginalGPID) { |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 // Since the shader will multiply coverage and color, the only way the f
inal A==1 is if | 800 // Since the shader will multiply coverage and color, the only way the f
inal A==1 is if |
801 // coverage and color both have A==1. | 801 // coverage and color both have A==1. |
802 return (kA_GrColorComponentFlag & validComponentFlags & coverageComponen
tFlags) && | 802 return (kA_GrColorComponentFlag & validComponentFlags & coverageComponen
tFlags) && |
803 0xFF == GrColorUnpackA(color) && 0xFF == GrColorUnpackA(coverage
); | 803 0xFF == GrColorUnpackA(color) && 0xFF == GrColorUnpackA(coverage
); |
804 | 804 |
805 } | 805 } |
806 | 806 |
807 return (kA_GrColorComponentFlag & validComponentFlags) && 0xFF == GrColorUnp
ackA(color); | 807 return (kA_GrColorComponentFlag & validComponentFlags) && 0xFF == GrColorUnp
ackA(color); |
808 } | 808 } |
809 | 809 |
OLD | NEW |