mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 02:58:02 +02:00
[spans] Add a sentinel cell to the cell_list.
By terminating the list with a cell for INT_MAX, we remove a few conditionals from the hot-paths.
This commit is contained in:
parent
3b2bb95249
commit
30cef3116e
1 changed files with 15 additions and 10 deletions
|
|
@ -457,6 +457,8 @@ struct cell {
|
|||
struct cell_list {
|
||||
/* Points to the left-most cell in the scan line. */
|
||||
struct cell *head;
|
||||
/* Sentinel node */
|
||||
struct cell tail;
|
||||
|
||||
/* Cursor state for iterating through the cell list. Points to
|
||||
* a pointer to the current cell: either &cell_list->head or the next
|
||||
|
|
@ -680,7 +682,7 @@ inline static void
|
|||
cell_list_maybe_rewind(struct cell_list *cells, int x)
|
||||
{
|
||||
struct cell *tail = *cells->cursor;
|
||||
if (tail && tail->x > x) {
|
||||
if (tail->x > x) {
|
||||
cell_list_rewind(cells);
|
||||
}
|
||||
}
|
||||
|
|
@ -691,7 +693,9 @@ cell_list_init(struct cell_list *cells)
|
|||
pool_init(cells->cell_pool.base,
|
||||
256*sizeof(struct cell),
|
||||
sizeof(cells->cell_pool.embedded));
|
||||
cells->head = NULL;
|
||||
cells->tail.next = NULL;
|
||||
cells->tail.x = INT_MAX;
|
||||
cells->head = &cells->tail;
|
||||
cell_list_rewind(cells);
|
||||
}
|
||||
|
||||
|
|
@ -708,7 +712,7 @@ inline static void
|
|||
cell_list_reset(struct cell_list *cells)
|
||||
{
|
||||
cell_list_rewind(cells);
|
||||
cells->head = NULL;
|
||||
cells->head = &cells->tail;
|
||||
pool_reset(cells->cell_pool.base);
|
||||
}
|
||||
|
||||
|
|
@ -726,14 +730,15 @@ cell_list_find(struct cell_list *cells, int x)
|
|||
while (1) {
|
||||
UNROLL3({
|
||||
tail = *cursor;
|
||||
if (NULL == tail || tail->x >= x) {
|
||||
if (tail->x >= x) {
|
||||
break;
|
||||
}
|
||||
cursor = &tail->next;
|
||||
});
|
||||
}
|
||||
cells->cursor = cursor;
|
||||
if (tail && tail->x == x) {
|
||||
|
||||
if (tail->x == x) {
|
||||
return tail;
|
||||
} else {
|
||||
struct cell *cell = pool_alloc(
|
||||
|
|
@ -758,7 +763,7 @@ cell_list_find(struct cell_list *cells, int x)
|
|||
*
|
||||
* except with less function call overhead. */
|
||||
inline static struct cell_pair
|
||||
cell_list_find2(struct cell_list *cells, int x1, int x2)
|
||||
cell_list_find_pair(struct cell_list *cells, int x1, int x2)
|
||||
{
|
||||
struct cell_pair pair;
|
||||
struct cell **cursor = cells->cursor;
|
||||
|
|
@ -770,7 +775,7 @@ cell_list_find2(struct cell_list *cells, int x1, int x2)
|
|||
while (1) {
|
||||
UNROLL3({
|
||||
cell1 = *cursor;
|
||||
if (NULL == cell1 || cell1->x > x1)
|
||||
if (cell1->x > x1)
|
||||
break;
|
||||
if (cell1->x == x1)
|
||||
goto found_first;
|
||||
|
|
@ -796,7 +801,7 @@ cell_list_find2(struct cell_list *cells, int x1, int x2)
|
|||
while (1) {
|
||||
UNROLL3({
|
||||
cell2 = *cursor;
|
||||
if (NULL == cell2 || cell2->x > x2)
|
||||
if (cell2->x > x2)
|
||||
break;
|
||||
if (cell2->x == x2)
|
||||
goto found_second;
|
||||
|
|
@ -860,7 +865,7 @@ cell_list_add_subspan(
|
|||
|
||||
if (ix1 != ix2) {
|
||||
struct cell_pair p;
|
||||
p = cell_list_find2(cells, ix1, ix2);
|
||||
p = cell_list_find_pair(cells, ix1, ix2);
|
||||
if (p.cell1 && p.cell2) {
|
||||
p.cell1->uncovered_area += 2*fx1;
|
||||
++p.cell1->covered_height;
|
||||
|
|
@ -974,7 +979,7 @@ cell_list_render_edge(
|
|||
* this function that the active list order won't change. */
|
||||
cell_list_maybe_rewind(cells, ix1);
|
||||
|
||||
pair = cell_list_find2(cells, ix1, ix1+1);
|
||||
pair = cell_list_find_pair(cells, ix1, ix1+1);
|
||||
if (!pair.cell1 || !pair.cell2)
|
||||
return GLITTER_STATUS_NO_MEMORY;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue