cursor: Load cursor images lazily
It doesn't make sense to load cursor textures that we might not ever use. Since the code here also uses CoglTexture2D, and cursors tend to be NPOT textures, then we won't crash users of cards without NPOT support. At least until they open the magnifier. :)
This commit is contained in:
parent
00535b34b6
commit
fd1243d881
@ -255,22 +255,30 @@ meta_cursor_image_load_from_xcursor_image (MetaCursorImage *image,
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
load_cursor_image (MetaCursorReference *cursor)
|
||||
{
|
||||
XcursorImage *image;
|
||||
|
||||
/* Either cursors are loaded from X cursors or buffers. Since
|
||||
* buffers are converted over immediately, we can make sure to
|
||||
* load this directly. */
|
||||
g_assert (cursor->cursor != META_CURSOR_NONE);
|
||||
|
||||
image = load_cursor_on_client (cursor->cursor);
|
||||
if (!image)
|
||||
return;
|
||||
|
||||
meta_cursor_image_load_from_xcursor_image (&cursor->image, image);
|
||||
XcursorImageDestroy (image);
|
||||
}
|
||||
|
||||
MetaCursorReference *
|
||||
meta_cursor_reference_from_theme (MetaCursor cursor)
|
||||
{
|
||||
MetaCursorReference *self;
|
||||
XcursorImage *image;
|
||||
|
||||
image = load_cursor_on_client (cursor);
|
||||
if (!image)
|
||||
return NULL;
|
||||
|
||||
self = g_slice_new0 (MetaCursorReference);
|
||||
MetaCursorReference *self = g_slice_new0 (MetaCursorReference);
|
||||
self->ref_count = 1;
|
||||
self->cursor = cursor;
|
||||
meta_cursor_image_load_from_xcursor_image (&self->image, image);
|
||||
|
||||
XcursorImageDestroy (image);
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -380,10 +388,14 @@ meta_cursor_reference_get_cogl_texture (MetaCursorReference *cursor,
|
||||
int *hot_x,
|
||||
int *hot_y)
|
||||
{
|
||||
if (!cursor->image.texture)
|
||||
load_cursor_image (cursor);
|
||||
|
||||
if (hot_x)
|
||||
*hot_x = cursor->image.hot_x;
|
||||
if (hot_y)
|
||||
*hot_y = cursor->image.hot_y;
|
||||
|
||||
return COGL_TEXTURE (cursor->image.texture);
|
||||
}
|
||||
|
||||
@ -393,6 +405,9 @@ meta_cursor_reference_get_gbm_bo (MetaCursorReference *cursor,
|
||||
int *hot_x,
|
||||
int *hot_y)
|
||||
{
|
||||
if (!cursor->image.bo)
|
||||
load_cursor_image (cursor);
|
||||
|
||||
if (hot_x)
|
||||
*hot_x = cursor->image.hot_x;
|
||||
if (hot_y)
|
||||
|
Loading…
Reference in New Issue
Block a user