From e197cbf9a3e66bab926bc5e51962752dad5221a0 Mon Sep 17 00:00:00 2001 From: "bsalomon@google.com" Date: Mon, 14 Jan 2013 16:46:26 +0000 Subject: [PATCH] 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 --- gyp/core.gyp | 6 + include/core/SkShader.h | 7 +- src/core/SkBitmapProcShader.cpp | 37 +++++ src/core/SkBitmapProcShader.h | 4 + src/core/SkShader.cpp | 2 +- src/effects/gradients/SkLinearGradient.cpp | 17 +- src/effects/gradients/SkLinearGradient.h | 2 +- src/effects/gradients/SkRadialGradient.cpp | 17 +- src/effects/gradients/SkRadialGradient.h | 2 +- src/effects/gradients/SkSweepGradient.cpp | 17 +- src/effects/gradients/SkSweepGradient.h | 2 +- .../gradients/SkTwoPointConicalGradient.cpp | 19 +-- .../gradients/SkTwoPointConicalGradient.h | 2 +- .../gradients/SkTwoPointRadialGradient.cpp | 20 +-- .../gradients/SkTwoPointRadialGradient.h | 2 +- src/gpu/SkGpuDevice.cpp | 149 ++++-------------- 16 files changed, 117 insertions(+), 188 deletions(-) diff --git a/gyp/core.gyp b/gyp/core.gyp index 14b14b04fb..eddb9400c7 100644 --- a/gyp/core.gyp +++ b/gyp/core.gyp @@ -93,6 +93,12 @@ '../src/core/SkUtilsArm.h', ], }], + ['skia_gpu == 1', { + 'include_dirs': [ + '../include/gpu', + '../src/gpu', + ], + }], ], 'direct_dependent_settings': { 'include_dirs': [ diff --git a/include/core/SkShader.h b/include/core/SkShader.h index 389be351b2..d5945afdd7 100644 --- a/include/core/SkShader.h +++ b/include/core/SkShader.h @@ -319,11 +319,10 @@ public: /** * If the shader subclass has a GrEffect implementation, this installs an effect on the stage. - * A GrContext pointer is required since effects may need to create textures. The stage - * parameter is necessary to set a texture matrix. It will eventually be removed and this - * function will operate as a GrEffect factory. + * The GrContext may be used by the effect to create textures. The GPU device does not call + * setContext. Instead we pass the paint here in case the shader needs paint info. */ - virtual bool asNewEffect(GrContext* context, GrEffectStage* stage) const; + virtual GrEffect* asNewEffect(GrContext* context, const SkPaint& paint) const; ////////////////////////////////////////////////////////////////////////// // Factory methods for stock shaders diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp index 3e4116651d..23167cc74e 100644 --- a/src/core/SkBitmapProcShader.cpp +++ b/src/core/SkBitmapProcShader.cpp @@ -336,4 +336,41 @@ bool SkBitmapProcShader::toDumpString(SkString* str) const { gTileModeName[fState.fTileModeY]); return true; } +/////////////////////////////////////////////////////////////////////////////// + +#if SK_SUPPORT_GPU + +#include "GrTextureAccess.h" +#include "effects/GrSingleTextureEffect.h" +#include "SkGr.h" + +GrEffect* SkBitmapProcShader::asNewEffect(GrContext* context, const SkPaint& paint) const { + SkMatrix matrix; + matrix.setIDiv(fRawBitmap.width(), fRawBitmap.height()); + + if (this->hasLocalMatrix()) { + SkMatrix inverse; + if (!this->getLocalMatrix().invert(&inverse)) { + return false; + } + matrix.preConcat(inverse); + } + SkShader::TileMode tm[] = { + (TileMode)fState.fTileModeX, + (TileMode)fState.fTileModeY, + }; + + // Must set wrap and filter on the sampler before requesting a texture. + GrTextureParams params(tm, paint.isFilterBitmap()); + GrTexture* texture = GrLockCachedBitmapTexture(context, fRawBitmap, ¶ms); + + if (NULL == texture) { + SkDebugf("Couldn't convert bitmap to texture.\n"); + return NULL; + } + GrEffect* effect = SkNEW_ARGS(GrSingleTextureEffect, (texture, matrix, params)); + GrUnlockCachedBitmapTexture(texture); + return effect; +} +#endif diff --git a/src/core/SkBitmapProcShader.h b/src/core/SkBitmapProcShader.h index cb791d0c92..fb7ff0bcb2 100644 --- a/src/core/SkBitmapProcShader.h +++ b/src/core/SkBitmapProcShader.h @@ -33,6 +33,10 @@ public: virtual bool toDumpString(SkString* str) const; SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader) +#if SK_SUPPORT_GPU + GrEffect* asNewEffect(GrContext*, const SkPaint&) const SK_OVERRIDE; +#endif + protected: SkBitmapProcShader(SkFlattenableReadBuffer& ); virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp index 706c1b79f5..574dfe3d2b 100644 --- a/src/core/SkShader.cpp +++ b/src/core/SkShader.cpp @@ -173,7 +173,7 @@ SkShader::GradientType SkShader::asAGradient(GradientInfo* info) const { return kNone_GradientType; } -bool SkShader::asNewEffect(GrContext*, GrEffectStage*) const { +GrEffect* SkShader::asNewEffect(GrContext*, const SkPaint&) const { return false; } 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 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(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 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(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 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(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(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(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; diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 3100e0c7ba..a2c388e45e 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -474,7 +474,6 @@ inline bool skPaint2GrPaintNoShader(SkGpuDevice* dev, const SkPaint& skPaint, bool justAlpha, bool constantColor, - SkGpuDevice::SkAutoCachedTexture* act, GrPaint* grPaint) { grPaint->setDither(skPaint.isDither()); @@ -537,81 +536,36 @@ inline bool skPaint2GrPaintNoShader(SkGpuDevice* dev, inline bool skPaint2GrPaintShader(SkGpuDevice* dev, const SkPaint& skPaint, bool constantColor, - SkGpuDevice::SkAutoCachedTexture textures[GrPaint::kMaxColorStages], GrPaint* grPaint) { SkShader* shader = skPaint.getShader(); if (NULL == shader) { - return skPaint2GrPaintNoShader(dev, - skPaint, - false, - constantColor, - &textures[kColorFilterTextureIdx], - grPaint); - } else if (!skPaint2GrPaintNoShader(dev, skPaint, true, false, - &textures[kColorFilterTextureIdx], grPaint)) { + return skPaint2GrPaintNoShader(dev, skPaint, false, constantColor, grPaint); + } else if (!skPaint2GrPaintNoShader(dev, skPaint, true, false, grPaint)) { return false; } - GrEffectStage* stage = grPaint->colorStage(kShaderTextureIdx); - if (shader->asNewEffect(dev->context(), stage)) { + SkAutoTUnref effect(shader->asNewEffect(dev->context(), skPaint)); + if (NULL != effect.get()) { + grPaint->colorStage(kShaderTextureIdx)->setEffect(effect); return true; } - SkBitmap bitmap; - SkMatrix matrix; - SkShader::TileMode tileModes[2]; - SkShader::BitmapType bmptype = shader->asABitmap(&bitmap, &matrix, tileModes); - - if (SkShader::kNone_BitmapType == bmptype) { - SkShader::GradientInfo info; - SkColor color; - - info.fColors = &color; - info.fColorOffsets = NULL; - info.fColorCount = 1; - if (SkShader::kColor_GradientType == shader->asAGradient(&info)) { - SkPaint copy(skPaint); - copy.setShader(NULL); - // modulate the paint alpha by the shader's solid color alpha - U8CPU newA = SkMulDiv255Round(SkColorGetA(color), copy.getAlpha()); - copy.setColor(SkColorSetA(color, newA)); - return skPaint2GrPaintNoShader(dev, - copy, - false, - constantColor, - &textures[kColorFilterTextureIdx], - grPaint); - } - return false; - } + // We still don't have SkColorShader::asNewEffect() implemented. + SkShader::GradientInfo info; + SkColor color; - // since our texture coords will be in local space, we whack the texture - // matrix to map them back into 0...1 before we load it - if (shader->hasLocalMatrix()) { - SkMatrix inverse; - if (!shader->getLocalMatrix().invert(&inverse)) { - return false; - } - matrix.preConcat(inverse); + info.fColors = &color; + info.fColorOffsets = NULL; + info.fColorCount = 1; + if (SkShader::kColor_GradientType == shader->asAGradient(&info)) { + SkPaint copy(skPaint); + copy.setShader(NULL); + // modulate the paint alpha by the shader's solid color alpha + U8CPU newA = SkMulDiv255Round(SkColorGetA(color), copy.getAlpha()); + copy.setColor(SkColorSetA(color, newA)); + return skPaint2GrPaintNoShader(dev, copy, false, constantColor, grPaint); } - - // Must set wrap and filter on the sampler before requesting a texture. - GrTextureParams params(tileModes, skPaint.isFilterBitmap()); - GrTexture* texture = textures[kShaderTextureIdx].set(dev, bitmap, ¶ms); - - if (NULL == texture) { - SkDebugf("Couldn't convert bitmap to texture.\n"); - return false; - } - - if (SkShader::kDefault_BitmapType == bmptype) { - SkScalar sx = SkFloatToScalar(1.f / bitmap.width()); - SkScalar sy = SkFloatToScalar(1.f / bitmap.height()); - matrix.postScale(sx, sy); - } - stage->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (texture, matrix, params)))->unref(); - - return true; + return false; } } @@ -625,12 +579,7 @@ void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { CHECK_SHOULD_DRAW(draw, false); GrPaint grPaint; - SkAutoCachedTexture textures[GrPaint::kMaxColorStages]; - if (!skPaint2GrPaintShader(this, - paint, - true, - textures, - &grPaint)) { + if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { return; } @@ -661,12 +610,7 @@ void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, } GrPaint grPaint; - SkAutoCachedTexture textures[GrPaint::kMaxColorStages]; - if (!skPaint2GrPaintShader(this, - paint, - true, - textures, - &grPaint)) { + if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { return; } @@ -723,12 +667,7 @@ void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, } GrPaint grPaint; - SkAutoCachedTexture textures[GrPaint::kMaxColorStages]; - if (!skPaint2GrPaintShader(this, - paint, - true, - textures, - &grPaint)) { + if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { return; } fContext->drawRect(grPaint, rect, doStroke ? width : -1); @@ -966,12 +905,7 @@ void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath, CHECK_SHOULD_DRAW(draw, false); GrPaint grPaint; - SkAutoCachedTexture textures[GrPaint::kMaxColorStages]; - if (!skPaint2GrPaintShader(this, - paint, - true, - textures, - &grPaint)) { + if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { return; } @@ -1199,10 +1133,9 @@ void SkGpuDevice::drawBitmapCommon(const SkDraw& draw, } GrPaint grPaint; - SkAutoCachedTexture colorLutTexture; bool alphaOnly = !(SkBitmap::kA8_Config == bitmap.config()); - if (!skPaint2GrPaintNoShader(this, paint, alphaOnly, false, &colorLutTexture, &grPaint)) { + if (!skPaint2GrPaintNoShader(this, paint, alphaOnly, false, &grPaint)) { return; } GrTextureParams params; @@ -1472,8 +1405,7 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, int h = bitmap.height(); GrPaint grPaint; - SkAutoCachedTexture colorLutTexture; - if(!skPaint2GrPaintNoShader(this, paint, true, false, &colorLutTexture, &grPaint)) { + if(!skPaint2GrPaintNoShader(this, paint, true, false, &grPaint)) { return; } @@ -1550,10 +1482,9 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkDevice* device, CHECK_SHOULD_DRAW(draw, true); GrPaint grPaint; - SkAutoCachedTexture colorLutTexture; grPaint.colorStage(kBitmapTextureIdx)->reset(); if (!dev->bindDeviceAsTexture(&grPaint) || - !skPaint2GrPaintNoShader(this, paint, true, false, &colorLutTexture, &grPaint)) { + !skPaint2GrPaintNoShader(this, paint, true, false, &grPaint)) { return; } @@ -1648,23 +1579,13 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode, CHECK_SHOULD_DRAW(draw, false); GrPaint grPaint; - SkAutoCachedTexture textures[GrPaint::kMaxColorStages]; // we ignore the shader if texs is null. if (NULL == texs) { - if (!skPaint2GrPaintNoShader(this, - paint, - false, - NULL == colors, - &textures[kColorFilterTextureIdx], - &grPaint)) { + if (!skPaint2GrPaintNoShader(this, paint, false, NULL == colors, &grPaint)) { return; } } else { - if (!skPaint2GrPaintShader(this, - paint, - NULL == colors, - textures, - &grPaint)) { + if (!skPaint2GrPaintShader(this, paint, NULL == colors, &grPaint)) { return; } } @@ -1763,12 +1684,7 @@ void SkGpuDevice::drawText(const SkDraw& draw, const void* text, SkDraw myDraw(draw); GrPaint grPaint; - SkAutoCachedTexture textures[GrPaint::kMaxColorStages]; - if (!skPaint2GrPaintShader(this, - paint, - true, - textures, - &grPaint)) { + if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { return; } GrTextContext context(fContext, grPaint); @@ -1791,12 +1707,7 @@ void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, SkDraw myDraw(draw); GrPaint grPaint; - SkAutoCachedTexture textures[GrPaint::kMaxColorStages]; - if (!skPaint2GrPaintShader(this, - paint, - true, - textures, - &grPaint)) { + if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { return; } GrTextContext context(fContext, grPaint); -- 2.34.1