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 "include/gpu/vk/GrVkTypes.h" 12 #include "src/gpu/GrGpuBuffer.h" 13 #include "src/gpu/vk/GrVkBuffer.h" 14 15 class GrVkGpu; 16 17 class GrVkTransferBuffer : public GrGpuBuffer, public GrVkBuffer { 18 public: 19 static sk_sp<GrVkTransferBuffer> Make(GrVkGpu* gpu, size_t size, GrVkBuffer::Type type); 20 21 protected: 22 void onAbandon() override; 23 void onRelease() override; 24 25 private: 26 GrVkTransferBuffer(GrVkGpu* gpu, const GrVkBuffer::Desc& desc, 27 const GrVkBuffer::Resource* resource); 28 void setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, 29 const SkString& dumpName) const override; 30 onMap()31 void onMap() override { this->GrGpuBuffer::fMapPtr = this->vkMap(this->getVkGpu()); } 32 onUnmap()33 void onUnmap() override { this->vkUnmap(this->getVkGpu()); } 34 onUpdateData(const void * src,size_t srcSizeInBytes)35 bool onUpdateData(const void* src, size_t srcSizeInBytes) override { 36 SK_ABORT("Not implemented for transfer buffers."); 37 } 38 getVkGpu()39 GrVkGpu* getVkGpu() const { 40 SkASSERT(!this->wasDestroyed()); 41 return reinterpret_cast<GrVkGpu*>(this->getGpu()); 42 } 43 44 typedef GrGpuBuffer INHERITED; 45 }; 46 47 #endif 48