OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 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 #ifndef GrVkTransferBuffer_DEFINED | 8 #ifndef GrVkTransferBuffer_DEFINED |
9 #define GrVkTransferBuffer_DEFINED | 9 #define GrVkTransferBuffer_DEFINED |
10 | 10 |
11 #include "GrTransferBuffer.h" | 11 #include "GrBuffer.h" |
12 #include "GrVkBuffer.h" | 12 #include "GrVkBuffer.h" |
13 #include "vk/GrVkInterface.h" | 13 #include "vk/GrVkInterface.h" |
14 | 14 |
15 class GrVkGpu; | 15 class GrVkGpu; |
16 | 16 |
17 class GrVkTransferBuffer : public GrTransferBuffer, public GrVkBuffer { | 17 class GrVkTransferBuffer : public GrBuffer, public GrVkBuffer { |
18 | 18 |
19 public: | 19 public: |
20 static GrVkTransferBuffer* Create(GrVkGpu* gpu, size_t size, GrVkBuffer::Typ
e type); | 20 static GrVkTransferBuffer* Create(GrVkGpu* gpu, size_t size, GrVkBuffer::Typ
e type); |
21 | 21 |
22 protected: | 22 protected: |
23 void onAbandon() override; | 23 void onAbandon() override; |
24 void onRelease() override; | 24 void onRelease() override; |
25 | 25 |
26 private: | 26 private: |
27 GrVkTransferBuffer(GrVkGpu* gpu, const GrVkBuffer::Desc& desc, | 27 GrVkTransferBuffer(GrVkGpu* gpu, const GrVkBuffer::Desc& desc, |
28 const GrVkBuffer::Resource* resource); | 28 const GrVkBuffer::Resource* resource); |
29 void setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, | 29 void setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, |
30 const SkString& dumpName) const override; | 30 const SkString& dumpName) const override; |
31 | 31 |
32 void* onMap() override { | 32 void onMap() override { |
33 if (!this->wasDestroyed()) { | 33 if (!this->wasDestroyed()) { |
34 return this->vkMap(this->getVkGpu()); | 34 this->GrBuffer::fMapPtr = this->vkMap(this->getVkGpu()); |
35 } else { | |
36 return nullptr; | |
37 } | 35 } |
38 } | 36 } |
39 | 37 |
40 void onUnmap() override { | 38 void onUnmap() override { |
41 if (!this->wasDestroyed()) { | 39 if (!this->wasDestroyed()) { |
42 this->vkUnmap(this->getVkGpu()); | 40 this->vkUnmap(this->getVkGpu()); |
43 } | 41 } |
44 } | 42 } |
45 | 43 |
| 44 bool onUpdateData(const void* src, size_t srcSizeInBytes) override { |
| 45 SkFAIL("Not implemented for transfer buffers."); |
| 46 return false; |
| 47 } |
| 48 |
46 GrVkGpu* getVkGpu() const { | 49 GrVkGpu* getVkGpu() const { |
47 SkASSERT(!this->wasDestroyed()); | 50 SkASSERT(!this->wasDestroyed()); |
48 return reinterpret_cast<GrVkGpu*>(this->getGpu()); | 51 return reinterpret_cast<GrVkGpu*>(this->getGpu()); |
49 } | 52 } |
50 | 53 |
51 typedef GrTransferBuffer INHERITED; | 54 typedef GrBuffer INHERITED; |
52 }; | 55 }; |
53 | 56 |
54 #endif | 57 #endif |
OLD | NEW |