diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-02-04 00:39:29 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-02-04 00:39:29 +0100 |
commit | 6979c89b30396d5567445112a3996af60130df71 (patch) | |
tree | 7b02cf3bc86a0955765b92d4db0148dac6b34ef8 | |
parent | fa39f4f3192c52658d1b371a3f26849840456a82 (diff) |
st/egl/wayland: Cleanup, put structs in header etcegl-wayland2egl-wayland
-rw-r--r-- | src/gallium/state_trackers/egl/wayland/native_wayland.c | 105 | ||||
-rw-r--r-- | src/gallium/state_trackers/egl/wayland/native_wayland.h | 90 |
2 files changed, 115 insertions, 80 deletions
diff --git a/src/gallium/state_trackers/egl/wayland/native_wayland.c b/src/gallium/state_trackers/egl/wayland/native_wayland.c index 665225cd82..cdc4782f9b 100644 --- a/src/gallium/state_trackers/egl/wayland/native_wayland.c +++ b/src/gallium/state_trackers/egl/wayland/native_wayland.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 7.8 + * Version: 7.11 * - * Copyright (C) 2010 Benjamin Franzke <benjaminfranzke@googlemail.com> + * Copyright (C) 2011 Benjamin Franzke <benjaminfranzke@googlemail.com> * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -23,11 +23,7 @@ * DEALINGS IN THE SOFTWARE. */ -#include "common/native.h" -#include "common/native_helper.h" - #include "util/u_memory.h" -#include "util/u_string.h" #include "util/u_inlines.h" #include "pipe/p_compiler.h" @@ -36,12 +32,14 @@ #include "pipe/p_state.h" #include "state_tracker/drm_driver.h" +#include "egllog.h" + +#include "native_wayland.h" + /* see get_drm_screen_name */ #include <radeon_drm.h> #include "radeon/drm/radeon_drm_public.h" -#include "egllog.h" - #include <wayland-client.h> #include "wayland-egl-priv.h" @@ -53,59 +51,6 @@ static struct native_event_handler *wayland_event_handler; -struct wayland_display { - struct native_display base; - - struct wayland_config *config; - struct wl_egl_display *dpy; -}; - -enum wayland_buffer_type { - WL_BUFFER_FRONT, - WL_BUFFER_BACK, - WL_BUFFER_COUNT -}; - -struct wayland_surface { - struct native_surface base; - struct wayland_display *display; - - struct wl_egl_window *win; - struct wl_egl_pixmap *pix; - struct resource_surface *rsurf; - enum pipe_format color_format; - - unsigned int sequence_number; - struct wl_buffer *buffer[WL_BUFFER_COUNT]; - unsigned int wl_buffers_invalid; - - boolean block_swap_buffers; - - boolean is_pixmap; -}; - -struct wayland_config { - struct native_config base; -}; - -static INLINE struct wayland_display * -wayland_display(const struct native_display *ndpy) -{ - return (struct wayland_display *) ndpy; -} - -static INLINE struct wayland_surface * -wayland_surface(const struct native_surface *nsurf) -{ - return (struct wayland_surface *) nsurf; -} - -static INLINE struct wayland_config * -wayland_config(const struct native_config *nconf) -{ - return (struct wayland_config *) nconf; -} - static const struct native_config ** wayland_display_get_configs (struct native_display *ndpy, int *num_configs) { @@ -124,9 +69,7 @@ wayland_display_get_configs (struct native_display *ndpy, int *num_configs) (1 << NATIVE_ATTACHMENT_FRONT_LEFT) | (1 << NATIVE_ATTACHMENT_BACK_LEFT); - /* FIXME: check format */ - format = PIPE_FORMAT_B8G8R8A8_UNORM; - /* format = PIPE_FORMAT_B8G8R8X8_UNORM; */ + format = PIPE_FORMAT_B8G8R8X8_UNORM; nconf->color_format = format; nconf->window_bit = TRUE; @@ -143,7 +86,6 @@ wayland_display_get_configs (struct native_display *ndpy, int *num_configs) return configs; } - static int wayland_display_get_param(struct native_display *ndpy, enum native_param_type param) @@ -167,6 +109,8 @@ wayland_display_is_pixmap_supported(struct native_display *ndpy, EGLNativePixmapType pix, const struct native_config *nconf) { + /* all wl_egl_pixmaps are supported */ + return TRUE; } @@ -225,17 +169,18 @@ wayland_surface_validate(struct native_surface *nsurf, uint attachment_mask, int *width, int *height) { struct wayland_surface *surface = wayland_surface(nsurf); - static uint priv_attachment_mask = (1 << NATIVE_ATTACHMENT_FRONT_LEFT) | - (1 << NATIVE_ATTACHMENT_BACK_LEFT); struct pipe_resource *resource; struct winsys_handle wsh; enum native_attachment natt = NATIVE_ATTACHMENT_FRONT_LEFT; int i; - if (!surface->is_pixmap && resource_surface_set_size(surface->rsurf, - surface->win->width, surface->win->height)) { - resource_surface_add_resources(surface->rsurf, priv_attachment_mask); + attachment_mask |= (1 << natt); + if (!surface->is_pixmap) + attachment_mask |= (1 << NATIVE_ATTACHMENT_BACK_LEFT); + + if (!surface->is_pixmap && resource_surface_set_size(surface->rsurf, + surface->win->width, surface->win->height)) { for (i = 0; i < WL_BUFFER_COUNT; ++i) { if (surface->buffer[i]) wl_buffer_destroy(surface->buffer[i]); @@ -337,7 +282,6 @@ wayland_surface_present(struct native_surface *nsurf, switch (natt) { case NATIVE_ATTACHMENT_FRONT_LEFT: - /* ret = wayland_surface_flush_frontbuffer(nsurf); */ ret = TRUE; break; case NATIVE_ATTACHMENT_BACK_LEFT: @@ -349,8 +293,8 @@ wayland_surface_present(struct native_surface *nsurf, } if (!surface->is_pixmap) - wl_surface_damage(surface->win->surface, 0, 0, - surface->win->width, surface->win->height); + wl_surface_damage(surface->win->surface, 0, 0, + surface->win->width, surface->win->height); return ret; @@ -379,8 +323,8 @@ wayland_surface_destroy(struct native_surface *nsurf) static struct native_surface * wayland_create_pixmap_surface(struct native_display *ndpy, - EGLNativePixmapType pix, - const struct native_config *nconf) + EGLNativePixmapType pix, + const struct native_config *nconf) { struct wayland_display *display = wayland_display(ndpy); struct wayland_config *config = wayland_config(nconf); @@ -394,9 +338,9 @@ wayland_create_pixmap_surface(struct native_display *ndpy, surface->display = display; if (config) - surface->color_format = config->base.color_format; + surface->color_format = config->base.color_format; else - surface->color_format = PIPE_FORMAT_B8G8R8A8_UNORM; + surface->color_format = PIPE_FORMAT_B8G8R8X8_UNORM; surface->is_pixmap = TRUE; surface->pix = egl_pixmap; @@ -507,6 +451,7 @@ wayland_display_init_screen(struct native_display *ndpy) return FALSE; } + /* FIXME: share this with native_drm or egl_dri2 */ driver_name = get_drm_screen_name(display->dpy->fd, version); display->base.screen = @@ -526,7 +471,7 @@ wayland_display_init_screen(struct native_display *ndpy) static void wayland_set_event_handler(struct native_event_handler *event_handler) { - wayland_event_handler = event_handler; + wayland_event_handler = event_handler; } static struct pipe_resource * @@ -540,8 +485,8 @@ wayland_display_import_buffer(struct native_display *ndpy, static boolean wayland_display_export_buffer(struct native_display *ndpy, - struct pipe_resource *res, - void *buf) + struct pipe_resource *res, + void *buf) { return ndpy->screen->resource_get_handle(ndpy->screen, res, (struct winsys_handle *) buf); diff --git a/src/gallium/state_trackers/egl/wayland/native_wayland.h b/src/gallium/state_trackers/egl/wayland/native_wayland.h new file mode 100644 index 0000000000..c349a95f69 --- /dev/null +++ b/src/gallium/state_trackers/egl/wayland/native_wayland.h @@ -0,0 +1,90 @@ +/* + * Mesa 3-D graphics library + * Version: 7.11 + * + * Copyright (C) 2011 Benjamin Franzke <benjaminfranzke@googlemail.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef _NATIVE_WAYLAND_H_ +#define _NATIVE_WAYLAND_H_ + +#include "pipe/p_compiler.h" +#include "pipe/p_format.h" + +#include "common/native.h" +#include "common/native_helper.h" + +#include "wayland-egl-priv.h" + +struct wayland_display { + struct native_display base; + + struct wayland_config *config; + struct wl_egl_display *dpy; +}; + +enum wayland_buffer_type { + WL_BUFFER_FRONT, + WL_BUFFER_BACK, + WL_BUFFER_COUNT +}; + +struct wayland_surface { + struct native_surface base; + struct wayland_display *display; + + struct wl_egl_window *win; + struct wl_egl_pixmap *pix; + struct resource_surface *rsurf; + enum pipe_format color_format; + + unsigned int sequence_number; + struct wl_buffer *buffer[WL_BUFFER_COUNT]; + unsigned int wl_buffers_invalid; + + boolean block_swap_buffers; + + boolean is_pixmap; +}; + +struct wayland_config { + struct native_config base; +}; + +static INLINE struct wayland_display * +wayland_display(const struct native_display *ndpy) +{ + return (struct wayland_display *) ndpy; +} + +static INLINE struct wayland_surface * +wayland_surface(const struct native_surface *nsurf) +{ + return (struct wayland_surface *) nsurf; +} + +static INLINE struct wayland_config * +wayland_config(const struct native_config *nconf) +{ + return (struct wayland_config *) nconf; +} + +#endif /* _NATIVE_WAYLAND_H_ */ |