cursor: Always use cogl_wayland_texture_2d_new_from_buffer
It makes our life so much easier.
This commit is contained in:
parent
30ebf46aa4
commit
ba131626c2
@ -283,9 +283,9 @@ meta_cursor_image_load_from_buffer (MetaCursorTracker *tracker,
|
|||||||
{
|
{
|
||||||
ClutterBackend *backend;
|
ClutterBackend *backend;
|
||||||
CoglContext *cogl_context;
|
CoglContext *cogl_context;
|
||||||
CoglPixelFormat cogl_format;
|
|
||||||
struct wl_shm_buffer *shm_buffer;
|
struct wl_shm_buffer *shm_buffer;
|
||||||
uint32_t gbm_format;
|
uint32_t gbm_format;
|
||||||
|
int width, height;
|
||||||
|
|
||||||
image->hot_x = hot_x;
|
image->hot_x = hot_x;
|
||||||
image->hot_y = hot_y;
|
image->hot_y = hot_y;
|
||||||
@ -293,47 +293,38 @@ meta_cursor_image_load_from_buffer (MetaCursorTracker *tracker,
|
|||||||
backend = clutter_get_default_backend ();
|
backend = clutter_get_default_backend ();
|
||||||
cogl_context = clutter_backend_get_cogl_context (backend);
|
cogl_context = clutter_backend_get_cogl_context (backend);
|
||||||
|
|
||||||
|
image->texture = cogl_wayland_texture_2d_new_from_buffer (cogl_context, buffer, NULL);
|
||||||
|
|
||||||
|
width = cogl_texture_get_width (COGL_TEXTURE (image->texture));
|
||||||
|
height = cogl_texture_get_height (COGL_TEXTURE (image->texture));
|
||||||
|
|
||||||
shm_buffer = wl_shm_buffer_get (buffer);
|
shm_buffer = wl_shm_buffer_get (buffer);
|
||||||
if (shm_buffer)
|
if (shm_buffer)
|
||||||
{
|
{
|
||||||
int rowstride = wl_shm_buffer_get_stride (shm_buffer);
|
int rowstride = wl_shm_buffer_get_stride (shm_buffer);
|
||||||
int width = wl_shm_buffer_get_width (shm_buffer);
|
|
||||||
int height = wl_shm_buffer_get_height (shm_buffer);
|
|
||||||
|
|
||||||
switch (wl_shm_buffer_get_format (shm_buffer))
|
switch (wl_shm_buffer_get_format (shm_buffer))
|
||||||
{
|
{
|
||||||
#if G_BYTE_ORDER == G_BIG_ENDIAN
|
#if G_BYTE_ORDER == G_BIG_ENDIAN
|
||||||
case WL_SHM_FORMAT_ARGB8888:
|
case WL_SHM_FORMAT_ARGB8888:
|
||||||
cogl_format = COGL_PIXEL_FORMAT_ARGB_8888_PRE;
|
|
||||||
gbm_format = GBM_FORMAT_ARGB8888;
|
gbm_format = GBM_FORMAT_ARGB8888;
|
||||||
break;
|
break;
|
||||||
case WL_SHM_FORMAT_XRGB8888:
|
case WL_SHM_FORMAT_XRGB8888:
|
||||||
cogl_format = COGL_PIXEL_FORMAT_ARGB_8888;
|
|
||||||
gbm_format = GBM_FORMAT_XRGB8888;
|
gbm_format = GBM_FORMAT_XRGB8888;
|
||||||
break;
|
break;
|
||||||
#else
|
#else
|
||||||
case WL_SHM_FORMAT_ARGB8888:
|
case WL_SHM_FORMAT_ARGB8888:
|
||||||
cogl_format = COGL_PIXEL_FORMAT_BGRA_8888_PRE;
|
|
||||||
gbm_format = GBM_FORMAT_ARGB8888;
|
gbm_format = GBM_FORMAT_ARGB8888;
|
||||||
break;
|
break;
|
||||||
case WL_SHM_FORMAT_XRGB8888:
|
case WL_SHM_FORMAT_XRGB8888:
|
||||||
cogl_format = COGL_PIXEL_FORMAT_BGRA_8888;
|
|
||||||
gbm_format = GBM_FORMAT_XRGB8888;
|
gbm_format = GBM_FORMAT_XRGB8888;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
g_warn_if_reached ();
|
g_warn_if_reached ();
|
||||||
cogl_format = COGL_PIXEL_FORMAT_ARGB_8888;
|
|
||||||
gbm_format = GBM_FORMAT_ARGB8888;
|
gbm_format = GBM_FORMAT_ARGB8888;
|
||||||
}
|
}
|
||||||
|
|
||||||
image->texture = cogl_texture_2d_new_from_data (cogl_context,
|
|
||||||
width, height,
|
|
||||||
cogl_format,
|
|
||||||
rowstride,
|
|
||||||
wl_shm_buffer_get_data (shm_buffer),
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
if (width > 64 || height > 64)
|
if (width > 64 || height > 64)
|
||||||
{
|
{
|
||||||
meta_warning ("Invalid cursor size (must be at most 64x64), falling back to software (GL) cursors\n");
|
meta_warning ("Invalid cursor size (must be at most 64x64), falling back to software (GL) cursors\n");
|
||||||
@ -365,12 +356,6 @@ meta_cursor_image_load_from_buffer (MetaCursorTracker *tracker,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int width, height;
|
|
||||||
|
|
||||||
image->texture = cogl_wayland_texture_2d_new_from_buffer (cogl_context, buffer, NULL);
|
|
||||||
width = cogl_texture_get_width (COGL_TEXTURE (image->texture));
|
|
||||||
height = cogl_texture_get_height (COGL_TEXTURE (image->texture));
|
|
||||||
|
|
||||||
/* HW cursors must be 64x64, but 64x64 is huge, and no cursor theme actually uses
|
/* HW cursors must be 64x64, but 64x64 is huge, and no cursor theme actually uses
|
||||||
that, so themed cursors must be padded with transparent pixels to fill the
|
that, so themed cursors must be padded with transparent pixels to fill the
|
||||||
overlay. This is trivial if we have CPU access to the data, but it's not
|
overlay. This is trivial if we have CPU access to the data, but it's not
|
||||||
|
Loading…
Reference in New Issue
Block a user