servo_media_player/
context.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5//! `PlayerGLContext` is a trait to be used to pass the GL context for
6//! rendering purposes.
7//!
8//! The current consumer of this trait is the GL rendering mechanism
9//! for the GStreamer backend.
10//!
11//! The client application should implement this trait and pass the
12//! trait object to its `player` instance.
13
14use malloc_size_of_derive::MallocSizeOf;
15
16#[derive(Clone, Debug, Deserialize, Serialize, MallocSizeOf)]
17pub enum GlContext {
18    /// The EGL platform used primarily with the X11, Wayland and
19    /// Android window systems as well as on embedded Linux.
20    Egl(usize),
21    /// The GLX platform used primarily with the X11 window system.
22    Glx(usize),
23    Unknown,
24}
25
26#[derive(Clone, Debug, Deserialize, Serialize, MallocSizeOf)]
27pub enum NativeDisplay {
28    /// The EGLDisplay memory address
29    Egl(usize),
30    /// XDisplay memory address
31    X11(usize),
32    /// wl_display memory address
33    Wayland(usize),
34    Headless,
35    Unknown,
36}
37
38#[derive(Clone, Debug, Deserialize, Serialize, MallocSizeOf)]
39pub enum GlApi {
40    OpenGL,
41    OpenGL3,
42    Gles1,
43    Gles2,
44    None,
45}
46
47pub trait PlayerGLContext {
48    /// Returns the GL context living pointer wrapped by `GlContext`
49    fn get_gl_context(&self) -> GlContext;
50    /// Returns the living pointer to the native display structure
51    /// wrapped by `NativeDisplay`.
52    fn get_native_display(&self) -> NativeDisplay;
53    /// Returns the GL API of the context
54    fn get_gl_api(&self) -> GlApi;
55}