Flutter Engine
The Flutter Engine
Namespaces | Functions
device_buffer.cc File Reference
#include "flutter/lib/gpu/device_buffer.h"
#include "dart_api.h"
#include "flutter/lib/gpu/formats.h"
#include "fml/mapping.h"
#include "impeller/core/device_buffer.h"
#include "impeller/core/device_buffer_descriptor.h"
#include "impeller/core/formats.h"
#include "impeller/core/platform.h"
#include "impeller/core/range.h"
#include "third_party/tonic/typed_data/dart_byte_data.h"
#include "tonic/converter/dart_converter.h"

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)
 

Function Documentation

◆ 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 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)
Definition: elf_loader.cc:260

◆ InternalFlutterGpu_DeviceBuffer_InitializeWithHostData()

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

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}
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ 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 95 of file device_buffer.cc.

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