cursor: Introduce accessors for the texture / GBM bo
We want to make this private, and have MetaCursorReference be backend-defined, with the texture possibly loaded on demand. We can't make the definition of MetaCursorReference truly private yet because of the XFixes cursor. A victim of MetaCursorTracker trying to do too many things at once...
This commit is contained in:
parent
21425b5833
commit
383d4c7e4e
@ -35,4 +35,12 @@ struct _MetaCursorReference {
|
|||||||
int hot_x, hot_y;
|
int hot_x, hot_y;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
CoglTexture *meta_cursor_reference_get_cogl_texture (MetaCursorReference *cursor,
|
||||||
|
int *hot_x,
|
||||||
|
int *hot_y);
|
||||||
|
|
||||||
|
struct gbm_bo *meta_cursor_reference_get_gbm_bo (MetaCursorReference *cursor,
|
||||||
|
int *hot_x,
|
||||||
|
int *hot_y);
|
||||||
|
|
||||||
#endif /* META_CURSOR_PRIVATE_H */
|
#endif /* META_CURSOR_PRIVATE_H */
|
||||||
|
@ -338,7 +338,7 @@ meta_cursor_tracker_get_sprite (MetaCursorTracker *tracker)
|
|||||||
ensure_xfixes_cursor (tracker);
|
ensure_xfixes_cursor (tracker);
|
||||||
|
|
||||||
if (tracker->displayed_cursor)
|
if (tracker->displayed_cursor)
|
||||||
return COGL_TEXTURE (tracker->displayed_cursor->texture);
|
return meta_cursor_reference_get_cogl_texture (tracker->displayed_cursor, NULL, NULL);
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -361,13 +361,7 @@ meta_cursor_tracker_get_hot (MetaCursorTracker *tracker,
|
|||||||
ensure_xfixes_cursor (tracker);
|
ensure_xfixes_cursor (tracker);
|
||||||
|
|
||||||
if (tracker->displayed_cursor)
|
if (tracker->displayed_cursor)
|
||||||
{
|
meta_cursor_reference_get_cogl_texture (tracker->displayed_cursor, x, y);
|
||||||
MetaCursorReference *displayed_cursor = tracker->displayed_cursor;
|
|
||||||
if (x)
|
|
||||||
*x = displayed_cursor->hot_x;
|
|
||||||
if (y)
|
|
||||||
*y = displayed_cursor->hot_y;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (x)
|
if (x)
|
||||||
@ -446,6 +440,15 @@ meta_cursor_tracker_set_root_cursor (MetaCursorTracker *tracker,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
should_have_hw_cursor (MetaCursorTracker *tracker)
|
||||||
|
{
|
||||||
|
if (tracker->displayed_cursor)
|
||||||
|
return (meta_cursor_reference_get_gbm_bo (tracker->displayed_cursor, NULL, NULL) != NULL);
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_hw_cursor (MetaCursorTracker *tracker)
|
update_hw_cursor (MetaCursorTracker *tracker)
|
||||||
{
|
{
|
||||||
@ -454,7 +457,7 @@ update_hw_cursor (MetaCursorTracker *tracker)
|
|||||||
unsigned int i, n_crtcs;
|
unsigned int i, n_crtcs;
|
||||||
gboolean enabled;
|
gboolean enabled;
|
||||||
|
|
||||||
enabled = tracker->displayed_cursor && tracker->displayed_cursor->bo != NULL;
|
enabled = should_have_hw_cursor (tracker);
|
||||||
tracker->has_hw_cursor = enabled;
|
tracker->has_hw_cursor = enabled;
|
||||||
|
|
||||||
monitors = meta_monitor_manager_get ();
|
monitors = meta_monitor_manager_get ();
|
||||||
@ -521,7 +524,10 @@ update_displayed_cursor (MetaCursorTracker *tracker)
|
|||||||
if (meta_is_wayland_compositor ())
|
if (meta_is_wayland_compositor ())
|
||||||
{
|
{
|
||||||
if (tracker->displayed_cursor)
|
if (tracker->displayed_cursor)
|
||||||
cogl_pipeline_set_layer_texture (tracker->pipeline, 0, COGL_TEXTURE (displayed_cursor->texture));
|
{
|
||||||
|
CoglTexture *texture = meta_cursor_reference_get_cogl_texture (tracker->displayed_cursor, NULL, NULL);
|
||||||
|
cogl_pipeline_set_layer_texture (tracker->pipeline, 0, texture);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
cogl_pipeline_set_layer_texture (tracker->pipeline, 0, NULL);
|
cogl_pipeline_set_layer_texture (tracker->pipeline, 0, NULL);
|
||||||
|
|
||||||
@ -585,10 +591,15 @@ sync_cursor (MetaCursorTracker *tracker)
|
|||||||
|
|
||||||
if (displayed_cursor)
|
if (displayed_cursor)
|
||||||
{
|
{
|
||||||
tracker->current_rect.x = tracker->current_x - displayed_cursor->hot_x;
|
CoglTexture *texture;
|
||||||
tracker->current_rect.y = tracker->current_y - displayed_cursor->hot_y;
|
int hot_x, hot_y;
|
||||||
tracker->current_rect.width = cogl_texture_get_width (COGL_TEXTURE (displayed_cursor->texture));
|
|
||||||
tracker->current_rect.height = cogl_texture_get_height (COGL_TEXTURE (displayed_cursor->texture));
|
texture = meta_cursor_reference_get_cogl_texture (displayed_cursor, &hot_x, &hot_y);
|
||||||
|
|
||||||
|
tracker->current_rect.x = tracker->current_x - hot_x;
|
||||||
|
tracker->current_rect.y = tracker->current_y - hot_y;
|
||||||
|
tracker->current_rect.width = cogl_texture_get_width (COGL_TEXTURE (texture));
|
||||||
|
tracker->current_rect.height = cogl_texture_get_height (COGL_TEXTURE (texture));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -649,15 +660,16 @@ meta_cursor_tracker_set_crtc_has_hw_cursor (MetaCursorTracker *tracker,
|
|||||||
if (has)
|
if (has)
|
||||||
{
|
{
|
||||||
MetaCursorReference *displayed_cursor = tracker->displayed_cursor;
|
MetaCursorReference *displayed_cursor = tracker->displayed_cursor;
|
||||||
|
struct gbm_bo *bo;
|
||||||
union gbm_bo_handle handle;
|
union gbm_bo_handle handle;
|
||||||
int width, height;
|
int width, height;
|
||||||
int hot_x, hot_y;
|
int hot_x, hot_y;
|
||||||
|
|
||||||
handle = gbm_bo_get_handle (displayed_cursor->bo);
|
bo = meta_cursor_reference_get_gbm_bo (displayed_cursor, &hot_x, &hot_y);
|
||||||
width = gbm_bo_get_width (displayed_cursor->bo);
|
|
||||||
height = gbm_bo_get_height (displayed_cursor->bo);
|
handle = gbm_bo_get_handle (bo);
|
||||||
hot_x = displayed_cursor->hot_x;
|
width = gbm_bo_get_width (bo);
|
||||||
hot_y = displayed_cursor->hot_y;
|
height = gbm_bo_get_height (bo);
|
||||||
|
|
||||||
drmModeSetCursor2 (tracker->drm_fd, crtc->crtc_id, handle.u32,
|
drmModeSetCursor2 (tracker->drm_fd, crtc->crtc_id, handle.u32,
|
||||||
width, height, hot_x, hot_y);
|
width, height, hot_x, hot_y);
|
||||||
|
@ -377,3 +377,27 @@ meta_cursor_reference_from_buffer (MetaCursorTracker *tracker,
|
|||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CoglTexture *
|
||||||
|
meta_cursor_reference_get_cogl_texture (MetaCursorReference *cursor,
|
||||||
|
int *hot_x,
|
||||||
|
int *hot_y)
|
||||||
|
{
|
||||||
|
if (hot_x)
|
||||||
|
*hot_x = cursor->hot_x;
|
||||||
|
if (hot_y)
|
||||||
|
*hot_y = cursor->hot_y;
|
||||||
|
return COGL_TEXTURE (cursor->texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct gbm_bo *
|
||||||
|
meta_cursor_reference_get_gbm_bo (MetaCursorReference *cursor,
|
||||||
|
int *hot_x,
|
||||||
|
int *hot_y)
|
||||||
|
{
|
||||||
|
if (hot_x)
|
||||||
|
*hot_x = cursor->hot_x;
|
||||||
|
if (hot_y)
|
||||||
|
*hot_y = cursor->hot_y;
|
||||||
|
return cursor->bo;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user