Add wlcore/wl_shm (WIP)

This commit is contained in:
Drew DeVault 2017-06-22 16:32:47 -04:00
parent f252c5a792
commit 2aafb5dd19
12 changed files with 186 additions and 4 deletions

View file

@ -129,6 +129,7 @@ static void draw_quad() {
static bool wlr_gles2_render_surface(struct wlr_renderer_state *state,
struct wlr_surface *surface, const float (*matrix)[16]) {
assert(surface && surface->valid);
// TODO: Convert GL formats to WL_SHM formats
switch (surface->format) {
case GL_RGB:
GL_CALL(glUseProgram(shaders.rgb));
@ -163,6 +164,16 @@ static void wlr_gles2_render_ellipse(struct wlr_renderer_state *state,
draw_quad();
}
static const enum wl_shm_format *wlr_gles2_formats(
struct wlr_renderer_state *state, size_t *len) {
static enum wl_shm_format formats[] = {
WL_SHM_FORMAT_ARGB8888,
WL_SHM_FORMAT_XRGB8888,
};
*len = sizeof(formats) / sizeof(formats[0]);
return formats;
}
static void wlr_gles2_destroy(struct wlr_renderer_state *state) {
// no-op
}
@ -174,6 +185,7 @@ static struct wlr_renderer_impl wlr_renderer_impl = {
.render_with_matrix = wlr_gles2_render_surface,
.render_quad = wlr_gles2_render_quad,
.render_ellipse = wlr_gles2_render_ellipse,
.formats = wlr_gles2_formats,
.destroy = wlr_gles2_destroy
};

View file

@ -41,3 +41,8 @@ void wlr_render_colored_ellipse(struct wlr_renderer *r,
const float (*color)[4], const float (*matrix)[16]) {
r->impl->render_ellipse(r->state, color, matrix);
}
const enum wl_shm_format *wlr_renderer_get_formats(
struct wlr_renderer *r, size_t *len) {
return r->impl->formats(r->state, len);
}