Revert r5962 because of failures.
git-svn-id: http://skia.googlecode.com/svn/trunk@5963 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp
index 7e3a92b..2f1def6 100644
--- a/src/core/SkShader.cpp
+++ b/src/core/SkShader.cpp
@@ -205,8 +205,9 @@
return kNone_GradientType;
}
-bool SkShader::asNewCustomStage(GrContext*, GrSamplerState*) const {
- return false;
+GrCustomStage* SkShader::asNewCustomStage(GrContext* context,
+ GrSamplerState* sampler) const {
+ return NULL;
}
SkShader* SkShader::CreateBitmapShader(const SkBitmap& src,
diff --git a/src/effects/SkBlendImageFilter.cpp b/src/effects/SkBlendImageFilter.cpp
index 1fa3c0d..7933e27 100644
--- a/src/effects/SkBlendImageFilter.cpp
+++ b/src/effects/SkBlendImageFilter.cpp
@@ -206,8 +206,10 @@
GrMatrix sampleM;
sampleM.setIDiv(background->width(), background->height());
GrPaint paint;
- paint.colorSampler(0)->setCustomStage(SkNEW_ARGS(GrSingleTextureEffect, (background.get())), sampleM)->unref();
- paint.colorSampler(1)->setCustomStage(SkNEW_ARGS(GrBlendEffect, (fMode, foreground.get())), sampleM)->unref();
+ paint.colorSampler(0)->reset(sampleM);
+ paint.colorSampler(0)->setCustomStage(SkNEW_ARGS(GrSingleTextureEffect, (background.get())))->unref();
+ paint.colorSampler(1)->reset(sampleM);
+ paint.colorSampler(1)->setCustomStage(SkNEW_ARGS(GrBlendEffect, (fMode, foreground.get())))->unref();
context->drawRect(paint, rect);
return dst;
}
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index 9bddb9b..64d22be 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -431,7 +431,8 @@
GrMatrix sampleM;
sampleM.setIDiv(texture->width(), texture->height());
GrPaint paint;
- paint.colorSampler(0)->setCustomStage(SkNEW_ARGS(GrMorphologyEffect, (texture, direction, radius, morphType)), sampleM)->unref();
+ paint.colorSampler(0)->reset(sampleM);
+ paint.colorSampler(0)->setCustomStage(SkNEW_ARGS(GrMorphologyEffect, (texture, direction, radius, morphType)))->unref();
context->drawRect(paint, rect);
}
diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp
index fff2180..4b673f6 100644
--- a/src/effects/gradients/SkLinearGradient.cpp
+++ b/src/effects/gradients/SkLinearGradient.cpp
@@ -539,11 +539,9 @@
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 @@
/////////////////////////////////////////////////////////////////////
-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 fe60543..129a56a 100644
--- a/src/effects/gradients/SkLinearGradient.h
+++ b/src/effects/gradients/SkLinearGradient.h
@@ -22,7 +22,8 @@
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 0156acd..512eafb 100644
--- a/src/effects/gradients/SkRadialGradient.cpp
+++ b/src/effects/gradients/SkRadialGradient.cpp
@@ -538,11 +538,9 @@
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 @@
/////////////////////////////////////////////////////////////////////
-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 fc17520..23a35f7 100644
--- a/src/effects/gradients/SkRadialGradient.h
+++ b/src/effects/gradients/SkRadialGradient.h
@@ -24,7 +24,8 @@
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 d8cbf9c..f18b08e 100644
--- a/src/effects/gradients/SkSweepGradient.cpp
+++ b/src/effects/gradients/SkSweepGradient.cpp
@@ -444,10 +444,9 @@
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 @@
/////////////////////////////////////////////////////////////////////
-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 8e42be0..2b9dfeb 100644
--- a/src/effects/gradients/SkSweepGradient.h
+++ b/src/effects/gradients/SkSweepGradient.h
@@ -24,7 +24,8 @@
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 19b1228..31e3b37 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient.cpp
@@ -441,11 +441,9 @@
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 @@
/////////////////////////////////////////////////////////////////////
-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();
+ sampler->matrix()->reset();
}
- matrix.preTranslate(-fCenter1.fX, -fCenter1.fY);
-
- SkMatrix localM;
- if (this->getLocalMatrix(&localM)) {
- if (!localM.invert(&localM)) {
- return false;
- }
- matrix.preConcat(localM);
- }
-
- 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 4054491..4ce7280 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient.h
+++ b/src/effects/gradients/SkTwoPointConicalGradient.h
@@ -61,7 +61,8 @@
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 2715511..97f335d 100644
--- a/src/effects/gradients/SkTwoPointRadialGradient.cpp
+++ b/src/effects/gradients/SkTwoPointRadialGradient.cpp
@@ -475,11 +475,9 @@
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 @@
/////////////////////////////////////////////////////////////////////
-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 adbb602..a6036f1 100644
--- a/src/effects/gradients/SkTwoPointRadialGradient.h
+++ b/src/effects/gradients/SkTwoPointRadialGradient.h
@@ -23,7 +23,8 @@
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;
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index aa0c024..322fba1 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -41,7 +41,9 @@
SkIntToScalar(-devBound.fTop));
mat.preConcat(drawState->getViewMatrix());
- drawState->createTextureEffect(maskStage, result, mat);
+ drawState->sampler(maskStage)->reset(mat);
+
+ drawState->createTextureEffect(maskStage, result);
}
bool path_needs_SW_renderer(GrContext* context,
@@ -493,7 +495,8 @@
GrMatrix sampleM;
sampleM.setIDiv(texture->width(), texture->height());
- drawState->createTextureEffect(0, texture, sampleM);
+ drawState->sampler(0)->reset(sampleM);
+ drawState->createTextureEffect(0, texture);
GrRect rect = GrRect::MakeWH(SkIntToScalar(target->width()),
SkIntToScalar(target->height()));
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 8b7d2d0..ee3a4e1 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -202,10 +202,11 @@
drawState->setRenderTarget(rt);
GrMatrix sampleM;
sampleM.setIDiv(texture->width(), texture->height());
+ drawState->sampler(0)->reset(sampleM);
SkAutoTUnref<GrConvolutionEffect> conv(SkNEW_ARGS(GrConvolutionEffect,
(texture, direction, radius,
sigma)));
- drawState->sampler(0)->setCustomStage(conv, sampleM);
+ drawState->sampler(0)->setCustomStage(conv);
target->drawSimpleRect(rect, NULL);
}
@@ -312,8 +313,9 @@
// if filtering is not desired then we want to ensure all
// texels in the resampled image are copies of texels from
// the original.
+ drawState->sampler(0)->reset();
GrTextureParams params(SkShader::kClamp_TileMode, needsFiltering);
- drawState->createTextureEffect(0, clampedTexture, GrMatrix::I(), params);
+ drawState->createTextureEffect(0, clampedTexture, params);
static const GrVertexLayout layout =
GrDrawTarget::StageTexCoordVertexLayoutBit(0,0);
@@ -1346,7 +1348,8 @@
matrix.setTranslate(SK_Scalar1 *left, SK_Scalar1 *top);
}
matrix.postIDiv(src->width(), src->height());
- drawState->sampler(0)->setCustomStage(stage, matrix);
+ drawState->sampler(0)->reset(matrix);
+ drawState->sampler(0)->setCustomStage(stage);
GrRect rect = GrRect::MakeWH(GrIntToScalar(width), GrIntToScalar(height));
fGpu->drawSimpleRect(rect, NULL);
// we want to read back from the scratch's origin
@@ -1446,7 +1449,8 @@
drawState->setRenderTarget(dst);
GrMatrix sampleM;
sampleM.setIDiv(src->width(), src->height());
- drawState->createTextureEffect(0, src, sampleM);
+ drawState->sampler(0)->reset(sampleM);
+ drawState->createTextureEffect(0, src);
SkRect rect = SkRect::MakeXYWH(0, 0,
SK_Scalar1 * src->width(),
SK_Scalar1 * src->height());
@@ -1554,7 +1558,8 @@
drawState->setRenderTarget(target);
matrix.setIDiv(texture->width(), texture->height());
- drawState->sampler(0)->setCustomStage(stage, matrix);
+ drawState->sampler(0)->reset(matrix);
+ drawState->sampler(0)->setCustomStage(stage);
fGpu->drawSimpleRect(GrRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height)), NULL);
}
@@ -1808,15 +1813,14 @@
paint.reset();
for (int i = 1; i < scaleFactorX || i < scaleFactorY; i *= 2) {
- GrMatrix matrix;
- matrix.setIDiv(srcTexture->width(), srcTexture->height());
+ paint.colorSampler(0)->matrix()->setIDiv(srcTexture->width(),
+ srcTexture->height());
this->setRenderTarget(dstTexture->asRenderTarget());
SkRect dstRect(srcRect);
scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f,
- i < scaleFactorY ? 0.5f : 1.0f);
-
+ i < scaleFactorY ? 0.5f : 1.0f);
paint.colorSampler(0)->setCustomStage(SkNEW_ARGS(GrSingleTextureEffect,
- (srcTexture, true)), matrix)->unref();
+ (srcTexture, true)))->unref();
this->drawRectToRect(paint, dstRect, srcRect);
srcRect = dstRect;
srcTexture = dstTexture;
@@ -1869,13 +1873,12 @@
clearRect = SkIRect::MakeXYWH(srcIRect.fRight, srcIRect.fTop,
1, srcIRect.height());
this->clear(&clearRect, 0x0);
- GrMatrix matrix;
// FIXME: This should be mitchell, not bilinear.
- matrix.setIDiv(srcTexture->width(), srcTexture->height());
+ paint.colorSampler(0)->matrix()->setIDiv(srcTexture->width(),
+ srcTexture->height());
this->setRenderTarget(dstTexture->asRenderTarget());
paint.colorSampler(0)->setCustomStage(SkNEW_ARGS(GrSingleTextureEffect,
- (srcTexture, true)),
- matrix)->unref();
+ (srcTexture, true)))->unref();
SkRect dstRect(srcRect);
scale_rect(&dstRect, (float) scaleFactorX, (float) scaleFactorY);
this->drawRectToRect(paint, dstRect, srcRect);
diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp
index cc11f6c..da81a76 100644
--- a/src/gpu/GrDrawState.cpp
+++ b/src/gpu/GrDrawState.cpp
@@ -54,7 +54,7 @@
fDrawState->setViewMatrix(fViewMatrix);
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
if (fRestoreMask & (1 << s)) {
- fDrawState->sampler(s)->setMatrixDeprecated(fSamplerMatrices[s]);
+ *fDrawState->sampler(s)->matrix() = fSamplerMatrices[s];
}
}
}
@@ -77,7 +77,6 @@
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
if (!(explicitCoordStageMask & (1 << s)) && drawState->isStageEnabled(s)) {
fRestoreMask |= (1 << s);
- fSamplerMatrices[s] = drawState->sampler(s)->getMatrix();
drawState->sampler(s)->preConcatMatrix(preconcatMatrix);
}
}
@@ -90,7 +89,7 @@
fDrawState->setViewMatrix(fViewMatrix);
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
if (fRestoreMask & (1 << s)) {
- fDrawState->sampler(s)->setMatrixDeprecated(fSamplerMatrices[s]);
+ *fDrawState->sampler(s)->matrix() = fSamplerMatrices[s];
}
}
}
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index 6306c33..69f0aea 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -194,17 +194,10 @@
this->sampler(stage)->setCustomStage(
SkNEW_ARGS(GrSingleTextureEffect, (texture)))->unref();
}
- void createTextureEffect(int stage, GrTexture* texture, const GrMatrix& matrix) {
+ void createTextureEffect(int stage, GrTexture* texture, const GrTextureParams& params) {
GrAssert(!this->getSampler(stage).getCustomStage());
- GrCustomStage* customStage = SkNEW_ARGS(GrSingleTextureEffect, (texture));
- this->sampler(stage)->setCustomStage(customStage, matrix)->unref();
- }
- void createTextureEffect(int stage, GrTexture* texture,
- const GrMatrix& matrix,
- const GrTextureParams& params) {
- GrAssert(!this->getSampler(stage).getCustomStage());
- GrCustomStage* customStage = SkNEW_ARGS(GrSingleTextureEffect, (texture, params));
- this->sampler(stage)->setCustomStage(customStage, matrix)->unref();
+ this->sampler(stage)->setCustomStage(
+ SkNEW_ARGS(GrSingleTextureEffect, (texture, params)))->unref();
}
diff --git a/src/gpu/GrTextContext.cpp b/src/gpu/GrTextContext.cpp
index c3c361c..c9944b9 100644
--- a/src/gpu/GrTextContext.cpp
+++ b/src/gpu/GrTextContext.cpp
@@ -35,7 +35,7 @@
GrAssert(GrIsALIGN4(fCurrVertex));
GrAssert(fCurrTexture);
GrTextureParams params(SkShader::kRepeat_TileMode, false);
- drawState->createTextureEffect(kGlyphMaskStage, fCurrTexture, GrMatrix::I(), params);
+ drawState->createTextureEffect(kGlyphMaskStage, fCurrTexture, params);
if (!GrPixelConfigIsAlphaOnly(fCurrTexture->config())) {
if (kOne_GrBlendCoeff != fPaint.getSrcBlendCoeff() ||
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 02bfdbd..a09b57f 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -548,14 +548,25 @@
}
GrSamplerState* sampler = grPaint->colorSampler(kShaderTextureIdx);
- if (shader->asNewCustomStage(dev->context(), sampler)) {
+ GrCustomStage* stage = shader->asNewCustomStage(dev->context(), sampler);
+
+ if (NULL != stage) {
+ sampler->setCustomStage(stage)->unref();
+ SkMatrix localM;
+ if (shader->getLocalMatrix(&localM)) {
+ SkMatrix inverse;
+ if (localM.invert(&inverse)) {
+ sampler->matrix()->preConcat(inverse);
+ }
+ }
return true;
}
SkBitmap bitmap;
- SkMatrix matrix;
+ SkMatrix* matrix = sampler->matrix();
SkShader::TileMode tileModes[2];
- SkShader::BitmapType bmptype = shader->asABitmap(&bitmap, &matrix, tileModes);
+ SkShader::BitmapType bmptype = shader->asABitmap(&bitmap, matrix,
+ tileModes);
if (SkShader::kNone_BitmapType == bmptype) {
SkShader::GradientInfo info;
@@ -589,21 +600,23 @@
return false;
}
- // since our texture coords will be in local space, we whack the texture
+ sampler->reset();
+ sampler->setCustomStage(SkNEW_ARGS(GrSingleTextureEffect, (texture, params)))->unref();
+
+ // since our texture coords will be in local space, we wack the texture
// matrix to map them back into 0...1 before we load it
SkMatrix localM;
if (shader->getLocalMatrix(&localM)) {
SkMatrix inverse;
if (localM.invert(&inverse)) {
- matrix.preConcat(inverse);
+ matrix->preConcat(inverse);
}
}
if (SkShader::kDefault_BitmapType == bmptype) {
GrScalar sx = SkFloatToScalar(1.f / bitmap.width());
GrScalar sy = SkFloatToScalar(1.f / bitmap.height());
- matrix.postScale(sx, sy);
+ matrix->postScale(sx, sy);
}
- sampler->setCustomStage(SkNEW_ARGS(GrSingleTextureEffect, (texture, params)), matrix)->unref();
return true;
}
@@ -863,11 +876,13 @@
if (!isNormalBlur) {
context->setIdentityMatrix();
GrPaint paint;
- GrMatrix matrix;
- matrix.setIDiv(pathTexture->width(), pathTexture->height());
+ paint.reset();
+ paint.colorSampler(0)->matrix()->setIDiv(pathTexture->width(),
+ pathTexture->height());
// Blend pathTexture over blurTexture.
context->setRenderTarget(blurTexture->asRenderTarget());
- paint.colorSampler(0)->setCustomStage(SkNEW_ARGS(GrSingleTextureEffect, (pathTexture)), matrix)->unref();
+ paint.colorSampler(0)->setCustomStage(SkNEW_ARGS
+ (GrSingleTextureEffect, (pathTexture)))->unref();
if (SkMaskFilter::kInner_BlurType == blurType) {
// inner: dst = dst * src
paint.setBlendFunc(kDC_GrBlendCoeff, kZero_GrBlendCoeff);
@@ -892,13 +907,13 @@
static const int MASK_IDX = GrPaint::kMaxCoverageStages - 1;
// we assume the last mask index is available for use
GrAssert(!grp->isCoverageStageEnabled(MASK_IDX));
-
- GrMatrix matrix;
- matrix.setTranslate(-finalRect.fLeft, -finalRect.fTop);
- matrix.postIDiv(blurTexture->width(), blurTexture->height());
-
grp->coverageSampler(MASK_IDX)->reset();
- grp->coverageSampler(MASK_IDX)->setCustomStage(SkNEW_ARGS(GrSingleTextureEffect, (blurTexture)), matrix)->unref();
+ grp->coverageSampler(MASK_IDX)->setCustomStage(
+ SkNEW_ARGS(GrSingleTextureEffect, (blurTexture)))->unref();
+ grp->coverageSampler(MASK_IDX)->matrix()->setTranslate(-finalRect.fLeft,
+ -finalRect.fTop);
+ grp->coverageSampler(MASK_IDX)->matrix()->postIDiv(blurTexture->width(),
+ blurTexture->height());
context->drawRect(*grp, finalRect);
return true;
}
@@ -949,18 +964,19 @@
static const int MASK_IDX = GrPaint::kMaxCoverageStages - 1;
// we assume the last mask index is available for use
GrAssert(!grp->isCoverageStageEnabled(MASK_IDX));
-
- GrMatrix m;
- m.setTranslate(-dstM.fBounds.fLeft*SK_Scalar1, -dstM.fBounds.fTop*SK_Scalar1);
- m.postIDiv(texture->width(), texture->height());
-
- grp->coverageSampler(MASK_IDX)->setCustomStage(SkNEW_ARGS(GrSingleTextureEffect, (texture)), m)->unref();
+ grp->coverageSampler(MASK_IDX)->reset();
+ grp->coverageSampler(MASK_IDX)->setCustomStage(
+ SkNEW_ARGS(GrSingleTextureEffect, (texture)))->unref();
GrRect d;
d.setLTRB(GrIntToScalar(dstM.fBounds.fLeft),
GrIntToScalar(dstM.fBounds.fTop),
GrIntToScalar(dstM.fBounds.fRight),
GrIntToScalar(dstM.fBounds.fBottom));
+ GrMatrix* m = grp->coverageSampler(MASK_IDX)->matrix();
+ m->setTranslate(-dstM.fBounds.fLeft*SK_Scalar1,
+ -dstM.fBounds.fTop*SK_Scalar1);
+ m->postIDiv(texture->width(), texture->height());
context->drawRect(*grp, d);
return true;
}
@@ -1369,6 +1385,8 @@
GrSamplerState* sampler = grPaint->colorSampler(kBitmapTextureIdx);
+ sampler->matrix()->reset();
+
GrTexture* texture;
SkAutoCachedTexture act(this, bitmap, ¶ms, &texture);
if (NULL == texture) {
@@ -1451,7 +1469,8 @@
GrMatrix sampleM;
sampleM.setIDiv(srcTexture->width(), srcTexture->height());
GrPaint paint;
- paint.colorSampler(0)->setCustomStage(stage, sampleM);
+ paint.colorSampler(0)->reset(sampleM);
+ paint.colorSampler(0)->setCustomStage(stage);
context->drawRect(paint, rect);
}