| 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 "GrGLGpu.h" | 9 #include "GrGLGpu.h" |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 } | 34 } |
| 35 VALIDATE(); | 35 VALIDATE(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void GrGLBufferImpl::release(GrGLGpu* gpu) { | 38 void GrGLBufferImpl::release(GrGLGpu* gpu) { |
| 39 VALIDATE(); | 39 VALIDATE(); |
| 40 // make sure we've not been abandoned or already released | 40 // make sure we've not been abandoned or already released |
| 41 if (fCPUData) { | 41 if (fCPUData) { |
| 42 sk_free(fCPUData); | 42 sk_free(fCPUData); |
| 43 fCPUData = NULL; | 43 fCPUData = NULL; |
| 44 } else if (fDesc.fID && !fDesc.fIsWrapped) { | 44 } else if (fDesc.fID) { |
| 45 GL_CALL(gpu, DeleteBuffers(1, &fDesc.fID)); | 45 GL_CALL(gpu, DeleteBuffers(1, &fDesc.fID)); |
| 46 if (GR_GL_ARRAY_BUFFER == fBufferType) { | 46 if (GR_GL_ARRAY_BUFFER == fBufferType) { |
| 47 gpu->notifyVertexBufferDelete(fDesc.fID); | 47 gpu->notifyVertexBufferDelete(fDesc.fID); |
| 48 } else { | 48 } else { |
| 49 SkASSERT(GR_GL_ELEMENT_ARRAY_BUFFER == fBufferType); | 49 SkASSERT(GR_GL_ELEMENT_ARRAY_BUFFER == fBufferType); |
| 50 gpu->notifyIndexBufferDelete(fDesc.fID); | 50 gpu->notifyIndexBufferDelete(fDesc.fID); |
| 51 } | 51 } |
| 52 fDesc.fID = 0; | 52 fDesc.fID = 0; |
| 53 fGLSizeInBytes = 0; | 53 fGLSizeInBytes = 0; |
| 54 } | 54 } |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 GL_CALL(gpu, BufferData(fBufferType, fGLSizeInBytes, src, usage)); | 212 GL_CALL(gpu, BufferData(fBufferType, fGLSizeInBytes, src, usage)); |
| 213 } | 213 } |
| 214 #endif | 214 #endif |
| 215 return true; | 215 return true; |
| 216 } | 216 } |
| 217 | 217 |
| 218 void GrGLBufferImpl::validate() const { | 218 void GrGLBufferImpl::validate() const { |
| 219 SkASSERT(GR_GL_ARRAY_BUFFER == fBufferType || GR_GL_ELEMENT_ARRAY_BUFFER ==
fBufferType); | 219 SkASSERT(GR_GL_ARRAY_BUFFER == fBufferType || GR_GL_ELEMENT_ARRAY_BUFFER ==
fBufferType); |
| 220 // The following assert isn't valid when the buffer has been abandoned: | 220 // The following assert isn't valid when the buffer has been abandoned: |
| 221 // SkASSERT((0 == fDesc.fID) == (fCPUData)); | 221 // SkASSERT((0 == fDesc.fID) == (fCPUData)); |
| 222 SkASSERT(0 != fDesc.fID || !fDesc.fIsWrapped); | |
| 223 SkASSERT(NULL == fCPUData || 0 == fGLSizeInBytes); | 222 SkASSERT(NULL == fCPUData || 0 == fGLSizeInBytes); |
| 224 SkASSERT(NULL == fMapPtr || fCPUData || fGLSizeInBytes == fDesc.fSizeInBytes
); | 223 SkASSERT(NULL == fMapPtr || fCPUData || fGLSizeInBytes == fDesc.fSizeInBytes
); |
| 225 SkASSERT(NULL == fCPUData || NULL == fMapPtr || fCPUData == fMapPtr); | 224 SkASSERT(NULL == fCPUData || NULL == fMapPtr || fCPUData == fMapPtr); |
| 226 } | 225 } |
| OLD | NEW |