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