Improve handling of FF vertex array state

R=robertphillips@google.com, jvanverth@google.com

Author: bsalomon@google.com

Review URL: https://chromiumcodereview.appspot.com/23542013

git-svn-id: http://skia.googlecode.com/svn/trunk@11154 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/gl/GrGLVertexArray.h b/src/gpu/gl/GrGLVertexArray.h
index 7352caf..5cc7b5f 100644
--- a/src/gpu/gl/GrGLVertexArray.h
+++ b/src/gpu/gl/GrGLVertexArray.h
@@ -49,7 +49,12 @@
  */
 class GrGLAttribArrayState {
 public:
-    explicit GrGLAttribArrayState(int arrayCount = 0) { this->resize(arrayCount); }
+    explicit GrGLAttribArrayState(int arrayCount = 0) {
+        this->resize(arrayCount);
+        // glVertexPointer doesn't have a normalization param.
+        fFixedFunctionVertexArray.fNormalized = false;
+        fUnusedFixedFunctionArraysDisabled = false;
+    }
 
     void resize(int newCount) {
         fAttribArrayStates.resize_back(newCount);
@@ -72,17 +77,26 @@
              GrGLsizei stride,
              GrGLvoid* offset);
 
+    void setFixedFunctionVertexArray(const GrGpuGL*,
+                                     GrGLVertexBuffer*,
+                                     GrGLint size,
+                                     GrGLenum type,
+                                     GrGLsizei stride,
+                                     GrGLvoid* offset);
+
     /**
      * This function disables vertex attribs not present in the mask. It is assumed that the
      * GrGLAttribArrayState is tracking the state of the currently bound vertex array object.
      */
-    void disableUnusedAttribArrays(const GrGpuGL*, uint64_t usedAttribArrayMask);
+    void disableUnusedArrays(const GrGpuGL*, uint64_t usedAttribArrayMask, bool usingFFVertexArray);
 
     void invalidate() {
         int count = fAttribArrayStates.count();
         for (int i = 0; i < count; ++i) {
             fAttribArrayStates[i].invalidate();
         }
+        fFixedFunctionVertexArray.invalidate();
+        fUnusedFixedFunctionArraysDisabled = false;
     }
 
     void notifyVertexBufferDelete(GrGLuint id) {
@@ -93,6 +107,10 @@
                 fAttribArrayStates[i].invalidate();
             }
         }
+        if (fFixedFunctionVertexArray.fAttribPointerIsValid &&
+            id == fFixedFunctionVertexArray.fVertexBufferID) {
+            fFixedFunctionVertexArray.invalidate();
+        }
     }
 
     /**
@@ -122,6 +140,13 @@
     };
 
     SkSTArray<16, AttribArrayState, true> fAttribArrayStates;
+
+    // Tracks the array specified by glVertexPointer.
+    AttribArrayState fFixedFunctionVertexArray;
+
+    // Tracks whether we've disabled the other fixed function arrays that we don't
+    // use (e.g. glNormalPointer).
+    bool fUnusedFixedFunctionArraysDisabled;
 };
 
 /**