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
This commit is contained in:
parent
ff06af20fd
commit
e197cbf9a3
@ -93,6 +93,12 @@
|
||||
'../src/core/SkUtilsArm.h',
|
||||
],
|
||||
}],
|
||||
['skia_gpu == 1', {
|
||||
'include_dirs': [
|
||||
'../include/gpu',
|
||||
'../src/gpu',
|
||||
],
|
||||
}],
|
||||
],
|
||||
'direct_dependent_settings': {
|
||||
'include_dirs': [
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -522,12 +522,8 @@ GrEffect* GrLinearGradient::TestCreate(SkRandom* random,
|
||||
SkAutoTUnref<SkShader> shader(SkGradientShader::CreateLinear(points,
|
||||
colors, stops, colorCount,
|
||||
tm));
|
||||
GrEffectStage stage;
|
||||
shader->asNewEffect(context, &stage);
|
||||
GrAssert(NULL != stage.getEffect());
|
||||
// const_cast and ref is a hack! Will remove when asNewEffect returns GrEffect*
|
||||
stage.getEffect()->ref();
|
||||
return const_cast<GrEffect*>(stage.getEffect());
|
||||
SkPaint paint;
|
||||
return shader->asNewEffect(context, paint);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
@ -550,22 +546,21 @@ void GrGLLinearGradient::emitCode(GrGLShaderBuilder* builder,
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool SkLinearGradient::asNewEffect(GrContext* context, GrEffectStage* stage) const {
|
||||
GrEffect* SkLinearGradient::asNewEffect(GrContext* context, const SkPaint&) const {
|
||||
SkASSERT(NULL != context && NULL != stage);
|
||||
SkMatrix matrix;
|
||||
if (!this->getLocalMatrix().invert(&matrix)) {
|
||||
return false;
|
||||
}
|
||||
matrix.postConcat(fPtsToUnit);
|
||||
stage->setEffect(SkNEW_ARGS(GrLinearGradient, (context, *this, matrix, fTileMode)))->unref();
|
||||
return true;
|
||||
return SkNEW_ARGS(GrLinearGradient, (context, *this, matrix, fTileMode));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool SkLinearGradient::asNewEffect(GrContext*, GrEffectStage*) const {
|
||||
GrEffect* SkLinearGradient::asNewEffect(GrContext* context, const SkPaint&) const {
|
||||
SkDEBUGFAIL("Should not call in GPU-less build");
|
||||
return false;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -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)
|
||||
|
||||
|
@ -545,12 +545,8 @@ GrEffect* GrRadialGradient::TestCreate(SkRandom* random,
|
||||
SkAutoTUnref<SkShader> shader(SkGradientShader::CreateRadial(center, radius,
|
||||
colors, stops, colorCount,
|
||||
tm));
|
||||
GrEffectStage stage;
|
||||
shader->asNewEffect(context, &stage);
|
||||
GrAssert(NULL != stage.getEffect());
|
||||
// const_cast and ref is a hack! Will remove when asNewEffect returns GrEffect*
|
||||
stage.getEffect()->ref();
|
||||
return const_cast<GrEffect*>(stage.getEffect());
|
||||
SkPaint paint;
|
||||
return shader->asNewEffect(context, paint);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
@ -573,7 +569,7 @@ void GrGLRadialGradient::emitCode(GrGLShaderBuilder* builder,
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool SkRadialGradient::asNewEffect(GrContext* context, GrEffectStage* stage) const {
|
||||
GrEffect* SkRadialGradient::asNewEffect(GrContext* context, const SkPaint&) const {
|
||||
SkASSERT(NULL != context && NULL != stage);
|
||||
|
||||
SkMatrix matrix;
|
||||
@ -581,15 +577,14 @@ bool SkRadialGradient::asNewEffect(GrContext* context, GrEffectStage* stage) con
|
||||
return false;
|
||||
}
|
||||
matrix.postConcat(fPtsToUnit);
|
||||
stage->setEffect(SkNEW_ARGS(GrRadialGradient, (context, *this, matrix, fTileMode)))->unref();
|
||||
return true;
|
||||
return SkNEW_ARGS(GrRadialGradient, (context, *this, matrix, fTileMode));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool SkRadialGradient::asNewEffect(GrContext*, GrEffectStage*) const {
|
||||
GrEffect* SkRadialGradient::asNewEffect(GrContext* context, const SkPaint&) const {
|
||||
SkDEBUGFAIL("Should not call in GPU-less build");
|
||||
return false;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -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)
|
||||
|
||||
|
@ -449,12 +449,8 @@ GrEffect* GrSweepGradient::TestCreate(SkRandom* random,
|
||||
int colorCount = RandomGradientParams(random, colors, &stops, &tmIgnored);
|
||||
SkAutoTUnref<SkShader> shader(SkGradientShader::CreateSweep(center.fX, center.fY,
|
||||
colors, stops, colorCount));
|
||||
GrEffectStage stage;
|
||||
shader->asNewEffect(context, &stage);
|
||||
GrAssert(NULL != stage.getEffect());
|
||||
// const_cast and ref is a hack! Will remove when asNewEffect returns GrEffect*
|
||||
stage.getEffect()->ref();
|
||||
return const_cast<GrEffect*>(stage.getEffect());
|
||||
SkPaint paint;
|
||||
return shader->asNewEffect(context, paint);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
@ -476,21 +472,20 @@ void GrGLSweepGradient::emitCode(GrGLShaderBuilder* builder,
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool SkSweepGradient::asNewEffect(GrContext* context, GrEffectStage* stage) const {
|
||||
GrEffect* SkSweepGradient::asNewEffect(GrContext* context, const SkPaint&) const {
|
||||
SkMatrix matrix;
|
||||
if (!this->getLocalMatrix().invert(&matrix)) {
|
||||
return false;
|
||||
}
|
||||
matrix.postConcat(fPtsToUnit);
|
||||
stage->setEffect(SkNEW_ARGS(GrSweepGradient, (context, *this, matrix)))->unref();
|
||||
return true;
|
||||
return SkNEW_ARGS(GrSweepGradient, (context, *this, matrix));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool SkSweepGradient::asNewEffect(GrContext*, GrEffectStage*) const {
|
||||
GrEffect* SkSweepGradient::asNewEffect(GrContext* context, const SkPaint&) const {
|
||||
SkDEBUGFAIL("Should not call in GPU-less build");
|
||||
return false;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -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)
|
||||
|
||||
|
@ -440,12 +440,8 @@ GrEffect* GrConical2Gradient::TestCreate(SkRandom* random,
|
||||
center2, radius2,
|
||||
colors, stops, colorCount,
|
||||
tm));
|
||||
GrEffectStage stage;
|
||||
shader->asNewEffect(context, &stage);
|
||||
GrAssert(NULL != stage.getEffect());
|
||||
// const_cast and ref is a hack! Will remove when asNewEffect returns GrEffect*
|
||||
stage.getEffect()->ref();
|
||||
return const_cast<GrEffect*>(stage.getEffect());
|
||||
SkPaint paint;
|
||||
return shader->asNewEffect(context, paint);
|
||||
}
|
||||
|
||||
|
||||
@ -688,8 +684,7 @@ GrGLEffect::EffectKey GrGLConical2Gradient::GenKey(const GrEffectStage& s, const
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool SkTwoPointConicalGradient::asNewEffect(GrContext* context,
|
||||
GrEffectStage* stage) const {
|
||||
GrEffect* SkTwoPointConicalGradient::asNewEffect(GrContext* context, const SkPaint&) const {
|
||||
SkASSERT(NULL != context && NULL != stage);
|
||||
SkASSERT(fPtsToUnit.isIdentity());
|
||||
// invert the localM, translate to center1, rotate so center2 is on x axis.
|
||||
@ -709,16 +704,14 @@ bool SkTwoPointConicalGradient::asNewEffect(GrContext* context,
|
||||
matrix.postConcat(rot);
|
||||
}
|
||||
|
||||
stage->setEffect(SkNEW_ARGS(GrConical2Gradient, (context, *this, matrix, fTileMode)))->unref();
|
||||
|
||||
return true;
|
||||
return SkNEW_ARGS(GrConical2Gradient, (context, *this, matrix, fTileMode));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool SkTwoPointConicalGradient::asNewEffect(GrContext*, GrEffectStage*) const {
|
||||
GrEffect* SkTwoPointConicalGradient::asNewEffect(GrContext* context, const SkPaint&) const {
|
||||
SkDEBUGFAIL("Should not call in GPU-less build");
|
||||
return false;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -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; }
|
||||
|
@ -463,7 +463,7 @@ GrEffect* GrRadial2Gradient::TestCreate(SkRandom* random,
|
||||
do {
|
||||
center2.set(random->nextUScalar1(), random->nextUScalar1());
|
||||
radius2 = random->nextUScalar1 ();
|
||||
// There is a bug in two point radial gradients with idenitical radii
|
||||
// There is a bug in two point radial gradients with identical radii
|
||||
} while (radius1 == radius2);
|
||||
|
||||
SkColor colors[kMaxRandomGradientColors];
|
||||
@ -475,12 +475,8 @@ GrEffect* GrRadial2Gradient::TestCreate(SkRandom* random,
|
||||
center2, radius2,
|
||||
colors, stops, colorCount,
|
||||
tm));
|
||||
GrEffectStage stage;
|
||||
shader->asNewEffect(context, &stage);
|
||||
GrAssert(NULL != stage.getEffect());
|
||||
// const_cast and ref is a hack! Will remove when asNewEffect returns GrEffect*
|
||||
stage.getEffect()->ref();
|
||||
return const_cast<GrEffect*>(stage.getEffect());
|
||||
SkPaint paint;
|
||||
return shader->asNewEffect(context, paint);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
@ -661,8 +657,7 @@ GrGLEffect::EffectKey GrGLRadial2Gradient::GenKey(const GrEffectStage& s, const
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool SkTwoPointRadialGradient::asNewEffect(GrContext* context,
|
||||
GrEffectStage* stage) const {
|
||||
GrEffect* SkTwoPointRadialGradient::asNewEffect(GrContext* context, const SkPaint&) const {
|
||||
SkASSERT(NULL != context && NULL != stage);
|
||||
// invert the localM, translate to center1 (fPtsToUni), rotate so center2 is on x axis.
|
||||
SkMatrix matrix;
|
||||
@ -680,15 +675,14 @@ bool SkTwoPointRadialGradient::asNewEffect(GrContext* context,
|
||||
matrix.postConcat(rot);
|
||||
}
|
||||
|
||||
stage->setEffect(SkNEW_ARGS(GrRadial2Gradient, (context, *this, matrix, fTileMode)))->unref();
|
||||
return true;
|
||||
return SkNEW_ARGS(GrRadial2Gradient, (context, *this, matrix, fTileMode));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool SkTwoPointRadialGradient::asNewEffect(GrContext*, GrEffectStage*) const {
|
||||
GrEffect* SkTwoPointRadialGradient::asNewEffect(GrContext* context, const SkPaint&) const {
|
||||
SkDEBUGFAIL("Should not call in GPU-less build");
|
||||
return false;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -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;
|
||||
|
@ -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<GrEffect> 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);
|
||||
// We still don't have SkColorShader::asNewEffect() implemented.
|
||||
SkShader::GradientInfo info;
|
||||
SkColor color;
|
||||
|
||||
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;
|
||||
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);
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
Loading…
Reference in New Issue
Block a user