diff --git a/windows/texture_rgba.cpp b/windows/texture_rgba.cpp index 6984351..91aaacc 100644 --- a/windows/texture_rgba.cpp +++ b/windows/texture_rgba.cpp @@ -39,6 +39,23 @@ void TextureRgba::MarkVideoFrameAvailable( } } +void TextureRgba::MarkVideoFrameAvailable2(const uint8_t* buffer, const size_t buffer_length, size_t width, size_t height) { + if (!buffer || buffer_length < width * height * 4) + { + return; + } + const std::lock_guard lock(mutex_); + int bg_index = fg_index_ ^ 1; + buffer_tmp_[bg_index].assign(buffer, buffer + buffer_length); + width_[bg_index] = width; + height_[bg_index] = height; + if (!buff_ready_) + { + buff_ready_ = true; + texture_registrar_->MarkTextureFrameAvailable(texture_id_); + } +} + // This function may be called // event texture_registrar_->MarkTextureFrameAvailable(texture_id_); is not called before. inline const FlutterDesktopPixelBuffer *TextureRgba::buffer() diff --git a/windows/texture_rgba.h b/windows/texture_rgba.h index ffcfc47..8273039 100644 --- a/windows/texture_rgba.h +++ b/windows/texture_rgba.h @@ -13,6 +13,8 @@ public: void MarkVideoFrameAvailable(std::vector& 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(); diff --git a/windows/texture_rgba_renderer_plugin_c_api.cpp b/windows/texture_rgba_renderer_plugin_c_api.cpp index 8d64947..6d7a55b 100644 --- a/windows/texture_rgba_renderer_plugin_c_api.cpp +++ b/windows/texture_rgba_renderer_plugin_c_api.cpp @@ -25,6 +25,5 @@ void FlutterRgbaRendererPluginOnRgba(void *texture_rgba, const uint8_t *buffer, } TextureRgba *rgba = static_cast(texture_rgba); - std::vector data(buffer, buffer + len); - rgba->MarkVideoFrameAvailable(data, width, height); + rgba->MarkVideoFrameAvailable2(buffer, len, width, height); }