Add GrDrawTarget::drawIndexedInstance, use in default text context.

Review URL: http://codereview.appspot.com/5848064/



git-svn-id: http://skia.googlecode.com/svn/trunk@3444 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrInOrderDrawBuffer.h b/src/gpu/GrInOrderDrawBuffer.h
index b802f96..a0880d2 100644
--- a/src/gpu/GrInOrderDrawBuffer.h
+++ b/src/gpu/GrInOrderDrawBuffer.h
@@ -109,6 +109,12 @@
                           const GrRect* srcRects[] = NULL,
                           const GrMatrix* srcMatrices[] = NULL) SK_OVERRIDE;
 
+    virtual void drawIndexedInstances(GrPrimitiveType type,
+                                      int instanceCount,
+                                      int verticesPerInstance,
+                                      int indicesPerInstance)
+                                      SK_OVERRIDE;
+
     virtual bool geometryHints(GrVertexLayout vertexLayout,
                                int* vertexCount,
                                int* indexCount) const SK_OVERRIDE;
@@ -116,13 +122,10 @@
     virtual void clear(const GrIRect* rect, GrColor color) SK_OVERRIDE;
 
 protected:
-
     virtual void willReserveVertexAndIndexSpace(GrVertexLayout vertexLayout,
                                                 int vertexCount,
                                                 int indexCount) SK_OVERRIDE;
-    
 private:
-
     struct Draw {
         GrPrimitiveType         fPrimitiveType;
         int                     fStartVertex;
@@ -172,7 +175,11 @@
 
     void pushState();
     void pushClip();
-    
+
+    // call this to invalidate the tracking data that is used to concatenate 
+    // multiple draws into a single draw.
+    void resetDrawTracking();
+
     enum {
         kDrawPreallocCnt         = 8,
         kStatePreallocCnt        = 8,
@@ -190,14 +197,25 @@
 
     bool                            fClipSet;
 
+    GrVertexBufferAllocPool&        fVertexPool;
+
+    GrIndexBufferAllocPool&         fIndexPool;
+
+    // these are used to attempt to concatenate drawRect calls
     GrVertexLayout                  fLastRectVertexLayout;
     const GrIndexBuffer*            fQuadIndexBuffer;
     int                             fMaxQuads;
     int                             fCurrQuad;
 
-    GrVertexBufferAllocPool&        fVertexPool;
-
-    GrIndexBufferAllocPool&         fIndexPool;
+    // bookkeeping to attempt to concantenate drawIndexedInstances calls
+    struct {
+        int            fVerticesPerInstance;
+        int            fIndicesPerInstance;
+        void reset() {
+            fVerticesPerInstance = 0;
+            fIndicesPerInstance = 0;
+        }
+    } fInstancedDrawTracker;
 
     struct GeometryPoolState {
         const GrVertexBuffer*           fPoolVertexBuffer;