diff options
author | 2012-07-26 19:39:06 +0000 | |
---|---|---|
committer | 2012-07-26 19:39:06 +0000 | |
commit | 1c31f633232df572f89a3bc1b0fee3e46d22cb5b (patch) | |
tree | a2e615f86b0a4c53009f60fc9a27b5c6b79d012e /src | |
parent | ea5488b9655fc7d71345c3a823de85f8b74e3279 (diff) |
Remove texture/mask setters on GrPaint
Review URL: http://codereview.appspot.com/6446052/
git-svn-id: http://skia.googlecode.com/svn/trunk@4790 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrContext.cpp | 6 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 29 |
2 files changed, 13 insertions, 22 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index e14456a966..8e3fb09a46 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -1551,9 +1551,8 @@ void GrContext::setPaint(const GrPaint& paint) { for (int i = 0; i < GrPaint::kMaxTextures; ++i) { int s = i + GrPaint::kFirstTextureStage; - ASSERT_OWNED_RESOURCE(paint.getTexture(i)); if (paint.isTextureStageEnabled(i)) { - fDrawState->setTexture(s, paint.getTexture(i)); + fDrawState->setTexture(s, NULL); *fDrawState->sampler(s) = paint.getTextureSampler(i); } } @@ -1562,9 +1561,8 @@ void GrContext::setPaint(const GrPaint& paint) { for (int i = 0; i < GrPaint::kMaxMasks; ++i) { int s = i + GrPaint::kFirstMaskStage; - ASSERT_OWNED_RESOURCE(paint.getMask(i)); if (paint.isMaskStageEnabled(i)) { - fDrawState->setTexture(s, paint.getMask(i)); + fDrawState->setTexture(s, NULL); *fDrawState->sampler(s) = paint.getMaskSampler(i); } } diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index cb33d7687a..1256285192 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -482,13 +482,8 @@ SkGpuRenderTarget* SkGpuDevice::accessRenderTarget() { 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(); + paint->textureSampler(kBitmapTextureIdx)->setCustomStage( + SkNEW_ARGS(GrSingleTextureEffect, (fTexture)))->unref(); return true; } return false; @@ -549,7 +544,7 @@ inline bool skPaint2GrPaintNoShader(SkGpuDevice* dev, GrAssert(!constantColor); } else { grPaint->fColor = SkColor2GrColor(skPaint.getColor()); - GrAssert(NULL == grPaint->getTexture(kShaderTextureIdx)); + GrAssert(!grPaint->isTextureStageEnabled(kShaderTextureIdx)); } SkColorFilter* colorFilter = skPaint.getColorFilter(); SkColor color; @@ -971,9 +966,9 @@ bool drawWithGPUMaskFilter(GrContext* context, const SkPath& path, static const int MASK_IDX = GrPaint::kMaxMasks - 1; // we assume the last mask index is available for use GrAssert(!grp->isMaskStageEnabled(MASK_IDX)); - grp->setMask(MASK_IDX, blurTexture); grp->maskSampler(MASK_IDX)->reset(); - + grp->maskSampler(MASK_IDX)->setCustomStage( + SkNEW_ARGS(GrSingleTextureEffect, (blurTexture)))->unref(); grp->maskSampler(MASK_IDX)->matrix()->setTranslate(-finalRect.fLeft, -finalRect.fTop); grp->maskSampler(MASK_IDX)->matrix()->postIDiv(blurTexture->width(), @@ -1034,9 +1029,9 @@ bool drawWithMaskFilter(GrContext* context, const SkPath& path, static const int MASK_IDX = GrPaint::kMaxMasks - 1; // we assume the last mask index is available for use GrAssert(!grp->isMaskStageEnabled(MASK_IDX)); - grp->setMask(MASK_IDX, texture); grp->maskSampler(MASK_IDX)->reset(); - + grp->maskSampler(MASK_IDX)->setCustomStage( + SkNEW_ARGS(GrSingleTextureEffect, (texture)))->unref(); GrRect d; d.setLTRB(GrIntToScalar(dstM.fBounds.fLeft), GrIntToScalar(dstM.fBounds.fTop), @@ -1628,25 +1623,23 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkDevice* device, GrPaint grPaint; SkAutoCachedTexture colorLutTexture; + grPaint.textureSampler(kBitmapTextureIdx)->reset(); if (!dev->bindDeviceAsTexture(&grPaint) || !skPaint2GrPaintNoShader(this, paint, true, false, &colorLutTexture, &grPaint)) { return; } - GrTexture* devTex = grPaint.getTexture(0); + GrTexture* devTex = grPaint.getTextureSampler(kBitmapTextureIdx).getCustomStage()->texture(0); SkASSERT(NULL != devTex); SkImageFilter* filter = paint.getImageFilter(); - grPaint.textureSampler(kBitmapTextureIdx)->reset(); if (NULL != filter) { - GrRect rect = GrRect::MakeWH(SkIntToScalar(devTex->width()), + GrRect rect = GrRect::MakeWH(SkIntToScalar(devTex->width()), SkIntToScalar(devTex->height())); - GrTexture* filteredTexture = filter_texture(fContext, devTex, filter, - rect); + GrTexture* filteredTexture = filter_texture(fContext, devTex, filter, rect); if (filteredTexture) { grPaint.textureSampler(kBitmapTextureIdx)->setCustomStage(SkNEW_ARGS (GrSingleTextureEffect, (filteredTexture)))->unref(); - grPaint.setTexture(kBitmapTextureIdx, NULL); devTex = filteredTexture; filteredTexture->unref(); } |