Flutter Engine
 
Loading...
Searching...
No Matches
device_buffer.cc File Reference

Go to the source code of this file.

Namespaces

namespace  flutter
 
namespace  flutter::gpu
 

Functions

 flutter::gpu::IMPLEMENT_WRAPPERTYPEINFO (flutter_gpu, DeviceBuffer)
 
bool InternalFlutterGpu_DeviceBuffer_Initialize (Dart_Handle wrapper, flutter::gpu::Context *gpu_context, int storage_mode, int size_in_bytes)
 
bool InternalFlutterGpu_DeviceBuffer_InitializeWithHostData (Dart_Handle wrapper, flutter::gpu::Context *gpu_context, Dart_Handle byte_data)
 
bool InternalFlutterGpu_DeviceBuffer_Overwrite (flutter::gpu::DeviceBuffer *device_buffer, Dart_Handle source_byte_data, int destination_offset_in_bytes)
 
bool InternalFlutterGpu_DeviceBuffer_Flush (flutter::gpu::DeviceBuffer *device_buffer, int offset_in_bytes, int size_in_bytes)
 

Function Documentation

◆ InternalFlutterGpu_DeviceBuffer_Flush()

bool InternalFlutterGpu_DeviceBuffer_Flush ( flutter::gpu::DeviceBuffer device_buffer,
int  offset_in_bytes,
int  size_in_bytes 
)

Definition at line 108 of file device_buffer.cc.

111 {
112 device_buffer->GetBuffer()->Flush(
113 impeller::Range(offset_in_bytes, size_in_bytes));
114 return true;
115}
std::shared_ptr< impeller::DeviceBuffer > GetBuffer()

References flutter::gpu::DeviceBuffer::GetBuffer().

◆ InternalFlutterGpu_DeviceBuffer_Initialize()

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

Exports

Definition at line 50 of file device_buffer.cc.

54 {
57 desc.size = size_in_bytes;
58 auto device_buffer =
59 gpu_context->GetContext().GetResourceAllocator()->CreateBuffer(desc);
60 if (!device_buffer) {
61 FML_LOG(ERROR) << "Failed to create device buffer.";
62 return false;
63 }
64
65 auto res =
66 fml::MakeRefCounted<flutter::gpu::DeviceBuffer>(std::move(device_buffer));
67 res->AssociateWithDartWrapper(wrapper);
68
69 return true;
70}
impeller::Context & GetContext()
Definition context.cc:77
virtual std::shared_ptr< Allocator > GetResourceAllocator() const =0
Returns the allocator used to create textures and buffers on the device.
#define FML_LOG(severity)
Definition logging.h:101
constexpr impeller::StorageMode ToImpellerStorageMode(FlutterGPUStorageMode value)
Definition formats.h:25

References FML_LOG, flutter::gpu::Context::GetContext(), impeller::Context::GetResourceAllocator(), impeller::DeviceBufferDescriptor::size, impeller::DeviceBufferDescriptor::storage_mode, and flutter::gpu::ToImpellerStorageMode().

◆ InternalFlutterGpu_DeviceBuffer_InitializeWithHostData()

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

Definition at line 72 of file device_buffer.cc.

75 {
76 std::shared_ptr<impeller::DeviceBuffer> device_buffer = nullptr;
77 {
78 // `DartByteData` gets raw pointers into the Dart heap via
79 // `Dart_TypedDataAcquireData`. So it must be destructed before
80 // `AssociateWithDartWrapper` is called, which mutates the heap.
81 auto data = tonic::DartByteData(byte_data);
82 auto mapping = fml::NonOwnedMapping(reinterpret_cast<uint8_t*>(data.data()),
83 data.length_in_bytes());
84 device_buffer =
85 gpu_context->GetContext().GetResourceAllocator()->CreateBufferWithCopy(
86 mapping);
87 }
88 if (!device_buffer) {
89 FML_LOG(ERROR) << "Failed to create device buffer with copy.";
90 return false;
91 }
92
93 auto res =
94 fml::MakeRefCounted<flutter::gpu::DeviceBuffer>(std::move(device_buffer));
95 res->AssociateWithDartWrapper(wrapper);
96
97 return true;
98}
std::shared_ptr< const fml::Mapping > data

References data, FML_LOG, flutter::gpu::Context::GetContext(), and impeller::Context::GetResourceAllocator().

◆ InternalFlutterGpu_DeviceBuffer_Overwrite()

bool InternalFlutterGpu_DeviceBuffer_Overwrite ( flutter::gpu::DeviceBuffer device_buffer,
Dart_Handle  source_byte_data,
int  destination_offset_in_bytes 
)

Definition at line 100 of file device_buffer.cc.

103 {
104 return device_buffer->Overwrite(tonic::DartByteData(source_byte_data),
105 destination_offset_in_bytes);
106}
bool Overwrite(const tonic::DartByteData &source_bytes, size_t destination_offset_in_bytes)

References flutter::gpu::DeviceBuffer::Overwrite().