Implement buffer.damage in shm, use it in window.c
This commit is contained in:
committed by
Kristian Høgsberg
parent
e997c5fb09
commit
bde55ec8e4
@@ -199,6 +199,8 @@ frame_callback(struct wl_surface *surface, void *data, uint32_t time)
|
|||||||
|
|
||||||
render(smoke);
|
render(smoke);
|
||||||
|
|
||||||
|
display_surface_damage(smoke->display, smoke->surface,
|
||||||
|
0, 0, smoke->width, smoke->height);
|
||||||
window_damage(smoke->window, 0, 0, smoke->width, smoke->height);
|
window_damage(smoke->window, 0, 0, smoke->width, smoke->height);
|
||||||
wl_display_frame_callback(display_get_display(smoke->display),
|
wl_display_frame_callback(display_get_display(smoke->display),
|
||||||
window_get_wl_surface(smoke->window),
|
window_get_wl_surface(smoke->window),
|
||||||
|
|||||||
+25
-1
@@ -734,9 +734,22 @@ window_attach_surface(struct window *window)
|
|||||||
void
|
void
|
||||||
window_flush(struct window *window)
|
window_flush(struct window *window)
|
||||||
{
|
{
|
||||||
if (window->cairo_surface)
|
if (window->cairo_surface) {
|
||||||
|
switch (window->buffer_type) {
|
||||||
|
case WINDOW_BUFFER_TYPE_EGL_IMAGE:
|
||||||
|
case WINDOW_BUFFER_TYPE_SHM:
|
||||||
|
display_surface_damage(window->display,
|
||||||
|
window->cairo_surface,
|
||||||
|
0, 0,
|
||||||
|
window->allocation.width,
|
||||||
|
window->allocation.height);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
window_attach_surface(window);
|
window_attach_surface(window);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
window_set_surface(struct window *window, cairo_surface_t *surface)
|
window_set_surface(struct window *window, cairo_surface_t *surface)
|
||||||
@@ -1420,6 +1433,17 @@ window_get_title(struct window *window)
|
|||||||
return window->title;
|
return window->title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
display_surface_damage(struct display *display, cairo_surface_t *cairo_surface,
|
||||||
|
int32_t x, int32_t y, int32_t width, int32_t height)
|
||||||
|
{
|
||||||
|
struct wl_buffer *buffer;
|
||||||
|
|
||||||
|
buffer = display_get_buffer_for_surface(display, cairo_surface);
|
||||||
|
|
||||||
|
wl_buffer_damage(buffer, x, y, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
window_damage(struct window *window, int32_t x, int32_t y,
|
window_damage(struct window *window, int32_t x, int32_t y,
|
||||||
int32_t width, int32_t height)
|
int32_t width, int32_t height)
|
||||||
|
|||||||
@@ -193,6 +193,10 @@ enum window_buffer_type {
|
|||||||
WINDOW_BUFFER_TYPE_SHM,
|
WINDOW_BUFFER_TYPE_SHM,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
display_surface_damage(struct display *display, cairo_surface_t *cairo_surface,
|
||||||
|
int32_t x, int32_t y, int32_t width, int32_t height);
|
||||||
|
|
||||||
void
|
void
|
||||||
window_set_buffer_type(struct window *window, enum window_buffer_type type);
|
window_set_buffer_type(struct window *window, enum window_buffer_type type);
|
||||||
|
|
||||||
|
|||||||
@@ -853,8 +853,6 @@ surface_damage(struct wl_client *client,
|
|||||||
{
|
{
|
||||||
struct wlsc_surface *es = (struct wlsc_surface *) surface;
|
struct wlsc_surface *es = (struct wlsc_surface *) surface;
|
||||||
|
|
||||||
es->buffer->damage(es->buffer, surface, x, y, width, height);
|
|
||||||
|
|
||||||
wlsc_surface_damage_rectangle(es, x, y, width, height);
|
wlsc_surface_damage_rectangle(es, x, y, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+33
-20
@@ -36,21 +36,53 @@ destroy_buffer(struct wl_resource *resource, struct wl_client *client)
|
|||||||
{
|
{
|
||||||
struct wlsc_shm_buffer *buffer =
|
struct wlsc_shm_buffer *buffer =
|
||||||
container_of(resource, struct wlsc_shm_buffer, buffer.resource);
|
container_of(resource, struct wlsc_shm_buffer, buffer.resource);
|
||||||
|
struct wlsc_compositor *compositor =
|
||||||
|
(struct wlsc_compositor *) buffer->buffer.compositor;
|
||||||
|
struct wlsc_surface *es;
|
||||||
|
|
||||||
if (buffer->mapped)
|
if (buffer->mapped)
|
||||||
munmap(buffer->data, buffer->stride * buffer->buffer.height);
|
munmap(buffer->data, buffer->stride * buffer->buffer.height);
|
||||||
else
|
else
|
||||||
free(buffer->data);
|
free(buffer->data);
|
||||||
|
|
||||||
|
wl_list_for_each(es, &compositor->surface_list, link)
|
||||||
|
if (es->buffer == (struct wl_buffer *) buffer)
|
||||||
|
es->buffer = NULL;
|
||||||
|
|
||||||
free(buffer);
|
free(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
buffer_damage(struct wl_client *client, struct wl_buffer *buffer_base,
|
||||||
|
int32_t x, int32_t y, int32_t width, int32_t height)
|
||||||
|
{
|
||||||
|
struct wlsc_shm_buffer *buffer =
|
||||||
|
(struct wlsc_shm_buffer *) buffer_base;
|
||||||
|
struct wlsc_compositor *compositor =
|
||||||
|
(struct wlsc_compositor *) buffer->buffer.compositor;
|
||||||
|
struct wlsc_surface *es;
|
||||||
|
|
||||||
|
wl_list_for_each(es, &compositor->surface_list, link) {
|
||||||
|
if (es->buffer != buffer_base)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_2D, es->texture);
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT,
|
||||||
|
buffer->buffer.width, buffer->buffer.height, 0,
|
||||||
|
GL_BGRA_EXT, GL_UNSIGNED_BYTE, buffer->data);
|
||||||
|
/* Hmm, should use glTexSubImage2D() here but GLES2 doesn't
|
||||||
|
* support any unpack attributes except GL_UNPACK_ALIGNMENT. */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
buffer_destroy(struct wl_client *client, struct wl_buffer *buffer)
|
buffer_destroy(struct wl_client *client, struct wl_buffer *buffer)
|
||||||
{
|
{
|
||||||
// wl_resource_destroy(&buffer->base, client);
|
wl_resource_destroy(&buffer->resource, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
const static struct wl_buffer_interface buffer_interface = {
|
const static struct wl_buffer_interface buffer_interface = {
|
||||||
|
buffer_damage,
|
||||||
buffer_destroy
|
buffer_destroy
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -73,24 +105,6 @@ shm_buffer_attach(struct wl_buffer *buffer_base, struct wl_surface *surface)
|
|||||||
es->visual = buffer->buffer.visual;
|
es->visual = buffer->buffer.visual;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
shm_buffer_damage(struct wl_buffer *buffer_base,
|
|
||||||
struct wl_surface *surface,
|
|
||||||
int32_t x, int32_t y, int32_t width, int32_t height)
|
|
||||||
{
|
|
||||||
struct wlsc_surface *es = (struct wlsc_surface *) surface;
|
|
||||||
struct wlsc_shm_buffer *buffer =
|
|
||||||
(struct wlsc_shm_buffer *) buffer_base;
|
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, es->texture);
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT,
|
|
||||||
buffer->buffer.width, buffer->buffer.height, 0,
|
|
||||||
GL_BGRA_EXT, GL_UNSIGNED_BYTE, buffer->data);
|
|
||||||
|
|
||||||
/* Hmm, should use glTexSubImage2D() here but GLES2 doesn't
|
|
||||||
* support any unpack attributes except GL_UNPACK_ALIGNMENT. */
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct wlsc_shm_buffer *
|
static struct wlsc_shm_buffer *
|
||||||
wlsc_shm_buffer_init(struct wlsc_compositor *compositor,
|
wlsc_shm_buffer_init(struct wlsc_compositor *compositor,
|
||||||
int32_t width, int32_t height,
|
int32_t width, int32_t height,
|
||||||
@@ -108,7 +122,6 @@ wlsc_shm_buffer_init(struct wlsc_compositor *compositor,
|
|||||||
buffer->buffer.height = height;
|
buffer->buffer.height = height;
|
||||||
buffer->buffer.visual = visual;
|
buffer->buffer.visual = visual;
|
||||||
buffer->buffer.attach = shm_buffer_attach;
|
buffer->buffer.attach = shm_buffer_attach;
|
||||||
buffer->buffer.damage = shm_buffer_damage;
|
|
||||||
buffer->stride = stride;
|
buffer->stride = stride;
|
||||||
buffer->data = data;
|
buffer->data = data;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user