aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects/gradients
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-10-16 14:31:26 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-10-16 14:31:26 +0000
commitf6eac8af585e44d56e6b18d269e6c34f9917ea88 (patch)
tree46332930405593186d0956fb29f093cd0afff80f /src/effects/gradients
parentb022177777c3602c47bb71c07920e63a261c5038 (diff)
Revert r5962 because of failures.
git-svn-id: http://skia.googlecode.com/svn/trunk@5963 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/effects/gradients')
-rw-r--r--src/effects/gradients/SkLinearGradient.cpp33
-rw-r--r--src/effects/gradients/SkLinearGradient.h3
-rw-r--r--src/effects/gradients/SkRadialGradient.cpp32
-rw-r--r--src/effects/gradients/SkRadialGradient.h3
-rw-r--r--src/effects/gradients/SkSweepGradient.cpp32
-rw-r--r--src/effects/gradients/SkSweepGradient.h3
-rw-r--r--src/effects/gradients/SkTwoPointConicalGradient.cpp40
-rw-r--r--src/effects/gradients/SkTwoPointConicalGradient.h3
-rw-r--r--src/effects/gradients/SkTwoPointRadialGradient.cpp39
-rw-r--r--src/effects/gradients/SkTwoPointRadialGradient.h3
10 files changed, 66 insertions, 125 deletions
diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp
index fff218010a..4b673f6691 100644
--- a/src/effects/gradients/SkLinearGradient.cpp
+++ b/src/effects/gradients/SkLinearGradient.cpp
@@ -539,11 +539,9 @@ GrCustomStage* GrLinearGradient::TestCreate(SkRandom* random,
colors, stops, colorCount,
tm));
GrSamplerState sampler;
- shader->asNewCustomStage(context, &sampler);
- GrAssert(NULL != sampler.getCustomStage());
- // const_cast and ref is a hack! Will remove when asNewCustomStage returns GrCustomStage*
- sampler.getCustomStage()->ref();
- return const_cast<GrCustomStage*>(sampler.getCustomStage());
+ GrCustomStage* stage = shader->asNewCustomStage(context, &sampler);
+ GrAssert(NULL != stage);
+ return stage;
}
/////////////////////////////////////////////////////////////////////
@@ -559,30 +557,19 @@ void GrGLLinearGradient::emitFS(GrGLShaderBuilder* builder,
/////////////////////////////////////////////////////////////////////
-bool SkLinearGradient::asNewCustomStage(GrContext* context, GrSamplerState* sampler) const {
+GrCustomStage* SkLinearGradient::asNewCustomStage(GrContext* context,
+ GrSamplerState* sampler) const {
SkASSERT(NULL != context && NULL != sampler);
-
- SkAutoTUnref<GrCustomStage> stage(SkNEW_ARGS(GrLinearGradient, (context, *this, fTileMode)));
-
- SkMatrix matrix;
- if (this->getLocalMatrix(&matrix)) {
- if (!matrix.invert(&matrix)) {
- return false;
- }
- matrix.postConcat(fPtsToUnit);
- sampler->setCustomStage(stage, matrix);
- } else {
- sampler->setCustomStage(stage, fPtsToUnit);
- }
-
- return true;
+ sampler->matrix()->preConcat(fPtsToUnit);
+ return SkNEW_ARGS(GrLinearGradient, (context, *this, fTileMode));
}
#else
-bool SkLinearGradient::asNewCustomStage(GrContext*, GrSamplerState*) const {
+GrCustomStage* SkLinearGradient::asNewCustomStage(GrContext* context,
+ GrSamplerState* sampler) 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 fe60543d52..129a56aadc 100644
--- a/src/effects/gradients/SkLinearGradient.h
+++ b/src/effects/gradients/SkLinearGradient.h
@@ -22,7 +22,8 @@ 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 asNewCustomStage(GrContext* context, GrSamplerState* sampler) const SK_OVERRIDE;
+ virtual GrCustomStage* asNewCustomStage(GrContext* context,
+ GrSamplerState* sampler) 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 0156acdd54..512eafb2ba 100644
--- a/src/effects/gradients/SkRadialGradient.cpp
+++ b/src/effects/gradients/SkRadialGradient.cpp
@@ -538,11 +538,9 @@ GrCustomStage* GrRadialGradient::TestCreate(SkRandom* random,
colors, stops, colorCount,
tm));
GrSamplerState sampler;
- shader->asNewCustomStage(context, &sampler);
- GrAssert(NULL != sampler.getCustomStage());
- // const_cast and ref is a hack! Will remove when asNewCustomStage returns GrCustomStage*
- sampler.getCustomStage()->ref();
- return const_cast<GrCustomStage*>(sampler.getCustomStage());
+ GrCustomStage* stage = shader->asNewCustomStage(context, &sampler);
+ GrAssert(NULL != stage);
+ return stage;
}
/////////////////////////////////////////////////////////////////////
@@ -558,29 +556,19 @@ void GrGLRadialGradient::emitFS(GrGLShaderBuilder* builder,
/////////////////////////////////////////////////////////////////////
-bool SkRadialGradient::asNewCustomStage(GrContext* context, GrSamplerState* sampler) const {
+GrCustomStage* SkRadialGradient::asNewCustomStage(GrContext* context,
+ GrSamplerState* sampler) const {
SkASSERT(NULL != context && NULL != sampler);
- SkAutoTUnref<GrCustomStage> stage(SkNEW_ARGS(GrRadialGradient, (context, *this, fTileMode)));
-
- SkMatrix matrix;
- if (this->getLocalMatrix(&matrix)) {
- if (!matrix.invert(&matrix)) {
- return false;
- }
- matrix.postConcat(fPtsToUnit);
- sampler->setCustomStage(stage, matrix);
- } else {
- sampler->setCustomStage(stage, fPtsToUnit);
- }
-
- return true;
+ sampler->matrix()->preConcat(fPtsToUnit);
+ return SkNEW_ARGS(GrRadialGradient, (context, *this, fTileMode));
}
#else
-bool SkRadialGradient::asNewCustomStage(GrContext*, GrSamplerState*) const {
+GrCustomStage* SkRadialGradient::asNewCustomStage(GrContext* context,
+ GrSamplerState* sampler) 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 fc17520e29..23a35f7fd2 100644
--- a/src/effects/gradients/SkRadialGradient.h
+++ b/src/effects/gradients/SkRadialGradient.h
@@ -24,7 +24,8 @@ public:
SkMatrix* matrix,
TileMode* xy) const SK_OVERRIDE;
virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
- virtual bool asNewCustomStage(GrContext* context, GrSamplerState* sampler) const SK_OVERRIDE;
+ virtual GrCustomStage* asNewCustomStage(GrContext* context,
+ GrSamplerState* sampler) 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 d8cbf9ceb6..f18b08ea9c 100644
--- a/src/effects/gradients/SkSweepGradient.cpp
+++ b/src/effects/gradients/SkSweepGradient.cpp
@@ -444,10 +444,9 @@ GrCustomStage* GrSweepGradient::TestCreate(SkRandom* random,
SkAutoTUnref<SkShader> shader(SkGradientShader::CreateSweep(center.fX, center.fY,
colors, stops, colorCount));
GrSamplerState sampler;
- shader->asNewCustomStage(context, &sampler);
- GrAssert(NULL != sampler.getCustomStage());
- // const_cast and ref is a hack! Will remove when asNewCustomStage returns GrCustomStage*
- return const_cast<GrCustomStage*>(sampler.getCustomStage());
+ GrCustomStage* stage = shader->asNewCustomStage(context, &sampler);
+ GrAssert(NULL != stage);
+ return stage;
}
/////////////////////////////////////////////////////////////////////
@@ -464,29 +463,18 @@ void GrGLSweepGradient::emitFS(GrGLShaderBuilder* builder,
/////////////////////////////////////////////////////////////////////
-bool SkSweepGradient::asNewCustomStage(GrContext* context, GrSamplerState* sampler) const {
- SkAutoTUnref<GrCustomStage> stage(SkNEW_ARGS(GrSweepGradient, (context, *this)));
-
-
- SkMatrix matrix;
- if (this->getLocalMatrix(&matrix)) {
- if (!matrix.invert(&matrix)) {
- return false;
- }
- matrix.postConcat(fPtsToUnit);
- sampler->setCustomStage(stage, matrix);
- } else {
- sampler->setCustomStage(stage, fPtsToUnit);
- }
-
- return true;
+GrCustomStage* SkSweepGradient::asNewCustomStage(GrContext* context,
+ GrSamplerState* sampler) const {
+ sampler->matrix()->preConcat(fPtsToUnit);
+ return SkNEW_ARGS(GrSweepGradient, (context, *this));
}
#else
-bool SkSweepGradient::asNewCustomStage(GrContext*, GrSamplerState*) const {
+GrCustomStage* SkSweepGradient::asNewCustomStage(GrContext* context,
+ GrSamplerState* sampler) 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 8e42be0921..2b9dfeb675 100644
--- a/src/effects/gradients/SkSweepGradient.h
+++ b/src/effects/gradients/SkSweepGradient.h
@@ -24,7 +24,8 @@ public:
virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
- virtual bool asNewCustomStage(GrContext* context, GrSamplerState* sampler) const SK_OVERRIDE;
+ virtual GrCustomStage* asNewCustomStage(GrContext* context,
+ GrSamplerState* sampler) 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 19b1228c88..31e3b37c13 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient.cpp
@@ -441,11 +441,9 @@ GrCustomStage* GrConical2Gradient::TestCreate(SkRandom* random,
colors, stops, colorCount,
tm));
GrSamplerState sampler;
- shader->asNewCustomStage(context, &sampler);
- GrAssert(NULL != sampler.getCustomStage());
- // const_cast and ref is a hack! Will remove when asNewCustomStage returns GrCustomStage*
- sampler.getCustomStage()->ref();
- return const_cast<GrCustomStage*>(sampler.getCustomStage());
+ GrCustomStage* stage = shader->asNewCustomStage(context, &sampler);
+ GrAssert(NULL != stage);
+ return stage;
}
@@ -675,40 +673,28 @@ GrCustomStage::StageKey GrGLConical2Gradient::GenKey(const GrCustomStage& s, con
/////////////////////////////////////////////////////////////////////
-bool SkTwoPointConicalGradient::asNewCustomStage(GrContext* context,
- GrSamplerState* sampler) const {
+GrCustomStage* SkTwoPointConicalGradient::asNewCustomStage(
+ GrContext* context, GrSamplerState* sampler) const {
SkASSERT(NULL != context && NULL != sampler);
-
- SkMatrix matrix;
SkPoint diff = fCenter2 - fCenter1;
SkScalar diffLen = diff.length();
if (0 != diffLen) {
SkScalar invDiffLen = SkScalarInvert(diffLen);
- matrix.setSinCos(-SkScalarMul(invDiffLen, diff.fY),
- SkScalarMul(invDiffLen, diff.fX));
+ sampler->matrix()->setSinCos(-SkScalarMul(invDiffLen, diff.fY),
+ SkScalarMul(invDiffLen, diff.fX));
} else {
- matrix.reset();
- }
- matrix.preTranslate(-fCenter1.fX, -fCenter1.fY);
-
- SkMatrix localM;
- if (this->getLocalMatrix(&localM)) {
- if (!localM.invert(&localM)) {
- return false;
- }
- matrix.preConcat(localM);
+ sampler->matrix()->reset();
}
-
- sampler->setCustomStage(SkNEW_ARGS(GrConical2Gradient, (context, *this, fTileMode)), matrix)->unref();
-
- return true;
+ sampler->matrix()->preTranslate(-fCenter1.fX, -fCenter1.fY);
+ return SkNEW_ARGS(GrConical2Gradient, (context, *this, fTileMode));
}
#else
-bool SkTwoPointConicalGradient::asNewCustomStage(GrContext*, GrSamplerState*) const {
+GrCustomStage* SkTwoPointConicalGradient::asNewCustomStage(
+ GrContext* context, GrSamplerState* sampler) 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 40544919c3..4ce72801e0 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient.h
+++ b/src/effects/gradients/SkTwoPointConicalGradient.h
@@ -61,7 +61,8 @@ public:
SkMatrix* matrix,
TileMode* xy) const;
virtual SkShader::GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
- virtual bool asNewCustomStage(GrContext* context, GrSamplerState* sampler) const SK_OVERRIDE;
+ virtual GrCustomStage* asNewCustomStage(GrContext* context,
+ GrSamplerState* sampler) 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 2715511e1b..97f335d97c 100644
--- a/src/effects/gradients/SkTwoPointRadialGradient.cpp
+++ b/src/effects/gradients/SkTwoPointRadialGradient.cpp
@@ -475,11 +475,9 @@ GrCustomStage* GrRadial2Gradient::TestCreate(SkRandom* random,
colors, stops, colorCount,
tm));
GrSamplerState sampler;
- shader->asNewCustomStage(context, &sampler);
- GrAssert(NULL != sampler.getCustomStage());
- // const_cast and ref is a hack! Will remove when asNewCustomStage returns GrCustomStage*
- sampler.getCustomStage()->ref();
- return const_cast<GrCustomStage*>(sampler.getCustomStage());
+ GrCustomStage* stage = shader->asNewCustomStage(context, &sampler);
+ GrAssert(NULL != stage);
+ return stage;
}
/////////////////////////////////////////////////////////////////////
@@ -649,38 +647,27 @@ GrCustomStage::StageKey GrGLRadial2Gradient::GenKey(const GrCustomStage& s, cons
/////////////////////////////////////////////////////////////////////
-bool SkTwoPointRadialGradient::asNewCustomStage(GrContext* context,
- GrSamplerState* sampler) const {
+GrCustomStage* SkTwoPointRadialGradient::asNewCustomStage(
+ GrContext* context, GrSamplerState* sampler) const {
SkASSERT(NULL != context && NULL != sampler);
SkScalar diffLen = fDiff.length();
- SkMatrix matrix;
if (0 != diffLen) {
SkScalar invDiffLen = SkScalarInvert(diffLen);
- matrix.setSinCos(-SkScalarMul(invDiffLen, fDiff.fY),
- SkScalarMul(invDiffLen, fDiff.fX));
+ sampler->matrix()->setSinCos(-SkScalarMul(invDiffLen, fDiff.fY),
+ SkScalarMul(invDiffLen, fDiff.fX));
} else {
- matrix.reset();
+ sampler->matrix()->reset();
}
-
- matrix.preConcat(fPtsToUnit);
-
- SkMatrix localM;
- if (this->getLocalMatrix(&localM)) {
- if (!localM.invert(&localM)) {
- return false;
- }
- matrix.preConcat(localM);
- }
-
- sampler->setCustomStage(SkNEW_ARGS(GrRadial2Gradient, (context, *this, fTileMode)), matrix)->unref();
- return true;
+ sampler->matrix()->preConcat(fPtsToUnit);
+ return SkNEW_ARGS(GrRadial2Gradient, (context, *this, fTileMode));
}
#else
-bool SkTwoPointRadialGradient::asNewCustomStage(GrContext*, GrSamplerState*) const {
+GrCustomStage* SkTwoPointRadialGradient::asNewCustomStage(
+ GrContext* context, GrSamplerState* sampler) 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 adbb602265..a6036f176f 100644
--- a/src/effects/gradients/SkTwoPointRadialGradient.h
+++ b/src/effects/gradients/SkTwoPointRadialGradient.h
@@ -23,7 +23,8 @@ public:
SkMatrix* matrix,
TileMode* xy) const SK_OVERRIDE;
virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
- virtual bool asNewCustomStage(GrContext* context, GrSamplerState* sampler) const SK_OVERRIDE;
+ virtual GrCustomStage* asNewCustomStage(GrContext* context,
+ GrSamplerState* sampler) const SK_OVERRIDE;
virtual void shadeSpan(int x, int y, SkPMColor* dstCParam,
int count) SK_OVERRIDE;