Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Buffer.cpp
Go to the documentation of this file.
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
11
12namespace skgpu::graphite {
13
14void* Buffer::map() {
15 SkASSERT(this->isUnmappable() || !this->sharedContext()->caps()->bufferMapsAreAsync());
16 if (!this->isMapped()) {
17 this->onMap();
18 }
19 return fMapPtr;
20}
21
23 SkASSERT(this->sharedContext()->caps()->bufferMapsAreAsync());
24 this->onAsyncMap(proc, ctx);
25}
26
28 SkASSERT(this->isUnmappable());
29 this->onUnmap();
30 fMapPtr = nullptr;
31}
32
33bool Buffer::isUnmappable() const { return isMapped(); }
34
36 SkASSERT(!this->sharedContext()->caps()->bufferMapsAreAsync());
37 SK_ABORT("Async buffer mapping not supported");
38}
39
40} // namespace skgpu::graphite
41
#define SK_ABORT(message,...)
Definition SkAssert.h:70
#define SkASSERT(cond)
Definition SkAssert.h:116
virtual void onAsyncMap(GpuFinishedProc, GpuFinishedContext)
Definition Buffer.cpp:35
virtual void onUnmap()=0
virtual void onMap()=0
virtual bool isUnmappable() const
Definition Buffer.cpp:33
bool isMapped() const
Definition Buffer.h:30
void asyncMap(GpuFinishedProc=nullptr, GpuFinishedContext=nullptr)
Definition Buffer.cpp:22
const SharedContext * sharedContext() const
Definition Resource.h:187
void * GpuFinishedContext
void(*)(GpuFinishedContext finishedContext, CallbackResult) GpuFinishedProc