diff --git a/clutter/clutter/cogl/clutter-stage-cogl.c b/clutter/clutter/cogl/clutter-stage-cogl.c index f345313cf..d48e97641 100644 --- a/clutter/clutter/cogl/clutter-stage-cogl.c +++ b/clutter/clutter/cogl/clutter-stage-cogl.c @@ -628,6 +628,7 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window, float fb_scale; int subpixel_compensation = 0; int fb_width, fb_height; + int buffer_age; wrapper = CLUTTER_ACTOR (stage_cogl->wrapper); @@ -650,16 +651,26 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window, else is_full_redraw = FALSE; - may_use_clipped_redraw = FALSE; - if (_clutter_stage_window_can_clip_redraws (stage_window) && - (can_blit_sub_buffer || has_buffer_age) && - !is_full_redraw && - /* some drivers struggle to get going and produce some junk - * frames when starting up... */ - cogl_onscreen_get_frame_counter (COGL_ONSCREEN (fb)) > 3) - { - may_use_clipped_redraw = TRUE; + may_use_clipped_redraw = + _clutter_stage_window_can_clip_redraws (stage_window) && + (can_blit_sub_buffer || has_buffer_age) && + !is_full_redraw && + /* some drivers struggle to get going and produce some junk + * frames when starting up... */ + cogl_onscreen_get_frame_counter (COGL_ONSCREEN (fb)) > 3; + if (has_buffer_age) + { + buffer_age = cogl_onscreen_get_buffer_age (COGL_ONSCREEN (fb)); + if (!valid_buffer_age (view_cogl, buffer_age)) + { + CLUTTER_NOTE (CLIPPING, "Invalid back buffer(age=%d): forcing full redraw\n", buffer_age); + may_use_clipped_redraw = FALSE; + } + } + + if (may_use_clipped_redraw) + { fb_clip_region = offset_scale_and_clamp_region (redraw_clip, -view_rect.x, -view_rect.y, @@ -715,64 +726,43 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window, { if (use_clipped_redraw && !clip_region_empty) { - int age; + cairo_region_t *fb_damage; + cairo_region_t *view_damage; + int i; - age = cogl_onscreen_get_buffer_age (COGL_ONSCREEN (fb)); + fill_current_damage_history (view, fb_clip_region); - if (valid_buffer_age (view_cogl, age)) + fb_damage = cairo_region_create (); + + for (i = 1; i <= buffer_age; i++) { - cairo_region_t *fb_damage; - cairo_region_t *view_damage; - int i; + int damage_index; - fill_current_damage_history (view, fb_clip_region); - - fb_damage = cairo_region_create (); - - for (i = 1; i <= age; i++) - { - int damage_index; - - damage_index = DAMAGE_HISTORY (view_priv->damage_index - i - 1); - cairo_region_union (fb_damage, - view_priv->damage_history[damage_index]); - } - - /* Update the fb clip region with the extra damage. */ - cairo_region_union (fb_clip_region, fb_damage); - - view_damage = offset_scale_and_clamp_region (fb_damage, - 0, 0, - 1.0f / fb_scale); - cairo_region_translate (view_damage, view_rect.x, view_rect.y); - cairo_region_intersect_rectangle (view_damage, &view_rect); - - /* Update the redraw clip region with the extra damage. */ - cairo_region_union (redraw_clip, view_damage); - - cairo_region_destroy (view_damage); - cairo_region_destroy (fb_damage); - - CLUTTER_NOTE (CLIPPING, "Reusing back buffer(age=%d) - repairing region: num rects: %d\n", - age, - cairo_region_num_rectangles (fb_clip_region)); - - swap_with_damage = TRUE; + damage_index = DAMAGE_HISTORY (view_priv->damage_index - i - 1); + cairo_region_union (fb_damage, + view_priv->damage_history[damage_index]); } - else - { - cairo_rectangle_int_t fb_damage; - CLUTTER_NOTE (CLIPPING, "Invalid back buffer(age=%d): forcing full redraw\n", age); - use_clipped_redraw = FALSE; - fb_damage = (cairo_rectangle_int_t) { - .x = 0, - .y = 0, - .width = ceilf (view_rect.width * fb_scale), - .height = ceilf (view_rect.height * fb_scale) - }; - fill_current_damage_history_rectangle (view, &fb_damage); - } + /* Update the fb clip region with the extra damage. */ + cairo_region_union (fb_clip_region, fb_damage); + + view_damage = offset_scale_and_clamp_region (fb_damage, + 0, 0, + 1.0f / fb_scale); + cairo_region_translate (view_damage, view_rect.x, view_rect.y); + cairo_region_intersect_rectangle (view_damage, &view_rect); + + /* Update the redraw clip region with the extra damage. */ + cairo_region_union (redraw_clip, view_damage); + + cairo_region_destroy (view_damage); + cairo_region_destroy (fb_damage); + + CLUTTER_NOTE (CLIPPING, "Reusing back buffer(age=%d) - repairing region: num rects: %d\n", + buffer_age, + cairo_region_num_rectangles (fb_clip_region)); + + swap_with_damage = TRUE; } else if (!use_clipped_redraw) {