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 "GrBuffer.h" 12 #include "GrVkBuffer.h" 13 #include "vk/GrVkTypes.h" 14 15 class GrVkGpu; 16 17 class GrVkTransferBuffer : public GrBuffer, public GrVkBuffer { 18 19 public: 20 static sk_sp<GrVkTransferBuffer> Make(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 this->GrBuffer::fMapPtr = this->vkMap(this->getVkGpu()); 35 } 36 } 37 onUnmap()38 void onUnmap() override { 39 if (!this->wasDestroyed()) { 40 this->vkUnmap(this->getVkGpu()); 41 } 42 } 43 onUpdateData(const void * src,size_t srcSizeInBytes)44 bool onUpdateData(const void* src, size_t srcSizeInBytes) override { 45 SK_ABORT("Not implemented for transfer buffers."); 46 return false; 47 } 48 getVkGpu()49 GrVkGpu* getVkGpu() const { 50 SkASSERT(!this->wasDestroyed()); 51 return reinterpret_cast<GrVkGpu*>(this->getGpu()); 52 } 53 54 typedef GrBuffer INHERITED; 55 }; 56 57 #endif 58