Simplify shm buffer handling
There was a lot of code here to do a lot of work we didn't need to do. If we damage a surface with a shm buffer attached, all we need to do is to re-upload the damaged region to the texture. As for drm buffers, we don't assume anything changes on attach and only update the regions the client tells us to update in the damage request.
This commit is contained in:
@@ -142,7 +142,6 @@ redraw(void *data, struct wl_callback *callback, uint32_t time)
|
||||
offset = time >> 4;
|
||||
for (i = 0; i < end; i++)
|
||||
p[i] = (i + offset) * 0x0080401;
|
||||
wl_buffer_damage(window->buffer, 0, 0, window->width, window->height);
|
||||
|
||||
wl_surface_attach(window->surface, window->buffer, 0, 0);
|
||||
wl_surface_damage(window->surface,
|
||||
|
||||
@@ -184,9 +184,7 @@ touch_paint(struct touch *touch, int32_t x, int32_t y, int32_t id)
|
||||
p += touch->width;
|
||||
p[1] = c;
|
||||
|
||||
wl_buffer_damage(touch->buffer, 0, 0, touch->width, touch->height);
|
||||
wl_surface_damage(touch->surface,
|
||||
0, 0, touch->width, touch->height);
|
||||
wl_surface_damage(touch->surface, 0, 0, touch->width, touch->height);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -312,7 +310,6 @@ touch_create(int width, int height)
|
||||
wl_surface_set_user_data(touch->surface, touch);
|
||||
|
||||
memset(touch->data, 64, width * height * 4);
|
||||
wl_buffer_damage(touch->buffer, 0, 0, width, height);
|
||||
wl_surface_attach(touch->surface, touch->buffer, 0, 0);
|
||||
wl_surface_damage(touch->surface, 0, 0, width, height);
|
||||
|
||||
|
||||
@@ -220,8 +220,6 @@ redraw_handler(struct widget *widget, void *data)
|
||||
|
||||
render(smoke, surface);
|
||||
|
||||
display_surface_damage(smoke->display, surface,
|
||||
0, 0, smoke->width, smoke->height);
|
||||
window_damage(smoke->window, 0, 0, smoke->width, smoke->height);
|
||||
|
||||
cairo_surface_destroy(surface);
|
||||
|
||||
+1
-25
@@ -782,21 +782,8 @@ window_attach_surface(struct window *window)
|
||||
void
|
||||
window_flush(struct window *window)
|
||||
{
|
||||
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;
|
||||
}
|
||||
if (window->cairo_surface)
|
||||
window_attach_surface(window);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2279,17 +2266,6 @@ window_get_title(struct window *window)
|
||||
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
|
||||
window_damage(struct window *window, int32_t x, int32_t y,
|
||||
int32_t width, int32_t height)
|
||||
|
||||
Reference in New Issue
Block a user