GrTexture* getTexture(int i) const {
GrAssert((unsigned)i < kMaxTextures);
+ //if (this->getTextureSampler(i).getCustomStage()) {
+ //return this->getTextureSampler(i).getCustomStage()->texture(i);
+ //}
return fTextures[i];
}
GrTexture* getMask(int i) const {
GrAssert((unsigned)i < kMaxMasks);
+ //if (this->getMaskSampler(i).getCustomStage()) {
+ //return this->getMaskSampler(i).getCustomStage()->texture(i);
+ //}
return fMaskTextures[i];
}
GrSamplerState::kNearest_Filter,
mat);
- drawState->setTexture(maskStage, result);
+ drawState->createTextureEffect(maskStage, result);
}
bool path_needs_SW_renderer(GrContext* context,
GrMatrix sampleM;
sampleM.setIDiv(texture->width(), texture->height());
- drawState->setTexture(0, texture);
drawState->sampler(0)->reset(GrSamplerState::kClamp_WrapMode,
GrSamplerState::kNearest_Filter,
sampleM);
+ drawState->createTextureEffect(0, texture);
GrRect rect = GrRect::MakeWH(SkIntToScalar(target->width()),
SkIntToScalar(target->height()));
GrDrawTarget::kReset_ASRInit);
GrDrawState* drawState = fGpu->drawState();
drawState->setRenderTarget(texture->asRenderTarget());
- drawState->sampler(0)->setCustomStage(SkNEW_ARGS(GrSingleTextureEffect,
- (clampEntry.texture())))->unref();
+ drawState->createTextureEffect(0, clampEntry.texture());
GrSamplerState::Filter filter;
// if filtering is not desired then we want to ensure all
matrix.postIDiv(src->width(), src->height());
drawState->sampler(0)->reset(matrix);
drawState->sampler(0)->setRAndBSwap(swapRAndB);
- drawState->sampler(0)->setCustomStage(SkNEW_ARGS(GrSingleTextureEffect, (src)))->unref();
+ drawState->createTextureEffect(0, src);
GrRect rect;
rect.setXYWH(0, 0, SK_Scalar1 * width, SK_Scalar1 * height);
fGpu->drawSimpleRect(rect, NULL);
GrMatrix sampleM;
sampleM.setIDiv(src->width(), src->height());
drawState->sampler(0)->reset(sampleM);
- drawState->sampler(0)->setCustomStage(SkNEW_ARGS(GrSingleTextureEffect, (src)))->unref();
+ drawState->createTextureEffect(0, src);
SkRect rect = SkRect::MakeXYWH(0, 0,
SK_Scalar1 * src->width(),
SK_Scalar1 * src->height());
drawState->sampler(0)->reset(GrSamplerState::kClamp_WrapMode,
GrSamplerState::kNearest_Filter,
matrix);
- drawState->sampler(0)->setCustomStage(SkNEW_ARGS(GrSingleTextureEffect, (texture)))->unref();
+ drawState->createTextureEffect(0, texture);
drawState->sampler(0)->setRAndBSwap(swapRAndB);
static const GrVertexLayout layout = 0;
#include "GrStencil.h"
#include "GrTexture.h"
#include "GrRenderTarget.h"
+#include "effects/GrSingleTextureEffect.h"
#include "SkXfermode.h"
*
* @param texture The texture to set. Can be NULL though there is no
* advantage to settings a NULL texture if doing non-textured drawing
+ *
+ * @deprecated
*/
void setTexture(int stage, GrTexture* texture) {
GrAssert((unsigned)stage < kNumStages);
GrSafeAssign(fTextures[stage], texture);
}
+ /**
+ * Creates a GrSingleTextureEffect.
+ *
+ * Replacement for setTexture.
+ */
+ void createTextureEffect(int stage, GrTexture* texture) {
+ GrAssert(!this->getSampler(stage).getCustomStage());
+ this->sampler(stage)->setCustomStage(
+ SkNEW_ARGS(GrSingleTextureEffect, (texture)))->unref();
+ }
+
/**
* Retrieves the currently set texture.
*
kPathMaskStage = GrPaint::kTotalStages,
};
GrAssert(!drawState->isStageEnabled(kPathMaskStage));
- drawState->setTexture(kPathMaskStage, texture);
drawState->sampler(kPathMaskStage)->reset();
+ drawState->createTextureEffect(kPathMaskStage, texture);
GrScalar w = GrIntToScalar(rect.width());
GrScalar h = GrIntToScalar(rect.height());
GrRect maskRect = GrRect::MakeWH(w / texture->width(),
GrAssert(GrIsALIGN4(fCurrVertex));
GrAssert(fCurrTexture);
- drawState->setTexture(kGlyphMaskStage, fCurrTexture);
+ drawState->createTextureEffect(kGlyphMaskStage, fCurrTexture);
if (!GrPixelConfigIsAlphaOnly(fCurrTexture->config())) {
if (kOne_GrBlendCoeff != fPaint.fSrcBlendCoeff ||
bool SkGpuDevice::bindDeviceAsTexture(GrPaint* paint) {
if (NULL != fTexture) {
+ // FIXME: cannot use GrSingleTextureEffect here: fails
+ // assert in line 1617: null != devTex; generalizing GrPaint::getTexture()
+ // to grab textures off of GrCustomStages breaks gms in various ways -
+ // particularly since table color filter requires multiple textures
paint->setTexture(kBitmapTextureIdx, fTexture);
+ //paint->textureSampler(kBitmapTextureIdx)->setCustomStage(
+ //SkNEW_ARGS(GrSingleTextureEffect, (fTexture)))->unref();
return true;
}
return false;
GrAssert(!constantColor);
} else {
grPaint->fColor = SkColor2GrColor(skPaint.getColor());
- grPaint->setTexture(kShaderTextureIdx, NULL);
+ GrAssert(NULL == grPaint->getTexture(kShaderTextureIdx));
}
SkColorFilter* colorFilter = skPaint.getColorFilter();
SkColor color;
} else {
sampler->setFilter(GrSamplerState::kNearest_Filter);
}
- // TODO - once we have a trivial GrCustomStage for texture drawing,
- // create that here & get rid of the paint's texture
- grPaint->setTexture(kShaderTextureIdx, texture);
+ sampler->setCustomStage(SkNEW_ARGS(GrSingleTextureEffect, (texture)))->unref();
break;
}
sampler->setWrapX(sk_tile_mode_to_grwrap(tileModes[0]));
pathTexture->height());
// Blend pathTexture over blurTexture.
context->setRenderTarget(blurTexture->asRenderTarget());
- paint.setTexture(0, pathTexture);
+ paint.textureSampler(0)->setCustomStage(SkNEW_ARGS
+ (GrSingleTextureEffect, (pathTexture)))->unref();
if (SkMaskFilter::kInner_BlurType == blurType) {
// inner: dst = dst * src
paint.fSrcBlendCoeff = kDC_GrBlendCoeff;
return;
}
- grPaint->setTexture(kBitmapTextureIdx, texture);
+ grPaint->textureSampler(kBitmapTextureIdx)->setCustomStage(SkNEW_ARGS
+ (GrSingleTextureEffect, (texture)))->unref();
GrRect dstRect = SkRect::MakeWH(GrIntToScalar(srcRect.width()),
GrIntToScalar(srcRect.height()));
GrTexture* texture;
sampler->reset();
SkAutoCachedTexture act(this, bitmap, sampler, &texture);
- grPaint.setTexture(kBitmapTextureIdx, texture);
+ grPaint.textureSampler(kBitmapTextureIdx)->setCustomStage(SkNEW_ARGS
+ (GrSingleTextureEffect, (texture)))->unref();
SkImageFilter* filter = paint.getImageFilter();
if (NULL != filter) {
GrTexture* filteredTexture = filter_texture(fContext, texture, filter,
GrRect::MakeWH(SkIntToScalar(w), SkIntToScalar(h)));
if (filteredTexture) {
- grPaint.setTexture(kBitmapTextureIdx, filteredTexture);
+ grPaint.textureSampler(kBitmapTextureIdx)->setCustomStage(SkNEW_ARGS
+ (GrSingleTextureEffect, (filteredTexture)))->unref();
texture = filteredTexture;
filteredTexture->unref();
}
GrTexture* filteredTexture = filter_texture(fContext, devTex, filter,
rect);
if (filteredTexture) {
- grPaint.setTexture(kBitmapTextureIdx, filteredTexture);
+ grPaint.textureSampler(kBitmapTextureIdx)->setCustomStage(SkNEW_ARGS
+ (GrSingleTextureEffect, (filteredTexture)))->unref();
devTex = filteredTexture;
filteredTexture->unref();
}