1 /* 2 * Copyright 2015 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef GrVkTransferBuffer_DEFINED 9 #define GrVkTransferBuffer_DEFINED 10 11 #include "GrTransferBuffer.h" 12 #include "GrVkBuffer.h" 13 #include "vk/GrVkInterface.h" 14 15 class GrVkGpu; 16 17 class GrVkTransferBuffer : public GrTransferBuffer, public GrVkBuffer { 18 19 public: 20 static GrVkTransferBuffer* Create(GrVkGpu* gpu, size_t size, GrVkBuffer::Type type); 21 22 protected: 23 void onAbandon() override; 24 void onRelease() override; 25 26 private: 27 GrVkTransferBuffer(GrVkGpu* gpu, const GrVkBuffer::Desc& desc, 28 const GrVkBuffer::Resource* resource); 29 void setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, 30 const SkString& dumpName) const override; 31 onMap()32 void* onMap() override { 33 if (!this->wasDestroyed()) { 34 return this->vkMap(this->getVkGpu()); 35 } else { 36 return nullptr; 37 } 38 } 39 onUnmap()40 void onUnmap() override { 41 if (!this->wasDestroyed()) { 42 this->vkUnmap(this->getVkGpu()); 43 } 44 } 45 getVkGpu()46 GrVkGpu* getVkGpu() const { 47 SkASSERT(!this->wasDestroyed()); 48 return reinterpret_cast<GrVkGpu*>(this->getGpu()); 49 } 50 51 typedef GrTransferBuffer INHERITED; 52 }; 53 54 #endif 55