aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-01-14 16:46:26 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-01-14 16:46:26 +0000
commite197cbf9a3e66bab926bc5e51962752dad5221a0 (patch)
tree75b9abe7a8dd3acdaa261a1e1a2740e54d1574af /src/effects
parentff06af20fde68aa737b540dc6e42924532873b22 (diff)
Change signature of SkShader::asNewEffect(), implement for SkBitmapProcShader.
Review URL: https://codereview.appspot.com/7086051 git-svn-id: http://skia.googlecode.com/svn/trunk@7153 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/effects')
-rw-r--r--src/effects/gradients/SkLinearGradient.cpp17
-rw-r--r--src/effects/gradients/SkLinearGradient.h2
-rw-r--r--src/effects/gradients/SkRadialGradient.cpp17
-rw-r--r--src/effects/gradients/SkRadialGradient.h2
-rw-r--r--src/effects/gradients/SkSweepGradient.cpp17
-rw-r--r--src/effects/gradients/SkSweepGradient.h2
-rw-r--r--src/effects/gradients/SkTwoPointConicalGradient.cpp19
-rw-r--r--src/effects/gradients/SkTwoPointConicalGradient.h2
-rw-r--r--src/effects/gradients/SkTwoPointRadialGradient.cpp20
-rw-r--r--src/effects/gradients/SkTwoPointRadialGradient.h2
10 files changed, 36 insertions, 64 deletions
diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp
index 2e80351cb6..1c95f29bfe 100644
--- a/src/effects/gradients/SkLinearGradient.cpp
+++ b/src/effects/gradients/SkLinearGradient.cpp
@@ -522,12 +522,8 @@ GrEffect* GrLinearGradient::TestCreate(SkRandom* random,
SkAutoTUnref<SkShader> shader(SkGradientShader::CreateLinear(points,
colors, stops, colorCount,
tm));
- GrEffectStage stage;
- shader->asNewEffect(context, &stage);
- GrAssert(NULL != stage.getEffect());
- // const_cast and ref is a hack! Will remove when asNewEffect returns GrEffect*
- stage.getEffect()->ref();
- return const_cast<GrEffect*>(stage.getEffect());
+ SkPaint paint;
+ return shader->asNewEffect(context, paint);
}
/////////////////////////////////////////////////////////////////////
@@ -550,22 +546,21 @@ void GrGLLinearGradient::emitCode(GrGLShaderBuilder* builder,
/////////////////////////////////////////////////////////////////////
-bool SkLinearGradient::asNewEffect(GrContext* context, GrEffectStage* stage) const {
+GrEffect* SkLinearGradient::asNewEffect(GrContext* context, const SkPaint&) const {
SkASSERT(NULL != context && NULL != stage);
SkMatrix matrix;
if (!this->getLocalMatrix().invert(&matrix)) {
return false;
}
matrix.postConcat(fPtsToUnit);
- stage->setEffect(SkNEW_ARGS(GrLinearGradient, (context, *this, matrix, fTileMode)))->unref();
- return true;
+ return SkNEW_ARGS(GrLinearGradient, (context, *this, matrix, fTileMode));
}
#else
-bool SkLinearGradient::asNewEffect(GrContext*, GrEffectStage*) const {
+GrEffect* SkLinearGradient::asNewEffect(GrContext* context, const SkPaint&) const {
SkDEBUGFAIL("Should not call in GPU-less build");
- return false;
+ return NULL;
}
#endif
diff --git a/src/effects/gradients/SkLinearGradient.h b/src/effects/gradients/SkLinearGradient.h
index 7d879266b1..29777c13ed 100644
--- a/src/effects/gradients/SkLinearGradient.h
+++ b/src/effects/gradients/SkLinearGradient.h
@@ -22,7 +22,7 @@ public:
virtual void shadeSpan16(int x, int y, uint16_t dstC[], int count) SK_OVERRIDE;
virtual BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*) const SK_OVERRIDE;
virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
- virtual bool asNewEffect(GrContext* context, GrEffectStage* stage) const SK_OVERRIDE;
+ virtual GrEffect* asNewEffect(GrContext* context, const SkPaint&) const SK_OVERRIDE;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLinearGradient)
diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp
index 02a56da588..db089f69f7 100644
--- a/src/effects/gradients/SkRadialGradient.cpp
+++ b/src/effects/gradients/SkRadialGradient.cpp
@@ -545,12 +545,8 @@ GrEffect* GrRadialGradient::TestCreate(SkRandom* random,
SkAutoTUnref<SkShader> shader(SkGradientShader::CreateRadial(center, radius,
colors, stops, colorCount,
tm));
- GrEffectStage stage;
- shader->asNewEffect(context, &stage);
- GrAssert(NULL != stage.getEffect());
- // const_cast and ref is a hack! Will remove when asNewEffect returns GrEffect*
- stage.getEffect()->ref();
- return const_cast<GrEffect*>(stage.getEffect());
+ SkPaint paint;
+ return shader->asNewEffect(context, paint);
}
/////////////////////////////////////////////////////////////////////
@@ -573,7 +569,7 @@ void GrGLRadialGradient::emitCode(GrGLShaderBuilder* builder,
/////////////////////////////////////////////////////////////////////
-bool SkRadialGradient::asNewEffect(GrContext* context, GrEffectStage* stage) const {
+GrEffect* SkRadialGradient::asNewEffect(GrContext* context, const SkPaint&) const {
SkASSERT(NULL != context && NULL != stage);
SkMatrix matrix;
@@ -581,15 +577,14 @@ bool SkRadialGradient::asNewEffect(GrContext* context, GrEffectStage* stage) con
return false;
}
matrix.postConcat(fPtsToUnit);
- stage->setEffect(SkNEW_ARGS(GrRadialGradient, (context, *this, matrix, fTileMode)))->unref();
- return true;
+ return SkNEW_ARGS(GrRadialGradient, (context, *this, matrix, fTileMode));
}
#else
-bool SkRadialGradient::asNewEffect(GrContext*, GrEffectStage*) const {
+GrEffect* SkRadialGradient::asNewEffect(GrContext* context, const SkPaint&) const {
SkDEBUGFAIL("Should not call in GPU-less build");
- return false;
+ return NULL;
}
#endif
diff --git a/src/effects/gradients/SkRadialGradient.h b/src/effects/gradients/SkRadialGradient.h
index cf0d43d3b9..9730df4f4d 100644
--- a/src/effects/gradients/SkRadialGradient.h
+++ b/src/effects/gradients/SkRadialGradient.h
@@ -24,7 +24,7 @@ public:
SkMatrix* matrix,
TileMode* xy) const SK_OVERRIDE;
virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
- virtual bool asNewEffect(GrContext* context, GrEffectStage* stage) const SK_OVERRIDE;
+ virtual GrEffect* asNewEffect(GrContext* context, const SkPaint&) const SK_OVERRIDE;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkRadialGradient)
diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp
index 589cf4ad14..918bf91a2d 100644
--- a/src/effects/gradients/SkSweepGradient.cpp
+++ b/src/effects/gradients/SkSweepGradient.cpp
@@ -449,12 +449,8 @@ GrEffect* GrSweepGradient::TestCreate(SkRandom* random,
int colorCount = RandomGradientParams(random, colors, &stops, &tmIgnored);
SkAutoTUnref<SkShader> shader(SkGradientShader::CreateSweep(center.fX, center.fY,
colors, stops, colorCount));
- GrEffectStage stage;
- shader->asNewEffect(context, &stage);
- GrAssert(NULL != stage.getEffect());
- // const_cast and ref is a hack! Will remove when asNewEffect returns GrEffect*
- stage.getEffect()->ref();
- return const_cast<GrEffect*>(stage.getEffect());
+ SkPaint paint;
+ return shader->asNewEffect(context, paint);
}
/////////////////////////////////////////////////////////////////////
@@ -476,21 +472,20 @@ void GrGLSweepGradient::emitCode(GrGLShaderBuilder* builder,
/////////////////////////////////////////////////////////////////////
-bool SkSweepGradient::asNewEffect(GrContext* context, GrEffectStage* stage) const {
+GrEffect* SkSweepGradient::asNewEffect(GrContext* context, const SkPaint&) const {
SkMatrix matrix;
if (!this->getLocalMatrix().invert(&matrix)) {
return false;
}
matrix.postConcat(fPtsToUnit);
- stage->setEffect(SkNEW_ARGS(GrSweepGradient, (context, *this, matrix)))->unref();
- return true;
+ return SkNEW_ARGS(GrSweepGradient, (context, *this, matrix));
}
#else
-bool SkSweepGradient::asNewEffect(GrContext*, GrEffectStage*) const {
+GrEffect* SkSweepGradient::asNewEffect(GrContext* context, const SkPaint&) const {
SkDEBUGFAIL("Should not call in GPU-less build");
- return false;
+ return NULL;
}
#endif
diff --git a/src/effects/gradients/SkSweepGradient.h b/src/effects/gradients/SkSweepGradient.h
index a44b4c15f1..5034b8e4c6 100644
--- a/src/effects/gradients/SkSweepGradient.h
+++ b/src/effects/gradients/SkSweepGradient.h
@@ -24,7 +24,7 @@ public:
virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
- virtual bool asNewEffect(GrContext* context, GrEffectStage* stage) const SK_OVERRIDE;
+ virtual GrEffect* asNewEffect(GrContext* context, const SkPaint&) const SK_OVERRIDE;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSweepGradient)
diff --git a/src/effects/gradients/SkTwoPointConicalGradient.cpp b/src/effects/gradients/SkTwoPointConicalGradient.cpp
index 5c06bce45c..ab420c61cb 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient.cpp
@@ -440,12 +440,8 @@ GrEffect* GrConical2Gradient::TestCreate(SkRandom* random,
center2, radius2,
colors, stops, colorCount,
tm));
- GrEffectStage stage;
- shader->asNewEffect(context, &stage);
- GrAssert(NULL != stage.getEffect());
- // const_cast and ref is a hack! Will remove when asNewEffect returns GrEffect*
- stage.getEffect()->ref();
- return const_cast<GrEffect*>(stage.getEffect());
+ SkPaint paint;
+ return shader->asNewEffect(context, paint);
}
@@ -688,8 +684,7 @@ GrGLEffect::EffectKey GrGLConical2Gradient::GenKey(const GrEffectStage& s, const
/////////////////////////////////////////////////////////////////////
-bool SkTwoPointConicalGradient::asNewEffect(GrContext* context,
- GrEffectStage* stage) const {
+GrEffect* SkTwoPointConicalGradient::asNewEffect(GrContext* context, const SkPaint&) const {
SkASSERT(NULL != context && NULL != stage);
SkASSERT(fPtsToUnit.isIdentity());
// invert the localM, translate to center1, rotate so center2 is on x axis.
@@ -709,16 +704,14 @@ bool SkTwoPointConicalGradient::asNewEffect(GrContext* context,
matrix.postConcat(rot);
}
- stage->setEffect(SkNEW_ARGS(GrConical2Gradient, (context, *this, matrix, fTileMode)))->unref();
-
- return true;
+ return SkNEW_ARGS(GrConical2Gradient, (context, *this, matrix, fTileMode));
}
#else
-bool SkTwoPointConicalGradient::asNewEffect(GrContext*, GrEffectStage*) const {
+GrEffect* SkTwoPointConicalGradient::asNewEffect(GrContext* context, const SkPaint&) const {
SkDEBUGFAIL("Should not call in GPU-less build");
- return false;
+ return NULL;
}
#endif
diff --git a/src/effects/gradients/SkTwoPointConicalGradient.h b/src/effects/gradients/SkTwoPointConicalGradient.h
index d199650414..c4ccc05d3c 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient.h
+++ b/src/effects/gradients/SkTwoPointConicalGradient.h
@@ -61,7 +61,7 @@ public:
SkMatrix* matrix,
TileMode* xy) const;
virtual SkShader::GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
- virtual bool asNewEffect(GrContext* context, GrEffectStage* stage) const SK_OVERRIDE;
+ virtual GrEffect* asNewEffect(GrContext* context, const SkPaint& paint) const SK_OVERRIDE;
SkScalar getCenterX1() const { return SkPoint::Distance(fCenter1, fCenter2); }
SkScalar getStartRadius() const { return fRadius1; }
diff --git a/src/effects/gradients/SkTwoPointRadialGradient.cpp b/src/effects/gradients/SkTwoPointRadialGradient.cpp
index 9aa923b2db..6615c4d373 100644
--- a/src/effects/gradients/SkTwoPointRadialGradient.cpp
+++ b/src/effects/gradients/SkTwoPointRadialGradient.cpp
@@ -463,7 +463,7 @@ GrEffect* GrRadial2Gradient::TestCreate(SkRandom* random,
do {
center2.set(random->nextUScalar1(), random->nextUScalar1());
radius2 = random->nextUScalar1 ();
- // There is a bug in two point radial gradients with idenitical radii
+ // There is a bug in two point radial gradients with identical radii
} while (radius1 == radius2);
SkColor colors[kMaxRandomGradientColors];
@@ -475,12 +475,8 @@ GrEffect* GrRadial2Gradient::TestCreate(SkRandom* random,
center2, radius2,
colors, stops, colorCount,
tm));
- GrEffectStage stage;
- shader->asNewEffect(context, &stage);
- GrAssert(NULL != stage.getEffect());
- // const_cast and ref is a hack! Will remove when asNewEffect returns GrEffect*
- stage.getEffect()->ref();
- return const_cast<GrEffect*>(stage.getEffect());
+ SkPaint paint;
+ return shader->asNewEffect(context, paint);
}
/////////////////////////////////////////////////////////////////////
@@ -661,8 +657,7 @@ GrGLEffect::EffectKey GrGLRadial2Gradient::GenKey(const GrEffectStage& s, const
/////////////////////////////////////////////////////////////////////
-bool SkTwoPointRadialGradient::asNewEffect(GrContext* context,
- GrEffectStage* stage) const {
+GrEffect* SkTwoPointRadialGradient::asNewEffect(GrContext* context, const SkPaint&) const {
SkASSERT(NULL != context && NULL != stage);
// invert the localM, translate to center1 (fPtsToUni), rotate so center2 is on x axis.
SkMatrix matrix;
@@ -680,15 +675,14 @@ bool SkTwoPointRadialGradient::asNewEffect(GrContext* context,
matrix.postConcat(rot);
}
- stage->setEffect(SkNEW_ARGS(GrRadial2Gradient, (context, *this, matrix, fTileMode)))->unref();
- return true;
+ return SkNEW_ARGS(GrRadial2Gradient, (context, *this, matrix, fTileMode));
}
#else
-bool SkTwoPointRadialGradient::asNewEffect(GrContext*, GrEffectStage*) const {
+GrEffect* SkTwoPointRadialGradient::asNewEffect(GrContext* context, const SkPaint&) const {
SkDEBUGFAIL("Should not call in GPU-less build");
- return false;
+ return NULL;
}
#endif
diff --git a/src/effects/gradients/SkTwoPointRadialGradient.h b/src/effects/gradients/SkTwoPointRadialGradient.h
index e7e451afe9..2f9d66d3ef 100644
--- a/src/effects/gradients/SkTwoPointRadialGradient.h
+++ b/src/effects/gradients/SkTwoPointRadialGradient.h
@@ -23,7 +23,7 @@ public:
SkMatrix* matrix,
TileMode* xy) const SK_OVERRIDE;
virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
- virtual bool asNewEffect(GrContext* context, GrEffectStage* stage) const SK_OVERRIDE;
+ virtual GrEffect* asNewEffect(GrContext* context, const SkPaint&) const SK_OVERRIDE;
virtual void shadeSpan(int x, int y, SkPMColor* dstCParam,
int count) SK_OVERRIDE;