mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-08-31 13:32:10 +08:00
[refactor] modularize Slint video rendering backends
This commit is contained in:
@@ -16,12 +16,7 @@
|
||||
#include "file_transfer.h"
|
||||
#include "localization.h"
|
||||
#include "platform.h"
|
||||
#if defined(_WIN32) || defined(__linux__)
|
||||
#include "platform/opengl_video_renderer.h"
|
||||
#endif
|
||||
#ifdef __APPLE__
|
||||
#include "platform/metal_video_renderer.h"
|
||||
#endif
|
||||
#include "platform/video_renderer.h"
|
||||
#include "rd_log.h"
|
||||
#include "runtime/gui_runtime.h"
|
||||
#include "runtime/remote_action_codec.h"
|
||||
@@ -319,61 +314,46 @@ void PeerEventHandler::OnConnectionStatus(ConnectionStatus status,
|
||||
props->enable_mouse_control_ = false;
|
||||
runtime->ResetRemoteServiceStatus(*props);
|
||||
|
||||
#if defined(__APPLE__) || defined(_WIN32) || defined(__linux__)
|
||||
std::shared_ptr<std::vector<unsigned char>> native_snapshot;
|
||||
int native_snapshot_width = 0;
|
||||
int native_snapshot_height = 0;
|
||||
bool needs_native_snapshot = false;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(props->video_frame_mutex_);
|
||||
needs_native_snapshot = !props->thumbnail_frame_ ||
|
||||
props->thumbnail_frame_->empty();
|
||||
needs_native_snapshot =
|
||||
!props->thumbnail_frame_ || props->thumbnail_frame_->empty();
|
||||
}
|
||||
if (needs_native_snapshot) {
|
||||
#if defined(__APPLE__)
|
||||
auto* native_renderer = runtime->mac_metal_video_renderer_.get();
|
||||
#else
|
||||
auto* native_renderer = runtime->opengl_video_renderer_.get();
|
||||
#endif
|
||||
auto* native_renderer = runtime->video_renderer_.get();
|
||||
auto snapshot = std::make_shared<std::vector<unsigned char>>();
|
||||
if (native_renderer && native_renderer->CopyLatestNv12(
|
||||
remote_id, snapshot.get(),
|
||||
&native_snapshot_width,
|
||||
&native_snapshot_height)) {
|
||||
if (native_renderer &&
|
||||
native_renderer->CopyLatestNv12(remote_id, snapshot.get(),
|
||||
&native_snapshot_width,
|
||||
&native_snapshot_height)) {
|
||||
native_snapshot = std::move(snapshot);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(props->video_frame_mutex_);
|
||||
props->front_frame_.reset();
|
||||
props->back_frame_.reset();
|
||||
#if defined(__APPLE__) || defined(_WIN32) || defined(__linux__)
|
||||
if (native_snapshot &&
|
||||
(!props->thumbnail_frame_ || props->thumbnail_frame_->empty())) {
|
||||
props->thumbnail_frame_ = std::move(native_snapshot);
|
||||
props->thumbnail_width_ = native_snapshot_width;
|
||||
props->thumbnail_height_ = native_snapshot_height;
|
||||
}
|
||||
#endif
|
||||
props->video_width_ = 0;
|
||||
props->video_height_ = 0;
|
||||
props->video_size_ = 0;
|
||||
props->render_rect_dirty_ = true;
|
||||
props->stream_cleanup_pending_ = true;
|
||||
}
|
||||
#if defined(__APPLE__) || defined(_WIN32) || defined(__linux__)
|
||||
#if defined(__APPLE__)
|
||||
auto* native_renderer = runtime->mac_metal_video_renderer_.get();
|
||||
#else
|
||||
auto* native_renderer = runtime->opengl_video_renderer_.get();
|
||||
#endif
|
||||
auto* native_renderer = runtime->video_renderer_.get();
|
||||
if (native_renderer) {
|
||||
native_renderer->DiscardStream(remote_id);
|
||||
runtime->video_frame_dirty_.store(true,
|
||||
std::memory_order_release);
|
||||
runtime->video_frame_dirty_.store(true, std::memory_order_release);
|
||||
}
|
||||
#endif
|
||||
|
||||
runtime->focus_on_stream_window_ = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user