Flutter Engine
The Flutter Engine
Classes | Public Member Functions | List of all members
GrStagingBufferManager Class Reference

#include <GrStagingBufferManager.h>

Classes

struct  Slice
 

Public Member Functions

 GrStagingBufferManager (GrGpu *gpu)
 
Slice allocateStagingBufferSlice (size_t size, size_t requiredAlignment=1)
 
void detachBuffers ()
 
bool hasBuffers ()
 
void reset ()
 

Detailed Description

Definition at line 17 of file GrStagingBufferManager.h.

Constructor & Destructor Documentation

◆ GrStagingBufferManager()

GrStagingBufferManager::GrStagingBufferManager ( GrGpu gpu)
inline

Definition at line 19 of file GrStagingBufferManager.h.

19: fGpu(gpu) {}

Member Function Documentation

◆ allocateStagingBufferSlice()

GrStagingBufferManager::Slice GrStagingBufferManager::allocateStagingBufferSlice ( size_t  size,
size_t  requiredAlignment = 1 
)

Definition at line 15 of file GrStagingBufferManager.cpp.

16 {
17 StagingBuffer* buffer = nullptr;
18 size_t offset = 0;
19 for (size_t i = 0; i < fBuffers.size(); ++i) {
20 size_t totalBufferSize = fBuffers[i].fBuffer->size();
21 size_t currentOffset = fBuffers[i].fOffset;
22 offset = ((currentOffset + requiredAlignment - 1)/requiredAlignment)*requiredAlignment;
23 if (totalBufferSize - offset >= size) {
24 buffer = &fBuffers[i];
25 break;
26 }
27 }
28
29 if (!buffer) {
30 GrResourceProvider* resourceProvider = fGpu->getContext()->priv().resourceProvider();
31 size_t minSize = fGpu->getContext()->priv().options().fMinimumStagingBufferSize;
32 size_t bufferSize = std::max(size, minSize);
33 sk_sp<GrGpuBuffer> newBuffer = resourceProvider->createBuffer(
34 bufferSize,
38 if (!newBuffer) {
39 return {}; // invalid slice
40 }
41 void* mapPtr = newBuffer->map();
42 if (!mapPtr) {
43 return {}; // invalid slice
44 }
45 fBuffers.emplace_back(std::move(newBuffer), mapPtr);
46 buffer = &fBuffers.back();
47 offset = 0;
48 }
49
51 SkASSERT(buffer->remaining() >= size);
52
53 buffer->fOffset = offset + size;
54 char* offsetMapPtr = static_cast<char*>(buffer->fMapPtr) + offset;
55 return {buffer->fBuffer.get(), offset, offsetMapPtr};
56}
@ kDynamic_GrAccessPattern
Definition: GrTypesPriv.h:426
#define SkASSERT(cond)
Definition: SkAssert.h:116
const GrContextOptions & options() const
GrResourceProvider * resourceProvider()
GrDirectContextPriv priv()
void * map()
Definition: GrGpuBuffer.cpp:28
GrDirectContext * getContext()
Definition: GrGpu.h:67
sk_sp< GrGpuBuffer > createBuffer(size_t size, GrGpuBufferType, GrAccessPattern, ZeroInit)
static float max(float r, float g, float b)
Definition: hsl.cpp:49
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
SeparatedVector2 offset
size_t fMinimumStagingBufferSize

◆ detachBuffers()

void GrStagingBufferManager::detachBuffers ( )

Definition at line 58 of file GrStagingBufferManager.cpp.

58 {
59 for (size_t i = 0; i < fBuffers.size(); ++i) {
60 fBuffers[i].fBuffer->unmap();
61 fGpu->takeOwnershipOfBuffer(std::move(fBuffers[i].fBuffer));
62 }
63 fBuffers.clear();
64}
virtual void takeOwnershipOfBuffer(sk_sp< GrGpuBuffer >)
Definition: GrGpu.h:432

◆ hasBuffers()

bool GrStagingBufferManager::hasBuffers ( )
inline

Definition at line 39 of file GrStagingBufferManager.h.

39{ return !fBuffers.empty(); }

◆ reset()

void GrStagingBufferManager::reset ( )
inline

Definition at line 41 of file GrStagingBufferManager.h.

41 {
42 for (size_t i = 0; i < fBuffers.size(); ++i) {
43 fBuffers[i].fBuffer->unmap();
44 }
45 fBuffers.clear();
46 }

The documentation for this class was generated from the following files: