From f6a73bcf22b4132d107cf52393820d3ee48935d3 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Mon, 31 Mar 2014 17:59:14 -0400 Subject: [PATCH] cursor: Do less work if we don't have a connection to GBM at all --- src/core/meta-cursor.c | 60 ++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/src/core/meta-cursor.c b/src/core/meta-cursor.c index a9bce1999..2a78328ef 100644 --- a/src/core/meta-cursor.c +++ b/src/core/meta-cursor.c @@ -315,36 +315,38 @@ meta_cursor_image_load_from_buffer (MetaCursorTracker *tracker, shm_buffer = wl_shm_buffer_get (buffer); if (shm_buffer) { - int rowstride = wl_shm_buffer_get_stride (shm_buffer); - - switch (wl_shm_buffer_get_format (shm_buffer)) - { -#if G_BYTE_ORDER == G_BIG_ENDIAN - case WL_SHM_FORMAT_ARGB8888: - gbm_format = GBM_FORMAT_ARGB8888; - break; - case WL_SHM_FORMAT_XRGB8888: - gbm_format = GBM_FORMAT_XRGB8888; - break; -#else - case WL_SHM_FORMAT_ARGB8888: - gbm_format = GBM_FORMAT_ARGB8888; - break; - case WL_SHM_FORMAT_XRGB8888: - gbm_format = GBM_FORMAT_XRGB8888; - break; -#endif - default: - g_warn_if_reached (); - gbm_format = GBM_FORMAT_ARGB8888; - } - if (tracker->gbm) - meta_cursor_image_load_gbm_buffer (tracker->gbm, - image, - (uint8_t *) wl_shm_buffer_get_data (shm_buffer), - width, height, rowstride, - gbm_format); + { + int rowstride = wl_shm_buffer_get_stride (shm_buffer); + + switch (wl_shm_buffer_get_format (shm_buffer)) + { +#if G_BYTE_ORDER == G_BIG_ENDIAN + case WL_SHM_FORMAT_ARGB8888: + gbm_format = GBM_FORMAT_ARGB8888; + break; + case WL_SHM_FORMAT_XRGB8888: + gbm_format = GBM_FORMAT_XRGB8888; + break; +#else + case WL_SHM_FORMAT_ARGB8888: + gbm_format = GBM_FORMAT_ARGB8888; + break; + case WL_SHM_FORMAT_XRGB8888: + gbm_format = GBM_FORMAT_XRGB8888; + break; +#endif + default: + g_warn_if_reached (); + gbm_format = GBM_FORMAT_ARGB8888; + } + + meta_cursor_image_load_gbm_buffer (tracker->gbm, + image, + (uint8_t *) wl_shm_buffer_get_data (shm_buffer), + width, height, rowstride, + gbm_format); + } } else {