summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2014-03-27 21:16:31 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2014-03-27 21:39:58 +0000
commit5c4d6d1ad748fe5301fa88d9c15c19a07c55149f (patch)
tree7101d04270132fa15597f8192a2fd2ada4073774 /src
parente8be2a438d7a413ba6c64005971ce814b0076fc7 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/sna/sna_display.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index 35f4ea35..0748758e 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -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;