Update invariant output computation for various texture effects.
authoregdaniel <egdaniel@google.com>
Tue, 25 Nov 2014 18:24:56 +0000 (10:24 -0800)
committerCommit bot <commit-bot@chromium.org>
Tue, 25 Nov 2014 18:24:56 +0000 (10:24 -0800)
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

src/effects/SkAlphaThresholdFilter.cpp
src/gpu/effects/GrCustomCoordsTextureEffect.cpp
src/gpu/effects/GrSingleTextureEffect.h
src/gpu/effects/GrTextureDomain.cpp

index bff877280c5689e1bd4371a3d502c856d141b196..c01dd975d0641b1fe6d4de06ed6d209415d807ef 100644 (file)
@@ -229,7 +229,9 @@ bool AlphaThresholdEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
 }
 
 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();
index 39f44820b0013b79443d5bb0e37d64b06eda6207..f61a37bb6fbed860aa0fc97657007d61890ffd3d 100644 (file)
@@ -68,7 +68,9 @@ bool GrCustomCoordsTextureEffect::onIsEqual(const GrGeometryProcessor& other) co
 }
 
 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();
index efdf25555259d315cf66970f18daca472d4de8ce..6fd6819e92ac6d688da0659fb15d6c04fffb096b 100644 (file)
@@ -40,7 +40,9 @@ protected:
      * 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();
index db3ef2cd98715064211c55dfefa6ac66576fc4a0..de552c0ac9665472492c3ff63cf82787837d18ed 100644 (file)
@@ -271,7 +271,11 @@ bool GrTextureDomainEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
 
 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);
     }