OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2015 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 "GrGLIndexBuffer.h" | 8 #include "GrGLTransferBuffer.h" |
9 #include "GrGLGpu.h" | 9 #include "GrGLGpu.h" |
10 #include "SkTraceMemoryDump.h" | 10 #include "SkTraceMemoryDump.h" |
11 | 11 |
12 GrGLIndexBuffer::GrGLIndexBuffer(GrGLGpu* gpu, const Desc& desc) | 12 GrGLTransferBuffer::GrGLTransferBuffer(GrGLGpu* gpu, const Desc& desc, GrGLenum
type) |
13 : INHERITED(gpu, desc.fSizeInBytes, desc.fDynamic, 0 == desc.fID) | 13 : INHERITED(gpu, desc.fSizeInBytes) |
14 , fImpl(gpu, desc, GR_GL_ELEMENT_ARRAY_BUFFER) { | 14 , fImpl(gpu, desc, type) { |
15 this->registerWithCache(); | 15 this->registerWithCache(); |
16 } | 16 } |
17 | 17 |
18 void GrGLIndexBuffer::onRelease() { | 18 void GrGLTransferBuffer::onRelease() { |
19 if (!this->wasDestroyed()) { | 19 if (!this->wasDestroyed()) { |
20 fImpl.release(this->getGpuGL()); | 20 fImpl.release(this->getGpuGL()); |
21 } | 21 } |
22 | 22 |
23 INHERITED::onRelease(); | 23 INHERITED::onRelease(); |
24 } | 24 } |
25 | 25 |
26 void GrGLIndexBuffer::onAbandon() { | 26 void GrGLTransferBuffer::onAbandon() { |
27 fImpl.abandon(); | 27 fImpl.abandon(); |
28 INHERITED::onAbandon(); | 28 INHERITED::onAbandon(); |
29 } | 29 } |
30 | 30 |
31 void* GrGLIndexBuffer::onMap() { | 31 void* GrGLTransferBuffer::onMap() { |
32 if (!this->wasDestroyed()) { | 32 if (!this->wasDestroyed()) { |
33 return fImpl.map(this->getGpuGL()); | 33 return fImpl.map(this->getGpuGL()); |
34 } else { | 34 } else { |
35 return nullptr; | 35 return nullptr; |
36 } | 36 } |
37 } | 37 } |
38 | 38 |
39 void GrGLIndexBuffer::onUnmap() { | 39 void GrGLTransferBuffer::onUnmap() { |
40 if (!this->wasDestroyed()) { | 40 if (!this->wasDestroyed()) { |
41 fImpl.unmap(this->getGpuGL()); | 41 fImpl.unmap(this->getGpuGL()); |
42 } | 42 } |
43 } | 43 } |
44 | 44 |
45 bool GrGLIndexBuffer::onUpdateData(const void* src, size_t srcSizeInBytes) { | 45 void GrGLTransferBuffer::setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, |
46 if (!this->wasDestroyed()) { | 46 const SkString& dumpName) const { |
47 return fImpl.updateData(this->getGpuGL(), src, srcSizeInBytes); | |
48 } else { | |
49 return false; | |
50 } | |
51 } | |
52 | |
53 void GrGLIndexBuffer::setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, | |
54 const SkString& dumpName) const { | |
55 SkString buffer_id; | 47 SkString buffer_id; |
56 buffer_id.appendU32(this->bufferID()); | 48 buffer_id.appendU32(this->bufferID()); |
57 traceMemoryDump->setMemoryBacking(dumpName.c_str(), "gl_buffer", | 49 traceMemoryDump->setMemoryBacking(dumpName.c_str(), "gl_buffer", |
58 buffer_id.c_str()); | 50 buffer_id.c_str()); |
59 } | 51 } |
OLD | NEW |