'<(skia_include_path)/gpu/GrFragmentProcessor.h',
'<(skia_include_path)/gpu/GrGlyph.h',
'<(skia_include_path)/gpu/GrGpuResource.h',
+ '<(skia_include_path)/gpu/GrInvariantOutput.h',
'<(skia_include_path)/gpu/GrPaint.h',
'<(skia_include_path)/gpu/GrPathRendererChain.h',
'<(skia_include_path)/gpu/GrProcessor.h',
'<(skia_src_path)/gpu/GrGpuResource.cpp',
'<(skia_src_path)/gpu/GrGpuFactory.cpp',
'<(skia_src_path)/gpu/GrIndexBuffer.h',
+ '<(skia_src_path)/gpu/GrInvariantOutput.cpp',
'<(skia_src_path)/gpu/GrInOrderDrawBuffer.cpp',
'<(skia_src_path)/gpu/GrInOrderDrawBuffer.h',
'<(skia_src_path)/gpu/GrLayerCache.cpp',
--- /dev/null
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrInvariantOutput_DEFINED
+#define GrInvariantOutput_DEFINED
+
+#include "GrColor.h"
+
+class GrInvariantOutput {
+public:
+ GrInvariantOutput(GrColor color, GrColorComponentFlags flags, bool isSingleComponent)
+ : fColor(color), fValidFlags(flags), fIsSingleComponent(isSingleComponent),
+ fNonMulStageFound(false), fWillUseInputColor(true) {}
+
+ virtual ~GrInvariantOutput() {}
+
+ enum ReadInput {
+ kWill_ReadInput,
+ kWillNot_ReadInput,
+ };
+
+ void mulByUnknownOpaqueColor() {
+ if (this->isOpaque()) {
+ fValidFlags = kA_GrColorComponentFlag;
+ fIsSingleComponent = false;
+ } else {
+ // Since the current state is not opaque we no longer care if the color being
+ // multiplied is opaque.
+ this->mulByUnknownColor();
+ }
+ }
+
+ void mulByUnknownColor() {
+ if (this->hasZeroAlpha()) {
+ this->internalSetToTransparentBlack();
+ } else {
+ this->internalSetToUnknown();
+ }
+ }
+
+ void mulByUnknownAlpha() {
+ if (this->hasZeroAlpha()) {
+ this->internalSetToTransparentBlack();
+ } else {
+ // We don't need to change fIsSingleComponent in this case
+ fValidFlags = 0;
+ }
+ }
+
+ void mulByKnownAlpha(uint8_t alpha) {
+ if (this->hasZeroAlpha() || 0 == alpha) {
+ this->internalSetToTransparentBlack();
+ } else {
+ if (alpha != 255) {
+ // Multiply color by alpha
+ fColor = GrColorPackRGBA(SkMulDiv255Round(GrColorUnpackR(fColor), alpha),
+ SkMulDiv255Round(GrColorUnpackG(fColor), alpha),
+ SkMulDiv255Round(GrColorUnpackB(fColor), alpha),
+ SkMulDiv255Round(GrColorUnpackA(fColor), alpha));
+ }
+ }
+ }
+
+ void invalidateComponents(uint8_t invalidateFlags, ReadInput readsInput) {
+ fValidFlags &= ~invalidateFlags;
+ fIsSingleComponent = false;
+ fNonMulStageFound = true;
+ if (kWillNot_ReadInput == readsInput) {
+ fWillUseInputColor = false;
+ }
+ }
+
+ void setToOther(uint8_t validFlags, GrColor color, ReadInput readsInput) {
+ fValidFlags = validFlags;
+ fColor = color;
+ fIsSingleComponent = false;
+ fNonMulStageFound = true;
+ if (kWillNot_ReadInput == readsInput) {
+ fWillUseInputColor = false;
+ }
+ }
+
+ void setToUnknown(ReadInput readsInput) {
+ this->internalSetToUnknown();
+ fNonMulStageFound= true;
+ if (kWillNot_ReadInput == readsInput) {
+ fWillUseInputColor = false;
+ }
+ }
+
+ bool isOpaque() const {
+ return ((fValidFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpackA(fColor));
+ }
+
+ bool isSolidWhite() const {
+ return (fValidFlags == kRGBA_GrColorComponentFlags && 0xFFFFFFFF == fColor);
+ }
+
+ GrColor color() const { return fColor; }
+ uint8_t validFlags() const { return fValidFlags; }
+
+ bool willUseInputColor() const { return fWillUseInputColor; }
+ void resetWillUseInputColor() { fWillUseInputColor = true; }
+
+ void resetNonMulStageFound() { fNonMulStageFound = false; }
+
+ /**
+ * If isSingleComponent is true, then the flag values for r, g, b, and a must all be the
+ * same. If the flags are all set then all color components must be equal.
+ */
+ SkDEBUGCODE(void validate() const;)
+
+protected:
+ GrColor fColor;
+ uint32_t fValidFlags;
+ bool fIsSingleComponent;
+ bool fNonMulStageFound;
+ bool fWillUseInputColor;
+
+private:
+ void internalSetToTransparentBlack() {
+ fValidFlags = kRGBA_GrColorComponentFlags;
+ fColor = 0;
+ fIsSingleComponent = true;
+ }
+
+ void internalSetToUnknown() {
+ fValidFlags = 0;
+ fIsSingleComponent = false;
+ }
+
+ bool hasZeroAlpha() const {
+ return ((fValidFlags & kA_GrColorComponentFlag) && 0 == GrColorUnpackA(fColor));
+ }
+
+ SkDEBUGCODE(bool colorComponentsAllEqual() const;)
+ /**
+ * If alpha is valid, check that any valid R,G,B values are <= A
+ */
+ SkDEBUGCODE(bool validPreMulColor() const;)
+};
+
+#endif
+
class GrContext;
class GrCoordTransform;
+class GrInvariantOutput;
/** Provides custom shader code to the Ganesh shading pipeline. GrProcessor objects *must* be
immutable: after being constructed, their fields may not change.
virtual ~GrProcessor();
- struct InvariantOutput{
- InvariantOutput() : fColor(0), fValidFlags(0), fIsSingleComponent(false),
- fNonMulStageFound(false), fWillUseInputColor(true) {}
-
- enum ReadInput {
- kWill_ReadInput,
- kWillNot_ReadInput,
- };
-
- void mulByUnknownOpaqueColor() {
- if (this->isOpaque()) {
- fValidFlags = kA_GrColorComponentFlag;
- fIsSingleComponent = false;
- } else {
- // Since the current state is not opaque we no longer care if the color being
- // multiplied is opaque.
- this->mulByUnknownColor();
- }
- }
-
- void mulByUnknownColor() {
- if (this->hasZeroAlpha()) {
- this->internalSetToTransparentBlack();
- } else {
- this->internalSetToUnknown();
- }
- }
-
- void mulByUnknownAlpha() {
- if (this->hasZeroAlpha()) {
- this->internalSetToTransparentBlack();
- } else {
- // We don't need to change fIsSingleComponent in this case
- fValidFlags = 0;
- }
- }
-
- void mulByKnownAlpha(uint8_t alpha) {
- if (this->hasZeroAlpha() || 0 == alpha) {
- this->internalSetToTransparentBlack();
- } else {
- if (alpha != 255) {
- // Multiply color by alpha
- fColor = GrColorPackRGBA(SkMulDiv255Round(GrColorUnpackR(fColor), alpha),
- SkMulDiv255Round(GrColorUnpackG(fColor), alpha),
- SkMulDiv255Round(GrColorUnpackB(fColor), alpha),
- SkMulDiv255Round(GrColorUnpackA(fColor), alpha));
- }
- }
- }
-
- void invalidateComponents(uint8_t invalidateFlags, ReadInput readsInput) {
- fValidFlags &= ~invalidateFlags;
- fIsSingleComponent = false;
- if (kWillNot_ReadInput == readsInput) {
- fWillUseInputColor = false;
- }
- }
-
- void setToOther(uint8_t validFlags, GrColor color, ReadInput readsInput) {
- fValidFlags = validFlags;
- fColor = color;
- fIsSingleComponent = false;
- fNonMulStageFound = true;
- if (kWillNot_ReadInput == readsInput) {
- fWillUseInputColor = false;
- }
- }
-
- void setToUnknown(ReadInput readsInput) {
- this->internalSetToUnknown();
- fNonMulStageFound= true;
- if (kWillNot_ReadInput == readsInput) {
- fWillUseInputColor = false;
- }
- }
-
- bool isOpaque() const {
- return ((fValidFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpackA(fColor));
- }
-
- bool isSolidWhite() const {
- return (fValidFlags == kRGBA_GrColorComponentFlags && 0xFFFFFFFF == fColor);
- }
-
- GrColor color() const { return fColor; }
- uint8_t validFlags() const { return fValidFlags; }
-
- /**
- * If isSingleComponent is true, then the flag values for r, g, b, and a must all be the
- * same. If the flags are all set then all color components must be equal.
- */
- SkDEBUGCODE(void validate() const;)
-
- private:
- void internalSetToTransparentBlack() {
- fValidFlags = kRGBA_GrColorComponentFlags;
- fColor = 0;
- fIsSingleComponent = true;
- }
-
- void internalSetToUnknown() {
- fValidFlags = 0;
- fIsSingleComponent = false;
- }
-
- bool hasZeroAlpha() const {
- return ((fValidFlags & kA_GrColorComponentFlag) && 0 == GrColorUnpackA(fColor));
- }
-
- SkDEBUGCODE(bool colorComponentsAllEqual() const;)
- /**
- * If alpha is valid, check that any valid R,G,B values are <= A
- */
- SkDEBUGCODE(bool validPreMulColor() const;)
-
- // Friended class that have "controller" code which loop over stages calling
- // computeInvarianteOutput(). These controllers may need to manually adjust the internal
- // members of InvariantOutput
- friend class GrDrawState;
- friend class GrOptDrawState;
- friend class GrPaint;
- friend class GrProcessor;
-
- GrColor fColor;
- uint32_t fValidFlags;
- bool fIsSingleComponent;
- bool fNonMulStageFound;
- bool fWillUseInputColor;
- };
-
/**
* This function is used to perform optimizations. When called the invarientOuput param
* indicate whether the input components to this processor in the FS will have known values.
* inout to indicate known values of its output. A component of the color member only has
* meaning if the corresponding bit in validFlags is set.
*/
- void computeInvariantOutput(InvariantOutput* inout) const {
- inout->fWillUseInputColor = true;
- this->onComputeInvariantOutput(inout);
-#ifdef SK_DEBUG
- inout->validate();
-#endif
- }
+ void computeInvariantOutput(GrInvariantOutput* inout) const;
/** This object, besides creating back-end-specific helper objects, is used for run-time-type-
identification. The factory should be an instance of templated class,
void setWillReadFragmentPosition() { fWillReadFragmentPosition = true; }
private:
-
/**
* Subclass implements this to support getConstantColorComponents(...).
*/
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const = 0;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const = 0;
SkSTArray<4, const GrTextureAccess*, true> fTextureAccesses;
bool fWillReadFragmentPosition;
#include "GrFragmentProcessor.h"
#include "GrCoordTransform.h"
+#include "GrInvariantOutput.h"
#include "GrProcessorUnitTest.h"
#include "GrTBackendProcessorFactory.h"
#include "gl/GrGLProcessor.h"
return fMode == s.fMode;
}
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE {
- inout->setToUnknown(InvariantOutput::kWill_ReadInput);
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE {
+ inout->setToUnknown(GrInvariantOutput::kWill_ReadInput);
}
SkXfermode::Mode fMode;
#include "GrContext.h"
#include "GrCoordTransform.h"
#include "GrFragmentProcessor.h"
+#include "GrInvariantOutput.h"
#include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "GrTBackendProcessorFactory.h"
virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
this->fOuterThreshold == s.fOuterThreshold);
}
-void AlphaThresholdEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
+void AlphaThresholdEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
if (GrPixelConfigIsOpaque(this->texture(0)->config()) && fOuterThreshold >= 1.f) {
inout->mulByUnknownOpaqueColor();
} else {
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrCoordTransform.h"
+#include "GrInvariantOutput.h"
#include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "GrTBackendProcessorFactory.h"
private:
virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
GrArithmeticEffect(float k1, float k2, float k3, float k4, bool enforcePMColor,
GrTexture* background);
return GrTBackendFragmentProcessorFactory<GrArithmeticEffect>::getInstance();
}
-void GrArithmeticEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
+void GrArithmeticEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
// TODO: optimize this
- inout->setToUnknown(InvariantOutput::kWill_ReadInput);
+ inout->setToUnknown(GrInvariantOutput::kWill_ReadInput);
}
///////////////////////////////////////////////////////////////////////////////
#include "GrContext.h"
#include "GrTexture.h"
#include "GrFragmentProcessor.h"
+#include "GrInvariantOutput.h"
#include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "effects/GrSimpleTextureEffect.h"
GrRectBlurEffect(const SkRect& rect, float sigma, GrTexture *blur_profile);
virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
static bool CreateBlurProfileTexture(GrContext *context, float sigma,
GrTexture **blurProfileTexture);
return this->getSigma() == s.getSigma() && this->getRect() == s.getRect();
}
-void GrRectBlurEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
+void GrRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
inout->mulByUnknownAlpha();
}
virtual bool onIsEqual(const GrFragmentProcessor& other) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
SkRRect fRRect;
float fSigma;
return SkNEW_ARGS(GrRRectBlurEffect, (sigma, rrect, blurNinePatchTexture));
}
-void GrRRectBlurEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
+void GrRRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
inout->mulByUnknownAlpha();
}
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrCoordTransform.h"
+#include "GrInvariantOutput.h"
#include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "GrTBackendProcessorFactory.h"
///////////////////////////////////////////////////////////////////////////////
#if SK_SUPPORT_GPU
+
class GrColorCubeEffect : public GrFragmentProcessor {
public:
static GrFragmentProcessor* Create(GrTexture* colorCube) {
static const char* Name() { return "ColorCube"; }
- virtual void onComputeInvariantOutput(GrProcessor::InvariantOutput*) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput*) const SK_OVERRIDE;
class GLProcessor : public GrGLFragmentProcessor {
public:
return GrTBackendFragmentProcessorFactory<GrColorCubeEffect>::getInstance();
}
-void GrColorCubeEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
- inout->setToUnknown(InvariantOutput::kWill_ReadInput);
+void GrColorCubeEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
+ inout->setToUnknown(GrInvariantOutput::kWill_ReadInput);
}
///////////////////////////////////////////////////////////////////////////////
#if SK_SUPPORT_GPU
#include "GrBlend.h"
#include "GrFragmentProcessor.h"
+#include "GrInvariantOutput.h"
#include "GrProcessorUnitTest.h"
#include "GrTBackendProcessorFactory.h"
#include "gl/GrGLProcessor.h"
return fMode == s.fMode && fColor == s.fColor;
}
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
SkXfermode::Mode fMode;
GrColor fColor;
}
-void ModeColorFilterEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
+void ModeColorFilterEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
float inputColor[4];
GrColorToRGBAFloat(inout->color(), inputColor);
float filterColor[4];
SkXfermode::Coeff dstCoeff;
SkXfermode::Coeff srcCoeff;
SkAssertResult(SkXfermode::ModeAsCoeff(fMode, &srcCoeff, &dstCoeff));
- InvariantOutput::ReadInput readInput = InvariantOutput::kWill_ReadInput;
+ GrInvariantOutput::ReadInput readInput = GrInvariantOutput::kWill_ReadInput;
// These could be calculated from the blend equation with template trickery..
if (SkXfermode::kZero_Coeff == dstCoeff &&
!GrBlendCoeffRefsDst(sk_blend_to_grblend(srcCoeff))) {
- readInput = InvariantOutput::kWillNot_ReadInput;
+ readInput = GrInvariantOutput::kWillNot_ReadInput;
}
inout->setToOther(result.getValidComponents(), result.getColor(), readInput);
}
#if SK_SUPPORT_GPU
#include "GrFragmentProcessor.h"
+#include "GrInvariantOutput.h"
#include "GrTBackendProcessorFactory.h"
#include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
return cme.fMatrix == fMatrix;
}
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE {
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE {
// We only bother to check whether the alpha channel will be constant. If SkColorMatrix had
// type flags it might be worth checking the other components.
// then we can't know the final result.
if (0 != fMatrix.fMat[kAlphaRowStartIdx + i]) {
if (!(inout->validFlags() & kRGBAFlags[i])) {
- inout->setToUnknown(InvariantOutput::kWill_ReadInput);
+ inout->setToUnknown(GrInvariantOutput::kWill_ReadInput);
return;
} else {
uint32_t component = (inout->color() >> kShifts[i]) & 0xFF;
// result if the matrix could over/underflow for any component?
inout->setToOther(kA_GrColorComponentFlag,
static_cast<uint8_t>(SkScalarPin(outputA, 0, 255)) << GrColor_SHIFT_A,
- InvariantOutput::kWill_ReadInput);
+ GrInvariantOutput::kWill_ReadInput);
}
SkColorMatrix fMatrix;
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrCoordTransform.h"
+#include "GrInvariantOutput.h"
#include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "GrTBackendProcessorFactory.h"
private:
virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
GrDisplacementMapEffect(SkDisplacementMapEffect::ChannelSelectorType xChannelSelector,
SkDisplacementMapEffect::ChannelSelectorType yChannelSelector,
return GrTBackendFragmentProcessorFactory<GrDisplacementMapEffect>::getInstance();
}
-void GrDisplacementMapEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
+void GrDisplacementMapEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
// Any displacement offset bringing a pixel out of bounds will output a color of (0,0,0,0),
// so the only way we'd get a constant alpha is if the input color image has a constant alpha
// 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
// not of constant color when a displacement effect is applied.
- inout->setToUnknown(InvariantOutput::kWillNot_ReadInput);
+ inout->setToUnknown(GrInvariantOutput::kWillNot_ReadInput);
}
///////////////////////////////////////////////////////////////////////////////
#include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "GrFragmentProcessor.h"
+#include "GrInvariantOutput.h"
#include "GrTBackendProcessorFactory.h"
class GrGLDiffuseLightingEffect;
protected:
virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE {
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE {
// lighting shaders are complicated. We just throw up our hands.
inout->mulByUnknownColor();
}
#include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "GrContext.h"
+#include "GrInvariantOutput.h"
#include "GrTBackendProcessorFactory.h"
#endif
private:
virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE { return true; }
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE {
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE {
// The output is always black. The alpha value for the color passed in is arbitrary.
inout->setToOther(kRGB_GrColorComponentFlags, GrColorPackRGBA(0, 0, 0, 0),
- InvariantOutput::kWill_ReadInput);
+ GrInvariantOutput::kWill_ReadInput);
}
};
#include "gl/builders/GrGLProgramBuilder.h"
#include "gl/GrGLSL.h"
#include "gl/GrGLTexture.h"
+#include "GrInvariantOutput.h"
#include "GrTBackendProcessorFactory.h"
class GrGLMagnifierEffect;
virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
this->fYInvInset == s.fYInvInset);
}
-void GrMagnifierEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
+void GrMagnifierEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
this->updateInvariantOutputForModulation(inout);
}
#include "SkMorphology_opts.h"
#if SK_SUPPORT_GPU
#include "GrContext.h"
+#include "GrInvariantOutput.h"
#include "GrTexture.h"
#include "GrTBackendProcessorFactory.h"
#include "gl/GrGLProcessor.h"
private:
virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
GrMorphologyEffect(GrTexture*, Direction, int radius, MorphologyType);
this->type() == s.type());
}
-void GrMorphologyEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
+void GrMorphologyEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
// This is valid because the color components of the result of the kernel all come
// exactly from existing values in the source texture.
this->updateInvariantOutputForModulation(inout);
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrCoordTransform.h"
+#include "GrInvariantOutput.h"
#include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "GrTBackendProcessorFactory.h"
fPaintingData->fStitchDataInit == s.fPaintingData->fStitchDataInit;
}
- void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE {
- inout->setToUnknown(InvariantOutput::kWillNot_ReadInput);
+ void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE {
+ inout->setToUnknown(GrInvariantOutput::kWillNot_ReadInput);
}
GrPerlinNoiseEffect(SkPerlinNoiseShader::Type type,
#if SK_SUPPORT_GPU
#include "GrFragmentProcessor.h"
+#include "GrInvariantOutput.h"
#include "GrTBackendProcessorFactory.h"
#include "SkGr.h"
#include "effects/GrTextureStripAtlas.h"
private:
virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
ColorTableEffect(GrTexture* texture, GrTextureStripAtlas* atlas, int row, unsigned flags);
return fRow == that.fRow;
}
-void ColorTableEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
+void ColorTableEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
// If we kept the table in the effect then we could actually run known inputs through the
// table.
uint8_t invalidateFlags = 0;
if (fFlags & SkTable_ColorFilter::kA_Flag) {
invalidateFlags |= kA_GrColorComponentFlag;
}
- inout->invalidateComponents(invalidateFlags, InvariantOutput::kWill_ReadInput);
+ inout->invalidateComponents(invalidateFlags, GrInvariantOutput::kWill_ReadInput);
}
///////////////////////////////////////////////////////////////////////////////
#if SK_SUPPORT_GPU
#include "effects/GrTextureStripAtlas.h"
+#include "GrInvariantOutput.h"
#include "GrTBackendProcessorFactory.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "SkGr.h"
return false;
}
-void GrGradientEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
+void GrGradientEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
if (fIsOpaque) {
inout->mulByUnknownOpaqueColor();
} else {
class GrFragmentStage;
class GrBackendProcessorFactory;
+class GrInvariantOutput;
/*
* The interpretation of the texture matrix depends on the sample mode. The
virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
const GrCoordTransform& getCoordTransform() const { return fCoordTransform; }
#include "GrContext.h"
#include "GrDrawState.h"
#include "GrDrawTargetCaps.h"
+#include "GrInvariantOutput.h"
#include "GrProcessor.h"
#include "GrPathUtils.h"
#include "GrTBackendProcessorFactory.h"
return true;
}
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE {
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE {
inout->mulByUnknownAlpha();
}
#include "GrAARectRenderer.h"
#include "GrGpu.h"
+#include "GrInvariantOutput.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "gl/GrGLProcessor.h"
#include "gl/GrGLGeometryProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "gl/GrGLGeometryProcessor.h"
#include "GrDrawState.h"
+#include "GrInvariantOutput.h"
#include "GrTBackendProcessorFactory.h"
/*
return true;
}
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE {
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE {
inout->mulByUnknownAlpha();
}
#include "GrDrawState.h"
+#include "GrInvariantOutput.h"
#include "GrOptDrawState.h"
#include "GrPaint.h"
return false;
}
- GrProcessor::InvariantOutput inout;
- inout.fIsSingleComponent = true;
+ GrColor color;
+ GrColorComponentFlags flags;
// Initialize to an unknown starting coverage if per-vertex coverage is specified.
if (this->hasCoverageVertexAttribute()) {
- inout.fValidFlags = 0;
+ color = 0;
+ flags = static_cast<GrColorComponentFlags>(0);
} else {
- inout.fColor = this->getCoverageColor();
- inout.fValidFlags = kRGBA_GrColorComponentFlags;
+ color = this->getCoverageColor();
+ flags = kRGBA_GrColorComponentFlags;
}
+ GrInvariantOutput inout(color, flags, true);
// check the coverage output from the GP
if (this->hasGeometryProcessor()) {
bool GrDrawState::srcAlphaWillBeOne() const {
- GrProcessor::InvariantOutput inoutColor;
- inoutColor.fIsSingleComponent = false;
+ GrColor color;
+ GrColorComponentFlags flags;
// Check if per-vertex or constant color may have partial alpha
if (this->hasColorVertexAttribute()) {
if (fHints & kVertexColorsAreOpaque_Hint) {
- inoutColor.fValidFlags = kA_GrColorComponentFlag;
- inoutColor.fColor = 0xFF << GrColor_SHIFT_A;
+ flags = kA_GrColorComponentFlag;
+ color = 0xFF << GrColor_SHIFT_A;
} else {
- inoutColor.fValidFlags = 0;
- // not strictly necessary but we get false alarms from tools about uninit.
- inoutColor.fColor = 0;
+ flags = static_cast<GrColorComponentFlags>(0);
+ color = 0;
}
} else {
- inoutColor.fValidFlags = kRGBA_GrColorComponentFlags;
- inoutColor.fColor = this->getColor();
+ flags = kRGBA_GrColorComponentFlags;
+ color = this->getColor();
}
+ GrInvariantOutput inoutColor(color, flags, false);
// Run through the color stages
for (int s = 0; s < this->numColorStages(); ++s) {
if (this->isCoverageDrawing()) {
// 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.
- GrProcessor::InvariantOutput inoutCoverage;
- inoutCoverage.fIsSingleComponent = true;
if (this->hasCoverageVertexAttribute()) {
- inoutCoverage.fValidFlags = 0;
- inoutCoverage.fColor = 0; // suppresses any warnings.
+ flags = static_cast<GrColorComponentFlags>(0);
+ color = 0;
} else {
- inoutCoverage.fValidFlags = kRGBA_GrColorComponentFlags;
- inoutCoverage.fColor = this->getCoverageColor();
+ flags = kRGBA_GrColorComponentFlags;
+ color = this->getCoverageColor();
}
+ GrInvariantOutput inoutCoverage(color, flags, true);
if (this->hasGeometryProcessor()) {
fGeometryProcessor->computeInvariantOutput(&inoutCoverage);
--- /dev/null
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GrInvariantOutput.h"
+
+#ifdef SK_DEBUG
+
+void GrInvariantOutput::validate() const {
+ if (fIsSingleComponent) {
+ SkASSERT(0 == fValidFlags || kRGBA_GrColorComponentFlags == fValidFlags);
+ if (kRGBA_GrColorComponentFlags == fValidFlags) {
+ SkASSERT(this->colorComponentsAllEqual());
+ }
+ }
+
+ SkASSERT(this->validPreMulColor());
+
+ // If we claim that we are not using the input color we must not be modulating the input.
+ SkASSERT(fNonMulStageFound || fWillUseInputColor);
+}
+
+bool GrInvariantOutput::colorComponentsAllEqual() const {
+ unsigned colorA = GrColorUnpackA(fColor);
+ return(GrColorUnpackR(fColor) == colorA &&
+ GrColorUnpackG(fColor) == colorA &&
+ GrColorUnpackB(fColor) == colorA);
+}
+
+bool GrInvariantOutput::validPreMulColor() const {
+ if (kA_GrColorComponentFlag & fValidFlags) {
+ float c[4];
+ GrColorToRGBAFloat(fColor, c);
+ if (kR_GrColorComponentFlag & fValidFlags) {
+ if (c[0] > c[3]) {
+ return false;
+ }
+ }
+ if (kG_GrColorComponentFlag & fValidFlags) {
+ if (c[1] > c[3]) {
+ return false;
+ }
+ }
+ if (kB_GrColorComponentFlag & fValidFlags) {
+ if (c[2] > c[3]) {
+ return false;
+ }
+ }
+ }
+ return true;
+}
+#endif // end DEBUG
+
#include "GrDrawState.h"
#include "GrDrawTargetCaps.h"
#include "GrGpu.h"
+#include "GrInvariantOutput.h"
GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
BlendOptFlags blendOptFlags,
int* firstColorStageIdx,
uint8_t* fixedFunctionVAToRemove) {
// Set up color and flags for ConstantColorComponent checks
- GrProcessor::InvariantOutput inout;
- inout.fIsSingleComponent = false;
+ GrColor color;
+ GrColorComponentFlags flags;
if (!descInfo->hasColorVertexAttribute()) {
- inout.fColor = ds.getColor();
- inout.fValidFlags = kRGBA_GrColorComponentFlags;
+ color = ds.getColor();
+ flags = kRGBA_GrColorComponentFlags;
} else {
if (ds.vertexColorsAreOpaque()) {
- inout.fColor = 0xFF << GrColor_SHIFT_A;
- inout.fValidFlags = kA_GrColorComponentFlag;
+ color = 0xFF << GrColor_SHIFT_A;
+ flags = kA_GrColorComponentFlag;
} else {
- inout.fValidFlags = 0;
+ flags = static_cast<GrColorComponentFlags>(0);
// not strictly necessary but we get false alarms from tools about uninit.
- inout.fColor = 0;
+ color = 0;
}
}
+ GrInvariantOutput inout(color, flags, false);
for (int i = 0; i < ds.numColorStages(); ++i) {
const GrFragmentProcessor* fp = ds.getColorStage(i).getProcessor();
fp->computeInvariantOutput(&inout);
- if (!inout.fWillUseInputColor) {
+ if (!inout.willUseInputColor()) {
*firstColorStageIdx = i;
descInfo->fInputColorIsUsed = false;
}
- if (kRGBA_GrColorComponentFlags == inout.fValidFlags) {
+ if (kRGBA_GrColorComponentFlags == inout.validFlags()) {
*firstColorStageIdx = i + 1;
- fColor = inout.fColor;
+ fColor = inout.color();
descInfo->fInputColorIsUsed = true;
*fixedFunctionVAToRemove |= 0x1 << kColor_GrVertexAttribBinding;
// 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.
- inout.fNonMulStageFound = false;
+ inout.resetNonMulStageFound();
}
}
}
// Don't do any optimizations on coverage stages. It should not be the case where we do not use
// input coverage in an effect
#ifdef OptCoverageStages
- GrProcessor::InvariantOutput inout;
+ GrInvariantOutput inout;
for (int i = 0; i < ds.numCoverageStages(); ++i) {
const GrFragmentProcessor* fp = ds.getCoverageStage(i).getProcessor();
fp->computeInvariantOutput(&inout);
#include "GrDrawState.h"
#include "GrDrawTarget.h"
#include "GrGpu.h"
+#include "GrInvariantOutput.h"
#include "SkRRect.h"
#include "SkStrokeRec.h"
return cee.fStroke == fStroke;
}
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE {
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE {
inout->mulByUnknownAlpha();
}
return eee.fStroke == fStroke;
}
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE {
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE {
inout->mulByUnknownAlpha();
}
return eee.fMode == fMode;
}
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE {
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE {
inout->mulByUnknownAlpha();
}
#include "GrPaint.h"
#include "GrBlend.h"
+#include "GrInvariantOutput.h"
#include "effects/GrSimpleTextureEffect.h"
void GrPaint::addColorTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
// TODO: Share this implementation with GrDrawState
- GrProcessor::InvariantOutput inout;
- inout.fColor = 0xFFFFFFFF;
- inout.fValidFlags = kRGBA_GrColorComponentFlags;
- inout.fIsSingleComponent = true;
+ GrInvariantOutput inoutCoverage(0xFFFFFFFF,
+ kRGBA_GrColorComponentFlags,
+ true);
int count = fCoverageStages.count();
for (int i = 0; i < count; ++i) {
- fCoverageStages[i].getProcessor()->computeInvariantOutput(&inout);
+ fCoverageStages[i].getProcessor()->computeInvariantOutput(&inoutCoverage);
}
- if (!inout.isSolidWhite()) {
+ if (!inoutCoverage.isSolidWhite()) {
return false;
}
- inout.fColor = fColor;
- inout.fValidFlags = kRGBA_GrColorComponentFlags;
- inout.fIsSingleComponent = false;
+ GrInvariantOutput inout(fColor, kRGBA_GrColorComponentFlags, false);
count = fColorStages.count();
for (int i = 0; i < count; ++i) {
fColorStages[i].getProcessor()->computeInvariantOutput(&inout);
GrBlendCoeff srcCoeff = fSrcBlendCoeff;
GrBlendCoeff dstCoeff = fDstBlendCoeff;
- GrSimplifyBlend(&srcCoeff, &dstCoeff, inout.fColor, inout.fValidFlags,
+ GrSimplifyBlend(&srcCoeff, &dstCoeff, inout.color(), inout.validFlags(),
0, 0, 0);
bool opaque = kZero_GrBlendCoeff == dstCoeff && !GrBlendCoeffRefsDst(srcCoeff);
break;
case kOne_GrBlendCoeff:
- *solidColor = inout.fColor;
- *solidColorKnownComponents = inout.fValidFlags;
+ *solidColor = inout.color();
+ *solidColorKnownComponents = inout.validFlags();
break;
// The src coeff should never refer to the src and if it refers to dst then opaque
#include "GrBackendProcessorFactory.h"
#include "GrContext.h"
#include "GrCoordTransform.h"
+#include "GrInvariantOutput.h"
#include "GrMemoryPool.h"
#include "SkTLS.h"
return true;
}
+void GrProcessor::computeInvariantOutput(GrInvariantOutput* inout) const {
+ inout->resetWillUseInputColor();
+ this->onComputeInvariantOutput(inout);
#ifdef SK_DEBUG
-
-void GrProcessor::InvariantOutput::validate() const {
- if (fIsSingleComponent) {
- SkASSERT(0 == fValidFlags || kRGBA_GrColorComponentFlags == fValidFlags);
- if (kRGBA_GrColorComponentFlags == fValidFlags) {
- SkASSERT(this->colorComponentsAllEqual());
- }
- }
-
- SkASSERT(this->validPreMulColor());
-
- // If we claim that we are not using the input color we must not be modulating the input.
- SkASSERT(fNonMulStageFound || fWillUseInputColor);
-}
-
-bool GrProcessor::InvariantOutput::colorComponentsAllEqual() const {
- unsigned colorA = GrColorUnpackA(fColor);
- return(GrColorUnpackR(fColor) == colorA &&
- GrColorUnpackG(fColor) == colorA &&
- GrColorUnpackB(fColor) == colorA);
-}
-
-bool GrProcessor::InvariantOutput::validPreMulColor() const {
- if (kA_GrColorComponentFlag & fValidFlags) {
- float c[4];
- GrColorToRGBAFloat(fColor, c);
- if (kR_GrColorComponentFlag & fValidFlags) {
- if (c[0] > c[3]) {
- return false;
- }
- }
- if (kG_GrColorComponentFlag & fValidFlags) {
- if (c[1] > c[3]) {
- return false;
- }
- }
- if (kB_GrColorComponentFlag & fValidFlags) {
- if (c[2] > c[3]) {
- return false;
- }
- }
- }
- return true;
+ inout->validate();
+#endif
}
-#endif // end DEBUG
///////////////////////////////////////////////////////////////////////////////////////////////////
#include "GrDrawTargetCaps.h"
#include "GrProcessor.h"
#include "GrGeometryProcessor.h"
+#include "GrInvariantOutput.h"
#include "GrTypesPriv.h"
/**
virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE {
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE {
inout->mulByUnknownAlpha();
}
virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE {
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE {
inout->mulByUnknownAlpha();
}
virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE {
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE {
inout->mulByUnknownAlpha();
}
#include "gl/builders/GrGLProgramBuilder.h"
#include "GrBicubicEffect.h"
-
+#include "GrInvariantOutput.h"
#define DS(x) SkDoubleToScalar(x)
fDomain == s.fDomain;
}
-void GrBicubicEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
+void GrBicubicEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
// FIXME: Perhaps we can do better.
inout->mulByUnknownAlpha();
}
#include "GrTBackendProcessorFactory.h"
class GrGLBicubicEffect;
+class GrInvariantOutput;
class GrBicubicEffect : public GrSingleTextureEffect {
public:
const SkMatrix &matrix, const SkRect& domain);
virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
float fCoefficients[16];
GrTextureDomain fDomain;
#include "GrConfigConversionEffect.h"
#include "GrContext.h"
+#include "GrInvariantOutput.h"
#include "GrTBackendProcessorFactory.h"
#include "GrSimpleTextureEffect.h"
#include "gl/GrGLProcessor.h"
other.fPMConversion == fPMConversion;
}
-void GrConfigConversionEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
+void GrConfigConversionEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
this->updateInvariantOutputForModulation(inout);
}
class GrFragmentStage;
class GrGLConfigConversionEffect;
+class GrInvariantOutput;
/**
* This class is used to perform config conversions. Clients may want to read/write data that is
virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
bool fSwapRedAndBlue;
PMConversion fPMConversion;
#include "gl/builders/GrGLProgramBuilder.h"
#include "GrConvexPolyEffect.h"
-
+#include "GrInvariantOutput.h"
#include "gl/GrGLProcessor.h"
#include "gl/GrGLSL.h"
#include "GrTBackendProcessorFactory.h"
return fRect == aare.fRect;
}
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE {
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE {
if (fRect.isEmpty()) {
// An empty rect will have no coverage anywhere.
inout->mulByKnownAlpha(0);
GrConvexPolyEffect::~GrConvexPolyEffect() {}
-void GrConvexPolyEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
+void GrConvexPolyEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
inout->mulByUnknownAlpha();
}
#include "GrTypesPriv.h"
class GrGLConvexPolyEffect;
+class GrInvariantOutput;
class SkPath;
/**
virtual bool onIsEqual(const GrFragmentProcessor& other) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
GrPrimitiveEdgeType fEdgeType;
int fEdgeCount;
#define GrConvolutionEffect_DEFINED
#include "Gr1DKernelEffect.h"
+#include "GrInvariantOutput.h"
class GrGLConvolutionEffect;
virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const {
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const {
// If the texture was opaque we could know that the output color if we knew the sum of the
// kernel values.
inout->mulByUnknownColor();
*/
#include "GrCustomCoordsTextureEffect.h"
+#include "GrInvariantOutput.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "gl/GrGLProcessor.h"
#include "gl/GrGLSL.h"
return true;
}
-void GrCustomCoordsTextureEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
+void GrCustomCoordsTextureEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
if (GrPixelConfigIsOpaque(this->texture(0)->config())) {
inout->mulByUnknownOpaqueColor();
} else {
#include "GrGeometryProcessor.h"
class GrGLCustomCoordsTextureEffect;
+class GrInvariantOutput;
/**
* The output color of this effect is a modulation of the input color and a sample from a texture.
virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
GrTextureAccess fTextureAccess;
const GrShaderVar& fInTextureCoords;
#include "GrCoordTransform.h"
#include "GrDrawTarget.h"
#include "GrDrawTargetCaps.h"
+#include "GrInvariantOutput.h"
#include "GrProcessor.h"
#include "GrGpu.h"
#include "GrStrokeInfo.h"
virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
GrPrimitiveEdgeType fEdgeType;
const GrShaderVar& fInCoord;
DashingCircleEffect::~DashingCircleEffect() {}
-void DashingCircleEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
+void DashingCircleEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
inout->mulByUnknownAlpha();
}
virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
GrPrimitiveEdgeType fEdgeType;
const GrShaderVar& fInCoord;
DashingLineEffect::~DashingLineEffect() {}
-void DashingLineEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
+void DashingLineEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
inout->mulByUnknownAlpha();
}
*/
#include "GrDistanceFieldTextureEffect.h"
+#include "GrInvariantOutput.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "gl/GrGLProcessor.h"
#include "gl/GrGLSL.h"
fFlags == cte.fFlags;
}
-void GrDistanceFieldTextureEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
+void GrDistanceFieldTextureEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
inout->mulByUnknownAlpha();
}
return fFlags == cte.fFlags;
}
-void GrDistanceFieldNoGammaTextureEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
+void GrDistanceFieldNoGammaTextureEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
inout->mulByUnknownAlpha();
}
fFlags == cte.fFlags);
}
-void GrDistanceFieldLCDTextureEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
+void GrDistanceFieldLCDTextureEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
inout->mulByUnknownColor();
}
class GrGLDistanceFieldTextureEffect;
class GrGLDistanceFieldNoGammaTextureEffect;
class GrGLDistanceFieldLCDTextureEffect;
+class GrInvariantOutput;
enum GrDistanceFieldEffectFlags {
kSimilarity_DistanceFieldEffectFlag = 0x01, // ctm is similarity matrix
virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
GrTextureAccess fTextureAccess;
#ifdef SK_GAMMA_APPLY_TO_A8
virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
GrTextureAccess fTextureAccess;
uint32_t fFlags;
virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
GrTextureAccess fTextureAccess;
GrTextureAccess fGammaTextureAccess;
#include "gl/builders/GrGLProgramBuilder.h"
#include "GrDitherEffect.h"
-
+#include "GrInvariantOutput.h"
#include "gl/GrGLProcessor.h"
#include "gl/GrGLSL.h"
#include "GrTBackendProcessorFactory.h"
// All dither effects are equal
virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE { return true; }
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
typedef GrFragmentProcessor INHERITED;
};
-void DitherEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
- inout->setToUnknown(InvariantOutput::kWill_ReadInput);
+void DitherEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
+ inout->setToUnknown(GrInvariantOutput::kWill_ReadInput);
}
//////////////////////////////////////////////////////////////////////////////
#define GrMatrixConvolutionEffect_DEFINED
#include "GrSingleTextureEffect.h"
+#include "GrInvariantOutput.h"
#include "GrTextureDomain.h"
// A little bit less than the minimum # uniforms required by DX9SM2 (32).
virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE {
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE {
// TODO: Try to do better?
inout->mulByUnknownColor();
}
#include "gl/builders/GrGLProgramBuilder.h"
#include "GrOvalEffect.h"
-
+#include "GrInvariantOutput.h"
#include "gl/GrGLProcessor.h"
#include "gl/GrGLSL.h"
#include "GrTBackendProcessorFactory.h"
virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
SkPoint fCenter;
SkScalar fRadius;
return SkNEW_ARGS(CircleEffect, (edgeType, center, radius));
}
-void CircleEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
+void CircleEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
inout->mulByUnknownAlpha();
}
virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
SkPoint fCenter;
SkVector fRadii;
return SkNEW_ARGS(EllipseEffect, (edgeType, center, rx, ry));
}
-void EllipseEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
+void EllipseEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
inout->mulByUnknownAlpha();
}
#include "gl/GrGLProcessor.h"
#include "gl/GrGLSL.h"
#include "GrConvexPolyEffect.h"
+#include "GrInvariantOutput.h"
#include "GrOvalEffect.h"
#include "GrTBackendProcessorFactory.h"
virtual bool onIsEqual(const GrFragmentProcessor& other) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
SkRRect fRRect;
GrPrimitiveEdgeType fEdgeType;
return SkNEW_ARGS(CircularRRectEffect, (edgeType, circularCornerFlags, rrect));
}
-void CircularRRectEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
+void CircularRRectEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
inout->mulByUnknownAlpha();
}
virtual bool onIsEqual(const GrFragmentProcessor& other) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
SkRRect fRRect;
GrPrimitiveEdgeType fEdgeType;
return SkNEW_ARGS(EllipticalRRectEffect, (edgeType, rrect));
}
-void EllipticalRRectEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
+void EllipticalRRectEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
inout->mulByUnknownAlpha();
}
* found in the LICENSE file.
*/
-#include "gl/builders/GrGLProgramBuilder.h"
#include "GrSimpleTextureEffect.h"
+#include "GrInvariantOutput.h"
+#include "GrTBackendProcessorFactory.h"
+#include "GrTexture.h"
#include "gl/GrGLProcessor.h"
#include "gl/GrGLSL.h"
#include "gl/GrGLTexture.h"
-#include "GrTBackendProcessorFactory.h"
-#include "GrTexture.h"
+#include "gl/builders/GrGLProgramBuilder.h"
class GrGLSimpleTextureEffect : public GrGLFragmentProcessor {
public:
///////////////////////////////////////////////////////////////////////////////
-void GrSimpleTextureEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
+void GrSimpleTextureEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
this->updateInvariantOutputForModulation(inout);
}
#include "GrSingleTextureEffect.h"
class GrGLSimpleTextureEffect;
+class GrInvariantOutput;
/**
* The output color of this effect is a modulation of the input color and a sample from a texture.
virtual bool onIsEqual(const GrFragmentProcessor& other) const SK_OVERRIDE { return true; }
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
#define GrSingleTextureEffect_DEFINED
#include "GrFragmentProcessor.h"
-#include "SkMatrix.h"
#include "GrCoordTransform.h"
+#include "GrInvariantOutput.h"
+#include "SkMatrix.h"
class GrTexture;
* the subclass output color will be a modulation of the input color with a value read from the
* texture.
*/
- void updateInvariantOutputForModulation(InvariantOutput* inout) const {
+ void updateInvariantOutputForModulation(GrInvariantOutput* inout) const {
if (GrPixelConfigIsOpaque(this->texture(0)->config())) {
inout->mulByUnknownOpaqueColor();
} else {
#include "gl/builders/GrGLProgramBuilder.h"
#include "GrTextureDomain.h"
+#include "GrInvariantOutput.h"
#include "GrSimpleTextureEffect.h"
#include "GrTBackendProcessorFactory.h"
#include "gl/GrGLProcessor.h"
return this->fTextureDomain == s.fTextureDomain;
}
-void GrTextureDomainEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
+void GrTextureDomainEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
if (GrTextureDomain::kDecal_Mode == fTextureDomain.mode()) { // TODO: helper
inout->mulByUnknownColor();
} else {
class GrGLProgramBuilder;
class GrGLShaderBuilder;
+class GrInvariantOutput;
struct SkRect;
/**
virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE;
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE;
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
#include "GrYUVtoRGBEffect.h"
#include "GrCoordTransform.h"
+#include "GrInvariantOutput.h"
#include "GrProcessor.h"
#include "gl/GrGLProcessor.h"
#include "GrTBackendProcessorFactory.h"
return fColorSpace == s.getColorSpace();
}
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE {
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE {
// YUV is opaque
inout->setToOther(kA_GrColorComponentFlag, 0xFF << GrColor_SHIFT_A,
- InvariantOutput::kWillNot_ReadInput);
+ GrInvariantOutput::kWillNot_ReadInput);
}
GrCoordTransform fCoordTransform;
#if SK_SUPPORT_GPU && SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
#include "GrContextFactory.h"
+#include "GrInvariantOutput.h"
#include "GrOptDrawState.h"
#include "GrTBackendProcessorFactory.h"
#include "GrTest.h"
private:
BigKeyProcessor() { }
virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE { return true; }
- virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE { }
+ virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE { }
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
#include "GrContext.h"
#include "GrContextFactory.h"
#include "GrFragmentProcessor.h"
+#include "GrInvariantOutput.h"
#include "SkColorFilter.h"
#include "SkGr.h"
#include "Test.h"
const GetConstantComponentTestCase& test = filterTests[i];
SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(test.filterColor, test.filterMode));
SkAutoTUnref<GrFragmentProcessor> effect(cf->asFragmentProcessor(grContext));
- GrProcessor::InvariantOutput inout;
- inout.setToOther(test.inputComponents, test.inputColor,
- GrProcessor::InvariantOutput::kWill_ReadInput);
+ GrInvariantOutput inout(test.inputColor,
+ static_cast<GrColorComponentFlags>(test.inputComponents),
+ false);
effect->computeInvariantOutput(&inout);
REPORTER_ASSERT(reporter, filterColor(inout.color(), inout.validFlags()) == test.outputColor);