2019-10-08 18:41:23 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2019 Andri Yngvason
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
|
|
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
|
|
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
|
|
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
|
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
|
|
|
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2019-10-06 17:14:53 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-10-06 18:50:47 +00:00
|
|
|
#include <GLES2/gl2.h>
|
|
|
|
#include <EGL/egl.h>
|
2020-03-24 22:48:13 +00:00
|
|
|
#include <unistd.h>
|
2020-03-05 19:13:41 +00:00
|
|
|
#include <wayland-client.h>
|
2019-10-06 18:50:47 +00:00
|
|
|
|
2019-10-06 17:14:53 +00:00
|
|
|
struct dmabuf_frame;
|
2020-03-05 20:49:22 +00:00
|
|
|
struct output;
|
2019-10-06 17:14:53 +00:00
|
|
|
|
2020-02-11 21:55:05 +00:00
|
|
|
enum renderer_input_type {
|
|
|
|
RENDERER_INPUT_FB,
|
|
|
|
RENDERER_INPUT_DMABUF,
|
|
|
|
};
|
|
|
|
|
2020-03-24 18:42:58 +00:00
|
|
|
struct renderer_fbo {
|
|
|
|
GLuint rbo;
|
|
|
|
GLuint fbo;
|
|
|
|
};
|
|
|
|
|
2019-10-06 18:50:47 +00:00
|
|
|
struct renderer {
|
|
|
|
EGLDisplay display;
|
|
|
|
EGLContext context;
|
2020-03-05 18:14:50 +00:00
|
|
|
|
2020-03-05 20:49:22 +00:00
|
|
|
const struct output* output;
|
2020-03-05 18:14:50 +00:00
|
|
|
|
2019-10-06 18:50:47 +00:00
|
|
|
GLint read_format;
|
|
|
|
GLint read_type;
|
2020-03-05 18:14:50 +00:00
|
|
|
|
2020-03-24 18:42:58 +00:00
|
|
|
struct renderer_fbo fbo;
|
|
|
|
|
2020-03-24 22:07:49 +00:00
|
|
|
GLuint tex[2];
|
|
|
|
int tex_index;
|
|
|
|
|
2020-03-05 18:14:50 +00:00
|
|
|
struct {
|
|
|
|
GLuint program;
|
2020-03-25 20:26:15 +00:00
|
|
|
GLint u_tex0;
|
|
|
|
GLint u_tex1;
|
2020-03-05 18:46:27 +00:00
|
|
|
GLint u_proj;
|
2020-03-05 18:14:50 +00:00
|
|
|
} shader;
|
2019-10-06 18:50:47 +00:00
|
|
|
};
|
|
|
|
|
2020-03-05 20:49:22 +00:00
|
|
|
int renderer_init(struct renderer* self, const struct output* output,
|
2020-02-11 21:55:05 +00:00
|
|
|
enum renderer_input_type input_type);
|
2019-10-06 22:12:29 +00:00
|
|
|
void renderer_destroy(struct renderer* self);
|
2019-10-06 20:54:59 +00:00
|
|
|
|
2020-03-24 22:48:13 +00:00
|
|
|
int renderer_import_dmabuf_frame(struct renderer* self, GLuint tex,
|
|
|
|
struct dmabuf_frame* frame);
|
|
|
|
int renderer_import_framebuffer(struct renderer* self, GLuint tex,
|
|
|
|
const void* addr, uint32_t format,
|
|
|
|
uint32_t width, uint32_t height,
|
|
|
|
uint32_t stride);
|
2019-10-06 17:14:53 +00:00
|
|
|
|
|
|
|
/* Copy a horizontal stripe from the GL frame into a pixel buffer */
|
|
|
|
void render_copy_pixels(struct renderer* self, void* dst, uint32_t y,
|
|
|
|
uint32_t height);
|
2020-03-24 22:48:13 +00:00
|
|
|
|
|
|
|
GLuint renderer_next_tex(struct renderer* self);
|
|
|
|
GLuint renderer_last_tex(const struct renderer* self);
|
|
|
|
|
2020-03-24 22:57:02 +00:00
|
|
|
void render(struct renderer* self);
|