{rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}
};
for(int edgeType = 0; edgeType < kGrEffectEdgeTypeCnt; ++edgeType) {
- SkAutoTUnref<GrEffectRef> effect;
+ SkAutoTUnref<GrEffect> effect;
{ // scope to contain GrTestTarget
GrTestTarget tt;
context->getTestTarget(&tt);
};
SkScalar weight = rand.nextRangeF(0.f, 2.f);
for(int edgeType = 0; edgeType < kGrEffectEdgeTypeCnt; ++edgeType) {
- SkAutoTUnref<GrEffectRef> effect;
+ SkAutoTUnref<GrEffect> effect;
{ // scope to contain GrTestTarget
GrTestTarget tt;
context->getTestTarget(&tt);
{rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}
};
for(int edgeType = 0; edgeType < kGrEffectEdgeTypeCnt; ++edgeType) {
- SkAutoTUnref<GrEffectRef> effect;
+ SkAutoTUnref<GrEffect> effect;
{ // scope to contain GrTestTarget
GrTestTarget tt;
context->getTestTarget(&tt);
path->transform(m, &p);
GrEffectEdgeType edgeType = (GrEffectEdgeType) et;
- SkAutoTUnref<GrEffectRef> effect(GrConvexPolyEffect::Create(edgeType, p));
+ SkAutoTUnref<GrEffect> effect(GrConvexPolyEffect::Create(edgeType, p));
if (!effect) {
continue;
}
SkRect rect = *iter.get();
rect.offset(x, y);
GrEffectEdgeType edgeType = (GrEffectEdgeType) et;
- SkAutoTUnref<GrEffectRef> effect(GrConvexPolyEffect::Create(edgeType, rect));
+ SkAutoTUnref<GrEffect> effect(GrConvexPolyEffect::Create(edgeType, rect));
if (!effect) {
continue;
}
SkRRect rrect = fRRects[curRRect];
rrect.offset(SkIntToScalar(x), SkIntToScalar(y));
GrEffectEdgeType edgeType = (GrEffectEdgeType) et;
- SkAutoTUnref<GrEffectRef> effect(GrRRectEffect::Create(edgeType, rrect));
+ SkAutoTUnref<GrEffect> effect(GrRRectEffect::Create(edgeType, rrect));
if (effect) {
drawState->addCoverageEffect(effect);
drawState->setIdentityViewMatrix();
SkScalar x = kDrawPad + kTestPad;
for (int m = 0; m < GrTextureDomain::kModeCount; ++m) {
GrTextureDomain::Mode mode = (GrTextureDomain::Mode) m;
- SkAutoTUnref<GrEffectRef> effect(
+ SkAutoTUnref<GrEffect> effect(
GrTextureDomainEffect::Create(texture, textureMatrices[tm],
GrTextureDomain::MakeTexelDomain(texture,
texelDomains[d]),
const int indices[6][3] = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2}, {1, 2, 0}, {2, 0, 1}, {2, 1, 0}};
for (int i = 0; i < 6; ++i) {
- SkAutoTUnref<GrEffectRef> effect(
+ SkAutoTUnref<GrEffect> effect(
GrYUVtoRGBEffect::Create(texture[indices[i][0]],
texture[indices[i][1]],
texture[indices[i][2]]));
virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
virtual bool asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* grColor,
- GrEffect** grEffect) const SK_OVERRIDE;
+ const SkMatrix* localMatrix, GrColor* paintColor,
+ GrEffect** effect) const SK_OVERRIDE;
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorShader)
/**
- * Returns true if the shader subclass succeeds in setting the grEffect and the grColor output
- * parameters to a value, returns false if it fails or if there is not an implementation of
- * this method in the shader subclass.
- * The incoming color to the effect has r=g=b=a all extracted from the SkPaint's alpha.
- * The output color should be the computed SkShader premul color modulated by the incoming
- * color. The GrContext may be used by the effect to create textures. The GPU device does not
+ * 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.
+ *
+ * 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 effect to create textures. The GPU device does not
* call createContext. Instead we pass the SkPaint here in case the shader needs paint info.
*/
virtual bool asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrixOrNull, GrColor* grColor,
- GrEffect** grEffect) const;
+ const SkMatrix* localMatrixOrNull, GrColor* paintColor,
+ GrEffect** effect) const;
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
/**
* of effects that make a readToUPM->writeToPM->readToUPM cycle invariant. Otherwise, they
* return NULL.
*/
- const GrEffectRef* createPMToUPMEffect(GrTexture* texture,
- bool swapRAndB,
- const SkMatrix& matrix);
- const GrEffectRef* createUPMToPMEffect(GrTexture* texture,
- bool swapRAndB,
- const SkMatrix& matrix);
+ const GrEffect* createPMToUPMEffect(GrTexture* texture,
+ bool swapRAndB,
+ const SkMatrix& matrix);
+ const GrEffect* createUPMToPMEffect(GrTexture* texture,
+ bool swapRAndB,
+ const SkMatrix& matrix);
/**
* This callback allows the resource cache to callback into the GrContext
typedef SkRefCnt INHERITED;
};
-typedef GrEffect GrEffectRef;
-
/**
* This creates an effect outside of the effect memory pool. The effect's destructor will be called
* at global destruction time. NAME will be the name of the created GrEffect.
////////////////////////////////////////////////////////////////////////////////
// Converts a SkPaint to a GrPaint, ignoring the SkPaint's shader.
-// Sets the color of GrPaint to the value of the parameter grColor
+// Sets the color of GrPaint to the value of the parameter paintColor
// Callers may subsequently modify the GrPaint. Setting constantColor indicates
// that the final paint will draw the same color at every pixel. This allows
// an optimization where the the color filter can be applied to the SkPaint's
// color once while converting to GrPaint and then ignored.
-void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, GrColor grColor,
+void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, GrColor paintColor,
bool constantColor, GrPaint* grPaint);
// This function is similar to skPaint2GrPaintNoShader but also converts
#include "SkGr.h"
bool SkBitmapProcShader::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* grColor,
- GrEffectRef** grEffect) const {
+ const SkMatrix* localMatrix, GrColor* paintColor,
+ GrEffect** effect) const {
SkMatrix matrix;
matrix.setIDiv(fRawBitmap.width(), fRawBitmap.height());
return false;
}
- *grColor = (kAlpha_8_SkColorType == fRawBitmap.colorType()) ? SkColor2GrColor(paint.getColor())
- : SkColor2GrColorJustAlpha(paint.getColor());
+ *paintColor = (kAlpha_8_SkColorType == fRawBitmap.colorType()) ?
+ SkColor2GrColor(paint.getColor()) :
+ SkColor2GrColorJustAlpha(paint.getColor());
if (useBicubic) {
- *grEffect = GrBicubicEffect::Create(texture, matrix, tm);
+ *effect = GrBicubicEffect::Create(texture, matrix, tm);
} else {
- *grEffect = GrSimpleTextureEffect::Create(texture, matrix, params);
+ *effect = GrSimpleTextureEffect::Create(texture, matrix, params);
}
GrUnlockAndUnrefCachedBitmapTexture(texture);
#else
bool SkBitmapProcShader::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* grColor,
- GrEffect** grEffect) const {
+ const SkMatrix* localMatrix, GrColor* paintColor,
+ GrEffect** effect) const {
SkDEBUGFAIL("Should not call in GPU-less build");
return false;
}
am.setIdentity(context);
GrContext::AutoRenderTarget art(context, dst.texture()->asRenderTarget());
GrContext::AutoClip acs(context, dstRect);
- GrEffectRef* effect;
+ GrEffect* effect;
offset->fX = bounds.left();
offset->fY = bounds.top();
bounds.offset(-srcOffset);
#if SK_SUPPORT_GPU
bool SkPictureShader::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* grColor,
- GrEffectRef** grEffect) const {
+ const SkMatrix* localMatrix, GrColor* paintColor,
+ GrEffect** effect) const {
SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(context->getMatrix(), localMatrix));
if (!bitmapShader) {
return false;
}
- return bitmapShader->asNewEffect(context, paint, NULL, grColor, grEffect);
+ return bitmapShader->asNewEffect(context, paint, NULL, paintColor, effect);
}
#else
bool SkPictureShader::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* grColor,
- GrEffect** grEffect) const {
+ const SkMatrix* localMatrix, GrColor* paintColor,
+ GrEffect** effect) const {
SkDEBUGFAIL("Should not call in GPU-less build");
return false;
}
}
bool SkShader::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrixOrNull, GrColor* grColor,
- GrEffect** grEffect) const {
+ const SkMatrix* localMatrixOrNull, GrColor* paintColor,
+ GrEffect** effect) const {
return false;
}
#include "SkGr.h"
bool SkColorShader::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* grColor,
- GrEffectRef** grEffect) const {
- *grEffect = NULL;
+ const SkMatrix* localMatrix, GrColor* paintColor,
+ GrEffect** effect) const {
+ *effect = NULL;
SkColor skColor = fColor;
U8CPU newA = SkMulDiv255Round(SkColorGetA(fColor), paint.getAlpha());
- *grColor = SkColor2GrColor(SkColorSetA(skColor, newA));
+ *paintColor = SkColor2GrColor(SkColorSetA(skColor, newA));
return true;
}
#else
bool SkColorShader::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* grColor,
- GrEffect** grEffect) const {
+ const SkMatrix* localMatrix, GrColor* paintColor,
+ GrEffect** effect) const {
SkDEBUGFAIL("Should not call in GPU-less build");
return false;
}
return mode > SkXfermode::kLastCoeffMode && mode <= SkXfermode::kLastMode;
}
- static GrEffectRef* Create(SkXfermode::Mode mode, GrTexture* background) {
+ static GrEffect* Create(SkXfermode::Mode mode, GrTexture* background) {
if (!IsSupportedMode(mode)) {
return NULL;
} else {
};
GR_DEFINE_EFFECT_TEST(XferEffect);
-GrEffectRef* XferEffect::TestCreate(SkRandom* rand,
- GrContext*,
- const GrDrawTargetCaps&,
- GrTexture*[]) {
+GrEffect* XferEffect::TestCreate(SkRandom* rand,
+ GrContext*,
+ const GrDrawTargetCaps&,
+ GrTexture*[]) {
int mode = rand->nextRangeU(SkXfermode::kLastCoeffMode + 1, SkXfermode::kLastSeparableMode);
return SkNEW_ARGS(XferEffect, (static_cast<SkXfermode::Mode>(mode), NULL));
}
#if SK_SUPPORT_GPU
-bool SkProcCoeffXfermode::asNewEffect(GrEffectRef** effect,
- GrTexture* background) const {
+bool SkProcCoeffXfermode::asNewEffect(GrEffect** effect, GrTexture* background) const {
if (XferEffect::IsSupportedMode(fMode)) {
if (NULL != effect) {
*effect = XferEffect::Create(fMode, background);
class AlphaThresholdEffect : public GrEffect {
public:
- static GrEffectRef* Create(GrTexture* texture,
- GrTexture* maskTexture,
- float innerThreshold,
- float outerThreshold) {
+ static GrEffect* Create(GrTexture* texture,
+ GrTexture* maskTexture,
+ float innerThreshold,
+ float outerThreshold) {
return SkNEW_ARGS(AlphaThresholdEffect, (texture,
maskTexture,
innerThreshold,
GR_DEFINE_EFFECT_TEST(AlphaThresholdEffect);
-GrEffectRef* AlphaThresholdEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture** textures) {
+GrEffect* AlphaThresholdEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture** textures) {
GrTexture* bmpTex = textures[GrEffectUnitTest::kSkiaPMTextureIdx];
GrTexture* maskTex = textures[GrEffectUnitTest::kAlphaTextureIdx];
float inner_thresh = random->nextUScalar1();
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkArithmeticMode_scalar)
#if SK_SUPPORT_GPU
- virtual bool asNewEffect(GrEffectRef** effect, GrTexture* background) const SK_OVERRIDE;
+ virtual bool asNewEffect(GrEffect** effect, GrTexture* background) const SK_OVERRIDE;
#endif
private:
class GrArithmeticEffect : public GrEffect {
public:
- static GrEffectRef* Create(float k1, float k2, float k3, float k4, bool enforcePMColor,
+ static GrEffect* Create(float k1, float k2, float k3, float k4, bool enforcePMColor,
GrTexture* background) {
return SkNEW_ARGS(GrArithmeticEffect, (k1, k2, k3, k4, enforcePMColor, background));
}
return key;
}
-GrEffectRef* GrArithmeticEffect::TestCreate(SkRandom* rand,
- GrContext*,
- const GrDrawTargetCaps&,
- GrTexture*[]) {
+GrEffect* GrArithmeticEffect::TestCreate(SkRandom* rand,
+ GrContext*,
+ const GrDrawTargetCaps&,
+ GrTexture*[]) {
float k1 = rand->nextF();
float k2 = rand->nextF();
float k3 = rand->nextF();
GR_DEFINE_EFFECT_TEST(GrArithmeticEffect);
-bool SkArithmeticMode_scalar::asNewEffect(GrEffectRef** effect, GrTexture* background) const {
+bool SkArithmeticMode_scalar::asNewEffect(GrEffect** effect, GrTexture* background) const {
if (effect) {
*effect = GrArithmeticEffect::Create(SkScalarToFloat(fK[0]),
SkScalarToFloat(fK[1]),
/**
* Create a simple filter effect with custom bicubic coefficients.
*/
- static GrEffectRef* Create(GrContext *context, const SkRect& rect,
- float sigma) {
+ static GrEffect* Create(GrContext *context, const SkRect& rect, float sigma) {
GrTexture *blurProfileTexture = NULL;
int doubleProfileSize = SkScalarCeilToInt(12*sigma);
GR_DEFINE_EFFECT_TEST(GrRectBlurEffect);
-GrEffectRef* GrRectBlurEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture**) {
+GrEffect* GrRectBlurEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture**) {
float sigma = random->nextRangeF(3,8);
float width = random->nextRangeF(200,300);
float height = random->nextRangeF(200,300);
int pad=SkScalarCeilToInt(6*xformedSigma)/2;
rect.outset(SkIntToScalar(pad), SkIntToScalar(pad));
- SkAutoTUnref<GrEffectRef> effect(GrRectBlurEffect::Create(
- context, rect, xformedSigma));
+ SkAutoTUnref<GrEffect> effect(GrRectBlurEffect::Create(context, rect, xformedSigma));
if (!effect) {
return false;
}
class GrRRectBlurEffect : public GrEffect {
public:
- static GrEffectRef* Create(GrContext* context, float sigma, const SkRRect&);
+ static GrEffect* Create(GrContext* context, float sigma, const SkRRect&);
virtual ~GrRRectBlurEffect() {};
static const char* Name() { return "GrRRectBlur"; }
};
-GrEffectRef* GrRRectBlurEffect::Create(GrContext* context, float sigma, const SkRRect& rrect) {
+GrEffect* GrRRectBlurEffect::Create(GrContext* context, float sigma, const SkRRect& rrect) {
if (!rrect.isSimpleCircular()) {
return NULL;
}
GR_DEFINE_EFFECT_TEST(GrRRectBlurEffect);
-GrEffectRef* GrRRectBlurEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps& caps,
- GrTexture*[]) {
+GrEffect* GrRRectBlurEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps& caps,
+ GrTexture*[]) {
SkScalar w = random->nextRangeScalar(100.f, 1000.f);
SkScalar h = random->nextRangeScalar(100.f, 1000.f);
SkScalar r = random->nextRangeF(1.f, 9.f);
float extra=3.f*SkScalarCeilToScalar(xformedSigma-1/6.0f);
proxy_rect.outset(extra, extra);
- SkAutoTUnref<GrEffectRef> effect(GrRRectBlurEffect::Create(
+ SkAutoTUnref<GrEffect> effect(GrRRectBlurEffect::Create(
context, xformedSigma, rrect));
if (!effect) {
return false;
class ModeColorFilterEffect : public GrEffect {
public:
- static GrEffectRef* Create(const GrColor& c, SkXfermode::Mode mode) {
+ static GrEffect* Create(const GrColor& c, SkXfermode::Mode mode) {
// TODO: Make the effect take the coeffs rather than mode since we already do the
// conversion here.
SkXfermode::Coeff srcCoeff, dstCoeff;
}
GR_DEFINE_EFFECT_TEST(ModeColorFilterEffect);
-GrEffectRef* ModeColorFilterEffect::TestCreate(SkRandom* rand,
- GrContext*,
- const GrDrawTargetCaps&,
- GrTexture*[]) {
+GrEffect* ModeColorFilterEffect::TestCreate(SkRandom* rand,
+ GrContext*,
+ const GrDrawTargetCaps&,
+ GrTexture*[]) {
SkXfermode::Mode mode = SkXfermode::kDst_Mode;
while (SkXfermode::kDst_Mode == mode) {
mode = static_cast<SkXfermode::Mode>(rand->nextRangeU(0, SkXfermode::kLastCoeffMode));
class ColorMatrixEffect : public GrEffect {
public:
- static GrEffectRef* Create(const SkColorMatrix& matrix) {
+ static GrEffect* Create(const SkColorMatrix& matrix) {
return SkNEW_ARGS(ColorMatrixEffect, (matrix));
}
GR_DEFINE_EFFECT_TEST(ColorMatrixEffect);
-GrEffectRef* ColorMatrixEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps&,
- GrTexture* dummyTextures[2]) {
+GrEffect* ColorMatrixEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps&,
+ GrTexture* dummyTextures[2]) {
SkColorMatrix colorMatrix;
for (size_t i = 0; i < SK_ARRAY_COUNT(colorMatrix.fMat); ++i) {
colorMatrix.fMat[i] = random->nextSScalar1();
return ColorMatrixEffect::Create(colorMatrix);
}
-GrEffectRef* SkColorMatrixFilter::asNewEffect(GrContext*) const {
+GrEffect* SkColorMatrixFilter::asNewEffect(GrContext*) const {
return ColorMatrixEffect::Create(fMatrix);
}
class GrDisplacementMapEffect : public GrEffect {
public:
- static GrEffectRef* Create(SkDisplacementMapEffect::ChannelSelectorType xChannelSelector,
- SkDisplacementMapEffect::ChannelSelectorType yChannelSelector,
- SkVector scale,
- GrTexture* displacement, const SkMatrix& offsetMatrix,
- GrTexture* color) {
+ static GrEffect* Create(SkDisplacementMapEffect::ChannelSelectorType xChannelSelector,
+ SkDisplacementMapEffect::ChannelSelectorType yChannelSelector,
+ SkVector scale,
+ GrTexture* displacement, const SkMatrix& offsetMatrix,
+ GrTexture* color) {
return SkNEW_ARGS(GrDisplacementMapEffect, (xChannelSelector,
yChannelSelector,
scale,
GR_DEFINE_EFFECT_TEST(GrDisplacementMapEffect);
-GrEffectRef* GrDisplacementMapEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
+GrEffect* GrDisplacementMapEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
int texIdxDispl = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
GrEffectUnitTest::kAlphaTextureIdx;
int texIdxColor = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
float bounds[2]) {
GrPaint paint;
paint.reset();
- SkAutoTUnref<GrEffectRef> conv(GrConvolutionEffect::CreateGaussian(
+ SkAutoTUnref<GrEffect> conv(GrConvolutionEffect::CreateGaussian(
texture, direction, radius, sigma, useBounds, bounds));
paint.reset();
paint.addColorEffect(conv);
matrix.mapRect(&domain, rect);
domain.inset(i < scaleFactorX ? SK_ScalarHalf / srcTexture->width() : 0.0f,
i < scaleFactorY ? SK_ScalarHalf / srcTexture->height() : 0.0f);
- SkAutoTUnref<GrEffectRef> effect(GrTextureDomainEffect::Create(
+ SkAutoTUnref<GrEffect> effect(GrTextureDomainEffect::Create(
srcTexture,
matrix,
domain,
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
#if SK_SUPPORT_GPU
- virtual bool asNewEffect(GrEffectRef** effect, GrTexture*, const SkMatrix& matrix, const SkIRect& bounds) const SK_OVERRIDE;
+ virtual bool asNewEffect(GrEffect** effect, GrTexture*, const SkMatrix& matrix,
+ const SkIRect& bounds) const SK_OVERRIDE;
#endif
private:
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
#if SK_SUPPORT_GPU
- virtual bool asNewEffect(GrEffectRef** effect, GrTexture*, const SkMatrix& matrix, const SkIRect& bounds) const SK_OVERRIDE;
+ virtual bool asNewEffect(GrEffect** effect, GrTexture*, const SkMatrix& matrix,
+ const SkIRect& bounds) const SK_OVERRIDE;
#endif
private:
class GrDiffuseLightingEffect : public GrLightingEffect {
public:
- static GrEffectRef* Create(GrTexture* texture,
- const SkLight* light,
- SkScalar surfaceScale,
- const SkMatrix& matrix,
- SkScalar kd) {
+ static GrEffect* Create(GrTexture* texture,
+ const SkLight* light,
+ SkScalar surfaceScale,
+ const SkMatrix& matrix,
+ SkScalar kd) {
return SkNEW_ARGS(GrDiffuseLightingEffect, (texture,
light,
surfaceScale,
class GrSpecularLightingEffect : public GrLightingEffect {
public:
- static GrEffectRef* Create(GrTexture* texture,
- const SkLight* light,
- SkScalar surfaceScale,
- const SkMatrix& matrix,
- SkScalar ks,
- SkScalar shininess) {
+ static GrEffect* Create(GrTexture* texture,
+ const SkLight* light,
+ SkScalar surfaceScale,
+ const SkMatrix& matrix,
+ SkScalar ks,
+ SkScalar shininess) {
return SkNEW_ARGS(GrSpecularLightingEffect, (texture,
light,
surfaceScale,
}
#if SK_SUPPORT_GPU
-bool SkDiffuseLightingImageFilter::asNewEffect(GrEffectRef** effect, GrTexture* texture, const SkMatrix& matrix, const SkIRect&) const {
+bool SkDiffuseLightingImageFilter::asNewEffect(GrEffect** effect, GrTexture* texture,
+ const SkMatrix& matrix, const SkIRect&) const {
if (effect) {
SkScalar scale = SkScalarMul(surfaceScale(), SkIntToScalar(255));
*effect = GrDiffuseLightingEffect::Create(texture, light(), scale, matrix, kd());
}
#if SK_SUPPORT_GPU
-bool SkSpecularLightingImageFilter::asNewEffect(GrEffectRef** effect, GrTexture* texture, const SkMatrix& matrix, const SkIRect&) const {
+bool SkSpecularLightingImageFilter::asNewEffect(GrEffect** effect, GrTexture* texture,
+ const SkMatrix& matrix, const SkIRect&) const {
if (effect) {
SkScalar scale = SkScalarMul(surfaceScale(), SkIntToScalar(255));
*effect = GrSpecularLightingEffect::Create(texture, light(), scale, matrix, ks(), shininess());
GR_DEFINE_EFFECT_TEST(GrDiffuseLightingEffect);
-GrEffectRef* GrDiffuseLightingEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
+GrEffect* GrDiffuseLightingEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
SkScalar surfaceScale = random->nextSScalar1();
SkScalar kd = random->nextUScalar1();
SkAutoTUnref<SkLight> light(create_random_light(random));
GR_DEFINE_EFFECT_TEST(GrSpecularLightingEffect);
-GrEffectRef* GrSpecularLightingEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
+GrEffect* GrSpecularLightingEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
SkScalar surfaceScale = random->nextSScalar1();
SkScalar ks = random->nextUScalar1();
SkScalar shininess = random->nextUScalar1();
#if SK_SUPPORT_GPU
class LumaColorFilterEffect : public GrEffect {
public:
- static GrEffectRef* Create() {
+ static GrEffect* Create() {
GR_CREATE_STATIC_EFFECT(gLumaEffect, LumaColorFilterEffect, ());
return SkRef(gLumaEffect);
}
class GrMagnifierEffect : public GrSingleTextureEffect {
public:
- static GrEffectRef* Create(GrTexture* texture,
- float xOffset,
- float yOffset,
- float xInvZoom,
- float yInvZoom,
- float xInvInset,
- float yInvInset) {
+ static GrEffect* Create(GrTexture* texture,
+ float xOffset,
+ float yOffset,
+ float xInvZoom,
+ float yInvZoom,
+ float xInvInset,
+ float yInvInset) {
return SkNEW_ARGS(GrMagnifierEffect, (texture,
xOffset,
yOffset,
GR_DEFINE_EFFECT_TEST(GrMagnifierEffect);
-GrEffectRef* GrMagnifierEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture** textures) {
+GrEffect* GrMagnifierEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture** textures) {
GrTexture* texture = textures[0];
const int kMaxWidth = 200;
const int kMaxHeight = 200;
uint32_t y = random->nextULessThan(kMaxHeight - height);
uint32_t inset = random->nextULessThan(kMaxInset);
- GrEffectRef* effect = GrMagnifierEffect::Create(
+ GrEffect* effect = GrMagnifierEffect::Create(
texture,
(float) width / texture->width(),
(float) height / texture->height(),
}
#if SK_SUPPORT_GPU
-bool SkMagnifierImageFilter::asNewEffect(GrEffectRef** effect, GrTexture* texture, const SkMatrix&, const SkIRect&) const {
+bool SkMagnifierImageFilter::asNewEffect(GrEffect** effect, GrTexture* texture, const SkMatrix&,
+ const SkIRect&) const {
if (effect) {
SkScalar yOffset = (texture->origin() == kTopLeft_GrSurfaceOrigin) ? fSrcRect.y() :
(texture->height() - (fSrcRect.y() + fSrcRect.height()));
class GrMatrixConvolutionEffect : public GrSingleTextureEffect {
public:
typedef SkMatrixConvolutionImageFilter::TileMode TileMode;
- static GrEffectRef* Create(GrTexture* texture,
- const SkIRect& bounds,
- const SkISize& kernelSize,
- const SkScalar* kernel,
- SkScalar gain,
- SkScalar bias,
- const SkIPoint& kernelOffset,
- TileMode tileMode,
- bool convolveAlpha) {
+ static GrEffect* Create(GrTexture* texture,
+ const SkIRect& bounds,
+ const SkISize& kernelSize,
+ const SkScalar* kernel,
+ SkScalar gain,
+ SkScalar bias,
+ const SkIPoint& kernelOffset,
+ TileMode tileMode,
+ bool convolveAlpha) {
return SkNEW_ARGS(GrMatrixConvolutionEffect, (texture,
bounds,
kernelSize,
// Allows for a 5x5 kernel (or 25x1, for that matter).
#define MAX_KERNEL_SIZE 25
-GrEffectRef* GrMatrixConvolutionEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
+GrEffect* GrMatrixConvolutionEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
GrEffectUnitTest::kAlphaTextureIdx;
int width = random->nextRangeU(1, MAX_KERNEL_SIZE);
convolveAlpha);
}
-bool SkMatrixConvolutionImageFilter::asNewEffect(GrEffectRef** effect,
+bool SkMatrixConvolutionImageFilter::asNewEffect(GrEffect** effect,
GrTexture* texture,
const SkMatrix&,
const SkIRect& bounds
kDilate_MorphologyType,
};
- static GrEffectRef* Create(GrTexture* tex, Direction dir, int radius, MorphologyType type) {
+ static GrEffect* Create(GrTexture* tex, Direction dir, int radius, MorphologyType type) {
return SkNEW_ARGS(GrMorphologyEffect, (tex, dir, radius, type));
}
GR_DEFINE_EFFECT_TEST(GrMorphologyEffect);
-GrEffectRef* GrMorphologyEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
+GrEffect* GrMorphologyEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
GrEffectUnitTest::kAlphaTextureIdx;
Direction dir = random->nextBool() ? kX_Direction : kY_Direction;
class GrPerlinNoiseEffect : public GrEffect {
public:
- static GrEffectRef* Create(SkPerlinNoiseShader::Type type,
- int numOctaves, bool stitchTiles,
- SkPerlinNoiseShader::PaintingData* paintingData,
- GrTexture* permutationsTexture, GrTexture* noiseTexture,
- const SkMatrix& matrix, uint8_t alpha) {
+ static GrEffect* Create(SkPerlinNoiseShader::Type type,
+ int numOctaves, bool stitchTiles,
+ SkPerlinNoiseShader::PaintingData* paintingData,
+ GrTexture* permutationsTexture, GrTexture* noiseTexture,
+ const SkMatrix& matrix, uint8_t alpha) {
return SkNEW_ARGS(GrPerlinNoiseEffect, (type, numOctaves, stitchTiles, paintingData,
permutationsTexture, noiseTexture, matrix, alpha));
}
/////////////////////////////////////////////////////////////////////
GR_DEFINE_EFFECT_TEST(GrPerlinNoiseEffect);
-GrEffectRef* GrPerlinNoiseEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture**) {
+GrEffect* GrPerlinNoiseEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture**) {
int numOctaves = random->nextRangeU(2, 10);
bool stitchTiles = random->nextBool();
SkScalar seed = SkIntToScalar(random->nextU());
stitchTiles ? &tileSize : NULL);
SkPaint paint;
- GrColor grColor;
- GrEffectRef* effect;
- shader->asNewEffect(context, paint, NULL, &grColor, &effect);
+ GrColor paintColor;
+ GrEffect* effect;
+ SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effect));
SkDELETE(shader);
/////////////////////////////////////////////////////////////////////
bool SkPerlinNoiseShader::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* externalLocalMatrix, GrColor* grColor,
- GrEffect** grEffect) const {
+ const SkMatrix* externalLocalMatrix, GrColor* paintColor,
+ GrEffect** effect) const {
SkASSERT(NULL != context);
- *grColor = SkColor2GrColorJustAlpha(paint.getColor());
+ *paintColor = SkColor2GrColorJustAlpha(paint.getColor());
SkMatrix localMatrix = this->getLocalMatrix();
if (externalLocalMatrix) {
}
SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(
clearColor, SkXfermode::kSrc_Mode));
- *grEffect = cf->asNewEffect(context);
+ *effect = cf->asNewEffect(context);
return true;
}
m.setTranslateX(-localMatrix.getTranslateX() + SK_Scalar1);
m.setTranslateY(-localMatrix.getTranslateY() + SK_Scalar1);
if ((NULL != permutationsTexture) && (NULL != noiseTexture)) {
- *grEffect = GrPerlinNoiseEffect::Create(fType,
+ *effect = GrPerlinNoiseEffect::Create(fType,
fNumOctaves,
fStitchTiles,
paintingData,
m, paint.getAlpha());
} else {
SkDELETE(paintingData);
- *grEffect = NULL;
+ *effect = NULL;
}
// Unlock immediately, this is not great, but we don't have a way of
#else
bool SkPerlinNoiseShader::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* externalLocalMatrix, GrColor* grColor,
- GrEffect** grEffect) const {
+ const SkMatrix* externalLocalMatrix, GrColor* paintColor,
+ GrEffect** effect) const {
SkDEBUGFAIL("Should not call in GPU-less build");
return false;
}
class ColorTableEffect : public GrEffect {
public:
- static GrEffectRef* Create(GrTexture* texture, unsigned flags) {
+ static GrEffect* Create(GrTexture* texture, unsigned flags) {
return SkNEW_ARGS(ColorTableEffect, (texture, flags));
}
GR_DEFINE_EFFECT_TEST(ColorTableEffect);
-GrEffectRef* ColorTableEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
+GrEffect* ColorTableEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
static unsigned kAllFlags = SkTable_ColorFilter::kR_Flag | SkTable_ColorFilter::kG_Flag |
SkTable_ColorFilter::kB_Flag | SkTable_ColorFilter::kA_Flag;
return ColorTableEffect::Create(textures[GrEffectUnitTest::kAlphaTextureIdx], kAllFlags);
}
-GrEffectRef* SkTable_ColorFilter::asNewEffect(GrContext* context) const {
+GrEffect* SkTable_ColorFilter::asNewEffect(GrContext* context) const {
SkBitmap bitmap;
- GrEffectRef* effect = NULL;
+ GrEffect* effect = NULL;
this->asComponentTable(&bitmap);
// passing NULL because this effect does no tiling or filtering.
GrTexture* texture = GrLockAndRefCachedBitmapTexture(context, bitmap, NULL);
GrTexture* foregroundTex = foreground.getTexture();
GrContext* context = foregroundTex->getContext();
- GrEffectRef* xferEffect = NULL;
+ GrEffect* xferEffect = NULL;
GrTextureDesc desc;
desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit;
class GrLinearGradient : public GrGradientEffect {
public:
- static GrEffectRef* Create(GrContext* ctx,
- const SkLinearGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm) {
+ static GrEffect* Create(GrContext* ctx,
+ const SkLinearGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm) {
return SkNEW_ARGS(GrLinearGradient, (ctx, shader, matrix, tm));
}
GR_DEFINE_EFFECT_TEST(GrLinearGradient);
-GrEffectRef* GrLinearGradient::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture**) {
+GrEffect* GrLinearGradient::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture**) {
SkPoint points[] = {{random->nextUScalar1(), random->nextUScalar1()},
{random->nextUScalar1(), random->nextUScalar1()}};
colors, stops, colorCount,
tm));
SkPaint paint;
- GrColor grColor;
- GrEffectRef* effect;
- shader->asNewEffect(context, paint, NULL, &grColor, &effect);
+ GrColor paintColor;
+ GrEffect* effect;
+ SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effect));
return effect;
}
/////////////////////////////////////////////////////////////////////
bool SkLinearGradient::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* grColor,
- GrEffectRef** grEffect) const {
+ const SkMatrix* localMatrix, GrColor* paintColor,
+ GrEffect** effect) const {
SkASSERT(NULL != context);
SkMatrix matrix;
}
matrix.postConcat(fPtsToUnit);
- *grColor = SkColor2GrColorJustAlpha(paint.getColor());
- *grEffect = GrLinearGradient::Create(context, *this, matrix, fTileMode);
+ *paintColor = SkColor2GrColorJustAlpha(paint.getColor());
+ *effect = GrLinearGradient::Create(context, *this, matrix, fTileMode);
return true;
}
#else
bool SkLinearGradient::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* grColor,
- GrEffect** grEffect) const {
+ const SkMatrix* localMatrix, GrColor* paintColor,
+ GrEffect** effect) const {
SkDEBUGFAIL("Should not call in GPU-less build");
return false;
}
virtual BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*) const SK_OVERRIDE;
virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
virtual bool asNewEffect(GrContext* context, const SkPaint& paint, const SkMatrix* localMatrix,
- GrColor* grColor, GrEffect** grEffect) const SK_OVERRIDE;
+ GrColor* paintColor, GrEffect** effect) const SK_OVERRIDE;
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLinearGradient)
class GrRadialGradient : public GrGradientEffect {
public:
- static GrEffectRef* Create(GrContext* ctx,
- const SkRadialGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm) {
+ static GrEffect* Create(GrContext* ctx,
+ const SkRadialGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm) {
return SkNEW_ARGS(GrRadialGradient, (ctx, shader, matrix, tm));
}
GR_DEFINE_EFFECT_TEST(GrRadialGradient);
-GrEffectRef* GrRadialGradient::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture**) {
+GrEffect* GrRadialGradient::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture**) {
SkPoint center = {random->nextUScalar1(), random->nextUScalar1()};
SkScalar radius = random->nextUScalar1();
colors, stops, colorCount,
tm));
SkPaint paint;
- GrColor grColor;
- GrEffectRef* effect;
- shader->asNewEffect(context, paint, NULL, &grColor, &effect);
+ GrColor paintColor;
+ GrEffect* effect;
+ SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effect));
return effect;
}
/////////////////////////////////////////////////////////////////////
bool SkRadialGradient::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* grColor,
- GrEffectRef** grEffect) const {
+ const SkMatrix* localMatrix, GrColor* paintColor,
+ GrEffect** effect) const {
SkASSERT(NULL != context);
SkMatrix matrix;
}
matrix.postConcat(fPtsToUnit);
- *grColor = SkColor2GrColorJustAlpha(paint.getColor());
- *grEffect = GrRadialGradient::Create(context, *this, matrix, fTileMode);
+ *paintColor = SkColor2GrColorJustAlpha(paint.getColor());
+ *effect = GrRadialGradient::Create(context, *this, matrix, fTileMode);
return true;
}
#else
bool SkRadialGradient::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* grColor,
- GrEffect** grEffect) const {
+ const SkMatrix* localMatrix, GrColor* paintColor,
+ GrEffect** effect) const {
SkDEBUGFAIL("Should not call in GPU-less build");
return false;
}
class GrSweepGradient : public GrGradientEffect {
public:
- static GrEffectRef* Create(GrContext* ctx,
- const SkSweepGradient& shader,
- const SkMatrix& matrix) {
- return SkNEW_ARGS(GrSweepGradient, (ctx, shader, matrix));
+ static GrEffect* Create(GrContext* ctx, const SkSweepGradient& shader, const SkMatrix& m) {
+ return SkNEW_ARGS(GrSweepGradient, (ctx, shader, m));
}
virtual ~GrSweepGradient() { }
GR_DEFINE_EFFECT_TEST(GrSweepGradient);
-GrEffectRef* GrSweepGradient::TestCreate(SkRandom* random,
+GrEffect* GrSweepGradient::TestCreate(SkRandom* random,
GrContext* context,
const GrDrawTargetCaps&,
GrTexture**) {
SkAutoTUnref<SkShader> shader(SkGradientShader::CreateSweep(center.fX, center.fY,
colors, stops, colorCount));
SkPaint paint;
- GrEffectRef* effect;
- GrColor grColor;
- shader->asNewEffect(context, paint, NULL, &grColor, &effect);
+ GrEffect* effect;
+ GrColor paintColor;
+ SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effect));
return effect;
}
/////////////////////////////////////////////////////////////////////
bool SkSweepGradient::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* grColor,
- GrEffectRef** grEffect) const {
+ const SkMatrix* localMatrix, GrColor* paintColor,
+ GrEffect** effect) const {
SkMatrix matrix;
if (!this->getLocalMatrix().invert(&matrix)) {
}
matrix.postConcat(fPtsToUnit);
- *grEffect = GrSweepGradient::Create(context, *this, matrix);
- *grColor = SkColor2GrColorJustAlpha(paint.getColor());
+ *effect = GrSweepGradient::Create(context, *this, matrix);
+ *paintColor = SkColor2GrColorJustAlpha(paint.getColor());
return true;
}
#else
bool SkSweepGradient::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* grColor,
- GrEffect** grEffect) const {
+ const SkMatrix* localMatrix, GrColor* paintColor,
+ GrEffect** effect) const {
SkDEBUGFAIL("Should not call in GPU-less build");
return false;
}
#include "SkGr.h"
bool SkTwoPointConicalGradient::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* grColor,
- GrEffectRef** grEffect) const {
+ const SkMatrix* localMatrix, GrColor* paintColor,
+ GrEffect** effect) const {
SkASSERT(NULL != context);
SkASSERT(fPtsToUnit.isIdentity());
- *grEffect = Gr2PtConicalGradientEffect::Create(context, *this, fTileMode, localMatrix);
- *grColor = SkColor2GrColorJustAlpha(paint.getColor());
+ *effect = Gr2PtConicalGradientEffect::Create(context, *this, fTileMode, localMatrix);
+ *paintColor = SkColor2GrColorJustAlpha(paint.getColor());
return true;
}
#else
bool SkTwoPointConicalGradient::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* grColor,
- GrEffect** grEffect) const {
+ const SkMatrix* localMatrix, GrColor* paintColor,
+ GrEffect** effect) const {
SkDEBUGFAIL("Should not call in GPU-less build");
return false;
}
SkMatrix* matrix,
TileMode* xy) const;
virtual SkShader::GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
- virtual bool asNewEffect(GrContext*, const SkPaint&, const SkMatrix*, GrColor* grColor,
+ virtual bool asNewEffect(GrContext*, const SkPaint&, const SkMatrix*, GrColor* paintColor,
GrEffect**) const SK_OVERRIDE;
virtual bool isOpaque() const SK_OVERRIDE;
class Edge2PtConicalEffect : public GrGradientEffect {
public:
- static GrEffectRef* Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm) {
+ static GrEffect* Create(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm) {
return SkNEW_ARGS(Edge2PtConicalEffect, (ctx, shader, matrix, tm));
}
GR_DEFINE_EFFECT_TEST(Edge2PtConicalEffect);
-GrEffectRef* Edge2PtConicalEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture**) {
+GrEffect* Edge2PtConicalEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture**) {
SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()};
SkScalar radius1 = random->nextUScalar1();
SkPoint center2;
colors, stops, colorCount,
tm));
SkPaint paint;
- GrEffectRef* effect;
- GrColor grColor;
- shader->asNewEffect(context, paint, NULL, &grColor, &effect);
+ GrEffect* effect;
+ GrColor paintColor;
+ SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effect));
return effect;
}
class FocalOutside2PtConicalEffect : public GrGradientEffect {
public:
- static GrEffectRef* Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm,
- SkScalar focalX) {
+ static GrEffect* Create(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm,
+ SkScalar focalX) {
return SkNEW_ARGS(FocalOutside2PtConicalEffect, (ctx, shader, matrix, tm, focalX));
}
GR_DEFINE_EFFECT_TEST(FocalOutside2PtConicalEffect);
-GrEffectRef* FocalOutside2PtConicalEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture**) {
+GrEffect* FocalOutside2PtConicalEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture**) {
SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()};
SkScalar radius1 = 0.f;
SkPoint center2;
colors, stops, colorCount,
tm));
SkPaint paint;
- GrEffectRef* effect;
- GrColor grColor;
- shader->asNewEffect(context, paint, NULL, &grColor, &effect);
+ GrEffect* effect;
+ GrColor paintColor;
+ SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effect));
return effect;
}
class FocalInside2PtConicalEffect : public GrGradientEffect {
public:
- static GrEffectRef* Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm,
- SkScalar focalX) {
+ static GrEffect* Create(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm,
+ SkScalar focalX) {
return SkNEW_ARGS(FocalInside2PtConicalEffect, (ctx, shader, matrix, tm, focalX));
}
GR_DEFINE_EFFECT_TEST(FocalInside2PtConicalEffect);
-GrEffectRef* FocalInside2PtConicalEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture**) {
+GrEffect* FocalInside2PtConicalEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture**) {
SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()};
SkScalar radius1 = 0.f;
SkPoint center2;
colors, stops, colorCount,
tm));
SkPaint paint;
- GrColor grColor;
- GrEffectRef* grEffect;
- shader->asNewEffect(context, paint, NULL, &grColor, &grEffect);
- return grEffect;
+ GrColor paintColor;
+ GrEffect* effect;
+ SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effect));
+ return effect;
}
GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrBackendEffectFactory& factory,
class CircleInside2PtConicalEffect : public GrGradientEffect {
public:
- static GrEffectRef* Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm,
- const CircleConicalInfo& info) {
+ static GrEffect* Create(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm,
+ const CircleConicalInfo& info) {
return SkNEW_ARGS(CircleInside2PtConicalEffect, (ctx, shader, matrix, tm, info));
}
GR_DEFINE_EFFECT_TEST(CircleInside2PtConicalEffect);
-GrEffectRef* CircleInside2PtConicalEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture**) {
+GrEffect* CircleInside2PtConicalEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture**) {
SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()};
SkScalar radius1 = random->nextUScalar1() + 0.0001f; // make sure radius1 != 0
SkPoint center2;
colors, stops, colorCount,
tm));
SkPaint paint;
- GrColor grColor;
- GrEffectRef* grEffect;
- shader->asNewEffect(context, paint, NULL, &grColor, &grEffect);
- return grEffect;
+ GrColor paintColor;
+ GrEffect* effect;
+ SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effect));
+ return effect;
}
GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrBackendEffectFactory& factory,
class CircleOutside2PtConicalEffect : public GrGradientEffect {
public:
- static GrEffectRef* Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm,
- const CircleConicalInfo& info) {
+ static GrEffect* Create(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm,
+ const CircleConicalInfo& info) {
return SkNEW_ARGS(CircleOutside2PtConicalEffect, (ctx, shader, matrix, tm, info));
}
GR_DEFINE_EFFECT_TEST(CircleOutside2PtConicalEffect);
-GrEffectRef* CircleOutside2PtConicalEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture**) {
+GrEffect* CircleOutside2PtConicalEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture**) {
SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()};
SkScalar radius1 = random->nextUScalar1() + 0.0001f; // make sure radius1 != 0
SkPoint center2;
colors, stops, colorCount,
tm));
SkPaint paint;
- GrColor grColor;
- GrEffectRef* grEffect;
- shader->asNewEffect(context, paint, NULL, &grColor, &grEffect);
- return grEffect;
+ GrColor paintColor;
+ GrEffect* effect;
+ SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effect));
+ return effect;
}
GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrBackendEffectFactory& factory,
//////////////////////////////////////////////////////////////////////////////
-GrEffectRef* Gr2PtConicalGradientEffect::Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- SkShader::TileMode tm,
- const SkMatrix* localMatrix) {
+GrEffect* Gr2PtConicalGradientEffect::Create(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ SkShader::TileMode tm,
+ const SkMatrix* localMatrix) {
SkMatrix matrix;
if (!shader.getLocalMatrix().invert(&matrix)) {
return NULL;
class GrRadial2Gradient : public GrGradientEffect {
public:
- static GrEffectRef* Create(GrContext* ctx,
- const SkTwoPointRadialGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm) {
+ static GrEffect* Create(GrContext* ctx,
+ const SkTwoPointRadialGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm) {
return SkNEW_ARGS(GrRadial2Gradient, (ctx, shader, matrix, tm));
}
GR_DEFINE_EFFECT_TEST(GrRadial2Gradient);
-GrEffectRef* GrRadial2Gradient::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture**) {
+GrEffect* GrRadial2Gradient::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture**) {
SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()};
SkScalar radius1 = random->nextUScalar1();
SkPoint center2;
colors, stops, colorCount,
tm));
SkPaint paint;
- GrEffectRef* effect;
- GrColor grColor;
- shader->asNewEffect(context, paint, NULL, &grColor, &effect);
+ GrEffect* effect;
+ GrColor paintColor;
+ SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effect));
return effect;
}
/////////////////////////////////////////////////////////////////////
bool SkTwoPointRadialGradient::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* grColor,
- GrEffectRef** grEffect) const {
+ const SkMatrix* localMatrix, GrColor* paintColor,
+ GrEffect** effect) const {
SkASSERT(NULL != context);
// invert the localM, translate to center1 (fPtsToUni), rotate so center2 is on x axis.
matrix.postConcat(rot);
}
- *grColor = SkColor2GrColorJustAlpha(paint.getColor());
- *grEffect = GrRadial2Gradient::Create(context, *this, matrix, fTileMode);
+ *paintColor = SkColor2GrColorJustAlpha(paint.getColor());
+ *effect = GrRadial2Gradient::Create(context, *this, matrix, fTileMode);
return true;
}
#else
bool SkTwoPointRadialGradient::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* grColor,
- GrEffect** grEffect) const {
+ const SkMatrix* localMatrix, GrColor* paintColor,
+ GrEffect** effect) const {
SkDEBUGFAIL("Should not call in GPU-less build");
return false;
}
class QuadEdgeEffect : public GrVertexEffect {
public:
- static GrEffectRef* Create() {
+ static GrEffect* Create() {
GR_CREATE_STATIC_EFFECT(gQuadEdgeEffect, QuadEdgeEffect, ());
gQuadEdgeEffect->ref();
return gQuadEdgeEffect;
GR_DEFINE_EFFECT_TEST(QuadEdgeEffect);
-GrEffectRef* QuadEdgeEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps& caps,
- GrTexture*[]) {
+GrEffect* QuadEdgeEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps& caps,
+ GrTexture*[]) {
// Doesn't work without derivative instructions.
return caps.shaderDerivativeSupport() ? QuadEdgeEffect::Create() : NULL;
}
drawState->setVertexAttribs<gPathAttribs>(SK_ARRAY_COUNT(gPathAttribs));
static const int kEdgeAttrIndex = 1;
- GrEffectRef* quadEffect = QuadEdgeEffect::Create();
+ GrEffect* quadEffect = QuadEdgeEffect::Create();
drawState->addCoverageEffect(quadEffect, kEdgeAttrIndex)->unref();
GrDrawTarget::AutoReleaseGeometry arg(target, vCount, iCount);
kVertsPerQuad * quadCnt + kVertsPerQuad * conicCnt));
if (quadCnt > 0) {
- GrEffectRef* hairQuadEffect = GrQuadEffect::Create(kHairlineAA_GrEffectEdgeType,
- *target->caps());
+ GrEffect* hairQuadEffect = GrQuadEffect::Create(kHairlineAA_GrEffectEdgeType,
+ *target->caps());
SkASSERT(NULL != hairQuadEffect);
GrDrawState::AutoRestoreEffects are(drawState);
target->setIndexSourceToBuffer(fQuadsIndexBuffer);
if (conicCnt > 0) {
GrDrawState::AutoRestoreEffects are(drawState);
- GrEffectRef* hairConicEffect = GrConicEffect::Create(kHairlineAA_GrEffectEdgeType,
- *target->caps());
+ GrEffect* hairConicEffect = GrConicEffect::Create(kHairlineAA_GrEffectEdgeType,
+ *target->caps());
SkASSERT(NULL != hairConicEffect);
drawState->addCoverageEffect(hairConicEffect, 1, 2)->unref();
int conics = 0;
// Axis Aligned special case
class GrAlignedRectEffect : public GrVertexEffect {
public:
- static GrEffectRef* Create() {
+ static GrEffect* Create() {
GR_CREATE_STATIC_EFFECT(gAlignedRectEffect, GrAlignedRectEffect, ());
gAlignedRectEffect->ref();
return gAlignedRectEffect;
GR_DEFINE_EFFECT_TEST(GrAlignedRectEffect);
-GrEffectRef* GrAlignedRectEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
+GrEffect* GrAlignedRectEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
return GrAlignedRectEffect::Create();
}
*/
class GrRectEffect : public GrVertexEffect {
public:
- static GrEffectRef* Create() {
+ static GrEffect* Create() {
GR_CREATE_STATIC_EFFECT(gRectEffect, GrRectEffect, ());
gRectEffect->ref();
return gRectEffect;
GR_DEFINE_EFFECT_TEST(GrRectEffect);
-GrEffectRef* GrRectEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
+GrEffect* GrRectEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
return GrRectEffect::Create();
}
RectVertex* verts = reinterpret_cast<RectVertex*>(geo.vertices());
- GrEffectRef* effect = GrRectEffect::Create();
+ GrEffect* effect = GrRectEffect::Create();
static const int kRectAttrIndex = 1;
static const int kWidthIndex = 2;
drawState->addCoverageEffect(effect, kRectAttrIndex, kWidthIndex)->unref();
AARectVertex* verts = reinterpret_cast<AARectVertex*>(geo.vertices());
- GrEffectRef* effect = GrAlignedRectEffect::Create();
+ GrEffect* effect = GrAlignedRectEffect::Create();
static const int kOffsetIndex = 1;
drawState->addCoverageEffect(effect, kOffsetIndex)->unref();
void* fVertices;
int32_t fMaxVertices;
GrTexture* fCurrTexture;
- SkAutoTUnref<GrEffectRef> fCachedEffect;
+ SkAutoTUnref<GrEffect> fCachedEffect;
uint32_t fEffectTextureGenID;
int fCurrVertex;
SkRect fVertexBounds;
} else {
edgeType = invert ? kInverseFillBW_GrEffectEdgeType : kFillBW_GrEffectEdgeType;
}
- SkAutoTUnref<GrEffectRef> effect;
+ SkAutoTUnref<GrEffect> effect;
switch (iter.get()->getType()) {
case SkClipStack::Element::kPath_Type:
effect.reset(GrConvexPolyEffect::Create(edgeType, iter.get()->getPath(),
textureMatrix.setTranslate(SK_Scalar1 *left, SK_Scalar1 *top);
textureMatrix.postIDiv(src->width(), src->height());
- SkAutoTUnref<const GrEffectRef> effect;
+ SkAutoTUnref<const GrEffect> effect;
if (unpremul) {
effect.reset(this->createPMToUPMEffect(src, swapRAndB, textureMatrix));
if (NULL != effect) {
return false;
}
- SkAutoTUnref<const GrEffectRef> effect;
+ SkAutoTUnref<const GrEffect> effect;
SkMatrix textureMatrix;
textureMatrix.setIDiv(texture->width(), texture->height());
}
}
-const GrEffectRef* GrContext::createPMToUPMEffect(GrTexture* texture,
- bool swapRAndB,
- const SkMatrix& matrix) {
+const GrEffect* GrContext::createPMToUPMEffect(GrTexture* texture,
+ bool swapRAndB,
+ const SkMatrix& matrix) {
if (!fDidTestPMConversions) {
test_pm_conversions(this, &fPMToUPMConversion, &fUPMToPMConversion);
fDidTestPMConversions = true;
}
}
-const GrEffectRef* GrContext::createUPMToPMEffect(GrTexture* texture,
- bool swapRAndB,
- const SkMatrix& matrix) {
+const GrEffect* GrContext::createUPMToPMEffect(GrTexture* texture,
+ bool swapRAndB,
+ const SkMatrix& matrix) {
if (!fDidTestPMConversions) {
test_pm_conversions(this, &fPMToUPMConversion, &fUPMToPMConversion);
fDidTestPMConversions = true;
class CircleEdgeEffect : public GrVertexEffect {
public:
- static GrEffectRef* Create(bool stroke) {
+ static GrEffect* Create(bool stroke) {
GR_CREATE_STATIC_EFFECT(gCircleStrokeEdge, CircleEdgeEffect, (true));
GR_CREATE_STATIC_EFFECT(gCircleFillEdge, CircleEdgeEffect, (false));
GR_DEFINE_EFFECT_TEST(CircleEdgeEffect);
-GrEffectRef* CircleEdgeEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
+GrEffect* CircleEdgeEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
return CircleEdgeEffect::Create(random->nextBool());
}
class EllipseEdgeEffect : public GrVertexEffect {
public:
- static GrEffectRef* Create(bool stroke) {
+ static GrEffect* Create(bool stroke) {
GR_CREATE_STATIC_EFFECT(gEllipseStrokeEdge, EllipseEdgeEffect, (true));
GR_CREATE_STATIC_EFFECT(gEllipseFillEdge, EllipseEdgeEffect, (false));
GR_DEFINE_EFFECT_TEST(EllipseEdgeEffect);
-GrEffectRef* EllipseEdgeEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
+GrEffect* EllipseEdgeEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
return EllipseEdgeEffect::Create(random->nextBool());
}
public:
enum Mode { kStroke = 0, kHairline, kFill };
- static GrEffectRef* Create(Mode mode) {
+ static GrEffect* Create(Mode mode) {
GR_CREATE_STATIC_EFFECT(gEllipseStrokeEdge, DIEllipseEdgeEffect, (kStroke));
GR_CREATE_STATIC_EFFECT(gEllipseHairlineEdge, DIEllipseEdgeEffect, (kHairline));
GR_CREATE_STATIC_EFFECT(gEllipseFillEdge, DIEllipseEdgeEffect, (kFill));
GR_DEFINE_EFFECT_TEST(DIEllipseEdgeEffect);
-GrEffectRef* DIEllipseEdgeEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
+GrEffect* DIEllipseEdgeEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
return DIEllipseEdgeEffect::Create((Mode)(random->nextRangeU(0,2)));
}
}
}
- GrEffectRef* effect = CircleEdgeEffect::Create(isStrokeOnly && innerRadius > 0);
+ GrEffect* effect = CircleEdgeEffect::Create(isStrokeOnly && innerRadius > 0);
static const int kCircleEdgeAttrIndex = 1;
drawState->addCoverageEffect(effect, kCircleEdgeAttrIndex)->unref();
EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(geo.vertices());
- GrEffectRef* effect = EllipseEdgeEffect::Create(isStrokeOnly &&
- innerXRadius > 0 && innerYRadius > 0);
+ GrEffect* effect = EllipseEdgeEffect::Create(isStrokeOnly &&
+ innerXRadius > 0 && innerYRadius > 0);
static const int kEllipseCenterAttrIndex = 1;
static const int kEllipseEdgeAttrIndex = 2;
DIEllipseVertex* verts = reinterpret_cast<DIEllipseVertex*>(geo.vertices());
- GrEffectRef* effect = DIEllipseEdgeEffect::Create(mode);
+ GrEffect* effect = DIEllipseEdgeEffect::Create(mode);
static const int kEllipseOuterOffsetAttrIndex = 1;
static const int kEllipseInnerOffsetAttrIndex = 2;
}
GrEffectEdgeType edgeType = applyAA ? kInverseFillAA_GrEffectEdgeType :
kInverseFillBW_GrEffectEdgeType;
- GrEffectRef* effect = GrRRectEffect::Create(edgeType, *inner);
+ GrEffect* effect = GrRRectEffect::Create(edgeType, *inner);
if (NULL == effect) {
return false;
}
}
GrEffectEdgeType edgeType = applyAA ? kFillAA_GrEffectEdgeType :
kFillBW_GrEffectEdgeType;
- GrEffectRef* effect = GrRRectEffect::Create(edgeType, *outer);
+ GrEffect* effect = GrRRectEffect::Create(edgeType, *outer);
if (NULL == effect) {
return false;
}
isStrokeOnly = (isStrokeOnly && innerRadius >= 0);
- GrEffectRef* effect = CircleEdgeEffect::Create(isStrokeOnly);
+ GrEffect* effect = CircleEdgeEffect::Create(isStrokeOnly);
static const int kCircleEdgeAttrIndex = 1;
drawState->addCoverageEffect(effect, kCircleEdgeAttrIndex)->unref();
}
EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(geo.vertices());
- GrEffectRef* effect = EllipseEdgeEffect::Create(isStrokeOnly);
+ GrEffect* effect = EllipseEdgeEffect::Create(isStrokeOnly);
static const int kEllipseOffsetAttrIndex = 1;
static const int kEllipseRadiiAttrIndex = 2;
drawState->addCoverageEffect(effect,
SkScalarMul(srcRect.fBottom, hInv));
SkRect textureDomain = SkRect::MakeEmpty();
- SkAutoTUnref<GrEffectRef> effect;
+ SkAutoTUnref<GrEffect> effect;
if (needsTextureDomain && !(flags & SkCanvas::kBleed_DrawBitmapRectFlag)) {
// Use a constrained texture domain to avoid color bleeding
SkScalar left, top, right, bottom;
GrPaint grPaint;
grPaint.addColorEffect(effect);
bool alphaOnly = !(kAlpha_8_SkColorType == bitmap.colorType());
- GrColor grColor = (alphaOnly) ? SkColor2GrColorJustAlpha(paint.getColor()) :
- SkColor2GrColor(paint.getColor());
- SkPaint2GrPaintNoShader(this->context(), paint, grColor, false, &grPaint);
+ GrColor paintColor = (alphaOnly) ? SkColor2GrColorJustAlpha(paint.getColor()) :
+ SkColor2GrColor(paint.getColor());
+ SkPaint2GrPaintNoShader(this->context(), paint, paintColor, false, &grPaint);
fContext->drawRectToRect(grPaint, dstRect, paintRect, NULL);
}
///////////////////////////////////////////////////////////////////////////////
-void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, GrColor grColor,
+void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, GrColor paintColor,
bool constantColor, GrPaint* grPaint) {
grPaint->setDither(skPaint.isDither());
SkXfermode::Coeff dm;
SkXfermode* mode = skPaint.getXfermode();
- GrEffectRef* xferEffect = NULL;
+ GrEffect* xferEffect = NULL;
if (SkXfermode::AsNewEffectOrCoeff(mode, &xferEffect, &sm, &dm)) {
if (NULL != xferEffect) {
grPaint->addColorEffect(xferEffect)->unref();
grPaint->setBlendFunc(sk_blend_to_grblend(sm), sk_blend_to_grblend(dm));
//set the color of the paint to the one of the parameter
- grPaint->setColor(grColor);
+ grPaint->setColor(paintColor);
SkColorFilter* colorFilter = skPaint.getColorFilter();
if (NULL != colorFilter) {
SkColor filtered = colorFilter->filterColor(skPaint.getColor());
grPaint->setColor(SkColor2GrColor(filtered));
} else {
- SkAutoTUnref<GrEffectRef> effect(colorFilter->asNewEffect(context));
+ SkAutoTUnref<GrEffect> effect(colorFilter->asNewEffect(context));
if (NULL != effect.get()) {
grPaint->addColorEffect(effect);
}
target->config() == kBGRA_8888_GrPixelConfig) {
// The dither flag is set and the target is likely
// not going to be dithered by the GPU.
- SkAutoTUnref<GrEffectRef> effect(GrDitherEffect::Create());
+ SkAutoTUnref<GrEffect> effect(GrDitherEffect::Create());
if (NULL != effect.get()) {
grPaint->addColorEffect(effect);
grPaint->setDither(false);
return;
}
- // SkShader::asNewEffect() may do offscreen rendering. Save off the current RT, clip, and
- // matrix. We don't reset the matrix on the context because SkShader::asNewEffect may use
- // GrContext::getMatrix() to know the transformation from local coords to device space.
- GrColor grColor = SkColor2GrColor(skPaint.getColor());
+ GrColor paintColor = SkColor2GrColor(skPaint.getColor());
// Start a new block here in order to preserve our context state after calling
// asNewEffect(). Since these calls get passed back to the client, we don't really
// want them messing around with the context.
{
+ // SkShader::asNewEffect() may do offscreen rendering. Save off the current RT, clip, and
+ // matrix. We don't reset the matrix on the context because SkShader::asNewEffect may use
+ // GrContext::getMatrix() to know the transformation from local coords to device space.
GrContext::AutoRenderTarget art(context, NULL);
GrContext::AutoClip ac(context, GrContext::AutoClip::kWideOpen_InitialClip);
AutoMatrix am(context);
- // setup the shader as the first color effect on the paint
- // the default grColor is the paint's color
- GrEffectRef* grEffect = NULL;
- if (shader->asNewEffect(context, skPaint, NULL, &grColor, &grEffect) && NULL != grEffect) {
- SkAutoTUnref<GrEffectRef> effect(grEffect);
- grPaint->addColorEffect(effect);
+ // Allow the shader to modify paintColor and also create an effect to be installed as
+ // the first color effect on the GrPaint.
+ GrEffect* effect = NULL;
+ if (shader->asNewEffect(context, skPaint, NULL, &paintColor, &effect) && NULL != effect) {
+ grPaint->addColorEffect(effect)->unref();
constantColor = false;
}
}
// The grcolor is automatically set when calling asneweffect.
// If the shader can be seen as an effect it returns true and adds its effect to the grpaint.
- SkPaint2GrPaintNoShader(context, skPaint, grColor, constantColor, grPaint);
+ SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint);
}
GR_DEFINE_EFFECT_TEST(GrConicEffect);
-GrEffectRef* GrConicEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps& caps,
- GrTexture*[]) {
- GrEffectRef* effect;
+GrEffect* GrConicEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps& caps,
+ GrTexture*[]) {
+ GrEffect* effect;
do {
GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>(
random->nextULessThan(kGrEffectEdgeTypeCnt));
GR_DEFINE_EFFECT_TEST(GrQuadEffect);
-GrEffectRef* GrQuadEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps& caps,
- GrTexture*[]) {
- GrEffectRef* effect;
+GrEffect* GrQuadEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps& caps,
+ GrTexture*[]) {
+ GrEffect* effect;
do {
GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>(
random->nextULessThan(kGrEffectEdgeTypeCnt));
GR_DEFINE_EFFECT_TEST(GrCubicEffect);
-GrEffectRef* GrCubicEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps& caps,
- GrTexture*[]) {
- GrEffectRef* effect;
+GrEffect* GrCubicEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps& caps,
+ GrTexture*[]) {
+ GrEffect* effect;
do {
GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>(
random->nextULessThan(kGrEffectEdgeTypeCnt));
class GrConicEffect : public GrVertexEffect {
public:
- static GrEffectRef* Create(const GrEffectEdgeType edgeType, const GrDrawTargetCaps& caps) {
+ static GrEffect* Create(const GrEffectEdgeType edgeType, const GrDrawTargetCaps& caps) {
GR_CREATE_STATIC_EFFECT(gConicFillAA, GrConicEffect, (kFillAA_GrEffectEdgeType));
GR_CREATE_STATIC_EFFECT(gConicHairAA, GrConicEffect, (kHairlineAA_GrEffectEdgeType));
GR_CREATE_STATIC_EFFECT(gConicFillBW, GrConicEffect, (kFillBW_GrEffectEdgeType));
class GrQuadEffect : public GrVertexEffect {
public:
- static GrEffectRef* Create(const GrEffectEdgeType edgeType, const GrDrawTargetCaps& caps) {
+ static GrEffect* Create(const GrEffectEdgeType edgeType, const GrDrawTargetCaps& caps) {
GR_CREATE_STATIC_EFFECT(gQuadFillAA, GrQuadEffect, (kFillAA_GrEffectEdgeType));
GR_CREATE_STATIC_EFFECT(gQuadHairAA, GrQuadEffect, (kHairlineAA_GrEffectEdgeType));
GR_CREATE_STATIC_EFFECT(gQuadFillBW, GrQuadEffect, (kFillBW_GrEffectEdgeType));
class GrCubicEffect : public GrVertexEffect {
public:
- static GrEffectRef* Create(const GrEffectEdgeType edgeType, const GrDrawTargetCaps& caps) {
+ static GrEffect* Create(const GrEffectEdgeType edgeType, const GrDrawTargetCaps& caps) {
GR_CREATE_STATIC_EFFECT(gCubicFillAA, GrCubicEffect, (kFillAA_GrEffectEdgeType));
GR_CREATE_STATIC_EFFECT(gCubicHairAA, GrCubicEffect, (kHairlineAA_GrEffectEdgeType));
GR_CREATE_STATIC_EFFECT(gCubicFillBW, GrCubicEffect, (kFillBW_GrEffectEdgeType));
GR_DEFINE_EFFECT_TEST(GrBicubicEffect);
-GrEffectRef* GrBicubicEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
+GrEffect* GrBicubicEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
GrEffectUnitTest::kAlphaTextureIdx;
SkScalar coefficients[16];
/**
* Create a simple filter effect with custom bicubic coefficients and optional domain.
*/
- static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16],
- const SkRect* domain = NULL) {
+ static GrEffect* Create(GrTexture* tex, const SkScalar coefficients[16],
+ const SkRect* domain = NULL) {
if (NULL == domain) {
static const SkShader::TileMode kTileModes[] = { SkShader::kClamp_TileMode,
SkShader::kClamp_TileMode };
/**
* Create a Mitchell filter effect with specified texture matrix and x/y tile modes.
*/
- static GrEffectRef* Create(GrTexture* tex, const SkMatrix& matrix,
- SkShader::TileMode tileModes[2]) {
+ static GrEffect* Create(GrTexture* tex, const SkMatrix& matrix,
+ SkShader::TileMode tileModes[2]) {
return Create(tex, gMitchellCoefficients, matrix, tileModes);
}
* Create a filter effect with custom bicubic coefficients, the texture matrix, and the x/y
* tilemodes.
*/
- static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16],
- const SkMatrix& matrix, const SkShader::TileMode tileModes[2]) {
+ static GrEffect* Create(GrTexture* tex, const SkScalar coefficients[16],
+ const SkMatrix& matrix, const SkShader::TileMode tileModes[2]) {
return SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, matrix, tileModes));
}
/**
* Create a Mitchell filter effect with a texture matrix and a domain.
*/
- static GrEffectRef* Create(GrTexture* tex, const SkMatrix& matrix, const SkRect& domain) {
+ static GrEffect* Create(GrTexture* tex, const SkMatrix& matrix, const SkRect& domain) {
return SkNEW_ARGS(GrBicubicEffect, (tex, gMitchellCoefficients, matrix, domain));
}
GR_DEFINE_EFFECT_TEST(GrConfigConversionEffect);
-GrEffectRef* GrConfigConversionEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
+GrEffect* GrConfigConversionEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
PMConversion pmConv = static_cast<PMConversion>(random->nextULessThan(kPMConversionCnt));
bool swapRB;
if (kNone_PMConversion == pmConv) {
}
}
-const GrEffectRef* GrConfigConversionEffect::Create(GrTexture* texture,
- bool swapRedAndBlue,
- PMConversion pmConversion,
- const SkMatrix& matrix) {
+const GrEffect* GrConfigConversionEffect::Create(GrTexture* texture,
+ bool swapRedAndBlue,
+ PMConversion pmConversion,
+ const SkMatrix& matrix) {
if (!swapRedAndBlue && kNone_PMConversion == pmConversion) {
// If we returned a GrConfigConversionEffect that was equivalent to a GrSimpleTextureEffect
// then we may pollute our texture cache with redundant shaders. So in the case that no
};
// Installs an effect in the GrEffectStage to perform a config conversion.
- static const GrEffectRef* Create(GrTexture*,
- bool swapRedAndBlue,
- PMConversion pmConversion,
- const SkMatrix& matrix);
+ static const GrEffect* Create(GrTexture*,
+ bool swapRedAndBlue,
+ PMConversion pmConversion,
+ const SkMatrix& matrix);
static const char* Name() { return "Config Conversion"; }
typedef GrGLConfigConversionEffect GLEffect;
static const char* Name() { return "AARect"; }
- static GrEffectRef* Create(GrEffectEdgeType edgeType, const SkRect& rect) {
+ static GrEffect* Create(GrEffectEdgeType edgeType, const SkRect& rect) {
return SkNEW_ARGS(AARectEffect, (edgeType, rect));
}
GR_DEFINE_EFFECT_TEST(AARectEffect);
-GrEffectRef* AARectEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps& caps,
- GrTexture*[]) {
+GrEffect* AARectEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps& caps,
+ GrTexture*[]) {
SkRect rect = SkRect::MakeLTRB(random->nextSScalar1(),
random->nextSScalar1(),
random->nextSScalar1(),
random->nextSScalar1());
- GrEffectRef* effect;
+ GrEffect* effect;
do {
GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>(random->nextULessThan(
kGrEffectEdgeTypeCnt));
//////////////////////////////////////////////////////////////////////////////
-GrEffectRef* GrConvexPolyEffect::Create(GrEffectEdgeType type, const SkPath& path, const SkVector* offset) {
+GrEffect* GrConvexPolyEffect::Create(GrEffectEdgeType type, const SkPath& path,
+ const SkVector* offset) {
if (kHairlineAA_GrEffectEdgeType == type) {
return NULL;
}
return Create(type, n, edges);
}
-GrEffectRef* GrConvexPolyEffect::Create(GrEffectEdgeType edgeType, const SkRect& rect) {
+GrEffect* GrConvexPolyEffect::Create(GrEffectEdgeType edgeType, const SkRect& rect) {
if (kHairlineAA_GrEffectEdgeType == edgeType){
return NULL;
}
GR_DEFINE_EFFECT_TEST(GrConvexPolyEffect);
-GrEffectRef* GrConvexPolyEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps& caps,
- GrTexture*[]) {
+GrEffect* GrConvexPolyEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps& caps,
+ GrTexture*[]) {
int count = random->nextULessThan(kMaxEdges) + 1;
SkScalar edges[kMaxEdges * 3];
for (int i = 0; i < 3 * count; ++i) {
edges[i] = random->nextSScalar1();
}
- GrEffectRef* effect;
+ GrEffect* effect;
do {
GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>(
random->nextULessThan(kGrEffectEdgeTypeCnt));
* have to modify the effect/shaderbuilder interface to make it possible (e.g. give access
* to the view matrix or untransformed positions in the fragment shader).
*/
- static GrEffectRef* Create(GrEffectEdgeType edgeType, int n, const SkScalar edges[]) {
+ static GrEffect* Create(GrEffectEdgeType edgeType, int n, const SkScalar edges[]) {
if (n <= 0 || n > kMaxEdges || kHairlineAA_GrEffectEdgeType == edgeType) {
return NULL;
}
* inverse filled, or has too many edges, this will return NULL. If offset is non-NULL, then
* the path is translated by the vector.
*/
- static GrEffectRef* Create(GrEffectEdgeType, const SkPath&, const SkVector* offset = NULL);
+ static GrEffect* Create(GrEffectEdgeType, const SkPath&, const SkVector* offset = NULL);
/**
* Creates an effect that fills inside the rect with AA edges..
*/
- static GrEffectRef* Create(GrEffectEdgeType, const SkRect&);
+ static GrEffect* Create(GrEffectEdgeType, const SkRect&);
virtual ~GrConvexPolyEffect();
GR_DEFINE_EFFECT_TEST(GrConvolutionEffect);
-GrEffectRef* GrConvolutionEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
+GrEffect* GrConvolutionEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
GrEffectUnitTest::kAlphaTextureIdx;
Direction dir = random->nextBool() ? kX_Direction : kY_Direction;
public:
/// Convolve with an arbitrary user-specified kernel
- static GrEffectRef* Create(GrTexture* tex,
- Direction dir,
- int halfWidth,
- const float* kernel,
- bool useBounds,
- float bounds[2]) {
+ static GrEffect* Create(GrTexture* tex,
+ Direction dir,
+ int halfWidth,
+ const float* kernel,
+ bool useBounds,
+ float bounds[2]) {
return SkNEW_ARGS(GrConvolutionEffect, (tex,
dir,
halfWidth,
}
/// Convolve with a Gaussian kernel
- static GrEffectRef* CreateGaussian(GrTexture* tex,
- Direction dir,
- int halfWidth,
- float gaussianSigma,
- bool useBounds,
- float bounds[2]) {
+ static GrEffect* CreateGaussian(GrTexture* tex,
+ Direction dir,
+ int halfWidth,
+ float gaussianSigma,
+ bool useBounds,
+ float bounds[2]) {
return SkNEW_ARGS(GrConvolutionEffect, (tex,
dir,
halfWidth,
GR_DEFINE_EFFECT_TEST(GrCustomCoordsTextureEffect);
-GrEffectRef* GrCustomCoordsTextureEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
+GrEffect* GrCustomCoordsTextureEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
GrEffectUnitTest::kAlphaTextureIdx;
static const SkShader::TileMode kTileModes[] = {
*/
class GrCustomCoordsTextureEffect : public GrVertexEffect {
public:
- static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& p) {
+ static GrEffect* Create(GrTexture* tex, const GrTextureParams& p) {
return SkNEW_ARGS(GrCustomCoordsTextureEffect, (tex, p));
}
public:
typedef SkPathEffect::DashInfo DashInfo;
- static GrEffectRef* Create(GrEffectEdgeType edgeType, const DashInfo& info,
- SkScalar radius);
+ static GrEffect* Create(GrEffectEdgeType edgeType, const DashInfo& info, SkScalar radius);
virtual ~DashingCircleEffect();
//////////////////////////////////////////////////////////////////////////////
-GrEffectRef* DashingCircleEffect::Create(GrEffectEdgeType edgeType, const DashInfo& info,
- SkScalar radius) {
+GrEffect* DashingCircleEffect::Create(GrEffectEdgeType edgeType, const DashInfo& info,
+ SkScalar radius) {
if (info.fCount != 2 || info.fIntervals[0] != 0) {
return NULL;
}
GR_DEFINE_EFFECT_TEST(DashingCircleEffect);
-GrEffectRef* DashingCircleEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps& caps,
- GrTexture*[]) {
- GrEffectRef* effect;
+GrEffect* DashingCircleEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps& caps,
+ GrTexture*[]) {
+ GrEffect* effect;
GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>(random->nextULessThan(
kGrEffectEdgeTypeCnt));
SkScalar strokeWidth = random->nextRangeScalar(0, 100.f);
public:
typedef SkPathEffect::DashInfo DashInfo;
- static GrEffectRef* Create(GrEffectEdgeType edgeType, const DashInfo& info,
- SkScalar strokeWidth);
+ static GrEffect* Create(GrEffectEdgeType edgeType, const DashInfo& info, SkScalar strokeWidth);
virtual ~DashingLineEffect();
//////////////////////////////////////////////////////////////////////////////
-GrEffectRef* DashingLineEffect::Create(GrEffectEdgeType edgeType, const DashInfo& info,
- SkScalar strokeWidth) {
+GrEffect* DashingLineEffect::Create(GrEffectEdgeType edgeType, const DashInfo& info,
+ SkScalar strokeWidth) {
if (info.fCount != 2) {
return NULL;
}
GR_DEFINE_EFFECT_TEST(DashingLineEffect);
-GrEffectRef* DashingLineEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps& caps,
- GrTexture*[]) {
- GrEffectRef* effect;
+GrEffect* DashingLineEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps& caps,
+ GrTexture*[]) {
+ GrEffect* effect;
GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>(random->nextULessThan(
kGrEffectEdgeTypeCnt));
SkScalar strokeWidth = random->nextRangeScalar(0, 100.f);
//////////////////////////////////////////////////////////////////////////////
-GrEffectRef* GrDashingEffect::Create(GrEffectEdgeType edgeType, const SkPathEffect::DashInfo& info,
- SkScalar strokeWidth, GrDashingEffect::DashCap cap) {
+GrEffect* GrDashingEffect::Create(GrEffectEdgeType edgeType, const SkPathEffect::DashInfo& info,
+ SkScalar strokeWidth, GrDashingEffect::DashCap cap) {
switch (cap) {
case GrDashingEffect::kRound_DashCap:
return DashingCircleEffect::Create(edgeType, info, SkScalarHalf(strokeWidth));
GR_DEFINE_EFFECT_TEST(GrDistanceFieldTextureEffect);
-GrEffectRef* GrDistanceFieldTextureEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
+GrEffect* GrDistanceFieldTextureEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
GrEffectUnitTest::kAlphaTextureIdx;
#ifdef SK_GAMMA_APPLY_TO_A8
GR_DEFINE_EFFECT_TEST(GrDistanceFieldLCDTextureEffect);
-GrEffectRef* GrDistanceFieldLCDTextureEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
+GrEffect* GrDistanceFieldLCDTextureEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
GrEffectUnitTest::kAlphaTextureIdx;
int texIdx2 = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
class GrDistanceFieldTextureEffect : public GrVertexEffect {
public:
#ifdef SK_GAMMA_APPLY_TO_A8
- static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& params,
- GrTexture* gamma, const GrTextureParams& gammaParams, float lum,
- bool similarity) {
+ static GrEffect* Create(GrTexture* tex, const GrTextureParams& params,
+ GrTexture* gamma, const GrTextureParams& gammaParams, float lum,
+ bool similarity) {
return SkNEW_ARGS(GrDistanceFieldTextureEffect, (tex, params, gamma, gammaParams, lum,
similarity));
}
#else
- static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& params,
- bool similarity) {
+ static GrEffect* Create(GrTexture* tex, const GrTextureParams& params,
+ bool similarity) {
return SkNEW_ARGS(GrDistanceFieldTextureEffect, (tex, params, similarity));
}
#endif
*/
class GrDistanceFieldLCDTextureEffect : public GrVertexEffect {
public:
- static GrEffectRef* Create(GrTexture* tex, const GrTextureParams& params,
- GrTexture* gamma, const GrTextureParams& gammaParams,
- SkColor textColor,
- bool uniformScale, bool useBGR) {
+ static GrEffect* Create(GrTexture* tex, const GrTextureParams& params,
+ GrTexture* gamma, const GrTextureParams& gammaParams,
+ SkColor textColor, bool uniformScale, bool useBGR) {
return SkNEW_ARGS(GrDistanceFieldLCDTextureEffect,
(tex, params, gamma, gammaParams, textColor, uniformScale, useBGR));
}
class DitherEffect : public GrEffect {
public:
- static GrEffectRef* Create() {
+ static GrEffect* Create() {
GR_CREATE_STATIC_EFFECT(gDitherEffect, DitherEffect, ())
return SkRef(gDitherEffect);
}
GR_DEFINE_EFFECT_TEST(DitherEffect);
-GrEffectRef* DitherEffect::TestCreate(SkRandom*,
- GrContext*,
- const GrDrawTargetCaps&,
- GrTexture*[]) {
+GrEffect* DitherEffect::TestCreate(SkRandom*,
+ GrContext*,
+ const GrDrawTargetCaps&,
+ GrTexture*[]) {
return DitherEffect::Create();
}
//////////////////////////////////////////////////////////////////////////////
-GrEffectRef* GrDitherEffect::Create() {
- return DitherEffect::Create();
-}
+GrEffect* GrDitherEffect::Create() { return DitherEffect::Create(); }
class CircleEffect : public GrEffect {
public:
- static GrEffectRef* Create(GrEffectEdgeType, const SkPoint& center, SkScalar radius);
+ static GrEffect* Create(GrEffectEdgeType, const SkPoint& center, SkScalar radius);
virtual ~CircleEffect() {};
static const char* Name() { return "Circle"; }
typedef GrEffect INHERITED;
};
-GrEffectRef* CircleEffect::Create(GrEffectEdgeType edgeType,
- const SkPoint& center,
- SkScalar radius) {
+GrEffect* CircleEffect::Create(GrEffectEdgeType edgeType, const SkPoint& center, SkScalar radius) {
SkASSERT(radius >= 0);
return SkNEW_ARGS(CircleEffect, (edgeType, center, radius));
}
GR_DEFINE_EFFECT_TEST(CircleEffect);
-GrEffectRef* CircleEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps& caps,
- GrTexture*[]) {
+GrEffect* CircleEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps& caps,
+ GrTexture*[]) {
SkPoint center;
center.fX = random->nextRangeScalar(0.f, 1000.f);
center.fY = random->nextRangeScalar(0.f, 1000.f);
class EllipseEffect : public GrEffect {
public:
- static GrEffectRef* Create(GrEffectEdgeType, const SkPoint& center, SkScalar rx, SkScalar ry);
+ static GrEffect* Create(GrEffectEdgeType, const SkPoint& center, SkScalar rx, SkScalar ry);
virtual ~EllipseEffect() {};
static const char* Name() { return "Ellipse"; }
typedef GrEffect INHERITED;
};
-GrEffectRef* EllipseEffect::Create(GrEffectEdgeType edgeType,
- const SkPoint& center,
- SkScalar rx,
- SkScalar ry) {
+GrEffect* EllipseEffect::Create(GrEffectEdgeType edgeType,
+ const SkPoint& center,
+ SkScalar rx,
+ SkScalar ry) {
SkASSERT(rx >= 0 && ry >= 0);
return SkNEW_ARGS(EllipseEffect, (edgeType, center, rx, ry));
}
GR_DEFINE_EFFECT_TEST(EllipseEffect);
-GrEffectRef* EllipseEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps& caps,
- GrTexture*[]) {
+GrEffect* EllipseEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps& caps,
+ GrTexture*[]) {
SkPoint center;
center.fX = random->nextRangeScalar(0.f, 1000.f);
center.fY = random->nextRangeScalar(0.f, 1000.f);
//////////////////////////////////////////////////////////////////////////////
-GrEffectRef* GrOvalEffect::Create(GrEffectEdgeType edgeType, const SkRect& oval) {
+GrEffect* GrOvalEffect::Create(GrEffectEdgeType edgeType, const SkRect& oval) {
if (kHairlineAA_GrEffectEdgeType == edgeType) {
return NULL;
}
// The flags are used to indicate which corners are circluar (unflagged corners are assumed to
// be square).
- static GrEffectRef* Create(GrEffectEdgeType, uint32_t circularCornerFlags, const SkRRect&);
+ static GrEffect* Create(GrEffectEdgeType, uint32_t circularCornerFlags, const SkRRect&);
virtual ~CircularRRectEffect() {};
static const char* Name() { return "CircularRRect"; }
typedef GrEffect INHERITED;
};
-GrEffectRef* CircularRRectEffect::Create(GrEffectEdgeType edgeType,
- uint32_t circularCornerFlags,
- const SkRRect& rrect) {
+GrEffect* CircularRRectEffect::Create(GrEffectEdgeType edgeType,
+ uint32_t circularCornerFlags,
+ const SkRRect& rrect) {
if (kFillAA_GrEffectEdgeType != edgeType && kInverseFillAA_GrEffectEdgeType != edgeType) {
return NULL;
}
GR_DEFINE_EFFECT_TEST(CircularRRectEffect);
-GrEffectRef* CircularRRectEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps& caps,
- GrTexture*[]) {
+GrEffect* CircularRRectEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps& caps,
+ GrTexture*[]) {
SkScalar w = random->nextRangeScalar(20.f, 1000.f);
SkScalar h = random->nextRangeScalar(20.f, 1000.f);
SkScalar r = random->nextRangeF(kRadiusMin, 9.f);
SkRRect rrect;
rrect.setRectXY(SkRect::MakeWH(w, h), r, r);
- GrEffectRef* effect;
+ GrEffect* effect;
do {
GrEffectEdgeType et = (GrEffectEdgeType)random->nextULessThan(kGrEffectEdgeTypeCnt);
effect = GrRRectEffect::Create(et, rrect);
class EllipticalRRectEffect : public GrEffect {
public:
- static GrEffectRef* Create(GrEffectEdgeType, const SkRRect&);
+ static GrEffect* Create(GrEffectEdgeType, const SkRRect&);
virtual ~EllipticalRRectEffect() {};
static const char* Name() { return "EllipticalRRect"; }
typedef GrEffect INHERITED;
};
-GrEffectRef* EllipticalRRectEffect::Create(GrEffectEdgeType edgeType, const SkRRect& rrect) {
+GrEffect* EllipticalRRectEffect::Create(GrEffectEdgeType edgeType, const SkRRect& rrect) {
if (kFillAA_GrEffectEdgeType != edgeType && kInverseFillAA_GrEffectEdgeType != edgeType) {
return NULL;
}
GR_DEFINE_EFFECT_TEST(EllipticalRRectEffect);
-GrEffectRef* EllipticalRRectEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps& caps,
- GrTexture*[]) {
+GrEffect* EllipticalRRectEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps& caps,
+ GrTexture*[]) {
SkScalar w = random->nextRangeScalar(20.f, 1000.f);
SkScalar h = random->nextRangeScalar(20.f, 1000.f);
SkVector r[4];
rrect.setRectXY(SkRect::MakeWH(w, h), r[SkRRect::kUpperLeft_Corner].fX,
r[SkRRect::kUpperLeft_Corner].fY);
}
- GrEffectRef* effect;
+ GrEffect* effect;
do {
GrEffectEdgeType et = (GrEffectEdgeType)random->nextULessThan(kGrEffectEdgeTypeCnt);
effect = GrRRectEffect::Create(et, rrect);
//////////////////////////////////////////////////////////////////////////////
-GrEffectRef* GrRRectEffect::Create(GrEffectEdgeType edgeType, const SkRRect& rrect) {
+GrEffect* GrRRectEffect::Create(GrEffectEdgeType edgeType, const SkRRect& rrect) {
if (rrect.isRect()) {
return GrConvexPolyEffect::Create(edgeType, rrect.getBounds());
}
GR_DEFINE_EFFECT_TEST(GrSimpleTextureEffect);
-GrEffectRef* GrSimpleTextureEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
+GrEffect* GrSimpleTextureEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
GrEffectUnitTest::kAlphaTextureIdx;
static const SkShader::TileMode kTileModes[] = {
class GrSimpleTextureEffect : public GrSingleTextureEffect {
public:
/* unfiltered, clamp mode */
- static GrEffectRef* Create(GrTexture* tex,
- const SkMatrix& matrix,
- GrCoordSet coordSet = kLocal_GrCoordSet) {
+ static GrEffect* Create(GrTexture* tex,
+ const SkMatrix& matrix,
+ GrCoordSet coordSet = kLocal_GrCoordSet) {
return SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, GrTextureParams::kNone_FilterMode,
coordSet));
}
/* clamp mode */
- static GrEffectRef* Create(GrTexture* tex,
- const SkMatrix& matrix,
- GrTextureParams::FilterMode filterMode,
- GrCoordSet coordSet = kLocal_GrCoordSet) {
+ static GrEffect* Create(GrTexture* tex,
+ const SkMatrix& matrix,
+ GrTextureParams::FilterMode filterMode,
+ GrCoordSet coordSet = kLocal_GrCoordSet) {
return SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, filterMode, coordSet));
}
- static GrEffectRef* Create(GrTexture* tex,
- const SkMatrix& matrix,
- const GrTextureParams& p,
- GrCoordSet coordSet = kLocal_GrCoordSet) {
+ static GrEffect* Create(GrTexture* tex,
+ const SkMatrix& matrix,
+ const GrTextureParams& p,
+ GrCoordSet coordSet = kLocal_GrCoordSet) {
return SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, p, coordSet));
}
///////////////////////////////////////////////////////////////////////////////
-GrEffectRef* GrTextureDomainEffect::Create(GrTexture* texture,
+GrEffect* GrTextureDomainEffect::Create(GrTexture* texture,
const SkMatrix& matrix,
const SkRect& domain,
GrTextureDomain::Mode mode,
GR_DEFINE_EFFECT_TEST(GrTextureDomainEffect);
-GrEffectRef* GrTextureDomainEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
+GrEffect* GrTextureDomainEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
GrEffectUnitTest::kAlphaTextureIdx;
SkRect domain;
class GrTextureDomainEffect : public GrSingleTextureEffect {
public:
- static GrEffectRef* Create(GrTexture*,
- const SkMatrix&,
- const SkRect& domain,
- GrTextureDomain::Mode,
- GrTextureParams::FilterMode filterMode,
- GrCoordSet = kLocal_GrCoordSet);
+ static GrEffect* Create(GrTexture*,
+ const SkMatrix&,
+ const SkRect& domain,
+ GrTextureDomain::Mode,
+ GrTextureParams::FilterMode filterMode,
+ GrCoordSet = kLocal_GrCoordSet);
virtual ~GrTextureDomainEffect();
//////////////////////////////////////////////////////////////////////////////
-GrEffectRef* GrYUVtoRGBEffect::Create(GrTexture* yTexture,
- GrTexture* uTexture,
- GrTexture* vTexture) {
+GrEffect* GrYUVtoRGBEffect::Create(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture) {
return YUVtoRGBEffect::Create(yTexture, uTexture, vTexture);
}
bool useFixedFunctionTexturing = this->shouldUseFixedFunctionTexturing();
for (int s = 0; s < numStages;) {
- SkAutoTUnref<const GrEffectRef> effect(GrEffectTestFactory::CreateStage(
+ SkAutoTUnref<const GrEffect> effect(GrEffectTestFactory::CreateStage(
&random,
this->getContext(),
*this->caps(),
for (size_t i = 0; i < SK_ARRAY_COUNT(filterTests); ++i) {
const GetConstantComponentTestCase& test = filterTests[i];
SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(test.filterColor, test.filterMode));
- SkAutoTUnref<GrEffectRef> grEffect(cf->asNewEffect(grContext));
+ SkAutoTUnref<GrEffect> effect(cf->asNewEffect(grContext));
GrColor color = test.inputColor;
uint32_t components = test.inputComponents;
- grEffect->getConstantColorComponents(&color, &components);
+ effect->getConstantColorComponents(&color, &components);
REPORTER_ASSERT(reporter, filterColor(color, components) == test.outputColor);
REPORTER_ASSERT(reporter, test.outputComponents == components);