win test commit (#2)

Signed-off-by: fufesou <shuanglongchen@yeah.net>
Co-authored-by: fufesou <shuanglongchen@yeah.net>
Co-authored-by: fufesou <fufesou@users.noreply.github.com>
This commit is contained in:
Kingtous 2023-02-18 04:39:00 -08:00 • committed by GitHub
parent 35e480aa73
commit e118e96341
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 57 additions and 20 deletions

View file

@ -1,12 +1,16 @@
#include "texture_rgba.h"
#include <iostream>
TextureRgba::TextureRgba(flutter::TextureRegistrar* texture_registrar)
TextureRgba::TextureRgba(flutter::TextureRegistrar *texture_registrar)
{
this->texture_registrar_ = texture_registrar;
// TODO: flutter only support PixelBuffer in 2023.02.17.
auto buffer = flutter::PixelBufferTexture([=](size_t width, size_t height) -> const FlutterDesktopPixelBuffer* {
return this->buffer();
});
auto buffer = flutter::PixelBufferTexture([=](size_t width, size_t height) -> const FlutterDesktopPixelBuffer *
{
std::cout << " GL. C++ rendering interval " << timer_.elapsed() << " ms" << std::endl;
timer_.reset();
const std::lock_guard<std::mutex> lock(mutex_);
return this->buffer(); });
texture_ = std::make_unique<flutter::TextureVariant>(buffer);
this->texture_id_ = texture_registrar->RegisterTexture(texture_.get());
}
@ -17,8 +21,9 @@ TextureRgba::~TextureRgba()
}
void TextureRgba::MarkVideoFrameAvailable(
std::vector<uint8_t>& buffer, size_t width, size_t height) {
const std::lock_guard<std::mutex> lock(mutex_);
std::vector<uint8_t> &buffer, size_t width, size_t height)
{
const std::lock_guard<std::mutex> lock(mutex_);
// FIXME: remove copy.
std::swap(buffer, buffer_tmp_);
flutter_pixel_buffer_.buffer = &buffer_tmp_[0];
@ -27,17 +32,7 @@ void TextureRgba::MarkVideoFrameAvailable(
texture_registrar_->MarkTextureFrameAvailable(texture_id_);
}
void TextureRgba::MarkVideoFrameAvailablePtr(
const uint8_t* buffer, size_t width, size_t height) {
const std::lock_guard<std::mutex> lock(mutex_);
// FIXME: remove copy.
flutter_pixel_buffer_.buffer = buffer;
flutter_pixel_buffer_.width = width;
flutter_pixel_buffer_.height = height;
texture_registrar_->MarkTextureFrameAvailable(texture_id_);
}
inline const FlutterDesktopPixelBuffer* TextureRgba::buffer()
inline const FlutterDesktopPixelBuffer *TextureRgba::buffer()
{
return &this->flutter_pixel_buffer_;
}