Revert r5962 because of failures.
git-svn-id: http://skia.googlecode.com/svn/trunk@5963 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
b022177777
commit
f6eac8af58
@ -112,9 +112,12 @@ protected:
|
|||||||
ctx->setMatrix(vm);
|
ctx->setMatrix(vm);
|
||||||
GrMatrix tm;
|
GrMatrix tm;
|
||||||
tm = vm;
|
tm = vm;
|
||||||
tm.postIDiv(2*S, 2*S);
|
GrMatrix* sampleMat = paint.colorSampler(0)->matrix();
|
||||||
paint.colorSampler(0)->setCustomStage(SkNEW_ARGS(GrSingleTextureEffect,
|
*sampleMat = vm;
|
||||||
(texture)), tm)->unref();
|
sampleMat->postIDiv(2*S, 2*S);
|
||||||
|
paint.colorSampler(0)->setCustomStage(
|
||||||
|
SkNEW_ARGS(GrSingleTextureEffect, (texture)))->unref();
|
||||||
|
|
||||||
|
|
||||||
ctx->drawRect(paint, GrRect::MakeWH(2*S, 2*S));
|
ctx->drawRect(paint, GrRect::MakeWH(2*S, 2*S));
|
||||||
|
|
||||||
|
@ -306,13 +306,14 @@ public:
|
|||||||
virtual GradientType asAGradient(GradientInfo* info) const;
|
virtual GradientType asAGradient(GradientInfo* info) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the shader subclass has a GrCustomStage implementation, this installs
|
* If the shader subclass has a GrCustomStage implementation, this returns
|
||||||
* a custom stage on the sampler. A GrContext pointer is required since custom
|
* a new custom stage (the caller assumes ownership, and will need to
|
||||||
* stages may need to create textures. The sampler parameter is necessary to set a
|
* unref it). A GrContext pointer is required since custom stages may
|
||||||
* texture matrix. It will eventually be removed and this function will operate as a
|
* need to create textures. The sampler parameter is necessary to set
|
||||||
* GrCustomStage factory.
|
* up matrix/tile modes/etc, and will eventually be removed.
|
||||||
*/
|
*/
|
||||||
virtual bool asNewCustomStage(GrContext* context, GrSamplerState* sampler) const;
|
virtual GrCustomStage* asNewCustomStage(GrContext* context,
|
||||||
|
GrSamplerState* sampler) const;
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// Factory methods for stock shaders
|
// Factory methods for stock shaders
|
||||||
|
@ -19,7 +19,14 @@
|
|||||||
|
|
||||||
class GrSamplerState {
|
class GrSamplerState {
|
||||||
public:
|
public:
|
||||||
|
static const bool kBilerpDefault = false;
|
||||||
|
|
||||||
|
static const SkShader::TileMode kTileModeDefault = SkShader::kClamp_TileMode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default sampler state is set to clamp, use normal sampling mode, be
|
||||||
|
* unfiltered, and use identity matrix.
|
||||||
|
*/
|
||||||
GrSamplerState()
|
GrSamplerState()
|
||||||
: fCustomStage (NULL) {
|
: fCustomStage (NULL) {
|
||||||
memset(this, 0, sizeof(GrSamplerState));
|
memset(this, 0, sizeof(GrSamplerState));
|
||||||
@ -55,6 +62,12 @@ public:
|
|||||||
|
|
||||||
const GrMatrix& getMatrix() const { return fMatrix; }
|
const GrMatrix& getMatrix() const { return fMatrix; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Access the sampler's matrix. See SampleMode for explanation of
|
||||||
|
* relationship between the matrix and sample mode.
|
||||||
|
*/
|
||||||
|
GrMatrix* matrix() { return &fMatrix; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Multiplies the current sampler matrix a matrix
|
* Multiplies the current sampler matrix a matrix
|
||||||
*
|
*
|
||||||
@ -67,10 +80,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
void preConcatMatrix(const GrMatrix& matrix) { fMatrix.preConcat(matrix); }
|
void preConcatMatrix(const GrMatrix& matrix) { fMatrix.preConcat(matrix); }
|
||||||
|
|
||||||
/**
|
void reset(const GrMatrix& matrix) {
|
||||||
* Do not call this function. It will be removed soon.
|
fMatrix = matrix;
|
||||||
*/
|
GrSafeSetNull(fCustomStage);
|
||||||
void setMatrixDeprecated(const GrMatrix& matrix) { fMatrix = matrix; }
|
}
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
fMatrix.reset();
|
fMatrix.reset();
|
||||||
@ -79,16 +92,8 @@ public:
|
|||||||
|
|
||||||
GrCustomStage* setCustomStage(GrCustomStage* stage) {
|
GrCustomStage* setCustomStage(GrCustomStage* stage) {
|
||||||
GrSafeAssign(fCustomStage, stage);
|
GrSafeAssign(fCustomStage, stage);
|
||||||
fMatrix.reset();
|
|
||||||
return stage;
|
return stage;
|
||||||
}
|
}
|
||||||
|
|
||||||
GrCustomStage* setCustomStage(GrCustomStage* stage, const GrMatrix& matrix) {
|
|
||||||
GrSafeAssign(fCustomStage, stage);
|
|
||||||
fMatrix = matrix;
|
|
||||||
return stage;
|
|
||||||
}
|
|
||||||
|
|
||||||
const GrCustomStage* getCustomStage() const { return fCustomStage; }
|
const GrCustomStage* getCustomStage() const { return fCustomStage; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -205,8 +205,9 @@ SkShader::GradientType SkShader::asAGradient(GradientInfo* info) const {
|
|||||||
return kNone_GradientType;
|
return kNone_GradientType;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkShader::asNewCustomStage(GrContext*, GrSamplerState*) const {
|
GrCustomStage* SkShader::asNewCustomStage(GrContext* context,
|
||||||
return false;
|
GrSamplerState* sampler) const {
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkShader* SkShader::CreateBitmapShader(const SkBitmap& src,
|
SkShader* SkShader::CreateBitmapShader(const SkBitmap& src,
|
||||||
|
@ -206,8 +206,10 @@ GrTexture* SkBlendImageFilter::onFilterImageGPU(Proxy* proxy, GrTexture* src, co
|
|||||||
GrMatrix sampleM;
|
GrMatrix sampleM;
|
||||||
sampleM.setIDiv(background->width(), background->height());
|
sampleM.setIDiv(background->width(), background->height());
|
||||||
GrPaint paint;
|
GrPaint paint;
|
||||||
paint.colorSampler(0)->setCustomStage(SkNEW_ARGS(GrSingleTextureEffect, (background.get())), sampleM)->unref();
|
paint.colorSampler(0)->reset(sampleM);
|
||||||
paint.colorSampler(1)->setCustomStage(SkNEW_ARGS(GrBlendEffect, (fMode, foreground.get())), sampleM)->unref();
|
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);
|
context->drawRect(paint, rect);
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
@ -431,7 +431,8 @@ void apply_morphology_pass(GrContext* context,
|
|||||||
GrMatrix sampleM;
|
GrMatrix sampleM;
|
||||||
sampleM.setIDiv(texture->width(), texture->height());
|
sampleM.setIDiv(texture->width(), texture->height());
|
||||||
GrPaint paint;
|
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);
|
context->drawRect(paint, rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -539,11 +539,9 @@ GrCustomStage* GrLinearGradient::TestCreate(SkRandom* random,
|
|||||||
colors, stops, colorCount,
|
colors, stops, colorCount,
|
||||||
tm));
|
tm));
|
||||||
GrSamplerState sampler;
|
GrSamplerState sampler;
|
||||||
shader->asNewCustomStage(context, &sampler);
|
GrCustomStage* stage = shader->asNewCustomStage(context, &sampler);
|
||||||
GrAssert(NULL != sampler.getCustomStage());
|
GrAssert(NULL != stage);
|
||||||
// const_cast and ref is a hack! Will remove when asNewCustomStage returns GrCustomStage*
|
return stage;
|
||||||
sampler.getCustomStage()->ref();
|
|
||||||
return const_cast<GrCustomStage*>(sampler.getCustomStage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
@ -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);
|
SkASSERT(NULL != context && NULL != sampler);
|
||||||
|
sampler->matrix()->preConcat(fPtsToUnit);
|
||||||
SkAutoTUnref<GrCustomStage> stage(SkNEW_ARGS(GrLinearGradient, (context, *this, fTileMode)));
|
return 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
bool SkLinearGradient::asNewCustomStage(GrContext*, GrSamplerState*) const {
|
GrCustomStage* SkLinearGradient::asNewCustomStage(GrContext* context,
|
||||||
|
GrSamplerState* sampler) const {
|
||||||
SkDEBUGFAIL("Should not call in GPU-less build");
|
SkDEBUGFAIL("Should not call in GPU-less build");
|
||||||
return false;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -22,7 +22,8 @@ public:
|
|||||||
virtual void shadeSpan16(int x, int y, uint16_t dstC[], int count) SK_OVERRIDE;
|
virtual void shadeSpan16(int x, int y, uint16_t dstC[], int count) SK_OVERRIDE;
|
||||||
virtual BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*) const SK_OVERRIDE;
|
virtual BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*) const SK_OVERRIDE;
|
||||||
virtual GradientType asAGradient(GradientInfo* info) 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)
|
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLinearGradient)
|
||||||
|
|
||||||
|
@ -538,11 +538,9 @@ GrCustomStage* GrRadialGradient::TestCreate(SkRandom* random,
|
|||||||
colors, stops, colorCount,
|
colors, stops, colorCount,
|
||||||
tm));
|
tm));
|
||||||
GrSamplerState sampler;
|
GrSamplerState sampler;
|
||||||
shader->asNewCustomStage(context, &sampler);
|
GrCustomStage* stage = shader->asNewCustomStage(context, &sampler);
|
||||||
GrAssert(NULL != sampler.getCustomStage());
|
GrAssert(NULL != stage);
|
||||||
// const_cast and ref is a hack! Will remove when asNewCustomStage returns GrCustomStage*
|
return stage;
|
||||||
sampler.getCustomStage()->ref();
|
|
||||||
return const_cast<GrCustomStage*>(sampler.getCustomStage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
@ -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);
|
SkASSERT(NULL != context && NULL != sampler);
|
||||||
SkAutoTUnref<GrCustomStage> stage(SkNEW_ARGS(GrRadialGradient, (context, *this, fTileMode)));
|
sampler->matrix()->preConcat(fPtsToUnit);
|
||||||
|
return 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
bool SkRadialGradient::asNewCustomStage(GrContext*, GrSamplerState*) const {
|
GrCustomStage* SkRadialGradient::asNewCustomStage(GrContext* context,
|
||||||
|
GrSamplerState* sampler) const {
|
||||||
SkDEBUGFAIL("Should not call in GPU-less build");
|
SkDEBUGFAIL("Should not call in GPU-less build");
|
||||||
return false;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -24,7 +24,8 @@ public:
|
|||||||
SkMatrix* matrix,
|
SkMatrix* matrix,
|
||||||
TileMode* xy) const SK_OVERRIDE;
|
TileMode* xy) const SK_OVERRIDE;
|
||||||
virtual GradientType asAGradient(GradientInfo* info) 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)
|
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkRadialGradient)
|
||||||
|
|
||||||
|
@ -444,10 +444,9 @@ GrCustomStage* GrSweepGradient::TestCreate(SkRandom* random,
|
|||||||
SkAutoTUnref<SkShader> shader(SkGradientShader::CreateSweep(center.fX, center.fY,
|
SkAutoTUnref<SkShader> shader(SkGradientShader::CreateSweep(center.fX, center.fY,
|
||||||
colors, stops, colorCount));
|
colors, stops, colorCount));
|
||||||
GrSamplerState sampler;
|
GrSamplerState sampler;
|
||||||
shader->asNewCustomStage(context, &sampler);
|
GrCustomStage* stage = shader->asNewCustomStage(context, &sampler);
|
||||||
GrAssert(NULL != sampler.getCustomStage());
|
GrAssert(NULL != stage);
|
||||||
// const_cast and ref is a hack! Will remove when asNewCustomStage returns GrCustomStage*
|
return stage;
|
||||||
return const_cast<GrCustomStage*>(sampler.getCustomStage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
@ -464,29 +463,18 @@ void GrGLSweepGradient::emitFS(GrGLShaderBuilder* builder,
|
|||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool SkSweepGradient::asNewCustomStage(GrContext* context, GrSamplerState* sampler) const {
|
GrCustomStage* SkSweepGradient::asNewCustomStage(GrContext* context,
|
||||||
SkAutoTUnref<GrCustomStage> stage(SkNEW_ARGS(GrSweepGradient, (context, *this)));
|
GrSamplerState* sampler) const {
|
||||||
|
sampler->matrix()->preConcat(fPtsToUnit);
|
||||||
|
return 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
bool SkSweepGradient::asNewCustomStage(GrContext*, GrSamplerState*) const {
|
GrCustomStage* SkSweepGradient::asNewCustomStage(GrContext* context,
|
||||||
|
GrSamplerState* sampler) const {
|
||||||
SkDEBUGFAIL("Should not call in GPU-less build");
|
SkDEBUGFAIL("Should not call in GPU-less build");
|
||||||
return false;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -24,7 +24,8 @@ public:
|
|||||||
|
|
||||||
virtual GradientType asAGradient(GradientInfo* info) 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(SkSweepGradient)
|
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSweepGradient)
|
||||||
|
|
||||||
|
@ -441,11 +441,9 @@ GrCustomStage* GrConical2Gradient::TestCreate(SkRandom* random,
|
|||||||
colors, stops, colorCount,
|
colors, stops, colorCount,
|
||||||
tm));
|
tm));
|
||||||
GrSamplerState sampler;
|
GrSamplerState sampler;
|
||||||
shader->asNewCustomStage(context, &sampler);
|
GrCustomStage* stage = shader->asNewCustomStage(context, &sampler);
|
||||||
GrAssert(NULL != sampler.getCustomStage());
|
GrAssert(NULL != stage);
|
||||||
// const_cast and ref is a hack! Will remove when asNewCustomStage returns GrCustomStage*
|
return stage;
|
||||||
sampler.getCustomStage()->ref();
|
|
||||||
return const_cast<GrCustomStage*>(sampler.getCustomStage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -675,40 +673,28 @@ GrCustomStage::StageKey GrGLConical2Gradient::GenKey(const GrCustomStage& s, con
|
|||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool SkTwoPointConicalGradient::asNewCustomStage(GrContext* context,
|
GrCustomStage* SkTwoPointConicalGradient::asNewCustomStage(
|
||||||
GrSamplerState* sampler) const {
|
GrContext* context, GrSamplerState* sampler) const {
|
||||||
SkASSERT(NULL != context && NULL != sampler);
|
SkASSERT(NULL != context && NULL != sampler);
|
||||||
|
|
||||||
SkMatrix matrix;
|
|
||||||
SkPoint diff = fCenter2 - fCenter1;
|
SkPoint diff = fCenter2 - fCenter1;
|
||||||
SkScalar diffLen = diff.length();
|
SkScalar diffLen = diff.length();
|
||||||
if (0 != diffLen) {
|
if (0 != diffLen) {
|
||||||
SkScalar invDiffLen = SkScalarInvert(diffLen);
|
SkScalar invDiffLen = SkScalarInvert(diffLen);
|
||||||
matrix.setSinCos(-SkScalarMul(invDiffLen, diff.fY),
|
sampler->matrix()->setSinCos(-SkScalarMul(invDiffLen, diff.fY),
|
||||||
SkScalarMul(invDiffLen, diff.fX));
|
SkScalarMul(invDiffLen, diff.fX));
|
||||||
} else {
|
} else {
|
||||||
matrix.reset();
|
sampler->matrix()->reset();
|
||||||
}
|
}
|
||||||
matrix.preTranslate(-fCenter1.fX, -fCenter1.fY);
|
sampler->matrix()->preTranslate(-fCenter1.fX, -fCenter1.fY);
|
||||||
|
return SkNEW_ARGS(GrConical2Gradient, (context, *this, fTileMode));
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
bool SkTwoPointConicalGradient::asNewCustomStage(GrContext*, GrSamplerState*) const {
|
GrCustomStage* SkTwoPointConicalGradient::asNewCustomStage(
|
||||||
|
GrContext* context, GrSamplerState* sampler) const {
|
||||||
SkDEBUGFAIL("Should not call in GPU-less build");
|
SkDEBUGFAIL("Should not call in GPU-less build");
|
||||||
return false;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -61,7 +61,8 @@ public:
|
|||||||
SkMatrix* matrix,
|
SkMatrix* matrix,
|
||||||
TileMode* xy) const;
|
TileMode* xy) const;
|
||||||
virtual SkShader::GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
|
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 getCenterX1() const { return SkPoint::Distance(fCenter1, fCenter2); }
|
||||||
SkScalar getStartRadius() const { return fRadius1; }
|
SkScalar getStartRadius() const { return fRadius1; }
|
||||||
|
@ -475,11 +475,9 @@ GrCustomStage* GrRadial2Gradient::TestCreate(SkRandom* random,
|
|||||||
colors, stops, colorCount,
|
colors, stops, colorCount,
|
||||||
tm));
|
tm));
|
||||||
GrSamplerState sampler;
|
GrSamplerState sampler;
|
||||||
shader->asNewCustomStage(context, &sampler);
|
GrCustomStage* stage = shader->asNewCustomStage(context, &sampler);
|
||||||
GrAssert(NULL != sampler.getCustomStage());
|
GrAssert(NULL != stage);
|
||||||
// const_cast and ref is a hack! Will remove when asNewCustomStage returns GrCustomStage*
|
return stage;
|
||||||
sampler.getCustomStage()->ref();
|
|
||||||
return const_cast<GrCustomStage*>(sampler.getCustomStage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
@ -649,38 +647,27 @@ GrCustomStage::StageKey GrGLRadial2Gradient::GenKey(const GrCustomStage& s, cons
|
|||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool SkTwoPointRadialGradient::asNewCustomStage(GrContext* context,
|
GrCustomStage* SkTwoPointRadialGradient::asNewCustomStage(
|
||||||
GrSamplerState* sampler) const {
|
GrContext* context, GrSamplerState* sampler) const {
|
||||||
SkASSERT(NULL != context && NULL != sampler);
|
SkASSERT(NULL != context && NULL != sampler);
|
||||||
SkScalar diffLen = fDiff.length();
|
SkScalar diffLen = fDiff.length();
|
||||||
SkMatrix matrix;
|
|
||||||
if (0 != diffLen) {
|
if (0 != diffLen) {
|
||||||
SkScalar invDiffLen = SkScalarInvert(diffLen);
|
SkScalar invDiffLen = SkScalarInvert(diffLen);
|
||||||
matrix.setSinCos(-SkScalarMul(invDiffLen, fDiff.fY),
|
sampler->matrix()->setSinCos(-SkScalarMul(invDiffLen, fDiff.fY),
|
||||||
SkScalarMul(invDiffLen, fDiff.fX));
|
SkScalarMul(invDiffLen, fDiff.fX));
|
||||||
} else {
|
} else {
|
||||||
matrix.reset();
|
sampler->matrix()->reset();
|
||||||
}
|
}
|
||||||
|
sampler->matrix()->preConcat(fPtsToUnit);
|
||||||
matrix.preConcat(fPtsToUnit);
|
return SkNEW_ARGS(GrRadial2Gradient, (context, *this, fTileMode));
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
bool SkTwoPointRadialGradient::asNewCustomStage(GrContext*, GrSamplerState*) const {
|
GrCustomStage* SkTwoPointRadialGradient::asNewCustomStage(
|
||||||
|
GrContext* context, GrSamplerState* sampler) const {
|
||||||
SkDEBUGFAIL("Should not call in GPU-less build");
|
SkDEBUGFAIL("Should not call in GPU-less build");
|
||||||
return false;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -23,7 +23,8 @@ public:
|
|||||||
SkMatrix* matrix,
|
SkMatrix* matrix,
|
||||||
TileMode* xy) const SK_OVERRIDE;
|
TileMode* xy) const SK_OVERRIDE;
|
||||||
virtual GradientType asAGradient(GradientInfo* info) 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,
|
virtual void shadeSpan(int x, int y, SkPMColor* dstCParam,
|
||||||
int count) SK_OVERRIDE;
|
int count) SK_OVERRIDE;
|
||||||
|
@ -41,7 +41,9 @@ void setup_drawstate_aaclip(GrGpu* gpu,
|
|||||||
SkIntToScalar(-devBound.fTop));
|
SkIntToScalar(-devBound.fTop));
|
||||||
mat.preConcat(drawState->getViewMatrix());
|
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,
|
bool path_needs_SW_renderer(GrContext* context,
|
||||||
@ -493,7 +495,8 @@ void GrClipMaskManager::drawTexture(GrTexture* target,
|
|||||||
GrMatrix sampleM;
|
GrMatrix sampleM;
|
||||||
sampleM.setIDiv(texture->width(), texture->height());
|
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()),
|
GrRect rect = GrRect::MakeWH(SkIntToScalar(target->width()),
|
||||||
SkIntToScalar(target->height()));
|
SkIntToScalar(target->height()));
|
||||||
|
@ -202,10 +202,11 @@ void convolve_gaussian(GrDrawTarget* target,
|
|||||||
drawState->setRenderTarget(rt);
|
drawState->setRenderTarget(rt);
|
||||||
GrMatrix sampleM;
|
GrMatrix sampleM;
|
||||||
sampleM.setIDiv(texture->width(), texture->height());
|
sampleM.setIDiv(texture->width(), texture->height());
|
||||||
|
drawState->sampler(0)->reset(sampleM);
|
||||||
SkAutoTUnref<GrConvolutionEffect> conv(SkNEW_ARGS(GrConvolutionEffect,
|
SkAutoTUnref<GrConvolutionEffect> conv(SkNEW_ARGS(GrConvolutionEffect,
|
||||||
(texture, direction, radius,
|
(texture, direction, radius,
|
||||||
sigma)));
|
sigma)));
|
||||||
drawState->sampler(0)->setCustomStage(conv, sampleM);
|
drawState->sampler(0)->setCustomStage(conv);
|
||||||
target->drawSimpleRect(rect, NULL);
|
target->drawSimpleRect(rect, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,8 +313,9 @@ GrTexture* GrContext::createResizedTexture(const GrTextureDesc& desc,
|
|||||||
// if filtering is not desired then we want to ensure all
|
// if filtering is not desired then we want to ensure all
|
||||||
// texels in the resampled image are copies of texels from
|
// texels in the resampled image are copies of texels from
|
||||||
// the original.
|
// the original.
|
||||||
|
drawState->sampler(0)->reset();
|
||||||
GrTextureParams params(SkShader::kClamp_TileMode, needsFiltering);
|
GrTextureParams params(SkShader::kClamp_TileMode, needsFiltering);
|
||||||
drawState->createTextureEffect(0, clampedTexture, GrMatrix::I(), params);
|
drawState->createTextureEffect(0, clampedTexture, params);
|
||||||
|
|
||||||
static const GrVertexLayout layout =
|
static const GrVertexLayout layout =
|
||||||
GrDrawTarget::StageTexCoordVertexLayoutBit(0,0);
|
GrDrawTarget::StageTexCoordVertexLayoutBit(0,0);
|
||||||
@ -1346,7 +1348,8 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target,
|
|||||||
matrix.setTranslate(SK_Scalar1 *left, SK_Scalar1 *top);
|
matrix.setTranslate(SK_Scalar1 *left, SK_Scalar1 *top);
|
||||||
}
|
}
|
||||||
matrix.postIDiv(src->width(), src->height());
|
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));
|
GrRect rect = GrRect::MakeWH(GrIntToScalar(width), GrIntToScalar(height));
|
||||||
fGpu->drawSimpleRect(rect, NULL);
|
fGpu->drawSimpleRect(rect, NULL);
|
||||||
// we want to read back from the scratch's origin
|
// we want to read back from the scratch's origin
|
||||||
@ -1446,7 +1449,8 @@ void GrContext::copyTexture(GrTexture* src, GrRenderTarget* dst) {
|
|||||||
drawState->setRenderTarget(dst);
|
drawState->setRenderTarget(dst);
|
||||||
GrMatrix sampleM;
|
GrMatrix sampleM;
|
||||||
sampleM.setIDiv(src->width(), src->height());
|
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,
|
SkRect rect = SkRect::MakeXYWH(0, 0,
|
||||||
SK_Scalar1 * src->width(),
|
SK_Scalar1 * src->width(),
|
||||||
SK_Scalar1 * src->height());
|
SK_Scalar1 * src->height());
|
||||||
@ -1554,7 +1558,8 @@ void GrContext::writeRenderTargetPixels(GrRenderTarget* target,
|
|||||||
drawState->setRenderTarget(target);
|
drawState->setRenderTarget(target);
|
||||||
|
|
||||||
matrix.setIDiv(texture->width(), texture->height());
|
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);
|
fGpu->drawSimpleRect(GrRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height)), NULL);
|
||||||
}
|
}
|
||||||
@ -1808,15 +1813,14 @@ GrTexture* GrContext::gaussianBlur(GrTexture* srcTexture,
|
|||||||
paint.reset();
|
paint.reset();
|
||||||
|
|
||||||
for (int i = 1; i < scaleFactorX || i < scaleFactorY; i *= 2) {
|
for (int i = 1; i < scaleFactorX || i < scaleFactorY; i *= 2) {
|
||||||
GrMatrix matrix;
|
paint.colorSampler(0)->matrix()->setIDiv(srcTexture->width(),
|
||||||
matrix.setIDiv(srcTexture->width(), srcTexture->height());
|
srcTexture->height());
|
||||||
this->setRenderTarget(dstTexture->asRenderTarget());
|
this->setRenderTarget(dstTexture->asRenderTarget());
|
||||||
SkRect dstRect(srcRect);
|
SkRect dstRect(srcRect);
|
||||||
scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f,
|
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,
|
paint.colorSampler(0)->setCustomStage(SkNEW_ARGS(GrSingleTextureEffect,
|
||||||
(srcTexture, true)), matrix)->unref();
|
(srcTexture, true)))->unref();
|
||||||
this->drawRectToRect(paint, dstRect, srcRect);
|
this->drawRectToRect(paint, dstRect, srcRect);
|
||||||
srcRect = dstRect;
|
srcRect = dstRect;
|
||||||
srcTexture = dstTexture;
|
srcTexture = dstTexture;
|
||||||
@ -1869,13 +1873,12 @@ GrTexture* GrContext::gaussianBlur(GrTexture* srcTexture,
|
|||||||
clearRect = SkIRect::MakeXYWH(srcIRect.fRight, srcIRect.fTop,
|
clearRect = SkIRect::MakeXYWH(srcIRect.fRight, srcIRect.fTop,
|
||||||
1, srcIRect.height());
|
1, srcIRect.height());
|
||||||
this->clear(&clearRect, 0x0);
|
this->clear(&clearRect, 0x0);
|
||||||
GrMatrix matrix;
|
|
||||||
// FIXME: This should be mitchell, not bilinear.
|
// 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());
|
this->setRenderTarget(dstTexture->asRenderTarget());
|
||||||
paint.colorSampler(0)->setCustomStage(SkNEW_ARGS(GrSingleTextureEffect,
|
paint.colorSampler(0)->setCustomStage(SkNEW_ARGS(GrSingleTextureEffect,
|
||||||
(srcTexture, true)),
|
(srcTexture, true)))->unref();
|
||||||
matrix)->unref();
|
|
||||||
SkRect dstRect(srcRect);
|
SkRect dstRect(srcRect);
|
||||||
scale_rect(&dstRect, (float) scaleFactorX, (float) scaleFactorY);
|
scale_rect(&dstRect, (float) scaleFactorX, (float) scaleFactorY);
|
||||||
this->drawRectToRect(paint, dstRect, srcRect);
|
this->drawRectToRect(paint, dstRect, srcRect);
|
||||||
|
@ -54,7 +54,7 @@ void GrDrawState::AutoViewMatrixRestore::restore() {
|
|||||||
fDrawState->setViewMatrix(fViewMatrix);
|
fDrawState->setViewMatrix(fViewMatrix);
|
||||||
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
|
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
|
||||||
if (fRestoreMask & (1 << s)) {
|
if (fRestoreMask & (1 << s)) {
|
||||||
fDrawState->sampler(s)->setMatrixDeprecated(fSamplerMatrices[s]);
|
*fDrawState->sampler(s)->matrix() = fSamplerMatrices[s];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -77,7 +77,6 @@ void GrDrawState::AutoViewMatrixRestore::set(GrDrawState* drawState,
|
|||||||
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
|
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
|
||||||
if (!(explicitCoordStageMask & (1 << s)) && drawState->isStageEnabled(s)) {
|
if (!(explicitCoordStageMask & (1 << s)) && drawState->isStageEnabled(s)) {
|
||||||
fRestoreMask |= (1 << s);
|
fRestoreMask |= (1 << s);
|
||||||
fSamplerMatrices[s] = drawState->sampler(s)->getMatrix();
|
|
||||||
drawState->sampler(s)->preConcatMatrix(preconcatMatrix);
|
drawState->sampler(s)->preConcatMatrix(preconcatMatrix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,7 +89,7 @@ void GrDrawState::AutoDeviceCoordDraw::restore() {
|
|||||||
fDrawState->setViewMatrix(fViewMatrix);
|
fDrawState->setViewMatrix(fViewMatrix);
|
||||||
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
|
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
|
||||||
if (fRestoreMask & (1 << s)) {
|
if (fRestoreMask & (1 << s)) {
|
||||||
fDrawState->sampler(s)->setMatrixDeprecated(fSamplerMatrices[s]);
|
*fDrawState->sampler(s)->matrix() = fSamplerMatrices[s];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -194,17 +194,10 @@ public:
|
|||||||
this->sampler(stage)->setCustomStage(
|
this->sampler(stage)->setCustomStage(
|
||||||
SkNEW_ARGS(GrSingleTextureEffect, (texture)))->unref();
|
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());
|
GrAssert(!this->getSampler(stage).getCustomStage());
|
||||||
GrCustomStage* customStage = SkNEW_ARGS(GrSingleTextureEffect, (texture));
|
this->sampler(stage)->setCustomStage(
|
||||||
this->sampler(stage)->setCustomStage(customStage, matrix)->unref();
|
SkNEW_ARGS(GrSingleTextureEffect, (texture, params)))->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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ void GrTextContext::flushGlyphs() {
|
|||||||
GrAssert(GrIsALIGN4(fCurrVertex));
|
GrAssert(GrIsALIGN4(fCurrVertex));
|
||||||
GrAssert(fCurrTexture);
|
GrAssert(fCurrTexture);
|
||||||
GrTextureParams params(SkShader::kRepeat_TileMode, false);
|
GrTextureParams params(SkShader::kRepeat_TileMode, false);
|
||||||
drawState->createTextureEffect(kGlyphMaskStage, fCurrTexture, GrMatrix::I(), params);
|
drawState->createTextureEffect(kGlyphMaskStage, fCurrTexture, params);
|
||||||
|
|
||||||
if (!GrPixelConfigIsAlphaOnly(fCurrTexture->config())) {
|
if (!GrPixelConfigIsAlphaOnly(fCurrTexture->config())) {
|
||||||
if (kOne_GrBlendCoeff != fPaint.getSrcBlendCoeff() ||
|
if (kOne_GrBlendCoeff != fPaint.getSrcBlendCoeff() ||
|
||||||
|
@ -548,14 +548,25 @@ inline bool skPaint2GrPaintShader(SkGpuDevice* dev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
GrSamplerState* sampler = grPaint->colorSampler(kShaderTextureIdx);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkBitmap bitmap;
|
SkBitmap bitmap;
|
||||||
SkMatrix matrix;
|
SkMatrix* matrix = sampler->matrix();
|
||||||
SkShader::TileMode tileModes[2];
|
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) {
|
if (SkShader::kNone_BitmapType == bmptype) {
|
||||||
SkShader::GradientInfo info;
|
SkShader::GradientInfo info;
|
||||||
@ -589,21 +600,23 @@ inline bool skPaint2GrPaintShader(SkGpuDevice* dev,
|
|||||||
return false;
|
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
|
// matrix to map them back into 0...1 before we load it
|
||||||
SkMatrix localM;
|
SkMatrix localM;
|
||||||
if (shader->getLocalMatrix(&localM)) {
|
if (shader->getLocalMatrix(&localM)) {
|
||||||
SkMatrix inverse;
|
SkMatrix inverse;
|
||||||
if (localM.invert(&inverse)) {
|
if (localM.invert(&inverse)) {
|
||||||
matrix.preConcat(inverse);
|
matrix->preConcat(inverse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (SkShader::kDefault_BitmapType == bmptype) {
|
if (SkShader::kDefault_BitmapType == bmptype) {
|
||||||
GrScalar sx = SkFloatToScalar(1.f / bitmap.width());
|
GrScalar sx = SkFloatToScalar(1.f / bitmap.width());
|
||||||
GrScalar sy = SkFloatToScalar(1.f / bitmap.height());
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
@ -863,11 +876,13 @@ bool drawWithGPUMaskFilter(GrContext* context, const SkPath& devPath,
|
|||||||
if (!isNormalBlur) {
|
if (!isNormalBlur) {
|
||||||
context->setIdentityMatrix();
|
context->setIdentityMatrix();
|
||||||
GrPaint paint;
|
GrPaint paint;
|
||||||
GrMatrix matrix;
|
paint.reset();
|
||||||
matrix.setIDiv(pathTexture->width(), pathTexture->height());
|
paint.colorSampler(0)->matrix()->setIDiv(pathTexture->width(),
|
||||||
|
pathTexture->height());
|
||||||
// Blend pathTexture over blurTexture.
|
// Blend pathTexture over blurTexture.
|
||||||
context->setRenderTarget(blurTexture->asRenderTarget());
|
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) {
|
if (SkMaskFilter::kInner_BlurType == blurType) {
|
||||||
// inner: dst = dst * src
|
// inner: dst = dst * src
|
||||||
paint.setBlendFunc(kDC_GrBlendCoeff, kZero_GrBlendCoeff);
|
paint.setBlendFunc(kDC_GrBlendCoeff, kZero_GrBlendCoeff);
|
||||||
@ -892,13 +907,13 @@ bool drawWithGPUMaskFilter(GrContext* context, const SkPath& devPath,
|
|||||||
static const int MASK_IDX = GrPaint::kMaxCoverageStages - 1;
|
static const int MASK_IDX = GrPaint::kMaxCoverageStages - 1;
|
||||||
// we assume the last mask index is available for use
|
// we assume the last mask index is available for use
|
||||||
GrAssert(!grp->isCoverageStageEnabled(MASK_IDX));
|
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)->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);
|
context->drawRect(*grp, finalRect);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -949,18 +964,19 @@ bool drawWithMaskFilter(GrContext* context, const SkPath& devPath,
|
|||||||
static const int MASK_IDX = GrPaint::kMaxCoverageStages - 1;
|
static const int MASK_IDX = GrPaint::kMaxCoverageStages - 1;
|
||||||
// we assume the last mask index is available for use
|
// we assume the last mask index is available for use
|
||||||
GrAssert(!grp->isCoverageStageEnabled(MASK_IDX));
|
GrAssert(!grp->isCoverageStageEnabled(MASK_IDX));
|
||||||
|
grp->coverageSampler(MASK_IDX)->reset();
|
||||||
GrMatrix m;
|
grp->coverageSampler(MASK_IDX)->setCustomStage(
|
||||||
m.setTranslate(-dstM.fBounds.fLeft*SK_Scalar1, -dstM.fBounds.fTop*SK_Scalar1);
|
SkNEW_ARGS(GrSingleTextureEffect, (texture)))->unref();
|
||||||
m.postIDiv(texture->width(), texture->height());
|
|
||||||
|
|
||||||
grp->coverageSampler(MASK_IDX)->setCustomStage(SkNEW_ARGS(GrSingleTextureEffect, (texture)), m)->unref();
|
|
||||||
GrRect d;
|
GrRect d;
|
||||||
d.setLTRB(GrIntToScalar(dstM.fBounds.fLeft),
|
d.setLTRB(GrIntToScalar(dstM.fBounds.fLeft),
|
||||||
GrIntToScalar(dstM.fBounds.fTop),
|
GrIntToScalar(dstM.fBounds.fTop),
|
||||||
GrIntToScalar(dstM.fBounds.fRight),
|
GrIntToScalar(dstM.fBounds.fRight),
|
||||||
GrIntToScalar(dstM.fBounds.fBottom));
|
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);
|
context->drawRect(*grp, d);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1369,6 +1385,8 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
|
|||||||
|
|
||||||
GrSamplerState* sampler = grPaint->colorSampler(kBitmapTextureIdx);
|
GrSamplerState* sampler = grPaint->colorSampler(kBitmapTextureIdx);
|
||||||
|
|
||||||
|
sampler->matrix()->reset();
|
||||||
|
|
||||||
GrTexture* texture;
|
GrTexture* texture;
|
||||||
SkAutoCachedTexture act(this, bitmap, ¶ms, &texture);
|
SkAutoCachedTexture act(this, bitmap, ¶ms, &texture);
|
||||||
if (NULL == texture) {
|
if (NULL == texture) {
|
||||||
@ -1451,7 +1469,8 @@ void apply_custom_stage(GrContext* context,
|
|||||||
GrMatrix sampleM;
|
GrMatrix sampleM;
|
||||||
sampleM.setIDiv(srcTexture->width(), srcTexture->height());
|
sampleM.setIDiv(srcTexture->width(), srcTexture->height());
|
||||||
GrPaint paint;
|
GrPaint paint;
|
||||||
paint.colorSampler(0)->setCustomStage(stage, sampleM);
|
paint.colorSampler(0)->reset(sampleM);
|
||||||
|
paint.colorSampler(0)->setCustomStage(stage);
|
||||||
context->drawRect(paint, rect);
|
context->drawRect(paint, rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user