Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Namespaces | Functions
device_buffer.h File Reference
#include "flutter/lib/gpu/context.h"
#include "flutter/lib/gpu/export.h"
#include "flutter/lib/ui/dart_wrapper.h"
#include "third_party/tonic/typed_data/dart_byte_data.h"

Go to the source code of this file.

Classes

class  flutter::gpu::DeviceBuffer
 

Namespaces

namespace  flutter
 
namespace  flutter::gpu
 

Functions

FLUTTER_GPU_EXPORT bool InternalFlutterGpu_DeviceBuffer_Initialize (Dart_Handle wrapper, flutter::gpu::Context *gpu_context, int storage_mode, int size_in_bytes)
 
FLUTTER_GPU_EXPORT bool InternalFlutterGpu_DeviceBuffer_InitializeWithHostData (Dart_Handle wrapper, flutter::gpu::Context *gpu_context, Dart_Handle byte_data)
 
FLUTTER_GPU_EXPORT bool InternalFlutterGpu_DeviceBuffer_Overwrite (flutter::gpu::DeviceBuffer *wrapper, Dart_Handle source_byte_data, int destination_offset_in_bytes)
 

Function Documentation

◆ InternalFlutterGpu_DeviceBuffer_Initialize()

FLUTTER_GPU_EXPORT bool InternalFlutterGpu_DeviceBuffer_Initialize ( Dart_Handle  wrapper,
flutter::gpu::Context gpu_context,
int  storage_mode,
int  size_in_bytes 
)
extern

Exports

Definition at line 51 of file device_buffer.cc.

55 {
57 desc.storage_mode = flutter::gpu::ToImpellerStorageMode(storage_mode);
58 desc.size = size_in_bytes;
59 auto device_buffer =
60 gpu_context->GetContext()->GetResourceAllocator()->CreateBuffer(desc);
61 if (!device_buffer) {
62 FML_LOG(ERROR) << "Failed to create device buffer.";
63 return false;
64 }
65
66 auto res =
67 fml::MakeRefCounted<flutter::gpu::DeviceBuffer>(std::move(device_buffer));
68 res->AssociateWithDartWrapper(wrapper);
69
70 return true;
71}
std::shared_ptr< impeller::Context > GetContext()
Definition context.cc:65
#define FML_LOG(severity)
Definition logging.h:82
constexpr impeller::StorageMode ToImpellerStorageMode(FlutterGPUStorageMode value)
Definition formats.h:25
#define ERROR(message)

◆ InternalFlutterGpu_DeviceBuffer_InitializeWithHostData()

FLUTTER_GPU_EXPORT bool InternalFlutterGpu_DeviceBuffer_InitializeWithHostData ( Dart_Handle  wrapper,
flutter::gpu::Context gpu_context,
Dart_Handle  byte_data 
)
extern

Definition at line 73 of file device_buffer.cc.

76 {
77 auto data = tonic::DartByteData(byte_data);
78 auto mapping = fml::NonOwnedMapping(reinterpret_cast<uint8_t*>(data.data()),
79 data.length_in_bytes());
80 auto device_buffer =
81 gpu_context->GetContext()->GetResourceAllocator()->CreateBufferWithCopy(
82 mapping);
83 if (!device_buffer) {
84 FML_LOG(ERROR) << "Failed to create device buffer with copy.";
85 return false;
86 }
87
88 auto res =
89 fml::MakeRefCounted<flutter::gpu::DeviceBuffer>(std::move(device_buffer));
90 res->AssociateWithDartWrapper(wrapper);
91
92 return true;
93}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41

◆ InternalFlutterGpu_DeviceBuffer_Overwrite()

FLUTTER_GPU_EXPORT bool InternalFlutterGpu_DeviceBuffer_Overwrite ( flutter::gpu::DeviceBuffer wrapper,
Dart_Handle  source_byte_data,
int  destination_offset_in_bytes 
)
extern

Definition at line 95 of file device_buffer.cc.

98 {
99 return device_buffer->Overwrite(tonic::DartByteData(source_byte_data),
100 destination_offset_in_bytes);
101}