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
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index a1e4161..149359f 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -618,12 +618,6 @@
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 @@
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 @@
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 @@
SkTSwap(srcTexture, dstTexture);
}
this->setRenderTarget(oldRenderTarget);
- this->setClip(oldClip);
return srcTexture;
}
@@ -1949,12 +1940,11 @@
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);
+ AutoMatrix avm(this, GrMatrix::I());
+
+ AutoClip acs(this, GrRect::MakeWH(SkIntToScalar(srcTexture->width()),
+ SkIntToScalar(srcTexture->height())));
if (radius.fWidth > 0) {
this->setRenderTarget(temp1->asRenderTarget());
@@ -1975,7 +1965,6 @@
srcTexture = temp2;
}
this->setRenderTarget(oldRenderTarget);
- this->setClip(oldClip);
return srcTexture;
}