Add support for vertex data rendered from CPU arrays.
Review URL: https://codereview.appspot.com/7380044

git-svn-id: http://skia.googlecode.com/svn/trunk@7807 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrBufferAllocPool.cpp b/src/gpu/GrBufferAllocPool.cpp
index ec8a9c9..db9b2c8 100644
--- a/src/gpu/GrBufferAllocPool.cpp
+++ b/src/gpu/GrBufferAllocPool.cpp
@@ -296,9 +296,21 @@
 
     GrAssert(NULL == fBufferPtr);
 
-    if (fGpu->getCaps().bufferLockSupport() &&
-        size > GR_GEOM_BUFFER_LOCK_THRESHOLD &&
-        (!fFrequentResetHint || requestSize > GR_GEOM_BUFFER_LOCK_THRESHOLD)) {
+    // If the buffer is CPU-backed we lock it because it is free to do so and saves a copy.
+    // Otherwise when buffer locking is supported:
+    //      a) If the frequently reset hint is set we only lock when the requested size meets a
+    //      threshold (since we don't expect it is likely that we will see more vertex data)
+    //      b) If the hint is not set we lock if the buffer size is greater than the threshold.
+    bool attemptLock = block.fBuffer->isCPUBacked();
+    if (!attemptLock && fGpu->getCaps().bufferLockSupport()) {
+        if (fFrequentResetHint) {
+            attemptLock = requestSize > GR_GEOM_BUFFER_LOCK_THRESHOLD;
+        } else {
+            attemptLock = size > GR_GEOM_BUFFER_LOCK_THRESHOLD;
+        }
+    }
+
+    if (attemptLock) {
         fBufferPtr = block.fBuffer->lock();
     }