#if SK_SUPPORT_GPU
#include "GrFragmentProcessor.h"
#include "GrCoordTransform.h"
-#include "effects/GrExtractAlphaFragmentProcessor.h"
#include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "Resources.h"
buf.writeMatrix(fDeviceMatrix);
}
- const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& viewM,
- const SkMatrix* localMatrix, SkFilterQuality, GrProcessorDataManager*) const override;
+ bool asFragmentProcessor(GrContext*, const SkPaint& paint, const SkMatrix& viewM,
+ const SkMatrix* localMatrix, GrColor* color, GrProcessorDataManager*,
+ GrFragmentProcessor** fp) const override;
#ifndef SK_IGNORE_TO_STRING
void toString(SkString* str) const override {
GrCoordTransform fDeviceTransform;
};
-const GrFragmentProcessor* DCShader::asFragmentProcessor(GrContext*, const SkMatrix& viewM,
- const SkMatrix* localMatrix, SkFilterQuality, GrProcessorDataManager* procDataManager) const {
- SkAutoTUnref<const GrFragmentProcessor> inner(new DCFP(procDataManager, fDeviceMatrix));
- return GrExtractAlphaFragmentProcessor::Create(inner);
+bool DCShader::asFragmentProcessor(GrContext*, const SkPaint& paint, const SkMatrix& viewM,
+ const SkMatrix* localMatrix, GrColor* color,
+ GrProcessorDataManager* procDataManager,
+ GrFragmentProcessor** fp) const {
+ *fp = new DCFP(procDataManager, fDeviceMatrix);
+ *color = GrColorPackA4(paint.getAlpha());
+ return true;
}
class DCShaderGM : public GM {
'<(skia_include_path)/gpu/effects/GrConstColorProcessor.h',
'<(skia_include_path)/gpu/effects/GrCoverageSetOpXP.h',
'<(skia_include_path)/gpu/effects/GrCustomXfermode.h',
- '<(skia_include_path)/gpu/effects/GrExtractAlphaFragmentProcessor.h',
'<(skia_include_path)/gpu/effects/GrPorterDuffXferProcessor.h',
'<(skia_include_path)/gpu/gl/GrGLConfig.h',
'<(skia_src_path)/gpu/effects/GrConfigConversionEffect.cpp',
'<(skia_src_path)/gpu/effects/GrConfigConversionEffect.h',
'<(skia_src_path)/gpu/effects/GrConstColorProcessor.cpp',
- '<(skia_src_path)/gpu/effects/GrExtractAlphaFragmentProcessor.cpp',
'<(skia_src_path)/gpu/effects/GrCoverageSetOpXP.cpp',
'<(skia_src_path)/gpu/effects/GrCustomXfermode.cpp',
'<(skia_src_path)/gpu/effects/GrCustomXfermodePriv.h',
/**
- * Returns a GrFragmentProcessor that implements the shader for the GPU backend. NULL is
- * returned if there is no GPU implementation.
+ * Returns true if the shader subclass succeeds in creating an effect or if none is required.
+ * False is returned if it fails or if there is not an implementation of this method in the
+ * shader subclass.
*
- * The GPU device does not call SkShader::createContext(), instead we pass the view matrix,
- * local matrix, and filter quality directly.
+ * On success an implementation of this method must inspect the SkPaint and set paintColor to
+ * the color the effect expects as its input color. If the SkShader wishes to emit a solid
+ * color then it should set paintColor to that color and not create an effect. Note that
+ * GrColor is always premul. The common patterns are to convert paint's SkColor to GrColor or
+ * to extract paint's alpha and replicate it to all channels in paintColor. Upon failure
+ * paintColor should not be modified. It is not recommended to specialize the effect to
+ * the paint's color as then many GPU shaders may be generated.
*
- * The GrContext may be used by the to create textures that are required by the returned
- * processor.
+ * The GrContext may be used by the effect to create textures. The GPU device does not
+ * call createContext. Instead we pass the SkPaint here in case the shader needs paint info.
+ *
+ * A view matrix is always required to create the correct GrFragmentProcessor. Some shaders
+ * may also use the optional localMatrix to define a matrix relevant only for sampling.
*/
- virtual const GrFragmentProcessor* asFragmentProcessor(GrContext*,
- const SkMatrix& viewMatric,
- const SkMatrix* localMatrix,
- SkFilterQuality,
- GrProcessorDataManager*) const;
+ virtual bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix& viewM,
+ const SkMatrix* localMatrix, GrColor*,
+ GrProcessorDataManager*, GrFragmentProcessor**) const;
/**
* If the shader can represent its "average" luminance in a single color, return true and
typedef SkShader::Context INHERITED;
};
-#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext* context, const SkMatrix& viewM,
- const SkMatrix*, SkFilterQuality,
- GrProcessorDataManager*) const override;
-#endif
+ virtual bool asFragmentProcessor(GrContext* context, const SkPaint&, const SkMatrix& viewM,
+ const SkMatrix*, GrColor*, GrProcessorDataManager*,
+ GrFragmentProcessor**) const override;
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPerlinNoiseShader)
#define GrFragmentProcessor_DEFINED
#include "GrProcessor.h"
-#include "GrInvariantOutput.h"
class GrCoordTransform;
class GrGLSLCaps;
* 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);
- }
+ void computeInvariantOutput(GrInvariantOutput* inout) const;
protected:
void addTextureAccess(const GrTextureAccess* textureAccess) override;
class GrProcessorTestFactory : SkNoncopyable {
public:
- typedef const Processor* (*CreateProc)(GrProcessorTestData*);
+ typedef Processor* (*CreateProc)(GrProcessorTestData*);
GrProcessorTestFactory(CreateProc createProc) {
fCreateProc = createProc;
GetFactories()->push_back(this);
}
- static const Processor* CreateStage(GrProcessorTestData* data) {
+ static Processor* CreateStage(GrProcessorTestData* data) {
VerifyFactoryCount();
SkASSERT(GetFactories()->count());
uint32_t idx = data->fRandom->nextRangeU(0, GetFactories()->count() - 1);
*/
#define GR_DECLARE_GEOMETRY_PROCESSOR_TEST \
static GrProcessorTestFactory<GrGeometryProcessor> gTestFactory SK_UNUSED; \
- static const GrGeometryProcessor* TestCreate(GrProcessorTestData*)
+ static GrGeometryProcessor* TestCreate(GrProcessorTestData*)
#define GR_DECLARE_FRAGMENT_PROCESSOR_TEST \
static GrProcessorTestFactory<GrFragmentProcessor> gTestFactory SK_UNUSED; \
- static const GrFragmentProcessor* TestCreate(GrProcessorTestData*)
+ static GrFragmentProcessor* TestCreate(GrProcessorTestData*)
#define GR_DECLARE_XP_FACTORY_TEST \
static GrProcessorTestFactory<GrXPFactory> gTestFactory SK_UNUSED; \
- static const GrXPFactory* TestCreate(GrProcessorTestData*)
+ static GrXPFactory* TestCreate(GrProcessorTestData*)
/** GrProcessor subclasses should insert this macro in their implementation file. They must then
// The unit test relies on static initializers. Just declare the TestCreate function so that
// its definitions will compile.
#define GR_DECLARE_FRAGMENT_PROCESSOR_TEST \
- static const GrFragmentProcessor* TestCreate(GrProcessorTestData*)
+ static GrFragmentProcessor* TestCreate(GrProcessorTestData*)
#define GR_DEFINE_FRAGMENT_PROCESSOR_TEST(X)
// The unit test relies on static initializers. Just declare the TestCreate function so that
// its definitions will compile.
#define GR_DECLARE_XP_FACTORY_TEST \
- static const GrXPFactory* TestCreate(GrProcessorTestData*)
+ static GrXPFactory* TestCreate(GrProcessorTestData*)
#define GR_DEFINE_XP_FACTORY_TEST(X)
// The unit test relies on static initializers. Just declare the TestCreate function so that
// its definitions will compile.
#define GR_DECLARE_GEOMETRY_PROCESSOR_TEST \
- static const GrGeometryProcessor* TestCreate(GrProcessorTestData*)
+ static GrGeometryProcessor* TestCreate(GrProcessorTestData*)
#define GR_DEFINE_GEOMETRY_PROCESSOR_TEST(X)
#endif // !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
#include "GrFragmentProcessor.h"
+class GrInvariantOutput;
+
/**
* This is a simple GrFragmentProcessor that outputs a constant color. It may do one of the
* following with its input color: ignore it, or multiply it by the constant color, multiply its
return new GrConstColorProcessor(color, mode);
}
+ ~GrConstColorProcessor() override {}
+
const char* name() const override { return "Color"; }
GrColor color() const { return fColor; }
+++ /dev/null
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrExtractAlphaFragmentProcessor_DEFINED
-#define GrExtractAlphaFragmentProcessor_DEFINED
-
-#include "GrFragmentProcessor.h"
-
-/** This processor extracts the incoming color's alpha, ignores r, g, and b, and feeds
- the replicated alpha to it's inner processor. */
-class GrExtractAlphaFragmentProcessor : public GrFragmentProcessor {
-public:
- static GrFragmentProcessor* Create(const GrFragmentProcessor* processor) {
- if (!processor) {
- return nullptr;
- }
- return SkNEW_ARGS(GrExtractAlphaFragmentProcessor, (processor));
- }
-
- ~GrExtractAlphaFragmentProcessor() override {}
-
- const char* name() const override { return "Extract Alpha"; }
-
-private:
- GrExtractAlphaFragmentProcessor(const GrFragmentProcessor* processor) {
- this->initClassID<GrExtractAlphaFragmentProcessor>();
- this->registerChildProcessor(processor);
- }
-
- GrGLFragmentProcessor* onCreateGLInstance() const override;
-
- void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override;
-
- bool onIsEqual(const GrFragmentProcessor&) const override;
-
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
-
- typedef GrFragmentProcessor INHERITED;
-};
-
-#endif
#if SK_SUPPORT_GPU
#include "effects/GrBicubicEffect.h"
-#include "effects/GrExtractAlphaFragmentProcessor.h"
#include "effects/GrSimpleTextureEffect.h"
#endif
#include "SkGr.h"
#include "effects/GrSimpleTextureEffect.h"
-const GrFragmentProcessor* SkBitmapProcShader::asFragmentProcessor(GrContext* context,
- const SkMatrix& viewM, const SkMatrix* localMatrix,
- SkFilterQuality filterQuality,
- GrProcessorDataManager* procDataManager) const {
+bool SkBitmapProcShader::asFragmentProcessor(GrContext* context, const SkPaint& paint,
+ const SkMatrix& viewM,
+ const SkMatrix* localMatrix, GrColor* paintColor,
+ GrProcessorDataManager* procDataManager,
+ GrFragmentProcessor** fp) const {
SkMatrix matrix;
matrix.setIDiv(fRawBitmap.width(), fRawBitmap.height());
SkMatrix lmInverse;
if (!this->getLocalMatrix().invert(&lmInverse)) {
- return nullptr;
+ return false;
}
if (localMatrix) {
SkMatrix inv;
if (!localMatrix->invert(&inv)) {
- return nullptr;
+ return false;
}
lmInverse.postConcat(inv);
}
// are provided by the caller.
bool doBicubic;
GrTextureParams::FilterMode textureFilterMode =
- GrSkFilterQualityToGrFilterMode(filterQuality, viewM, this->getLocalMatrix(),
+ GrSkFilterQualityToGrFilterMode(paint.getFilterQuality(), viewM, this->getLocalMatrix(),
&doBicubic);
GrTextureParams params(tm, textureFilterMode);
SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(context, fRawBitmap, ¶ms));
if (!texture) {
SkErrorInternals::SetError( kInternalError_SkError,
"Couldn't convert bitmap to texture.");
- return nullptr;
+ return false;
}
- SkAutoTUnref<GrFragmentProcessor> inner;
+ *paintColor = (kAlpha_8_SkColorType == fRawBitmap.colorType()) ?
+ SkColor2GrColor(paint.getColor()) :
+ SkColor2GrColorJustAlpha(paint.getColor());
+
if (doBicubic) {
- inner.reset(GrBicubicEffect::Create(procDataManager, texture, matrix, tm));
+ *fp = GrBicubicEffect::Create(procDataManager, texture, matrix, tm);
} else {
- inner.reset(GrSimpleTextureEffect::Create(procDataManager, texture, matrix, params));
+ *fp = GrSimpleTextureEffect::Create(procDataManager, texture, matrix, params);
}
- if (kAlpha_8_SkColorType == fRawBitmap.colorType()) {
- return SkRef(inner.get());
- }
- return GrExtractAlphaFragmentProcessor::Create(inner);
+ return true;
+}
+
+#else
+
+bool SkBitmapProcShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix&,
+ const SkMatrix*, GrColor*, GrProcessorDataManager*,
+ GrFragmentProcessor**) const {
+ SkDEBUGFAIL("Should not call in GPU-less build");
+ return false;
}
#endif
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader)
-#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& viewM,
- const SkMatrix*, SkFilterQuality,
- GrProcessorDataManager*) const override;
-#endif
+
+ bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix& viewM, const SkMatrix*,
+ GrColor*, GrProcessorDataManager*,
+ GrFragmentProcessor**) const override;
class BitmapProcShaderContext : public SkShader::Context {
public:
GradientType asAGradient(GradientInfo* info) const override;
-#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& viewM,
- const SkMatrix*, SkFilterQuality,
- GrProcessorDataManager*) const override;
-#endif
+ bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix& viewM,
+ const SkMatrix*, GrColor*, GrProcessorDataManager*,
+ GrFragmentProcessor**) const override;
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorShader)
bool isOpaque() const override;
-#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& viewM,
- const SkMatrix* localMatrix, SkFilterQuality, GrProcessorDataManager*) const override;
-#endif
+ bool asFragmentProcessor(GrContext*, const SkPaint& paint, const SkMatrix& viewM,
+ const SkMatrix* localMatrix, GrColor* color,
+ GrProcessorDataManager*, GrFragmentProcessor** fp) const override;
size_t contextSize() const override;
#include "GrCoordTransform.h"
#include "GrFragmentProcessor.h"
#include "GrTextureAccess.h"
-#include "effects/GrExtractAlphaFragmentProcessor.h"
#include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "SkGr.h"
return true;
}
-const GrFragmentProcessor* SkLightingShaderImpl::asFragmentProcessor(GrContext* context,
- const SkMatrix& viewM, const SkMatrix* localMatrix, SkFilterQuality filterQuality,
- GrProcessorDataManager* pdm) const {
+bool SkLightingShaderImpl::asFragmentProcessor(GrContext* context, const SkPaint& paint,
+ const SkMatrix& viewM, const SkMatrix* localMatrix,
+ GrColor* color, GrProcessorDataManager* pdm,
+ GrFragmentProcessor** fp) const {
// we assume diffuse and normal maps have same width and height
// TODO: support different sizes
SkASSERT(fDiffuseMap.width() == fNormalMap.width() &&
SkMatrix diffM, normM;
if (!make_mat(fDiffuseMap, this->getLocalMatrix(), localMatrix, &diffM)) {
- return nullptr;
+ return false;
}
if (!make_mat(fNormalMap, fNormLocalMatrix, localMatrix, &normM)) {
- return nullptr;
+ return false;
}
bool doBicubic;
GrTextureParams::FilterMode diffFilterMode = GrSkFilterQualityToGrFilterMode(
- SkTMin(filterQuality, kMedium_SkFilterQuality),
+ SkTMin(paint.getFilterQuality(), kMedium_SkFilterQuality),
viewM,
this->getLocalMatrix(),
&doBicubic);
SkASSERT(!doBicubic);
GrTextureParams::FilterMode normFilterMode = GrSkFilterQualityToGrFilterMode(
- SkTMin(filterQuality, kMedium_SkFilterQuality),
+ SkTMin(paint.getFilterQuality(), kMedium_SkFilterQuality),
viewM,
fNormLocalMatrix,
&doBicubic);
SkAutoTUnref<GrTexture> diffuseTexture(GrRefCachedBitmapTexture(context,
fDiffuseMap, &diffParams));
if (!diffuseTexture) {
- SkErrorInternals::SetError(kInternalError_SkError, "Couldn't convert bitmap to texture.");
- return nullptr;
+ SkErrorInternals::SetError(kInternalError_SkError,
+ "Couldn't convert bitmap to texture.");
+ return false;
}
GrTextureParams normParams(kClamp_TileMode, normFilterMode);
SkAutoTUnref<GrTexture> normalTexture(GrRefCachedBitmapTexture(context,
fNormalMap, &normParams));
if (!normalTexture) {
- SkErrorInternals::SetError(kInternalError_SkError, "Couldn't convert bitmap to texture.");
- return nullptr;
+ SkErrorInternals::SetError(kInternalError_SkError,
+ "Couldn't convert bitmap to texture.");
+ return false;
}
- SkAutoTUnref<const GrFragmentProcessor> inner (
- new LightingFP(pdm, diffuseTexture, normalTexture, diffM, normM, diffParams, normParams,
- fLights, fInvNormRotation));
- return GrExtractAlphaFragmentProcessor::Create(inner);
+ *fp = new LightingFP(pdm, diffuseTexture, normalTexture, diffM, normM, diffParams, normParams,
+ fLights, fInvNormRotation);
+
+ *color = GrColorPackA4(paint.getAlpha());
+ return true;
+}
+#else
+
+bool SkLightingShaderImpl::asFragmentProcessor(GrContext* context, const SkPaint& paint,
+ const SkMatrix& viewM, const SkMatrix* localMatrix,
+ GrColor* color, GrProcessorDataManager*,
+ GrFragmentProcessor** fp) const {
+ SkDEBUGFAIL("Should not call in GPU-less build");
+ return false;
}
#endif
}
#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext* context, const SkMatrix& viewM,
- const SkMatrix* localMatrix, SkFilterQuality fq,
- GrProcessorDataManager* procDataManager) const override {
+
+ virtual bool asFragmentProcessor(GrContext* context, const SkPaint& paint,
+ const SkMatrix& viewM, const SkMatrix* localMatrix,
+ GrColor* grColor, GrProcessorDataManager* procDataManager,
+ GrFragmentProcessor** fp) const override {
SkMatrix tmp = this->getLocalMatrix();
if (localMatrix) {
tmp.preConcat(*localMatrix);
}
- return fProxyShader->asFragmentProcessor(context, viewM, &tmp, fq, procDataManager);
+ return fProxyShader->asFragmentProcessor(context, paint, viewM, &tmp, grColor,
+ procDataManager, fp);
}
+
+#else
+
+ virtual bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix&,
+ const SkMatrix*, GrColor*, GrProcessorDataManager*,
+ GrFragmentProcessor**) const override {
+ SkDEBUGFAIL("Should not call in GPU-less build");
+ return false;
+ }
+
#endif
SkShader* refAsALocalMatrixShader(SkMatrix* localMatrix) const override {
#endif
#if SK_SUPPORT_GPU
-const GrFragmentProcessor* SkPictureShader::asFragmentProcessor(GrContext* context,
- const SkMatrix& viewM, const SkMatrix* localMatrix, SkFilterQuality fq,
- GrProcessorDataManager* procDataManager) const {
+bool SkPictureShader::asFragmentProcessor(GrContext* context, const SkPaint& paint,
+ const SkMatrix& viewM, const SkMatrix* localMatrix,
+ GrColor* paintColor,
+ GrProcessorDataManager* procDataManager,
+ GrFragmentProcessor** fp) const {
int maxTextureSize = 0;
if (context) {
maxTextureSize = context->caps()->maxTextureSize();
}
SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(viewM, localMatrix, maxTextureSize));
if (!bitmapShader) {
- return nullptr;
+ return false;
}
- return bitmapShader->asFragmentProcessor(context, viewM, nullptr, fq, procDataManager);
+ return bitmapShader->asFragmentProcessor(context, paint, viewM, nullptr, paintColor,
+ procDataManager, fp);
+}
+#else
+bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix&,
+ const SkMatrix*, GrColor*, GrProcessorDataManager*,
+ GrFragmentProcessor**) const {
+ SkDEBUGFAIL("Should not call in GPU-less build");
+ return false;
}
#endif
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureShader)
-#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& viewM,
- const SkMatrix*, SkFilterQuality, GrProcessorDataManager*) const override;
-#endif
+ bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix& viewM, const SkMatrix*,
+ GrColor*, GrProcessorDataManager*,
+ GrFragmentProcessor**) const override;
protected:
SkPictureShader(SkReadBuffer&);
return kNone_GradientType;
}
-const GrFragmentProcessor* SkShader::asFragmentProcessor(GrContext*, const SkMatrix&,
- const SkMatrix*, SkFilterQuality,
- GrProcessorDataManager*) const {
- return nullptr;
+bool SkShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix&, const SkMatrix*,
+ GrColor*, GrProcessorDataManager*,
+ GrFragmentProcessor**) const {
+ return false;
}
SkShader* SkShader::refAsALocalMatrixShader(SkMatrix*) const {
#if SK_SUPPORT_GPU
#include "SkGr.h"
-#include "effects/GrConstColorProcessor.h"
-const GrFragmentProcessor* SkColorShader::asFragmentProcessor(GrContext*, const SkMatrix&,
- const SkMatrix*, SkFilterQuality,
- GrProcessorDataManager*) const {
- GrColor color = SkColor2GrColor(fColor);
- return GrConstColorProcessor::Create(color, GrConstColorProcessor::kModulateA_InputMode);
+
+bool SkColorShader::asFragmentProcessor(GrContext*, const SkPaint& paint, const SkMatrix&,
+ const SkMatrix*, GrColor* paintColor,
+ GrProcessorDataManager*, GrFragmentProcessor** fp) const {
+ *fp = nullptr;
+ SkColor skColor = fColor;
+ U8CPU newA = SkMulDiv255Round(SkColorGetA(fColor), paint.getAlpha());
+ *paintColor = SkColor2GrColor(SkColorSetA(skColor, newA));
+ return true;
+}
+
+#else
+
+bool SkColorShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix&,
+ const SkMatrix*, GrColor*, GrProcessorDataManager*,
+ GrFragmentProcessor**) const {
+ SkDEBUGFAIL("Should not call in GPU-less build");
+ return false;
}
#endif
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(AlphaThresholdEffect);
-const GrFragmentProcessor* AlphaThresholdEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* AlphaThresholdEffect::TestCreate(GrProcessorTestData* d) {
GrTexture* bmpTex = d->fTextures[GrProcessorUnitTest::kSkiaPMTextureIdx];
GrTexture* maskTex = d->fTextures[GrProcessorUnitTest::kAlphaTextureIdx];
float innerThresh = d->fRandom->nextUScalar1();
///////////////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* GrArithmeticFP::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* GrArithmeticFP::TestCreate(GrProcessorTestData* d) {
float k1 = d->fRandom->nextF();
float k2 = d->fRandom->nextF();
float k3 = d->fRandom->nextF();
GR_DEFINE_XP_FACTORY_TEST(GrArithmeticXPFactory);
-const GrXPFactory* GrArithmeticXPFactory::TestCreate(GrProcessorTestData* d) {
+GrXPFactory* GrArithmeticXPFactory::TestCreate(GrProcessorTestData* d) {
float k1 = d->fRandom->nextF();
float k2 = d->fRandom->nextF();
float k3 = d->fRandom->nextF();
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRectBlurEffect);
-const GrFragmentProcessor* GrRectBlurEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* GrRectBlurEffect::TestCreate(GrProcessorTestData* d) {
float sigma = d->fRandom->nextRangeF(3,8);
float width = d->fRandom->nextRangeF(200,300);
float height = d->fRandom->nextRangeF(200,300);
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRRectBlurEffect);
-const GrFragmentProcessor* GrRRectBlurEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* GrRRectBlurEffect::TestCreate(GrProcessorTestData* d) {
SkScalar w = d->fRandom->nextRangeScalar(100.f, 1000.f);
SkScalar h = d->fRandom->nextRangeScalar(100.f, 1000.f);
SkScalar r = d->fRandom->nextRangeF(1.f, 9.f);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ModeColorFilterEffect);
-const GrFragmentProcessor* ModeColorFilterEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* ModeColorFilterEffect::TestCreate(GrProcessorTestData* d) {
SkXfermode::Mode mode = SkXfermode::kDst_Mode;
while (SkXfermode::kDst_Mode == mode) {
mode = static_cast<SkXfermode::Mode>(d->fRandom->nextRangeU(0, SkXfermode::kLastCoeffMode));
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ColorMatrixEffect);
-const GrFragmentProcessor* ColorMatrixEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* ColorMatrixEffect::TestCreate(GrProcessorTestData* d) {
SkColorMatrix colorMatrix;
for (size_t i = 0; i < SK_ARRAY_COUNT(colorMatrix.fMat); ++i) {
colorMatrix.fMat[i] = d->fRandom->nextSScalar1();
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDisplacementMapEffect);
-const GrFragmentProcessor* GrDisplacementMapEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* GrDisplacementMapEffect::TestCreate(GrProcessorTestData* d) {
int texIdxDispl = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
int texIdxColor = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDiffuseLightingEffect);
-const GrFragmentProcessor* GrDiffuseLightingEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* GrDiffuseLightingEffect::TestCreate(GrProcessorTestData* d) {
SkScalar surfaceScale = d->fRandom->nextSScalar1();
SkScalar kd = d->fRandom->nextUScalar1();
SkAutoTUnref<SkImageFilterLight> light(create_random_light(d->fRandom));
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSpecularLightingEffect);
-const GrFragmentProcessor* GrSpecularLightingEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* GrSpecularLightingEffect::TestCreate(GrProcessorTestData* d) {
SkScalar surfaceScale = d->fRandom->nextSScalar1();
SkScalar ks = d->fRandom->nextUScalar1();
SkScalar shininess = d->fRandom->nextUScalar1();
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMagnifierEffect);
-const GrFragmentProcessor* GrMagnifierEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* GrMagnifierEffect::TestCreate(GrProcessorTestData* d) {
GrTexture* texture = d->fTextures[0];
const int kMaxWidth = 200;
const int kMaxHeight = 200;
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMorphologyEffect);
-const GrFragmentProcessor* GrMorphologyEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* GrMorphologyEffect::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
Direction dir = d->fRandom->nextBool() ? kX_Direction : kY_Direction;
#include "GrCoordTransform.h"
#include "GrInvariantOutput.h"
#include "SkGr.h"
-#include "effects/GrConstColorProcessor.h"
-#include "effects/GrExtractAlphaFragmentProcessor.h"
#include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#endif
bool fStitchTiles;
int fNumOctaves;
GrGLProgramDataManager::UniformHandle fBaseFrequencyUni;
+ GrGLProgramDataManager::UniformHandle fAlphaUni;
private:
typedef GrGLFragmentProcessor INHERITED;
int numOctaves, bool stitchTiles,
SkPerlinNoiseShader::PaintingData* paintingData,
GrTexture* permutationsTexture, GrTexture* noiseTexture,
- const SkMatrix& matrix) {
+ const SkMatrix& matrix, uint8_t alpha) {
return new GrPerlinNoiseEffect(procDataManager, type, numOctaves, stitchTiles, paintingData,
- permutationsTexture, noiseTexture, matrix);
+ permutationsTexture, noiseTexture, matrix, alpha);
}
virtual ~GrPerlinNoiseEffect() { delete fPaintingData; }
const SkVector& baseFrequency() const { return fPaintingData->fBaseFrequency; }
int numOctaves() const { return fNumOctaves; }
const SkMatrix& matrix() const { return fCoordTransform.getMatrix(); }
+ uint8_t alpha() const { return fAlpha; }
private:
GrGLFragmentProcessor* onCreateGLInstance() const override {
fPaintingData->fBaseFrequency == s.fPaintingData->fBaseFrequency &&
fNumOctaves == s.fNumOctaves &&
fStitchTiles == s.fStitchTiles &&
+ fAlpha == s.fAlpha &&
fPaintingData->fStitchDataInit == s.fPaintingData->fStitchDataInit;
}
int numOctaves, bool stitchTiles,
SkPerlinNoiseShader::PaintingData* paintingData,
GrTexture* permutationsTexture, GrTexture* noiseTexture,
- const SkMatrix& matrix)
+ const SkMatrix& matrix, uint8_t alpha)
: fType(type)
, fNumOctaves(numOctaves)
, fStitchTiles(stitchTiles)
+ , fAlpha(alpha)
, fPermutationsAccess(permutationsTexture)
, fNoiseAccess(noiseTexture)
, fPaintingData(paintingData) {
GrCoordTransform fCoordTransform;
int fNumOctaves;
bool fStitchTiles;
+ uint8_t fAlpha;
GrTextureAccess fPermutationsAccess;
GrTextureAccess fNoiseAccess;
SkPerlinNoiseShader::PaintingData *fPaintingData;
/////////////////////////////////////////////////////////////////////
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrPerlinNoiseEffect);
-const GrFragmentProcessor* GrPerlinNoiseEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* GrPerlinNoiseEffect::TestCreate(GrProcessorTestData* d) {
int numOctaves = d->fRandom->nextRangeU(2, 10);
bool stitchTiles = d->fRandom->nextBool();
SkScalar seed = SkIntToScalar(d->fRandom->nextU());
SkPerlinNoiseShader::CreateTurbulence(baseFrequencyX, baseFrequencyY, numOctaves, seed,
stitchTiles ? &tileSize : nullptr);
+ SkPaint paint;
+ GrColor paintColor;
GrFragmentProcessor* effect;
GrPaint grPaint;
- return shader->asFragmentProcessor(d->fContext,
- GrTest::TestMatrix(d->fRandom), NULL,
- kNone_SkFilterQuality,
- grPaint.getProcessorDataManager());
+ SkAssertResult(shader->asFragmentProcessor(d->fContext, paint,
+ GrTest::TestMatrix(d->fRandom), nullptr,
+ &paintColor, grPaint.getProcessorDataManager(),
+ &effect));
delete shader;
kVec2f_GrSLType, kDefault_GrSLPrecision,
"baseFrequency");
const char* baseFrequencyUni = args.fBuilder->getUniformCStr(fBaseFrequencyUni);
+ fAlphaUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+ kFloat_GrSLType, kDefault_GrSLPrecision,
+ "alpha");
+ const char* alphaUni = args.fBuilder->getUniformCStr(fAlphaUni);
const char* stitchDataUni = nullptr;
if (fStitchTiles) {
args.fOutputColor,args.fOutputColor);
}
+ fsBuilder->codeAppendf("\n\t\t%s.a *= %s;", args.fOutputColor, alphaUni);
+
// Clamp values
fsBuilder->codeAppendf("\n\t\t%s = clamp(%s, 0.0, 1.0);", args.fOutputColor, args.fOutputColor);
const SkVector& baseFrequency = turbulence.baseFrequency();
pdman.set2f(fBaseFrequencyUni, baseFrequency.fX, baseFrequency.fY);
+ pdman.set1f(fAlphaUni, SkIntToScalar(turbulence.alpha()) / 255);
if (turbulence.stitchTiles()) {
const SkPerlinNoiseShader::StitchData& stitchData = turbulence.stitchData();
}
/////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* SkPerlinNoiseShader::asFragmentProcessor(GrContext* context,
- const SkMatrix& viewM, const SkMatrix* externalLocalMatrix, SkFilterQuality,
- GrProcessorDataManager* procDataManager) const {
+
+bool SkPerlinNoiseShader::asFragmentProcessor(GrContext* context, const SkPaint& paint,
+ const SkMatrix& viewM,
+ const SkMatrix* externalLocalMatrix,
+ GrColor* paintColor,
+ GrProcessorDataManager* procDataManager,
+ GrFragmentProcessor** fp) const {
SkASSERT(context);
+ *paintColor = SkColor2GrColorJustAlpha(paint.getColor());
+
SkMatrix localMatrix = this->getLocalMatrix();
if (externalLocalMatrix) {
localMatrix.preConcat(*externalLocalMatrix);
if (0 == fNumOctaves) {
if (kFractalNoise_Type == fType) {
- // Extract the incoming alpha and emit rgba = (a/4, a/4, a/4, a/2)
- SkAutoTUnref<const GrFragmentProcessor> inner(
- GrConstColorProcessor::Create(0x80404040,
- GrConstColorProcessor::kModulateRGBA_InputMode));
- return GrExtractAlphaFragmentProcessor::Create(inner);
+ uint32_t alpha = paint.getAlpha() >> 1;
+ uint32_t rgb = alpha >> 1;
+ *paintColor = GrColorPackRGBA(rgb, rgb, rgb, alpha);
+ } else {
+ *paintColor = 0;
}
- // Emit zero.
- return GrConstColorProcessor::Create(0x0, GrConstColorProcessor::kIgnore_InputMode);
+ return true;
}
// Either we don't stitch tiles, either we have a valid tile size
m.setTranslateX(-localMatrix.getTranslateX() + SK_Scalar1);
m.setTranslateY(-localMatrix.getTranslateY() + SK_Scalar1);
if ((permutationsTexture) && (noiseTexture)) {
- SkAutoTUnref<GrFragmentProcessor> inner(
- GrPerlinNoiseEffect::Create(procDataManager,
- fType,
- fNumOctaves,
- fStitchTiles,
- paintingData,
- permutationsTexture, noiseTexture,
- m));
- return GrExtractAlphaFragmentProcessor::Create(inner);
- }
- delete paintingData;
- return nullptr;
+ *fp = GrPerlinNoiseEffect::Create(procDataManager,
+ fType,
+ fNumOctaves,
+ fStitchTiles,
+ paintingData,
+ permutationsTexture, noiseTexture,
+ m, paint.getAlpha());
+ } else {
+ delete paintingData;
+ *fp = nullptr;
+ }
+ return true;
+}
+
+#else
+
+bool SkPerlinNoiseShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix&,
+ const SkMatrix*, GrColor*, GrProcessorDataManager*,
+ GrFragmentProcessor**) const {
+ SkDEBUGFAIL("Should not call in GPU-less build");
+ return false;
}
#endif
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ColorTableEffect);
-const GrFragmentProcessor* ColorTableEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* ColorTableEffect::TestCreate(GrProcessorTestData* d) {
int flags = 0;
uint8_t luts[256][4];
do {
#if SK_SUPPORT_GPU
-#include "effects/GrExtractAlphaFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "SkGr.h"
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrLinearGradient);
-const GrFragmentProcessor* GrLinearGradient::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* GrLinearGradient::TestCreate(GrProcessorTestData* d) {
SkPoint points[] = {{d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()},
{d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}};
SkAutoTUnref<SkShader> shader(SkGradientShader::CreateLinear(points,
colors, stops, colorCount,
tm));
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
- GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality, d->fProcDataManager);
- GrAlwaysAssert(fp);
+ SkPaint paint;
+ GrColor paintColor;
+ GrFragmentProcessor* fp;
+ SkAssertResult(shader->asFragmentProcessor(d->fContext, paint,
+ GrTest::TestMatrix(d->fRandom), nullptr,
+ &paintColor, d->fProcDataManager, &fp));
return fp;
}
/////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* SkLinearGradient::asFragmentProcessor(
- GrContext* context, const SkMatrix& viewm, const SkMatrix* localMatrix, SkFilterQuality,
- GrProcessorDataManager* procDataManager) const {
+bool SkLinearGradient::asFragmentProcessor(GrContext* context, const SkPaint& paint,
+ const SkMatrix& viewm, const SkMatrix* localMatrix,
+ GrColor* paintColor,
+ GrProcessorDataManager* procDataManager,
+ GrFragmentProcessor** fp) const {
SkASSERT(context);
SkMatrix matrix;
if (!this->getLocalMatrix().invert(&matrix)) {
- return nullptr;
+ return false;
}
if (localMatrix) {
SkMatrix inv;
if (!localMatrix->invert(&inv)) {
- return nullptr;
+ return false;
}
matrix.postConcat(inv);
}
matrix.postConcat(fPtsToUnit);
- SkAutoTUnref<const GrFragmentProcessor> inner(
- GrLinearGradient::Create(context, procDataManager, *this, matrix, fTileMode));
- return GrExtractAlphaFragmentProcessor::Create(inner);
+ *paintColor = SkColor2GrColorJustAlpha(paint.getColor());
+ *fp = GrLinearGradient::Create(context, procDataManager, *this, matrix, fTileMode);
+
+ return true;
}
+#else
+
+bool SkLinearGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix&,
+ const SkMatrix*, GrColor*, GrProcessorDataManager*,
+ GrFragmentProcessor**) const {
+ SkDEBUGFAIL("Should not call in GPU-less build");
+ return false;
+}
#endif
};
GradientType asAGradient(GradientInfo* info) const override;
-#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& viewM,
- const SkMatrix*, SkFilterQuality, GrProcessorDataManager*) const override;
-#endif
+ bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix& viewM,
+ const SkMatrix*, GrColor*, GrProcessorDataManager*,
+ GrFragmentProcessor**) const override;
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLinearGradient)
#if SK_SUPPORT_GPU
#include "SkGr.h"
-#include "effects/GrExtractAlphaFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
class GrGLRadialGradient : public GrGLGradientEffect {
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRadialGradient);
-const GrFragmentProcessor* GrRadialGradient::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* GrRadialGradient::TestCreate(GrProcessorTestData* d) {
SkPoint center = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkScalar radius = d->fRandom->nextUScalar1();
SkAutoTUnref<SkShader> shader(SkGradientShader::CreateRadial(center, radius,
colors, stops, colorCount,
tm));
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
- GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality, d->fProcDataManager);
- GrAlwaysAssert(fp);
+ SkPaint paint;
+ GrColor paintColor;
+ GrFragmentProcessor* fp;
+ SkAssertResult(shader->asFragmentProcessor(d->fContext, paint,
+ GrTest::TestMatrix(d->fRandom), nullptr,
+ &paintColor, d->fProcDataManager, &fp));
return fp;
}
/////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* SkRadialGradient::asFragmentProcessor(GrContext* context,
- const SkMatrix& viewM, const SkMatrix* localMatrix, SkFilterQuality,
- GrProcessorDataManager* procDataManager) const {
+bool SkRadialGradient::asFragmentProcessor(GrContext* context, const SkPaint& paint,
+ const SkMatrix& viewM,
+ const SkMatrix* localMatrix, GrColor* paintColor,
+ GrProcessorDataManager* procDataManager,
+ GrFragmentProcessor** fp) const {
SkASSERT(context);
SkMatrix matrix;
if (!this->getLocalMatrix().invert(&matrix)) {
- return nullptr;
+ return false;
}
if (localMatrix) {
SkMatrix inv;
if (!localMatrix->invert(&inv)) {
- return nullptr;
+ return false;
}
matrix.postConcat(inv);
}
matrix.postConcat(fPtsToUnit);
- SkAutoTUnref<const GrFragmentProcessor> inner(
- GrRadialGradient::Create(context, procDataManager, *this, matrix, fTileMode));
- return GrExtractAlphaFragmentProcessor::Create(inner);
+
+ *paintColor = SkColor2GrColorJustAlpha(paint.getColor());
+ *fp = GrRadialGradient::Create(context, procDataManager, *this, matrix, fTileMode);
+
+ return true;
+}
+
+#else
+
+bool SkRadialGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix&,
+ const SkMatrix*, GrColor*, GrProcessorDataManager*,
+ GrFragmentProcessor**) const {
+ SkDEBUGFAIL("Should not call in GPU-less build");
+ return false;
}
#endif
};
GradientType asAGradient(GradientInfo* info) const override;
-#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& viewM,
- const SkMatrix*, SkFilterQuality, GrProcessorDataManager*) const override;
-#endif
+ bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix& viewM,
+ const SkMatrix*, GrColor*, GrProcessorDataManager*,
+ GrFragmentProcessor**) const override;
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkRadialGradient)
#if SK_SUPPORT_GPU
#include "SkGr.h"
-#include "effects/GrExtractAlphaFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
class GrGLSweepGradient : public GrGLGradientEffect {
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSweepGradient);
-const GrFragmentProcessor* GrSweepGradient::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* GrSweepGradient::TestCreate(GrProcessorTestData* d) {
SkPoint center = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkColor colors[kMaxRandomGradientColors];
int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tmIgnored);
SkAutoTUnref<SkShader> shader(SkGradientShader::CreateSweep(center.fX, center.fY,
colors, stops, colorCount));
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
- GrTest::TestMatrix(d->fRandom),
- NULL, kNone_SkFilterQuality,
- d->fProcDataManager);
- GrAlwaysAssert(fp);
+ SkPaint paint;
+ GrFragmentProcessor* fp;
+ GrColor paintColor;
+ SkAssertResult(shader->asFragmentProcessor(d->fContext, paint,
+ GrTest::TestMatrix(d->fRandom), nullptr,
+ &paintColor, d->fProcDataManager, &fp));
return fp;
}
/////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* SkSweepGradient::asFragmentProcessor(GrContext* context,
- const SkMatrix& viewM, const SkMatrix* localMatrix, SkFilterQuality,
- GrProcessorDataManager* procDataManager) const {
+bool SkSweepGradient::asFragmentProcessor(GrContext* context, const SkPaint& paint,
+ const SkMatrix& viewM,
+ const SkMatrix* localMatrix, GrColor* paintColor,
+ GrProcessorDataManager* procDataManager,
+ GrFragmentProcessor** effect) const {
SkMatrix matrix;
if (!this->getLocalMatrix().invert(&matrix)) {
- return nullptr;
+ return false;
}
if (localMatrix) {
SkMatrix inv;
if (!localMatrix->invert(&inv)) {
- return nullptr;
+ return false;
}
matrix.postConcat(inv);
}
matrix.postConcat(fPtsToUnit);
- SkAutoTUnref<const GrFragmentProcessor> inner(
- GrSweepGradient::Create(context, procDataManager, *this, matrix));
- return GrExtractAlphaFragmentProcessor::Create(inner);
+ *effect = GrSweepGradient::Create(context, procDataManager, *this, matrix);
+ *paintColor = SkColor2GrColorJustAlpha(paint.getColor());
+
+ return true;
+}
+
+#else
+
+bool SkSweepGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix&,
+ const SkMatrix*, GrColor*, GrProcessorDataManager*,
+ GrFragmentProcessor**) const {
+ SkDEBUGFAIL("Should not call in GPU-less build");
+ return false;
}
#endif
GradientType asAGradient(GradientInfo* info) const override;
-#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& viewM,
- const SkMatrix*, SkFilterQuality, GrProcessorDataManager*) const override;
-#endif
+ bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix& viewM,
+ const SkMatrix*, GrColor*, GrProcessorDataManager*,
+ GrFragmentProcessor**) const override;
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSweepGradient)
#if SK_SUPPORT_GPU
#include "SkGr.h"
-#include "effects/GrExtractAlphaFragmentProcessor.h"
-const GrFragmentProcessor* SkTwoPointConicalGradient::asFragmentProcessor(GrContext* context,
- const SkMatrix& viewM, const SkMatrix* localMatrix, SkFilterQuality,
- GrProcessorDataManager* procDataManager) const {
+bool SkTwoPointConicalGradient::asFragmentProcessor(GrContext* context,
+ const SkPaint& paint,
+ const SkMatrix& viewM,
+ const SkMatrix* localMatrix,
+ GrColor* paintColor,
+ GrProcessorDataManager* procDataManager,
+ GrFragmentProcessor** fp) const {
SkASSERT(context);
SkASSERT(fPtsToUnit.isIdentity());
- SkAutoTUnref<const GrFragmentProcessor> inner(
- Gr2PtConicalGradientEffect::Create(context, procDataManager, *this, fTileMode,
- localMatrix));
- return GrExtractAlphaFragmentProcessor::Create(inner);
+
+ *fp = Gr2PtConicalGradientEffect::Create(context, procDataManager, *this, fTileMode,
+ localMatrix);
+ *paintColor = SkColor2GrColorJustAlpha(paint.getColor());
+ return true;
+}
+
+#else
+
+bool SkTwoPointConicalGradient::asFragmentProcessor(GrContext*, const SkPaint&,
+ const SkMatrix&, const SkMatrix*,
+ GrColor*, GrProcessorDataManager*,
+ GrFragmentProcessor**) const {
+ SkDEBUGFAIL("Should not call in GPU-less build");
+ return false;
}
#endif
};
SkShader::GradientType asAGradient(GradientInfo* info) const override;
-#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix&, const SkMatrix*,
- SkFilterQuality, GrProcessorDataManager*) const override;
-#endif
+ bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix&, const SkMatrix*,
+ GrColor*, GrProcessorDataManager*,
+ GrFragmentProcessor**) const override;
bool isOpaque() const override;
SkScalar getCenterX1() const { return SkPoint::Distance(fCenter1, fCenter2); }
/*
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
-const GrFragmentProcessor* Edge2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* Edge2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkScalar radius1 = d->fRandom->nextUScalar1();
SkPoint center2;
center2, radius2,
colors, stops, colorCount,
tm));
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
- GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality, d->fProcDataManager);
- GrAlwaysAssert(fp);
+ SkPaint paint;
+ GrFragmentProcessor* fp;
+ GrColor paintColor;
+ SkAssertResult(shader->asFragmentProcessor(d->fContext, paint,
+ GrTest::TestMatrix(d->fRandom), nullptr,
+ &paintColor, d->fProcDataManager, &fp));
return fp;
}
/*
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
-const GrFragmentProcessor* FocalOutside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* FocalOutside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkScalar radius1 = 0.f;
SkPoint center2;
center2, radius2,
colors, stops, colorCount,
tm));
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
- GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality, d->fProcDataManager);
- GrAlwaysAssert(fp);
- return fp;
+ SkPaint paint;
+ GrFragmentProcessor* effect;
+ GrColor paintColor;
+ GrPaint grPaint;
+ SkAssertResult(shader->asFragmentProcessor(d->fContext, paint,
+ GrTest::TestMatrix(d->fRandom), nullptr,
+ &paintColor, d->fProcDataManager,
+ &effect));
+ return effect;
}
GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrProcessor& processor)
/*
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
-const GrFragmentProcessor* FocalInside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* FocalInside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkScalar radius1 = 0.f;
SkPoint center2;
center2, radius2,
colors, stops, colorCount,
tm));
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
- GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality, d->fProcDataManager);
- GrAlwaysAssert(fp);
+ SkPaint paint;
+ GrColor paintColor;
+ GrFragmentProcessor* fp;
+ SkAssertResult(shader->asFragmentProcessor(d->fContext, paint,
+ GrTest::TestMatrix(d->fRandom), nullptr,
+ &paintColor, d->fProcDataManager, &fp));
return fp;
}
/*
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
-const GrFragmentProcessor* CircleInside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor*
+CircleInside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkScalar radius1 = d->fRandom->nextUScalar1() + 0.0001f; // make sure radius1 != 0
SkPoint center2;
center2, radius2,
colors, stops, colorCount,
tm));
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
- GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality, d->fProcDataManager);
- GrAlwaysAssert(fp);
+ SkPaint paint;
+ GrColor paintColor;
+ GrFragmentProcessor* fp;
+ SkAssertResult(shader->asFragmentProcessor(d->fContext, paint,
+ GrTest::TestMatrix(d->fRandom), nullptr,
+ &paintColor, d->fProcDataManager, &fp));
return fp;
}
/*
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
-const GrFragmentProcessor* CircleOutside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* CircleOutside2PtConicalEffect::TestCreate(GrProcessorTestData* d) {
SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
SkScalar radius1 = d->fRandom->nextUScalar1() + 0.0001f; // make sure radius1 != 0
SkPoint center2;
center2, radius2,
colors, stops, colorCount,
tm));
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(
- d->fContext,GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
- d->fProcDataManager);
- GrAlwaysAssert(fp);
+ SkPaint paint;
+ GrColor paintColor;
+ GrFragmentProcessor* fp;
+ SkAssertResult(shader->asFragmentProcessor(d->fContext, paint,
+ GrTest::TestMatrix(d->fRandom), nullptr,
+ &paintColor, d->fProcDataManager, &fp));
return fp;
}
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(QuadEdgeEffect);
-const GrGeometryProcessor* QuadEdgeEffect::TestCreate(GrProcessorTestData* d) {
+GrGeometryProcessor* QuadEdgeEffect::TestCreate(GrProcessorTestData* d) {
// Doesn't work without derivative instructions.
return d->fCaps->shaderCaps()->shaderDerivativeSupport() ?
QuadEdgeEffect::Create(GrRandomColor(d->fRandom),
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DefaultGeoProc);
-const GrGeometryProcessor* DefaultGeoProc::TestCreate(GrProcessorTestData* d) {
+GrGeometryProcessor* DefaultGeoProc::TestCreate(GrProcessorTestData* d) {
uint32_t flags = 0;
if (d->fRandom->nextBool()) {
flags |= kColor_GPFlag;
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(CircleEdgeEffect);
-const GrGeometryProcessor* CircleEdgeEffect::TestCreate(GrProcessorTestData* d) {
+GrGeometryProcessor* CircleEdgeEffect::TestCreate(GrProcessorTestData* d) {
return CircleEdgeEffect::Create(GrRandomColor(d->fRandom),
d->fRandom->nextBool(),
GrTest::TestMatrix(d->fRandom),
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(EllipseEdgeEffect);
-const GrGeometryProcessor* EllipseEdgeEffect::TestCreate(GrProcessorTestData* d) {
+GrGeometryProcessor* EllipseEdgeEffect::TestCreate(GrProcessorTestData* d) {
return EllipseEdgeEffect::Create(GrRandomColor(d->fRandom),
d->fRandom->nextBool(),
GrTest::TestMatrix(d->fRandom),
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DIEllipseEdgeEffect);
-const GrGeometryProcessor* DIEllipseEdgeEffect::TestCreate(GrProcessorTestData* d) {
+GrGeometryProcessor* DIEllipseEdgeEffect::TestCreate(GrProcessorTestData* d) {
return DIEllipseEdgeEffect::Create(GrRandomColor(d->fRandom),
GrTest::TestMatrix(d->fRandom),
(Mode)(d->fRandom->nextRangeU(0,2)),
return true;
}
+void GrFragmentProcessor::computeInvariantOutput(GrInvariantOutput* inout) const {
+ this->onComputeInvariantOutput(inout);
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////////
// Initial static variable from GrXPFactory
GrColor paintColor = SkColor2GrColor(skPaint.getColor());
- const GrFragmentProcessor* fp = shader->asFragmentProcessor(context, viewM, NULL,
- skPaint.getFilterQuality(), grPaint->getProcessorDataManager());
- if (!fp) {
- return false;
+ // Start a new block here in order to preserve our context state after calling
+ // asFragmentProcessor(). Since these calls get passed back to the client, we don't really
+ // want them messing around with the context.
+ {
+ // Allow the shader to modify paintColor and also create an effect to be installed as
+ // the first color effect on the GrPaint.
+ GrFragmentProcessor* fp = nullptr;
+ if (!shader->asFragmentProcessor(context, skPaint, viewM, nullptr, &paintColor,
+ grPaint->getProcessorDataManager(), &fp)) {
+ return false;
+ }
+ if (fp) {
+ grPaint->addColorFragmentProcessor(fp)->unref();
+ constantColor = false;
+ }
}
- grPaint->addColorFragmentProcessor(fp)->unref();
- constantColor = false;
// The grcolor is automatically set when calling asFragmentProcessor.
// If the shader can be seen as an effect it returns true and adds its effect to the grpaint.
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrConicEffect);
-const GrGeometryProcessor* GrConicEffect::TestCreate(GrProcessorTestData* d) {
+GrGeometryProcessor* GrConicEffect::TestCreate(GrProcessorTestData* d) {
GrGeometryProcessor* gp;
do {
GrPrimitiveEdgeType edgeType =
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrQuadEffect);
-const GrGeometryProcessor* GrQuadEffect::TestCreate(GrProcessorTestData* d) {
+GrGeometryProcessor* GrQuadEffect::TestCreate(GrProcessorTestData* d) {
GrGeometryProcessor* gp;
do {
GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrCubicEffect);
-const GrGeometryProcessor* GrCubicEffect::TestCreate(GrProcessorTestData* d) {
+GrGeometryProcessor* GrCubicEffect::TestCreate(GrProcessorTestData* d) {
GrGeometryProcessor* gp;
do {
GrPrimitiveEdgeType edgeType =
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrBicubicEffect);
-const GrFragmentProcessor* GrBicubicEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* GrBicubicEffect::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
SkScalar coefficients[16];
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrBitmapTextGeoProc);
-const GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(GrProcessorTestData* d) {
+GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
static const SkShader::TileMode kTileModes[] = {
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConfigConversionEffect);
-const GrFragmentProcessor* GrConfigConversionEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* GrConfigConversionEffect::TestCreate(GrProcessorTestData* d) {
PMConversion pmConv = static_cast<PMConversion>(d->fRandom->nextULessThan(kPMConversionCnt));
bool swapRB;
if (kNone_PMConversion == pmConv) {
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConstColorProcessor);
-const GrFragmentProcessor* GrConstColorProcessor::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* GrConstColorProcessor::TestCreate(GrProcessorTestData* d) {
GrColor color;
int colorPicker = d->fRandom->nextULessThan(3);
switch (colorPicker) {
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(AARectEffect);
-const GrFragmentProcessor* AARectEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* AARectEffect::TestCreate(GrProcessorTestData* d) {
SkRect rect = SkRect::MakeLTRB(d->fRandom->nextSScalar1(),
d->fRandom->nextSScalar1(),
d->fRandom->nextSScalar1(),
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConvexPolyEffect);
-const GrFragmentProcessor* GrConvexPolyEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* GrConvexPolyEffect::TestCreate(GrProcessorTestData* d) {
int count = d->fRandom->nextULessThan(kMaxEdges) + 1;
SkScalar edges[kMaxEdges * 3];
for (int i = 0; i < 3 * count; ++i) {
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConvolutionEffect);
-const GrFragmentProcessor* GrConvolutionEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* GrConvolutionEffect::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
Direction dir = d->fRandom->nextBool() ? kX_Direction : kY_Direction;
GR_DEFINE_XP_FACTORY_TEST(GrCoverageSetOpXPFactory);
-const GrXPFactory* GrCoverageSetOpXPFactory::TestCreate(GrProcessorTestData* d) {
+GrXPFactory* GrCoverageSetOpXPFactory::TestCreate(GrProcessorTestData* d) {
SkRegion::Op regionOp = SkRegion::Op(d->fRandom->nextULessThan(SkRegion::kLastOp + 1));
bool invertCoverage = d->fRandom->nextBool();
return GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrCustomXferFP);
-const GrFragmentProcessor* GrCustomXferFP::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* GrCustomXferFP::TestCreate(GrProcessorTestData* d) {
int mode = d->fRandom->nextRangeU(SkXfermode::kLastCoeffMode + 1, SkXfermode::kLastSeparableMode);
return new GrCustomXferFP(d->fProcDataManager, static_cast<SkXfermode::Mode>(mode),
}
GR_DEFINE_XP_FACTORY_TEST(GrCustomXPFactory);
-const GrXPFactory* GrCustomXPFactory::TestCreate(GrProcessorTestData* d) {
+GrXPFactory* GrCustomXPFactory::TestCreate(GrProcessorTestData* d) {
int mode = d->fRandom->nextRangeU(SkXfermode::kLastCoeffMode + 1,
SkXfermode::kLastSeparableMode);
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingCircleEffect);
-const GrGeometryProcessor* DashingCircleEffect::TestCreate(GrProcessorTestData* d) {
+GrGeometryProcessor* DashingCircleEffect::TestCreate(GrProcessorTestData* d) {
DashAAMode aaMode = static_cast<DashAAMode>(d->fRandom->nextULessThan(kDashAAModeCount));
return DashingCircleEffect::Create(GrRandomColor(d->fRandom),
aaMode, GrTest::TestMatrix(d->fRandom),
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingLineEffect);
-const GrGeometryProcessor* DashingLineEffect::TestCreate(GrProcessorTestData* d) {
+GrGeometryProcessor* DashingLineEffect::TestCreate(GrProcessorTestData* d) {
DashAAMode aaMode = static_cast<DashAAMode>(d->fRandom->nextULessThan(kDashAAModeCount));
return DashingLineEffect::Create(GrRandomColor(d->fRandom),
aaMode, GrTest::TestMatrix(d->fRandom),
GR_DEFINE_XP_FACTORY_TEST(GrDisableColorXPFactory);
-const GrXPFactory* GrDisableColorXPFactory::TestCreate(GrProcessorTestData*) {
+GrXPFactory* GrDisableColorXPFactory::TestCreate(GrProcessorTestData*) {
return GrDisableColorXPFactory::Create();
}
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldA8TextGeoProc);
-const GrGeometryProcessor* GrDistanceFieldA8TextGeoProc::TestCreate(GrProcessorTestData* d) {
+GrGeometryProcessor* GrDistanceFieldA8TextGeoProc::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
static const SkShader::TileMode kTileModes[] = {
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldPathGeoProc);
-const GrGeometryProcessor* GrDistanceFieldPathGeoProc::TestCreate(GrProcessorTestData* d) {
+GrGeometryProcessor* GrDistanceFieldPathGeoProc::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: GrProcessorUnitTest::kAlphaTextureIdx;
static const SkShader::TileMode kTileModes[] = {
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldLCDTextGeoProc);
-const GrGeometryProcessor* GrDistanceFieldLCDTextGeoProc::TestCreate(GrProcessorTestData* d) {
+GrGeometryProcessor* GrDistanceFieldLCDTextGeoProc::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
static const SkShader::TileMode kTileModes[] = {
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(DitherEffect);
-const GrFragmentProcessor* DitherEffect::TestCreate(GrProcessorTestData*) {
+GrFragmentProcessor* DitherEffect::TestCreate(GrProcessorTestData*) {
return DitherEffect::Create();
}
+++ /dev/null
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "effects/GrExtractAlphaFragmentProcessor.h"
-#include "gl/GrGLFragmentProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
-
-class GLExtractAlphaFragmentProcessor : public GrGLFragmentProcessor {
-public:
- GLExtractAlphaFragmentProcessor() {}
-
- void emitCode(EmitArgs& args) override {
- GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
- fsBuilder->codeAppendf("vec4 alpha4 = %s.aaaa;", args.fInputColor);
- SkString output;
- this->emitChild(0, "alpha4", &output, args);
- fsBuilder->codeAppendf("%s = %s;", args.fOutputColor, output.c_str());
- }
-
-private:
- typedef GrGLFragmentProcessor INHERITED;
-};
-
-GrGLFragmentProcessor* GrExtractAlphaFragmentProcessor::onCreateGLInstance() const {
- return SkNEW(GLExtractAlphaFragmentProcessor);
-}
-
-void GrExtractAlphaFragmentProcessor::onGetGLProcessorKey(const GrGLSLCaps&,
- GrProcessorKeyBuilder*) const {
-}
-
-bool GrExtractAlphaFragmentProcessor::onIsEqual(const GrFragmentProcessor&) const { return true; }
-
-void GrExtractAlphaFragmentProcessor::onComputeInvariantOutput(GrInvariantOutput* inout) const {
- if (inout->validFlags() & kA_GrColorComponentFlag) {
- GrColor color = GrColorPackA4(GrColorUnpackA(inout->color()));
- inout->setToOther(kRGBA_GrColorComponentFlags, color,
- GrInvariantOutput::kWill_ReadInput);
- } else {
- inout->setToUnknown(GrInvariantOutput::kWill_ReadInput);
- }
- this->childProcessor(0).computeInvariantOutput(inout);
-}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMatrixConvolutionEffect);
-const GrFragmentProcessor* GrMatrixConvolutionEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* GrMatrixConvolutionEffect::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
int width = d->fRandom->nextRangeU(1, MAX_KERNEL_SIZE);
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleEffect);
-const GrFragmentProcessor* CircleEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* CircleEffect::TestCreate(GrProcessorTestData* d) {
SkPoint center;
center.fX = d->fRandom->nextRangeScalar(0.f, 1000.f);
center.fY = d->fRandom->nextRangeScalar(0.f, 1000.f);
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(EllipseEffect);
-const GrFragmentProcessor* EllipseEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* EllipseEffect::TestCreate(GrProcessorTestData* d) {
SkPoint center;
center.fX = d->fRandom->nextRangeScalar(0.f, 1000.f);
center.fY = d->fRandom->nextRangeScalar(0.f, 1000.f);
GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory);
-const GrXPFactory* GrPorterDuffXPFactory::TestCreate(GrProcessorTestData* d) {
+GrXPFactory* GrPorterDuffXPFactory::TestCreate(GrProcessorTestData* d) {
SkXfermode::Mode mode = SkXfermode::Mode(d->fRandom->nextULessThan(SkXfermode::kLastCoeffMode));
return GrPorterDuffXPFactory::Create(mode);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircularRRectEffect);
-const GrFragmentProcessor* CircularRRectEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* CircularRRectEffect::TestCreate(GrProcessorTestData* d) {
SkScalar w = d->fRandom->nextRangeScalar(20.f, 1000.f);
SkScalar h = d->fRandom->nextRangeScalar(20.f, 1000.f);
SkScalar r = d->fRandom->nextRangeF(kRadiusMin, 9.f);
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(EllipticalRRectEffect);
-const GrFragmentProcessor* EllipticalRRectEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* EllipticalRRectEffect::TestCreate(GrProcessorTestData* d) {
SkScalar w = d->fRandom->nextRangeScalar(20.f, 1000.f);
SkScalar h = d->fRandom->nextRangeScalar(20.f, 1000.f);
SkVector r[4];
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSimpleTextureEffect);
-const GrFragmentProcessor* GrSimpleTextureEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* GrSimpleTextureEffect::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
static const SkShader::TileMode kTileModes[] = {
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrTextureDomainEffect);
-const GrFragmentProcessor* GrTextureDomainEffect::TestCreate(GrProcessorTestData* d) {
+GrFragmentProcessor* GrTextureDomainEffect::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
GrProcessorUnitTest::kAlphaTextureIdx;
SkRect domain;
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(BigKeyProcessor);
-const GrFragmentProcessor* BigKeyProcessor::TestCreate(GrProcessorTestData*) {
+GrFragmentProcessor* BigKeyProcessor::TestCreate(GrProcessorTestData*) {
return BigKeyProcessor::Create();
}