Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 std::string_view label,
41 bool commandBufferRefsAsUsageRefs = false)
45 size,
46 std::move(label),
47 /*commandBufferRefsAsUsageRefs=*/commandBufferRefsAsUsageRefs)
48 , fSize(size) {}
49
50 void* fMapPtr = nullptr;
51
52private:
53 virtual void onMap() = 0;
55 virtual void onUnmap() = 0;
56
57 size_t fSize;
58};
59
60} // namespace skgpu::graphite
61
62#endif // skgpu_graphite_Buffer_DEFINED
63
@ kYes
Do pre-clip the geometry before applying the (perspective) matrix.
Buffer(const SharedContext *sharedContext, size_t size, std::string_view label, bool commandBufferRefsAsUsageRefs=false)
Definition Buffer.h:38
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
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:187
void * GpuFinishedContext
void(*)(GpuFinishedContext finishedContext, CallbackResult) GpuFinishedProc
Budgeted
Definition GpuTypes.h:35
Definition ref_ptr.h:256