Create helper functions to use in computeInvariantOutput calls
BUG=skia:
Review URL: https://codereview.chromium.org/643743003
diff --git a/src/gpu/effects/GrBezierEffect.h b/src/gpu/effects/GrBezierEffect.h
index 4631a2c..e6751db 100644
--- a/src/gpu/effects/GrBezierEffect.h
+++ b/src/gpu/effects/GrBezierEffect.h
@@ -105,8 +105,7 @@
virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE;
virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE {
- inout->fValidFlags = 0;
- inout->fIsSingleComponent = false;
+ inout->mulByUnknownAlpha();
}
GrPrimitiveEdgeType fEdgeType;
@@ -178,8 +177,7 @@
virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE;
virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE {
- inout->fValidFlags = 0;
- inout->fIsSingleComponent = false;
+ inout->mulByUnknownAlpha();
}
GrPrimitiveEdgeType fEdgeType;
@@ -253,8 +251,7 @@
virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE;
virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE {
- inout->fValidFlags = 0;
- inout->fIsSingleComponent = false;
+ inout->mulByUnknownAlpha();
}
GrPrimitiveEdgeType fEdgeType;
diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp
index 7cdb56a..75a0861 100644
--- a/src/gpu/effects/GrBicubicEffect.cpp
+++ b/src/gpu/effects/GrBicubicEffect.cpp
@@ -171,9 +171,7 @@
void GrBicubicEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
// FIXME: Perhaps we can do better.
- inout->fValidFlags = 0;
- inout->fIsSingleComponent = false;
- return;
+ inout->mulByUnknownAlpha();
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrBicubicEffect);
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index 96a7be2..fb66cf4 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -128,7 +128,6 @@
void GrConfigConversionEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
this->updateInvariantOutputForModulation(inout);
- inout->fIsSingleComponent = false;
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/effects/GrConvexPolyEffect.cpp b/src/gpu/effects/GrConvexPolyEffect.cpp
index bc76e5a..87d1286 100644
--- a/src/gpu/effects/GrConvexPolyEffect.cpp
+++ b/src/gpu/effects/GrConvexPolyEffect.cpp
@@ -46,12 +46,10 @@
virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE {
if (fRect.isEmpty()) {
// An empty rect will have no coverage anywhere.
- inout->fColor = 0x00000000;
- inout->fValidFlags = kRGBA_GrColorComponentFlags;
+ inout->setToTransparentBlack();
} else {
- inout->fValidFlags = 0;
+ inout->mulByUnknownAlpha();
}
- inout->fIsSingleComponent = false;
}
SkRect fRect;
@@ -329,8 +327,7 @@
GrConvexPolyEffect::~GrConvexPolyEffect() {}
void GrConvexPolyEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
- inout->fValidFlags = 0;
- inout->fIsSingleComponent = false;
+ inout->mulByUnknownAlpha();
}
const GrBackendFragmentProcessorFactory& GrConvexPolyEffect::getFactory() const {
diff --git a/src/gpu/effects/GrConvolutionEffect.h b/src/gpu/effects/GrConvolutionEffect.h
index f61f378..6c55656 100644
--- a/src/gpu/effects/GrConvolutionEffect.h
+++ b/src/gpu/effects/GrConvolutionEffect.h
@@ -100,8 +100,7 @@
virtual void onComputeInvariantOutput(InvariantOutput* inout) const {
// If the texture was opaque we could know that the output color if we knew the sum of the
// kernel values.
- inout->fValidFlags = 0;
- inout->fIsSingleComponent = false;
+ inout->mulByUnknownColor();
}
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
diff --git a/src/gpu/effects/GrCustomCoordsTextureEffect.cpp b/src/gpu/effects/GrCustomCoordsTextureEffect.cpp
index e89e46c..40ff1b1 100644
--- a/src/gpu/effects/GrCustomCoordsTextureEffect.cpp
+++ b/src/gpu/effects/GrCustomCoordsTextureEffect.cpp
@@ -73,12 +73,11 @@
}
void GrCustomCoordsTextureEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
- if (inout->isOpaque() && GrPixelConfigIsOpaque(this->texture(0)->config())) {
- inout->fValidFlags = kA_GrColorComponentFlag;
+ if (GrPixelConfigIsOpaque(this->texture(0)->config())) {
+ inout->mulByUnknownOpaqueColor();
} else {
- inout->fValidFlags = 0;
+ inout->mulByUnknownColor();
}
- inout->fIsSingleComponent = false;
}
const GrBackendGeometryProcessorFactory& GrCustomCoordsTextureEffect::getFactory() const {
diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp
index d7a2f40..7e20809 100644
--- a/src/gpu/effects/GrDashingEffect.cpp
+++ b/src/gpu/effects/GrDashingEffect.cpp
@@ -585,8 +585,7 @@
DashingCircleEffect::~DashingCircleEffect() {}
void DashingCircleEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
- inout->fValidFlags = 0;
- inout->fIsSingleComponent = false;
+ inout->mulByUnknownAlpha();
}
const GrBackendGeometryProcessorFactory& DashingCircleEffect::getFactory() const {
@@ -809,8 +808,7 @@
DashingLineEffect::~DashingLineEffect() {}
void DashingLineEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
- inout->fValidFlags = 0;
- inout->fIsSingleComponent = false;
+ inout->mulByUnknownAlpha();
}
const GrBackendGeometryProcessorFactory& DashingLineEffect::getFactory() const {
diff --git a/src/gpu/effects/GrDistanceFieldTextureEffect.cpp b/src/gpu/effects/GrDistanceFieldTextureEffect.cpp
index c8ed5c9..3374adc 100755
--- a/src/gpu/effects/GrDistanceFieldTextureEffect.cpp
+++ b/src/gpu/effects/GrDistanceFieldTextureEffect.cpp
@@ -207,12 +207,7 @@
}
void GrDistanceFieldTextureEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
- if (inout->isOpaque() && GrPixelConfigIsOpaque(this->texture(0)->config())) {
- inout->fValidFlags = kA_GrColorComponentFlag;
- } else {
- inout->fValidFlags = 0;
- }
- inout->fIsSingleComponent = false;
+ inout->mulByUnknownAlpha();
}
const GrBackendGeometryProcessorFactory& GrDistanceFieldTextureEffect::getFactory() const {
@@ -391,12 +386,7 @@
}
void GrDistanceFieldNoGammaTextureEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
- if (inout->isOpaque() && GrPixelConfigIsOpaque(this->texture(0)->config())) {
- inout->fValidFlags = kA_GrColorComponentFlag;
- } else {
- inout->fValidFlags = 0;
- }
- inout->fIsSingleComponent = false;
+ inout->mulByUnknownAlpha();
}
const GrBackendGeometryProcessorFactory& GrDistanceFieldNoGammaTextureEffect::getFactory() const {
@@ -647,12 +637,7 @@
}
void GrDistanceFieldLCDTextureEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
- if (inout->isOpaque() && GrPixelConfigIsOpaque(this->texture(0)->config())) {
- inout->fValidFlags = kA_GrColorComponentFlag;
- } else {
- inout->fValidFlags = 0;
- }
- inout->fIsSingleComponent = false;
+ inout->mulByUnknownColor();
}
const GrBackendGeometryProcessorFactory& GrDistanceFieldLCDTextureEffect::getFactory() const {
diff --git a/src/gpu/effects/GrDitherEffect.cpp b/src/gpu/effects/GrDitherEffect.cpp
index ce8c471..96cdd75 100644
--- a/src/gpu/effects/GrDitherEffect.cpp
+++ b/src/gpu/effects/GrDitherEffect.cpp
@@ -50,8 +50,7 @@
};
void DitherEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
- inout->fValidFlags = 0;
- inout->fIsSingleComponent = false;
+ inout->setToUnknown();
}
//////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
index a9e7157..07b4851 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
@@ -58,7 +58,6 @@
const char* inputColor,
const TransformedCoordsArray& coords,
const TextureSamplerArray& samplers) {
- sk_ignore_unused_variable(inputColor);
const GrTextureDomain& domain = fp.cast<GrMatrixConvolutionEffect>().domain();
fBoundsUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.h b/src/gpu/effects/GrMatrixConvolutionEffect.h
index 4d76f4c..c653230 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.h
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.h
@@ -81,8 +81,7 @@
virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE {
// TODO: Try to do better?
- inout->fValidFlags = 0;
- inout->fIsSingleComponent = false;
+ inout->mulByUnknownColor();
}
SkIRect fBounds;
diff --git a/src/gpu/effects/GrOvalEffect.cpp b/src/gpu/effects/GrOvalEffect.cpp
index c4e272a..3d8f207 100644
--- a/src/gpu/effects/GrOvalEffect.cpp
+++ b/src/gpu/effects/GrOvalEffect.cpp
@@ -57,8 +57,7 @@
}
void CircleEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
- inout->fValidFlags = 0;
- inout->fIsSingleComponent = false;
+ inout->mulByUnknownAlpha();
}
const GrBackendFragmentProcessorFactory& CircleEffect::getFactory() const {
@@ -232,8 +231,7 @@
}
void EllipseEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
- inout->fValidFlags = 0;
- inout->fIsSingleComponent = false;
+ inout->mulByUnknownAlpha();
}
const GrBackendFragmentProcessorFactory& EllipseEffect::getFactory() const {
diff --git a/src/gpu/effects/GrRRectEffect.cpp b/src/gpu/effects/GrRRectEffect.cpp
index 2113554..ae1daef 100644
--- a/src/gpu/effects/GrRRectEffect.cpp
+++ b/src/gpu/effects/GrRRectEffect.cpp
@@ -87,8 +87,7 @@
}
void CircularRRectEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
- inout->fValidFlags = 0;
- inout->fIsSingleComponent = false;
+ inout->mulByUnknownAlpha();
}
const GrBackendFragmentProcessorFactory& CircularRRectEffect::getFactory() const {
@@ -426,8 +425,7 @@
}
void EllipticalRRectEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
- inout->fValidFlags = 0;
- inout->fIsSingleComponent = false;
+ inout->mulByUnknownAlpha();
}
const GrBackendFragmentProcessorFactory& EllipticalRRectEffect::getFactory() const {
diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrSimpleTextureEffect.cpp
index 7abde24..4da9e8e 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.cpp
+++ b/src/gpu/effects/GrSimpleTextureEffect.cpp
@@ -43,7 +43,6 @@
void GrSimpleTextureEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
this->updateInvariantOutputForModulation(inout);
- inout->fIsSingleComponent = false;
}
const GrBackendFragmentProcessorFactory& GrSimpleTextureEffect::getFactory() const {
diff --git a/src/gpu/effects/GrSingleTextureEffect.h b/src/gpu/effects/GrSingleTextureEffect.h
index cba322e..899755c 100644
--- a/src/gpu/effects/GrSingleTextureEffect.h
+++ b/src/gpu/effects/GrSingleTextureEffect.h
@@ -49,10 +49,10 @@
* texture.
*/
void updateInvariantOutputForModulation(InvariantOutput* inout) const {
- if (inout->isOpaque() && GrPixelConfigIsOpaque(this->texture(0)->config())) {
- inout->fValidFlags = kA_GrColorComponentFlag;
+ if (GrPixelConfigIsOpaque(this->texture(0)->config())) {
+ inout->mulByUnknownOpaqueColor();
} else {
- inout->fValidFlags = 0;
+ inout->mulByUnknownColor();
}
}
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index 2117857..596415e 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -271,11 +271,10 @@
void GrTextureDomainEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
if (GrTextureDomain::kDecal_Mode == fTextureDomain.mode()) { // TODO: helper
- inout->fValidFlags = 0;
+ inout->mulByUnknownColor();
} else {
this->updateInvariantOutputForModulation(inout);
}
- inout->fIsSingleComponent = false;
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/effects/GrYUVtoRGBEffect.cpp b/src/gpu/effects/GrYUVtoRGBEffect.cpp
index ecbaf3a..e3d25a2 100644
--- a/src/gpu/effects/GrYUVtoRGBEffect.cpp
+++ b/src/gpu/effects/GrYUVtoRGBEffect.cpp
@@ -112,9 +112,7 @@
virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE {
// YUV is opaque
- inout->fColor = 0xFF;
- inout->fValidFlags = kA_GrColorComponentFlag;
- inout->fIsSingleComponent = false;
+ inout->setToOther(kA_GrColorComponentFlag, 0xFF << GrColor_SHIFT_A);
}
GrCoordTransform fCoordTransform;