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 |
33 SkAutoTUnref<GrGLBuffer> buffer(new GrGLBuffer(gpu, size, intendedType, acce
ssPattern, data)); | 39 SkAutoTUnref<GrGLBuffer> buffer(new GrGLBuffer(gpu, size, intendedType, acce
ssPattern, data)); |
34 if (0 == buffer->bufferID()) { | 40 if (0 == buffer->bufferID()) { |
35 return nullptr; | 41 return nullptr; |
36 } | 42 } |
37 return buffer.release(); | 43 return buffer.release(); |
38 } | 44 } |
39 | 45 |
40 // GL_STREAM_DRAW triggers an optimization in Chromium's GPU process where a cli
ent's vertex buffer | 46 // GL_STREAM_DRAW triggers an optimization in Chromium's GPU process where a cli
ent's vertex buffer |
41 // objects are implemented as client-side-arrays on tile-deferred architectures. | 47 // objects are implemented as client-side-arrays on tile-deferred architectures. |
42 #define DYNAMIC_DRAW_PARAM GR_GL_STREAM_DRAW | 48 #define DYNAMIC_DRAW_PARAM GR_GL_STREAM_DRAW |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 } | 285 } |
280 | 286 |
281 #ifdef SK_DEBUG | 287 #ifdef SK_DEBUG |
282 | 288 |
283 void GrGLBuffer::validate() const { | 289 void GrGLBuffer::validate() const { |
284 SkASSERT(0 != fBufferID || 0 == fGLSizeInBytes); | 290 SkASSERT(0 != fBufferID || 0 == fGLSizeInBytes); |
285 SkASSERT(nullptr == fMapPtr || fGLSizeInBytes <= this->sizeInBytes()); | 291 SkASSERT(nullptr == fMapPtr || fGLSizeInBytes <= this->sizeInBytes()); |
286 } | 292 } |
287 | 293 |
288 #endif | 294 #endif |
OLD | NEW |