screen-cast: Implement viewport support
[jadahl] Rework hotspot calculations Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3859>
This commit is contained in:
parent
f77d8e2a12
commit
e580453df9
@ -667,22 +667,15 @@ meta_screen_cast_area_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc *s
|
|||||||
{
|
{
|
||||||
if (cursor_sprite)
|
if (cursor_sprite)
|
||||||
{
|
{
|
||||||
float scale;
|
float view_scale;
|
||||||
float cursor_scale;
|
|
||||||
float metadata_scale;
|
|
||||||
MtkMonitorTransform transform;
|
|
||||||
|
|
||||||
scale = meta_screen_cast_area_stream_get_scale (area_stream);
|
view_scale = meta_screen_cast_area_stream_get_scale (area_stream);
|
||||||
cursor_scale = meta_cursor_sprite_get_texture_scale (cursor_sprite);
|
|
||||||
metadata_scale = scale * cursor_scale;
|
|
||||||
transform = meta_cursor_sprite_get_texture_transform (cursor_sprite);
|
|
||||||
|
|
||||||
meta_screen_cast_stream_src_set_cursor_sprite_metadata (src,
|
meta_screen_cast_stream_src_set_cursor_sprite_metadata (src,
|
||||||
spa_meta_cursor,
|
spa_meta_cursor,
|
||||||
cursor_sprite,
|
cursor_sprite,
|
||||||
x, y,
|
x, y,
|
||||||
transform,
|
view_scale);
|
||||||
metadata_scale);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -852,21 +852,14 @@ meta_screen_cast_monitor_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc
|
|||||||
if (cursor_sprite)
|
if (cursor_sprite)
|
||||||
{
|
{
|
||||||
float view_scale;
|
float view_scale;
|
||||||
float cursor_scale;
|
|
||||||
float scale;
|
|
||||||
MtkMonitorTransform transform;
|
|
||||||
|
|
||||||
view_scale = get_view_scale (monitor_src);
|
view_scale = get_view_scale (monitor_src);
|
||||||
cursor_scale = meta_cursor_sprite_get_texture_scale (cursor_sprite);
|
|
||||||
scale = view_scale * cursor_scale;
|
|
||||||
transform = meta_cursor_sprite_get_texture_transform (cursor_sprite);
|
|
||||||
|
|
||||||
meta_screen_cast_stream_src_set_cursor_sprite_metadata (src,
|
meta_screen_cast_stream_src_set_cursor_sprite_metadata (src,
|
||||||
spa_meta_cursor,
|
spa_meta_cursor,
|
||||||
cursor_sprite,
|
cursor_sprite,
|
||||||
x, y,
|
x, y,
|
||||||
scale,
|
view_scale);
|
||||||
transform);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -368,7 +368,7 @@ draw_cursor_sprite_via_offscreen (MetaScreenCastStreamSrc *src,
|
|||||||
CoglTexture *cursor_texture,
|
CoglTexture *cursor_texture,
|
||||||
int bitmap_width,
|
int bitmap_width,
|
||||||
int bitmap_height,
|
int bitmap_height,
|
||||||
MtkMonitorTransform transform,
|
const graphene_matrix_t *matrix,
|
||||||
uint8_t *bitmap_data,
|
uint8_t *bitmap_data,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
@ -385,7 +385,6 @@ draw_cursor_sprite_via_offscreen (MetaScreenCastStreamSrc *src,
|
|||||||
CoglFramebuffer *fb;
|
CoglFramebuffer *fb;
|
||||||
CoglPipeline *pipeline;
|
CoglPipeline *pipeline;
|
||||||
CoglColor clear_color;
|
CoglColor clear_color;
|
||||||
graphene_matrix_t matrix;
|
|
||||||
|
|
||||||
bitmap_texture = cogl_texture_2d_new_with_size (cogl_context,
|
bitmap_texture = cogl_texture_2d_new_with_size (cogl_context,
|
||||||
bitmap_width, bitmap_height);
|
bitmap_width, bitmap_height);
|
||||||
@ -411,10 +410,7 @@ draw_cursor_sprite_via_offscreen (MetaScreenCastStreamSrc *src,
|
|||||||
COGL_PIPELINE_FILTER_LINEAR,
|
COGL_PIPELINE_FILTER_LINEAR,
|
||||||
COGL_PIPELINE_FILTER_LINEAR);
|
COGL_PIPELINE_FILTER_LINEAR);
|
||||||
|
|
||||||
graphene_matrix_init_identity (&matrix);
|
cogl_pipeline_set_layer_matrix (pipeline, 0, matrix);
|
||||||
mtk_monitor_transform_transform_matrix (transform,
|
|
||||||
&matrix);
|
|
||||||
cogl_pipeline_set_layer_matrix (pipeline, 0, &matrix);
|
|
||||||
|
|
||||||
cogl_color_init_from_4f (&clear_color, 0.0, 0.0, 0.0, 0.0);
|
cogl_color_init_from_4f (&clear_color, 0.0, 0.0, 0.0, 0.0);
|
||||||
cogl_framebuffer_clear (fb, COGL_BUFFER_BIT_COLOR, &clear_color);
|
cogl_framebuffer_clear (fb, COGL_BUFFER_BIT_COLOR, &clear_color);
|
||||||
@ -435,22 +431,20 @@ draw_cursor_sprite_via_offscreen (MetaScreenCastStreamSrc *src,
|
|||||||
gboolean
|
gboolean
|
||||||
meta_screen_cast_stream_src_draw_cursor_into (MetaScreenCastStreamSrc *src,
|
meta_screen_cast_stream_src_draw_cursor_into (MetaScreenCastStreamSrc *src,
|
||||||
CoglTexture *cursor_texture,
|
CoglTexture *cursor_texture,
|
||||||
float scale,
|
int width,
|
||||||
MtkMonitorTransform transform,
|
int height,
|
||||||
|
const graphene_matrix_t *matrix,
|
||||||
uint8_t *data,
|
uint8_t *data,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
int texture_width, texture_height;
|
int texture_width, texture_height;
|
||||||
int width, height;
|
|
||||||
|
|
||||||
texture_width = cogl_texture_get_width (cursor_texture);
|
texture_width = cogl_texture_get_width (cursor_texture);
|
||||||
texture_height = cogl_texture_get_height (cursor_texture);
|
texture_height = cogl_texture_get_height (cursor_texture);
|
||||||
width = (int) ceilf (texture_width * scale);
|
|
||||||
height = (int) ceilf (texture_height * scale);
|
|
||||||
|
|
||||||
if (texture_width == width &&
|
if (texture_width == width &&
|
||||||
texture_height == height &&
|
texture_height == height &&
|
||||||
transform == MTK_MONITOR_TRANSFORM_NORMAL)
|
graphene_matrix_is_identity (matrix))
|
||||||
{
|
{
|
||||||
cogl_texture_get_data (cursor_texture,
|
cogl_texture_get_data (cursor_texture,
|
||||||
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
|
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
|
||||||
@ -463,7 +457,7 @@ meta_screen_cast_stream_src_draw_cursor_into (MetaScreenCastStreamSrc *src,
|
|||||||
cursor_texture,
|
cursor_texture,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
transform,
|
matrix,
|
||||||
data,
|
data,
|
||||||
error))
|
error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -525,15 +519,19 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
|
|||||||
MetaCursorSprite *cursor_sprite,
|
MetaCursorSprite *cursor_sprite,
|
||||||
int x,
|
int x,
|
||||||
int y,
|
int y,
|
||||||
float scale,
|
float view_scale)
|
||||||
MtkMonitorTransform transform)
|
|
||||||
{
|
{
|
||||||
CoglTexture *cursor_texture;
|
CoglTexture *cursor_texture;
|
||||||
struct spa_meta_bitmap *spa_meta_bitmap;
|
struct spa_meta_bitmap *spa_meta_bitmap;
|
||||||
int hotspot_x, hotspot_y;
|
int hotspot_x, hotspot_y;
|
||||||
int texture_width, texture_height;
|
int texture_width, texture_height;
|
||||||
int bitmap_width, bitmap_height;
|
int bitmap_width, bitmap_height;
|
||||||
|
int dst_width, dst_height;
|
||||||
uint8_t *bitmap_data;
|
uint8_t *bitmap_data;
|
||||||
|
float cursor_scale;
|
||||||
|
MtkMonitorTransform cursor_transform;
|
||||||
|
const graphene_rect_t *src_rect;
|
||||||
|
graphene_matrix_t matrix;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
cursor_texture = meta_cursor_sprite_get_cogl_texture (cursor_sprite);
|
cursor_texture = meta_cursor_sprite_get_cogl_texture (cursor_sprite);
|
||||||
@ -557,14 +555,72 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
|
|||||||
spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA;
|
spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA;
|
||||||
spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
|
spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
|
||||||
|
|
||||||
meta_cursor_sprite_get_hotspot (cursor_sprite, &hotspot_x, &hotspot_y);
|
|
||||||
spa_meta_cursor->hotspot.x = (int32_t) roundf (hotspot_x * scale);
|
|
||||||
spa_meta_cursor->hotspot.y = (int32_t) roundf (hotspot_y * scale);
|
|
||||||
|
|
||||||
texture_width = cogl_texture_get_width (cursor_texture);
|
texture_width = cogl_texture_get_width (cursor_texture);
|
||||||
texture_height = cogl_texture_get_height (cursor_texture);
|
texture_height = cogl_texture_get_height (cursor_texture);
|
||||||
|
|
||||||
|
meta_cursor_sprite_get_hotspot (cursor_sprite, &hotspot_x, &hotspot_y);
|
||||||
|
cursor_scale = meta_cursor_sprite_get_texture_scale (cursor_sprite);
|
||||||
|
cursor_transform = meta_cursor_sprite_get_texture_transform (cursor_sprite);
|
||||||
|
src_rect = meta_cursor_sprite_get_viewport_src_rect (cursor_sprite);
|
||||||
|
|
||||||
|
if (meta_cursor_sprite_get_viewport_dst_size (cursor_sprite,
|
||||||
|
&dst_width,
|
||||||
|
&dst_height))
|
||||||
|
{
|
||||||
|
float cursor_scale_x, cursor_scale_y;
|
||||||
|
float scaled_hotspot_x, scaled_hotspot_y;
|
||||||
|
|
||||||
|
cursor_scale_x = (float) dst_width / texture_width;
|
||||||
|
cursor_scale_y = (float) dst_height / texture_height;
|
||||||
|
|
||||||
|
scaled_hotspot_x = roundf (hotspot_x * cursor_scale_x);
|
||||||
|
scaled_hotspot_y = roundf (hotspot_y * cursor_scale_y);
|
||||||
|
|
||||||
|
bitmap_width = (int) ceilf (dst_width * view_scale);
|
||||||
|
bitmap_height = (int) ceilf (dst_height * view_scale);
|
||||||
|
spa_meta_cursor->hotspot.x = (int32_t) ceilf (scaled_hotspot_x * view_scale);
|
||||||
|
spa_meta_cursor->hotspot.y = (int32_t) ceilf (scaled_hotspot_y * view_scale);
|
||||||
|
}
|
||||||
|
else if (src_rect)
|
||||||
|
{
|
||||||
|
float scale_x, scale_y;
|
||||||
|
|
||||||
|
scale_x = (float) src_rect->size.width / texture_width * view_scale;
|
||||||
|
scale_y = (float) src_rect->size.height / texture_height * view_scale;
|
||||||
|
|
||||||
|
bitmap_width = (int) ceilf (src_rect->size.width * view_scale);
|
||||||
|
bitmap_height = (int) ceilf (src_rect->size.height * view_scale);
|
||||||
|
spa_meta_cursor->hotspot.x = (int32_t) roundf (hotspot_x * scale_x);
|
||||||
|
spa_meta_cursor->hotspot.y = (int32_t) roundf (hotspot_y * scale_y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
float scale;
|
||||||
|
|
||||||
|
scale = cursor_scale * view_scale;
|
||||||
|
|
||||||
|
if (mtk_monitor_transform_is_rotated (cursor_transform))
|
||||||
|
{
|
||||||
|
bitmap_width = (int) ceilf (texture_height * scale);
|
||||||
|
bitmap_height = (int) ceilf (texture_width * scale);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
bitmap_width = (int) ceilf (texture_width * scale);
|
bitmap_width = (int) ceilf (texture_width * scale);
|
||||||
bitmap_height = (int) ceilf (texture_height * scale);
|
bitmap_height = (int) ceilf (texture_height * scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
spa_meta_cursor->hotspot.x = (int32_t) ceilf (hotspot_x * scale);
|
||||||
|
spa_meta_cursor->hotspot.y = (int32_t) ceilf (hotspot_y * scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
graphene_matrix_init_identity (&matrix);
|
||||||
|
mtk_compute_viewport_matrix (&matrix,
|
||||||
|
texture_width,
|
||||||
|
texture_height,
|
||||||
|
cursor_scale,
|
||||||
|
cursor_transform,
|
||||||
|
src_rect);
|
||||||
|
|
||||||
spa_meta_bitmap->size.width = bitmap_width;
|
spa_meta_bitmap->size.width = bitmap_width;
|
||||||
spa_meta_bitmap->size.height = bitmap_height;
|
spa_meta_bitmap->size.height = bitmap_height;
|
||||||
@ -576,8 +632,9 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
|
|||||||
|
|
||||||
if (!meta_screen_cast_stream_src_draw_cursor_into (src,
|
if (!meta_screen_cast_stream_src_draw_cursor_into (src,
|
||||||
cursor_texture,
|
cursor_texture,
|
||||||
scale,
|
bitmap_width,
|
||||||
transform,
|
bitmap_height,
|
||||||
|
&matrix,
|
||||||
bitmap_data,
|
bitmap_data,
|
||||||
&error))
|
&error))
|
||||||
{
|
{
|
||||||
|
@ -118,8 +118,9 @@ MetaScreenCastStream * meta_screen_cast_stream_src_get_stream (MetaScreenCastStr
|
|||||||
|
|
||||||
gboolean meta_screen_cast_stream_src_draw_cursor_into (MetaScreenCastStreamSrc *src,
|
gboolean meta_screen_cast_stream_src_draw_cursor_into (MetaScreenCastStreamSrc *src,
|
||||||
CoglTexture *cursor_texture,
|
CoglTexture *cursor_texture,
|
||||||
float scale,
|
int width,
|
||||||
MtkMonitorTransform transform,
|
int height,
|
||||||
|
const graphene_matrix_t *matrix,
|
||||||
uint8_t *data,
|
uint8_t *data,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
@ -141,8 +142,7 @@ void meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStrea
|
|||||||
MetaCursorSprite *cursor_sprite,
|
MetaCursorSprite *cursor_sprite,
|
||||||
int x,
|
int x,
|
||||||
int y,
|
int y,
|
||||||
float scale,
|
float view_scale);
|
||||||
MtkMonitorTransform transform);
|
|
||||||
|
|
||||||
gboolean meta_screen_cast_stream_src_uses_dma_bufs (MetaScreenCastStreamSrc *src);
|
gboolean meta_screen_cast_stream_src_uses_dma_bufs (MetaScreenCastStreamSrc *src);
|
||||||
|
|
||||||
|
@ -563,23 +563,15 @@ meta_screen_cast_virtual_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc
|
|||||||
{
|
{
|
||||||
ClutterStageView *stage_view;
|
ClutterStageView *stage_view;
|
||||||
float view_scale;
|
float view_scale;
|
||||||
float cursor_scale;
|
|
||||||
float scale;
|
|
||||||
MtkMonitorTransform transform;
|
|
||||||
|
|
||||||
stage_view = view_from_src (src);
|
stage_view = view_from_src (src);
|
||||||
view_scale = clutter_stage_view_get_scale (stage_view);
|
view_scale = clutter_stage_view_get_scale (stage_view);
|
||||||
|
|
||||||
cursor_scale = meta_cursor_sprite_get_texture_scale (cursor_sprite);
|
|
||||||
scale = view_scale * cursor_scale;
|
|
||||||
transform = meta_cursor_sprite_get_texture_transform (cursor_sprite);
|
|
||||||
|
|
||||||
meta_screen_cast_stream_src_set_cursor_sprite_metadata (src,
|
meta_screen_cast_stream_src_set_cursor_sprite_metadata (src,
|
||||||
spa_meta_cursor,
|
spa_meta_cursor,
|
||||||
cursor_sprite,
|
cursor_sprite,
|
||||||
x, y,
|
x, y,
|
||||||
scale,
|
view_scale);
|
||||||
transform);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -133,8 +133,11 @@ maybe_draw_cursor_sprite (MetaScreenCastWindowStreamSrc *window_src,
|
|||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
cairo_surface_t *stream_surface;
|
cairo_surface_t *stream_surface;
|
||||||
int width, height;
|
int width, height;
|
||||||
float scale;
|
int texture_width, texture_height;
|
||||||
MtkMonitorTransform transform;
|
float scale, view_scale, cursor_scale;
|
||||||
|
MtkMonitorTransform cursor_transform;
|
||||||
|
const graphene_rect_t *src_rect;
|
||||||
|
graphene_matrix_t matrix;
|
||||||
int hotspot_x, hotspot_y;
|
int hotspot_x, hotspot_y;
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
|
|
||||||
@ -151,23 +154,63 @@ maybe_draw_cursor_sprite (MetaScreenCastWindowStreamSrc *window_src,
|
|||||||
if (!meta_screen_cast_window_transform_cursor_position (screen_cast_window,
|
if (!meta_screen_cast_window_transform_cursor_position (screen_cast_window,
|
||||||
cursor_sprite,
|
cursor_sprite,
|
||||||
&cursor_position,
|
&cursor_position,
|
||||||
&scale,
|
&relative_cursor_position,
|
||||||
&transform,
|
&view_scale))
|
||||||
&relative_cursor_position))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
meta_cursor_sprite_get_hotspot (cursor_sprite, &hotspot_x, &hotspot_y);
|
meta_cursor_sprite_get_hotspot (cursor_sprite, &hotspot_x, &hotspot_y);
|
||||||
|
cursor_scale = meta_cursor_sprite_get_texture_scale (cursor_sprite);
|
||||||
|
scale = cursor_scale * view_scale;
|
||||||
|
cursor_transform = meta_cursor_sprite_get_texture_transform (cursor_sprite);
|
||||||
|
src_rect = meta_cursor_sprite_get_viewport_src_rect (cursor_sprite);
|
||||||
|
|
||||||
|
texture_width = cogl_texture_get_width (cursor_texture);
|
||||||
|
texture_height = cogl_texture_get_height (cursor_texture);
|
||||||
|
|
||||||
|
if (meta_cursor_sprite_get_viewport_dst_size (cursor_sprite,
|
||||||
|
&width,
|
||||||
|
&height))
|
||||||
|
{
|
||||||
|
width = (int) ceilf (width * view_scale);
|
||||||
|
height = (int) ceilf (height * view_scale);
|
||||||
|
}
|
||||||
|
else if (src_rect)
|
||||||
|
{
|
||||||
|
width = (int) ceilf (src_rect->size.width * view_scale);
|
||||||
|
height = (int) ceilf (src_rect->size.height * view_scale);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (mtk_monitor_transform_is_rotated (cursor_transform))
|
||||||
|
{
|
||||||
|
width = (int) ceilf (texture_height * scale);
|
||||||
|
height = (int) ceilf (texture_width * scale);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
width = (int) ceilf (texture_width * scale);
|
||||||
|
height = (int) ceilf (texture_height * scale);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
graphene_matrix_init_identity (&matrix);
|
||||||
|
mtk_compute_viewport_matrix (&matrix,
|
||||||
|
texture_width,
|
||||||
|
texture_height,
|
||||||
|
cursor_scale,
|
||||||
|
cursor_transform,
|
||||||
|
src_rect);
|
||||||
|
|
||||||
|
|
||||||
width = (int) (cogl_texture_get_width (cursor_texture) * scale);
|
|
||||||
height = (int) (cogl_texture_get_height (cursor_texture) * scale);
|
|
||||||
cursor_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
|
cursor_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
|
||||||
width, height);
|
width, height);
|
||||||
|
|
||||||
cursor_surface_data = cairo_image_surface_get_data (cursor_surface);
|
cursor_surface_data = cairo_image_surface_get_data (cursor_surface);
|
||||||
if (!meta_screen_cast_stream_src_draw_cursor_into (src,
|
if (!meta_screen_cast_stream_src_draw_cursor_into (src,
|
||||||
cursor_texture,
|
cursor_texture,
|
||||||
scale,
|
width,
|
||||||
transform,
|
height,
|
||||||
|
&matrix,
|
||||||
cursor_surface_data,
|
cursor_surface_data,
|
||||||
&error))
|
&error))
|
||||||
{
|
{
|
||||||
@ -216,11 +259,12 @@ maybe_blit_cursor_sprite (MetaScreenCastWindowStreamSrc *window_src,
|
|||||||
CoglTexture *cursor_texture;
|
CoglTexture *cursor_texture;
|
||||||
CoglPipeline *pipeline;
|
CoglPipeline *pipeline;
|
||||||
int width, height;
|
int width, height;
|
||||||
float scale;
|
float scale, view_scale, cursor_scale;
|
||||||
MtkMonitorTransform transform;
|
MtkMonitorTransform cursor_transform;
|
||||||
|
const graphene_rect_t *src_rect;
|
||||||
|
graphene_matrix_t matrix;
|
||||||
int hotspot_x, hotspot_y;
|
int hotspot_x, hotspot_y;
|
||||||
float x, y;
|
float x, y;
|
||||||
graphene_matrix_t matrix;
|
|
||||||
|
|
||||||
cursor_sprite = meta_cursor_renderer_get_cursor (cursor_renderer);
|
cursor_sprite = meta_cursor_renderer_get_cursor (cursor_renderer);
|
||||||
if (!cursor_sprite)
|
if (!cursor_sprite)
|
||||||
@ -235,12 +279,15 @@ maybe_blit_cursor_sprite (MetaScreenCastWindowStreamSrc *window_src,
|
|||||||
if (!meta_screen_cast_window_transform_cursor_position (screen_cast_window,
|
if (!meta_screen_cast_window_transform_cursor_position (screen_cast_window,
|
||||||
cursor_sprite,
|
cursor_sprite,
|
||||||
&cursor_position,
|
&cursor_position,
|
||||||
&scale,
|
&relative_cursor_position,
|
||||||
&transform,
|
&view_scale))
|
||||||
&relative_cursor_position))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
meta_cursor_sprite_get_hotspot (cursor_sprite, &hotspot_x, &hotspot_y);
|
meta_cursor_sprite_get_hotspot (cursor_sprite, &hotspot_x, &hotspot_y);
|
||||||
|
cursor_scale = meta_cursor_sprite_get_texture_scale (cursor_sprite);
|
||||||
|
scale = cursor_scale * view_scale;
|
||||||
|
cursor_transform = meta_cursor_sprite_get_texture_transform (cursor_sprite);
|
||||||
|
src_rect = meta_cursor_sprite_get_viewport_src_rect (cursor_sprite);
|
||||||
|
|
||||||
x = (relative_cursor_position.x - hotspot_x) * scale;
|
x = (relative_cursor_position.x - hotspot_x) * scale;
|
||||||
y = (relative_cursor_position.y - hotspot_y) * scale;
|
y = (relative_cursor_position.y - hotspot_y) * scale;
|
||||||
@ -254,8 +301,12 @@ maybe_blit_cursor_sprite (MetaScreenCastWindowStreamSrc *window_src,
|
|||||||
COGL_PIPELINE_FILTER_LINEAR);
|
COGL_PIPELINE_FILTER_LINEAR);
|
||||||
|
|
||||||
graphene_matrix_init_identity (&matrix);
|
graphene_matrix_init_identity (&matrix);
|
||||||
mtk_monitor_transform_transform_matrix (transform,
|
mtk_compute_viewport_matrix (&matrix,
|
||||||
&matrix);
|
width,
|
||||||
|
height,
|
||||||
|
cursor_scale,
|
||||||
|
cursor_transform,
|
||||||
|
src_rect);
|
||||||
cogl_pipeline_set_layer_matrix (pipeline, 0, &matrix);
|
cogl_pipeline_set_layer_matrix (pipeline, 0, &matrix);
|
||||||
|
|
||||||
cogl_framebuffer_draw_rectangle (framebuffer,
|
cogl_framebuffer_draw_rectangle (framebuffer,
|
||||||
@ -600,8 +651,8 @@ meta_screen_cast_window_stream_src_is_cursor_metadata_valid (MetaScreenCastStrea
|
|||||||
meta_screen_cast_window_transform_cursor_position (screen_cast_window,
|
meta_screen_cast_window_transform_cursor_position (screen_cast_window,
|
||||||
cursor_sprite,
|
cursor_sprite,
|
||||||
&cursor_position,
|
&cursor_position,
|
||||||
NULL, NULL,
|
&relative_cursor_position,
|
||||||
&relative_cursor_position))
|
NULL))
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
@ -637,8 +688,7 @@ meta_screen_cast_window_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc
|
|||||||
MetaScreenCastWindow *screen_cast_window = window_src->screen_cast_window;
|
MetaScreenCastWindow *screen_cast_window = window_src->screen_cast_window;
|
||||||
MetaCursorSprite *cursor_sprite;
|
MetaCursorSprite *cursor_sprite;
|
||||||
graphene_point_t cursor_position;
|
graphene_point_t cursor_position;
|
||||||
float scale;
|
float view_scale;
|
||||||
MtkMonitorTransform transform;
|
|
||||||
graphene_point_t relative_cursor_position;
|
graphene_point_t relative_cursor_position;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
@ -649,9 +699,8 @@ meta_screen_cast_window_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc
|
|||||||
!meta_screen_cast_window_transform_cursor_position (screen_cast_window,
|
!meta_screen_cast_window_transform_cursor_position (screen_cast_window,
|
||||||
cursor_sprite,
|
cursor_sprite,
|
||||||
&cursor_position,
|
&cursor_position,
|
||||||
&scale,
|
&relative_cursor_position,
|
||||||
&transform,
|
&view_scale))
|
||||||
&relative_cursor_position))
|
|
||||||
{
|
{
|
||||||
window_src->last_cursor_matadata.set = FALSE;
|
window_src->last_cursor_matadata.set = FALSE;
|
||||||
meta_screen_cast_stream_src_unset_cursor_metadata (src,
|
meta_screen_cast_stream_src_unset_cursor_metadata (src,
|
||||||
@ -674,8 +723,7 @@ meta_screen_cast_window_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc
|
|||||||
spa_meta_cursor,
|
spa_meta_cursor,
|
||||||
cursor_sprite,
|
cursor_sprite,
|
||||||
x, y,
|
x, y,
|
||||||
scale,
|
view_scale);
|
||||||
transform);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -53,9 +53,8 @@ gboolean
|
|||||||
meta_screen_cast_window_transform_cursor_position (MetaScreenCastWindow *screen_cast_window,
|
meta_screen_cast_window_transform_cursor_position (MetaScreenCastWindow *screen_cast_window,
|
||||||
MetaCursorSprite *cursor_sprite,
|
MetaCursorSprite *cursor_sprite,
|
||||||
graphene_point_t *cursor_position,
|
graphene_point_t *cursor_position,
|
||||||
float *out_cursor_scale,
|
graphene_point_t *out_relative_cursor_position,
|
||||||
MtkMonitorTransform *out_cursor_transform,
|
float *out_view_scale)
|
||||||
graphene_point_t *out_relative_cursor_position)
|
|
||||||
{
|
{
|
||||||
MetaScreenCastWindowInterface *iface =
|
MetaScreenCastWindowInterface *iface =
|
||||||
META_SCREEN_CAST_WINDOW_GET_IFACE (screen_cast_window);
|
META_SCREEN_CAST_WINDOW_GET_IFACE (screen_cast_window);
|
||||||
@ -63,9 +62,8 @@ meta_screen_cast_window_transform_cursor_position (MetaScreenCastWindow *screen_
|
|||||||
return iface->transform_cursor_position (screen_cast_window,
|
return iface->transform_cursor_position (screen_cast_window,
|
||||||
cursor_sprite,
|
cursor_sprite,
|
||||||
cursor_position,
|
cursor_position,
|
||||||
out_cursor_scale,
|
out_relative_cursor_position,
|
||||||
out_cursor_transform,
|
out_view_scale);
|
||||||
out_relative_cursor_position);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -46,9 +46,8 @@ struct _MetaScreenCastWindowInterface
|
|||||||
gboolean (*transform_cursor_position) (MetaScreenCastWindow *screen_cast_window,
|
gboolean (*transform_cursor_position) (MetaScreenCastWindow *screen_cast_window,
|
||||||
MetaCursorSprite *cursor_sprite,
|
MetaCursorSprite *cursor_sprite,
|
||||||
graphene_point_t *cursor_position,
|
graphene_point_t *cursor_position,
|
||||||
float *out_cursor_scale,
|
graphene_point_t *out_relative_cursor_position,
|
||||||
MtkMonitorTransform *out_cursor_transform,
|
float *out_view_scale);
|
||||||
graphene_point_t *out_relative_cursor_position);
|
|
||||||
|
|
||||||
void (*capture_into) (MetaScreenCastWindow *screen_cast_window,
|
void (*capture_into) (MetaScreenCastWindow *screen_cast_window,
|
||||||
MtkRectangle *bounds,
|
MtkRectangle *bounds,
|
||||||
@ -76,9 +75,8 @@ void meta_screen_cast_window_transform_relative_position (MetaScreenCastWindow *
|
|||||||
gboolean meta_screen_cast_window_transform_cursor_position (MetaScreenCastWindow *screen_cast_window,
|
gboolean meta_screen_cast_window_transform_cursor_position (MetaScreenCastWindow *screen_cast_window,
|
||||||
MetaCursorSprite *cursor_sprite,
|
MetaCursorSprite *cursor_sprite,
|
||||||
graphene_point_t *cursor_position,
|
graphene_point_t *cursor_position,
|
||||||
float *out_cursor_scale,
|
graphene_point_t *out_relative_cursor_position,
|
||||||
MtkMonitorTransform *out_cursor_transform,
|
float *out_view_scale);
|
||||||
graphene_point_t *out_relative_cursor_position);
|
|
||||||
|
|
||||||
void meta_screen_cast_window_capture_into (MetaScreenCastWindow *screen_cast_window,
|
void meta_screen_cast_window_capture_into (MetaScreenCastWindow *screen_cast_window,
|
||||||
MtkRectangle *bounds,
|
MtkRectangle *bounds,
|
||||||
|
@ -1284,9 +1284,8 @@ static gboolean
|
|||||||
meta_window_actor_transform_cursor_position (MetaScreenCastWindow *screen_cast_window,
|
meta_window_actor_transform_cursor_position (MetaScreenCastWindow *screen_cast_window,
|
||||||
MetaCursorSprite *cursor_sprite,
|
MetaCursorSprite *cursor_sprite,
|
||||||
graphene_point_t *cursor_position,
|
graphene_point_t *cursor_position,
|
||||||
float *out_cursor_scale,
|
graphene_point_t *out_relative_cursor_position,
|
||||||
MtkMonitorTransform *out_cursor_transform,
|
float *out_view_scale)
|
||||||
graphene_point_t *out_relative_cursor_position)
|
|
||||||
{
|
{
|
||||||
MetaWindowActor *window_actor = META_WINDOW_ACTOR (screen_cast_window);
|
MetaWindowActor *window_actor = META_WINDOW_ACTOR (screen_cast_window);
|
||||||
MetaWindowActorPrivate *priv =
|
MetaWindowActorPrivate *priv =
|
||||||
@ -1297,37 +1296,6 @@ meta_window_actor_transform_cursor_position (MetaScreenCastWindow *screen_cast_w
|
|||||||
if (!meta_window_has_pointer (window))
|
if (!meta_window_has_pointer (window))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (cursor_sprite &&
|
|
||||||
meta_cursor_sprite_get_cogl_texture (cursor_sprite) &&
|
|
||||||
out_cursor_scale)
|
|
||||||
{
|
|
||||||
MetaDisplay *display = meta_compositor_get_display (priv->compositor);
|
|
||||||
MetaContext *context = meta_display_get_context (display);
|
|
||||||
MetaBackend *backend = meta_context_get_backend (context);
|
|
||||||
MetaLogicalMonitor *logical_monitor;
|
|
||||||
float view_scale;
|
|
||||||
float cursor_texture_scale;
|
|
||||||
|
|
||||||
logical_monitor = meta_window_get_main_logical_monitor (window);
|
|
||||||
|
|
||||||
if (meta_backend_is_stage_views_scaled (backend))
|
|
||||||
view_scale = meta_logical_monitor_get_scale (logical_monitor);
|
|
||||||
else
|
|
||||||
view_scale = 1.0;
|
|
||||||
|
|
||||||
cursor_texture_scale = meta_cursor_sprite_get_texture_scale (cursor_sprite);
|
|
||||||
|
|
||||||
*out_cursor_scale = view_scale * cursor_texture_scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cursor_sprite &&
|
|
||||||
meta_cursor_sprite_get_cogl_texture (cursor_sprite) &&
|
|
||||||
out_cursor_transform)
|
|
||||||
{
|
|
||||||
*out_cursor_transform =
|
|
||||||
meta_cursor_sprite_get_texture_transform (cursor_sprite);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (out_relative_cursor_position)
|
if (out_relative_cursor_position)
|
||||||
{
|
{
|
||||||
MetaShapedTexture *stex = meta_surface_actor_get_texture (priv->surface);
|
MetaShapedTexture *stex = meta_surface_actor_get_texture (priv->surface);
|
||||||
@ -1350,6 +1318,25 @@ meta_window_actor_transform_cursor_position (MetaScreenCastWindow *screen_cast_w
|
|||||||
out_relative_cursor_position->y *= unscaled_height / height;
|
out_relative_cursor_position->y *= unscaled_height / height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (out_view_scale)
|
||||||
|
{
|
||||||
|
MetaDisplay *display = meta_compositor_get_display (priv->compositor);
|
||||||
|
MetaContext *context = meta_display_get_context (display);
|
||||||
|
MetaBackend *backend = meta_context_get_backend (context);
|
||||||
|
|
||||||
|
if (meta_backend_is_stage_views_scaled (backend))
|
||||||
|
{
|
||||||
|
MetaLogicalMonitor *logical_monitor;
|
||||||
|
|
||||||
|
logical_monitor = meta_window_get_main_logical_monitor (window);
|
||||||
|
*out_view_scale = meta_logical_monitor_get_scale (logical_monitor);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*out_view_scale = 1.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user