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

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

Issue 480113002: Fix srcAlpaWillBeOne() for coverage drawing (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use 4 byte coverage Created 6 years, 4 months 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 | « no previous file | no next file » | 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 #include "GrPaint.h" 9 #include "GrPaint.h"
10 #include "GrDrawTargetCaps.h" 10 #include "GrDrawTargetCaps.h"
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 } 389 }
390 390
391 // Run through the color stages 391 // Run through the color stages
392 for (int s = 0; s < this->numColorStages(); ++s) { 392 for (int s = 0; s < this->numColorStages(); ++s) {
393 const GrEffect* effect = this->getColorStage(s).getEffect(); 393 const GrEffect* effect = this->getColorStage(s).getEffect();
394 effect->getConstantColorComponents(&color, &validComponentFlags); 394 effect->getConstantColorComponents(&color, &validComponentFlags);
395 } 395 }
396 396
397 // Check whether coverage is treated as color. If so we run through the cove rage computation. 397 // Check whether coverage is treated as color. If so we run through the cove rage computation.
398 if (this->isCoverageDrawing()) { 398 if (this->isCoverageDrawing()) {
399 GrColor coverageColor = this->getCoverageColor(); 399 // The shader generated for coverage drawing runs the full coverage comp utation and then
400 GrColor oldColor = color; 400 // makes the shader output be the multiplication of color and coverage. We mirror that here.
401 color = 0; 401 GrColor coverage;
402 for (int c = 0; c < 4; ++c) { 402 uint32_t coverageComponentFlags;
403 if (validComponentFlags & (1 << c)) { 403 if (this->hasCoverageVertexAttribute()) {
404 U8CPU a = (oldColor >> (c * 8)) & 0xff; 404 coverageComponentFlags = 0;
405 U8CPU b = (coverageColor >> (c * 8)) & 0xff; 405 coverage = 0; // suppresses any warnings.
406 color |= (SkMulDiv255Round(a, b) << (c * 8)); 406 } else {
407 } 407 coverageComponentFlags = kRGBA_GrColorComponentFlags;
408 coverage = this->getCoverageColor();
408 } 409 }
410
411 // Run through the coverage stages
409 for (int s = 0; s < this->numCoverageStages(); ++s) { 412 for (int s = 0; s < this->numCoverageStages(); ++s) {
410 const GrEffect* effect = this->getCoverageStage(s).getEffect(); 413 const GrEffect* effect = this->getCoverageStage(s).getEffect();
411 effect->getConstantColorComponents(&color, &validComponentFlags); 414 effect->getConstantColorComponents(&coverage, &coverageComponentFlag s);
412 } 415 }
416
417 // Since the shader will multiply coverage and color, the only way the f inal A==1 is if
418 // coverage and color both have A==1.
419 return (kA_GrColorComponentFlag & validComponentFlags & coverageComponen tFlags) &&
420 0xFF == GrColorUnpackA(color) && 0xFF == GrColorUnpackA(coverage );
421
413 } 422 }
414 return (kA_GrColorComponentFlag & validComponentFlags) && 0xff == GrColorUnp ackA(color); 423
424 return (kA_GrColorComponentFlag & validComponentFlags) && 0xFF == GrColorUnp ackA(color);
415 } 425 }
416 426
417 bool GrDrawState::hasSolidCoverage() const { 427 bool GrDrawState::hasSolidCoverage() const {
418 // If we're drawing coverage directly then coverage is effectively treated a s color. 428 // If we're drawing coverage directly then coverage is effectively treated a s color.
419 if (this->isCoverageDrawing()) { 429 if (this->isCoverageDrawing()) {
420 return true; 430 return true;
421 } 431 }
422 432
423 GrColor coverage; 433 GrColor coverage;
424 uint32_t validComponentFlags; 434 uint32_t validComponentFlags;
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 fDrawState->getColorStage(s).saveCoordChange(&fSavedCoordChanges[i]); 702 fDrawState->getColorStage(s).saveCoordChange(&fSavedCoordChanges[i]);
693 fDrawState->fState.fColorStages[s].localCoordChange(coordChangeMatrix); 703 fDrawState->fState.fColorStages[s].localCoordChange(coordChangeMatrix);
694 } 704 }
695 705
696 int numCoverageStages = fDrawState->numCoverageStages(); 706 int numCoverageStages = fDrawState->numCoverageStages();
697 for (int s = 0; s < numCoverageStages; ++s, ++i) { 707 for (int s = 0; s < numCoverageStages; ++s, ++i) {
698 fDrawState->getCoverageStage(s).saveCoordChange(&fSavedCoordChanges[i]); 708 fDrawState->getCoverageStage(s).saveCoordChange(&fSavedCoordChanges[i]);
699 fDrawState->fState.fCoverageStages[s].localCoordChange(coordChangeMatrix ); 709 fDrawState->fState.fCoverageStages[s].localCoordChange(coordChangeMatrix );
700 } 710 }
701 } 711 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698