clutter/stage: Add private API to get max view scale for rect

Move the same code from ClutterActor as this is something we can
reuse elsewhere.

https://bugzilla.gnome.org/show_bug.cgi?id=765011
https://gitlab.gnome.org/GNOME/mutter/merge_requests/3
This commit is contained in:
Marco Trevisan (Treviño) 2017-12-23 04:17:03 +01:00 committed by Marco Trevisan
parent 97a3b88f25
commit c695471475
3 changed files with 35 additions and 17 deletions

View File

@ -17785,29 +17785,15 @@ _clutter_actor_get_resource_scale_for_rect (ClutterActor *self,
float *resource_scale)
{
ClutterActor *stage;
GList *views;
GList *l;
float max_scale = 0;
stage = _clutter_actor_get_stage_internal (self);
if (!stage)
return FALSE;
views = _clutter_stage_peek_stage_views (CLUTTER_STAGE (stage));
for (l = views; l; l = l->next)
{
ClutterStageView *view = l->data;
cairo_rectangle_int_t view_layout;
ClutterRect view_rect;
clutter_stage_view_get_layout (view, &view_layout);
_clutter_util_rect_from_rectangle (&view_layout, &view_rect);
if (clutter_rect_intersection (&view_rect, bounding_rect, NULL))
max_scale = MAX (clutter_stage_view_get_scale (view), max_scale);
}
if (max_scale == 0)
if (!_clutter_stage_get_max_view_scale_factor_for_rect (CLUTTER_STAGE (stage),
bounding_rect,
&max_scale))
return FALSE;
*resource_scale = max_scale;

View File

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

View File

@ -5018,3 +5018,32 @@ clutter_stage_update_resource_scales (ClutterStage *stage)
{
_clutter_actor_queue_update_resource_scale_recursive (CLUTTER_ACTOR (stage));
}
gboolean
_clutter_stage_get_max_view_scale_factor_for_rect (ClutterStage *stage,
ClutterRect *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;
ClutterRect view_rect;
clutter_stage_view_get_layout (view, &view_layout);
_clutter_util_rect_from_rectangle (&view_layout, &view_rect);
if (clutter_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;
}