mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-01 22:58:40 -04:00
Remove the wl_visual interface
The visual interface was meant to be a generic mechanism for specifying the content of a buffer. It goes back to before we had the buffer factory interfaces (like wl_drm and wl_shm) and we wanted to keep it open-ended enough that yuv, png or even svg buffer or so would be possible. Now that we have the buffer abstraction, we can add different buffer types by introducing new interfaces that create buffers. It only makes sense to leave it to those interfaces to specify the contents of the buffers. For wl_shm, this means that we now just specify the pixel format using an enum. For EGL buffers, the exact pixel formats are controlled by the implementation (part of wl_drm and similar), and from the client point of view, everything is controlled using EGLConfigs.
This commit is contained in:
parent
f9c8a691b2
commit
c640571c00
5 changed files with 50 additions and 88 deletions
|
|
@ -93,32 +93,27 @@
|
||||||
<request name="create_surface">
|
<request name="create_surface">
|
||||||
<arg name="id" type="new_id" interface="wl_surface"/>
|
<arg name="id" type="new_id" interface="wl_surface"/>
|
||||||
</request>
|
</request>
|
||||||
|
|
||||||
<enum name="visual">
|
|
||||||
<entry name="argb32" value="0"/>
|
|
||||||
<entry name="premultiplied_argb32" value="1"/>
|
|
||||||
<entry name="xrgb32" value="2"/>
|
|
||||||
</enum>
|
|
||||||
|
|
||||||
<event name="token_visual">
|
|
||||||
<arg name="name" type="uint"/>
|
|
||||||
<arg name="token" type="uint"/>
|
|
||||||
</event>
|
|
||||||
</interface>
|
</interface>
|
||||||
|
|
||||||
<!-- Shared memory support -->
|
<!-- Shared memory support -->
|
||||||
<interface name="wl_shm" version="1">
|
<interface name="wl_shm" version="1">
|
||||||
<enum name="error">
|
<enum name="error">
|
||||||
<entry name="invalid_visual" value="0"/>
|
<entry name="invalid_format" value="0"/>
|
||||||
<entry name="invalid_stride" value="1"/>
|
<entry name="invalid_stride" value="1"/>
|
||||||
<entry name="invalid_fd" value="2"/>
|
<entry name="invalid_fd" value="2"/>
|
||||||
</enum>
|
</enum>
|
||||||
|
|
||||||
|
<enum name="format">
|
||||||
|
<entry name="argb32" value="0"/>
|
||||||
|
<entry name="premultiplied_argb32" value="1"/>
|
||||||
|
<entry name="xrgb32" value="2"/>
|
||||||
|
</enum>
|
||||||
|
|
||||||
<!-- Transfer a shm buffer to the server. The allocated buffer
|
<!-- Transfer a shm buffer to the server. The allocated buffer
|
||||||
would include at least stride * height bytes starting at the
|
would include at least stride * height bytes starting at the
|
||||||
beginning of fd. The file descriptor is transferred over the
|
beginning of fd. The file descriptor is transferred over the
|
||||||
socket using AF_UNIX magical features. width, height, stride
|
socket using AF_UNIX magical features. width, height, stride
|
||||||
and visual describe the respective properties of the pixel
|
and format describe the respective properties of the pixel
|
||||||
data contained in the buffer. -->
|
data contained in the buffer. -->
|
||||||
<request name="create_buffer">
|
<request name="create_buffer">
|
||||||
<arg name="id" type="new_id" interface="wl_buffer"/>
|
<arg name="id" type="new_id" interface="wl_buffer"/>
|
||||||
|
|
@ -126,8 +121,12 @@
|
||||||
<arg name="width" type="int"/>
|
<arg name="width" type="int"/>
|
||||||
<arg name="height" type="int"/>
|
<arg name="height" type="int"/>
|
||||||
<arg name="stride" type="uint"/>
|
<arg name="stride" type="uint"/>
|
||||||
<arg name="visual" type="object" interface="wl_visual"/>
|
<arg name="format" type="uint"/>
|
||||||
</request>
|
</request>
|
||||||
|
|
||||||
|
<event name="format">
|
||||||
|
<arg name="format" type="uint"/>
|
||||||
|
</event>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -547,10 +546,4 @@
|
||||||
</event>
|
</event>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
||||||
|
|
||||||
<!-- A visual is the pixel format. The different visuals are
|
|
||||||
currently only identified by the order they are advertised by
|
|
||||||
the 'global' events. We need something better. -->
|
|
||||||
<interface name="wl_visual" version="1"/>
|
|
||||||
|
|
||||||
</protocol>
|
</protocol>
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,7 @@ struct wl_egl_pixmap;
|
||||||
|
|
||||||
struct wl_egl_window *
|
struct wl_egl_window *
|
||||||
wl_egl_window_create(struct wl_surface *surface,
|
wl_egl_window_create(struct wl_surface *surface,
|
||||||
int width, int height,
|
int width, int height);
|
||||||
struct wl_visual *visual);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
wl_egl_window_destroy(struct wl_egl_window *egl_window);
|
wl_egl_window_destroy(struct wl_egl_window *egl_window);
|
||||||
|
|
@ -53,8 +52,7 @@ wl_egl_window_get_attached_size(struct wl_egl_window *egl_window,
|
||||||
int *width, int *height);
|
int *width, int *height);
|
||||||
|
|
||||||
struct wl_egl_pixmap *
|
struct wl_egl_pixmap *
|
||||||
wl_egl_pixmap_create(int width, int height,
|
wl_egl_pixmap_create(int width, int height, uint32_t flags);
|
||||||
struct wl_visual *visual, uint32_t flags);
|
|
||||||
void
|
void
|
||||||
wl_egl_pixmap_destroy(struct wl_egl_pixmap *egl_pixmap);
|
wl_egl_pixmap_destroy(struct wl_egl_pixmap *egl_pixmap);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -858,28 +858,6 @@ compositor_bind(struct wl_client *client,
|
||||||
compositor->interface, id, compositor);
|
compositor->interface, id, compositor);
|
||||||
if (resource == NULL)
|
if (resource == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wl_resource_post_event(resource,
|
|
||||||
WL_COMPOSITOR_TOKEN_VISUAL,
|
|
||||||
compositor->argb_visual.name,
|
|
||||||
WL_COMPOSITOR_VISUAL_ARGB32);
|
|
||||||
|
|
||||||
wl_resource_post_event(resource,
|
|
||||||
WL_COMPOSITOR_TOKEN_VISUAL,
|
|
||||||
compositor->premultiplied_argb_visual.name,
|
|
||||||
WL_COMPOSITOR_VISUAL_PREMULTIPLIED_ARGB32);
|
|
||||||
|
|
||||||
wl_resource_post_event(resource,
|
|
||||||
WL_COMPOSITOR_TOKEN_VISUAL,
|
|
||||||
compositor->rgb_visual.name,
|
|
||||||
WL_COMPOSITOR_VISUAL_XRGB32);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
bind_visual(struct wl_client *client,
|
|
||||||
void *data, uint32_t version, uint32_t id)
|
|
||||||
{
|
|
||||||
wl_client_add_object(client, &wl_visual_interface, NULL, id, data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WL_EXPORT int
|
WL_EXPORT int
|
||||||
|
|
@ -895,24 +873,5 @@ wl_compositor_init(struct wl_compositor *compositor,
|
||||||
if (!global)
|
if (!global)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
global = wl_display_add_global(display, &wl_visual_interface,
|
|
||||||
&compositor->argb_visual, bind_visual);
|
|
||||||
if (!global)
|
|
||||||
return -1;
|
|
||||||
compositor->argb_visual.name = global->name;
|
|
||||||
|
|
||||||
global = wl_display_add_global(display, &wl_visual_interface,
|
|
||||||
&compositor->premultiplied_argb_visual,
|
|
||||||
bind_visual);
|
|
||||||
if (!global)
|
|
||||||
return -1;
|
|
||||||
compositor->premultiplied_argb_visual.name = global->name;
|
|
||||||
|
|
||||||
global = wl_display_add_global(display, &wl_visual_interface,
|
|
||||||
&compositor->rgb_visual, bind_visual);
|
|
||||||
if (!global)
|
|
||||||
return -1;
|
|
||||||
compositor->rgb_visual.name = global->name;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -117,11 +117,6 @@ struct wl_resource {
|
||||||
void *data;
|
void *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wl_visual {
|
|
||||||
struct wl_object object;
|
|
||||||
uint32_t name;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct wl_shm_callbacks {
|
struct wl_shm_callbacks {
|
||||||
void (*buffer_created)(struct wl_buffer *buffer);
|
void (*buffer_created)(struct wl_buffer *buffer);
|
||||||
|
|
||||||
|
|
@ -134,14 +129,10 @@ struct wl_shm_callbacks {
|
||||||
|
|
||||||
struct wl_compositor {
|
struct wl_compositor {
|
||||||
const struct wl_compositor_interface *interface;
|
const struct wl_compositor_interface *interface;
|
||||||
struct wl_visual argb_visual;
|
|
||||||
struct wl_visual premultiplied_argb_visual;
|
|
||||||
struct wl_visual rgb_visual;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wl_buffer {
|
struct wl_buffer {
|
||||||
struct wl_resource resource;
|
struct wl_resource resource;
|
||||||
struct wl_visual *visual;
|
|
||||||
int32_t width, height;
|
int32_t width, height;
|
||||||
uint32_t busy_count;
|
uint32_t busy_count;
|
||||||
void *user_data;
|
void *user_data;
|
||||||
|
|
@ -285,10 +276,12 @@ wl_shm_buffer_get_data(struct wl_buffer *buffer);
|
||||||
int32_t
|
int32_t
|
||||||
wl_shm_buffer_get_stride(struct wl_buffer *buffer);
|
wl_shm_buffer_get_stride(struct wl_buffer *buffer);
|
||||||
|
|
||||||
|
uint32_t
|
||||||
|
wl_shm_buffer_get_format(struct wl_buffer *buffer);
|
||||||
|
|
||||||
struct wl_buffer *
|
struct wl_buffer *
|
||||||
wl_shm_buffer_create(struct wl_shm *shm, int width, int height,
|
wl_shm_buffer_create(struct wl_shm *shm, int width, int height,
|
||||||
int stride, struct wl_visual *visual,
|
int stride, uint32_t visual, void *data);
|
||||||
void *data);
|
|
||||||
|
|
||||||
int
|
int
|
||||||
wl_buffer_is_shm(struct wl_buffer *buffer);
|
wl_buffer_is_shm(struct wl_buffer *buffer);
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ struct wl_shm_buffer {
|
||||||
struct wl_buffer buffer;
|
struct wl_buffer buffer;
|
||||||
struct wl_shm *shm;
|
struct wl_shm *shm;
|
||||||
int32_t stride;
|
int32_t stride;
|
||||||
|
uint32_t format;
|
||||||
void *data;
|
void *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -81,8 +82,7 @@ const static struct wl_buffer_interface shm_buffer_interface = {
|
||||||
static struct wl_shm_buffer *
|
static struct wl_shm_buffer *
|
||||||
wl_shm_buffer_init(struct wl_shm *shm, struct wl_client *client, uint32_t id,
|
wl_shm_buffer_init(struct wl_shm *shm, struct wl_client *client, uint32_t id,
|
||||||
int32_t width, int32_t height,
|
int32_t width, int32_t height,
|
||||||
int32_t stride, struct wl_visual *visual,
|
int32_t stride, uint32_t format, void *data)
|
||||||
void *data)
|
|
||||||
{
|
{
|
||||||
struct wl_shm_buffer *buffer;
|
struct wl_shm_buffer *buffer;
|
||||||
|
|
||||||
|
|
@ -92,7 +92,7 @@ wl_shm_buffer_init(struct wl_shm *shm, struct wl_client *client, uint32_t id,
|
||||||
|
|
||||||
buffer->buffer.width = width;
|
buffer->buffer.width = width;
|
||||||
buffer->buffer.height = height;
|
buffer->buffer.height = height;
|
||||||
buffer->buffer.visual = visual;
|
buffer->format = format;
|
||||||
buffer->stride = stride;
|
buffer->stride = stride;
|
||||||
buffer->data = data;
|
buffer->data = data;
|
||||||
|
|
||||||
|
|
@ -115,17 +115,22 @@ wl_shm_buffer_init(struct wl_shm *shm, struct wl_client *client, uint32_t id,
|
||||||
static void
|
static void
|
||||||
shm_create_buffer(struct wl_client *client, struct wl_resource *resource,
|
shm_create_buffer(struct wl_client *client, struct wl_resource *resource,
|
||||||
uint32_t id, int fd, int32_t width, int32_t height,
|
uint32_t id, int fd, int32_t width, int32_t height,
|
||||||
uint32_t stride, struct wl_resource *visual_resource)
|
uint32_t stride, uint32_t format)
|
||||||
{
|
{
|
||||||
struct wl_shm *shm = resource->data;
|
struct wl_shm *shm = resource->data;
|
||||||
struct wl_shm_buffer *buffer;
|
struct wl_shm_buffer *buffer;
|
||||||
struct wl_visual *visual = visual_resource->data;
|
|
||||||
void *data;
|
void *data;
|
||||||
|
|
||||||
if (!visual || visual_resource->object.interface != &wl_visual_interface) {
|
|
||||||
|
switch (format) {
|
||||||
|
case WL_SHM_FORMAT_ARGB32:
|
||||||
|
case WL_SHM_FORMAT_PREMULTIPLIED_ARGB32:
|
||||||
|
case WL_SHM_FORMAT_XRGB32:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
wl_client_post_error(client, &resource->object,
|
wl_client_post_error(client, &resource->object,
|
||||||
WL_SHM_ERROR_INVALID_VISUAL,
|
WL_SHM_ERROR_INVALID_FORMAT,
|
||||||
"invalid visual");
|
"invalid format");
|
||||||
close(fd);
|
close(fd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -151,8 +156,7 @@ shm_create_buffer(struct wl_client *client, struct wl_resource *resource,
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer = wl_shm_buffer_init(shm, client, id,
|
buffer = wl_shm_buffer_init(shm, client, id,
|
||||||
width, height, stride, visual,
|
width, height, stride, format, data);
|
||||||
data);
|
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
munmap(data, stride * height);
|
munmap(data, stride * height);
|
||||||
wl_client_post_no_memory(client);
|
wl_client_post_no_memory(client);
|
||||||
|
|
@ -170,8 +174,15 @@ static void
|
||||||
bind_shm(struct wl_client *client,
|
bind_shm(struct wl_client *client,
|
||||||
void *data, uint32_t version, uint32_t id)
|
void *data, uint32_t version, uint32_t id)
|
||||||
{
|
{
|
||||||
wl_client_add_object(client,
|
struct wl_resource *resource;
|
||||||
&wl_shm_interface, &shm_interface, id, data);
|
|
||||||
|
resource = wl_client_add_object(client, &wl_shm_interface,
|
||||||
|
&shm_interface, id, data);
|
||||||
|
|
||||||
|
wl_resource_post_event(resource, WL_SHM_FORMAT, WL_SHM_FORMAT_ARGB32);
|
||||||
|
wl_resource_post_event(resource, WL_SHM_FORMAT,
|
||||||
|
WL_SHM_FORMAT_PREMULTIPLIED_ARGB32);
|
||||||
|
wl_resource_post_event(resource, WL_SHM_FORMAT, WL_SHM_FORMAT_XRGB32);
|
||||||
}
|
}
|
||||||
|
|
||||||
WL_EXPORT struct wl_shm *
|
WL_EXPORT struct wl_shm *
|
||||||
|
|
@ -232,3 +243,11 @@ wl_shm_buffer_get_data(struct wl_buffer *buffer_base)
|
||||||
|
|
||||||
return buffer->data;
|
return buffer->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WL_EXPORT uint32_t
|
||||||
|
wl_shm_buffer_get_format(struct wl_buffer *buffer_base)
|
||||||
|
{
|
||||||
|
struct wl_shm_buffer *buffer = (struct wl_shm_buffer *) buffer_base;
|
||||||
|
|
||||||
|
return buffer->format;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue