19#define SUNSHINE_STRINGIFY_HELPER(x) #x
20#define SUNSHINE_STRINGIFY(x) SUNSHINE_STRINGIFY_HELPER(x)
21#define gl_drain_errors_helper(x) gl::drain_errors(x)
22#define gl_drain_errors gl_drain_errors_helper(__FILE__ ":" SUNSHINE_STRINGIFY(__LINE__))
28extern "C" struct _XDisplay;
32free_frame(AVFrame *frame);
37 extern GladGLContext ctx;
39 drain_errors(
const std::string_view &prefix);
47 operator=(
tex_t &&) =
default;
52 make(std::size_t count);
66 make(std::size_t count);
69 bind(std::nullptr_t, std::nullptr_t) {
71 for (
auto fb : (*this)) {
72 ctx.BindFramebuffer(GL_FRAMEBUFFER, fb);
73 ctx.FramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + x, 0, 0);
82 bind(It it_begin, It it_end) {
83 using namespace std::literals;
84 if (std::distance(it_begin, it_end) > size()) {
85 BOOST_LOG(warning) <<
"To many elements to bind"sv;
90 std::for_each(it_begin, it_end, [&](
auto tex) {
91 ctx.BindFramebuffer(GL_FRAMEBUFFER, (*
this)[x]);
92 ctx.BindTexture(GL_TEXTURE_2D, tex);
94 ctx.FramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + x, tex, 0);
104 copy(
int id,
int texture,
int offset_x,
int offset_y,
int width,
int height);
108 KITTY_USING_MOVE_T(shader_internal_t, GLuint, std::numeric_limits<GLuint>::max(), {
109 if (el != std::numeric_limits<GLuint>::max()) {
110 ctx.DeleteShader(el);
119 compile(
const std::string_view &source, GLenum type);
125 shader_internal_t _shader;
129 KITTY_USING_MOVE_T(buffer_internal_t, GLuint, std::numeric_limits<GLuint>::max(), {
130 if (el != std::numeric_limits<GLuint>::max()) {
131 ctx.DeleteBuffers(1, &el);
146 update(
const std::string_view &view, std::size_t offset = 0);
148 update(std::string_view *members, std::size_t count, std::size_t offset = 0);
157 buffer_internal_t _buffer;
161 KITTY_USING_MOVE_T(program_internal_t, GLuint, std::numeric_limits<GLuint>::max(), {
162 if (el != std::numeric_limits<GLuint>::max()) {
163 ctx.DeleteProgram(el);
177 std::optional<buffer_t>
178 uniform(
const char *block, std::pair<const char *, std::string_view> *members, std::size_t count);
184 program_internal_t _program;
190 typedef void (*device_destroy_fn)(device *gbm);
191 typedef device *(*create_device_fn)(
int fd);
193 extern device_destroy_fn device_destroy;
194 extern create_device_fn create_device;
207 display_t::pointer display;
214 display_t::pointer display;
222 static constexpr std::size_t num_fds = 4;
224 std::array<file_t, num_fds> fds;
229 eglDestroyImage(el.display, el.xrgb8);
233 KITTY_USING_MOVE_T(nv12_t, nv12_img_t, , {
235 eglDestroyImage(el.display, el.r8);
239 eglDestroyImage(el.display, el.bg88);
243 KITTY_USING_MOVE_T(ctx_t, (std::tuple<display_t::pointer, EGLContext>), , {
244 TUPLE_2D_REF(disp, ctx, el);
246 eglMakeCurrent(disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
247 eglDestroyContext(disp, ctx);
255 std::uint32_t fourcc;
256 std::uint64_t modifier;
257 std::uint32_t pitches[4];
258 std::uint32_t offsets[4];
262 make_display(std::variant<gbm::gbm_t::pointer, wl_display *, _XDisplay *> native_display);
264 make_ctx(display_t::pointer display);
268 display_t::pointer egl_display,
274 std::optional<nv12_t>
276 display_t::pointer egl_display,
277 std::array<file_t, nv12_img_t::num_fds> &&fds,
287 std::optional<nv12_t>
295 unsigned long serial;
297 std::vector<std::uint8_t> buffer;
309 for (
auto x = 0; x < 4; ++x) {
310 if (sd.fds[x] >= 0) {
321 std::uint64_t sequence;
326 static std::optional<sws_t>
327 make(
int in_width,
int in_height,
int out_width,
int out_height,
gl::tex_t &&tex);
328 static std::optional<sws_t>
329 make(
int in_width,
int in_height,
int out_width,
int out_height, AVPixelFormat format);
337 blank(
gl::frame_buf_t &fb,
int offsetX,
int offsetY,
int width,
int height);
359 int out_width, out_height;
360 int in_width, in_height;
361 int offsetX, offsetY;
367 std::uint64_t serial;
Definition graphics.h:290
Definition graphics.h:301
Definition graphics.h:324
Definition graphics.h:128
void copy(int id, int texture, int offset_x, int offset_y, int width, int height)
Definition graphics.cpp:83
Definition graphics.h:160
Definition graphics.h:107
Declarations for common platform specific utilities.
rgb_t create_blank(platf::img_t &img)
Create a black RGB texture of the specified image size.
Definition graphics.cpp:584
std::optional< nv12_t > create_target(int width, int height, AVPixelFormat format)
Create biplanar YUV textures to render into.
Definition graphics.cpp:665
Miscellaneous declarations for Linux.
Declarations for logging related functions.
Definition graphics.h:213
Definition graphics.h:206
Definition graphics.h:251
Definition video_colorspace.h:20
Declarations for utility functions.
Declarations for colorspace functions.