summaryrefslogtreecommitdiff
path: root/src/wayland/meta-wayland-buffer.c
diff options
context:
space:
mode:
authorJasper St. Pierre <jstpierre@mecheye.net>2014-10-07 19:48:49 -0700
committerJasper St. Pierre <jstpierre@mecheye.net>2014-10-07 20:42:27 -0700
commitf658740043e43340b5a92bd95022ed2cb5af8896 (patch)
tree807934604a7af5dda1c992a5faf9215361980364 /src/wayland/meta-wayland-buffer.c
parentc1613a16c099b52d63026e1405d45018c00897c5 (diff)
downloadmutter-f658740043e43340b5a92bd95022ed2cb5af8896.tar.gz
wayland: Move some buffer manipulation functions to meta-wayland-buffer
Diffstat (limited to 'src/wayland/meta-wayland-buffer.c')
-rw-r--r--src/wayland/meta-wayland-buffer.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/wayland/meta-wayland-buffer.c b/src/wayland/meta-wayland-buffer.c
index 1c1e76e7c..40db3b0fb 100644
--- a/src/wayland/meta-wayland-buffer.c
+++ b/src/wayland/meta-wayland-buffer.c
@@ -26,6 +26,10 @@
#include "meta-wayland-buffer.h"
+#include <clutter/clutter.h>
+#include <cogl/cogl-wayland-server.h>
+#include <meta/util.h>
+
static void
meta_wayland_buffer_destroy_handler (struct wl_listener *listener,
void *data)
@@ -80,3 +84,54 @@ meta_wayland_buffer_from_resource (struct wl_resource *resource)
return buffer;
}
+
+CoglTexture *
+meta_wayland_buffer_ensure_texture (MetaWaylandBuffer *buffer)
+{
+ CoglContext *ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ());
+ CoglError *catch_error = NULL;
+ CoglTexture *texture;
+
+ if (buffer->texture)
+ goto out;
+
+ texture = COGL_TEXTURE (cogl_wayland_texture_2d_new_from_buffer (ctx,
+ buffer->resource,
+ &catch_error));
+ if (!texture)
+ {
+ cogl_error_free (catch_error);
+ meta_fatal ("Could not import pending buffer, ignoring commit\n");
+ }
+
+ buffer->texture = texture;
+
+ out:
+ return buffer->texture;
+}
+
+void
+meta_wayland_buffer_process_damage (MetaWaylandBuffer *buffer,
+ cairo_region_t *region)
+{
+ struct wl_shm_buffer *shm_buffer;
+
+ shm_buffer = wl_shm_buffer_get (buffer->resource);
+
+ if (shm_buffer)
+ {
+ int i, n_rectangles;
+
+ n_rectangles = cairo_region_num_rectangles (region);
+
+ for (i = 0; i < n_rectangles; i++)
+ {
+ cairo_rectangle_int_t rect;
+ cairo_region_get_rectangle (region, i, &rect);
+ cogl_wayland_texture_set_region_from_shm_buffer (buffer->texture,
+ rect.x, rect.y, rect.width, rect.height,
+ shm_buffer,
+ rect.x, rect.y, 0, NULL);
+ }
+ }
+}