fix: isolated EGL context for mpv rendering

This commit is contained in:
edde746
2026-02-23 18:20:08 +01:00
parent e23f472d78
commit 3d9c6b203f
4 changed files with 276 additions and 115 deletions
+11
View File
@@ -6,6 +6,7 @@
#include <mpv/render_gl.h>
#include <gtk/gtk.h>
#include <epoxy/gl.h>
#include <epoxy/egl.h>
#include <atomic>
#include <functional>
@@ -49,6 +50,12 @@ class MpvPlayer {
/// Returns true if the render context has been created.
bool HasRenderContext() const { return mpv_gl_ != nullptr; }
/// Returns the isolated EGL display used for mpv rendering.
EGLDisplay GetEglDisplay() const { return egl_display_; }
/// Returns the isolated EGL context used for mpv rendering.
EGLContext GetEglContext() const { return egl_context_; }
/// Disposes mpv and releases resources.
void Dispose();
@@ -126,6 +133,10 @@ class MpvPlayer {
mpv_handle* mpv_ = nullptr;
mpv_render_context* mpv_gl_ = nullptr;
// Isolated EGL context for mpv rendering (not shared with Flutter)
EGLDisplay egl_display_ = EGL_NO_DISPLAY;
EGLContext egl_context_ = EGL_NO_CONTEXT;
std::atomic<bool> needs_redraw_{false};
std::atomic<bool> disposed_{false};
EventCallback event_callback_;