Flutter Engine
The Flutter Engine
GrStagingBufferManager.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 Google LLC
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 GrStagingBufferManager_DEFINED
9#define GrStagingBufferManager_DEFINED
10
13#include <vector>
14
15class GrGpu;
16
18public:
19 GrStagingBufferManager(GrGpu* gpu) : fGpu(gpu) {}
20
21 struct Slice {
22 Slice() {}
23 Slice(GrGpuBuffer* buffer, size_t offset, void* offsetMapPtr)
24 : fBuffer(buffer), fOffset(offset), fOffsetMapPtr(offsetMapPtr) {}
25 GrGpuBuffer* fBuffer = nullptr;
26 size_t fOffset = 0;
27 void* fOffsetMapPtr = nullptr;
28 };
29
30 Slice allocateStagingBufferSlice(size_t size, size_t requiredAlignment = 1);
31
32 // This call is used to move all the buffers off of the manager and to backend gpu by calling
33 // the virtual GrGpu::takeOwnershipOfBuffer on each buffer. This is called during
34 // submitToGpu. It is up to the backend to take refs to the buffers in their implemented
35 // takeOwnershipOfBuffer implementation if they need to. After this call returns the
36 // manager will have released all refs to its buffers.
37 void detachBuffers();
38
39 bool hasBuffers() { return !fBuffers.empty(); }
40
41 void reset() {
42 for (size_t i = 0; i < fBuffers.size(); ++i) {
43 fBuffers[i].fBuffer->unmap();
44 }
45 fBuffers.clear();
46 }
47
48private:
49 struct StagingBuffer {
50 StagingBuffer(sk_sp<GrGpuBuffer> buffer, void* mapPtr)
51 : fBuffer(std::move(buffer))
52 , fMapPtr(mapPtr) {}
53
54 sk_sp<GrGpuBuffer> fBuffer;
55 void* fMapPtr;
56 size_t fOffset = 0;
57
58 size_t remaining() { return fBuffer->size() - fOffset; }
59 };
60
61 std::vector<StagingBuffer> fBuffers;
62 GrGpu* fGpu;
63};
64
65#endif
66
size_t size() const final
Definition: GrGpuBuffer.h:34
Definition: GrGpu.h:62
Slice allocateStagingBufferSlice(size_t size, size_t requiredAlignment=1)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
Definition: ref_ptr.h:256
SeparatedVector2 offset
Slice(GrGpuBuffer *buffer, size_t offset, void *offsetMapPtr)