#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrCoordTransform.h"
-#include "GrInvariantOutput.h"
#include "SkGr.h"
#include "effects/GrConstColorProcessor.h"
#include "glsl/GrGLSLFragmentProcessor.h"
fPaintingData->fStitchDataInit == s.fPaintingData->fStitchDataInit;
}
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
- inout->setToUnknown();
- }
-
GrPerlinNoise2Effect(SkPerlinNoiseShader2::Type type, int numOctaves, bool stitchTiles,
SkPerlinNoiseShader2::PaintingData* paintingData,
GrTexture* permutationsTexture, GrTexture* noiseTexture,
fPaintingData->fBaseFrequency == s.fPaintingData->fBaseFrequency;
}
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
- inout->setToUnknown();
- }
-
GrImprovedPerlinNoiseEffect(int octaves, SkScalar z,
SkPerlinNoiseShader2::PaintingData* paintingData,
GrTexture* permutationsTexture, GrTexture* gradientTexture,
"$_include/gpu/GrCoordTransform.h",
"$_include/gpu/GrFragmentProcessor.h",
"$_include/gpu/GrGpuResource.h",
- "$_include/gpu/GrInvariantOutput.h",
"$_include/gpu/GrPaint.h",
"$_include/gpu/GrProcessor.h",
"$_include/gpu/GrProcessorUnitTest.h",
"$_src/gpu/GrPipeline.h",
"$_src/gpu/GrPipelineBuilder.cpp",
"$_src/gpu/GrPipelineBuilder.h",
+ "$_src/gpu/GrPipelineInput.h",
"$_src/gpu/GrPrimitiveProcessor.cpp",
"$_src/gpu/GrPrimitiveProcessor.h",
"$_src/gpu/GrProcessorSet.cpp",
"$_tests/GeometryTest.cpp",
"$_tests/GifTest.cpp",
"$_tests/GLProgramsTest.cpp",
- "$_tests/GpuColorFilterTest.cpp",
"$_tests/GpuDrawPathTest.cpp",
"$_tests/GpuLayerCacheTest.cpp",
"$_tests/GpuRectanizerTest.cpp",
bool isEqual(const GrFragmentProcessor& that) const;
/**
- * 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.
- * In inout the validFlags member is a bitfield of GrColorComponentFlags. The isSingleComponent
- * member indicates whether the input will be 1 or 4 bytes. The function updates the members of
- * 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(GrInvariantOutput* inout) const {
- this->onComputeInvariantOutput(inout);
- }
-
- /**
* Pre-order traversal of a FP hierarchy, or of the forest of FPs in a GrPipeline. In the latter
* case the tree rooted at each FP in the GrPipeline is visited successively.
*/
int registerChildProcessor(sk_sp<GrFragmentProcessor> child);
/**
- * Subclass implements this to support getConstantColorComponents(...).
- *
- * Note: it's up to the subclass implementation to do any recursive call to compute the child
- * procs' output invariants; computeInvariantOutput will not be recursive.
- */
- virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const = 0;
-
- /**
* Sub-classes should call this in their constructors if they need access to a distance
* vector field to the nearest edge
*/
+++ /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"
-
-/**
- * This describes the color or coverage input that will be seen by the first color or coverage stage
- * of a GrPipeline. This is also the GrPrimitiveProcessor color or coverage *output*.
- */
-struct GrPipelineInput {
- GrPipelineInput()
- : fValidFlags(kNone_GrColorComponentFlags)
- , fColor(0)
- , fIsLCDCoverage(false) {}
-
- void setKnownFourComponents(GrColor color) {
- fColor = color;
- fValidFlags = kRGBA_GrColorComponentFlags;
- }
-
- void setUnknownFourComponents() {
- fValidFlags = kNone_GrColorComponentFlags;
- }
-
- void setUnknownOpaqueFourComponents() {
- fColor = 0xffU << GrColor_SHIFT_A;
- fValidFlags = kA_GrColorComponentFlag;
- }
-
- void setKnownSingleComponent(uint8_t alpha) {
- fColor = GrColorPackRGBA(alpha, alpha, alpha, alpha);
- fValidFlags = kRGBA_GrColorComponentFlags;
- }
-
- void setUnknownSingleComponent() {
- fValidFlags = kNone_GrColorComponentFlags;
- }
-
- void setUsingLCDCoverage() { fIsLCDCoverage = true; }
-
- GrColorComponentFlags fValidFlags;
- GrColor fColor;
- bool fIsLCDCoverage; // Temorary data member until texture pixel configs are
- // updated
-};
-
-/** This describes the output of a GrFragmentProcessor in a GrPipeline. */
-class GrInvariantOutput {
-public:
- GrInvariantOutput(GrColor color, GrColorComponentFlags flags)
- : fColor(color), fValidFlags(flags), fNonMulStageFound(false) {}
-
- GrInvariantOutput(const GrPipelineInput& input)
- : fColor(input.fColor), fValidFlags(input.fValidFlags), fNonMulStageFound(false) {}
-
- virtual ~GrInvariantOutput() {}
-
- void mulByUnknownOpaqueFourComponents() {
- if (this->isOpaque()) {
- fValidFlags = kA_GrColorComponentFlag;
- } else {
- // Since the current state is not opaque we no longer care if the color being
- // multiplied is opaque.
- this->mulByUnknownFourComponents();
- }
- }
-
- void mulByUnknownFourComponents() {
- if (this->hasZeroAlpha()) {
- this->internalSetToTransparentBlack();
- } else {
- this->internalSetToUnknown();
- }
- }
-
- void mulByUnknownSingleComponent() {
- if (this->hasZeroAlpha()) {
- this->internalSetToTransparentBlack();
- } else {
- // We don't need to change fIsSingleComponent in this case
- fValidFlags = kNone_GrColorComponentFlags;
- }
- }
-
- void mulByKnownSingleComponent(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));
- // We don't need to change fIsSingleComponent in this case
- }
- }
- }
-
- void mulByKnownFourComponents(GrColor color) {
- uint32_t a;
- if (GetAlphaAndCheckSingleChannel(color, &a)) {
- this->mulByKnownSingleComponent(a);
- } else {
- if (color != 0xffffffff) {
- fColor = GrColorPackRGBA(
- SkMulDiv255Round(GrColorUnpackR(fColor), GrColorUnpackR(color)),
- SkMulDiv255Round(GrColorUnpackG(fColor), GrColorUnpackG(color)),
- SkMulDiv255Round(GrColorUnpackB(fColor), GrColorUnpackB(color)),
- SkMulDiv255Round(GrColorUnpackA(fColor), a));
- }
- }
- }
-
- // Ignores the incoming color's RGB and muls its alpha by color.
- void mulAlphaByKnownFourComponents(GrColor color) {
- uint32_t a;
- if (GetAlphaAndCheckSingleChannel(color, &a)) {
- this->mulAlphaByKnownSingleComponent(a);
- } else if (fValidFlags & kA_GrColorComponentFlag) {
- GrColor preAlpha = GrColorUnpackA(fColor);
- if (0 == preAlpha) {
- this->internalSetToTransparentBlack();
- } else {
- // We know that color has different component values
- fColor = GrColorPackRGBA(
- SkMulDiv255Round(preAlpha, GrColorUnpackR(color)),
- SkMulDiv255Round(preAlpha, GrColorUnpackG(color)),
- SkMulDiv255Round(preAlpha, GrColorUnpackB(color)),
- SkMulDiv255Round(preAlpha, a));
- fValidFlags = kRGBA_GrColorComponentFlags;
- }
- } else {
- fValidFlags = kNone_GrColorComponentFlags;
- }
- }
-
- // Ignores the incoming color's RGB and muls its alpha by the alpha param and sets all channels
- // equal to that value.
- void mulAlphaByKnownSingleComponent(uint8_t alpha) {
- if (0 == alpha || this->hasZeroAlpha()) {
- this->internalSetToTransparentBlack();
- } else {
- if (fValidFlags & kA_GrColorComponentFlag) {
- GrColor a = GrColorUnpackA(fColor);
- a = SkMulDiv255Round(alpha, a);
- fColor = GrColorPackRGBA(a, a, a, a);
- fValidFlags = kRGBA_GrColorComponentFlags;
- } else {
- fValidFlags = kNone_GrColorComponentFlags;
- }
- }
- }
-
- void premulFourChannelColor() {
- fNonMulStageFound = true;
- if (!(fValidFlags & kA_GrColorComponentFlag)) {
- fValidFlags = kNone_GrColorComponentFlags;
- } else {
- fColor = GrPremulColor(fColor);
- }
- }
-
- void invalidateComponents(GrColorComponentFlags invalidateFlags) {
- fValidFlags = (fValidFlags & ~invalidateFlags);
- fNonMulStageFound = true;
- }
-
- void setToOther(GrColorComponentFlags validFlags, GrColor color) {
- fValidFlags = validFlags;
- fColor = color;
- fNonMulStageFound = true;
- }
-
- void setToUnknown() {
- this->internalSetToUnknown();
- fNonMulStageFound = true;
- }
-
- GrColor color() const { return fColor; }
- GrColorComponentFlags validFlags() const { return fValidFlags; }
-
-private:
- friend class GrProcOptInfo;
-
- /** Extracts the alpha channel and returns true if r,g,b == a. */
- static bool GetAlphaAndCheckSingleChannel(GrColor color, uint32_t* alpha) {
- *alpha = GrColorUnpackA(color);
- return *alpha == GrColorUnpackR(color) && *alpha == GrColorUnpackG(color) &&
- *alpha == GrColorUnpackB(color);
- }
-
- void reset(GrColor color, GrColorComponentFlags flags) {
- fColor = color;
- fValidFlags = flags;
- fNonMulStageFound = false;
- }
-
- void reset(const GrPipelineInput& input) {
- fColor = input.fColor;
- fValidFlags = input.fValidFlags;
- fNonMulStageFound = false;
- }
-
- void internalSetToTransparentBlack() {
- fValidFlags = kRGBA_GrColorComponentFlags;
- fColor = 0;
- }
-
- void internalSetToUnknown() {
- fValidFlags = kNone_GrColorComponentFlags;
- }
-
- bool hasZeroAlpha() const {
- return ((fValidFlags & kA_GrColorComponentFlag) && 0 == GrColorUnpackA(fColor));
- }
-
- bool isOpaque() const {
- return ((fValidFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpackA(fColor));
- }
-
- bool isSolidWhite() const {
- return (fValidFlags == kRGBA_GrColorComponentFlags && 0xFFFFFFFF == fColor);
- }
-
- bool allStagesMulInput() const { return !fNonMulStageFound; }
- void resetNonMulStageFound() { fNonMulStageFound = false; }
-
- /**
- * If alpha is valid, check that any valid R,G,B values are <= A
- */
- SkDEBUGCODE(bool validPreMulColor() const;)
-
- GrColor fColor;
- GrColorComponentFlags fValidFlags;
- bool fNonMulStageFound;
-};
-
-#endif
-
bool onIsEqual(const GrFragmentProcessor&) const override;
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
-
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
Mode fMode;
bool onIsEqual(const GrFragmentProcessor&) const override;
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
GrColor4f constantOutputForConstantInput(GrColor4f input) const override;
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
#if SK_SUPPORT_GPU
#include "GrFragmentProcessor.h"
-#include "GrInvariantOutput.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
return 0 == memcmp(fMatrix, cme.fMatrix, sizeof(fMatrix));
}
- void onComputeInvariantOutput(GrInvariantOutput* inout) const 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.
-
- // The matrix is defined such the 4th row determines the output alpha. The first four
- // columns of that row multiply the input r, g, b, and a, respectively, and the last column
- // is the "translation".
- static const uint32_t kRGBAFlags[] = {
- kR_GrColorComponentFlag,
- kG_GrColorComponentFlag,
- kB_GrColorComponentFlag,
- kA_GrColorComponentFlag
- };
- static const int kShifts[] = {
- GrColor_SHIFT_R, GrColor_SHIFT_G, GrColor_SHIFT_B, GrColor_SHIFT_A,
- };
- enum {
- kAlphaRowStartIdx = 15,
- kAlphaRowTranslateIdx = 19,
- };
-
- SkScalar outputA = 0;
- for (int i = 0; i < 4; ++i) {
- // If any relevant component of the color to be passed through the matrix is non-const
- // then we can't know the final result.
- if (0 != fMatrix[kAlphaRowStartIdx + i]) {
- if (!(inout->validFlags() & kRGBAFlags[i])) {
- inout->setToUnknown();
- return;
- } else {
- uint32_t component = (inout->color() >> kShifts[i]) & 0xFF;
- outputA += fMatrix[kAlphaRowStartIdx + i] * component;
- }
- }
- }
- outputA += fMatrix[kAlphaRowTranslateIdx];
- // We pin the color to [0,1]. This would happen to the *final* color output from the frag
- // shader but currently the effect does not pin its own output. So in the case of over/
- // underflow this may deviate from the actual result. Maybe the effect should pin its
- // 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);
- }
-
SkScalar fMatrix[20];
typedef GrFragmentProcessor INHERITED;
#include "GrCoordTransform.h"
#include "GrFragmentProcessor.h"
-#include "GrInvariantOutput.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
const char* name() const override { return "LightingFP"; }
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
- inout->mulByUnknownFourComponents();
- }
-
const SkTArray<SkLights::Light>& directionalLights() const { return fDirectionalLights; }
const SkColor3f& ambientColor() const { return fAmbientColor; }
///////////////////////////////////////////////////////////////////////////////
#if SK_SUPPORT_GPU
#include "GrBlend.h"
-#include "GrInvariantOutput.h"
#include "effects/GrXfermodeFragmentProcessor.h"
#include "effects/GrConstColorProcessor.h"
#include "SkGr.h"
// With a solid color input this should always be able to compute the blended color
// (at least for coeff modes)
if ((unsigned)fMode <= (unsigned)SkBlendMode::kLastCoeffMode) {
- static SkRandom gRand;
- GrInvariantOutput io(GrPremulColor(gRand.nextU()), kRGBA_GrColorComponentFlags);
- fp->computeInvariantOutput(&io);
- SkASSERT(io.validFlags() == kRGBA_GrColorComponentFlags);
+ SkASSERT(fp->hasConstantOutputForConstantInput());
}
#endif
return fp;
#include "SkWriteBuffer.h"
#if SK_SUPPORT_GPU
-#include "GrInvariantOutput.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "SkGr.h"
const char* name() const override { return "NormalBevelFP"; }
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
- inout->setToUnknown();
- }
-
private:
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override { return new GLSLNormalBevelFP; }
#include "SkWriteBuffer.h"
#if SK_SUPPORT_GPU
-#include "GrInvariantOutput.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
GLSLNormalFlatFP::GenKey(*this, caps, b);
}
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
- inout->setToUnknown();
- }
+
GrColor4f constantOutputForConstantInput(GrColor4f) const override {
return GrColor4f(0, 0, 1, 0);
}
#if SK_SUPPORT_GPU
#include "GrCoordTransform.h"
-#include "GrInvariantOutput.h"
#include "GrSamplerParams.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
const char* name() const override { return "NormalMapFP"; }
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
- inout->setToUnknown();
- }
-
const SkMatrix& invCTM() const { return fInvCTM; }
private:
const char* name() const override { return "RadialShadowMapFP"; }
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
- inout->mulByUnknownFourComponents();
- }
const SkVector3& lightPos() const {
return fLightPos;
}
const char* name() const override { return "shadowFP"; }
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
- inout->mulByUnknownFourComponents();
- }
int32_t numLights() const { return fNumNonAmbLights; }
const SkColor3f& ambientColor() const { return fAmbientColor; }
bool isPointLight(int i) const {
#if SK_SUPPORT_GPU
-#include "GrInvariantOutput.h"
#include "SkRefCnt.h"
-
#include "glsl/GrGLSLColorSpaceXformHelper.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
this->fOuterThreshold == s.fOuterThreshold);
}
-void GrAlphaThresholdFragmentProcessor::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- GrPixelConfig config = this->textureSampler(0).texture()->config();
- if (GrPixelConfigIsAlphaOnly(config)) {
- inout->mulByUnknownSingleComponent();
- } else if (GrPixelConfigIsOpaque(config) && fOuterThreshold >= 1.f) {
- inout->mulByUnknownOpaqueFourComponents();
- } else {
- inout->mulByUnknownFourComponents();
- }
-}
-
///////////////////////////////////////////////////////////////////////////////
class GrGLAlphaThresholdFragmentProcessor : public GrGLSLFragmentProcessor {
bool onIsEqual(const GrFragmentProcessor&) const override;
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
-
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
float fInnerThreshold;
#if SK_SUPPORT_GPU
#include "GrContext.h"
-#include "GrInvariantOutput.h"
#include "GrTextureProvider.h"
-
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
return;
}
-void GrCircleBlurFragmentProcessor::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- inout->mulByUnknownSingleComponent();
-}
-
// Computes an unnormalized half kernel (right side). Returns the summation of all the half kernel
// values.
static float make_unnormalized_half_kernel(float* halfKernel, int halfKernelSize, float sigma) {
fTextureRadius == cbfp.fTextureRadius;
}
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
-
SkRect fCircle;
SkScalar fSolidRadius;
float fTextureRadius;
fEnforcePMColor == fp.fEnforcePMColor;
}
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
- // TODO: optimize this
- inout->setToUnknown();
- }
-
// This could implement the const input -> const output optimization but it's unlikely to help.
ArithmeticFP(float k1, float k2, float k3, float k4, bool enforcePMColor,
sk_sp<GrFragmentProcessor> dst)
#include "GrRenderTargetContext.h"
#include "GrTexture.h"
#include "GrFragmentProcessor.h"
-#include "GrInvariantOutput.h"
#include "GrShaderCaps.h"
#include "GrStyle.h"
#include "GrTextureProxy.h"
bool onIsEqual(const GrFragmentProcessor&) const override;
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
-
static GrTexture* CreateBlurProfileTexture(GrTextureProvider*, float sigma);
SkRect fRect;
return this->getSigma() == s.getSigma() && this->getRect() == s.getRect();
}
-void GrRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- inout->mulByUnknownSingleComponent();
-}
-
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRectBlurEffect);
#if GR_TEST_UTILS
bool onIsEqual(const GrFragmentProcessor& other) const override;
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
-
SkRRect fRRect;
float fSigma;
TextureSampler fNinePatchSampler;
mask.get()));
}
-void GrRRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- inout->mulByUnknownSingleComponent();
-}
-
GrRRectBlurEffect::GrRRectBlurEffect(float sigma, const SkRRect& rrect, GrTexture* ninePatchTexture)
: INHERITED(kModulatesInput_OptimizationFlag)
, fRRect(rrect)
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrCoordTransform.h"
-#include "GrInvariantOutput.h"
#include "GrRenderTargetContext.h"
#include "GrTextureProxy.h"
bool onIsEqual(const GrFragmentProcessor&) const override;
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
-
GrDisplacementMapEffect(SkDisplacementMapEffect::ChannelSelectorType xChannelSelector,
SkDisplacementMapEffect::ChannelSelectorType yChannelSelector,
const SkVector& scale,
fScale == s.fScale;
}
-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();
-}
-
///////////////////////////////////////////////////////////////////////////////
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDisplacementMapEffect);
#include "GrContext.h"
#include "GrFixedClip.h"
#include "GrFragmentProcessor.h"
-#include "GrInvariantOutput.h"
#include "GrPaint.h"
#include "GrRenderTargetContext.h"
#include "GrTextureProxy.h"
protected:
bool onIsEqual(const GrFragmentProcessor&) const override;
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
- // lighting shaders are complicated. We just throw up our hands.
- inout->mulByUnknownFourComponents();
- }
private:
const SkImageFilterLight* fLight;
#if SK_SUPPORT_GPU
#include "GrContext.h"
-#include "GrInvariantOutput.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#endif
bool onIsEqual(const GrFragmentProcessor&) const override { return true; }
- void onComputeInvariantOutput(GrInvariantOutput* inout) const 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));
- }
GrColor4f constantOutputForConstantInput(GrColor4f input) const override {
float luma = SK_ITU_BT709_LUM_COEFF_R * input.fRGBA[0] +
SK_ITU_BT709_LUM_COEFF_G * input.fRGBA[1] +
////////////////////////////////////////////////////////////////////////////////
#if SK_SUPPORT_GPU
#include "GrContext.h"
-#include "GrInvariantOutput.h"
#include "effects/GrSingleTextureEffect.h"
#include "glsl/GrGLSLColorSpaceXformHelper.h"
#include "glsl/GrGLSLFragmentProcessor.h"
bool onIsEqual(const GrFragmentProcessor&) const override;
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
-
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
SkRect fBounds;
this->fYInvInset == s.fYInvInset);
}
-void GrMagnifierEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- this->updateInvariantOutputForModulation(inout);
-}
-
#endif
////////////////////////////////////////////////////////////////////////////////
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrFixedClip.h"
-#include "GrInvariantOutput.h"
#include "GrRenderTargetContext.h"
#include "GrTexture.h"
#include "GrTextureProxy.h"
bool onIsEqual(const GrFragmentProcessor&) const override;
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
-
GrMorphologyEffect(GrTexture*, Direction, int radius, MorphologyType);
GrMorphologyEffect(GrTexture*, Direction, int radius, MorphologyType, const float bounds[2]);
this->type() == s.type());
}
-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);
-}
-
///////////////////////////////////////////////////////////////////////////////
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMorphologyEffect);
#if SK_SUPPORT_GPU
#include "GrFragmentProcessor.h"
-#include "GrInvariantOutput.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {}
bool onIsEqual(const GrFragmentProcessor&) const override;
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
OverdrawFragmentProcessor(const GrColor4f* colors);
sizeof(GrColor4f) * SkOverdrawColorFilter::kNumColors);
}
-void OverdrawFragmentProcessor::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- inout->invalidateComponents(kRGBA_GrColorComponentFlags);
-}
-
GLOverdrawFragmentProcessor::GLOverdrawFragmentProcessor(const GrColor4f* colors) {
memcpy(fColors, colors, SkOverdrawColorFilter::kNumColors * sizeof(GrColor4f));
}
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrCoordTransform.h"
-#include "GrInvariantOutput.h"
#include "SkGr.h"
#include "effects/GrConstColorProcessor.h"
#include "glsl/GrGLSLFragmentProcessor.h"
fPaintingData->fStitchDataInit == s.fPaintingData->fStitchDataInit;
}
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
- inout->setToUnknown();
- }
-
GrPerlinNoiseEffect(SkPerlinNoiseShader::Type type, int numOctaves, bool stitchTiles,
SkPerlinNoiseShader::PaintingData* paintingData,
GrTexture* permutationsTexture, GrTexture* noiseTexture,
#include "GrCoordTransform.h"
#include "GrFragmentProcessor.h"
-#include "GrInvariantOutput.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
const char* name() const override { return "RRectsGaussianEdgeFP"; }
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
- inout->setToUnknown();
- }
-
const SkRRect& first() const { return fFirst; }
Mode firstMode() const { return fFirstMode; }
const SkRRect& second() const { return fSecond; }
#include "GrContext.h"
#include "GrFragmentProcessor.h"
-#include "GrInvariantOutput.h"
#include "GrTextureStripAtlas.h"
#include "SkGr.h"
#include "glsl/GrGLSLFragmentProcessor.h"
bool onIsEqual(const GrFragmentProcessor&) const override;
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
-
ColorTableEffect(GrTexture* texture, GrTextureStripAtlas* atlas, int row, unsigned flags);
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
- TextureSampler fTextureSampler;
-
- // currently not used in shader code, just to assist onComputeInvariantOutput().
- unsigned fFlags;
-
- GrTextureStripAtlas* fAtlas;
- int fRow;
+ TextureSampler fTextureSampler;
+ GrTextureStripAtlas* fAtlas;
+ int fRow;
typedef GrFragmentProcessor INHERITED;
};
unsigned flags)
: INHERITED(kNone_OptimizationFlags) // Not bothering with table-specific optimizations.
, fTextureSampler(texture)
- , fFlags(flags)
, fAtlas(atlas)
, fRow(row) {
this->initClassID<ColorTableEffect>();
return fRow == that.fRow;
}
-void ColorTableEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- // If we kept the table in the effect then we could actually run known inputs through the
- // table.
- GrColorComponentFlags invalidateFlags = kNone_GrColorComponentFlags;
- if (fFlags & SkTable_ColorFilter::kR_Flag) {
- invalidateFlags |= kR_GrColorComponentFlag;
- }
- if (fFlags & SkTable_ColorFilter::kG_Flag) {
- invalidateFlags |= kG_GrColorComponentFlag;
- }
- if (fFlags & SkTable_ColorFilter::kB_Flag) {
- invalidateFlags |= kB_GrColorComponentFlag;
- }
- if (fFlags & SkTable_ColorFilter::kA_Flag) {
- invalidateFlags |= kA_GrColorComponentFlag;
- }
- inout->invalidateComponents(invalidateFlags);
-}
-
///////////////////////////////////////////////////////////////////////////////
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ColorTableEffect);
#if SK_SUPPORT_GPU
#include "GrContext.h"
-#include "GrInvariantOutput.h"
#include "GrShaderCaps.h"
#include "GrTextureStripAtlas.h"
#include "gl/GrGLContext.h"
return GrColorSpaceXform::Equals(this->fColorSpaceXform.get(), ge.fColorSpaceXform.get());
}
-void GrGradientEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- if (fIsOpaque) {
- inout->mulByUnknownOpaqueFourComponents();
- } else {
- inout->mulByUnknownFourComponents();
- }
-}
-
#if GR_TEST_UTILS
GrGradientEffect::RandomGradientParams::RandomGradientParams(SkRandom* random) {
// Set color count to min of 2 so that we don't trigger the const color optimization and make
bool onIsEqual(const GrFragmentProcessor&) const override;
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
-
const GrCoordTransform& getCoordTransform() const { return fCoordTransform; }
private:
#if SK_SUPPORT_GPU
#include "GrCoordTransform.h"
-#include "GrInvariantOutput.h"
#include "GrPaint.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "GrDefaultGeoProcFactory.h"
-#include "GrInvariantOutput.h"
#include "SkRefCnt.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLGeometryProcessor.h"
#include "GrFragmentProcessor.h"
#include "GrCoordTransform.h"
-#include "GrInvariantOutput.h"
#include "GrPipeline.h"
#include "GrProcOptInfo.h"
#include "glsl/GrGLSLFragmentProcessor.h"
bool onIsEqual(const GrFragmentProcessor&) const override { return true; }
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
- inout->premulFourChannelColor();
- }
GrColor4f constantOutputForConstantInput(GrColor4f input) const override {
return input.premul();
}
}
return flags;
}
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
- // TODO: Add a helper to GrInvariantOutput that handles multiplying by color with flags?
- if (!(inout->validFlags() & kA_GrColorComponentFlag)) {
- inout->setToUnknown();
- return;
- }
-
- GrInvariantOutput childOutput(GrColor_WHITE, kRGBA_GrColorComponentFlags);
- this->childProcessor(0).computeInvariantOutput(&childOutput);
- if (0 == GrColorUnpackA(inout->color()) || 0 == GrColorUnpackA(childOutput.color())) {
- inout->mulByKnownFourComponents(0x0);
- return;
- }
- GrColorComponentFlags commonFlags = childOutput.validFlags() & inout->validFlags();
- GrColor c0 = GrPremulColor(inout->color());
- GrColor c1 = childOutput.color();
- GrColor color = 0x0;
- if (commonFlags & kR_GrColorComponentFlag) {
- color |= SkMulDiv255Round(GrColorUnpackR(c0), GrColorUnpackR(c1)) <<
- GrColor_SHIFT_R;
- }
- if (commonFlags & kG_GrColorComponentFlag) {
- color |= SkMulDiv255Round(GrColorUnpackG(c0), GrColorUnpackG(c1)) <<
- GrColor_SHIFT_G;
- }
- if (commonFlags & kB_GrColorComponentFlag) {
- color |= SkMulDiv255Round(GrColorUnpackB(c0), GrColorUnpackB(c1)) <<
- GrColor_SHIFT_B;
- }
- inout->setToOther(commonFlags, color);
- }
GrColor4f constantOutputForConstantInput(GrColor4f input) const override {
GrColor4f childColor = ConstantOutputForConstantInput(this->childProcessor(0),
GrColor4f::OpaqueWhite());
return fColor == that.cast<ReplaceInputFragmentProcessor>().fColor;
}
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
- inout->setToOther(kRGBA_GrColorComponentFlags, fColor.toGrColor());
- this->childProcessor(0).computeInvariantOutput(inout);
- }
-
GrColor4f constantOutputForConstantInput(GrColor4f) const override {
return ConstantOutputForConstantInput(this->childProcessor(0), fColor);
}
typedef GrFragmentProcessor INHERITED;
};
- GrInvariantOutput childOut(0x0, kNone_GrColorComponentFlags);
- fp->computeInvariantOutput(&childOut);
return sk_sp<GrFragmentProcessor>(new ReplaceInputFragmentProcessor(std::move(fp), color));
}
bool onIsEqual(const GrFragmentProcessor&) const override { return true; }
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
- for (int i = 0; i < this->numChildProcessors(); ++i) {
- this->childProcessor(i).computeInvariantOutput(inout);
- }
- }
GrColor4f constantOutputForConstantInput(GrColor4f color) const override {
int childCnt = this->numChildProcessors();
for (int i = 0; i < childCnt; ++i) {
--- /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 GrPipelineInput_DEFINED
+#define GrPipelineInput_DEFINED
+
+#include "GrColor.h"
+
+/**
+ * This describes the color or coverage input that will be seen by the first color or coverage stage
+ * of a GrPipeline. This is also the GrPrimitiveProcessor color or coverage *output*.
+ */
+struct GrPipelineInput {
+ GrPipelineInput()
+ : fValidFlags(kNone_GrColorComponentFlags), fColor(0), fIsLCDCoverage(false) {}
+
+ void setKnownFourComponents(GrColor color) {
+ fColor = color;
+ fValidFlags = kRGBA_GrColorComponentFlags;
+ }
+
+ void setUnknownFourComponents() { fValidFlags = kNone_GrColorComponentFlags; }
+
+ void setUnknownOpaqueFourComponents() {
+ fColor = 0xffU << GrColor_SHIFT_A;
+ fValidFlags = kA_GrColorComponentFlag;
+ }
+
+ void setKnownSingleComponent(uint8_t alpha) {
+ fColor = GrColorPackRGBA(alpha, alpha, alpha, alpha);
+ fValidFlags = kRGBA_GrColorComponentFlags;
+ }
+
+ void setUnknownSingleComponent() { fValidFlags = kNone_GrColorComponentFlags; }
+
+ void setUsingLCDCoverage() { fIsLCDCoverage = true; }
+
+ GrColorComponentFlags fValidFlags;
+ GrColor fColor;
+ bool fIsLCDCoverage;
+};
+
+#endif
* functionality.
*
* There are two feedback loops between the GrFragmentProcessors, the GrXferProcessor, and the
- * GrPrimitiveProcessor. These loops run on the CPU and compute any invariant components which
- * might be useful for correctness / optimization decisions. The GrPrimitiveProcessor seeds these
- * loops, one with initial color and one with initial coverage, in its
- * onComputeInvariantColor / Coverage calls. These seed values are processed by the subsequent
+ * GrPrimitiveProcessor. These loops run on the CPU and to determine known properties of the final
+ * color and coverage inputs to the GrXferProcessor in order to perform optimizations that preserve
+ * correctness. The GrDrawOp seeds these loops with initial color and coverage, in its
+ * getPipelineAnalysisInput implementation. These seed values are processed by the subsequent
* stages of the rendering pipeline and the output is then fed back into the GrDrawOp in
* the applyPipelineOptimizations call, where the op can use the information to inform decisions
* about GrPrimitiveProcessor creation.
#define GrProcOptInfo_DEFINED
#include "GrColor.h"
-#include "GrInvariantOutput.h"
+#include "GrPipelineInput.h"
class GrDrawOp;
class GrFragmentProcessor;
#include "GrProcessor.h"
#include "GrContext.h"
#include "GrGeometryProcessor.h"
-#include "GrInvariantOutput.h"
#include "GrMemoryPool.h"
#include "GrSamplerParams.h"
#include "GrTexturePriv.h"
#include "GrCaps.h"
#include "GrProcessor.h"
#include "GrGeometryProcessor.h"
-#include "GrInvariantOutput.h"
#include "GrTypesPriv.h"
/**
*/
#include "GrBicubicEffect.h"
-#include "GrInvariantOutput.h"
#include "GrProxyMove.h"
#include "GrTextureProxy.h"
#include "glsl/GrGLSLColorSpaceXformHelper.h"
return fDomain == s.fDomain;
}
-void GrBicubicEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- // FIXME: Perhaps we can do better.
- inout->mulByUnknownSingleComponent();
-}
-
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrBicubicEffect);
#if GR_TEST_UTILS
bool onIsEqual(const GrFragmentProcessor&) const override;
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
-
GrTextureDomain fDomain;
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
*/
#include "GrBitmapTextGeoProc.h"
-#include "GrInvariantOutput.h"
#include "GrTexture.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLGeometryProcessor.h"
*/
#include "effects/GrBlurredEdgeFragmentProcessor.h"
-#include "GrInvariantOutput.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
return that.fMode == fMode;
}
-void GrBlurredEdgeFP::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- inout->mulByUnknownFourComponents();
-}
-
#include "GrConfigConversionEffect.h"
#include "GrContext.h"
#include "GrRenderTargetContext.h"
-#include "GrInvariantOutput.h"
#include "GrSimpleTextureEffect.h"
#include "SkMatrix.h"
#include "glsl/GrGLSLFragmentProcessor.h"
other.fPMConversion == fPMConversion;
}
-void GrConfigConversionEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- this->updateInvariantOutputForModulation(inout);
-}
-
///////////////////////////////////////////////////////////////////////////////
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConfigConversionEffect);
bool onIsEqual(const GrFragmentProcessor&) const override;
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
-
GrSwizzle fSwizzle;
PMConversion fPMConversion;
*/
#include "effects/GrConstColorProcessor.h"
-#include "GrInvariantOutput.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
///////////////////////////////////////////////////////////////////////////////
-void GrConstColorProcessor::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- if (kIgnore_InputMode == fMode) {
- inout->setToOther(kRGBA_GrColorComponentFlags, fColor.toGrColor());
- } else {
- float r = fColor.fRGBA[0];
- bool colorIsSingleChannel = r == fColor.fRGBA[1] && r == fColor.fRGBA[2] &&
- r == fColor.fRGBA[3];
- if (kModulateRGBA_InputMode == fMode) {
- if (colorIsSingleChannel) {
- inout->mulByKnownSingleComponent(SkToU8(sk_float_round2int(255.0f * r)));
- } else {
- inout->mulByKnownFourComponents(fColor.toGrColor());
- }
- } else {
- if (colorIsSingleChannel) {
- inout->mulAlphaByKnownSingleComponent(SkToU8(sk_float_round2int(255.0f * r)));
- } else {
- inout->mulAlphaByKnownFourComponents(fColor.toGrColor());
- }
- }
- }
-}
-
GrColor4f GrConstColorProcessor::constantOutputForConstantInput(GrColor4f input) const {
switch (fMode) {
case kIgnore_InputMode:
*/
#include "GrConvexPolyEffect.h"
-#include "GrInvariantOutput.h"
#include "SkPathPriv.h"
#include "effects/GrConstColorProcessor.h"
#include "glsl/GrGLSLFragmentProcessor.h"
return fRect == aare.fRect;
}
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
- if (fRect.isEmpty()) {
- // An empty rect will have no coverage anywhere.
- inout->mulByKnownSingleComponent(0);
- } else {
- inout->mulByUnknownSingleComponent();
- }
- }
-
SkRect fRect;
GrPrimitiveEdgeType fEdgeType;
GrConvexPolyEffect::~GrConvexPolyEffect() {}
-void GrConvexPolyEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- inout->mulByUnknownSingleComponent();
-}
-
void GrConvexPolyEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GrGLConvexPolyEffect::GenKey(*this, caps, b);
bool onIsEqual(const GrFragmentProcessor& other) const override;
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
-
GrPrimitiveEdgeType fEdgeType;
int fEdgeCount;
SkScalar fEdges[3 * kMaxEdges];
#include "GrCoordTransform.h"
#include "GrContext.h"
#include "GrFragmentProcessor.h"
-#include "GrInvariantOutput.h"
#include "GrPipeline.h"
#include "GrProcessor.h"
#include "GrShaderCaps.h"
*/
#include "GrDistanceFieldGeoProc.h"
-#include "GrInvariantOutput.h"
#include "GrTexture.h"
-
#include "SkDistanceFieldGen.h"
-
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLGeometryProcessor.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "GrDitherEffect.h"
#include "GrFragmentProcessor.h"
-#include "GrInvariantOutput.h"
#include "SkRect.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
// All dither effects are equal
bool onIsEqual(const GrFragmentProcessor&) const override { return true; }
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
-
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
typedef GrFragmentProcessor INHERITED;
};
-void DitherEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- inout->setToUnknown();
-}
-
//////////////////////////////////////////////////////////////////////////////
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(DitherEffect);
#define GrGaussianConvolutionFragmentProcessor_DEFINED
#include "Gr1DKernelEffect.h"
-#include "GrInvariantOutput.h"
/**
* A 1D Gaussian convolution effect. The kernel is computed as an array of 2 * half-width weights.
bool onIsEqual(const GrFragmentProcessor&) const override;
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
- // If the texture was opaque we could know that the output color if we knew the sum of the
- // kernel values.
- inout->mulByUnknownFourComponents();
- }
-
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
// TODO: Inline the kernel constants into the generated shader code. This may involve pulling
#define GrMatrixConvolutionEffect_DEFINED
#include "GrSingleTextureEffect.h"
-#include "GrInvariantOutput.h"
#include "GrTextureDomain.h"
// A little bit less than the minimum # uniforms required by DX9SM2 (32).
bool onIsEqual(const GrFragmentProcessor&) const override;
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
- // TODO: Try to do better?
- inout->mulByUnknownFourComponents();
- }
-
SkIRect fBounds;
SkISize fKernelSize;
float fKernel[MAX_KERNEL_SIZE];
#include "GrOvalEffect.h"
#include "GrFragmentProcessor.h"
-#include "GrInvariantOutput.h"
#include "SkRect.h"
#include "GrShaderCaps.h"
#include "glsl/GrGLSLFragmentProcessor.h"
bool onIsEqual(const GrFragmentProcessor&) const override;
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
-
SkPoint fCenter;
SkScalar fRadius;
GrPrimitiveEdgeType fEdgeType;
return sk_sp<GrFragmentProcessor>(new CircleEffect(edgeType, center, radius));
}
-void CircleEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- inout->mulByUnknownSingleComponent();
-}
-
CircleEffect::CircleEffect(GrPrimitiveEdgeType edgeType, const SkPoint& c, SkScalar r)
: INHERITED(kModulatesInput_OptimizationFlag), fCenter(c), fRadius(r), fEdgeType(edgeType) {
this->initClassID<CircleEffect>();
bool onIsEqual(const GrFragmentProcessor&) const override;
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
-
SkPoint fCenter;
SkVector fRadii;
GrPrimitiveEdgeType fEdgeType;
return sk_sp<GrFragmentProcessor>(new EllipseEffect(edgeType, center, rx, ry));
}
-void EllipseEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- inout->mulByUnknownSingleComponent();
-}
-
EllipseEffect::EllipseEffect(GrPrimitiveEdgeType edgeType, const SkPoint& c, SkScalar rx,
SkScalar ry)
: INHERITED(kModulatesInput_OptimizationFlag)
#include "GrConvexPolyEffect.h"
#include "GrFragmentProcessor.h"
-#include "GrInvariantOutput.h"
#include "GrOvalEffect.h"
#include "GrShaderCaps.h"
#include "SkRRect.h"
bool onIsEqual(const GrFragmentProcessor& other) const override;
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
-
SkRRect fRRect;
GrPrimitiveEdgeType fEdgeType;
uint32_t fCircularCornerFlags;
new CircularRRectEffect(edgeType, circularCornerFlags, rrect));
}
-void CircularRRectEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- inout->mulByUnknownSingleComponent();
-}
-
CircularRRectEffect::CircularRRectEffect(GrPrimitiveEdgeType edgeType, uint32_t circularCornerFlags,
const SkRRect& rrect)
: INHERITED(kModulatesInput_OptimizationFlag)
bool onIsEqual(const GrFragmentProcessor& other) const override;
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
-
SkRRect fRRect;
GrPrimitiveEdgeType fEdgeType;
return sk_sp<GrFragmentProcessor>(new EllipticalRRectEffect(edgeType, rrect));
}
-void EllipticalRRectEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- inout->mulByUnknownSingleComponent();
-}
-
EllipticalRRectEffect::EllipticalRRectEffect(GrPrimitiveEdgeType edgeType, const SkRRect& rrect)
: INHERITED(kModulatesInput_OptimizationFlag), fRRect(rrect), fEdgeType(edgeType) {
this->initClassID<EllipticalRRectEffect>();
#include "GrContext.h"
#include "GrFragmentProcessor.h"
-#include "GrInvariantOutput.h"
#include "GrProcessor.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
return other.fMode == fMode;
}
-void GrSRGBEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- inout->setToUnknown();
-}
-
static inline float srgb_to_linear(float srgb) {
return (srgb <= 0.04045f) ? srgb / 12.92f : powf((srgb + 0.055f) / 1.055f, 2.4f);
}
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor&) const override;
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
+
GrColor4f constantOutputForConstantInput(GrColor4f input) const override;
Mode fMode;
*/
#include "GrSimpleTextureEffect.h"
-#include "GrInvariantOutput.h"
#include "GrProxyMove.h"
#include "GrTexture.h"
#include "glsl/GrGLSLColorSpaceXformHelper.h"
///////////////////////////////////////////////////////////////////////////////
-void GrSimpleTextureEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- this->updateInvariantOutputForModulation(inout);
-}
-
void GrSimpleTextureEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
GrGLSimpleTextureEffect::GenKey(*this, caps, b);
bool onIsEqual(const GrFragmentProcessor& other) const override { return true; }
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
-
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
typedef GrSingleTextureEffect INHERITED;
#include "GrFragmentProcessor.h"
#include "GrColorSpaceXform.h"
#include "GrCoordTransform.h"
-#include "GrInvariantOutput.h"
#include "SkMatrix.h"
class GrTexture;
sk_sp<GrColorSpaceXform>, const SkMatrix&, const GrSamplerParams&);
/**
- * Can be used as a helper to implement subclass onComputeInvariantOutput(). It assumes that
- * the subclass output color will be a modulation of the input color with a value read from the
- * texture.
- */
- void updateInvariantOutputForModulation(GrInvariantOutput* inout) const {
- GrPixelConfig config = this->textureSampler(0).texture()->config();
- if (GrPixelConfigIsAlphaOnly(config)) {
- inout->mulByUnknownSingleComponent();
- } else if (GrPixelConfigIsOpaque(config)) {
- inout->mulByUnknownOpaqueFourComponents();
- } else {
- inout->mulByUnknownFourComponents();
- }
- }
-
- /**
* Can be used as a helper to implement subclass onOptimizationFlags(). It assumes that
* the subclass output color will be a modulation of the input color with a value read from the
* texture.
#include "GrTextureDomain.h"
#include "GrContext.h"
-#include "GrInvariantOutput.h"
#include "GrShaderCaps.h"
#include "GrSimpleTextureEffect.h"
#include "GrSurfaceProxyPriv.h"
return this->fTextureDomain == s.fTextureDomain;
}
-void GrTextureDomainEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- if (GrTextureDomain::kDecal_Mode == fTextureDomain.mode()) {
- if (GrPixelConfigIsAlphaOnly(this->textureSampler(0).texture()->config())) {
- inout->mulByUnknownSingleComponent();
- } else {
- inout->mulByUnknownFourComponents();
- }
- } else {
- this->updateInvariantOutputForModulation(inout);
- }
-}
-
///////////////////////////////////////////////////////////////////////////////
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrTextureDomainEffect);
dstdfp.fTextureDomain == fTextureDomain;
}
-void GrDeviceSpaceTextureDecalFragmentProcessor::onComputeInvariantOutput(
- GrInvariantOutput* inout) const {
- if (GrPixelConfigIsAlphaOnly(this->textureSampler(0).texture()->config())) {
- inout->mulByUnknownSingleComponent();
- } else {
- inout->mulByUnknownFourComponents();
- }
-}
-
///////////////////////////////////////////////////////////////////////////////
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDeviceSpaceTextureDecalFragmentProcessor);
bool onIsEqual(const GrFragmentProcessor&) const override;
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
-
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
typedef GrSingleTextureEffect INHERITED;
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {}
bool onIsEqual(const GrFragmentProcessor& fp) const override;
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
#include "effects/GrXfermodeFragmentProcessor.h"
#include "GrFragmentProcessor.h"
-#include "GrInvariantOutput.h"
#include "effects/GrConstColorProcessor.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLBlend.h"
return fMode == cs.fMode;
}
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
- inout->setToUnknown();
- }
-
GrColor4f constantOutputForConstantInput(GrColor4f input) const override {
float alpha = input.fRGBA[3];
input = input.opaque();
return fMode == that.cast<ComposeOneFragmentProcessor>().fMode;
}
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
- SkXfermode::Coeff skSrcCoeff, skDstCoeff;
- if (SkXfermode::ModeAsCoeff(fMode, &skSrcCoeff, &skDstCoeff)) {
- GrBlendCoeff srcCoeff = SkXfermodeCoeffToGrBlendCoeff(skSrcCoeff);
- GrBlendCoeff dstCoeff = SkXfermodeCoeffToGrBlendCoeff(skDstCoeff);
- GrInvariantOutput childOutput(0xFFFFFFFF, kRGBA_GrColorComponentFlags);
- this->childProcessor(0).computeInvariantOutput(&childOutput);
- GrColor blendColor;
- GrColorComponentFlags blendFlags;
- if (kDst_Child == fChild) {
- GrGetCoeffBlendKnownComponents(srcCoeff, dstCoeff,
- inout->color(), inout->validFlags(),
- childOutput.color(), childOutput.validFlags(),
- &blendColor, &blendFlags);
- } else {
- GrGetCoeffBlendKnownComponents(srcCoeff, dstCoeff,
- childOutput.color(), childOutput.validFlags(),
- inout->color(), inout->validFlags(),
- &blendColor, &blendFlags);
- }
- inout->setToOther(blendFlags, blendColor);
- } else {
- inout->setToUnknown();
- }
- }
-
GrColor4f constantOutputForConstantInput(GrColor4f inputColor) const override {
GrColor4f childColor =
ConstantOutputForConstantInput(this->childProcessor(0), GrColor4f::OpaqueWhite());
#include "GrContext.h"
#include "GrCoordTransform.h"
#include "GrFragmentProcessor.h"
-#include "GrInvariantOutput.h"
#include "GrProcessor.h"
#include "GrTextureProxy.h"
#include "glsl/GrGLSLFragmentProcessor.h"
return (fColorSpace == s.getColorSpace()) && (fNV12 == s.isNV12());
}
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
- // YUV is opaque
- inout->setToOther(kA_GrColorComponentFlag, 0xFF << GrColor_SHIFT_A);
- }
-
GrCoordTransform fYTransform;
TextureSampler fYSampler;
GrCoordTransform fUTransform;
return fColorSpace == s.getColorSpace() && fOutputChannels == s.outputChannels();
}
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
- inout->setToUnknown();
- }
-
GrCoordTransform fTransform;
TextureSampler fTextureSampler;
SkYUVColorSpace fColorSpace;
#include "GrDefaultGeoProcFactory.h"
#include "GrDrawOpTest.h"
#include "GrGeometryProcessor.h"
-#include "GrInvariantOutput.h"
#include "GrOpFlushState.h"
#include "GrPathUtils.h"
#include "GrPipelineBuilder.h"
#include "GrDefaultGeoProcFactory.h"
#include "GrDrawOpTest.h"
#include "GrGeometryProcessor.h"
-#include "GrInvariantOutput.h"
#include "GrOpFlushState.h"
#include "GrPathUtils.h"
#include "GrPipelineBuilder.h"
#include "GrDrawOpTest.h"
#include "GrGeometryProcessor.h"
-#include "GrInvariantOutput.h"
#include "GrOpFlushState.h"
#include "GrProcessor.h"
#include "GrResourceProvider.h"
#include "GrDefaultGeoProcFactory.h"
#include "GrDrawOpTest.h"
#include "GrGeometryProcessor.h"
-#include "GrInvariantOutput.h"
#include "GrOpFlushState.h"
#include "GrProcessor.h"
#include "GrStyle.h"
#include "GrDrawOpTest.h"
#include "GrGeometryProcessor.h"
-#include "GrInvariantOutput.h"
#include "GrOpFlushState.h"
#include "GrProcessor.h"
#include "GrResourceProvider.h"
#include "GrContext.h"
#include "GrDefaultGeoProcFactory.h"
#include "GrDrawOpTest.h"
-#include "GrInvariantOutput.h"
#include "GrOpFlushState.h"
#include "GrPLSGeometryProcessor.h"
#include "GrPathUtils.h"
#include "GrContextPriv.h"
#include "GrDrawOpTest.h"
#include "GrDrawingManager.h"
-#include "GrInvariantOutput.h"
#include "GrPipeline.h"
#include "GrRenderTargetContextPriv.h"
#include "GrResourceProvider.h"
GLBigKeyProcessor::GenKey(*this, caps, b);
}
bool onIsEqual(const GrFragmentProcessor&) const override { return true; }
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override { }
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
bool onIsEqual(const GrFragmentProcessor&) const override { return true; }
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
- inout->setToOther(kRGBA_GrColorComponentFlags, GrColor_WHITE);
- this->childProcessor(0).computeInvariantOutput(inout);
- }
-
typedef GrFragmentProcessor INHERITED;
};
+++ /dev/null
-/*
- * Copyright 2013 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkColorFilter.h"
-#include "Test.h"
-
-#if SK_SUPPORT_GPU
-
-#include "GrContext.h"
-#include "GrFragmentProcessor.h"
-#include "GrInvariantOutput.h"
-#include "SkGr.h"
-
-static GrColor filterColor(const GrColor& color, uint32_t flags) {
- uint32_t mask = 0;
- if (flags & kR_GrColorComponentFlag) {
- mask = 0xFF << GrColor_SHIFT_R;
- }
- if (flags & kG_GrColorComponentFlag) {
- mask |= 0xFF << GrColor_SHIFT_G;
- }
- if (flags & kB_GrColorComponentFlag) {
- mask |= 0xFF << GrColor_SHIFT_B;
- }
- if (flags & kA_GrColorComponentFlag) {
- mask |= 0xFF << GrColor_SHIFT_A;
- }
- return color & mask;
-}
-
-DEF_GPUTEST_FOR_ALL_CONTEXTS(GpuColorFilter, reporter, ctxInfo) {
- struct GetConstantComponentTestCase {
- // "Shape drawn with"
- uint32_t inputComponents; // "rgb of", "red of", "alpha of", ...
- GrColor inputColor; // "[color]"
-
- SkColor filterColor; // "with filter color [color]"
- SkBlendMode filterMode; // "in mode [mode]"
-
- // "produces"
- uint32_t outputComponents; // "rgb of", "red of", "alpha of", ...
- GrColor outputColor; // "[color]"
- };
-
- // Shorthands.
- enum {
- kR = kR_GrColorComponentFlag,
- kG = kG_GrColorComponentFlag,
- kB = kB_GrColorComponentFlag,
- kA = kA_GrColorComponentFlag,
- kRGB = kRGB_GrColorComponentFlags,
- kRGBA = kRGBA_GrColorComponentFlags
- };
-
- // Note: below, SkColors are non-premultiplied, where as GrColors are premultiplied.
-
- const SkColor c1 = SkColorSetARGB(200, 200, 200, 200);
- const SkColor c2 = SkColorSetARGB(60, 60, 60, 60);
- const GrColor gr_c1 = SkColorToPremulGrColor(c1);
- const GrColor gr_c2 = SkColorToPremulGrColor(c2);
-
- const GrColor gr_black = GrColorPackA4(0);
- const GrColor gr_white = GrColorPackA4(255);
- const GrColor gr_whiteTrans = GrColorPackA4(128);
-
- GetConstantComponentTestCase filterTests[] = {
- // A color filtered with Clear produces black.
- { kRGBA, gr_white, SK_ColorBLACK, SkBlendMode::kClear, kRGBA, gr_black },
- { kRGBA, gr_c1, SK_ColorWHITE, SkBlendMode::kClear, kRGBA, gr_black },
- { kR, gr_white, c1, SkBlendMode::kClear, kRGBA, gr_black },
-
- // A color filtered with a color in mode Src, produces the filter color.
- { kRGBA, gr_c2, c1, SkBlendMode::kSrc, kRGBA, gr_c1 },
- { kA, gr_c1, c1, SkBlendMode::kSrc, kRGBA, gr_c1 },
-
- // A color filtered with SrcOver produces a color.
- { kRGBA, gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkBlendMode::kSrcOver, kRGBA, GrColorPackRGBA(164, 164, 164, 192)},
- // An unknown color with known alpha filtered with SrcOver produces an unknown color with known alpha.
- { kA , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkBlendMode::kSrcOver, kA , GrColorPackRGBA(0, 0, 0, 192)},
- // A color with unknown alpha filtered with SrcOver produces a color with unknown alpha.
- { kRGB , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkBlendMode::kSrcOver, kRGB, GrColorPackRGBA(164, 164, 164, 0)},
-
- // A color filtered with DstOver produces a color.
- { kRGBA, gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkBlendMode::kDstOver, kRGBA, GrColorPackRGBA(178, 178, 178, 192)},
- // An unknown color with known alpha filtered with DstOver produces an unknown color with known alpha.
- { kA , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkBlendMode::kDstOver, kA , GrColorPackRGBA(0, 0, 0, 192)},
- // A color with unknown alpha filtered with DstOver produces an unknown color.
- { kRGB , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkBlendMode::kDstOver, 0 , gr_black},
-
- // An unknown color with known alpha and red component filtered with Multiply produces an unknown color with known red and alpha.
- { kR|kA , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkBlendMode::kModulate, kR|kA, GrColorPackRGBA(50, 0, 0, 64) }
- };
-
- GrPaint paint;
- for (size_t i = 0; i < SK_ARRAY_COUNT(filterTests); ++i) {
- const GetConstantComponentTestCase& test = filterTests[i];
- auto cf(SkColorFilter::MakeModeFilter(test.filterColor, test.filterMode));
- // TODO: Test other color spaces
- sk_sp<GrFragmentProcessor> fp(cf->asFragmentProcessor(ctxInfo.grContext(), nullptr));
- REPORTER_ASSERT(reporter, fp);
- GrInvariantOutput inout(test.inputColor,
- static_cast<GrColorComponentFlags>(test.inputComponents));
- fp->computeInvariantOutput(&inout);
- REPORTER_ASSERT(reporter, filterColor(inout.color(), inout.validFlags()) ==
- test.outputColor);
- REPORTER_ASSERT(reporter, test.outputComponents == inout.validFlags());
- }
-}
-
-#endif
#if SK_SUPPORT_GPU
#include "GrFragmentProcessor.h"
-#include "GrInvariantOutput.h"
#include "GrRenderTargetContext.h"
#include "GrTexture.h"
#include "glsl/GrGLSLFragmentProcessor.h"
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {}
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
- inout->setToUnknown();
- }
-
bool onIsEqual(const GrFragmentProcessor& that) const override { return true; }
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override {
b->add32(sk_atomic_inc(&gKey));
}
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
- // We don't care about optimizing these processors.
- inout->setToUnknown();
- }
-
private:
TestFP(const SkTArray<sk_sp<GrTexture>>& textures, const SkTArray<sk_sp<GrBuffer>>& buffers,
const SkTArray<Image>& images)