Make GrDrawState a real class with getters and setters
Review URL: http://codereview.appspot.com/5448119/
git-svn-id: http://skia.googlecode.com/svn/trunk@2830 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 1583630..4c0594b 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -185,10 +185,10 @@
// We used to clear down in the GL subclass using a special purpose
// FBO. But iOS doesn't allow a stencil-only FBO. It reports unsupported
// FBO status.
- GrRenderTarget* oldRT = fCurrDrawState.fRenderTarget;
- fCurrDrawState.fRenderTarget = rt;
+ GrRenderTarget* oldRT = this->getRenderTarget();
+ this->setRenderTarget(rt);
this->clearStencil();
- fCurrDrawState.fRenderTarget = oldRT;
+ this->setRenderTarget(oldRT);
return true;
} else {
return false;
@@ -530,16 +530,17 @@
const GrIRect* r = NULL;
GrIRect clipRect;
- // GrDrawTarget should have filtered this for us
- GrAssert(NULL != fCurrDrawState.fRenderTarget);
+ GrRenderTarget* rt = this->getRenderTarget();
- if (fCurrDrawState.fFlagBits & kClip_StateBit) {
- GrRenderTarget& rt = *fCurrDrawState.fRenderTarget;
+ // GrDrawTarget should have filtered this for us
+ GrAssert(NULL != rt);
+
+ if (this->getDrawState().isClipState()) {
GrRect bounds;
GrRect rtRect;
rtRect.setLTRB(0, 0,
- GrIntToScalar(rt.width()), GrIntToScalar(rt.height()));
+ GrIntToScalar(rt->width()), GrIntToScalar(rt->height()));
if (fClip.hasConservativeBounds()) {
bounds = fClip.getConservativeBounds();
if (!bounds.intersect(rtRect)) {
@@ -560,15 +561,17 @@
!bounds.isEmpty();
// TODO: dynamically attach a SB when needed.
- GrStencilBuffer* stencilBuffer = rt.getStencilBuffer();
+ GrStencilBuffer* stencilBuffer = rt->getStencilBuffer();
if (fClipInStencil && NULL == stencilBuffer) {
return false;
}
- if (fClipInStencil &&
- stencilBuffer->mustRenderClip(fClip, rt.width(), rt.height())) {
+ GrDrawState* drawState = this->drawState();
- stencilBuffer->setLastClip(fClip, rt.width(), rt.height());
+ if (fClipInStencil &&
+ stencilBuffer->mustRenderClip(fClip, rt->width(), rt->height())) {
+
+ stencilBuffer->setLastClip(fClip, rt->width(), rt->height());
// we set the current clip to the bounds so that our recursive
// draws are scissored to them. We use the copy of the complex clip
@@ -583,9 +586,9 @@
this->setViewMatrix(GrMatrix::I());
this->flushScissor(NULL);
#if !VISUALIZE_COMPLEX_CLIP
- this->enableState(kNoColorWrites_StateBit);
+ drawState->enableState(GrDrawState::kNoColorWrites_StateBit);
#else
- this->disableState(kNoColorWrites_StateBit);
+ drawState->disableState(GrDrawState::kNoColorWrites_StateBit);
#endif
int count = clip.getElementCount();
int clipBit = stencilBuffer->bits();
@@ -606,7 +609,7 @@
GrPathFill fill;
bool fillInverted;
// enabled at bottom of loop
- this->disableState(kModifyStencilClip_StateBit);
+ drawState->disableState(kModifyStencilClip_StateBit);
bool canRenderDirectToStencil; // can the clip element be drawn
// directly to the stencil buffer
@@ -664,11 +667,11 @@
};
SET_RANDOM_COLOR
if (kRect_ClipType == clip.getElementType(c)) {
- this->setStencil(gDrawToStencil);
+ drawState->setStencil(gDrawToStencil);
this->drawSimpleRect(clip.getRect(c), NULL, 0);
} else {
if (canRenderDirectToStencil) {
- this->setStencil(gDrawToStencil);
+ drawState->setStencil(gDrawToStencil);
pr->drawPath(0);
} else {
pr->drawPathToStencil();
@@ -678,9 +681,9 @@
// now we modify the clip bit by rendering either the clip
// element directly or a bounding rect of the entire clip.
- this->enableState(kModifyStencilClip_StateBit);
+ drawState->enableState(kModifyStencilClip_StateBit);
for (int p = 0; p < passes; ++p) {
- this->setStencil(stencilSettings[p]);
+ drawState->setStencil(stencilSettings[p]);
if (canDrawDirectToClip) {
if (kRect_ClipType == clip.getElementType(c)) {
SET_RANDOM_COLOR