uwac: Make damage tracking more readable
This commit is contained in:
parent
d27ad43093
commit
2548fd4aae
@ -204,6 +204,7 @@ struct uwac_seat {
|
|||||||
/** @brief a buffer used for drawing a surface frame */
|
/** @brief a buffer used for drawing a surface frame */
|
||||||
struct uwac_buffer {
|
struct uwac_buffer {
|
||||||
bool used;
|
bool used;
|
||||||
|
bool dirty;
|
||||||
#ifdef HAVE_PIXMAN_REGION
|
#ifdef HAVE_PIXMAN_REGION
|
||||||
pixman_region32_t damage;
|
pixman_region32_t damage;
|
||||||
#else
|
#else
|
||||||
|
@ -617,37 +617,40 @@ static const struct wl_callback_listener frame_listener =
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static void UwacSubmitBufferPtr(UwacWindow* window, UwacBuffer* buffer)
|
#ifdef HAVE_PIXMAN_REGION
|
||||||
|
static void damage_surface(UwacWindow* window, UwacBuffer* buffer)
|
||||||
{
|
{
|
||||||
UINT32 nrects, i;
|
UINT32 nrects, i;
|
||||||
#ifdef HAVE_PIXMAN_REGION
|
const pixman_box32_t* box = pixman_region32_rectangles(&buffer->damage, &nrects);
|
||||||
const pixman_box32_t* box;
|
|
||||||
#else
|
|
||||||
const RECTANGLE_16* box;
|
|
||||||
#endif
|
|
||||||
wl_surface_attach(window->surface, buffer->wayland_buffer, 0, 0);
|
|
||||||
#ifdef HAVE_PIXMAN_REGION
|
|
||||||
box = pixman_region32_rectangles(&buffer->damage, &nrects);
|
|
||||||
|
|
||||||
for (i = 0; i < nrects; i++, box++)
|
for (i = 0; i < nrects; i++, box++)
|
||||||
wl_surface_damage(window->surface, box->x1, box->y1, (box->x2 - box->x1), (box->y2 - box->y1));
|
wl_surface_damage(window->surface, box->x1, box->y1, (box->x2 - box->x1), (box->y2 - box->y1));
|
||||||
|
|
||||||
|
pixman_region32_clear(&buffer->damage);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
box = region16_rects(&buffer->damage, &nrects);
|
static void damage_surface(UwacWindow* window, UwacBuffer* buffer)
|
||||||
|
{
|
||||||
|
UINT32 nrects, i;
|
||||||
|
const RECTANGLE_16* box = region16_rects(&buffer->damage, &nrects);
|
||||||
|
|
||||||
for (i = 0; i < nrects; i++, box++)
|
for (i = 0; i < nrects; i++, box++)
|
||||||
wl_surface_damage(window->surface, box->left, box->top, (box->right - box->left),
|
wl_surface_damage(window->surface, box->left, box->top, (box->right - box->left),
|
||||||
(box->bottom - box->top));
|
(box->bottom - box->top));
|
||||||
|
|
||||||
|
region16_clear(&buffer->damage);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void UwacSubmitBufferPtr(UwacWindow* window, UwacBuffer* buffer)
|
||||||
|
{
|
||||||
|
wl_surface_attach(window->surface, buffer->wayland_buffer, 0, 0);
|
||||||
|
|
||||||
|
damage_surface(window, buffer);
|
||||||
|
|
||||||
struct wl_callback* frame_callback = wl_surface_frame(window->surface);
|
struct wl_callback* frame_callback = wl_surface_frame(window->surface);
|
||||||
wl_callback_add_listener(frame_callback, &frame_listener, window);
|
wl_callback_add_listener(frame_callback, &frame_listener, window);
|
||||||
wl_surface_commit(window->surface);
|
wl_surface_commit(window->surface);
|
||||||
#ifdef HAVE_PIXMAN_REGION
|
|
||||||
pixman_region32_clear(&buffer->damage);
|
|
||||||
#else
|
|
||||||
region16_clear(&buffer->damage);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -665,14 +668,20 @@ static void frame_done_cb(void* data, struct wl_callback* callback, uint32_t tim
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef HAVE_PIXMAN_REGION
|
||||||
UwacReturnCode UwacWindowAddDamage(UwacWindow* window, uint32_t x, uint32_t y, uint32_t width,
|
UwacReturnCode UwacWindowAddDamage(UwacWindow* window, uint32_t x, uint32_t y, uint32_t width,
|
||||||
uint32_t height)
|
uint32_t height)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_PIXMAN_REGION
|
|
||||||
|
|
||||||
if (!pixman_region32_union_rect(&window->drawingBuffer->damage, &window->drawingBuffer->damage, x,
|
if (!pixman_region32_union_rect(&window->drawingBuffer->damage, &window->drawingBuffer->damage, x,
|
||||||
y, width, height))
|
y, width, height))
|
||||||
|
return UWAC_ERROR_INTERNAL;
|
||||||
|
|
||||||
|
return UWAC_SUCCESS;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
|
UwacReturnCode UwacWindowAddDamage(UwacWindow* window, uint32_t x, uint32_t y, uint32_t width,
|
||||||
|
uint32_t height)
|
||||||
|
{
|
||||||
RECTANGLE_16 box;
|
RECTANGLE_16 box;
|
||||||
|
|
||||||
box.left = x;
|
box.left = x;
|
||||||
@ -681,11 +690,11 @@ UwacReturnCode UwacWindowAddDamage(UwacWindow* window, uint32_t x, uint32_t y, u
|
|||||||
box.bottom = y + height;
|
box.bottom = y + height;
|
||||||
|
|
||||||
if (!region16_union_rect(&window->drawingBuffer->damage, &window->drawingBuffer->damage, &box))
|
if (!region16_union_rect(&window->drawingBuffer->damage, &window->drawingBuffer->damage, &box))
|
||||||
#endif
|
|
||||||
return UWAC_ERROR_INTERNAL;
|
return UWAC_ERROR_INTERNAL;
|
||||||
|
|
||||||
return UWAC_SUCCESS;
|
return UWAC_SUCCESS;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
UwacReturnCode UwacWindowGetDrawingBufferGeometry(UwacWindow* window, UwacSize* geometry, size_t* stride)
|
UwacReturnCode UwacWindowGetDrawingBufferGeometry(UwacWindow* window, UwacSize* geometry, size_t* stride)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user