The renderers commit the rectangles derived from the region in a random order.
This gives some tearing as the screen is displayed with a random regions in
their new state. The change sorts the list of rectangles according to their Y
value to commit them from top to bottom. This gives fewer tear lines.
return region->rectangle_list;
}
+static int
+rectangle_compare_y (void *element_a, void *element_b)
+{
+ ply_rectangle_t *rectangle_a = element_a;
+ ply_rectangle_t *rectangle_b = element_b;
+ return rectangle_a->y - rectangle_b->y;
+}
+
+ply_list_t *
+ply_region_get_sorted_rectangle_list (ply_region_t *region)
+{
+ return region->rectangle_list;
+}
+
#ifdef PLY_REGION_ENABLE_TEST
#include <stdio.h>
ply_rectangle_t *rectangle);
void ply_region_clear (ply_region_t *region);
ply_list_t *ply_region_get_rectangle_list (ply_region_t *region);
+ply_list_t *ply_region_get_sorted_rectangle_list (ply_region_t *region);
bool ply_region_is_empty (ply_region_t *region);
ply_terminal_set_unbuffered_input (backend->terminal);
pixel_buffer = head->pixel_buffer;
updated_region = ply_pixel_buffer_get_updated_areas (pixel_buffer);
- areas_to_flush = ply_region_get_rectangle_list (updated_region);
+ areas_to_flush = ply_region_get_sorted_rectangle_list (updated_region);
map_address =
backend->driver_interface->begin_flush (backend->driver,
ply_terminal_set_unbuffered_input (backend->terminal);
pixel_buffer = head->pixel_buffer;
updated_region = ply_pixel_buffer_get_updated_areas (pixel_buffer);
- areas_to_flush = ply_region_get_rectangle_list (updated_region);
+ areas_to_flush = ply_region_get_sorted_rectangle_list (updated_region);
node = ply_list_get_first_node (areas_to_flush);
while (node != NULL)
pixel_buffer = head->pixel_buffer;
updated_region = ply_pixel_buffer_get_updated_areas (pixel_buffer);
- areas_to_flush = ply_region_get_rectangle_list (updated_region);
+ areas_to_flush = ply_region_get_sorted_rectangle_list (updated_region);
cr = gdk_cairo_create (head->pixmap);