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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrDrawState.cpp
diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp
index d54d085d0ed24b74566e8e081e74d77a3b90ddb1..e13c6057f846b228f96771f2c205617bda0e6871 100644
--- a/src/gpu/GrDrawState.cpp
+++ b/src/gpu/GrDrawState.cpp
@@ -396,22 +396,32 @@ bool GrDrawState::srcAlphaWillBeOne() const {
// Check whether coverage is treated as color. If so we run through the coverage computation.
if (this->isCoverageDrawing()) {
- GrColor coverageColor = this->getCoverageColor();
- GrColor oldColor = color;
- color = 0;
- for (int c = 0; c < 4; ++c) {
- if (validComponentFlags & (1 << c)) {
- U8CPU a = (oldColor >> (c * 8)) & 0xff;
- U8CPU b = (coverageColor >> (c * 8)) & 0xff;
- color |= (SkMulDiv255Round(a, b) << (c * 8));
- }
+ // The shader generated for coverage drawing runs the full coverage computation and then
+ // makes the shader output be the multiplication of color and coverage. We mirror that here.
+ GrColor coverage;
+ uint32_t coverageComponentFlags;
+ if (this->hasCoverageVertexAttribute()) {
+ coverageComponentFlags = 0;
+ coverage = 0; // suppresses any warnings.
+ } else {
+ coverageComponentFlags = kRGBA_GrColorComponentFlags;
+ coverage = this->getCoverageColor();
}
+
+ // Run through the coverage stages
for (int s = 0; s < this->numCoverageStages(); ++s) {
const GrEffect* effect = this->getCoverageStage(s).getEffect();
- effect->getConstantColorComponents(&color, &validComponentFlags);
+ effect->getConstantColorComponents(&coverage, &coverageComponentFlags);
}
+
+ // Since the shader will multiply coverage and color, the only way the final A==1 is if
+ // coverage and color both have A==1.
+ return (kA_GrColorComponentFlag & validComponentFlags & coverageComponentFlags) &&
+ 0xFF == GrColorUnpackA(color) && 0xFF == GrColorUnpackA(coverage);
+
}
- return (kA_GrColorComponentFlag & validComponentFlags) && 0xff == GrColorUnpackA(color);
+
+ return (kA_GrColorComponentFlag & validComponentFlags) && 0xFF == GrColorUnpackA(color);
}
bool GrDrawState::hasSolidCoverage() const {
« 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