sna: Reorder the cursor cache search

Search for an exact match first, before looking for a cursor we can
reuse. This should help reuse with multiple rotated screens not stealing
the others' cursor on every pass.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2014-03-27 21:16:31 +00:00
parent e8be2a438d
commit 5c4d6d1ad7
1 changed files with 18 additions and 9 deletions

View File

@ -3103,9 +3103,10 @@ static struct sna_cursor *__sna_get_cursor(struct sna *sna, xf86CrtcPtr crtc)
if (sna->cursor.ref == NULL || sna->cursor.ref->bits == NULL)
return NULL;
__DBG(("%s: cursor=%dx%d\n", __FUNCTION__,
__DBG(("%s: cursor=%dx%d, serial=%d\n", __FUNCTION__,
sna->cursor.ref->bits->width,
sna->cursor.ref->bits->height));
sna->cursor.ref->bits->height,
sna->cursor.serial));
i = MAX(sna->cursor.ref->bits->width, sna->cursor.ref->bits->height);
for (size = 64; size < i; size <<= 1)
@ -3113,9 +3114,22 @@ static struct sna_cursor *__sna_get_cursor(struct sna *sna, xf86CrtcPtr crtc)
assert(size <= sna->cursor.max_width && size <= sna->cursor.max_height);
rotation = crtc->transform_in_use ? crtc->rotation : RR_Rotate_0;
for (cursor = sna->cursor.cursors; cursor; cursor = cursor->next)
if (cursor->size >= size && cursor->rotation == rotation)
for (cursor = sna->cursor.cursors; cursor; cursor = cursor->next) {
if (cursor->serial == sna->cursor.serial && cursor->rotation == rotation) {
__DBG(("%s: reusing handle=%d, serial=%d, rotation=%d\n",
__FUNCTION__, cursor->handle, cursor->serial, cursor->rotation));
assert(cursor->size == size);
return cursor;
}
}
for (cursor = sna->cursor.cursors; cursor; cursor = cursor->next) {
if (cursor->alloc >= 4*size*size && cursor->serial != sna->cursor.serial) {
__DBG(("%s: stealing handle=%d, serial=%d, rotation=%d, alloc=%d\n",
__FUNCTION__, cursor->handle, cursor->serial, cursor->rotation, cursor->alloc));
break;
}
}
if (cursor == NULL) {
cursor = __sna_create_cursor(sna, size);
@ -3123,11 +3137,6 @@ static struct sna_cursor *__sna_get_cursor(struct sna *sna, xf86CrtcPtr crtc)
return NULL;
}
__DBG(("%s: using handle=%d, serial=%d, current=%d\n",
__FUNCTION__, cursor->handle, cursor->serial, sna->cursor.serial));
if (cursor->serial == sna->cursor.serial)
return cursor;
width = sna->cursor.ref->bits->width;
height = sna->cursor.ref->bits->height;
src = sna->cursor.ref->bits->argb;