[PATCH weston] compositor: automatically set opaque region for color formats

Pekka Paalanen ppaalanen at gmail.com
Tue Sep 4 23:36:59 PDT 2012


Some color formats are naturally opaque: RGB, XRGB, YUV formats without
A channel. For these, automatically set the opaque region to whole
surface.

Note:
If a client first sends a buffer with opaque color format, and then
sends another buffer of the same size but with non-opaque color format,
the opaque region in the server is no longer what the client expects
based on protocol: it has been changed from what the client earlier
specified into whole surface. Therefore this is a protocol change.

---

This patch has been only compile-tested, because I'm not sure we can do
it like this, and temporary opaque region setup would be more complex.

Kristian, do we really want to go there?
---
 src/compositor.c |   21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index 2b963f5..e7c2c88 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -798,10 +798,15 @@ weston_surface_attach(struct wl_surface *surface, struct wl_buffer *buffer)
 		glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT,
 			     es->pitch, es->buffer->height, 0,
 			     GL_BGRA_EXT, GL_UNSIGNED_BYTE, NULL);
-		if (wl_shm_buffer_get_format(buffer) == WL_SHM_FORMAT_XRGB8888)
+		if (wl_shm_buffer_get_format(buffer) == WL_SHM_FORMAT_XRGB8888) {
 			es->shader = &ec->texture_shader_rgbx;
-		else
+			pixman_region32_union_rect(&es->opaque, &es->opaque,
+						   0, 0,
+						   buffer->width,
+						   buffer->height);
+		} else {
 			es->shader = &ec->texture_shader_rgba;
+		}
 	} else if (ec->query_buffer(ec->egl_display, buffer,
 				    EGL_TEXTURE_FORMAT, &format)) {
 		for (i = 0; i < es->num_images; i++)
@@ -834,6 +839,18 @@ weston_surface_attach(struct wl_surface *surface, struct wl_buffer *buffer)
 			break;
 		}
 
+		/* opaque color formats */
+		switch (format) {
+		case EGL_TEXTURE_RGB:
+		case EGL_TEXTURE_Y_UV_WL:
+		case EGL_TEXTURE_Y_U_V_WL:
+		case EGL_TEXTURE_Y_XUXV_WL:
+			pixman_region32_union_rect(&es->opaque, &es->opaque,
+						   0, 0,
+						   buffer->width,
+						   buffer->height);
+		}
+
 		ensure_textures(es, num_planes);
 		for (i = 0; i < num_planes; i++) {
 			attribs[0] = EGL_WAYLAND_PLANE_WL;
-- 
1.7.8.6



More information about the wayland-devel mailing list