summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2012-03-26 16:33:24 -0400
committerKristian Høgsberg <krh@bitplanet.net>2012-03-26 16:33:24 -0400
commit83685c506e76212ae4e5cb722205d98d3b0603b9 (patch)
tree5640f96af047625ef68a2156b1e7e137798c9ea9
parenta0e590a0f3ea87b7616cf197edd240b7b99fcc2e (diff)
Remove wl_buffer.damage and simplify shm implementation
-rw-r--r--TODO4
-rw-r--r--protocol/wayland.xml14
-rw-r--r--src/wayland-server.h7
-rw-r--r--src/wayland-shm.c58
4 files changed, 10 insertions, 73 deletions
diff --git a/TODO b/TODO
index 10d41d1..49edf89 100644
--- a/TODO
+++ b/TODO
@@ -36,10 +36,6 @@ Core wayland protocol
is something in the protocol/architecute that makes it harder than
it should be.
- - Remove wl_buffer.damage. This is only used for wl_shm buffers and
- is not a generic wl_buffer request. We move it to wl_shm, and
- we'll have to figure out how to get swrast to call it.
-
- Reconsider data types for coordinates in events. double, floats or
fixed point. Transformed and/or accelerated input generates
sub-pixel positions. 24.8 fixed point could work. Need to think
diff --git a/protocol/wayland.xml b/protocol/wayland.xml
index 3dcfac8..c32bc8b 100644
--- a/protocol/wayland.xml
+++ b/protocol/wayland.xml
@@ -183,20 +183,6 @@
updates the contents is defined by the buffer factory interface
</description>
- <request name="damage">
- <description summary="mark part of the buffer damaged">
- Notify the server that the specified area of the buffers
- contents have changed. To describe a more complicated area of
- damage, break down the region into rectangles and use this
- request several times.
- </description>
-
- <arg name="x" type="int"/>
- <arg name="y" type="int"/>
- <arg name="width" type="int"/>
- <arg name="height" type="int"/>
- </request>
-
<request name="destroy" type="destructor">
<description summary="destroy a buffer">
Destroy a buffer. This will invalidate the object id.
diff --git a/src/wayland-server.h b/src/wayland-server.h
index 2072827..78372eb 100644
--- a/src/wayland-server.h
+++ b/src/wayland-server.h
@@ -339,12 +339,11 @@ wl_shm_buffer_create(struct wl_shm *shm, int width, int height,
int
wl_buffer_is_shm(struct wl_buffer *buffer);
-struct wl_shm *
-wl_shm_init(struct wl_display *display,
- const struct wl_shm_callbacks *callbacks);
+int
+wl_display_init_shm(struct wl_display *display);
void
-wl_shm_finish(struct wl_shm *shm);
+wl_shm_finish(struct wl_display *display);
#ifdef __cplusplus
}
diff --git a/src/wayland-shm.c b/src/wayland-shm.c
index b0af0e1..8e4ceb8 100644
--- a/src/wayland-shm.c
+++ b/src/wayland-shm.c
@@ -33,13 +33,8 @@
#include "wayland-server.h"
-struct wl_shm {
- const struct wl_shm_callbacks *callbacks;
-};
-
struct wl_shm_buffer {
struct wl_buffer buffer;
- struct wl_shm *shm;
int32_t stride;
uint32_t format;
void *data;
@@ -53,34 +48,21 @@ destroy_buffer(struct wl_resource *resource)
munmap(buffer->data, buffer->stride * buffer->buffer.height);
- buffer->shm->callbacks->buffer_destroyed(&buffer->buffer);
-
free(buffer);
}
static void
-shm_buffer_damage(struct wl_client *client, struct wl_resource *resource,
- int32_t x, int32_t y, int32_t width, int32_t height)
-{
- struct wl_shm_buffer *buffer = resource->data;
-
- buffer->shm->callbacks->buffer_damaged(&buffer->buffer, x, y,
- width, height);
-}
-
-static void
shm_buffer_destroy(struct wl_client *client, struct wl_resource *resource)
{
wl_resource_destroy(resource, 0);
}
const static struct wl_buffer_interface shm_buffer_interface = {
- shm_buffer_damage,
shm_buffer_destroy
};
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_client *client, uint32_t id,
int32_t width, int32_t height,
int32_t stride, uint32_t format, void *data)
{
@@ -105,10 +87,6 @@ wl_shm_buffer_init(struct wl_shm *shm, struct wl_client *client, uint32_t id,
buffer->buffer.resource.client = client;
buffer->buffer.resource.destroy = destroy_buffer;
- buffer->shm = shm;
-
- buffer->shm->callbacks->buffer_created(&buffer->buffer);
-
return buffer;
}
@@ -117,7 +95,6 @@ shm_create_buffer(struct wl_client *client, struct wl_resource *resource,
uint32_t id, int fd, int32_t width, int32_t height,
uint32_t stride, uint32_t format)
{
- struct wl_shm *shm = resource->data;
struct wl_shm_buffer *buffer;
void *data;
@@ -154,7 +131,7 @@ shm_create_buffer(struct wl_client *client, struct wl_resource *resource,
return;
}
- buffer = wl_shm_buffer_init(shm, client, id,
+ buffer = wl_shm_buffer_init(client, id,
width, height, stride, format, data);
if (buffer == NULL) {
munmap(data, stride * height);
@@ -182,34 +159,13 @@ bind_shm(struct wl_client *client,
wl_shm_send_format(resource, WL_SHM_FORMAT_XRGB8888);
}
-WL_EXPORT struct wl_shm *
-wl_shm_init(struct wl_display *display,
- const struct wl_shm_callbacks *callbacks)
-{
- struct wl_shm *shm;
-
- shm = malloc(sizeof *shm);
- if (!shm)
- return NULL;
-
- if (!wl_display_add_global(display,
- &wl_shm_interface, shm, bind_shm)) {
-
- free(shm);
- return NULL;
- }
-
- shm->callbacks = callbacks;
-
- return shm;
-}
-
-WL_EXPORT void
-wl_shm_finish(struct wl_shm *shm)
+WL_EXPORT int
+wl_display_init_shm(struct wl_display *display)
{
- /* FIXME: add wl_display_del_{object,global} */
+ if (!wl_display_add_global(display, &wl_shm_interface, NULL, bind_shm))
+ return -1;
- free(shm);
+ return 0;
}
WL_EXPORT int