Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
host_buffer.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "flutter/lib/gpu/host_buffer.h"
6
7#include <optional>
8
9#include "dart_api.h"
13
14namespace flutter {
15namespace gpu {
16
18
20 : host_buffer_(impeller::HostBuffer::Create(
21 context->GetContext()->GetResourceAllocator())) {}
22
23HostBuffer::~HostBuffer() = default;
24
25std::shared_ptr<impeller::HostBuffer> HostBuffer::GetBuffer() {
26 return host_buffer_;
27}
28
30 auto view =
31 host_buffer_->Emplace(byte_data.data(), byte_data.length_in_bytes(),
33 emplacements_[current_offset_] = view;
34 size_t previous_offset = current_offset_;
35 current_offset_ += view.range.length;
36 return previous_offset;
37}
38
39std::optional<impeller::BufferView> HostBuffer::GetBufferViewForOffset(
40 size_t offset) {
41 return emplacements_[offset];
42}
43
44} // namespace gpu
45} // namespace flutter
46
47//----------------------------------------------------------------------------
48/// Exports
49///
50
52 flutter::gpu::Context* context) {
53 auto res = fml::MakeRefCounted<flutter::gpu::HostBuffer>(context);
54 res->AssociateWithDartWrapper(wrapper);
55}
56
59 Dart_Handle byte_data) {
60 return wrapper->EmplaceBytes(tonic::DartByteData(byte_data));
61}
static sk_sp< Effect > Create()
std::shared_ptr< impeller::HostBuffer > GetBuffer()
size_t EmplaceBytes(const tonic::DartByteData &byte_data)
std::optional< impeller::BufferView > GetBufferViewForOffset(size_t offset)
HostBuffer(Context *context)
const void * data() const
size_t length_in_bytes() const
struct _Dart_Handle * Dart_Handle
Definition dart_api.h:258
#define IMPLEMENT_WRAPPERTYPEINFO(LibraryName, ClassName)
size_t InternalFlutterGpu_HostBuffer_EmplaceBytes(flutter::gpu::HostBuffer *wrapper, Dart_Handle byte_data)
void InternalFlutterGpu_HostBuffer_Initialize(Dart_Handle wrapper, flutter::gpu::Context *context)
constexpr size_t DefaultUniformAlignment()
Definition platform.h:15
Point previous_offset
Point offset