Add support for clipstack to Gr. GrClip is now a list of rects and paths with set operations to combine them. The stencil buffer is used to perform the set operations to put the clip into the stencil buffer. Building Gr's clip from Skia's clipStack is currently disabled due to the fact that Skia's clipStack is relative to the root layer not the current layer. This will be fixed in a subsequent CL.

git-svn-id: http://skia.googlecode.com/svn/trunk@878 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/src/GrInOrderDrawBuffer.cpp b/gpu/src/GrInOrderDrawBuffer.cpp
index 68590fc..a249364 100644
--- a/gpu/src/GrInOrderDrawBuffer.cpp
+++ b/gpu/src/GrInOrderDrawBuffer.cpp
@@ -67,17 +67,17 @@
         fCurrQuad = 0;
         fMaxQuads = (NULL == indexBuffer) ? 0 : indexBuffer->maxQuads();
     } else {
-        GrAssert((NULL == indexBuffer && 0 == fMaxQuads) || 
+        GrAssert((NULL == indexBuffer && 0 == fMaxQuads) ||
                  (indexBuffer->maxQuads() == fMaxQuads));
     }
 }
 
-void GrInOrderDrawBuffer::drawRect(const GrRect& rect, 
+void GrInOrderDrawBuffer::drawRect(const GrRect& rect,
                                    const GrMatrix* matrix,
                                    StageBitfield stageEnableBitfield,
                                    const GrRect* srcRects[],
                                    const GrMatrix* srcMatrices[]) {
-    
+
     GrAssert(!(NULL == fQuadIndexBuffer && fCurrQuad));
     GrAssert(!(fDraws.empty() && fCurrQuad));
     GrAssert(!(0 != fMaxQuads && NULL == fQuadIndexBuffer));
@@ -85,7 +85,7 @@
     // if we have a quad IB then either append to the previous run of
     // rects or start a new run
     if (fMaxQuads) {
-        
+
         bool appendToPreviousDraw = false;
         GrVertexLayout layout = GetRectVertexLayout(stageEnableBitfield, srcRects);
         AutoReleaseGeometry geo(this, layout, 4, 0);
@@ -103,10 +103,14 @@
         // the rect.
         bool disabledClip = false;
         if (this->isClipState() && fClip.isRect()) {
-            GrRect clipRect = GrRect(*fClip.getRects());
+
+            // single rect clip should have bounds
+            GrAssert(fClip.hasBounds());
+
+            GrRect clipRect = GrRect(fClip.getBounds());
             // If the clip rect touches the edge of the viewport, extended it
             // out (close) to infinity to avoid bogus intersections.
-            // We might consider a more exact clip to viewport if this 
+            // We might consider a more exact clip to viewport if this
             // conservative test fails.
             const GrRenderTarget* target = this->getRenderTarget();
             if (0 >= clipRect.fLeft) {
@@ -135,11 +139,11 @@
                 disabledClip = true;
             }
         }
-        if (!needsNewClip() && !needsNewState() && fCurrQuad > 0 && 
+        if (!needsNewClip() && !needsNewState() && fCurrQuad > 0 &&
             fCurrQuad < fMaxQuads && layout == fLastRectVertexLayout) {
 
             int vsize = VertexSize(layout);
-        
+
             Draw& lastDraw = fDraws.back();
 
             GrAssert(lastDraw.fIndexBuffer == fQuadIndexBuffer);
@@ -500,7 +504,7 @@
     }
     this->saveCurrentDrawState(&fStates.push_back());
  }
- 
+
 bool GrInOrderDrawBuffer::needsNewClip() const {
    if (fCurrDrawState.fFlagBits & kClip_StateBit) {
        if (fClips.empty() || (fClipSet && fClips.back() != fClip)) {
@@ -509,12 +513,12 @@
     }
     return false;
 }
- 
+
 void GrInOrderDrawBuffer::pushClip() {
     fClips.push_back() = fClip;
     fClipSet = false;
 }
- 
+
 void GrInOrderDrawBuffer::clipWillBeSet(const GrClip& newClip)  {
     fClipSet = true;
 }