[PATCH] select rgba / gbra at compile time
twied
twied at gmx.net
Mon Jan 17 17:53:46 PST 2011
Hi,
sorry for spamming. This patch is a temporary solution for the rgba vs. bgra problem.
The --enable-rgba configure switch (defaulting to disabled = bgra) allows Wayland to
compile and run while mesa doesn't support bgra yet.
---
compositor/compositor.c | 5 +++++
compositor/drm.c | 5 +++++
compositor/shm.c | 14 ++++++++++++++
configure.ac | 9 +++++++++
4 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/compositor/compositor.c b/compositor/compositor.c
index cd13e4d..abec2f4 100644
--- a/compositor/compositor.c
+++ b/compositor/compositor.c
@@ -1424,12 +1424,17 @@ wlsc_compositor_init(struct wlsc_compositor *ec, struct wl_display *display)
screenshooter_create(ec);
+#if USE_DEPRECATED_RGBA
+ printf("using deprecated RGBA color format\n");
+ (void) extensions;
+#else
extensions = (const char *) glGetString(GL_EXTENSIONS);
if (!strstr(extensions, "GL_EXT_texture_format_BGRA8888")) {
fprintf(stderr,
"GL_EXT_texture_format_BGRA8888 not available\n");
return -1;
}
+#endif
glGenFramebuffers(1, &ec->fbo);
glBindFramebuffer(GL_FRAMEBUFFER, ec->fbo);
diff --git a/compositor/drm.c b/compositor/drm.c
index 9e25d33..951bb12 100644
--- a/compositor/drm.c
+++ b/compositor/drm.c
@@ -237,8 +237,13 @@ wlsc_drm_buffer_create(struct wlsc_compositor *ec, int width, int height,
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, buffer->image);
+#if USE_DEPRECATED_RGBA
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height,
+ GL_RGBA, GL_UNSIGNED_BYTE, data);
+#else
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height,
GL_BGRA_EXT, GL_UNSIGNED_BYTE, data);
+#endif
glDeleteTextures(1, &texture);
diff --git a/compositor/shm.c b/compositor/shm.c
index 6b96a5b..9a7fd7e 100644
--- a/compositor/shm.c
+++ b/compositor/shm.c
@@ -61,11 +61,19 @@ shm_buffer_attach(struct wl_buffer *buffer_base, struct wl_surface *surface)
/* Unbind any EGLImage texture that may be bound, so we don't
* overwrite it.*/
+#if USE_DEPRECATED_RGBA
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
+ 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
+ buffer->buffer.width, buffer->buffer.height, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, buffer->data);
+#else
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
0, 0, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, NULL);
glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT,
buffer->buffer.width, buffer->buffer.height, 0,
GL_BGRA_EXT, GL_UNSIGNED_BYTE, buffer->data);
+#endif
es->visual = buffer->buffer.visual;
}
@@ -79,9 +87,15 @@ shm_buffer_damage(struct wl_buffer *buffer_base,
(struct wlsc_shm_buffer *) buffer_base;
glBindTexture(GL_TEXTURE_2D, es->texture);
+#if USE_DEPRECATED_RGBA
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
+ buffer->buffer.width, buffer->buffer.height, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, buffer->data);
+#else
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
buffer->buffer.width, buffer->buffer.height, 0,
GL_BGRA_EXT, GL_UNSIGNED_BYTE, buffer->data);
+#endif
/* Hmm, should use glTexSubImage2D() here but GLES2 doesn't
* support any unpack attributes except GL_UNPACK_ALIGNMENT. */
diff --git a/configure.ac b/configure.ac
index bcc1e83..fcf0f21 100644
--- a/configure.ac
+++ b/configure.ac
@@ -55,6 +55,15 @@ if test x$enable_wayland_compositor == xyes; then
fi
+AC_ARG_ENABLE([bgra],
+ [AS_HELP_STRING([--disabled-bgra],
+ [use deprecated rgba @<:@default=enable@:>@])],
+ [enable_bgra="$enableval"],
+ [enable_bgra=yes])
+if test "x$enable_bgra" == "xno"; then
+ AC_DEFINE([USE_DEPRECATED_RGBA], [1], [use deprecated rgba])
+fi
+
PKG_CHECK_MODULES(CAIRO_EGL, [cairo-egl],
[have_cairo_egl=yes], [have_cairo_egl=no])
AS_IF([test "x$have_cairo_egl" = "xyes"],
--
1.7.2.3
More information about the wayland-devel
mailing list