summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2011-03-09 00:08:20 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2011-03-22 14:22:19 +0100
commitda41fbc8d67f68eed3424b8bec184527170a67d3 (patch)
tree16b2aa85ddec2bd5770cf2f045287ad1e6d134ff
parentadc7c575b3a8bb74fefcf5a01ce5b33e3fbdbb8c (diff)
compositor: wl_shm handled by eglBindDWaylandisplay nowshm-in-egl
-rw-r--r--compositor/compositor.c98
-rw-r--r--compositor/compositor.h3
2 files changed, 10 insertions, 91 deletions
diff --git a/compositor/compositor.c b/compositor/compositor.c
index 15f124a..e36c7b6 100644
--- a/compositor/compositor.c
+++ b/compositor/compositor.c
@@ -150,7 +150,6 @@ wlsc_surface_create(struct wlsc_compositor *compositor,
surface->compositor = compositor;
surface->visual = NULL;
- surface->buffer = NULL;
surface->x = x;
surface->y = y;
surface->width = width;
@@ -293,36 +292,15 @@ wlsc_buffer_attach(struct wl_buffer *buffer, struct wl_surface *surface)
struct wlsc_surface *es = (struct wlsc_surface *) surface;
struct wlsc_compositor *ec = es->compositor;
EGLImageKHR *image;
- struct wl_list *surfaces_attached_to;
-
- if (wl_is_shm_buffer(buffer)) {
- glBindTexture(GL_TEXTURE_2D, es->texture);
-
- /* Unbind any EGLImage texture that may be bound, so we don't
- * overwrite it.*/
- glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT,
- 0, 0, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, NULL);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT,
- buffer->width, buffer->height, 0,
- GL_BGRA_EXT, GL_UNSIGNED_BYTE,
- wl_shm_buffer_get_data(buffer));
- es->visual = buffer->visual;
-
- surfaces_attached_to = buffer->user_data;
-
- if (es->buffer)
- wl_list_remove(&es->buffer_link);
- wl_list_insert(surfaces_attached_to, &es->buffer_link);
- } else {
- image = eglCreateImageKHR(ec->display, ec->context,
- EGL_WAYLAND_BUFFER_WL,
- buffer, NULL);
-
- glBindTexture(GL_TEXTURE_2D, es->texture);
- glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
- es->visual = buffer->visual;
- eglDestroyImageKHR(ec->display, image);
- }
+
+ image = eglCreateImageKHR(ec->display, ec->context,
+ EGL_WAYLAND_BUFFER_WL,
+ buffer, NULL);
+
+ glBindTexture(GL_TEXTURE_2D, es->texture);
+ glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
+ es->visual = buffer->visual;
+ eglDestroyImageKHR(ec->display, image);
}
static struct wl_buffer *
@@ -336,7 +314,7 @@ create_buffer_from_png(struct wlsc_compositor *ec,
if(pixels == NULL)
return NULL;
- buffer = wl_shm_buffer_create(ec->shm, width, height, width * 4,
+ buffer = wl_shm_buffer_create(width, height, width * 4,
&ec->compositor.premultiplied_argb_visual,
pixels);
@@ -617,7 +595,6 @@ surface_attach(struct wl_client *client,
wlsc_buffer_attach(buffer, surface);
- es->buffer = buffer;
es->x += x;
es->y += y;
es->width = buffer->width;
@@ -1391,60 +1368,6 @@ wlsc_output_init(struct wlsc_output *output, struct wlsc_compositor *c,
wlsc_output_post_geometry);
}
-static void
-shm_buffer_created(struct wl_buffer *buffer)
-{
- struct wl_list *surfaces_attached_to;
-
- surfaces_attached_to = malloc(sizeof *surfaces_attached_to);
- if (!surfaces_attached_to) {
- buffer->user_data = NULL;
- return;
- }
-
- wl_list_init(surfaces_attached_to);
-
- buffer->user_data = surfaces_attached_to;
-}
-
-static void
-shm_buffer_damaged(struct wl_buffer *buffer,
- int32_t x, int32_t y, int32_t width, int32_t height)
-{
- struct wl_list *surfaces_attached_to = buffer->user_data;
- struct wlsc_surface *es;
-
- wl_list_for_each(es, surfaces_attached_to, buffer_link) {
- glBindTexture(GL_TEXTURE_2D, es->texture);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT,
- buffer->width, buffer->height, 0,
- GL_BGRA_EXT, GL_UNSIGNED_BYTE,
- wl_shm_buffer_get_data(buffer));
- /* Hmm, should use glTexSubImage2D() here but GLES2 doesn't
- * support any unpack attributes except GL_UNPACK_ALIGNMENT. */
- }
-}
-
-static void
-shm_buffer_destroyed(struct wl_buffer *buffer)
-{
- struct wl_list *surfaces_attached_to = buffer->user_data;
- struct wlsc_surface *es, *next;
-
- wl_list_for_each_safe(es, next, surfaces_attached_to, buffer_link) {
- es->buffer = NULL;
- wl_list_remove(&es->buffer_link);
- }
-
- free(surfaces_attached_to);
-}
-
-const static struct wl_shm_callbacks shm_callbacks = {
- shm_buffer_created,
- shm_buffer_damaged,
- shm_buffer_destroyed
-};
-
int
wlsc_compositor_init(struct wlsc_compositor *ec, struct wl_display *display)
{
@@ -1455,7 +1378,6 @@ wlsc_compositor_init(struct wlsc_compositor *ec, struct wl_display *display)
wl_compositor_init(&ec->compositor, &compositor_interface, display);
- ec->shm = wl_shm_init(display, &shm_callbacks);
eglBindWaylandDisplayWL(ec->display, ec->wl_display);
wlsc_shell_init(ec);
diff --git a/compositor/compositor.h b/compositor/compositor.h
index ed51d0c..6666929 100644
--- a/compositor/compositor.h
+++ b/compositor/compositor.h
@@ -78,8 +78,6 @@ struct wlsc_input_device {
struct wlsc_compositor {
struct wl_compositor compositor;
- struct wl_shm *shm;
-
EGLDisplay display;
EGLContext context;
EGLConfig config;
@@ -144,7 +142,6 @@ struct wlsc_surface {
struct wlsc_matrix matrix;
struct wlsc_matrix matrix_inv;
struct wl_visual *visual;
- struct wl_buffer *buffer;
enum wlsc_surface_map_type map_type;
struct wlsc_output *fullscreen_output;
};