mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Resolves https://github.com/flutter/flutter/issues/132516. Add `impeller::HostBuffer` wrapper to Flutter GPU. * Allows for lazy batch uploads of sparse host data to the GPU. * Handles platform alignment requirements. * API returns buffer view handles that will be fed to commands.
41 lines
1.3 KiB
C++
41 lines
1.3 KiB
C++
// Copyright 2013 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "flutter/lib/gpu/host_buffer.h"
|
|
|
|
#include "impeller/core/host_buffer.h"
|
|
#include "impeller/core/platform.h"
|
|
#include "third_party/tonic/typed_data/dart_byte_data.h"
|
|
|
|
namespace flutter {
|
|
|
|
IMPLEMENT_WRAPPERTYPEINFO(gpu, HostBuffer);
|
|
|
|
HostBuffer::HostBuffer() : host_buffer_(impeller::HostBuffer::Create()) {}
|
|
|
|
HostBuffer::~HostBuffer() = default;
|
|
|
|
size_t HostBuffer::EmplaceBytes(const tonic::DartByteData& byte_data) {
|
|
auto view =
|
|
host_buffer_->Emplace(byte_data.data(), byte_data.length_in_bytes(),
|
|
impeller::DefaultUniformAlignment());
|
|
return view.range.offset;
|
|
}
|
|
|
|
} // namespace flutter
|
|
|
|
//----------------------------------------------------------------------------
|
|
/// Exports
|
|
///
|
|
|
|
void InternalFlutterGpu_HostBuffer_Initialize(Dart_Handle wrapper) {
|
|
auto res = fml::MakeRefCounted<flutter::HostBuffer>();
|
|
res->AssociateWithDartWrapper(wrapper);
|
|
}
|
|
|
|
size_t InternalFlutterGpu_HostBuffer_EmplaceBytes(flutter::HostBuffer* wrapper,
|
|
Dart_Handle byte_data) {
|
|
return wrapper->EmplaceBytes(tonic::DartByteData(byte_data));
|
|
}
|