Skip to content

Commit c6be033

Browse files
authored
Fix region clipping issues when using fractional scaling (#777)
* Fix region clipping issues * Update libmuffin0.symbols * clutter-stage-cogl: Fix uninitialized variable use_clipped_redraw * clutter/stage-cogl: Avoid copying fb_clip_region * Fix intents
1 parent 4668c4f commit c6be033

29 files changed

+1340
-539
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* Copyright (C) 2007,2008,2009,2010,2011 Intel Corporation.
3+
* Copyright (C) 2020 Red Hat Inc
4+
*
5+
* This library is free software; you can redistribute it and/or
6+
* modify it under the terms of the GNU Lesser General Public
7+
* License as published by the Free Software Foundation; either
8+
* version 2 of the License, or (at your option) any later version.
9+
*
10+
* This library is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public
16+
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
#include "clutter-build-config.h"
20+
21+
#include "clutter-damage-history.h"
22+
23+
#define DAMAGE_HISTORY_LENGTH 0x10
24+
25+
struct _ClutterDamageHistory
26+
{
27+
cairo_region_t *damages[DAMAGE_HISTORY_LENGTH];
28+
int index;
29+
};
30+
31+
ClutterDamageHistory *
32+
clutter_damage_history_new (void)
33+
{
34+
ClutterDamageHistory *history;
35+
36+
history = g_new0 (ClutterDamageHistory, 1);
37+
38+
return history;
39+
}
40+
41+
void
42+
clutter_damage_history_free (ClutterDamageHistory *history)
43+
{
44+
int i;
45+
46+
for (i = 0; i < G_N_ELEMENTS (history->damages); i++)
47+
g_clear_pointer (&history->damages[i], cairo_region_destroy);
48+
49+
g_free (history);
50+
}
51+
52+
gboolean
53+
clutter_damage_history_is_age_valid (ClutterDamageHistory *history,
54+
int age)
55+
{
56+
if (age >= DAMAGE_HISTORY_LENGTH ||
57+
age < 1)
58+
return FALSE;
59+
60+
if (!clutter_damage_history_lookup (history, age))
61+
return FALSE;
62+
63+
return TRUE;
64+
}
65+
66+
void
67+
clutter_damage_history_record (ClutterDamageHistory *history,
68+
const cairo_region_t *damage)
69+
{
70+
g_clear_pointer (&history->damages[history->index], cairo_region_destroy);
71+
history->damages[history->index] = cairo_region_copy (damage);
72+
}
73+
74+
static inline int
75+
step_damage_index (int current,
76+
int diff)
77+
{
78+
return (current + diff) & (DAMAGE_HISTORY_LENGTH - 1);
79+
}
80+
81+
void
82+
clutter_damage_history_step (ClutterDamageHistory *history)
83+
{
84+
history->index = step_damage_index (history->index, 1);
85+
}
86+
87+
const cairo_region_t *
88+
clutter_damage_history_lookup (ClutterDamageHistory *history,
89+
int age)
90+
{
91+
return history->damages[step_damage_index (history->index, -age)];
92+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (C) 2007,2008,2009,2010,2011 Intel Corporation.
3+
* Copyright (C) 2020 Red Hat Inc
4+
*
5+
* This library is free software; you can redistribute it and/or
6+
* modify it under the terms of the GNU Lesser General Public
7+
* License as published by the Free Software Foundation; either
8+
* version 2 of the License, or (at your option) any later version.
9+
*
10+
* This library is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public
16+
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
#ifndef CLUTTER_DAMAGE_HISTORY_H
20+
#define CLUTTER_DAMAGE_HISTORY_H
21+
22+
#include <cairo.h>
23+
#include <glib.h>
24+
25+
typedef struct _ClutterDamageHistory ClutterDamageHistory;
26+
27+
ClutterDamageHistory * clutter_damage_history_new (void);
28+
29+
void clutter_damage_history_free (ClutterDamageHistory *history);
30+
31+
gboolean clutter_damage_history_is_age_valid (ClutterDamageHistory *history,
32+
int age);
33+
34+
void clutter_damage_history_record (ClutterDamageHistory *history,
35+
const cairo_region_t *damage);
36+
37+
void clutter_damage_history_step (ClutterDamageHistory *history);
38+
39+
const cairo_region_t * clutter_damage_history_lookup (ClutterDamageHistory *history,
40+
int age);
41+
42+
#endif /* CLUTTER_DAMAGE_HISTORY_H */

clutter/clutter/clutter-stage-view-private.h

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,28 @@
2020

2121
#include "clutter/clutter-stage-view.h"
2222

23-
void clutter_stage_view_after_paint (ClutterStageView *view);
23+
void clutter_stage_view_after_paint (ClutterStageView *view,
24+
cairo_region_t *redraw_clip);
25+
26+
void clutter_stage_view_before_swap_buffer (ClutterStageView *view,
27+
const cairo_region_t *swap_region);
2428

2529
gboolean clutter_stage_view_is_dirty_viewport (ClutterStageView *view);
2630

27-
void clutter_stage_view_set_dirty_viewport (ClutterStageView *view,
28-
gboolean dirty);
31+
void clutter_stage_view_invalidate_viewport (ClutterStageView *view);
32+
33+
void clutter_stage_view_set_viewport (ClutterStageView *view,
34+
float x,
35+
float y,
36+
float width,
37+
float height);
2938

3039
gboolean clutter_stage_view_is_dirty_projection (ClutterStageView *view);
3140

32-
void clutter_stage_view_set_dirty_projection (ClutterStageView *view,
33-
gboolean dirty);
41+
void clutter_stage_view_invalidate_projection (ClutterStageView *view);
42+
43+
void clutter_stage_view_set_projection (ClutterStageView *view,
44+
const CoglMatrix *matrix);
3445

3546
void clutter_stage_view_add_redraw_clip (ClutterStageView *view,
3647
const cairo_rectangle_int_t *clip);
@@ -43,4 +54,11 @@ const cairo_region_t * clutter_stage_view_peek_redraw_clip (ClutterStageView *vi
4354

4455
cairo_region_t * clutter_stage_view_take_redraw_clip (ClutterStageView *view);
4556

57+
58+
void clutter_stage_view_transform_rect_to_onscreen (ClutterStageView *view,
59+
const cairo_rectangle_int_t *src_rect,
60+
int dst_width,
61+
int dst_height,
62+
cairo_rectangle_int_t *dst_rect);
63+
4664
#endif /* __CLUTTER_STAGE_VIEW_PRIVATE_H__ */

0 commit comments

Comments
 (0)