Stop tracking whether GrFragmentProcessors read their input
Change-Id: Id5338901978b97289798eaef873527597bd8dfd6 Reviewed-on: https://skia-review.googlesource.com/7414 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
This commit is contained in:
parent
319ba3d3a1
commit
5f13fbac19
@ -672,7 +672,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
||||||
inout->setToUnknown(GrInvariantOutput::kWillNot_ReadInput);
|
inout->setToUnknown();
|
||||||
}
|
}
|
||||||
|
|
||||||
GrPerlinNoise2Effect(SkPerlinNoiseShader2::Type type,
|
GrPerlinNoise2Effect(SkPerlinNoiseShader2::Type type,
|
||||||
@ -1084,7 +1084,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
||||||
inout->setToUnknown(GrInvariantOutput::kWillNot_ReadInput);
|
inout->setToUnknown();
|
||||||
}
|
}
|
||||||
|
|
||||||
GrImprovedPerlinNoiseEffect(int octaves, SkScalar z,
|
GrImprovedPerlinNoiseEffect(int octaves, SkScalar z,
|
||||||
|
@ -55,26 +55,14 @@ struct GrPipelineInput {
|
|||||||
class GrInvariantOutput {
|
class GrInvariantOutput {
|
||||||
public:
|
public:
|
||||||
GrInvariantOutput(GrColor color, GrColorComponentFlags flags)
|
GrInvariantOutput(GrColor color, GrColorComponentFlags flags)
|
||||||
: fColor(color)
|
: fColor(color), fValidFlags(flags), fNonMulStageFound(false) {}
|
||||||
, fValidFlags(flags)
|
|
||||||
, fNonMulStageFound(false)
|
|
||||||
, fWillUseInputColor(true) {}
|
|
||||||
|
|
||||||
GrInvariantOutput(const GrPipelineInput& input)
|
GrInvariantOutput(const GrPipelineInput& input)
|
||||||
: fColor(input.fColor)
|
: fColor(input.fColor), fValidFlags(input.fValidFlags), fNonMulStageFound(false) {}
|
||||||
, fValidFlags(input.fValidFlags)
|
|
||||||
, fNonMulStageFound(false)
|
|
||||||
, fWillUseInputColor(false) {}
|
|
||||||
|
|
||||||
virtual ~GrInvariantOutput() {}
|
virtual ~GrInvariantOutput() {}
|
||||||
|
|
||||||
enum ReadInput {
|
|
||||||
kWill_ReadInput,
|
|
||||||
kWillNot_ReadInput,
|
|
||||||
};
|
|
||||||
|
|
||||||
void mulByUnknownOpaqueFourComponents() {
|
void mulByUnknownOpaqueFourComponents() {
|
||||||
SkDEBUGCODE(this->validate());
|
|
||||||
if (this->isOpaque()) {
|
if (this->isOpaque()) {
|
||||||
fValidFlags = kA_GrColorComponentFlag;
|
fValidFlags = kA_GrColorComponentFlag;
|
||||||
} else {
|
} else {
|
||||||
@ -82,32 +70,26 @@ public:
|
|||||||
// multiplied is opaque.
|
// multiplied is opaque.
|
||||||
this->mulByUnknownFourComponents();
|
this->mulByUnknownFourComponents();
|
||||||
}
|
}
|
||||||
SkDEBUGCODE(this->validate());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mulByUnknownFourComponents() {
|
void mulByUnknownFourComponents() {
|
||||||
SkDEBUGCODE(this->validate());
|
|
||||||
if (this->hasZeroAlpha()) {
|
if (this->hasZeroAlpha()) {
|
||||||
this->internalSetToTransparentBlack();
|
this->internalSetToTransparentBlack();
|
||||||
} else {
|
} else {
|
||||||
this->internalSetToUnknown();
|
this->internalSetToUnknown();
|
||||||
}
|
}
|
||||||
SkDEBUGCODE(this->validate());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mulByUnknownSingleComponent() {
|
void mulByUnknownSingleComponent() {
|
||||||
SkDEBUGCODE(this->validate());
|
|
||||||
if (this->hasZeroAlpha()) {
|
if (this->hasZeroAlpha()) {
|
||||||
this->internalSetToTransparentBlack();
|
this->internalSetToTransparentBlack();
|
||||||
} else {
|
} else {
|
||||||
// We don't need to change fIsSingleComponent in this case
|
// We don't need to change fIsSingleComponent in this case
|
||||||
fValidFlags = kNone_GrColorComponentFlags;
|
fValidFlags = kNone_GrColorComponentFlags;
|
||||||
}
|
}
|
||||||
SkDEBUGCODE(this->validate());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mulByKnownSingleComponent(uint8_t alpha) {
|
void mulByKnownSingleComponent(uint8_t alpha) {
|
||||||
SkDEBUGCODE(this->validate());
|
|
||||||
if (this->hasZeroAlpha() || 0 == alpha) {
|
if (this->hasZeroAlpha() || 0 == alpha) {
|
||||||
this->internalSetToTransparentBlack();
|
this->internalSetToTransparentBlack();
|
||||||
} else {
|
} else {
|
||||||
@ -120,11 +102,9 @@ public:
|
|||||||
// We don't need to change fIsSingleComponent in this case
|
// We don't need to change fIsSingleComponent in this case
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SkDEBUGCODE(this->validate());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mulByKnownFourComponents(GrColor color) {
|
void mulByKnownFourComponents(GrColor color) {
|
||||||
SkDEBUGCODE(this->validate());
|
|
||||||
uint32_t a;
|
uint32_t a;
|
||||||
if (GetAlphaAndCheckSingleChannel(color, &a)) {
|
if (GetAlphaAndCheckSingleChannel(color, &a)) {
|
||||||
this->mulByKnownSingleComponent(a);
|
this->mulByKnownSingleComponent(a);
|
||||||
@ -137,12 +117,10 @@ public:
|
|||||||
SkMulDiv255Round(GrColorUnpackA(fColor), a));
|
SkMulDiv255Round(GrColorUnpackA(fColor), a));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SkDEBUGCODE(this->validate());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignores the incoming color's RGB and muls its alpha by color.
|
// Ignores the incoming color's RGB and muls its alpha by color.
|
||||||
void mulAlphaByKnownFourComponents(GrColor color) {
|
void mulAlphaByKnownFourComponents(GrColor color) {
|
||||||
SkDEBUGCODE(this->validate());
|
|
||||||
uint32_t a;
|
uint32_t a;
|
||||||
if (GetAlphaAndCheckSingleChannel(color, &a)) {
|
if (GetAlphaAndCheckSingleChannel(color, &a)) {
|
||||||
this->mulAlphaByKnownSingleComponent(a);
|
this->mulAlphaByKnownSingleComponent(a);
|
||||||
@ -162,13 +140,11 @@ public:
|
|||||||
} else {
|
} else {
|
||||||
fValidFlags = kNone_GrColorComponentFlags;
|
fValidFlags = kNone_GrColorComponentFlags;
|
||||||
}
|
}
|
||||||
SkDEBUGCODE(this->validate());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignores the incoming color's RGB and muls its alpha by the alpha param and sets all channels
|
// Ignores the incoming color's RGB and muls its alpha by the alpha param and sets all channels
|
||||||
// equal to that value.
|
// equal to that value.
|
||||||
void mulAlphaByKnownSingleComponent(uint8_t alpha) {
|
void mulAlphaByKnownSingleComponent(uint8_t alpha) {
|
||||||
SkDEBUGCODE(this->validate());
|
|
||||||
if (0 == alpha || this->hasZeroAlpha()) {
|
if (0 == alpha || this->hasZeroAlpha()) {
|
||||||
this->internalSetToTransparentBlack();
|
this->internalSetToTransparentBlack();
|
||||||
} else {
|
} else {
|
||||||
@ -181,63 +157,35 @@ public:
|
|||||||
fValidFlags = kNone_GrColorComponentFlags;
|
fValidFlags = kNone_GrColorComponentFlags;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SkDEBUGCODE(this->validate());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void premulFourChannelColor() {
|
void premulFourChannelColor() {
|
||||||
SkDEBUGCODE(this->validate());
|
|
||||||
fNonMulStageFound = true;
|
fNonMulStageFound = true;
|
||||||
if (!(fValidFlags & kA_GrColorComponentFlag)) {
|
if (!(fValidFlags & kA_GrColorComponentFlag)) {
|
||||||
fValidFlags = kNone_GrColorComponentFlags;
|
fValidFlags = kNone_GrColorComponentFlags;
|
||||||
} else {
|
} else {
|
||||||
fColor = GrPremulColor(fColor);
|
fColor = GrPremulColor(fColor);
|
||||||
}
|
}
|
||||||
SkDEBUGCODE(this->validate());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void invalidateComponents(GrColorComponentFlags invalidateFlags, ReadInput readsInput) {
|
void invalidateComponents(GrColorComponentFlags invalidateFlags) {
|
||||||
SkDEBUGCODE(this->validate());
|
|
||||||
fValidFlags = (fValidFlags & ~invalidateFlags);
|
fValidFlags = (fValidFlags & ~invalidateFlags);
|
||||||
fNonMulStageFound = true;
|
fNonMulStageFound = true;
|
||||||
if (kWillNot_ReadInput == readsInput) {
|
|
||||||
fWillUseInputColor = false;
|
|
||||||
}
|
|
||||||
SkDEBUGCODE(this->validate());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setToOther(GrColorComponentFlags validFlags, GrColor color, ReadInput readsInput) {
|
void setToOther(GrColorComponentFlags validFlags, GrColor color) {
|
||||||
SkDEBUGCODE(this->validate());
|
|
||||||
fValidFlags = validFlags;
|
fValidFlags = validFlags;
|
||||||
fColor = color;
|
fColor = color;
|
||||||
fNonMulStageFound = true;
|
fNonMulStageFound = true;
|
||||||
if (kWillNot_ReadInput == readsInput) {
|
|
||||||
fWillUseInputColor = false;
|
|
||||||
}
|
|
||||||
if (kRGBA_GrColorComponentFlags == fValidFlags) {
|
|
||||||
}
|
|
||||||
SkDEBUGCODE(this->validate());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setToUnknown(ReadInput readsInput) {
|
void setToUnknown() {
|
||||||
SkDEBUGCODE(this->validate());
|
|
||||||
this->internalSetToUnknown();
|
this->internalSetToUnknown();
|
||||||
fNonMulStageFound= true;
|
fNonMulStageFound = true;
|
||||||
if (kWillNot_ReadInput == readsInput) {
|
|
||||||
fWillUseInputColor = false;
|
|
||||||
}
|
|
||||||
SkDEBUGCODE(this->validate());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GrColor color() const { return fColor; }
|
GrColor color() const { return fColor; }
|
||||||
GrColorComponentFlags validFlags() const { return fValidFlags; }
|
GrColorComponentFlags validFlags() const { return fValidFlags; }
|
||||||
bool willUseInputColor() const { return fWillUseInputColor; }
|
|
||||||
|
|
||||||
#ifdef SK_DEBUG
|
|
||||||
void validate() const {
|
|
||||||
// If we claim that we are not using the input color we must not be modulating the input.
|
|
||||||
SkASSERT(fNonMulStageFound || fWillUseInputColor);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class GrProcOptInfo;
|
friend class GrProcOptInfo;
|
||||||
@ -253,14 +201,12 @@ private:
|
|||||||
fColor = color;
|
fColor = color;
|
||||||
fValidFlags = flags;
|
fValidFlags = flags;
|
||||||
fNonMulStageFound = false;
|
fNonMulStageFound = false;
|
||||||
fWillUseInputColor = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset(const GrPipelineInput& input) {
|
void reset(const GrPipelineInput& input) {
|
||||||
fColor = input.fColor;
|
fColor = input.fColor;
|
||||||
fValidFlags = input.fValidFlags;
|
fValidFlags = input.fValidFlags;
|
||||||
fNonMulStageFound = false;
|
fNonMulStageFound = false;
|
||||||
fWillUseInputColor = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void internalSetToTransparentBlack() {
|
void internalSetToTransparentBlack() {
|
||||||
@ -284,8 +230,6 @@ private:
|
|||||||
return (fValidFlags == kRGBA_GrColorComponentFlags && 0xFFFFFFFF == fColor);
|
return (fValidFlags == kRGBA_GrColorComponentFlags && 0xFFFFFFFF == fColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetWillUseInputColor() { fWillUseInputColor = true; }
|
|
||||||
|
|
||||||
bool allStagesMulInput() const { return !fNonMulStageFound; }
|
bool allStagesMulInput() const { return !fNonMulStageFound; }
|
||||||
void resetNonMulStageFound() { fNonMulStageFound = false; }
|
void resetNonMulStageFound() { fNonMulStageFound = false; }
|
||||||
|
|
||||||
@ -297,7 +241,6 @@ private:
|
|||||||
GrColor fColor;
|
GrColor fColor;
|
||||||
GrColorComponentFlags fValidFlags;
|
GrColorComponentFlags fValidFlags;
|
||||||
bool fNonMulStageFound;
|
bool fNonMulStageFound;
|
||||||
bool fWillUseInputColor;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -393,7 +393,7 @@ private:
|
|||||||
// then we can't know the final result.
|
// then we can't know the final result.
|
||||||
if (0 != fMatrix[kAlphaRowStartIdx + i]) {
|
if (0 != fMatrix[kAlphaRowStartIdx + i]) {
|
||||||
if (!(inout->validFlags() & kRGBAFlags[i])) {
|
if (!(inout->validFlags() & kRGBAFlags[i])) {
|
||||||
inout->setToUnknown(GrInvariantOutput::kWill_ReadInput);
|
inout->setToUnknown();
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
uint32_t component = (inout->color() >> kShifts[i]) & 0xFF;
|
uint32_t component = (inout->color() >> kShifts[i]) & 0xFF;
|
||||||
@ -407,8 +407,7 @@ private:
|
|||||||
// underflow this may deviate from the actual result. Maybe the effect should pin its
|
// underflow this may deviate from the actual result. Maybe the effect should pin its
|
||||||
// result if the matrix could over/underflow for any component?
|
// result if the matrix could over/underflow for any component?
|
||||||
inout->setToOther(kA_GrColorComponentFlag,
|
inout->setToOther(kA_GrColorComponentFlag,
|
||||||
static_cast<uint8_t>(SkScalarPin(outputA, 0, 255)) << GrColor_SHIFT_A,
|
static_cast<uint8_t>(SkScalarPin(outputA, 0, 255)) << GrColor_SHIFT_A);
|
||||||
GrInvariantOutput::kWill_ReadInput);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SkScalar fMatrix[20];
|
SkScalar fMatrix[20];
|
||||||
|
@ -223,7 +223,7 @@ public:
|
|||||||
const char* name() const override { return "NormalBevelFP"; }
|
const char* name() const override { return "NormalBevelFP"; }
|
||||||
|
|
||||||
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
||||||
inout->setToUnknown(GrInvariantOutput::ReadInput::kWillNot_ReadInput);
|
inout->setToUnknown();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -50,7 +50,7 @@ public:
|
|||||||
const char* name() const override { return "NormalFlatFP"; }
|
const char* name() const override { return "NormalFlatFP"; }
|
||||||
|
|
||||||
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
||||||
inout->setToUnknown(GrInvariantOutput::ReadInput::kWillNot_ReadInput);
|
inout->setToUnknown();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -103,7 +103,7 @@ public:
|
|||||||
const char* name() const override { return "NormalMapFP"; }
|
const char* name() const override { return "NormalMapFP"; }
|
||||||
|
|
||||||
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
||||||
inout->setToUnknown(GrInvariantOutput::ReadInput::kWillNot_ReadInput);
|
inout->setToUnknown();
|
||||||
}
|
}
|
||||||
|
|
||||||
const SkMatrix& invCTM() const { return fInvCTM; }
|
const SkMatrix& invCTM() const { return fInvCTM; }
|
||||||
|
@ -287,7 +287,7 @@ private:
|
|||||||
|
|
||||||
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
||||||
// TODO: optimize this
|
// TODO: optimize this
|
||||||
inout->setToUnknown(GrInvariantOutput::kWill_ReadInput);
|
inout->setToUnknown();
|
||||||
}
|
}
|
||||||
|
|
||||||
ArithmeticFP(float k1, float k2, float k3, float k4, bool enforcePMColor,
|
ArithmeticFP(float k1, float k2, float k3, float k4, bool enforcePMColor,
|
||||||
|
@ -528,7 +528,7 @@ void GrDisplacementMapEffect::onComputeInvariantOutput(GrInvariantOutput* inout)
|
|||||||
// and no displacement offset push any texture coordinates out of bounds OR if the constant
|
// and no displacement offset push any texture coordinates out of bounds OR if the constant
|
||||||
// alpha is 0. Since this isn't trivial to compute at this point, let's assume the output is
|
// alpha is 0. Since this isn't trivial to compute at this point, let's assume the output is
|
||||||
// not of constant color when a displacement effect is applied.
|
// not of constant color when a displacement effect is applied.
|
||||||
inout->setToUnknown(GrInvariantOutput::kWillNot_ReadInput);
|
inout->setToUnknown();
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -115,8 +115,7 @@ private:
|
|||||||
|
|
||||||
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
||||||
// The output is always black. The alpha value for the color passed in is arbitrary.
|
// The output is always black. The alpha value for the color passed in is arbitrary.
|
||||||
inout->setToOther(kRGB_GrColorComponentFlags, GrColorPackRGBA(0, 0, 0, 0),
|
inout->setToOther(kRGB_GrColorComponentFlags, GrColorPackRGBA(0, 0, 0, 0));
|
||||||
GrInvariantOutput::kWill_ReadInput);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ bool OverdrawFragmentProcessor::onIsEqual(const GrFragmentProcessor& other) cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OverdrawFragmentProcessor::onComputeInvariantOutput(GrInvariantOutput* inout) const {
|
void OverdrawFragmentProcessor::onComputeInvariantOutput(GrInvariantOutput* inout) const {
|
||||||
inout->invalidateComponents(kRGBA_GrColorComponentFlags, GrInvariantOutput::kWill_ReadInput);
|
inout->invalidateComponents(kRGBA_GrColorComponentFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLOverdrawFragmentProcessor::GLOverdrawFragmentProcessor(const GrColor4f* colors) {
|
GLOverdrawFragmentProcessor::GLOverdrawFragmentProcessor(const GrColor4f* colors) {
|
||||||
|
@ -536,7 +536,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
||||||
inout->setToUnknown(GrInvariantOutput::kWillNot_ReadInput);
|
inout->setToUnknown();
|
||||||
}
|
}
|
||||||
|
|
||||||
GrPerlinNoiseEffect(SkPerlinNoiseShader::Type type,
|
GrPerlinNoiseEffect(SkPerlinNoiseShader::Type type,
|
||||||
|
@ -456,7 +456,7 @@ public:
|
|||||||
const char* name() const override { return "RRectsGaussianEdgeFP"; }
|
const char* name() const override { return "RRectsGaussianEdgeFP"; }
|
||||||
|
|
||||||
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
||||||
inout->setToUnknown(GrInvariantOutput::kWill_ReadInput);
|
inout->setToUnknown();
|
||||||
}
|
}
|
||||||
|
|
||||||
const SkRRect& first() const { return fFirst; }
|
const SkRRect& first() const { return fFirst; }
|
||||||
|
@ -561,7 +561,7 @@ void ColorTableEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
|
|||||||
if (fFlags & SkTable_ColorFilter::kA_Flag) {
|
if (fFlags & SkTable_ColorFilter::kA_Flag) {
|
||||||
invalidateFlags |= kA_GrColorComponentFlag;
|
invalidateFlags |= kA_GrColorComponentFlag;
|
||||||
}
|
}
|
||||||
inout->invalidateComponents(invalidateFlags, GrInvariantOutput::kWill_ReadInput);
|
inout->invalidateComponents(invalidateFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -181,7 +181,7 @@ sk_sp<GrFragmentProcessor> GrFragmentProcessor::MulOutputByInputUnpremulColor(
|
|||||||
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
||||||
// TODO: Add a helper to GrInvariantOutput that handles multiplying by color with flags?
|
// TODO: Add a helper to GrInvariantOutput that handles multiplying by color with flags?
|
||||||
if (!(inout->validFlags() & kA_GrColorComponentFlag)) {
|
if (!(inout->validFlags() & kA_GrColorComponentFlag)) {
|
||||||
inout->setToUnknown(GrInvariantOutput::kWill_ReadInput);
|
inout->setToUnknown();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ sk_sp<GrFragmentProcessor> GrFragmentProcessor::MulOutputByInputUnpremulColor(
|
|||||||
color |= SkMulDiv255Round(GrColorUnpackB(c0), GrColorUnpackB(c1)) <<
|
color |= SkMulDiv255Round(GrColorUnpackB(c0), GrColorUnpackB(c1)) <<
|
||||||
GrColor_SHIFT_B;
|
GrColor_SHIFT_B;
|
||||||
}
|
}
|
||||||
inout->setToOther(commonFlags, color, GrInvariantOutput::kWill_ReadInput);
|
inout->setToOther(commonFlags, color);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
@ -272,8 +272,7 @@ sk_sp<GrFragmentProcessor> GrFragmentProcessor::OverrideInput(sk_sp<GrFragmentPr
|
|||||||
}
|
}
|
||||||
|
|
||||||
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
||||||
inout->setToOther(kRGBA_GrColorComponentFlags, fColor.toGrColor(),
|
inout->setToOther(kRGBA_GrColorComponentFlags, fColor.toGrColor());
|
||||||
GrInvariantOutput::kWillNot_ReadInput);
|
|
||||||
this->childProcessor(0).computeInvariantOutput(inout);
|
this->childProcessor(0).computeInvariantOutput(inout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,11 +281,7 @@ sk_sp<GrFragmentProcessor> GrFragmentProcessor::OverrideInput(sk_sp<GrFragmentPr
|
|||||||
|
|
||||||
GrInvariantOutput childOut(0x0, kNone_GrColorComponentFlags);
|
GrInvariantOutput childOut(0x0, kNone_GrColorComponentFlags);
|
||||||
fp->computeInvariantOutput(&childOut);
|
fp->computeInvariantOutput(&childOut);
|
||||||
if (childOut.willUseInputColor()) {
|
return sk_sp<GrFragmentProcessor>(new ReplaceInputFragmentProcessor(std::move(fp), color));
|
||||||
return sk_sp<GrFragmentProcessor>(new ReplaceInputFragmentProcessor(std::move(fp), color));
|
|
||||||
} else {
|
|
||||||
return fp;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrFragmentProcessor> GrFragmentProcessor::RunInSeries(sk_sp<GrFragmentProcessor>* series,
|
sk_sp<GrFragmentProcessor> GrFragmentProcessor::RunInSeries(sk_sp<GrFragmentProcessor>* series,
|
||||||
@ -354,7 +349,7 @@ sk_sp<GrFragmentProcessor> GrFragmentProcessor::RunInSeries(sk_sp<GrFragmentProc
|
|||||||
|
|
||||||
int firstIdx = info.firstEffectiveProcessorIndex();
|
int firstIdx = info.firstEffectiveProcessorIndex();
|
||||||
cnt -= firstIdx;
|
cnt -= firstIdx;
|
||||||
if (firstIdx > 0 && info.inputColorIsUsed()) {
|
if (firstIdx > 0) {
|
||||||
// See comment above - need to preserve 4f and color spaces during invariant processing.
|
// See comment above - need to preserve 4f and color spaces during invariant processing.
|
||||||
sk_sp<GrFragmentProcessor> colorFP(GrConstColorProcessor::Make(
|
sk_sp<GrFragmentProcessor> colorFP(GrConstColorProcessor::Make(
|
||||||
GrColor4f::FromGrColor(info.inputColorToFirstEffectiveProccesor()),
|
GrColor4f::FromGrColor(info.inputColorToFirstEffectiveProccesor()),
|
||||||
@ -366,9 +361,6 @@ sk_sp<GrFragmentProcessor> GrFragmentProcessor::RunInSeries(sk_sp<GrFragmentProc
|
|||||||
replacementSeries.emplace_back(std::move(series[firstIdx + i]));
|
replacementSeries.emplace_back(std::move(series[firstIdx + i]));
|
||||||
}
|
}
|
||||||
series = replacementSeries.begin();
|
series = replacementSeries.begin();
|
||||||
} else {
|
|
||||||
series += firstIdx;
|
|
||||||
cnt -= firstIdx;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (1 == cnt) {
|
if (1 == cnt) {
|
||||||
|
@ -12,17 +12,10 @@
|
|||||||
void GrProcOptInfo::analyzeProcessors(const GrFragmentProcessor* const* processors, int cnt) {
|
void GrProcOptInfo::analyzeProcessors(const GrFragmentProcessor* const* processors, int cnt) {
|
||||||
for (int i = 0; i < cnt; ++i) {
|
for (int i = 0; i < cnt; ++i) {
|
||||||
const GrFragmentProcessor* processor = processors[i];
|
const GrFragmentProcessor* processor = processors[i];
|
||||||
fInOut.resetWillUseInputColor();
|
|
||||||
processor->computeInvariantOutput(&fInOut);
|
processor->computeInvariantOutput(&fInOut);
|
||||||
SkDEBUGCODE(fInOut.validate());
|
|
||||||
if (!fInOut.willUseInputColor()) {
|
|
||||||
fFirstEffectiveProcessorIndex = i;
|
|
||||||
fInputColorIsUsed = false;
|
|
||||||
}
|
|
||||||
if (kRGBA_GrColorComponentFlags == fInOut.validFlags()) {
|
if (kRGBA_GrColorComponentFlags == fInOut.validFlags()) {
|
||||||
fFirstEffectiveProcessorIndex = i + 1;
|
fFirstEffectiveProcessorIndex = i + 1;
|
||||||
fInputColor = fInOut.color();
|
fInputColor = fInOut.color();
|
||||||
fInputColorIsUsed = true;
|
|
||||||
// Since we are clearing all previous color stages we are in a state where we have found
|
// Since we are clearing all previous color stages we are in a state where we have found
|
||||||
// zero stages that don't multiply the inputColor.
|
// zero stages that don't multiply the inputColor.
|
||||||
fInOut.resetNonMulStageFound();
|
fInOut.resetNonMulStageFound();
|
||||||
|
@ -64,11 +64,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
int firstEffectiveProcessorIndex() const { return fFirstEffectiveProcessorIndex; }
|
int firstEffectiveProcessorIndex() const { return fFirstEffectiveProcessorIndex; }
|
||||||
|
|
||||||
/**
|
|
||||||
* True if the first effective processor reads its input, false otherwise.
|
|
||||||
*/
|
|
||||||
bool inputColorIsUsed() const { return fInputColorIsUsed; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If input color is used and per-vertex colors are not used, this is the input color to the
|
* If input color is used and per-vertex colors are not used, this is the input color to the
|
||||||
* first effective processor.
|
* first effective processor.
|
||||||
@ -79,7 +74,6 @@ private:
|
|||||||
void internalReset(GrColor color, GrColorComponentFlags colorFlags, bool isLCDCoverage) {
|
void internalReset(GrColor color, GrColorComponentFlags colorFlags, bool isLCDCoverage) {
|
||||||
fInOut.reset(color, colorFlags);
|
fInOut.reset(color, colorFlags);
|
||||||
fFirstEffectiveProcessorIndex = 0;
|
fFirstEffectiveProcessorIndex = 0;
|
||||||
fInputColorIsUsed = true;
|
|
||||||
fInputColor = color;
|
fInputColor = color;
|
||||||
fIsLCDCoverage = isLCDCoverage;
|
fIsLCDCoverage = isLCDCoverage;
|
||||||
}
|
}
|
||||||
@ -88,7 +82,6 @@ private:
|
|||||||
|
|
||||||
GrInvariantOutput fInOut;
|
GrInvariantOutput fInOut;
|
||||||
int fFirstEffectiveProcessorIndex = 0;
|
int fFirstEffectiveProcessorIndex = 0;
|
||||||
bool fInputColorIsUsed = true;
|
|
||||||
bool fIsLCDCoverage = false;
|
bool fIsLCDCoverage = false;
|
||||||
GrColor fInputColor = 0;
|
GrColor fInputColor = 0;
|
||||||
};
|
};
|
||||||
|
@ -64,8 +64,7 @@ private:
|
|||||||
|
|
||||||
void GrConstColorProcessor::onComputeInvariantOutput(GrInvariantOutput* inout) const {
|
void GrConstColorProcessor::onComputeInvariantOutput(GrInvariantOutput* inout) const {
|
||||||
if (kIgnore_InputMode == fMode) {
|
if (kIgnore_InputMode == fMode) {
|
||||||
inout->setToOther(kRGBA_GrColorComponentFlags, fColor.toGrColor(),
|
inout->setToOther(kRGBA_GrColorComponentFlags, fColor.toGrColor());
|
||||||
GrInvariantOutput::kWillNot_ReadInput);
|
|
||||||
} else {
|
} else {
|
||||||
float r = fColor.fRGBA[0];
|
float r = fColor.fRGBA[0];
|
||||||
bool colorIsSingleChannel = r == fColor.fRGBA[1] && r == fColor.fRGBA[2] &&
|
bool colorIsSingleChannel = r == fColor.fRGBA[1] && r == fColor.fRGBA[2] &&
|
||||||
|
@ -45,7 +45,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
void DitherEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
|
void DitherEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
|
||||||
inout->setToUnknown(GrInvariantOutput::kWill_ReadInput);
|
inout->setToUnknown();
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -109,7 +109,7 @@ bool GrGammaEffect::onIsEqual(const GrFragmentProcessor& s) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GrGammaEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
|
void GrGammaEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
|
||||||
inout->setToUnknown(GrInvariantOutput::kWill_ReadInput);
|
inout->setToUnknown();
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -42,7 +42,7 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
||||||
inout->setToUnknown(GrInvariantOutput::kWill_ReadInput);
|
inout->setToUnknown();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -197,20 +197,9 @@ protected:
|
|||||||
inout->color(), inout->validFlags(),
|
inout->color(), inout->validFlags(),
|
||||||
&blendColor, &blendFlags);
|
&blendColor, &blendFlags);
|
||||||
}
|
}
|
||||||
// will the shader code reference the input color?
|
inout->setToOther(blendFlags, blendColor);
|
||||||
GrInvariantOutput::ReadInput readsInput = GrInvariantOutput::kWillNot_ReadInput;
|
|
||||||
if (kDst_Child == fChild) {
|
|
||||||
if (kZero_GrBlendCoeff != srcCoeff || GrBlendCoeffRefsSrc(dstCoeff)) {
|
|
||||||
readsInput = GrInvariantOutput::kWill_ReadInput;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (kZero_GrBlendCoeff != dstCoeff || GrBlendCoeffRefsDst(srcCoeff)) {
|
|
||||||
readsInput = GrInvariantOutput::kWill_ReadInput;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
inout->setToOther(blendFlags, blendColor, readsInput);
|
|
||||||
} else {
|
} else {
|
||||||
inout->setToUnknown(GrInvariantOutput::kWill_ReadInput);
|
inout->setToUnknown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,8 +187,7 @@ private:
|
|||||||
|
|
||||||
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
||||||
// YUV is opaque
|
// YUV is opaque
|
||||||
inout->setToOther(kA_GrColorComponentFlag, 0xFF << GrColor_SHIFT_A,
|
inout->setToOther(kA_GrColorComponentFlag, 0xFF << GrColor_SHIFT_A);
|
||||||
GrInvariantOutput::kWillNot_ReadInput);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GrCoordTransform fYTransform;
|
GrCoordTransform fYTransform;
|
||||||
@ -348,7 +347,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
||||||
inout->setToUnknown(GrInvariantOutput::kWillNot_ReadInput);
|
inout->setToUnknown();
|
||||||
}
|
}
|
||||||
|
|
||||||
GrCoordTransform fTransform;
|
GrCoordTransform fTransform;
|
||||||
|
@ -132,8 +132,7 @@ private:
|
|||||||
bool onIsEqual(const GrFragmentProcessor&) const override { return true; }
|
bool onIsEqual(const GrFragmentProcessor&) const override { return true; }
|
||||||
|
|
||||||
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
||||||
inout->setToOther(kRGBA_GrColorComponentFlags, GrColor_WHITE,
|
inout->setToOther(kRGBA_GrColorComponentFlags, GrColor_WHITE);
|
||||||
GrInvariantOutput::kWillNot_ReadInput);
|
|
||||||
this->childProcessor(0).computeInvariantOutput(inout);
|
this->childProcessor(0).computeInvariantOutput(inout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageStorageLoad, reporter, ctxInfo) {
|
|||||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {}
|
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {}
|
||||||
|
|
||||||
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
||||||
inout->setToUnknown(GrInvariantOutput::kWillNot_ReadInput);
|
inout->setToUnknown();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool onIsEqual(const GrFragmentProcessor& that) const override { return true; }
|
bool onIsEqual(const GrFragmentProcessor& that) const override { return true; }
|
||||||
|
@ -64,7 +64,7 @@ public:
|
|||||||
|
|
||||||
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
|
||||||
// We don't care about optimizing these processors.
|
// We don't care about optimizing these processors.
|
||||||
inout->setToUnknown(GrInvariantOutput::kWill_ReadInput);
|
inout->setToUnknown();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user