OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "GrGLBuffer.h" | 8 #include "GrGLBuffer.h" |
9 #include "GrGLGpu.h" | 9 #include "GrGLGpu.h" |
10 #include "SkTraceMemoryDump.h" | 10 #include "SkTraceMemoryDump.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #endif | 23 #endif |
24 | 24 |
25 #ifdef SK_DEBUG | 25 #ifdef SK_DEBUG |
26 #define VALIDATE() this->validate() | 26 #define VALIDATE() this->validate() |
27 #else | 27 #else |
28 #define VALIDATE() do {} while(false) | 28 #define VALIDATE() do {} while(false) |
29 #endif | 29 #endif |
30 | 30 |
31 GrGLBuffer* GrGLBuffer::Create(GrGLGpu* gpu, size_t size, GrBufferType intendedT
ype, | 31 GrGLBuffer* GrGLBuffer::Create(GrGLGpu* gpu, size_t size, GrBufferType intendedT
ype, |
32 GrAccessPattern accessPattern, const void* data)
{ | 32 GrAccessPattern accessPattern, const void* data)
{ |
33 if (gpu->glCaps().transferBufferType() == GrGLCaps::kNone_TransferBufferType
&& | |
34 (kXferCpuToGpu_GrBufferType == intendedType || | |
35 kXferGpuToCpu_GrBufferType == intendedType)) { | |
36 return nullptr; | |
37 } | |
38 | |
39 bool cpuBacked = gpu->glCaps().useNonVBOVertexAndIndexDynamicData() && | 33 bool cpuBacked = gpu->glCaps().useNonVBOVertexAndIndexDynamicData() && |
40 GrBufferTypeIsVertexOrIndex(intendedType) && | 34 GrBufferTypeIsVertexOrIndex(intendedType) && |
41 kDynamic_GrAccessPattern == accessPattern; | 35 kDynamic_GrAccessPattern == accessPattern; |
42 SkAutoTUnref<GrGLBuffer> buffer(new GrGLBuffer(gpu, size, intendedType, acce
ssPattern, | 36 SkAutoTUnref<GrGLBuffer> buffer(new GrGLBuffer(gpu, size, intendedType, acce
ssPattern, |
43 cpuBacked, data)); | 37 cpuBacked, data)); |
44 if (!cpuBacked && 0 == buffer->bufferID()) { | 38 if (!cpuBacked && 0 == buffer->bufferID()) { |
45 return nullptr; | 39 return nullptr; |
46 } | 40 } |
47 return buffer.release(); | 41 return buffer.release(); |
48 } | 42 } |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 | 317 |
324 void GrGLBuffer::validate() const { | 318 void GrGLBuffer::validate() const { |
325 // The following assert isn't valid when the buffer has been abandoned: | 319 // The following assert isn't valid when the buffer has been abandoned: |
326 // SkASSERT((0 == fDesc.fID) == (fCPUData)); | 320 // SkASSERT((0 == fDesc.fID) == (fCPUData)); |
327 SkASSERT(0 != fBufferID || 0 == fGLSizeInBytes); | 321 SkASSERT(0 != fBufferID || 0 == fGLSizeInBytes); |
328 SkASSERT(nullptr == fMapPtr || fCPUData || fGLSizeInBytes <= fSizeInBytes); | 322 SkASSERT(nullptr == fMapPtr || fCPUData || fGLSizeInBytes <= fSizeInBytes); |
329 SkASSERT(nullptr == fCPUData || nullptr == fMapPtr || fCPUData == fMapPtr); | 323 SkASSERT(nullptr == fCPUData || nullptr == fMapPtr || fCPUData == fMapPtr); |
330 } | 324 } |
331 | 325 |
332 #endif | 326 #endif |
OLD | NEW |