Flutter Engine
The Flutter Engine
Buffer.h
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
8#ifndef skgpu_graphite_Buffer_DEFINED
9#define skgpu_graphite_Buffer_DEFINED
10
14
15namespace skgpu::graphite {
16
17class Buffer : public Resource {
18public:
19 size_t size() const { return fSize; }
20
21 // TODO(b/262249983): Separate into mapRead(), mapWrite() methods.
22 // If the buffer is already mapped then pointer is returned. If an asyncMap() was started then
23 // it is waited on. Otherwise, a synchronous map is performed.
24 void* map();
25 // Starts a new asynchronous map.
26 void asyncMap(GpuFinishedProc = nullptr, GpuFinishedContext = nullptr);
27 // If the buffer is mapped then unmaps. If an async map is pending then it is cancelled.
28 void unmap();
29
30 bool isMapped() const { return fMapPtr; }
31
32 // Returns true if mapped or an asyncMap was started and hasn't been completed or canceled.
33 virtual bool isUnmappable() const;
34
35 const char* getResourceType() const override { return "Buffer"; }
36
37protected:
39 size_t size,
40 bool commandBufferRefsAsUsageRefs = false)
44 size,
45 /*commandBufferRefsAsUsageRefs=*/commandBufferRefsAsUsageRefs)
46 , fSize(size) {}
47
48 void* fMapPtr = nullptr;
49
50private:
51 virtual void onMap() = 0;
53 virtual void onUnmap() = 0;
54
55 size_t fSize;
56};
57
58} // namespace skgpu::graphite
59
60#endif // skgpu_graphite_Buffer_DEFINED
@ kYes
Do pre-clip the geometry before applying the (perspective) matrix.
virtual void onAsyncMap(GpuFinishedProc, GpuFinishedContext)
Definition: Buffer.cpp:35
virtual void onUnmap()=0
size_t size() const
Definition: Buffer.h:19
virtual void onMap()=0
virtual bool isUnmappable() const
Definition: Buffer.cpp:33
bool isMapped() const
Definition: Buffer.h:30
Buffer(const SharedContext *sharedContext, size_t size, bool commandBufferRefsAsUsageRefs=false)
Definition: Buffer.h:38
const char * getResourceType() const override
Definition: Buffer.h:35
void asyncMap(GpuFinishedProc=nullptr, GpuFinishedContext=nullptr)
Definition: Buffer.cpp:22
const SharedContext * sharedContext() const
Definition: Resource.h:189
void * GpuFinishedContext
Definition: GraphiteTypes.h:29
void(*)(GpuFinishedContext finishedContext, CallbackResult) GpuFinishedProc
Definition: GraphiteTypes.h:30
Definition: GpuTools.h:21
Budgeted
Definition: GpuTypes.h:35