compositor: Use GL_EXT_unpack_subimage for texture updates

Kristian Høgsberg 13 years ago
parent 8cbfb2a40a
commit fb6de223b2
  1. 20
      src/compositor.c

@ -714,6 +714,9 @@ weston_surface_attach(struct wl_surface *surface, struct wl_buffer *buffer)
if (wl_buffer_is_shm(buffer)) { if (wl_buffer_is_shm(buffer)) {
es->pitch = wl_shm_buffer_get_stride(buffer) / 4; es->pitch = wl_shm_buffer_get_stride(buffer) / 4;
glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT,
es->pitch, es->buffer->height, 0,
GL_BGRA_EXT, GL_UNSIGNED_BYTE, NULL);
} else { } else {
if (es->image != EGL_NO_IMAGE_KHR) if (es->image != EGL_NO_IMAGE_KHR)
ec->destroy_image(ec->display, es->image); ec->destroy_image(ec->display, es->image);
@ -1177,13 +1180,13 @@ surface_damage(struct wl_client *client,
if (es->buffer && wl_buffer_is_shm(es->buffer)) { if (es->buffer && wl_buffer_is_shm(es->buffer)) {
glBindTexture(GL_TEXTURE_2D, es->texture); glBindTexture(GL_TEXTURE_2D, es->texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, glPixelStorei(GL_UNPACK_ROW_LENGTH, es->pitch);
es->pitch, es->buffer->height, 0, glPixelStorei(GL_UNPACK_SKIP_PIXELS, x);
GL_BGRA_EXT, GL_UNSIGNED_BYTE, glPixelStorei(GL_UNPACK_SKIP_ROWS, y);
wl_shm_buffer_get_data(es->buffer));
/* Hmm, should use glTexSubImage2D() here but GLES2 doesn't glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, width, height,
* support any unpack attributes except GL_UNPACK_ALIGNMENT. */ GL_BGRA_EXT, GL_UNSIGNED_BYTE,
wl_shm_buffer_get_data(es->buffer));
} }
} }
@ -2357,6 +2360,11 @@ weston_compositor_init(struct weston_compositor *ec, struct wl_display *display)
return -1; return -1;
} }
if (!strstr(extensions, "GL_EXT_unpack_subimage")) {
fprintf(stderr, "GL_EXT_unpack_subimage not available\n");
return -1;
}
extensions = extensions =
(const char *) eglQueryString(ec->display, EGL_EXTENSIONS); (const char *) eglQueryString(ec->display, EGL_EXTENSIONS);
if (strstr(extensions, "EGL_WL_bind_wayland_display")) if (strstr(extensions, "EGL_WL_bind_wayland_display"))

Loading…
Cancel
Save