| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "GrGLBufferImpl.h" | 8 #include "GrGLBufferImpl.h" |
| 9 #include "GrGpuGL.h" | 9 #include "GrGpuGL.h" |
| 10 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 void GrGLBufferImpl::abandon() { | 51 void GrGLBufferImpl::abandon() { |
| 52 fDesc.fID = 0; | 52 fDesc.fID = 0; |
| 53 fLockPtr = NULL; | 53 fLockPtr = NULL; |
| 54 sk_free(fCPUData); | 54 sk_free(fCPUData); |
| 55 fCPUData = NULL; | 55 fCPUData = NULL; |
| 56 } | 56 } |
| 57 | 57 |
| 58 void GrGLBufferImpl::bind(GrGpuGL* gpu) const { | 58 void GrGLBufferImpl::bind(GrGpuGL* gpu) const { |
| 59 VALIDATE(); | 59 VALIDATE(); |
| 60 GL_CALL(gpu, BindBuffer(fBufferType, fDesc.fID)); | |
| 61 if (GR_GL_ARRAY_BUFFER == fBufferType) { | 60 if (GR_GL_ARRAY_BUFFER == fBufferType) { |
| 62 gpu->notifyVertexBufferBind(fDesc.fID); | 61 gpu->bindVertexBuffer(fDesc.fID); |
| 63 } else { | 62 } else { |
| 64 GrAssert(GR_GL_ELEMENT_ARRAY_BUFFER == fBufferType); | 63 GrAssert(GR_GL_ELEMENT_ARRAY_BUFFER == fBufferType); |
| 65 gpu->notifyIndexBufferBind(fDesc.fID); | 64 gpu->bindIndexBufferAndDefaultVertexArray(fDesc.fID); |
| 66 } | 65 } |
| 67 } | 66 } |
| 68 | 67 |
| 69 void* GrGLBufferImpl::lock(GrGpuGL* gpu) { | 68 void* GrGLBufferImpl::lock(GrGpuGL* gpu) { |
| 70 VALIDATE(); | 69 VALIDATE(); |
| 71 GrAssert(!this->isLocked()); | 70 GrAssert(!this->isLocked()); |
| 72 if (0 == fDesc.fID) { | 71 if (0 == fDesc.fID) { |
| 73 fLockPtr = fCPUData; | 72 fLockPtr = fCPUData; |
| 74 } else if (gpu->getCaps().bufferLockSupport()) { | 73 } else if (gpu->getCaps().bufferLockSupport()) { |
| 75 this->bind(gpu); | 74 this->bind(gpu); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 #endif | 151 #endif |
| 153 return true; | 152 return true; |
| 154 } | 153 } |
| 155 | 154 |
| 156 void GrGLBufferImpl::validate() const { | 155 void GrGLBufferImpl::validate() const { |
| 157 GrAssert(GR_GL_ARRAY_BUFFER == fBufferType || GR_GL_ELEMENT_ARRAY_BUFFER ==
fBufferType); | 156 GrAssert(GR_GL_ARRAY_BUFFER == fBufferType || GR_GL_ELEMENT_ARRAY_BUFFER ==
fBufferType); |
| 158 GrAssert((0 == fDesc.fID) == (NULL != fCPUData)); | 157 GrAssert((0 == fDesc.fID) == (NULL != fCPUData)); |
| 159 GrAssert(0 != fDesc.fID || !fDesc.fIsWrapped); | 158 GrAssert(0 != fDesc.fID || !fDesc.fIsWrapped); |
| 160 GrAssert(NULL == fCPUData || NULL == fLockPtr || fCPUData == fLockPtr); | 159 GrAssert(NULL == fCPUData || NULL == fLockPtr || fCPUData == fLockPtr); |
| 161 } | 160 } |
| OLD | NEW |