Sunshine latest
Self-hosted game stream host for Moonlight.
graphics.h File Reference

Declarations for graphics related functions. More...

#include <optional>
#include <string_view>
#include <glad/egl.h>
#include <glad/gl.h>
#include "misc.h"
#include "src/logging.h"
#include "src/platform/common.h"
#include "src/utility.h"
#include "src/video_colorspace.h"
Include dependency graph for graphics.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  gl::buffer_t
 
class  egl::cursor_t
 
class  gl::frame_buf_t
 
class  egl::img_descriptor_t
 
struct  egl::nv12_img_t
 
class  gl::program_t
 
struct  egl::rgb_img_t
 
class  gl::shader_t
 
struct  egl::surface_descriptor_t
 
class  egl::sws_t
 
class  gl::tex_t
 

Macros

#define gl_drain_errors   gl_drain_errors_helper(__FILE__ ":" SUNSHINE_STRINGIFY(__LINE__))
 
#define gl_drain_errors_helper(x)   gl::drain_errors(x)
 
#define SUNSHINE_STRINGIFY(x)   SUNSHINE_STRINGIFY_HELPER(x)
 
#define SUNSHINE_STRINGIFY_HELPER(x)   #x
 

Typedefs

typedef device *(* gbm::create_device_fn) (int fd)
 
typedef void(* gbm::device_destroy_fn) (device *gbm)
 
using egl::display_t = util::dyn_safe_ptr_v2<void, EGLBoolean, &eglTerminate>
 
using frame_t = util::safe_ptr<AVFrame, free_frame>
 
using gbm::gbm_t = util::dyn_safe_ptr<device, &device_destroy>
 

Functions

int close (int __fd)
 
rgb_t egl::create_blank (platf::img_t &img)
 Create a black RGB texture of the specified image size.
 
std::optional< nv12_t > egl::create_target (int width, int height, AVPixelFormat format)
 Create biplanar YUV textures to render into.
 
void gl::drain_errors (const std::string_view &prefix)
 
bool egl::fail ()
 
void free_frame (AVFrame *frame)
 
std::optional< rgb_t > egl::import_source (display_t::pointer egl_display, const surface_descriptor_t &xrgb)
 
std::optional< nv12_t > egl::import_target (display_t::pointer egl_display, std::array< file_t, nv12_img_t::num_fds > &&fds, const surface_descriptor_t &y, const surface_descriptor_t &uv)
 
int gbm::init ()
 
 egl::KITTY_USING_MOVE_T (ctx_t,(std::tuple< display_t::pointer, EGLContext >),, { TUPLE_2D_REF(disp, ctx, el);if(ctx) { eglMakeCurrent(disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);eglDestroyContext(disp, ctx);} })
 
 egl::KITTY_USING_MOVE_T (nv12_t, nv12_img_t,, { if(el.r8) { eglDestroyImage(el.display, el.r8);} if(el.bg88) { eglDestroyImage(el.display, el.bg88);} })
 
 egl::KITTY_USING_MOVE_T (rgb_t, rgb_img_t,, { if(el.xrgb8) { eglDestroyImage(el.display, el.xrgb8);} })
 
std::optional< ctx_t > egl::make_ctx (display_t::pointer display)
 
display_t egl::make_display (std::variant< gbm::gbm_t::pointer, wl_display *, _XDisplay * > native_display)
 

Detailed Description

Declarations for graphics related functions.

Function Documentation

◆ create_blank()

rgb_t egl::create_blank ( platf::img_t & img)

Create a black RGB texture of the specified image size.

Parameters
imgThe image to use for texture sizing.
Returns
The new RGB texture.

◆ create_target()

std::optional< nv12_t > egl::create_target ( int width,
int height,
AVPixelFormat format )

Create biplanar YUV textures to render into.

Creates biplanar YUV textures to render into.

Parameters
widthWidth of the target frame.
heightHeight of the target frame.
formatFormat of the target frame.
Returns
The new RGB texture.