gl-renderer: Prevent programming errors on damage regions

transform_damage() expects a non-empty damage region. Remove
compress_bands()'s run-time handling of errors and use asserts to
prevent programming errors.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
This commit is contained in:
Loïc Molinari 2023-08-31 14:11:50 +02:00 committed by Marius Vlad
parent 946bb51a2a
commit 7ba16ef264

View file

@ -1195,10 +1195,7 @@ compress_bands(pixman_box32_t *inrects, int nrects, pixman_box32_t **outrects)
pixman_box32_t *out, merge_rect;
int i, j, nout;
if (!nrects) {
*outrects = NULL;
return 0;
}
assert(nrects > 0);
/* nrects is an upper bound - we're not too worried about
* allocating a little extra
@ -1253,7 +1250,7 @@ node_axis_aligned(const struct weston_view *view)
/* Transform damage 'region' in global coordinates to damage 'quads' in surface
* coordinates. 'quads' and 'nquads' are output arguments set if 'quads' is
* NULL, no transformation happens otherwise. Caller must free 'quads' if
* set.
* set. Caller must ensure 'region' is not empty.
*/
static void
transform_damage(const struct weston_paint_node *pnode,
@ -1276,6 +1273,7 @@ transform_damage(const struct weston_paint_node *pnode,
if (compress)
nrects = compress_bands(rects, nrects, &rects);
assert(nrects > 0);
*quads = quads_alloc = malloc(nrects * sizeof *quads_alloc);
*nquads = nrects;