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.
52 lines
1.7 KiB
C++
52 lines
1.7 KiB
C++
// Modified by the Kitedesk fork (2026, B252): the texture no longer
|
|
// unregisters itself when destroyed (closeTexture does, and the plugin keeps
|
|
// the object alive until the engine is done with it); a closed texture drops
|
|
// pushed frames, hands the engine no buffer, and frees its frame buffers once
|
|
// the engine has unregistered it.
|
|
|
|
#ifndef TEXTURE_RGBA_H_
|
|
#define TEXTURE_RGBA_H_
|
|
|
|
#include <flutter/texture_registrar.h>
|
|
#include <atomic>
|
|
#include <mutex>
|
|
#include <chrono>
|
|
|
|
class TextureRgba
|
|
{
|
|
public:
|
|
TextureRgba(flutter::TextureRegistrar* texture_registrar);
|
|
|
|
void MarkVideoFrameAvailable(std::vector<uint8_t>& buffer, size_t width, size_t height);
|
|
|
|
void MarkVideoFrameAvailable2(const uint8_t* buffer, size_t buffer_length, size_t width, size_t height);
|
|
|
|
int64_t texture_id() const { return texture_id_; };
|
|
|
|
const FlutterDesktopPixelBuffer* buffer();
|
|
|
|
// Closes the texture: frames pushed from now on are dropped without
|
|
// touching the texture registrar, and the engine gets no buffer any more.
|
|
void Terminate();
|
|
|
|
// Frees the frame buffers. Call after Terminate, once the engine has
|
|
// unregistered the texture and so no longer reads them.
|
|
void FreeBuffers();
|
|
|
|
private:
|
|
FlutterDesktopPixelBuffer flutter_pixel_buffer_{};
|
|
flutter::TextureRegistrar* texture_registrar_ = nullptr;
|
|
std::unique_ptr<flutter::TextureVariant> texture_ = nullptr;
|
|
int64_t texture_id_;
|
|
std::mutex mutex_;
|
|
// Set and read with mutex_ held, so that no frame is copied or announced
|
|
// to the engine after Terminate returns.
|
|
std::atomic<bool> terminated_{false};
|
|
int fg_index_ = 0;
|
|
bool buff_ready_ = false;
|
|
size_t width_[2];
|
|
size_t height_[2];
|
|
std::vector<uint8_t> buffer_tmp_[2];
|
|
};
|
|
|
|
#endif // TEXTURE_RGBA_H_
|