diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-11 20:57:46 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-11 20:57:46 +0000 |
commit | 56c79b10377e358b8092d9c6ab3e1aacf2cd60e5 (patch) | |
tree | 0945f3dd6dd3a43c1d0fc9c5c08257bbc8996cdc /src | |
parent | eb311845c1b412a9a7d851444a70ec24ab60fb2c (diff) |
Added GrContext::AutoClipStack to encapsulate setting\resetting of clip stack
http://codereview.appspot.com/6343097/
git-svn-id: http://skia.googlecode.com/svn/trunk@4558 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrContext.cpp | 19 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 6 |
2 files changed, 5 insertions, 20 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index a1e41618ed..149359f83e 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -618,12 +618,6 @@ void GrContext::setClip(const GrClip& clip) { fDrawState->enableState(GrDrawState::kClip_StateBit); } -void GrContext::setClip(const GrIRect& rect) { - GrClip clip; - clip.setFromIRect(rect); - fGpu->setClip(clip); -} - //////////////////////////////////////////////////////////////////////////////// void GrContext::clear(const GrIRect* rect, @@ -1822,7 +1816,6 @@ GrTexture* GrContext::gaussianBlur(GrTexture* srcTexture, float sigmaX, float sigmaY) { ASSERT_OWNED_RESOURCE(srcTexture); GrRenderTarget* oldRenderTarget = this->getRenderTarget(); - GrClip oldClip = this->getClip(); GrTexture* origTexture = srcTexture; AutoMatrix avm(this, GrMatrix::I()); SkIRect clearRect; @@ -1837,8 +1830,7 @@ GrTexture* GrContext::gaussianBlur(GrTexture* srcTexture, scale_rect(&srcRect, static_cast<float>(scaleFactorX), static_cast<float>(scaleFactorY)); - GrClip newClip(srcRect); - this->setClip(newClip); + AutoClip acs(this, srcRect); GrAssert(kBGRA_8888_PM_GrPixelConfig == srcTexture->config() || kRGBA_8888_PM_GrPixelConfig == srcTexture->config() || @@ -1938,7 +1930,6 @@ GrTexture* GrContext::gaussianBlur(GrTexture* srcTexture, SkTSwap(srcTexture, dstTexture); } this->setRenderTarget(oldRenderTarget); - this->setClip(oldClip); return srcTexture; } @@ -1949,12 +1940,11 @@ GrTexture* GrContext::applyMorphology(GrTexture* srcTexture, SkISize radius) { ASSERT_OWNED_RESOURCE(srcTexture); GrRenderTarget* oldRenderTarget = this->getRenderTarget(); + AutoMatrix avm(this, GrMatrix::I()); - GrClip oldClip = this->getClip(); - GrClip newClip(GrRect::MakeWH(SkIntToScalar(srcTexture->width()), - SkIntToScalar(srcTexture->height()))); - this->setClip(newClip); + AutoClip acs(this, GrRect::MakeWH(SkIntToScalar(srcTexture->width()), + SkIntToScalar(srcTexture->height()))); if (radius.fWidth > 0) { this->setRenderTarget(temp1->asRenderTarget()); @@ -1975,7 +1965,6 @@ GrTexture* GrContext::applyMorphology(GrTexture* srcTexture, srcTexture = temp2; } this->setRenderTarget(oldRenderTarget); - this->setClip(oldClip); return srcTexture; } diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index fc77c47091..2a2bbcdc37 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -1445,10 +1445,7 @@ void apply_custom_stage(GrContext* context, SkASSERT(srcTexture && srcTexture->getContext() == context); GrContext::AutoMatrix avm(context, GrMatrix::I()); GrContext::AutoRenderTarget art(context, dstTexture->asRenderTarget()); - GrClip oldClip = context->getClip(); - - GrClip newClip(rect); - context->setClip(newClip); + GrContext::AutoClip acs(context, rect); GrMatrix sampleM; sampleM.setIDiv(srcTexture->width(), srcTexture->height()); @@ -1459,7 +1456,6 @@ void apply_custom_stage(GrContext* context, paint.textureSampler(0)->setCustomStage(stage); paint.setTexture(0, srcTexture); context->drawRect(paint, rect); - context->setClip(oldClip); } }; |