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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 VALIDATE(); | 92 VALIDATE(); |
93 if (srcSizeInBytes > fDesc.fSizeInBytes) { | 93 if (srcSizeInBytes > fDesc.fSizeInBytes) { |
94 return false; | 94 return false; |
95 } | 95 } |
96 if (0 == fDesc.fID) { | 96 if (0 == fDesc.fID) { |
97 memcpy(fCPUData, src, srcSizeInBytes); | 97 memcpy(fCPUData, src, srcSizeInBytes); |
98 return true; | 98 return true; |
99 } | 99 } |
100 gpu->bufferData(fDesc.fID, fBufferType, fDesc.fDynamic, fDesc.fSizeInBytes,
src, | 100 gpu->bufferData(fDesc.fID, fBufferType, fDesc.fDynamic, fDesc.fSizeInBytes,
src, |
101 srcSizeInBytes); | 101 srcSizeInBytes); |
| 102 #if GR_GL_USE_BUFFER_DATA_NULL_HINT |
| 103 fGLSizeInBytes = fDesc.fSizeInBytes; |
| 104 #else |
102 fGLSizeInBytes = srcSizeInBytes; | 105 fGLSizeInBytes = srcSizeInBytes; |
| 106 #endif |
103 VALIDATE(); | 107 VALIDATE(); |
104 return true; | 108 return true; |
105 } | 109 } |
106 | 110 |
107 void GrGLBufferImpl::validate() const { | 111 void GrGLBufferImpl::validate() const { |
108 SkASSERT(GR_GL_ARRAY_BUFFER == fBufferType || GR_GL_ELEMENT_ARRAY_BUFFER ==
fBufferType); | 112 SkASSERT(GR_GL_ARRAY_BUFFER == fBufferType || GR_GL_ELEMENT_ARRAY_BUFFER ==
fBufferType); |
109 // The following assert isn't valid when the buffer has been abandoned: | 113 // The following assert isn't valid when the buffer has been abandoned: |
110 // SkASSERT((0 == fDesc.fID) == (fCPUData)); | 114 // SkASSERT((0 == fDesc.fID) == (fCPUData)); |
111 SkASSERT(nullptr == fCPUData || 0 == fGLSizeInBytes); | 115 SkASSERT(nullptr == fCPUData || 0 == fGLSizeInBytes); |
112 SkASSERT(nullptr == fMapPtr || fCPUData || fGLSizeInBytes <= fDesc.fSizeInBy
tes); | 116 SkASSERT(nullptr == fMapPtr || fCPUData || fGLSizeInBytes <= fDesc.fSizeInBy
tes); |
113 SkASSERT(nullptr == fCPUData || nullptr == fMapPtr || fCPUData == fMapPtr); | 117 SkASSERT(nullptr == fCPUData || nullptr == fMapPtr || fCPUData == fMapPtr); |
114 } | 118 } |
OLD | NEW |