backend: Get 'is-stage-views-scaled' from backend

It did, but used the old backend singleton.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
This commit is contained in:
Jonas Ådahl 2022-05-27 20:30:37 +02:00 committed by Marge Bot
parent c390f70edc
commit 7e974ba6cc
20 changed files with 80 additions and 42 deletions

View File

@ -172,7 +172,7 @@ void meta_backend_set_client_pointer_constraint (MetaBackend *backend,
void meta_backend_monitors_changed (MetaBackend *backend);
gboolean meta_is_stage_views_scaled (void);
gboolean meta_backend_is_stage_views_scaled (MetaBackend *backend);
MetaInputMapper *meta_backend_get_input_mapper (MetaBackend *backend);
MetaInputSettings *meta_backend_get_input_settings (MetaBackend *backend);

View File

@ -1598,9 +1598,8 @@ meta_backend_get_capabilities (MetaBackend *backend)
}
gboolean
meta_is_stage_views_scaled (void)
meta_backend_is_stage_views_scaled (MetaBackend *backend)
{
MetaBackend *backend = meta_get_backend ();
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaLogicalMonitorLayoutMode layout_mode;

View File

@ -3881,6 +3881,7 @@ meta_monitor_manager_post_init (MetaMonitorManager *manager)
MetaViewportInfo *
meta_monitor_manager_get_viewports (MetaMonitorManager *manager)
{
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
MetaViewportInfo *info;
GArray *views, *scales;
GList *logical_monitors, *l;
@ -3906,7 +3907,7 @@ meta_monitor_manager_get_viewports (MetaMonitorManager *manager)
info = meta_viewport_info_new ((cairo_rectangle_int_t *) views->data,
(float *) scales->data,
views->len,
meta_is_stage_views_scaled ());
meta_backend_is_stage_views_scaled (backend));
g_array_unref (views);
g_array_unref (scales);

View File

@ -158,7 +158,7 @@ meta_renderer_real_rebuild_views (MetaRenderer *renderer)
float scale;
clutter_backend = meta_backend_get_clutter_backend (backend);
scale = meta_is_stage_views_scaled ()
scale = meta_backend_is_stage_views_scaled (backend)
? meta_logical_monitor_get_scale (logical_monitor)
: 1.f;

View File

@ -62,6 +62,18 @@ G_DEFINE_TYPE_WITH_CODE (MetaScreenCastMonitorStreamSrc,
G_IMPLEMENT_INTERFACE (META_TYPE_HW_CURSOR_INHIBITOR,
hw_cursor_inhibitor_iface_init))
static MetaBackend *
get_backend (MetaScreenCastMonitorStreamSrc *monitor_src)
{
MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (monitor_src);
MetaScreenCastStream *stream = meta_screen_cast_stream_src_get_stream (src);
MetaScreenCastSession *session = meta_screen_cast_stream_get_session (stream);
MetaScreenCast *screen_cast =
meta_screen_cast_session_get_screen_cast (session);
return meta_screen_cast_get_backend (screen_cast);
}
static ClutterStage *
get_stage (MetaScreenCastMonitorStreamSrc *monitor_src)
{
@ -98,6 +110,7 @@ meta_screen_cast_monitor_stream_src_get_specs (MetaScreenCastStreamSrc *src,
{
MetaScreenCastMonitorStreamSrc *monitor_src =
META_SCREEN_CAST_MONITOR_STREAM_SRC (src);
MetaBackend *backend = get_backend (monitor_src);
MetaMonitor *monitor;
MetaLogicalMonitor *logical_monitor;
float scale;
@ -107,7 +120,7 @@ meta_screen_cast_monitor_stream_src_get_specs (MetaScreenCastStreamSrc *src,
logical_monitor = meta_monitor_get_logical_monitor (monitor);
mode = meta_monitor_get_current_mode (monitor);
if (meta_is_stage_views_scaled ())
if (meta_backend_is_stage_views_scaled (backend))
scale = logical_monitor->scale;
else
scale = 1.0;
@ -175,18 +188,6 @@ before_stage_painted (MetaStage *stage,
meta_screen_cast_stream_src_maybe_record_frame (src, flags);
}
static MetaBackend *
get_backend (MetaScreenCastMonitorStreamSrc *monitor_src)
{
MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (monitor_src);
MetaScreenCastStream *stream = meta_screen_cast_stream_src_get_stream (src);
MetaScreenCastSession *session = meta_screen_cast_stream_get_session (stream);
MetaScreenCast *screen_cast =
meta_screen_cast_session_get_screen_cast (session);
return meta_screen_cast_get_backend (screen_cast);
}
static gboolean
is_cursor_in_stream (MetaScreenCastMonitorStreamSrc *monitor_src)
{
@ -508,6 +509,7 @@ meta_screen_cast_monitor_stream_src_record_to_buffer (MetaScreenCastStreamSrc *
MetaScreenCastMonitorStreamSrc *monitor_src =
META_SCREEN_CAST_MONITOR_STREAM_SRC (src);
MetaScreenCastStream *stream = meta_screen_cast_stream_src_get_stream (src);
MetaBackend *backend = get_backend (monitor_src);
ClutterStage *stage;
MetaMonitor *monitor;
MetaLogicalMonitor *logical_monitor;
@ -518,7 +520,7 @@ meta_screen_cast_monitor_stream_src_record_to_buffer (MetaScreenCastStreamSrc *
logical_monitor = meta_monitor_get_logical_monitor (monitor);
stage = get_stage (monitor_src);
if (meta_is_stage_views_scaled ())
if (meta_backend_is_stage_views_scaled (backend))
scale = meta_logical_monitor_get_scale (logical_monitor);
else
scale = 1.0;
@ -553,6 +555,7 @@ meta_screen_cast_monitor_stream_src_record_to_framebuffer (MetaScreenCastStreamS
MetaScreenCastMonitorStreamSrc *monitor_src =
META_SCREEN_CAST_MONITOR_STREAM_SRC (src);
MetaScreenCastStream *stream = meta_screen_cast_stream_src_get_stream (src);
MetaBackend *backend = get_backend (monitor_src);
ClutterStage *stage = get_stage (monitor_src);
MetaMonitor *monitor;
MetaLogicalMonitor *logical_monitor;
@ -564,7 +567,7 @@ meta_screen_cast_monitor_stream_src_record_to_framebuffer (MetaScreenCastStreamS
logical_monitor = meta_monitor_get_logical_monitor (monitor);
logical_monitor_layout = meta_logical_monitor_get_layout (logical_monitor);
if (meta_is_stage_views_scaled ())
if (meta_backend_is_stage_views_scaled (backend))
view_scale = meta_logical_monitor_get_scale (logical_monitor);
else
view_scale = 1.0;
@ -667,7 +670,7 @@ meta_screen_cast_monitor_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc
logical_monitor_rect =
meta_rectangle_to_graphene_rect (&logical_monitor_layout);
if (meta_is_stage_views_scaled ())
if (meta_backend_is_stage_views_scaled (backend))
view_scale = meta_logical_monitor_get_scale (logical_monitor);
else
view_scale = 1.0;

View File

@ -198,13 +198,14 @@ meta_screen_cast_monitor_stream_transform_position (MetaScreenCastStream *stream
{
MetaScreenCastMonitorStream *monitor_stream =
META_SCREEN_CAST_MONITOR_STREAM (stream);
MetaBackend *backend = meta_monitor_get_backend (monitor_stream->monitor);
MetaRectangle logical_monitor_layout;
double scale;
logical_monitor_layout =
meta_logical_monitor_get_layout (monitor_stream->logical_monitor);
if (meta_is_stage_views_scaled ())
if (meta_backend_is_stage_views_scaled (backend))
scale = meta_logical_monitor_get_scale (monitor_stream->logical_monitor);
else
scale = 1.0;

View File

@ -24,6 +24,7 @@
#include "backends/meta-logical-monitor.h"
#include "backends/meta-monitor-manager-private.h"
#include "backends/meta-screen-cast-session.h"
#include "backends/meta-screen-cast-window.h"
#include "backends/meta-screen-cast-window-stream-src.h"
#include "compositor/meta-window-actor-private.h"
@ -211,6 +212,11 @@ meta_screen_cast_window_stream_initable_init (GInitable *initable,
{
MetaScreenCastWindowStream *window_stream =
META_SCREEN_CAST_WINDOW_STREAM (initable);
MetaScreenCastStream *stream = META_SCREEN_CAST_STREAM (initable);
MetaScreenCastSession *session = meta_screen_cast_stream_get_session (stream);
MetaScreenCast *screen_cast =
meta_screen_cast_session_get_screen_cast (session);
MetaBackend *backend = meta_screen_cast_get_backend (screen_cast);
MetaWindow *window = window_stream->window;
MetaLogicalMonitor *logical_monitor;
int scale;
@ -228,7 +234,7 @@ meta_screen_cast_window_stream_initable_init (GInitable *initable,
G_CALLBACK (on_window_unmanaged),
window_stream);
if (meta_is_stage_views_scaled ())
if (meta_backend_is_stage_views_scaled (backend))
scale = (int) ceilf (meta_logical_monitor_get_scale (logical_monitor));
else
scale = 1;

View File

@ -98,7 +98,7 @@ update_ui_scaling_factor (MetaSettings *settings)
{
int ui_scaling_factor;
if (meta_is_stage_views_scaled ())
if (meta_backend_is_stage_views_scaled (settings->backend))
ui_scaling_factor = 1;
else
ui_scaling_factor = calculate_ui_scaling_factor (settings);

View File

@ -373,10 +373,11 @@ assign_cursor_plane (MetaCursorRendererNative *native,
}
static float
calculate_cursor_crtc_sprite_scale (MetaCursorSprite *cursor_sprite,
calculate_cursor_crtc_sprite_scale (MetaBackend *backend,
MetaCursorSprite *cursor_sprite,
MetaLogicalMonitor *logical_monitor)
{
if (meta_is_stage_views_scaled ())
if (meta_backend_is_stage_views_scaled (backend))
{
return (meta_logical_monitor_get_scale (logical_monitor) *
meta_cursor_sprite_get_texture_scale (cursor_sprite));
@ -393,6 +394,8 @@ set_crtc_cursor (MetaCursorRendererNative *cursor_renderer_native,
MetaCrtc *crtc,
MetaCursorSprite *cursor_sprite)
{
MetaCursorRendererNativePrivate *priv =
meta_cursor_renderer_native_get_instance_private (cursor_renderer_native);
MetaCursorRenderer *cursor_renderer =
META_CURSOR_RENDERER (cursor_renderer_native);
MetaOutput *output = meta_crtc_get_outputs (crtc)->data;
@ -438,7 +441,8 @@ set_crtc_cursor (MetaCursorRendererNative *cursor_renderer_native,
tex_height = cogl_texture_get_height (texture);
cursor_crtc_scale =
calculate_cursor_crtc_sprite_scale (cursor_sprite,
calculate_cursor_crtc_sprite_scale (priv->backend,
cursor_sprite,
logical_monitor);
cursor_rect = (MetaRectangle) {
@ -763,7 +767,9 @@ get_common_crtc_sprite_scale_for_logical_monitors (MetaCursorRenderer *renderer,
continue;
tmp_scale =
calculate_cursor_crtc_sprite_scale (cursor_sprite, logical_monitor);
calculate_cursor_crtc_sprite_scale (backend,
cursor_sprite,
logical_monitor);
if (has_visible_crtc_sprite && scale != tmp_scale)
return FALSE;

View File

@ -1372,7 +1372,7 @@ meta_renderer_native_create_view (MetaRenderer *renderer,
g_error ("Failed to allocate back buffer texture: %s", error->message);
}
if (meta_is_stage_views_scaled ())
if (meta_backend_is_stage_views_scaled (backend))
scale = meta_logical_monitor_get_scale (logical_monitor);
else
scale = 1.0;

View File

@ -196,7 +196,7 @@ meta_renderer_x11_nested_create_view (MetaRenderer *renderer,
view_transform = calculate_view_transform (monitor_manager, logical_monitor);
if (meta_is_stage_views_scaled ())
if (meta_backend_is_stage_views_scaled (backend))
view_scale = logical_monitor->scale;
else
view_scale = 1.0;

View File

@ -391,6 +391,8 @@ setup_pipeline (MetaBackgroundContent *self,
ClutterPaintContext *paint_context,
cairo_rectangle_int_t *actor_pixel_rect)
{
MetaContext *context = meta_display_get_context (self->display);
MetaBackend *backend = meta_context_get_backend (context);
PipelineFlags pipeline_flags = 0;
guint8 opacity;
float color_component;
@ -478,7 +480,7 @@ setup_pipeline (MetaBackgroundContent *self,
float bounds_x1, bounds_x2, bounds_y1, bounds_y2;
float clip_radius;
monitor_scale = meta_is_stage_views_scaled ()
monitor_scale = meta_backend_is_stage_views_scaled (backend)
? meta_display_get_monitor_scale (self->display, self->monitor)
: 1.0;
@ -566,12 +568,14 @@ static void
set_glsl_parameters (MetaBackgroundContent *self,
cairo_rectangle_int_t *actor_pixel_rect)
{
MetaContext *context = meta_display_get_context (self->display);
MetaBackend *backend = meta_context_get_backend (context);
float monitor_scale;
float scale[2];
float offset[2];
int pixel_step_uniform_location;
monitor_scale = meta_is_stage_views_scaled ()
monitor_scale = meta_backend_is_stage_views_scaled (backend)
? meta_display_get_monitor_scale (self->display, self->monitor)
: 1.0;

View File

@ -799,11 +799,13 @@ meta_background_get_texture (MetaBackground *self,
if (monitor->dirty)
{
MetaContext *context = meta_display_get_context (self->display);
MetaBackend *backend = meta_context_get_backend (context);
GError *catch_error = NULL;
gboolean bare_region_visible = FALSE;
int texture_width, texture_height;
if (meta_is_stage_views_scaled ())
if (meta_backend_is_stage_views_scaled (backend))
{
texture_width = monitor_area.width * monitor_scale;
texture_height = monitor_area.height * monitor_scale;

View File

@ -1741,7 +1741,7 @@ root_cursor_prepare_at (MetaCursorSpriteXcursor *sprite_xcursor,
MetaCursorSprite *cursor_sprite = META_CURSOR_SPRITE (sprite_xcursor);
MetaBackend *backend = meta_get_backend ();
if (meta_is_stage_views_scaled ())
if (meta_backend_is_stage_views_scaled (backend))
{
if (best_scale != 0.0f)
{

View File

@ -102,7 +102,7 @@ cursor_sprite_prepare_at (MetaCursorSprite *cursor_sprite,
{
float texture_scale;
if (meta_is_stage_views_scaled ())
if (meta_backend_is_stage_views_scaled (backend))
texture_scale = 1.0 / surface->scale;
else
texture_scale = (meta_logical_monitor_get_scale (logical_monitor) /

View File

@ -87,7 +87,13 @@ dnd_surface_find_logical_monitor (MetaWaylandActorSurface *actor_surface)
static int
dnd_subsurface_get_geometry_scale (MetaWaylandActorSurface *actor_surface)
{
if (meta_is_stage_views_scaled ())
MetaWaylandSurfaceRole *role = META_WAYLAND_SURFACE_ROLE (actor_surface);
MetaWaylandSurface *surface = meta_wayland_surface_role_get_surface (role);
MetaContext *context =
meta_wayland_compositor_get_context (surface->compositor);
MetaBackend *backend = meta_context_get_backend (context);
if (meta_backend_is_stage_views_scaled (backend))
{
return 1;
}

View File

@ -256,10 +256,14 @@ meta_wayland_shell_surface_get_geometry_scale (MetaWaylandActorSurface *actor_su
META_WAYLAND_SURFACE_ROLE (actor_surface);
MetaWaylandSurface *surface =
meta_wayland_surface_role_get_surface (surface_role);
MetaContext *context =
meta_wayland_compositor_get_context (surface->compositor);
MetaBackend *backend = meta_context_get_backend (context);
MetaWindow *toplevel_window;
toplevel_window = meta_wayland_surface_get_toplevel_window (surface);
if (meta_is_stage_views_scaled () || !toplevel_window)
if (meta_backend_is_stage_views_scaled (backend) ||
!toplevel_window)
return 1;
else
return meta_window_wayland_get_geometry_scale (toplevel_window);

View File

@ -2247,7 +2247,11 @@ meta_wayland_surface_can_scanout_untransformed (MetaWaylandSurface *surface,
}
else
{
if (meta_is_stage_views_scaled ())
MetaContext *context =
meta_wayland_compositor_get_context (surface->compositor);
MetaBackend *backend = meta_context_get_backend (context);
if (meta_backend_is_stage_views_scaled (backend))
{
float view_scale;

View File

@ -372,7 +372,7 @@ tool_cursor_prepare_at (MetaCursorSpriteXcursor *sprite_xcursor,
meta_cursor_sprite_xcursor_set_theme_scale (sprite_xcursor,
(int) ceiled_scale);
if (meta_is_stage_views_scaled ())
if (meta_backend_is_stage_views_scaled (backend))
meta_cursor_sprite_set_texture_scale (cursor_sprite,
1.0 / ceiled_scale);
else

View File

@ -101,9 +101,11 @@ set_geometry_scale_for_window (MetaWindowWayland *wl_window,
static int
get_window_geometry_scale_for_logical_monitor (MetaLogicalMonitor *logical_monitor)
{
g_assert (logical_monitor);
MetaMonitor *monitor =
meta_logical_monitor_get_monitors (logical_monitor)->data;
MetaBackend *backend = meta_monitor_get_backend (monitor);
if (meta_is_stage_views_scaled ())
if (meta_backend_is_stage_views_scaled (backend))
return 1;
else
return meta_logical_monitor_get_scale (logical_monitor);
@ -566,7 +568,7 @@ meta_window_wayland_update_main_monitor (MetaWindow *window,
return;
}
if (meta_is_stage_views_scaled ())
if (meta_backend_is_stage_views_scaled (backend))
{
window->monitor = to;
return;