| 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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 | 259 |
| 260 bool GrDrawState::validateVertexAttribs() const { | 260 bool GrDrawState::validateVertexAttribs() const { |
| 261 // check consistency of effects and attributes | 261 // check consistency of effects and attributes |
| 262 GrSLType slTypes[kMaxVertexAttribCnt]; | 262 GrSLType slTypes[kMaxVertexAttribCnt]; |
| 263 for (int i = 0; i < kMaxVertexAttribCnt; ++i) { | 263 for (int i = 0; i < kMaxVertexAttribCnt; ++i) { |
| 264 slTypes[i] = static_cast<GrSLType>(-1); | 264 slTypes[i] = static_cast<GrSLType>(-1); |
| 265 } | 265 } |
| 266 | 266 |
| 267 if (this->hasGeometryProcessor()) { | 267 if (this->hasGeometryProcessor()) { |
| 268 const GrGeometryStage& stage = *this->getGeometryProcessor(); | 268 const GrGeometryStage& stage = *this->getGeometryProcessor(); |
| 269 const GrGeometryProcessor* gp = stage.getProcessor(); | 269 const GrGeometryProcessor* gp = stage.getGeometryProcessor(); |
| 270 SkASSERT(gp); | 270 SkASSERT(gp); |
| 271 // make sure that any attribute indices have the correct binding type, t
hat the attrib | 271 // make sure that any attribute indices have the correct binding type, t
hat the attrib |
| 272 // type and effect's shader lang type are compatible, and that attribute
s shared by | 272 // type and effect's shader lang type are compatible, and that attribute
s shared by |
| 273 // multiple effects use the same shader lang type. | 273 // multiple effects use the same shader lang type. |
| 274 const GrGeometryProcessor::VertexAttribArray& s = gp->getVertexAttribs()
; | 274 const GrGeometryProcessor::VertexAttribArray& s = gp->getVertexAttribs()
; |
| 275 | 275 |
| 276 int effectIndex = 0; | 276 int effectIndex = 0; |
| 277 for (int index = 0; index < fVACount; index++) { | 277 for (int index = 0; index < fVACount; index++) { |
| 278 if (kGeometryProcessor_GrVertexAttribBinding != fVAPtr[index].fBindi
ng) { | 278 if (kGeometryProcessor_GrVertexAttribBinding != fVAPtr[index].fBindi
ng) { |
| 279 // we only care about effect bindings | 279 // we only care about effect bindings |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 // Initialize to an unknown starting coverage if per-vertex coverage is spec
ified. | 403 // Initialize to an unknown starting coverage if per-vertex coverage is spec
ified. |
| 404 if (this->hasCoverageVertexAttribute()) { | 404 if (this->hasCoverageVertexAttribute()) { |
| 405 inout.fValidFlags = 0; | 405 inout.fValidFlags = 0; |
| 406 } else { | 406 } else { |
| 407 inout.fColor = fCoverage; | 407 inout.fColor = fCoverage; |
| 408 inout.fValidFlags = kRGBA_GrColorComponentFlags; | 408 inout.fValidFlags = kRGBA_GrColorComponentFlags; |
| 409 } | 409 } |
| 410 | 410 |
| 411 // Run through the coverage stages and see if the coverage will be all ones
at the end. | 411 // Run through the coverage stages and see if the coverage will be all ones
at the end. |
| 412 if (this->hasGeometryProcessor()) { | 412 if (this->hasGeometryProcessor()) { |
| 413 const GrGeometryProcessor* gp = fGeometryProcessor->getProcessor(); | 413 const GrGeometryProcessor* gp = fGeometryProcessor->getGeometryProcessor
(); |
| 414 gp->computeInvariantOutput(&inout); | 414 gp->computeInvariantOutput(&inout); |
| 415 } | 415 } |
| 416 for (int s = 0; s < this->numCoverageStages(); ++s) { | 416 for (int s = 0; s < this->numCoverageStages(); ++s) { |
| 417 const GrProcessor* processor = this->getCoverageStage(s).getProcessor(); | 417 const GrProcessor* processor = this->getCoverageStage(s).getProcessor(); |
| 418 processor->computeInvariantOutput(&inout); | 418 processor->computeInvariantOutput(&inout); |
| 419 } | 419 } |
| 420 return inout.isSolidWhite(); | 420 return inout.isSolidWhite(); |
| 421 } | 421 } |
| 422 | 422 |
| 423 ////////////////////////////////////////////////////////////////////////////// | 423 ////////////////////////////////////////////////////////////////////////////// |
| 424 | 424 |
| 425 GrDrawState::AutoVertexAttribRestore::AutoVertexAttribRestore(GrDrawState* drawS
tate) { | 425 GrDrawState::AutoVertexAttribRestore::AutoVertexAttribRestore(GrDrawState* drawS
tate) { |
| 426 SkASSERT(drawState); | 426 SkASSERT(drawState); |
| 427 fDrawState = drawState; | 427 fDrawState = drawState; |
| 428 fVAPtr = drawState->fVAPtr; | 428 fVAPtr = drawState->fVAPtr; |
| 429 fVACount = drawState->fVACount; | 429 fVACount = drawState->fVACount; |
| 430 fVAStride = drawState->fVAStride; | 430 fVAStride = drawState->fVAStride; |
| 431 fDrawState->setDefaultVertexAttribs(); | 431 fDrawState->setDefaultVertexAttribs(); |
| 432 } | 432 } |
| 433 | 433 |
| 434 //////////////////////////////////////////////////////////////////////////////s | 434 //////////////////////////////////////////////////////////////////////////////s |
| 435 | 435 |
| 436 bool GrDrawState::willEffectReadDstColor() const { | 436 bool GrDrawState::willEffectReadDstColor() const { |
| 437 if (!this->isColorWriteDisabled()) { | 437 if (!this->isColorWriteDisabled()) { |
| 438 for (int s = 0; s < this->numColorStages(); ++s) { | 438 for (int s = 0; s < this->numColorStages(); ++s) { |
| 439 if (this->getColorStage(s).getProcessor()->willReadDstColor()) { | 439 if (this->getColorStage(s).getFragmentProcessor()->willReadDstColor(
)) { |
| 440 return true; | 440 return true; |
| 441 } | 441 } |
| 442 } | 442 } |
| 443 } | 443 } |
| 444 for (int s = 0; s < this->numCoverageStages(); ++s) { | 444 for (int s = 0; s < this->numCoverageStages(); ++s) { |
| 445 if (this->getCoverageStage(s).getProcessor()->willReadDstColor()) { | 445 if (this->getCoverageStage(s).getFragmentProcessor()->willReadDstColor()
) { |
| 446 return true; | 446 return true; |
| 447 } | 447 } |
| 448 } | 448 } |
| 449 return false; | 449 return false; |
| 450 } | 450 } |
| 451 | 451 |
| 452 void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) { | 452 void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) { |
| 453 if (fDrawState) { | 453 if (fDrawState) { |
| 454 // See the big comment on the class definition about GPs. | 454 // See the big comment on the class definition about GPs. |
| 455 if (SK_InvalidUniqueID == fOriginalGPID) { | 455 if (SK_InvalidUniqueID == fOriginalGPID) { |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 } | 776 } |
| 777 | 777 |
| 778 // Since the shader will multiply coverage and color, the only way the f
inal A==1 is if | 778 // Since the shader will multiply coverage and color, the only way the f
inal A==1 is if |
| 779 // coverage and color both have A==1. | 779 // coverage and color both have A==1. |
| 780 return (inoutColor.isOpaque() && inoutCoverage.isOpaque()); | 780 return (inoutColor.isOpaque() && inoutCoverage.isOpaque()); |
| 781 } | 781 } |
| 782 | 782 |
| 783 return inoutColor.isOpaque(); | 783 return inoutColor.isOpaque(); |
| 784 } | 784 } |
| 785 | 785 |
| OLD | NEW |