1 /* 2 * Copyright 2021 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 #include "src/gpu/graphite/Buffer.h" 9 #include "src/gpu/graphite/Caps.h" 10 #include "src/gpu/graphite/SharedContext.h" 11 12 namespace skgpu::graphite { 13 map()14void* Buffer::map() { 15 SkASSERT(this->isUnmappable() || !this->sharedContext()->caps()->bufferMapsAreAsync()); 16 if (!this->isMapped()) { 17 this->onMap(); 18 } 19 return fMapPtr; 20 } 21 asyncMap(GpuFinishedProc proc,GpuFinishedContext ctx)22void Buffer::asyncMap(GpuFinishedProc proc, GpuFinishedContext ctx) { 23 SkASSERT(this->sharedContext()->caps()->bufferMapsAreAsync()); 24 this->onAsyncMap(proc, ctx); 25 } 26 unmap()27void Buffer::unmap() { 28 SkASSERT(this->isUnmappable()); 29 this->onUnmap(); 30 fMapPtr = nullptr; 31 } 32 isUnmappable() const33bool Buffer::isUnmappable() const { return isMapped(); } 34 onAsyncMap(skgpu::graphite::GpuFinishedProc,skgpu::graphite::GpuFinishedContext)35void Buffer::onAsyncMap(skgpu::graphite::GpuFinishedProc, skgpu::graphite::GpuFinishedContext) { 36 SkASSERT(!this->sharedContext()->caps()->bufferMapsAreAsync()); 37 SK_ABORT("Async buffer mapping not supported"); 38 } 39 40 } // namespace skgpu::graphite 41 42