clutter/stage: Remove _clutter_stage_get_max_view_scale_factor_for_rect

Since we now have _clutter_stage_get_views_for_rect(), we can easily
replace _clutter_stage_get_max_view_scale_factor_for_rect() with it and
remove that private method.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1196
This commit is contained in:
Jonas Dreßler 2020-04-10 00:53:33 +02:00 committed by Carlos Garnacho
parent e27d2702a8
commit 670f4f22fe
3 changed files with 26 additions and 39 deletions

View File

@ -17421,17 +17421,27 @@ _clutter_actor_get_resource_scale_for_rect (ClutterActor *self,
float *resource_scale) float *resource_scale)
{ {
ClutterActor *stage; ClutterActor *stage;
g_autoptr (GList) views = NULL;
GList *l;
float max_scale = 0; float max_scale = 0;
stage = _clutter_actor_get_stage_internal (self); stage = _clutter_actor_get_stage_internal (self);
if (!stage) if (!stage)
return FALSE; return FALSE;
if (!_clutter_stage_get_max_view_scale_factor_for_rect (CLUTTER_STAGE (stage), views = clutter_stage_get_views_for_rect (CLUTTER_STAGE (stage),
bounding_rect, bounding_rect);
&max_scale))
if (!views)
return FALSE; return FALSE;
for (l = views; l; l = l->next)
{
ClutterStageView *view = l->data;
max_scale = MAX (clutter_stage_view_get_scale (view), max_scale);
}
*resource_scale = max_scale; *resource_scale = max_scale;
return TRUE; return TRUE;

View File

@ -125,9 +125,6 @@ gboolean _clutter_stage_update_state (ClutterStage *stag
void _clutter_stage_set_scale_factor (ClutterStage *stage, void _clutter_stage_set_scale_factor (ClutterStage *stage,
int factor); int factor);
gboolean _clutter_stage_get_max_view_scale_factor_for_rect (ClutterStage *stage,
graphene_rect_t *rect,
float *view_scale);
void _clutter_stage_presented (ClutterStage *stage, void _clutter_stage_presented (ClutterStage *stage,
CoglFrameEvent frame_event, CoglFrameEvent frame_event,

View File

@ -4077,20 +4077,29 @@ clutter_stage_get_capture_final_size (ClutterStage *stage,
int *out_height, int *out_height,
float *out_scale) float *out_scale)
{ {
float max_scale; float max_scale = 1.0;
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE); g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE);
if (rect) if (rect)
{ {
graphene_rect_t capture_rect; graphene_rect_t capture_rect;
g_autoptr (GList) views = NULL;
GList *l;
_clutter_util_rect_from_rectangle (rect, &capture_rect); _clutter_util_rect_from_rectangle (rect, &capture_rect);
if (!_clutter_stage_get_max_view_scale_factor_for_rect (stage, views = clutter_stage_get_views_for_rect (stage, &capture_rect);
&capture_rect,
&max_scale)) if (!views)
return FALSE; return FALSE;
for (l = views; l; l = l->next)
{
ClutterStageView *view = l->data;
max_scale = MAX (clutter_stage_view_get_scale (view), max_scale);
}
if (out_width) if (out_width)
*out_width = (gint) roundf (rect->width * max_scale); *out_width = (gint) roundf (rect->width * max_scale);
@ -4376,35 +4385,6 @@ clutter_stage_update_resource_scales (ClutterStage *stage)
_clutter_actor_queue_update_resource_scale_recursive (CLUTTER_ACTOR (stage)); _clutter_actor_queue_update_resource_scale_recursive (CLUTTER_ACTOR (stage));
} }
gboolean
_clutter_stage_get_max_view_scale_factor_for_rect (ClutterStage *stage,
graphene_rect_t *rect,
float *view_scale)
{
ClutterStagePrivate *priv = stage->priv;
float scale = 0.0f;
GList *l;
for (l = _clutter_stage_window_get_views (priv->impl); l; l = l->next)
{
ClutterStageView *view = l->data;
cairo_rectangle_int_t view_layout;
graphene_rect_t view_rect;
clutter_stage_view_get_layout (view, &view_layout);
_clutter_util_rect_from_rectangle (&view_layout, &view_rect);
if (graphene_rect_intersection (&view_rect, rect, NULL))
scale = MAX (clutter_stage_view_get_scale (view), scale);
}
if (scale == 0.0)
return FALSE;
*view_scale = scale;
return TRUE;
}
GList * GList *
clutter_stage_get_views_for_rect (ClutterStage *stage, clutter_stage_get_views_for_rect (ClutterStage *stage,
const graphene_rect_t *rect) const graphene_rect_t *rect)