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 SkASSERT(this->isProtected() == Protected::kNo); 17 if (!this->isMapped()) { 18 this->onMap(); 19 } 20 return fMapPtr; 21 } 22 asyncMap(GpuFinishedProc proc,GpuFinishedContext ctx)23void Buffer::asyncMap(GpuFinishedProc proc, GpuFinishedContext ctx) { 24 SkASSERT(this->sharedContext()->caps()->bufferMapsAreAsync()); 25 SkASSERT(this->isProtected() == Protected::kNo); 26 this->onAsyncMap(proc, ctx); 27 } 28 unmap()29void Buffer::unmap() { 30 SkASSERT(this->isUnmappable()); 31 this->onUnmap(); 32 fMapPtr = nullptr; 33 } 34 isUnmappable() const35bool Buffer::isUnmappable() const { return isMapped(); } 36 onAsyncMap(skgpu::graphite::GpuFinishedProc,skgpu::graphite::GpuFinishedContext)37void Buffer::onAsyncMap(skgpu::graphite::GpuFinishedProc, skgpu::graphite::GpuFinishedContext) { 38 SkASSERT(!this->sharedContext()->caps()->bufferMapsAreAsync()); 39 SK_ABORT("Async buffer mapping not supported"); 40 } 41 42 } // namespace skgpu::graphite 43 44