mtk: Move Rectangle.to_graphene_rect from Meta

Also drops the clutter equivalent

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
This commit is contained in:
Bilal Elmoussaoui 2023-08-08 12:27:58 +02:00
parent 3d693e8309
commit a93471eb90
16 changed files with 41 additions and 48 deletions

View File

@ -201,9 +201,6 @@ void _clutter_util_fully_transform_vertices (const graphene_matrix_t *modelvie
graphene_point3d_t *vertices_out,
int n_vertices);
CLUTTER_EXPORT
void _clutter_util_rect_from_rectangle (const MtkRectangle *src,
graphene_rect_t *dest);
CLUTTER_EXPORT
void _clutter_util_rectangle_int_extents (const graphene_rect_t *src,

View File

@ -2689,7 +2689,7 @@ clutter_stage_get_capture_final_size (ClutterStage *stage,
g_autoptr (GList) views = NULL;
GList *l;
_clutter_util_rect_from_rectangle (rect, &capture_rect);
capture_rect = mtk_rectangle_to_graphene_rect (rect);
views = clutter_stage_get_views_for_rect (stage, &capture_rect);
if (!views)
@ -2977,7 +2977,7 @@ clutter_stage_get_views_for_rect (ClutterStage *stage,
graphene_rect_t view_rect;
clutter_stage_view_get_layout (view, &view_layout);
_clutter_util_rect_from_rectangle (&view_layout, &view_rect);
view_rect = mtk_rectangle_to_graphene_rect (&view_layout);
if (graphene_rect_intersection (&view_rect, rect, NULL))
views_for_rect = g_list_prepend (views_for_rect, view);

View File

@ -119,22 +119,6 @@ _clutter_util_fully_transform_vertices (const graphene_matrix_t *modelview,
}
}
void
_clutter_util_rect_from_rectangle (const MtkRectangle *src,
graphene_rect_t *dest)
{
*dest = (graphene_rect_t) {
.origin = {
.x = src->x,
.y = src->y
},
.size = {
.width = src->width,
.height = src->height
}
};
}
void
_clutter_util_rectangle_int_extents (const graphene_rect_t *src,
MtkRectangle *dest)

View File

@ -29,6 +29,7 @@ mtk_pkg_deps = [
glib_dep,
gobject_dep,
gio_dep,
graphene_dep,
]
mtk_deps = [

View File

@ -55,6 +55,7 @@ if have_introspection
includes: [
'GObject-2.0',
'cairo-1.0',
'Graphene-1.0',
],
extra_args: mtk_introspection_args + ['--c-include=mtk/mtk.h'],
install_dir_gir: pkglibdir,

View File

@ -276,3 +276,24 @@ mtk_rectangle_contains_rect (const MtkRectangle *outer_rect,
inner_rect->x + inner_rect->width <= outer_rect->x + outer_rect->width &&
inner_rect->y + inner_rect->height <= outer_rect->y + outer_rect->height;
}
/**
* mtk_rectangle_to_graphene_rect:
* @rect: A rectangle
*
* Returns: Return a graphene_rect_t created from `rect`
*/
graphene_rect_t
mtk_rectangle_to_graphene_rect (MtkRectangle *rect)
{
return (graphene_rect_t) {
.origin = {
.x = rect->x,
.y = rect->y
},
.size = {
.width = rect->width,
.height = rect->height
}
};
}

View File

@ -23,6 +23,7 @@
#include <cairo.h>
#include <glib-object.h>
#include <graphene.h>
#include "mtk/mtk-macros.h"
@ -118,3 +119,6 @@ MTK_EXPORT
gboolean mtk_rectangle_contains_rect (const MtkRectangle *outer_rect,
const MtkRectangle *inner_rect);
MTK_EXPORT
graphene_rect_t mtk_rectangle_to_graphene_rect (MtkRectangle *rect);

View File

@ -179,7 +179,7 @@ meta_cursor_renderer_after_paint (ClutterStage *stage,
rect = meta_cursor_renderer_calculate_rect (renderer,
priv->displayed_cursor);
clutter_stage_view_get_layout (stage_view, &view_layout);
view_rect = meta_rectangle_to_graphene_rect (&view_layout);
view_rect = mtk_rectangle_to_graphene_rect (&view_layout);
if (graphene_rect_intersection (&rect, &view_rect, NULL))
{
meta_cursor_renderer_emit_painted (renderer,
@ -392,7 +392,7 @@ find_highest_logical_monitor_scale (MetaBackend *backend,
{
MetaLogicalMonitor *logical_monitor = l->data;
graphene_rect_t logical_monitor_rect =
meta_rectangle_to_graphene_rect (&logical_monitor->rect);
mtk_rectangle_to_graphene_rect (&logical_monitor->rect);
if (!graphene_rect_intersection (&cursor_rect,
&logical_monitor_rect,

View File

@ -118,7 +118,7 @@ is_cursor_in_stream (MetaScreenCastAreaStreamSrc *area_src)
MetaCursorSprite *cursor_sprite;
area = meta_screen_cast_area_stream_get_area (area_stream);
area_rect = meta_rectangle_to_graphene_rect (area);
area_rect = mtk_rectangle_to_graphene_rect (area);
cursor_sprite = meta_cursor_renderer_get_cursor (cursor_renderer);
if (cursor_sprite)

View File

@ -234,7 +234,7 @@ is_cursor_in_stream (MetaScreenCastMonitorStreamSrc *monitor_src)
logical_monitor = meta_monitor_get_logical_monitor (monitor);
logical_monitor_layout = meta_logical_monitor_get_layout (logical_monitor);
logical_monitor_rect =
meta_rectangle_to_graphene_rect (&logical_monitor_layout);
mtk_rectangle_to_graphene_rect (&logical_monitor_layout);
cursor_sprite = meta_cursor_renderer_get_cursor (cursor_renderer);
if (cursor_sprite)
@ -699,7 +699,7 @@ meta_screen_cast_monitor_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc
logical_monitor = meta_monitor_get_logical_monitor (monitor);
logical_monitor_layout = meta_logical_monitor_get_layout (logical_monitor);
logical_monitor_rect =
meta_rectangle_to_graphene_rect (&logical_monitor_layout);
mtk_rectangle_to_graphene_rect (&logical_monitor_layout);
if (meta_backend_is_stage_views_scaled (backend))
view_scale = meta_logical_monitor_get_scale (logical_monitor);

View File

@ -442,7 +442,7 @@ is_cursor_in_stream (MetaScreenCastVirtualStreamSrc *virtual_src)
MetaCursorSprite *cursor_sprite;
clutter_stage_view_get_layout (stage_view, &view_layout);
view_rect = meta_rectangle_to_graphene_rect (&view_layout);
view_rect = mtk_rectangle_to_graphene_rect (&view_layout);
cursor_sprite = meta_cursor_renderer_get_cursor (cursor_renderer);
if (cursor_sprite)
@ -496,7 +496,7 @@ meta_screen_cast_virtual_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc
stage_view = view_from_src (src);
clutter_stage_view_get_layout (stage_view, &view_layout);
view_rect = meta_rectangle_to_graphene_rect (&view_layout);
view_rect = mtk_rectangle_to_graphene_rect (&view_layout);
view_scale = clutter_stage_view_get_scale (stage_view);
meta_cursor_tracker_get_pointer (cursor_tracker, &cursor_position, NULL);

View File

@ -366,7 +366,7 @@ offset_scale_and_clamp_region (const cairo_region_t *region,
cairo_region_get_rectangle (region, i, rect);
_clutter_util_rect_from_rectangle (rect, &tmp);
tmp = mtk_rectangle_to_graphene_rect (rect);
graphene_rect_offset (&tmp, offset_x, offset_y);
graphene_rect_scale (&tmp, scale, scale, &tmp);
_clutter_util_rectangle_int_extents (&tmp, rect);
@ -402,7 +402,7 @@ scale_offset_and_clamp_region (const cairo_region_t *region,
cairo_region_get_rectangle (region, i, rect);
_clutter_util_rect_from_rectangle (rect, &tmp);
tmp = mtk_rectangle_to_graphene_rect (rect);
graphene_rect_scale (&tmp, scale, scale, &tmp);
graphene_rect_offset (&tmp, offset_x, offset_y);
_clutter_util_rectangle_int_extents (&tmp, rect);

View File

@ -1451,7 +1451,7 @@ meta_window_actor_blit_to_framebuffer (MetaScreenCastWindow *screen_cast_window,
0, 0,
unscaled_width, unscaled_height);
scaled_clip = meta_rectangle_to_graphene_rect (bounds);
scaled_clip = mtk_rectangle_to_graphene_rect (bounds);
graphene_rect_scale (&scaled_clip,
unscaled_width / width,
unscaled_height / height,

View File

@ -463,7 +463,7 @@ meta_region_apply_matrix_transform_expand (const cairo_region_t *region,
MtkRectangle int_rect;
cairo_region_get_rectangle (region, i, &int_rect);
rect = meta_rectangle_to_graphene_rect (&int_rect);
rect = mtk_rectangle_to_graphene_rect (&int_rect);
graphene_matrix_transform_bounds (transform, &rect, &transformed_rect);

View File

@ -254,21 +254,6 @@ void meta_rectangle_scale_double (const MtkRectangle *rect,
MetaRoundingStrategy rounding_strategy,
MtkRectangle *dest);
static inline graphene_rect_t
meta_rectangle_to_graphene_rect (MtkRectangle *rect)
{
return (graphene_rect_t) {
.origin = {
.x = rect->x,
.y = rect->y
},
.size = {
.width = rect->width,
.height = rect->height
}
};
}
META_EXPORT_TEST
void meta_rectangle_transform (const MtkRectangle *rect,
MetaMonitorTransform transform,

View File

@ -200,7 +200,7 @@ meta_wayland_cursor_surface_is_on_logical_monitor (MetaWaylandSurfaceRole *role,
return FALSE;
logical_monitor_rect =
meta_rectangle_to_graphene_rect (&logical_monitor->rect);
mtk_rectangle_to_graphene_rect (&logical_monitor->rect);
device = meta_cursor_renderer_get_input_device (priv->cursor_renderer);
clutter_seat_query_state (clutter_input_device_get_seat (device),