Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: src/gpu/GrDrawState.cpp

Issue 699023003: remove separate color from coverage (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrDrawState.h ('k') | src/gpu/GrOptDrawState.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 fBlendConstant = 0x0; 178 fBlendConstant = 0x0;
179 fFlagBits = 0x0; 179 fFlagBits = 0x0;
180 fStencilSettings.setDisabled(); 180 fStencilSettings.setDisabled();
181 fCoverage = 0xff; 181 fCoverage = 0xff;
182 fDrawFace = kBoth_DrawFace; 182 fDrawFace = kBoth_DrawFace;
183 183
184 fHints = 0; 184 fHints = 0;
185 } 185 }
186 186
187 bool GrDrawState::setIdentityViewMatrix() { 187 bool GrDrawState::setIdentityViewMatrix() {
188 if (this->numTotalStages()) { 188 if (this->numFragmentStages()) {
189 SkMatrix invVM; 189 SkMatrix invVM;
190 if (!fViewMatrix.invert(&invVM)) { 190 if (!fViewMatrix.invert(&invVM)) {
191 // sad trombone sound 191 // sad trombone sound
192 return false; 192 return false;
193 } 193 }
194 for (int s = 0; s < this->numColorStages(); ++s) { 194 for (int s = 0; s < this->numColorStages(); ++s) {
195 fColorStages[s].localCoordChange(invVM); 195 fColorStages[s].localCoordChange(invVM);
196 } 196 }
197 for (int s = 0; s < this->numCoverageStages(); ++s) { 197 for (int s = 0; s < this->numCoverageStages(); ++s) {
198 fCoverageStages[s].localCoordChange(invVM); 198 fCoverageStages[s].localCoordChange(invVM);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 (this->willEffectReadDstColor() && 371 (this->willEffectReadDstColor() &&
372 kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCoeff); 372 kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCoeff);
373 } 373 }
374 374
375 bool GrDrawState::hasSolidCoverage() const { 375 bool GrDrawState::hasSolidCoverage() const {
376 // If we're drawing coverage directly then coverage is effectively treated a s color. 376 // If we're drawing coverage directly then coverage is effectively treated a s color.
377 if (this->isCoverageDrawing()) { 377 if (this->isCoverageDrawing()) {
378 return true; 378 return true;
379 } 379 }
380 380
381 if (this->numCoverageStages() > 0) {
382 return false;
383 }
384
381 GrProcessor::InvariantOutput inout; 385 GrProcessor::InvariantOutput inout;
382 inout.fIsSingleComponent = true; 386 inout.fIsSingleComponent = true;
383 // Initialize to an unknown starting coverage if per-vertex coverage is spec ified. 387 // Initialize to an unknown starting coverage if per-vertex coverage is spec ified.
384 if (this->hasCoverageVertexAttribute()) { 388 if (this->hasCoverageVertexAttribute()) {
385 inout.fValidFlags = 0; 389 inout.fValidFlags = 0;
386 } else { 390 } else {
387 inout.fColor = this->getCoverageColor(); 391 inout.fColor = this->getCoverageColor();
388 inout.fValidFlags = kRGBA_GrColorComponentFlags; 392 inout.fValidFlags = kRGBA_GrColorComponentFlags;
389 } 393 }
390 394
391 // Run through the coverage stages and see if the coverage will be all ones at the end. 395 // check the coverage output from the GP
392 if (this->hasGeometryProcessor()) { 396 if (this->hasGeometryProcessor()) {
393 fGeometryProcessor->computeInvariantOutput(&inout); 397 fGeometryProcessor->computeInvariantOutput(&inout);
394 } 398 }
395 399
396 for (int s = 0; s < this->numCoverageStages(); ++s) {
397 const GrProcessor* processor = this->getCoverageStage(s).getProcessor();
398 processor->computeInvariantOutput(&inout);
399 }
400 return inout.isSolidWhite(); 400 return inout.isSolidWhite();
401 } 401 }
402 402
403 ////////////////////////////////////////////////////////////////////////////// 403 //////////////////////////////////////////////////////////////////////////////
404 404
405 GrDrawState::AutoVertexAttribRestore::AutoVertexAttribRestore(GrDrawState* drawS tate) { 405 GrDrawState::AutoVertexAttribRestore::AutoVertexAttribRestore(GrDrawState* drawS tate) {
406 SkASSERT(drawState); 406 SkASSERT(drawState);
407 fDrawState = drawState; 407 fDrawState = drawState;
408 fVAPtr = drawState->fVAPtr; 408 fVAPtr = drawState->fVAPtr;
409 fVACount = drawState->fVACount; 409 fVACount = drawState->fVACount;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 526
527 if (NULL == drawState) { 527 if (NULL == drawState) {
528 return false; 528 return false;
529 } 529 }
530 530
531 if (drawState->getViewMatrix().isIdentity()) { 531 if (drawState->getViewMatrix().isIdentity()) {
532 return true; 532 return true;
533 } 533 }
534 534
535 fViewMatrix = drawState->getViewMatrix(); 535 fViewMatrix = drawState->getViewMatrix();
536 if (0 == drawState->numTotalStages()) { 536 if (0 == drawState->numFragmentStages()) {
537 drawState->fViewMatrix.reset(); 537 drawState->fViewMatrix.reset();
538 fDrawState = drawState; 538 fDrawState = drawState;
539 fNumColorStages = 0; 539 fNumColorStages = 0;
540 fSavedCoordChanges.reset(0); 540 fSavedCoordChanges.reset(0);
541 SkDEBUGCODE(++fDrawState->fBlockEffectRemovalCnt;) 541 SkDEBUGCODE(++fDrawState->fBlockEffectRemovalCnt;)
542 return true; 542 return true;
543 } else { 543 } else {
544 SkMatrix inv; 544 SkMatrix inv;
545 if (!fViewMatrix.invert(&inv)) { 545 if (!fViewMatrix.invert(&inv)) {
546 return false; 546 return false;
547 } 547 }
548 drawState->fViewMatrix.reset(); 548 drawState->fViewMatrix.reset();
549 fDrawState = drawState; 549 fDrawState = drawState;
550 this->doEffectCoordChanges(inv); 550 this->doEffectCoordChanges(inv);
551 SkDEBUGCODE(++fDrawState->fBlockEffectRemovalCnt;) 551 SkDEBUGCODE(++fDrawState->fBlockEffectRemovalCnt;)
552 return true; 552 return true;
553 } 553 }
554 } 554 }
555 555
556 void GrDrawState::AutoViewMatrixRestore::doEffectCoordChanges(const SkMatrix& co ordChangeMatrix) { 556 void GrDrawState::AutoViewMatrixRestore::doEffectCoordChanges(const SkMatrix& co ordChangeMatrix) {
557 fSavedCoordChanges.reset(fDrawState->numTotalStages()); 557 fSavedCoordChanges.reset(fDrawState->numFragmentStages());
558 int i = 0; 558 int i = 0;
559 559
560 fNumColorStages = fDrawState->numColorStages(); 560 fNumColorStages = fDrawState->numColorStages();
561 for (int s = 0; s < fNumColorStages; ++s, ++i) { 561 for (int s = 0; s < fNumColorStages; ++s, ++i) {
562 fDrawState->getColorStage(s).saveCoordChange(&fSavedCoordChanges[i]); 562 fDrawState->getColorStage(s).saveCoordChange(&fSavedCoordChanges[i]);
563 fDrawState->fColorStages[s].localCoordChange(coordChangeMatrix); 563 fDrawState->fColorStages[s].localCoordChange(coordChangeMatrix);
564 } 564 }
565 565
566 int numCoverageStages = fDrawState->numCoverageStages(); 566 int numCoverageStages = fDrawState->numCoverageStages();
567 for (int s = 0; s < numCoverageStages; ++s, ++i) { 567 for (int s = 0; s < numCoverageStages; ++s, ++i) {
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 } 735 }
736 736
737 // Since the shader will multiply coverage and color, the only way the f inal A==1 is if 737 // Since the shader will multiply coverage and color, the only way the f inal A==1 is if
738 // coverage and color both have A==1. 738 // coverage and color both have A==1.
739 return (inoutColor.isOpaque() && inoutCoverage.isOpaque()); 739 return (inoutColor.isOpaque() && inoutCoverage.isOpaque());
740 } 740 }
741 741
742 return inoutColor.isOpaque(); 742 return inoutColor.isOpaque();
743 } 743 }
744 744
OLDNEW
« no previous file with comments | « src/gpu/GrDrawState.h ('k') | src/gpu/GrOptDrawState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698