G26: keep Windows textures alive through asynchronous unregister
Retain closed raw-pointer identities for late frames, release frame buffers after engine completion, and serialize termination with decoded frame writes. Add native regression controls for held raster buffers, inline completion, failed raster posts, missing registrations, teardown and concurrent closure. B252; Apache-2.0 dependency license and upstream history preserved.
This commit is contained in:
parent
8cd34a80ff
commit
50efc18ec5
10 changed files with 1268 additions and 14 deletions
|
|
@ -1,3 +1,6 @@
|
|||
// Modified by the Kitedesk fork (2026, B252): no UnregisterTexture in the
|
||||
// destructor; Terminate and FreeBuffers for closeTexture.
|
||||
|
||||
#include "texture_rgba.h"
|
||||
#include <iostream>
|
||||
|
||||
|
|
@ -11,11 +14,6 @@ TextureRgba::TextureRgba(flutter::TextureRegistrar *texture_registrar)
|
|||
this->texture_id_ = texture_registrar->RegisterTexture(texture_.get());
|
||||
}
|
||||
|
||||
TextureRgba::~TextureRgba()
|
||||
{
|
||||
texture_registrar_->UnregisterTexture(texture_id_);
|
||||
}
|
||||
|
||||
void TextureRgba::MarkVideoFrameAvailable(
|
||||
std::vector<uint8_t> &buffer, size_t width, size_t height)
|
||||
{
|
||||
|
|
@ -45,6 +43,11 @@ void TextureRgba::MarkVideoFrameAvailable2(const uint8_t* buffer, const size_t b
|
|||
return;
|
||||
}
|
||||
const std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (terminated_)
|
||||
{
|
||||
// Closed while the session still pushes frames to this pointer.
|
||||
return;
|
||||
}
|
||||
int bg_index = fg_index_ ^ 1;
|
||||
buffer_tmp_[bg_index].assign(buffer, buffer + buffer_length);
|
||||
width_[bg_index] = width;
|
||||
|
|
@ -61,6 +64,11 @@ void TextureRgba::MarkVideoFrameAvailable2(const uint8_t* buffer, const size_t b
|
|||
inline const FlutterDesktopPixelBuffer *TextureRgba::buffer()
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (terminated_)
|
||||
{
|
||||
// Closed; the engine may draw the texture until it has unregistered it.
|
||||
return nullptr;
|
||||
}
|
||||
if (buff_ready_)
|
||||
{
|
||||
fg_index_ ^= 1;
|
||||
|
|
@ -71,3 +79,18 @@ inline const FlutterDesktopPixelBuffer *TextureRgba::buffer()
|
|||
}
|
||||
return &this->flutter_pixel_buffer_;
|
||||
}
|
||||
|
||||
void TextureRgba::Terminate()
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(mutex_);
|
||||
terminated_ = true;
|
||||
}
|
||||
|
||||
void TextureRgba::FreeBuffers()
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::vector<uint8_t>().swap(buffer_tmp_[0]);
|
||||
std::vector<uint8_t>().swap(buffer_tmp_[1]);
|
||||
flutter_pixel_buffer_.buffer = nullptr;
|
||||
buff_ready_ = false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue