mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 00:20:42 -05:00
screencast: Implement buffer-transform support
So all cursor renderers support the feature. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/344>
This commit is contained in:
parent
f804fe3a82
commit
22b9a4219a
@ -592,13 +592,17 @@ meta_screen_cast_area_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc *s
|
||||
{
|
||||
float cursor_scale;
|
||||
float metadata_scale;
|
||||
MetaMonitorTransform transform;
|
||||
|
||||
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,
|
||||
spa_meta_cursor,
|
||||
cursor_sprite,
|
||||
x, y,
|
||||
transform,
|
||||
metadata_scale);
|
||||
}
|
||||
else
|
||||
|
@ -687,14 +687,18 @@ meta_screen_cast_monitor_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc
|
||||
{
|
||||
float cursor_scale;
|
||||
float scale;
|
||||
MetaMonitorTransform transform;
|
||||
|
||||
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,
|
||||
spa_meta_cursor,
|
||||
cursor_sprite,
|
||||
x, y,
|
||||
scale);
|
||||
scale,
|
||||
transform);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -249,6 +249,7 @@ draw_cursor_sprite_via_offscreen (MetaScreenCastStreamSrc *src,
|
||||
CoglTexture *cursor_texture,
|
||||
int bitmap_width,
|
||||
int bitmap_height,
|
||||
MetaMonitorTransform transform,
|
||||
uint8_t *bitmap_data,
|
||||
GError **error)
|
||||
{
|
||||
@ -265,6 +266,7 @@ draw_cursor_sprite_via_offscreen (MetaScreenCastStreamSrc *src,
|
||||
CoglFramebuffer *fb;
|
||||
CoglPipeline *pipeline;
|
||||
CoglColor clear_color;
|
||||
graphene_matrix_t matrix;
|
||||
|
||||
bitmap_texture = cogl_texture_2d_new_with_size (cogl_context,
|
||||
bitmap_width, bitmap_height);
|
||||
@ -290,6 +292,12 @@ draw_cursor_sprite_via_offscreen (MetaScreenCastStreamSrc *src,
|
||||
cogl_pipeline_set_layer_filters (pipeline, 0,
|
||||
COGL_PIPELINE_FILTER_LINEAR,
|
||||
COGL_PIPELINE_FILTER_LINEAR);
|
||||
|
||||
graphene_matrix_init_identity (&matrix);
|
||||
meta_monitor_transform_transform_matrix (transform,
|
||||
&matrix);
|
||||
cogl_pipeline_set_layer_matrix (pipeline, 0, &matrix);
|
||||
|
||||
cogl_color_init_from_4ub (&clear_color, 0, 0, 0, 0);
|
||||
cogl_framebuffer_clear (fb, COGL_BUFFER_BIT_COLOR, &clear_color);
|
||||
cogl_framebuffer_draw_rectangle (fb, pipeline,
|
||||
@ -310,6 +318,7 @@ gboolean
|
||||
meta_screen_cast_stream_src_draw_cursor_into (MetaScreenCastStreamSrc *src,
|
||||
CoglTexture *cursor_texture,
|
||||
float scale,
|
||||
MetaMonitorTransform transform,
|
||||
uint8_t *data,
|
||||
GError **error)
|
||||
{
|
||||
@ -322,7 +331,8 @@ meta_screen_cast_stream_src_draw_cursor_into (MetaScreenCastStreamSrc *src,
|
||||
height = texture_height * scale;
|
||||
|
||||
if (texture_width == width &&
|
||||
texture_height == height)
|
||||
texture_height == height &&
|
||||
transform == META_MONITOR_TRANSFORM_NORMAL)
|
||||
{
|
||||
cogl_texture_get_data (cursor_texture,
|
||||
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
|
||||
@ -335,6 +345,7 @@ meta_screen_cast_stream_src_draw_cursor_into (MetaScreenCastStreamSrc *src,
|
||||
cursor_texture,
|
||||
width,
|
||||
height,
|
||||
transform,
|
||||
data,
|
||||
error))
|
||||
return FALSE;
|
||||
@ -396,7 +407,8 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
|
||||
MetaCursorSprite *cursor_sprite,
|
||||
int x,
|
||||
int y,
|
||||
float scale)
|
||||
float scale,
|
||||
MetaMonitorTransform transform)
|
||||
{
|
||||
CoglTexture *cursor_texture;
|
||||
struct spa_meta_bitmap *spa_meta_bitmap;
|
||||
@ -447,6 +459,7 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
|
||||
if (!meta_screen_cast_stream_src_draw_cursor_into (src,
|
||||
cursor_texture,
|
||||
scale,
|
||||
transform,
|
||||
bitmap_data,
|
||||
&error))
|
||||
{
|
||||
|
@ -94,6 +94,7 @@ MetaScreenCastStream * meta_screen_cast_stream_src_get_stream (MetaScreenCastStr
|
||||
gboolean meta_screen_cast_stream_src_draw_cursor_into (MetaScreenCastStreamSrc *src,
|
||||
CoglTexture *cursor_texture,
|
||||
float scale,
|
||||
MetaMonitorTransform transform,
|
||||
uint8_t *data,
|
||||
GError **error);
|
||||
|
||||
@ -115,6 +116,7 @@ void meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStrea
|
||||
MetaCursorSprite *cursor_sprite,
|
||||
int x,
|
||||
int y,
|
||||
float scale);
|
||||
float scale,
|
||||
MetaMonitorTransform transform);
|
||||
|
||||
#endif /* META_SCREEN_CAST_STREAM_SRC_H */
|
||||
|
@ -471,14 +471,18 @@ meta_screen_cast_virtual_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc
|
||||
{
|
||||
float cursor_scale;
|
||||
float scale;
|
||||
MetaMonitorTransform transform;
|
||||
|
||||
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,
|
||||
spa_meta_cursor,
|
||||
cursor_sprite,
|
||||
x, y,
|
||||
scale);
|
||||
scale,
|
||||
transform);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -130,6 +130,7 @@ maybe_draw_cursor_sprite (MetaScreenCastWindowStreamSrc *window_src,
|
||||
cairo_surface_t *stream_surface;
|
||||
int width, height;
|
||||
float scale;
|
||||
MetaMonitorTransform transform;
|
||||
int hotspot_x, hotspot_y;
|
||||
cairo_t *cr;
|
||||
|
||||
@ -147,6 +148,7 @@ maybe_draw_cursor_sprite (MetaScreenCastWindowStreamSrc *window_src,
|
||||
cursor_sprite,
|
||||
&cursor_position,
|
||||
&scale,
|
||||
&transform,
|
||||
&relative_cursor_position))
|
||||
return;
|
||||
|
||||
@ -161,6 +163,7 @@ maybe_draw_cursor_sprite (MetaScreenCastWindowStreamSrc *window_src,
|
||||
if (!meta_screen_cast_stream_src_draw_cursor_into (src,
|
||||
cursor_texture,
|
||||
scale,
|
||||
transform,
|
||||
cursor_surface_data,
|
||||
&error))
|
||||
{
|
||||
@ -208,8 +211,10 @@ maybe_blit_cursor_sprite (MetaScreenCastWindowStreamSrc *window_src,
|
||||
CoglPipeline *pipeline;
|
||||
int width, height;
|
||||
float scale;
|
||||
MetaMonitorTransform transform;
|
||||
int hotspot_x, hotspot_y;
|
||||
float x, y;
|
||||
graphene_matrix_t matrix;
|
||||
|
||||
cursor_sprite = meta_cursor_renderer_get_cursor (cursor_renderer);
|
||||
if (!cursor_sprite)
|
||||
@ -225,6 +230,7 @@ maybe_blit_cursor_sprite (MetaScreenCastWindowStreamSrc *window_src,
|
||||
cursor_sprite,
|
||||
&cursor_position,
|
||||
&scale,
|
||||
&transform,
|
||||
&relative_cursor_position))
|
||||
return;
|
||||
|
||||
@ -241,6 +247,11 @@ maybe_blit_cursor_sprite (MetaScreenCastWindowStreamSrc *window_src,
|
||||
COGL_PIPELINE_FILTER_LINEAR,
|
||||
COGL_PIPELINE_FILTER_LINEAR);
|
||||
|
||||
graphene_matrix_init_identity (&matrix);
|
||||
meta_monitor_transform_transform_matrix (transform,
|
||||
&matrix);
|
||||
cogl_pipeline_set_layer_matrix (pipeline, 0, &matrix);
|
||||
|
||||
cogl_framebuffer_draw_rectangle (framebuffer,
|
||||
pipeline,
|
||||
x, y,
|
||||
@ -557,6 +568,7 @@ meta_screen_cast_window_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc
|
||||
MetaCursorSprite *cursor_sprite;
|
||||
graphene_point_t cursor_position;
|
||||
float scale;
|
||||
MetaMonitorTransform transform;
|
||||
graphene_point_t relative_cursor_position;
|
||||
int x, y;
|
||||
|
||||
@ -568,6 +580,7 @@ meta_screen_cast_window_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc
|
||||
cursor_sprite,
|
||||
&cursor_position,
|
||||
&scale,
|
||||
&transform,
|
||||
&relative_cursor_position))
|
||||
{
|
||||
meta_screen_cast_stream_src_unset_cursor_metadata (src,
|
||||
@ -586,7 +599,8 @@ meta_screen_cast_window_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc
|
||||
spa_meta_cursor,
|
||||
cursor_sprite,
|
||||
x, y,
|
||||
scale);
|
||||
scale,
|
||||
transform);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -56,6 +56,7 @@ meta_screen_cast_window_transform_cursor_position (MetaScreenCastWindow *screen_
|
||||
MetaCursorSprite *cursor_sprite,
|
||||
graphene_point_t *cursor_position,
|
||||
float *out_cursor_scale,
|
||||
MetaMonitorTransform *out_cursor_transform,
|
||||
graphene_point_t *out_relative_cursor_position)
|
||||
{
|
||||
MetaScreenCastWindowInterface *iface =
|
||||
@ -65,6 +66,7 @@ meta_screen_cast_window_transform_cursor_position (MetaScreenCastWindow *screen_
|
||||
cursor_sprite,
|
||||
cursor_position,
|
||||
out_cursor_scale,
|
||||
out_cursor_transform,
|
||||
out_relative_cursor_position);
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,7 @@ struct _MetaScreenCastWindowInterface
|
||||
MetaCursorSprite *cursor_sprite,
|
||||
graphene_point_t *cursor_position,
|
||||
float *out_cursor_scale,
|
||||
MetaMonitorTransform *out_cursor_transform,
|
||||
graphene_point_t *out_relative_cursor_position);
|
||||
|
||||
void (*capture_into) (MetaScreenCastWindow *screen_cast_window,
|
||||
@ -76,6 +77,7 @@ gboolean meta_screen_cast_window_transform_cursor_position (MetaScreenCastWindow
|
||||
MetaCursorSprite *cursor_sprite,
|
||||
graphene_point_t *cursor_position,
|
||||
float *out_cursor_scale,
|
||||
MetaMonitorTransform *out_cursor_transform,
|
||||
graphene_point_t *out_relative_cursor_position);
|
||||
|
||||
void meta_screen_cast_window_capture_into (MetaScreenCastWindow *screen_cast_window,
|
||||
|
@ -1241,6 +1241,7 @@ meta_window_actor_transform_cursor_position (MetaScreenCastWindow *screen_cast_w
|
||||
MetaCursorSprite *cursor_sprite,
|
||||
graphene_point_t *cursor_position,
|
||||
float *out_cursor_scale,
|
||||
MetaMonitorTransform *out_cursor_transform,
|
||||
graphene_point_t *out_relative_cursor_position)
|
||||
{
|
||||
MetaWindowActor *window_actor = META_WINDOW_ACTOR (screen_cast_window);
|
||||
@ -1267,6 +1268,14 @@ meta_window_actor_transform_cursor_position (MetaScreenCastWindow *screen_cast_w
|
||||
*out_cursor_scale = texture_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)
|
||||
{
|
||||
clutter_actor_transform_stage_point (CLUTTER_ACTOR (priv->surface),
|
||||
|
Loading…
Reference in New Issue
Block a user