aboutsummaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
Diffstat (limited to 'render')
-rw-r--r--render/egl.c11
-rw-r--r--render/gles2/renderer.c2
-rw-r--r--render/matrix.c9
-rw-r--r--render/wlr_renderer.c15
-rw-r--r--render/wlr_texture.c12
5 files changed, 49 insertions, 0 deletions
diff --git a/render/egl.c b/render/egl.c
index 21c446f1..046eeb36 100644
--- a/render/egl.c
+++ b/render/egl.c
@@ -6,11 +6,13 @@
#include <wlr/render/egl.h>
#include <wlr/util/log.h>
#include "glapi.h"
+#include "util/defs.h"
// Extension documentation
// https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_image_base.txt.
// https://cgit.freedesktop.org/mesa/mesa/tree/docs/specs/WL_bind_wayland_display.spec
+WLR_API
const char *egl_error(void) {
switch (eglGetError()) {
case EGL_SUCCESS:
@@ -83,6 +85,7 @@ static bool egl_get_config(EGLDisplay disp, EGLint *attribs, EGLConfig *out,
return false;
}
+WLR_API
bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *remote_display,
EGLint *config_attribs, EGLint visual_id) {
if (!load_glapi()) {
@@ -158,6 +161,7 @@ error:
return false;
}
+WLR_API
void wlr_egl_finish(struct wlr_egl *egl) {
eglMakeCurrent(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (egl->wl_display && eglUnbindWaylandDisplayWL) {
@@ -169,6 +173,7 @@ void wlr_egl_finish(struct wlr_egl *egl) {
eglReleaseThread();
}
+WLR_API
bool wlr_egl_bind_display(struct wlr_egl *egl, struct wl_display *local_display) {
if (!eglBindWaylandDisplayWL) {
return false;
@@ -182,6 +187,7 @@ bool wlr_egl_bind_display(struct wlr_egl *egl, struct wl_display *local_display)
return false;
}
+WLR_API
bool wlr_egl_query_buffer(struct wlr_egl *egl, struct wl_resource *buf,
int attrib, int *value) {
if (!eglQueryWaylandBufferWL) {
@@ -190,6 +196,7 @@ bool wlr_egl_query_buffer(struct wlr_egl *egl, struct wl_resource *buf,
return eglQueryWaylandBufferWL(egl->display, buf, attrib, value);
}
+WLR_API
EGLImage wlr_egl_create_image(struct wlr_egl *egl, EGLenum target,
EGLClientBuffer buffer, const EGLint *attribs) {
if (!eglCreateImageKHR) {
@@ -200,6 +207,7 @@ EGLImage wlr_egl_create_image(struct wlr_egl *egl, EGLenum target,
buffer, attribs);
}
+WLR_API
bool wlr_egl_destroy_image(struct wlr_egl *egl, EGLImage image) {
if (!eglDestroyImageKHR) {
return false;
@@ -209,6 +217,7 @@ bool wlr_egl_destroy_image(struct wlr_egl *egl, EGLImage image) {
return true;
}
+WLR_API
EGLSurface wlr_egl_create_surface(struct wlr_egl *egl, void *window) {
EGLSurface surf = eglCreatePlatformWindowSurfaceEXT(egl->display, egl->config,
window, NULL);
@@ -235,6 +244,7 @@ int wlr_egl_get_buffer_age(struct wlr_egl *egl, EGLSurface surface) {
return buffer_age;
}
+WLR_API
bool wlr_egl_make_current(struct wlr_egl *egl, EGLSurface surface,
int *buffer_age) {
if (!eglMakeCurrent(egl->display, surface, surface, egl->context)) {
@@ -248,6 +258,7 @@ bool wlr_egl_make_current(struct wlr_egl *egl, EGLSurface surface,
return true;
}
+WLR_API
bool wlr_egl_swap_buffers(struct wlr_egl *egl, EGLSurface surface,
pixman_region32_t *damage) {
EGLBoolean ret;
diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c
index 81a932e6..36486232 100644
--- a/render/gles2/renderer.c
+++ b/render/gles2/renderer.c
@@ -13,6 +13,7 @@
#include <wlr/util/log.h>
#include "render/gles2.h"
#include "glapi.h"
+#include "util/defs.h"
struct shaders shaders;
@@ -266,6 +267,7 @@ static struct wlr_renderer_impl wlr_renderer_impl = {
.format_supported = wlr_gles2_format_supported,
};
+WLR_API
struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_backend *backend) {
init_globals();
struct wlr_gles2_renderer *renderer;
diff --git a/render/matrix.c b/render/matrix.c
index d5d7f49d..ca6b995b 100644
--- a/render/matrix.c
+++ b/render/matrix.c
@@ -4,12 +4,14 @@
#include <wlr/render/matrix.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_output.h>
+#include "util/defs.h"
/* Obtains the index for the given row/column */
static inline int mind(int row, int col) {
return (row - 1) * 4 + col - 1;
}
+WLR_API
void wlr_matrix_identity(float (*output)[16]) {
static const float identity[16] = {
1.0f, 0.0f, 0.0f, 0.0f,
@@ -20,6 +22,7 @@ void wlr_matrix_identity(float (*output)[16]) {
memcpy(*output, identity, sizeof(identity));
}
+WLR_API
void wlr_matrix_translate(float (*output)[16], float x, float y, float z) {
wlr_matrix_identity(output);
(*output)[mind(1, 4)] = x;
@@ -27,6 +30,7 @@ void wlr_matrix_translate(float (*output)[16], float x, float y, float z) {
(*output)[mind(3, 4)] = z;
}
+WLR_API
void wlr_matrix_scale(float (*output)[16], float x, float y, float z) {
wlr_matrix_identity(output);
(*output)[mind(1, 1)] = x;
@@ -34,6 +38,7 @@ void wlr_matrix_scale(float (*output)[16], float x, float y, float z) {
(*output)[mind(3, 3)] = z;
}
+WLR_API
void wlr_matrix_rotate(float (*output)[16], float radians) {
wlr_matrix_identity(output);
float _cos = cosf(radians);
@@ -44,6 +49,7 @@ void wlr_matrix_rotate(float (*output)[16], float radians) {
(*output)[mind(2, 2)] = _cos;
}
+WLR_API
void wlr_matrix_mul(const float (*x)[16], const float (*y)[16], float (*product)[16]) {
float _product[16] = {
(*x)[mind(1, 1)] * (*y)[mind(1, 1)] + (*x)[mind(1, 2)] * (*y)[mind(2, 1)] +
@@ -120,6 +126,7 @@ static const float transforms[][4] = {
},
};
+WLR_API
void wlr_matrix_transform(float mat[static 16],
enum wl_output_transform transform) {
memset(mat, 0, sizeof(*mat) * 16);
@@ -138,6 +145,7 @@ void wlr_matrix_transform(float mat[static 16],
}
// Equivilent to glOrtho(0, width, 0, height, 1, -1) with the transform applied
+WLR_API
void wlr_matrix_texture(float mat[static 16], int32_t width, int32_t height,
enum wl_output_transform transform) {
memset(mat, 0, sizeof(*mat) * 16);
@@ -161,6 +169,7 @@ void wlr_matrix_texture(float mat[static 16], int32_t width, int32_t height,
mat[15] = 1.0f;
}
+WLR_API
void wlr_matrix_project_box(float (*mat)[16], struct wlr_box *box,
enum wl_output_transform transform, float rotation,
float (*projection)[16]) {
diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c
index fa6c6fc3..83513452 100644
--- a/render/wlr_renderer.c
+++ b/render/wlr_renderer.c
@@ -1,12 +1,15 @@
#include <stdbool.h>
#include <stdlib.h>
#include <wlr/render/interface.h>
+#include "util/defs.h"
+WLR_API
void wlr_renderer_init(struct wlr_renderer *renderer,
struct wlr_renderer_impl *impl) {
renderer->impl = impl;
}
+WLR_API
void wlr_renderer_destroy(struct wlr_renderer *r) {
if (r && r->impl && r->impl->destroy) {
r->impl->destroy(r);
@@ -15,51 +18,62 @@ void wlr_renderer_destroy(struct wlr_renderer *r) {
}
}
+WLR_API
void wlr_renderer_begin(struct wlr_renderer *r, struct wlr_output *o) {
r->impl->begin(r, o);
}
+WLR_API
void wlr_renderer_end(struct wlr_renderer *r) {
r->impl->end(r);
}
+WLR_API
void wlr_renderer_clear(struct wlr_renderer *r, const float (*color)[4]) {
r->impl->clear(r, color);
}
+WLR_API
void wlr_renderer_scissor(struct wlr_renderer *r, struct wlr_box *box) {
r->impl->scissor(r, box);
}
+WLR_API
struct wlr_texture *wlr_render_texture_create(struct wlr_renderer *r) {
return r->impl->texture_create(r);
}
+WLR_API
bool wlr_render_with_matrix(struct wlr_renderer *r,
struct wlr_texture *texture, const float (*matrix)[16]) {
return r->impl->render_with_matrix(r, texture, matrix);
}
+WLR_API
void wlr_render_colored_quad(struct wlr_renderer *r,
const float (*color)[4], const float (*matrix)[16]) {
r->impl->render_quad(r, color, matrix);
}
+WLR_API
void wlr_render_colored_ellipse(struct wlr_renderer *r,
const float (*color)[4], const float (*matrix)[16]) {
r->impl->render_ellipse(r, color, matrix);
}
+WLR_API
const enum wl_shm_format *wlr_renderer_get_formats(
struct wlr_renderer *r, size_t *len) {
return r->impl->formats(r, len);
}
+WLR_API
bool wlr_renderer_buffer_is_drm(struct wlr_renderer *r,
struct wl_resource *buffer) {
return r->impl->buffer_is_drm(r, buffer);
}
+WLR_API
bool wlr_renderer_read_pixels(struct wlr_renderer *r, enum wl_shm_format fmt,
uint32_t stride, uint32_t width, uint32_t height,
uint32_t src_x, uint32_t src_y, uint32_t dst_x, uint32_t dst_y,
@@ -68,6 +82,7 @@ bool wlr_renderer_read_pixels(struct wlr_renderer *r, enum wl_shm_format fmt,
dst_x, dst_y, data);
}
+WLR_API
bool wlr_renderer_format_supported(struct wlr_renderer *r,
enum wl_shm_format fmt) {
return r->impl->format_supported(r, fmt);
diff --git a/render/wlr_texture.c b/render/wlr_texture.c
index a82a16b2..f74ebc66 100644
--- a/render/wlr_texture.c
+++ b/render/wlr_texture.c
@@ -1,13 +1,16 @@
#include <stdbool.h>
#include <stdlib.h>
#include <wlr/render/interface.h>
+#include "util/defs.h"
+WLR_API
void wlr_texture_init(struct wlr_texture *texture,
struct wlr_texture_impl *impl) {
texture->impl = impl;
wl_signal_init(&texture->destroy_signal);
}
+WLR_API
void wlr_texture_destroy(struct wlr_texture *texture) {
if (texture && texture->impl && texture->impl->destroy) {
texture->impl->destroy(texture);
@@ -16,16 +19,19 @@ void wlr_texture_destroy(struct wlr_texture *texture) {
}
}
+WLR_API
void wlr_texture_bind(struct wlr_texture *texture) {
texture->impl->bind(texture);
}
+WLR_API
bool wlr_texture_upload_pixels(struct wlr_texture *texture, uint32_t format,
int stride, int width, int height, const unsigned char *pixels) {
return texture->impl->upload_pixels(texture, format, stride,
width, height, pixels);
}
+WLR_API
bool wlr_texture_update_pixels(struct wlr_texture *texture,
enum wl_shm_format format, int stride, int x, int y,
int width, int height, const unsigned char *pixels) {
@@ -33,31 +39,37 @@ bool wlr_texture_update_pixels(struct wlr_texture *texture,
width, height, pixels);
}
+WLR_API
bool wlr_texture_upload_shm(struct wlr_texture *texture, uint32_t format,
struct wl_shm_buffer *shm) {
return texture->impl->upload_shm(texture, format, shm);
}
+WLR_API
bool wlr_texture_update_shm(struct wlr_texture *texture, uint32_t format,
int x, int y, int width, int height, struct wl_shm_buffer *shm) {
return texture->impl->update_shm(texture, format, x, y, width, height, shm);
}
+WLR_API
bool wlr_texture_upload_drm(struct wlr_texture *texture,
struct wl_resource *drm_buffer) {
return texture->impl->upload_drm(texture, drm_buffer);
}
+WLR_API
bool wlr_texture_upload_eglimage(struct wlr_texture *texture,
EGLImageKHR image, uint32_t width, uint32_t height) {
return texture->impl->upload_eglimage(texture, image, width, height);
}
+WLR_API
void wlr_texture_get_matrix(struct wlr_texture *texture,
float (*matrix)[16], const float (*projection)[16], int x, int y) {
texture->impl->get_matrix(texture, matrix, projection, x, y);
}
+WLR_API
void wlr_texture_get_buffer_size(struct wlr_texture *texture, struct wl_resource
*resource, int *width, int *height) {
texture->impl->get_buffer_size(texture, resource, width, height);