From a93471eb905f49e9bdcee32ef3c0929e517fc104 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Tue, 8 Aug 2023 12:27:58 +0200 Subject: [PATCH] mtk: Move Rectangle.to_graphene_rect from Meta Also drops the clutter equivalent Part-of: --- clutter/clutter/clutter-private.h | 3 --- clutter/clutter/clutter-stage.c | 4 ++-- clutter/clutter/clutter-util.c | 16 -------------- mtk/meson.build | 1 + mtk/mtk/meson.build | 1 + mtk/mtk/mtk-rectangle.c | 21 +++++++++++++++++++ mtk/mtk/mtk-rectangle.h | 4 ++++ src/backends/meta-cursor-renderer.c | 4 ++-- .../meta-screen-cast-area-stream-src.c | 2 +- .../meta-screen-cast-monitor-stream-src.c | 4 ++-- .../meta-screen-cast-virtual-stream-src.c | 4 ++-- src/backends/meta-stage-impl.c | 4 ++-- src/compositor/meta-window-actor.c | 2 +- src/compositor/region-utils.c | 2 +- src/core/boxes-private.h | 15 ------------- src/wayland/meta-wayland-cursor-surface.c | 2 +- 16 files changed, 41 insertions(+), 48 deletions(-) diff --git a/clutter/clutter/clutter-private.h b/clutter/clutter/clutter-private.h index 5bc811427..af5b1dd79 100644 --- a/clutter/clutter/clutter-private.h +++ b/clutter/clutter/clutter-private.h @@ -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, diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c index eaae5b496..ce5b16ff9 100644 --- a/clutter/clutter/clutter-stage.c +++ b/clutter/clutter/clutter-stage.c @@ -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); diff --git a/clutter/clutter/clutter-util.c b/clutter/clutter/clutter-util.c index 81d06b922..2bcfb7d9b 100644 --- a/clutter/clutter/clutter-util.c +++ b/clutter/clutter/clutter-util.c @@ -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) diff --git a/mtk/meson.build b/mtk/meson.build index 2a978a2ba..f7862f378 100644 --- a/mtk/meson.build +++ b/mtk/meson.build @@ -29,6 +29,7 @@ mtk_pkg_deps = [ glib_dep, gobject_dep, gio_dep, + graphene_dep, ] mtk_deps = [ diff --git a/mtk/mtk/meson.build b/mtk/mtk/meson.build index d7ae49d28..648e6d99b 100644 --- a/mtk/mtk/meson.build +++ b/mtk/mtk/meson.build @@ -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, diff --git a/mtk/mtk/mtk-rectangle.c b/mtk/mtk/mtk-rectangle.c index 4b93d38e5..f8a51e245 100644 --- a/mtk/mtk/mtk-rectangle.c +++ b/mtk/mtk/mtk-rectangle.c @@ -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 + } + }; +} diff --git a/mtk/mtk/mtk-rectangle.h b/mtk/mtk/mtk-rectangle.h index b2a88d349..d6b248d92 100644 --- a/mtk/mtk/mtk-rectangle.h +++ b/mtk/mtk/mtk-rectangle.h @@ -23,6 +23,7 @@ #include #include +#include #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); + diff --git a/src/backends/meta-cursor-renderer.c b/src/backends/meta-cursor-renderer.c index 1a06f3865..cd8e4d8f0 100644 --- a/src/backends/meta-cursor-renderer.c +++ b/src/backends/meta-cursor-renderer.c @@ -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, diff --git a/src/backends/meta-screen-cast-area-stream-src.c b/src/backends/meta-screen-cast-area-stream-src.c index 44a364cbb..5dd01c9ca 100644 --- a/src/backends/meta-screen-cast-area-stream-src.c +++ b/src/backends/meta-screen-cast-area-stream-src.c @@ -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) diff --git a/src/backends/meta-screen-cast-monitor-stream-src.c b/src/backends/meta-screen-cast-monitor-stream-src.c index 603b364ad..41f3a806c 100644 --- a/src/backends/meta-screen-cast-monitor-stream-src.c +++ b/src/backends/meta-screen-cast-monitor-stream-src.c @@ -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); diff --git a/src/backends/meta-screen-cast-virtual-stream-src.c b/src/backends/meta-screen-cast-virtual-stream-src.c index c1c80bcf9..1890ee71b 100644 --- a/src/backends/meta-screen-cast-virtual-stream-src.c +++ b/src/backends/meta-screen-cast-virtual-stream-src.c @@ -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); diff --git a/src/backends/meta-stage-impl.c b/src/backends/meta-stage-impl.c index 48d62c1bb..da0366f89 100644 --- a/src/backends/meta-stage-impl.c +++ b/src/backends/meta-stage-impl.c @@ -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); diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c index c7948e0b2..e51fe041d 100644 --- a/src/compositor/meta-window-actor.c +++ b/src/compositor/meta-window-actor.c @@ -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, diff --git a/src/compositor/region-utils.c b/src/compositor/region-utils.c index 2798276fd..29686e026 100644 --- a/src/compositor/region-utils.c +++ b/src/compositor/region-utils.c @@ -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); diff --git a/src/core/boxes-private.h b/src/core/boxes-private.h index da5a18e4e..cdcd4e530 100644 --- a/src/core/boxes-private.h +++ b/src/core/boxes-private.h @@ -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, diff --git a/src/wayland/meta-wayland-cursor-surface.c b/src/wayland/meta-wayland-cursor-surface.c index 02f28ddc3..cd54de2bc 100644 --- a/src/wayland/meta-wayland-cursor-surface.c +++ b/src/wayland/meta-wayland-cursor-surface.c @@ -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),