| 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 20 matching lines...) Expand all  Loading... | 
| 31         fCPUData = NULL; | 31         fCPUData = NULL; | 
| 32         // We assume that the GL buffer was created at the desc's size initially
     . | 32         // We assume that the GL buffer was created at the desc's size initially
     . | 
| 33         fGLSizeInBytes = fDesc.fSizeInBytes; | 33         fGLSizeInBytes = fDesc.fSizeInBytes; | 
| 34     } | 34     } | 
| 35     VALIDATE(); | 35     VALIDATE(); | 
| 36 } | 36 } | 
| 37 | 37 | 
| 38 void GrGLBufferImpl::release(GrGpuGL* gpu) { | 38 void GrGLBufferImpl::release(GrGpuGL* 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 (NULL != 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 && !fDesc.fIsWrapped) { | 
| 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         } | 
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 150                 this->bind(gpu); | 150                 this->bind(gpu); | 
| 151                 GR_GL_CALL(gpu->glInterface(), UnmapBufferSubData(fMapPtr)); | 151                 GR_GL_CALL(gpu->glInterface(), UnmapBufferSubData(fMapPtr)); | 
| 152                 break; | 152                 break; | 
| 153         } | 153         } | 
| 154     } | 154     } | 
| 155     fMapPtr = NULL; | 155     fMapPtr = NULL; | 
| 156 } | 156 } | 
| 157 | 157 | 
| 158 bool GrGLBufferImpl::isMapped() const { | 158 bool GrGLBufferImpl::isMapped() const { | 
| 159     VALIDATE(); | 159     VALIDATE(); | 
| 160     return NULL != fMapPtr; | 160     return SkToBool(fMapPtr); | 
| 161 } | 161 } | 
| 162 | 162 | 
| 163 bool GrGLBufferImpl::updateData(GrGpuGL* gpu, const void* src, size_t srcSizeInB
     ytes) { | 163 bool GrGLBufferImpl::updateData(GrGpuGL* gpu, const void* src, size_t srcSizeInB
     ytes) { | 
| 164     SkASSERT(!this->isMapped()); | 164     SkASSERT(!this->isMapped()); | 
| 165     VALIDATE(); | 165     VALIDATE(); | 
| 166     if (srcSizeInBytes > fDesc.fSizeInBytes) { | 166     if (srcSizeInBytes > fDesc.fSizeInBytes) { | 
| 167         return false; | 167         return false; | 
| 168     } | 168     } | 
| 169     if (0 == fDesc.fID) { | 169     if (0 == fDesc.fID) { | 
| 170         memcpy(fCPUData, src, srcSizeInBytes); | 170         memcpy(fCPUData, src, srcSizeInBytes); | 
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 211         fGLSizeInBytes = srcSizeInBytes; | 211         fGLSizeInBytes = srcSizeInBytes; | 
| 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) == (NULL != fCPUData)); | 221     // SkASSERT((0 == fDesc.fID) == (fCPUData)); | 
| 222     SkASSERT(0 != fDesc.fID || !fDesc.fIsWrapped); | 222     SkASSERT(0 != fDesc.fID || !fDesc.fIsWrapped); | 
| 223     SkASSERT(NULL == fCPUData || 0 == fGLSizeInBytes); | 223     SkASSERT(NULL == fCPUData || 0 == fGLSizeInBytes); | 
| 224     SkASSERT(NULL == fMapPtr || NULL != fCPUData || fGLSizeInBytes == fDesc.fSiz
     eInBytes); | 224     SkASSERT(NULL == fMapPtr || fCPUData || fGLSizeInBytes == fDesc.fSizeInBytes
     ); | 
| 225     SkASSERT(NULL == fCPUData || NULL == fMapPtr || fCPUData == fMapPtr); | 225     SkASSERT(NULL == fCPUData || NULL == fMapPtr || fCPUData == fMapPtr); | 
| 226 } | 226 } | 
| OLD | NEW | 
|---|