summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPekka Paalanen <ppaalanen@gmail.com>2012-04-11 16:19:37 +0300
committerPekka Paalanen <ppaalanen@gmail.com>2012-04-17 14:36:00 +0300
commit52bfbaae14cb1e382c7fe19186a7d73e6aa1a075 (patch)
tree51294a1a3eac778c829b48dfd758e6a951d34a4d
parent2eaa11e954c6fd93e18ca0f6dea56ea6d5c4516e (diff)
compositor: use GL_EXT_unpack_subimage only if available
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
-rw-r--r--src/compositor.c43
-rw-r--r--src/compositor.h3
2 files changed, 33 insertions, 13 deletions
diff --git a/src/compositor.c b/src/compositor.c
index 03f0eb1..e0cba67 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1166,24 +1166,43 @@ surface_attach(struct wl_client *client,
}
static void
-surface_damage(struct wl_client *client,
- struct wl_resource *resource,
- int32_t x, int32_t y, int32_t width, int32_t height)
+texture_set_subimage(struct weston_surface *surface,
+ int32_t x, int32_t y, int32_t width, int32_t height)
{
- struct weston_surface *es = resource->data;
+ glBindTexture(GL_TEXTURE_2D, surface->texture);
- weston_surface_damage_rectangle(es, x, y, width, height);
+#ifdef GL_UNPACK_ROW_LENGTH
+ /* Mesa does not define GL_EXT_unpack_subimage */
- if (es->buffer && wl_buffer_is_shm(es->buffer)) {
- glBindTexture(GL_TEXTURE_2D, es->texture);
- glPixelStorei(GL_UNPACK_ROW_LENGTH, es->pitch);
+ if (surface->compositor->has_unpack_subimage) {
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, surface->pitch);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, x);
glPixelStorei(GL_UNPACK_SKIP_ROWS, y);
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, width, height,
GL_BGRA_EXT, GL_UNSIGNED_BYTE,
- wl_shm_buffer_get_data(es->buffer));
+ wl_shm_buffer_get_data(surface->buffer));
+ return;
}
+#endif
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT,
+ surface->pitch, surface->buffer->height, 0,
+ GL_BGRA_EXT, GL_UNSIGNED_BYTE,
+ wl_shm_buffer_get_data(surface->buffer));
+}
+
+static void
+surface_damage(struct wl_client *client,
+ struct wl_resource *resource,
+ int32_t x, int32_t y, int32_t width, int32_t height)
+{
+ struct weston_surface *es = resource->data;
+
+ weston_surface_damage_rectangle(es, x, y, width, height);
+
+ if (es->buffer && wl_buffer_is_shm(es->buffer))
+ texture_set_subimage(es, x, y, width, height);
}
static void
@@ -2372,10 +2391,8 @@ weston_compositor_init(struct weston_compositor *ec, struct wl_display *display)
return -1;
}
- if (!strstr(extensions, "GL_EXT_unpack_subimage")) {
- fprintf(stderr, "GL_EXT_unpack_subimage not available\n");
- return -1;
- }
+ if (strstr(extensions, "GL_EXT_unpack_subimage"))
+ ec->has_unpack_subimage = 1;
extensions =
(const char *) eglQueryString(ec->display, EGL_EXTENSIONS);
diff --git a/src/compositor.h b/src/compositor.h
index a27a7a0..e381e66 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -221,6 +221,9 @@ struct weston_compositor {
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC image_target_texture_2d;
PFNEGLCREATEIMAGEKHRPROC create_image;
PFNEGLDESTROYIMAGEKHRPROC destroy_image;
+
+ int has_unpack_subimage;
+
PFNEGLBINDWAYLANDDISPLAYWL bind_display;
PFNEGLUNBINDWAYLANDDISPLAYWL unbind_display;
int has_bind_display;