When we're not using the NULL buffer data hint update with glBufferData rather than glBufferSubData.

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




git-svn-id: http://skia.googlecode.com/svn/trunk@2443 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/src/GrGLVertexBuffer.cpp b/gpu/src/GrGLVertexBuffer.cpp
index c542602..33c1e7e 100644
--- a/gpu/src/GrGLVertexBuffer.cpp
+++ b/gpu/src/GrGLVertexBuffer.cpp
@@ -101,28 +101,26 @@
     }
     this->bind();
     GrGLenum usage = dynamic() ? GR_GL_DYNAMIC_DRAW : GR_GL_STATIC_DRAW;
+#if !GR_GL_USE_BUFFER_DATA_NULL_HINT
+    // Note that we're cheating on the size here. Currently no methods
+    // allow a partial update that preserves contents of non-updated
+    // portions of the buffer (and lock() does a glBufferData(..size, NULL..))
+    GL_CALL(BufferData(GR_GL_ARRAY_BUFFER, srcSizeInBytes, src, usage));
+#else
     if (this->sizeInBytes() == srcSizeInBytes) {
         GL_CALL(BufferData(GR_GL_ARRAY_BUFFER, srcSizeInBytes, src, usage));
     } else {
-#if GR_GL_USE_BUFFER_DATA_NULL_HINT
+        // Before we call glBufferSubData we give the driver a hint using
+        // glBufferData with NULL. This makes the old buffer contents
+        // inaccessible to future draws. The GPU may still be processing draws
+        // that reference the old contents. With this hint it can assign a
+        // different allocation for the new contents to avoid flushing the gpu
+        // past draws consuming the old contents.
         GL_CALL(BufferData(GR_GL_ARRAY_BUFFER, 
                            this->sizeInBytes(), NULL, usage));
-#endif
         GL_CALL(BufferSubData(GR_GL_ARRAY_BUFFER, 0, srcSizeInBytes, src));
     }
-    return true;
-}
-
-bool GrGLVertexBuffer::updateSubData(const void* src,
-                                     size_t srcSizeInBytes,
-                                     size_t offset) {
-    GrAssert(fBufferID);
-    GrAssert(!isLocked());
-    if (srcSizeInBytes + offset > this->sizeInBytes()) {
-        return false;
-    }
-    this->bind();
-    GL_CALL(BufferSubData(GR_GL_ARRAY_BUFFER, offset, srcSizeInBytes, src));
+#endif
     return true;
 }