diff --git a/src/compositor/meta-surface-actor.c b/src/compositor/meta-surface-actor.c index 105258954..5b328dcd3 100644 --- a/src/compositor/meta-surface-actor.c +++ b/src/compositor/meta-surface-actor.c @@ -57,6 +57,12 @@ enum static guint signals[LAST_SIGNAL]; +typedef enum +{ + IN_STAGE_PERSPECTIVE, + IN_ACTOR_PERSPECTIVE +} ScalePerspectiveType; + static cairo_region_t * effective_unobscured_region (MetaSurfaceActor *surface_actor) { @@ -78,18 +84,39 @@ effective_unobscured_region (MetaSurfaceActor *surface_actor) } static cairo_region_t* -get_scaled_region (MetaSurfaceActor *surface_actor, - cairo_region_t *region) +get_scaled_region (MetaSurfaceActor *surface_actor, + cairo_region_t *region, + ScalePerspectiveType scale_perspective) { MetaWindowActor *window_actor; + cairo_region_t *scaled_region; int geometry_scale; + float x, y; window_actor = meta_window_actor_from_actor (CLUTTER_ACTOR (surface_actor)); geometry_scale = meta_window_actor_get_geometry_scale (window_actor); - return meta_region_scale_double (region, - 1.0 / geometry_scale, - META_ROUNDING_STRATEGY_GROW); + clutter_actor_get_position (CLUTTER_ACTOR (surface_actor), &x, &y); + cairo_region_translate (region, x, y); + + switch (scale_perspective) + { + case IN_STAGE_PERSPECTIVE: + scaled_region = meta_region_scale_double (region, + geometry_scale, + META_ROUNDING_STRATEGY_GROW); + break; + case IN_ACTOR_PERSPECTIVE: + scaled_region = meta_region_scale_double (region, + 1.0 / geometry_scale, + META_ROUNDING_STRATEGY_GROW); + break; + } + + cairo_region_translate (region, -x, -y); + cairo_region_translate (scaled_region, -x, -y); + + return scaled_region; } static void @@ -119,8 +146,9 @@ set_unobscured_region (MetaSurfaceActor *surface_actor, .height = height, }; - priv->unobscured_region = - get_scaled_region (surface_actor, unobscured_region); + priv->unobscured_region = get_scaled_region (surface_actor, + unobscured_region, + IN_ACTOR_PERSPECTIVE); cairo_region_intersect_rectangle (priv->unobscured_region, &bounds); } @@ -139,7 +167,9 @@ set_clip_region (MetaSurfaceActor *surface_actor, { cairo_region_t *region; - region = get_scaled_region (surface_actor, clip_region); + region = get_scaled_region (surface_actor, + clip_region, + IN_ACTOR_PERSPECTIVE); meta_shaped_texture_set_clip_region (stex, region); cairo_region_destroy (region); @@ -267,11 +297,8 @@ meta_surface_actor_cull_out (MetaCullable *cullable, if (opacity == 0xff) { - MetaWindowActor *window_actor; - cairo_region_t *scaled_opaque_region; cairo_region_t *opaque_region; - int geometry_scale; - float x, y; + cairo_region_t *scaled_opaque_region; opaque_region = meta_shaped_texture_get_opaque_region (priv->texture); if (opaque_region) @@ -294,14 +321,9 @@ meta_surface_actor_cull_out (MetaCullable *cullable, return; } - window_actor = meta_window_actor_from_actor (CLUTTER_ACTOR (surface_actor)); - geometry_scale = meta_window_actor_get_geometry_scale (window_actor); - clutter_actor_get_position (CLUTTER_ACTOR (surface_actor), &x, &y); - - cairo_region_translate (opaque_region, x, y); - scaled_opaque_region = meta_region_scale (opaque_region, geometry_scale); - cairo_region_translate (scaled_opaque_region, -x, -y); - cairo_region_translate (opaque_region, -x, -y); + scaled_opaque_region = get_scaled_region (surface_actor, + opaque_region, + IN_STAGE_PERSPECTIVE); if (unobscured_region) cairo_region_subtract (unobscured_region, scaled_opaque_region);