Move away from visuals and just use EGLConfigs or shm format tokens
This commit is contained in:
@@ -46,7 +46,6 @@ struct wayland_compositor {
|
||||
struct wl_compositor *compositor;
|
||||
struct wl_shell *shell;
|
||||
struct wl_output *output;
|
||||
struct wl_visual *visual;
|
||||
|
||||
struct {
|
||||
int32_t x, y, width, height;
|
||||
@@ -104,6 +103,7 @@ wayland_compositor_init_egl(struct wayland_compositor *c)
|
||||
EGL_RED_SIZE, 1,
|
||||
EGL_GREEN_SIZE, 1,
|
||||
EGL_BLUE_SIZE, 1,
|
||||
EGL_ALPHA_SIZE, 0,
|
||||
EGL_DEPTH_SIZE, 1,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
EGL_NONE
|
||||
@@ -257,8 +257,7 @@ wayland_compositor_create_output(struct wayland_compositor *c,
|
||||
wl_surface_set_user_data(output->parent.surface, output);
|
||||
|
||||
output->parent.egl_window =
|
||||
wl_egl_window_create(output->parent.surface,
|
||||
width, height, c->parent.visual);
|
||||
wl_egl_window_create(output->parent.surface, width, height);
|
||||
if (!output->parent.egl_window) {
|
||||
fprintf(stderr, "failure to create wl_egl_window\n");
|
||||
goto cleanup_output;
|
||||
@@ -462,25 +461,6 @@ display_add_input(struct wayland_compositor *c, uint32_t id)
|
||||
wl_input_device_set_user_data(input->input_device, input);
|
||||
}
|
||||
|
||||
static void
|
||||
compositor_handle_visual(void *data,
|
||||
struct wl_compositor *compositor,
|
||||
uint32_t id, uint32_t token)
|
||||
{
|
||||
struct wayland_compositor *c = data;
|
||||
|
||||
switch (token) {
|
||||
case WL_COMPOSITOR_VISUAL_ARGB32:
|
||||
c->parent.visual = wl_display_bind(c->parent.display,
|
||||
id, &wl_visual_interface);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static const struct wl_compositor_listener compositor_listener = {
|
||||
compositor_handle_visual,
|
||||
};
|
||||
|
||||
static void
|
||||
display_handle_global(struct wl_display *display, uint32_t id,
|
||||
const char *interface, uint32_t version, void *data)
|
||||
@@ -490,8 +470,6 @@ display_handle_global(struct wl_display *display, uint32_t id,
|
||||
if (strcmp(interface, "wl_compositor") == 0) {
|
||||
c->parent.compositor =
|
||||
wl_display_bind(display, id, &wl_compositor_interface);
|
||||
wl_compositor_add_listener(c->parent.compositor,
|
||||
&compositor_listener, c);
|
||||
} else if (strcmp(interface, "wl_output") == 0) {
|
||||
c->parent.output =
|
||||
wl_display_bind(display, id, &wl_output_interface);
|
||||
|
||||
+32
-16
@@ -244,7 +244,7 @@ wlsc_surface_create(struct wlsc_compositor *compositor,
|
||||
surface->surface.resource.client = NULL;
|
||||
|
||||
surface->compositor = compositor;
|
||||
surface->visual = NULL;
|
||||
surface->visual = WLSC_NONE_VISUAL;
|
||||
surface->image = EGL_NO_IMAGE_KHR;
|
||||
surface->saved_texture = 0;
|
||||
surface->x = x;
|
||||
@@ -308,8 +308,6 @@ WL_EXPORT void
|
||||
wlsc_surface_configure(struct wlsc_surface *surface,
|
||||
int x, int y, int width, int height)
|
||||
{
|
||||
struct wlsc_compositor *compositor = surface->compositor;
|
||||
|
||||
wlsc_surface_damage_below(surface);
|
||||
|
||||
surface->x = x;
|
||||
@@ -321,7 +319,7 @@ wlsc_surface_configure(struct wlsc_surface *surface,
|
||||
wlsc_surface_damage(surface);
|
||||
|
||||
pixman_region32_fini(&surface->opaque);
|
||||
if (surface->visual == &compositor->compositor.rgb_visual)
|
||||
if (surface->visual == WLSC_RGB_VISUAL)
|
||||
pixman_region32_init_rect(&surface->opaque,
|
||||
surface->x, surface->y,
|
||||
surface->width, surface->height);
|
||||
@@ -388,7 +386,18 @@ wlsc_buffer_attach(struct wl_buffer *buffer, struct wl_surface *surface)
|
||||
es->pitch, buffer->height, 0,
|
||||
GL_BGRA_EXT, GL_UNSIGNED_BYTE,
|
||||
wl_shm_buffer_get_data(buffer));
|
||||
es->visual = buffer->visual;
|
||||
|
||||
switch (wl_shm_buffer_get_format(buffer)) {
|
||||
case WL_SHM_FORMAT_ARGB32:
|
||||
es->visual = WLSC_ARGB_VISUAL;
|
||||
break;
|
||||
case WL_SHM_FORMAT_PREMULTIPLIED_ARGB32:
|
||||
es->visual = WLSC_PREMUL_ARGB_VISUAL;
|
||||
break;
|
||||
case WL_SHM_FORMAT_XRGB32:
|
||||
es->visual = WLSC_RGB_VISUAL;
|
||||
break;
|
||||
}
|
||||
|
||||
surfaces_attached_to = buffer->user_data;
|
||||
|
||||
@@ -402,7 +411,9 @@ wlsc_buffer_attach(struct wl_buffer *buffer, struct wl_surface *surface)
|
||||
buffer, NULL);
|
||||
|
||||
ec->image_target_texture_2d(GL_TEXTURE_2D, es->image);
|
||||
es->visual = buffer->visual;
|
||||
|
||||
/* FIXME: we need to get the visual from the wl_buffer */
|
||||
es->visual = WLSC_PREMUL_ARGB_VISUAL;
|
||||
es->pitch = es->width;
|
||||
}
|
||||
}
|
||||
@@ -453,7 +464,7 @@ create_sprite_from_png(struct wlsc_compositor *ec,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sprite->visual = &ec->compositor.premultiplied_argb_visual;
|
||||
sprite->visual = WLSC_PREMUL_ARGB_VISUAL;
|
||||
sprite->width = width;
|
||||
sprite->height = height;
|
||||
sprite->image = EGL_NO_IMAGE_KHR;
|
||||
@@ -646,14 +657,21 @@ wlsc_surface_draw(struct wlsc_surface *es,
|
||||
if (!pixman_region32_not_empty(&repaint))
|
||||
return;
|
||||
|
||||
if (es->visual == &ec->compositor.argb_visual) {
|
||||
switch (es->visual) {
|
||||
case WLSC_ARGB_VISUAL:
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
} else if (es->visual == &ec->compositor.premultiplied_argb_visual) {
|
||||
break;
|
||||
case WLSC_PREMUL_ARGB_VISUAL:
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
} else {
|
||||
break;
|
||||
case WLSC_RGB_VISUAL:
|
||||
glDisable(GL_BLEND);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "bogus visual\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (es->transform == NULL) {
|
||||
@@ -760,10 +778,9 @@ fade_output(struct wlsc_output *output,
|
||||
surface.transform = NULL;
|
||||
|
||||
if (tint <= 1.0)
|
||||
surface.visual =
|
||||
&compositor->compositor.premultiplied_argb_visual;
|
||||
surface.visual = WLSC_PREMUL_ARGB_VISUAL;
|
||||
else
|
||||
surface.visual = &compositor->compositor.rgb_visual;
|
||||
surface.visual = WLSC_RGB_VISUAL;
|
||||
|
||||
glUseProgram(compositor->solid_shader.program);
|
||||
glUniformMatrix4fv(compositor->solid_shader.proj_uniform,
|
||||
@@ -855,7 +872,7 @@ wlsc_output_repaint(struct wlsc_output *output)
|
||||
|
||||
es = container_of(ec->surface_list.next, struct wlsc_surface, link);
|
||||
|
||||
if (es->visual == &ec->compositor.rgb_visual &&
|
||||
if (es->visual == WLSC_RGB_VISUAL &&
|
||||
output->prepare_scanout_surface(output, es) == 0) {
|
||||
/* We're drawing nothing now,
|
||||
* draw the damaged regions later. */
|
||||
@@ -1028,10 +1045,9 @@ surface_attach(struct wl_client *client,
|
||||
wl_list_insert(es->buffer->resource.destroy_listener_list.prev,
|
||||
&es->buffer_destroy_listener.link);
|
||||
|
||||
if (es->visual == NULL)
|
||||
if (es->visual == WLSC_NONE_VISUAL)
|
||||
wl_list_insert(&es->compositor->surface_list, &es->link);
|
||||
|
||||
es->visual = buffer->visual;
|
||||
if (x != 0 || y != 0 ||
|
||||
es->width != buffer->width || es->height != buffer->height)
|
||||
wlsc_surface_configure(es, es->x + x, es->y + y,
|
||||
|
||||
@@ -114,10 +114,17 @@ struct wlsc_input_device {
|
||||
struct wl_selection *selection;
|
||||
};
|
||||
|
||||
enum wlsc_visual {
|
||||
WLSC_NONE_VISUAL,
|
||||
WLSC_ARGB_VISUAL,
|
||||
WLSC_PREMUL_ARGB_VISUAL,
|
||||
WLSC_RGB_VISUAL
|
||||
};
|
||||
|
||||
struct wlsc_sprite {
|
||||
GLuint texture;
|
||||
EGLImageKHR image;
|
||||
struct wl_visual *visual;
|
||||
uint32_t visual;
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
@@ -248,7 +255,7 @@ struct wlsc_surface {
|
||||
struct wl_list link;
|
||||
struct wl_list buffer_link;
|
||||
struct wlsc_transform *transform;
|
||||
struct wl_visual *visual;
|
||||
uint32_t visual;
|
||||
struct wlsc_output *output;
|
||||
enum wlsc_surface_map_type map_type;
|
||||
struct wlsc_output *fullscreen_output;
|
||||
|
||||
Reference in New Issue
Block a user