Update invariant output computation for various texture effects.
Update various effects that read in textures to check whether or not the texture is alpha only.
This allows us to use a more specific mulByUnKnownAlpha instead of the more general mulByUnknownColor
BUG=skia:
Review URL: https://codereview.chromium.org/759653004
diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp
index bff8772..c01dd97 100644
--- a/src/effects/SkAlphaThresholdFilter.cpp
+++ b/src/effects/SkAlphaThresholdFilter.cpp
@@ -229,7 +229,9 @@
}
void AlphaThresholdEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- if (GrPixelConfigIsOpaque(this->texture(0)->config()) && fOuterThreshold >= 1.f) {
+ if (GrPixelConfigIsAlphaOnly(this->texture(0)->config())) {
+ inout->mulByUnknownAlpha();
+ } else if (GrPixelConfigIsOpaque(this->texture(0)->config()) && fOuterThreshold >= 1.f) {
inout->mulByUnknownOpaqueColor();
} else {
inout->mulByUnknownColor();
diff --git a/src/gpu/effects/GrCustomCoordsTextureEffect.cpp b/src/gpu/effects/GrCustomCoordsTextureEffect.cpp
index 39f4482..f61a37b 100644
--- a/src/gpu/effects/GrCustomCoordsTextureEffect.cpp
+++ b/src/gpu/effects/GrCustomCoordsTextureEffect.cpp
@@ -68,7 +68,9 @@
}
void GrCustomCoordsTextureEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- if (GrPixelConfigIsOpaque(this->texture(0)->config())) {
+ if (GrPixelConfigIsAlphaOnly(this->texture(0)->config())) {
+ inout->mulByUnknownAlpha();
+ } else if (GrPixelConfigIsOpaque(this->texture(0)->config())) {
inout->mulByUnknownOpaqueColor();
} else {
inout->mulByUnknownColor();
diff --git a/src/gpu/effects/GrSingleTextureEffect.h b/src/gpu/effects/GrSingleTextureEffect.h
index efdf255..6fd6819 100644
--- a/src/gpu/effects/GrSingleTextureEffect.h
+++ b/src/gpu/effects/GrSingleTextureEffect.h
@@ -40,7 +40,9 @@
* texture.
*/
void updateInvariantOutputForModulation(GrInvariantOutput* inout) const {
- if (GrPixelConfigIsOpaque(this->texture(0)->config())) {
+ if (GrPixelConfigIsAlphaOnly(this->texture(0)->config())) {
+ inout->mulByUnknownAlpha();
+ } else if (GrPixelConfigIsOpaque(this->texture(0)->config())) {
inout->mulByUnknownOpaqueColor();
} else {
inout->mulByUnknownColor();
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index db3ef2c..de552c0 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -271,7 +271,11 @@
void GrTextureDomainEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
if (GrTextureDomain::kDecal_Mode == fTextureDomain.mode()) { // TODO: helper
- inout->mulByUnknownColor();
+ if (GrPixelConfigIsAlphaOnly(this->texture(0)->config())) {
+ inout->mulByUnknownAlpha();
+ } else {
+ inout->mulByUnknownColor();
+ }
} else {
this->updateInvariantOutputForModulation(inout);
}