Remove GR_STATIC_RECT_VB

https://codereview.chromium.org/14367030/



git-svn-id: http://skia.googlecode.com/svn/trunk@8786 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 5ebe5b9..85c241a 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -853,30 +853,7 @@
         target->drawNonIndexed(primType, 0, vertCount);
     } else {
         // filled BW rect
-#if GR_STATIC_RECT_VB
-            const GrVertexBuffer* sqVB = fGpu->getUnitSquareVertexBuffer();
-            if (NULL == sqVB) {
-                GrPrintf("Failed to create static rect vb.\n");
-                return;
-            }
-
-            GrDrawState* drawState = target->drawState();
-            target->drawState()->setDefaultVertexAttribs();
-            target->setVertexSourceToBuffer(sqVB);
-            SkMatrix m;
-            m.setAll(rect.width(),    0,             rect.fLeft,
-                        0,            rect.height(), rect.fTop,
-                        0,            0,             SkMatrix::I()[8]);
-
-            if (NULL != matrix) {
-                m.postConcat(*matrix);
-            }
-            GrDrawState::AutoViewMatrixRestore avmr(drawState, m);
-
-            target->drawNonIndexed(kTriangleFan_GrPrimitiveType, 0, 4);
-#else
-            target->drawSimpleRect(rect, matrix);
-#endif
+        target->drawSimpleRect(rect, matrix);
     }
 }
 
@@ -890,46 +867,7 @@
     GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW);
     GrDrawState::AutoStageDisable atr(fDrawState);
 
-#if GR_STATIC_RECT_VB
-    GrDrawState* drawState = target->drawState();
-
-    SkMatrix m;
-
-    m.setAll(dstRect.width(), 0,                dstRect.fLeft,
-             0,               dstRect.height(), dstRect.fTop,
-             0,               0,                SkMatrix::I()[8]);
-    if (NULL != dstMatrix) {
-        m.postConcat(*dstMatrix);
-    }
-
-    // This code path plays a little fast and loose with the notion of local coords and coord
-    // change matrices in order to account for localRect and localMatrix. The unit square VB only
-    // has one set of coords. Rather than using AutoViewMatrixRestore we instead directly set concat
-    // with m and then call GrDrawState::localCoordChange() with a matrix that accounts for
-    // localRect and localMatrix. This code path is preventing some encapsulation in GrDrawState.
-    SkMatrix savedViewMatrix = drawState->getViewMatrix();
-    drawState->preConcatViewMatrix(m);
-
-    m.setAll(localRect.width(), 0,                localRect.fLeft,
-             0,               localRect.height(), localRect.fTop,
-             0,               0,                  SkMatrix::I()[8]);
-    if (NULL != localMatrix) {
-        m.postConcat(*localMatrix);
-    }
-    drawState->localCoordChange(m);
-
-    const GrVertexBuffer* sqVB = fGpu->getUnitSquareVertexBuffer();
-    if (NULL == sqVB) {
-        GrPrintf("Failed to create static rect vb.\n");
-        return;
-    }
-    drawState->setDefaultVertexAttribs();
-    target->setVertexSourceToBuffer(sqVB);
-    target->drawNonIndexed(kTriangleFan_GrPrimitiveType, 0, 4);
-    drawState->setViewMatrix(savedViewMatrix);
-#else
     target->drawRect(dstRect, dstMatrix, &localRect, localMatrix);
-#endif
 }
 
 void GrContext::drawVertices(const GrPaint& paint,
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 7fc2ab8..0c58430 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -34,7 +34,6 @@
     , fIndexPool(NULL)
     , fVertexPoolUseCnt(0)
     , fIndexPoolUseCnt(0)
-    , fUnitSquareVertexBuffer(NULL)
     , fQuadIndexBuffer(NULL)
     , fContextIsDirty(true) {
 
@@ -67,10 +66,7 @@
     }
 
     GrAssert(NULL == fQuadIndexBuffer || !fQuadIndexBuffer->isValid());
-    GrAssert(NULL == fUnitSquareVertexBuffer ||
-             !fUnitSquareVertexBuffer->isValid());
     GrSafeSetNull(fQuadIndexBuffer);
-    GrSafeSetNull(fUnitSquareVertexBuffer);
     delete fVertexPool;
     fVertexPool = NULL;
     delete fIndexPool;
@@ -86,10 +82,7 @@
     }
 
     GrAssert(NULL == fQuadIndexBuffer || !fQuadIndexBuffer->isValid());
-    GrAssert(NULL == fUnitSquareVertexBuffer ||
-             !fUnitSquareVertexBuffer->isValid());
     GrSafeSetNull(fQuadIndexBuffer);
-    GrSafeSetNull(fUnitSquareVertexBuffer);
     delete fVertexPool;
     fVertexPool = NULL;
     delete fIndexPool;
@@ -297,37 +290,6 @@
     return fQuadIndexBuffer;
 }
 
-const GrVertexBuffer* GrGpu::getUnitSquareVertexBuffer() const {
-    if (NULL == fUnitSquareVertexBuffer) {
-
-        static const GrPoint DATA[] = {
-            { 0,            0 },
-            { SK_Scalar1,   0 },
-            { SK_Scalar1,   SK_Scalar1 },
-            { 0,            SK_Scalar1 }
-#if 0
-            GrPoint(0,         0),
-            GrPoint(SK_Scalar1,0),
-            GrPoint(SK_Scalar1,SK_Scalar1),
-            GrPoint(0,         SK_Scalar1)
-#endif
-        };
-        static const size_t SIZE = sizeof(DATA);
-
-        GrGpu* me = const_cast<GrGpu*>(this);
-        fUnitSquareVertexBuffer = me->createVertexBuffer(SIZE, false);
-        if (NULL != fUnitSquareVertexBuffer) {
-            if (!fUnitSquareVertexBuffer->updateData(DATA, SIZE)) {
-                fUnitSquareVertexBuffer->unref();
-                fUnitSquareVertexBuffer = NULL;
-                GrCrash("Can't get vertices into buffer!");
-            }
-        }
-    }
-
-    return fUnitSquareVertexBuffer;
-}
-
 ////////////////////////////////////////////////////////////////////////////////
 
 bool GrGpu::setupClipAndFlushState(DrawType type, const GrDeviceCoordTexture* dstCopy) {
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index f55c6ad..656761b 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -140,13 +140,6 @@
     const GrIndexBuffer* getQuadIndexBuffer() const;
 
     /**
-     * Returns a vertex buffer with four position-only vertices [(0,0), (1,0),
-     * (1,1), (0,1)].
-     * @ return unit square vertex buffer
-     */
-    const GrVertexBuffer* getUnitSquareVertexBuffer() const;
-
-    /**
      * Resolves MSAA.
      */
     void resolveRenderTarget(GrRenderTarget* target);
@@ -528,7 +521,6 @@
     int                                                                 fVertexPoolUseCnt;
     int                                                                 fIndexPoolUseCnt;
     // these are mutable so they can be created on-demand
-    mutable GrVertexBuffer*                                             fUnitSquareVertexBuffer;
     mutable GrIndexBuffer*                                              fQuadIndexBuffer;
     bool                                                                fContextIsDirty;
     ResourceList                                                        fResourceList;