Merge lp:~cimi/overlay-scrollbar/performance-tweaks into lp:overlay-scrollbar
- performance-tweaks
- Merge into trunk
Proposed by
Andrea Cimitan
Status: | Merged |
---|---|
Merged at revision: | 159 |
Proposed branch: | lp:~cimi/overlay-scrollbar/performance-tweaks |
Merge into: | lp:overlay-scrollbar |
Diff against target: |
263 lines (+37/-83) 3 files modified
os/os-pager.c (+22/-33) os/os-scrollbar.c (+14/-49) os/os-thumb.c (+1/-1) |
To merge this branch: | bzr merge lp:~cimi/overlay-scrollbar/performance-tweaks |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Javier Jardón | Approve | ||
Review via email: mp+53639@code.launchpad.net |
Commit message
Description of the change
First branch containing fixes for performance
To post a comment you must log in.
Revision history for this message
Javier Jardón (jjardon) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'os/os-pager.c' | |||
2 | --- os/os-pager.c 2011-03-15 18:03:47 +0000 | |||
3 | +++ os/os-pager.c 2011-03-16 15:43:24 +0000 | |||
4 | @@ -40,15 +40,27 @@ | |||
5 | 40 | gint height; | 40 | gint height; |
6 | 41 | }; | 41 | }; |
7 | 42 | 42 | ||
8 | 43 | static gboolean rectangle_changed (GdkRectangle rectangle1, GdkRectangle rectangle2); | ||
9 | 43 | static void os_pager_dispose (GObject *object); | 44 | static void os_pager_dispose (GObject *object); |
10 | 44 | static void os_pager_finalize (GObject *object); | 45 | static void os_pager_finalize (GObject *object); |
11 | 45 | static void os_pager_create (OsPager *pager); | 46 | static void os_pager_create (OsPager *pager); |
12 | 46 | static void os_pager_draw (OsPager *pager); | 47 | static void os_pager_draw (OsPager *pager); |
13 | 47 | static void os_pager_draw_bitmap (GdkPixmap *pixmap); | ||
14 | 48 | static void os_pager_mask (OsPager *pager); | 48 | static void os_pager_mask (OsPager *pager); |
15 | 49 | 49 | ||
16 | 50 | /* Private functions */ | 50 | /* Private functions */ |
17 | 51 | 51 | ||
18 | 52 | static gboolean | ||
19 | 53 | rectangle_changed (GdkRectangle rectangle1, | ||
20 | 54 | GdkRectangle rectangle2) | ||
21 | 55 | { | ||
22 | 56 | if (rectangle1.x != rectangle2.x) return TRUE; | ||
23 | 57 | if (rectangle1.y != rectangle2.y) return TRUE; | ||
24 | 58 | if (rectangle1.width != rectangle2.width) return TRUE; | ||
25 | 59 | if (rectangle1.height != rectangle2.height) return TRUE; | ||
26 | 60 | |||
27 | 61 | return FALSE; | ||
28 | 62 | } | ||
29 | 63 | |||
30 | 52 | /* Create a pager. */ | 64 | /* Create a pager. */ |
31 | 53 | static void | 65 | static void |
32 | 54 | os_pager_create (OsPager *pager) | 66 | os_pager_create (OsPager *pager) |
33 | @@ -106,44 +118,15 @@ | |||
34 | 106 | static void | 118 | static void |
35 | 107 | os_pager_mask (OsPager *pager) | 119 | os_pager_mask (OsPager *pager) |
36 | 108 | { | 120 | { |
37 | 109 | GdkBitmap *bitmap; | ||
38 | 110 | OsPagerPrivate *priv; | 121 | OsPagerPrivate *priv; |
39 | 111 | 122 | ||
40 | 112 | priv = pager->priv; | 123 | priv = pager->priv; |
41 | 113 | 124 | ||
48 | 114 | bitmap = gdk_pixmap_new (NULL, MAX (1, priv->mask.width), | 125 | gdk_window_shape_combine_region (priv->pager_window, |
49 | 115 | MAX (1, priv->mask.height), 1); | 126 | gdk_region_rectangle (&priv->mask), |
50 | 116 | os_pager_draw_bitmap (bitmap); | 127 | 0, 0); |
45 | 117 | |||
46 | 118 | gdk_window_shape_combine_mask (priv->pager_window, bitmap, | ||
47 | 119 | priv->mask.x, priv->mask.y); | ||
51 | 120 | 128 | ||
52 | 121 | gdk_window_clear (priv->pager_window); | 129 | gdk_window_clear (priv->pager_window); |
53 | 122 | |||
54 | 123 | g_object_unref (bitmap); | ||
55 | 124 | } | ||
56 | 125 | |||
57 | 126 | /* Draw on the bitmap of the pager, to get a mask. */ | ||
58 | 127 | static void | ||
59 | 128 | os_pager_draw_bitmap (GdkBitmap *bitmap) | ||
60 | 129 | { | ||
61 | 130 | cairo_t *cr_surface; | ||
62 | 131 | cairo_surface_t *surface; | ||
63 | 132 | gint width, height; | ||
64 | 133 | |||
65 | 134 | gdk_pixmap_get_size (bitmap, &width, &height); | ||
66 | 135 | |||
67 | 136 | surface = cairo_xlib_surface_create_for_bitmap | ||
68 | 137 | (GDK_DRAWABLE_XDISPLAY (bitmap), gdk_x11_drawable_get_xid (bitmap), | ||
69 | 138 | GDK_SCREEN_XSCREEN (gdk_drawable_get_screen (bitmap)), width, height); | ||
70 | 139 | |||
71 | 140 | cr_surface = cairo_create (surface); | ||
72 | 141 | |||
73 | 142 | cairo_paint (cr_surface); | ||
74 | 143 | |||
75 | 144 | cairo_destroy (cr_surface); | ||
76 | 145 | |||
77 | 146 | cairo_surface_destroy (surface); | ||
78 | 147 | } | 130 | } |
79 | 148 | 131 | ||
80 | 149 | /* Type definition. */ | 132 | /* Type definition. */ |
81 | @@ -257,6 +240,9 @@ | |||
82 | 257 | 240 | ||
83 | 258 | priv = pager->priv; | 241 | priv = pager->priv; |
84 | 259 | 242 | ||
85 | 243 | if (!rectangle_changed (priv->mask, mask)) | ||
86 | 244 | return; | ||
87 | 245 | |||
88 | 260 | priv->mask = mask; | 246 | priv->mask = mask; |
89 | 261 | 247 | ||
90 | 262 | if (priv->parent == NULL) | 248 | if (priv->parent == NULL) |
91 | @@ -376,6 +362,9 @@ | |||
92 | 376 | 362 | ||
93 | 377 | priv = pager->priv; | 363 | priv = pager->priv; |
94 | 378 | 364 | ||
95 | 365 | if (!rectangle_changed (priv->allocation, rectangle)) | ||
96 | 366 | return; | ||
97 | 367 | |||
98 | 379 | priv->allocation = rectangle; | 368 | priv->allocation = rectangle; |
99 | 380 | 369 | ||
100 | 381 | if (priv->parent == NULL) | 370 | if (priv->parent == NULL) |
101 | 382 | 371 | ||
102 | === modified file 'os/os-scrollbar.c' | |||
103 | --- os/os-scrollbar.c 2011-03-15 15:43:22 +0000 | |||
104 | +++ os/os-scrollbar.c 2011-03-16 15:43:24 +0000 | |||
105 | @@ -101,7 +101,6 @@ | |||
106 | 101 | static gboolean thumb_leave_notify_event_cb (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data); | 101 | static gboolean thumb_leave_notify_event_cb (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data); |
107 | 102 | static gboolean thumb_motion_notify_event_cb (GtkWidget *widget, GdkEventMotion *event, gpointer user_data); | 102 | static gboolean thumb_motion_notify_event_cb (GtkWidget *widget, GdkEventMotion *event, gpointer user_data); |
108 | 103 | static void pager_move (OsScrollbar *scrollbar); | 103 | static void pager_move (OsScrollbar *scrollbar); |
109 | 104 | static void pager_set_allocation (OsScrollbar *scrollbar); | ||
110 | 105 | static void pager_set_state (OsScrollbar *scrollbar); | 104 | static void pager_set_state (OsScrollbar *scrollbar); |
111 | 106 | static void adjustment_changed_cb (GtkAdjustment *adjustment, gpointer user_data); | 105 | static void adjustment_changed_cb (GtkAdjustment *adjustment, gpointer user_data); |
112 | 107 | static void adjustment_value_changed_cb (GtkAdjustment *adjustment, gpointer user_data); | 106 | static void adjustment_value_changed_cb (GtkAdjustment *adjustment, gpointer user_data); |
113 | @@ -656,8 +655,6 @@ | |||
114 | 656 | 655 | ||
115 | 657 | priv->pointer_x = event->x; | 656 | priv->pointer_x = event->x; |
116 | 658 | priv->pointer_y = event->y; | 657 | priv->pointer_y = event->y; |
117 | 659 | |||
118 | 660 | gtk_widget_queue_draw (widget); | ||
119 | 661 | } | 658 | } |
120 | 662 | } | 659 | } |
121 | 663 | 660 | ||
122 | @@ -703,8 +700,6 @@ | |||
123 | 703 | 700 | ||
124 | 704 | priv->button_press_event = FALSE; | 701 | priv->button_press_event = FALSE; |
125 | 705 | priv->motion_notify_event = FALSE; | 702 | priv->motion_notify_event = FALSE; |
126 | 706 | |||
127 | 707 | gtk_widget_queue_draw (widget); | ||
128 | 708 | } | 703 | } |
129 | 709 | } | 704 | } |
130 | 710 | 705 | ||
131 | @@ -782,9 +777,6 @@ | |||
132 | 782 | priv->value_changed_event = FALSE; | 777 | priv->value_changed_event = FALSE; |
133 | 783 | } | 778 | } |
134 | 784 | 779 | ||
135 | 785 | if (!priv->motion_notify_event) | ||
136 | 786 | gtk_widget_queue_draw (widget); | ||
137 | 787 | |||
138 | 788 | priv->motion_notify_event = TRUE; | 780 | priv->motion_notify_event = TRUE; |
139 | 789 | 781 | ||
140 | 790 | os_scrollbar_move (scrollbar, event->x_root, event->y_root); | 782 | os_scrollbar_move (scrollbar, event->x_root, event->y_root); |
141 | @@ -875,40 +867,6 @@ | |||
142 | 875 | os_pager_move_resize (OS_PAGER (priv->pager), mask); | 867 | os_pager_move_resize (OS_PAGER (priv->pager), mask); |
143 | 876 | } | 868 | } |
144 | 877 | 869 | ||
145 | 878 | /* Resize the overlay window. */ | ||
146 | 879 | static void | ||
147 | 880 | pager_set_allocation (OsScrollbar *scrollbar) | ||
148 | 881 | { | ||
149 | 882 | GdkRectangle rect; | ||
150 | 883 | OsScrollbarPrivate *priv; | ||
151 | 884 | gint offset; | ||
152 | 885 | |||
153 | 886 | priv = scrollbar->priv; | ||
154 | 887 | |||
155 | 888 | if (GTK_IS_SCROLLED_WINDOW (priv->parent) && | ||
156 | 889 | gtk_scrolled_window_get_shadow_type (GTK_SCROLLED_WINDOW (priv->parent)) != GTK_SHADOW_NONE) | ||
157 | 890 | offset = 1; | ||
158 | 891 | else | ||
159 | 892 | offset = 0; | ||
160 | 893 | |||
161 | 894 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | ||
162 | 895 | { | ||
163 | 896 | rect.x = priv->overlay_all.x; | ||
164 | 897 | rect.y = priv->overlay_all.y + offset; | ||
165 | 898 | rect.width = DEFAULT_PAGER_WIDTH; | ||
166 | 899 | rect.height = priv->overlay_all.height - offset * 2; | ||
167 | 900 | } | ||
168 | 901 | else | ||
169 | 902 | { | ||
170 | 903 | rect.x = priv->overlay_all.x + offset; | ||
171 | 904 | rect.y = priv->overlay_all.y; | ||
172 | 905 | rect.width = priv->overlay_all.width - offset * 2; | ||
173 | 906 | rect.height = DEFAULT_PAGER_WIDTH; | ||
174 | 907 | } | ||
175 | 908 | |||
176 | 909 | os_pager_size_allocate (OS_PAGER (priv->pager), rect); | ||
177 | 910 | } | ||
178 | 911 | |||
179 | 912 | static void | 870 | static void |
180 | 913 | pager_set_state (OsScrollbar *scrollbar) | 871 | pager_set_state (OsScrollbar *scrollbar) |
181 | 914 | { | 872 | { |
182 | @@ -1005,6 +963,7 @@ | |||
183 | 1005 | GtkAllocation *allocation, | 963 | GtkAllocation *allocation, |
184 | 1006 | gpointer user_data) | 964 | gpointer user_data) |
185 | 1007 | { | 965 | { |
186 | 966 | GdkRectangle rect; | ||
187 | 1008 | OsScrollbar *scrollbar; | 967 | OsScrollbar *scrollbar; |
188 | 1009 | OsScrollbarPrivate *priv; | 968 | OsScrollbarPrivate *priv; |
189 | 1010 | gint offset; | 969 | gint offset; |
190 | @@ -1032,6 +991,11 @@ | |||
191 | 1032 | priv->slider.height = DEFAULT_SCROLLBAR_HEIGHT; | 991 | priv->slider.height = DEFAULT_SCROLLBAR_HEIGHT; |
192 | 1033 | priv->overlay_all.x = allocation->x + allocation->width - DEFAULT_PAGER_WIDTH - offset; | 992 | priv->overlay_all.x = allocation->x + allocation->width - DEFAULT_PAGER_WIDTH - offset; |
193 | 1034 | priv->thumb_all.x = allocation->x + allocation->width - offset; | 993 | priv->thumb_all.x = allocation->x + allocation->width - offset; |
194 | 994 | |||
195 | 995 | rect.x = priv->overlay_all.x; | ||
196 | 996 | rect.y = priv->overlay_all.y + offset; | ||
197 | 997 | rect.width = DEFAULT_PAGER_WIDTH; | ||
198 | 998 | rect.height = priv->overlay_all.height - offset * 2; | ||
199 | 1035 | } | 999 | } |
200 | 1036 | else | 1000 | else |
201 | 1037 | { | 1001 | { |
202 | @@ -1039,6 +1003,11 @@ | |||
203 | 1039 | priv->slider.height = DEFAULT_SCROLLBAR_WIDTH; | 1003 | priv->slider.height = DEFAULT_SCROLLBAR_WIDTH; |
204 | 1040 | priv->overlay_all.y = allocation->y + allocation->height - DEFAULT_PAGER_WIDTH - offset; | 1004 | priv->overlay_all.y = allocation->y + allocation->height - DEFAULT_PAGER_WIDTH - offset; |
205 | 1041 | priv->thumb_all.y = allocation->y + allocation->height - offset; | 1005 | priv->thumb_all.y = allocation->y + allocation->height - offset; |
206 | 1006 | |||
207 | 1007 | rect.x = priv->overlay_all.x + offset; | ||
208 | 1008 | rect.y = priv->overlay_all.y; | ||
209 | 1009 | rect.width = priv->overlay_all.width - offset * 2; | ||
210 | 1010 | rect.height = DEFAULT_PAGER_WIDTH; | ||
211 | 1042 | } | 1011 | } |
212 | 1043 | 1012 | ||
213 | 1044 | if (priv->adjustment != NULL) | 1013 | if (priv->adjustment != NULL) |
214 | @@ -1047,7 +1016,8 @@ | |||
215 | 1047 | os_scrollbar_calc_layout_slider (scrollbar, priv->adjustment->value); | 1016 | os_scrollbar_calc_layout_slider (scrollbar, priv->adjustment->value); |
216 | 1048 | } | 1017 | } |
217 | 1049 | 1018 | ||
219 | 1050 | pager_set_allocation (scrollbar); | 1019 | os_pager_size_allocate (OS_PAGER (priv->pager), rect); |
220 | 1020 | |||
221 | 1051 | pager_move (scrollbar); | 1021 | pager_move (scrollbar); |
222 | 1052 | 1022 | ||
223 | 1053 | if (gtk_widget_get_realized (widget)) | 1023 | if (gtk_widget_get_realized (widget)) |
224 | @@ -1094,15 +1064,13 @@ | |||
225 | 1094 | 1064 | ||
226 | 1095 | os_scrollbar_calc_layout_pager (scrollbar, priv->adjustment->value); | 1065 | os_scrollbar_calc_layout_pager (scrollbar, priv->adjustment->value); |
227 | 1096 | os_scrollbar_calc_layout_slider (scrollbar, priv->adjustment->value); | 1066 | os_scrollbar_calc_layout_slider (scrollbar, priv->adjustment->value); |
228 | 1067 | |||
229 | 1097 | os_scrollbar_move_thumb (scrollbar, | 1068 | os_scrollbar_move_thumb (scrollbar, |
230 | 1098 | event->x + priv->thumb_all.x + priv->slider.x, | 1069 | event->x + priv->thumb_all.x + priv->slider.x, |
231 | 1099 | event->y + priv->thumb_all.y + priv->slider.y); | 1070 | event->y + priv->thumb_all.y + priv->slider.y); |
232 | 1100 | 1071 | ||
233 | 1101 | os_scrollbar_store_window_position (scrollbar); | 1072 | os_scrollbar_store_window_position (scrollbar); |
234 | 1102 | 1073 | ||
235 | 1103 | pager_set_allocation (scrollbar); | ||
236 | 1104 | pager_move (scrollbar); | ||
237 | 1105 | |||
238 | 1106 | return FALSE; | 1074 | return FALSE; |
239 | 1107 | } | 1075 | } |
240 | 1108 | 1076 | ||
241 | @@ -1132,9 +1100,6 @@ | |||
242 | 1132 | /* get the motion_notify_event trough XEvent */ | 1100 | /* get the motion_notify_event trough XEvent */ |
243 | 1133 | if (xevent->type == MotionNotify) | 1101 | if (xevent->type == MotionNotify) |
244 | 1134 | { | 1102 | { |
245 | 1135 | os_scrollbar_calc_layout_pager (scrollbar, priv->adjustment->value); | ||
246 | 1136 | os_scrollbar_calc_layout_slider (scrollbar, priv->adjustment->value); | ||
247 | 1137 | |||
248 | 1138 | /* proximity area */ | 1103 | /* proximity area */ |
249 | 1139 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | 1104 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
250 | 1140 | { | 1105 | { |
251 | 1141 | 1106 | ||
252 | === modified file 'os/os-thumb.c' | |||
253 | --- os/os-thumb.c 2011-03-14 15:17:25 +0000 | |||
254 | +++ os/os-thumb.c 2011-03-16 15:43:24 +0000 | |||
255 | @@ -266,7 +266,7 @@ | |||
256 | 266 | gint radius; | 266 | gint radius; |
257 | 267 | 267 | ||
258 | 268 | thumb = OS_THUMB (widget); | 268 | thumb = OS_THUMB (widget); |
260 | 269 | priv = thumb->priv;; | 269 | priv = thumb->priv; |
261 | 270 | 270 | ||
262 | 271 | state_type_down = GTK_STATE_NORMAL; | 271 | state_type_down = GTK_STATE_NORMAL; |
263 | 272 | state_type_up = GTK_STATE_NORMAL; | 272 | state_type_up = GTK_STATE_NORMAL; |