Merge lp:~cimi/overlay-scrollbar/performance-tweaks into lp:overlay-scrollbar

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
Reviewer Review Type Date Requested Status
Javier Jardón Approve
Review via email: mp+53639@code.launchpad.net

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 gint height;
6 };
7
8+static gboolean rectangle_changed (GdkRectangle rectangle1, GdkRectangle rectangle2);
9 static void os_pager_dispose (GObject *object);
10 static void os_pager_finalize (GObject *object);
11 static void os_pager_create (OsPager *pager);
12 static void os_pager_draw (OsPager *pager);
13-static void os_pager_draw_bitmap (GdkPixmap *pixmap);
14 static void os_pager_mask (OsPager *pager);
15
16 /* Private functions */
17
18+static gboolean
19+rectangle_changed (GdkRectangle rectangle1,
20+ GdkRectangle rectangle2)
21+{
22+ if (rectangle1.x != rectangle2.x) return TRUE;
23+ if (rectangle1.y != rectangle2.y) return TRUE;
24+ if (rectangle1.width != rectangle2.width) return TRUE;
25+ if (rectangle1.height != rectangle2.height) return TRUE;
26+
27+ return FALSE;
28+}
29+
30 /* Create a pager. */
31 static void
32 os_pager_create (OsPager *pager)
33@@ -106,44 +118,15 @@
34 static void
35 os_pager_mask (OsPager *pager)
36 {
37- GdkBitmap *bitmap;
38 OsPagerPrivate *priv;
39
40 priv = pager->priv;
41
42- bitmap = gdk_pixmap_new (NULL, MAX (1, priv->mask.width),
43- MAX (1, priv->mask.height), 1);
44- os_pager_draw_bitmap (bitmap);
45-
46- gdk_window_shape_combine_mask (priv->pager_window, bitmap,
47- priv->mask.x, priv->mask.y);
48+ gdk_window_shape_combine_region (priv->pager_window,
49+ gdk_region_rectangle (&priv->mask),
50+ 0, 0);
51
52 gdk_window_clear (priv->pager_window);
53-
54- g_object_unref (bitmap);
55-}
56-
57-/* Draw on the bitmap of the pager, to get a mask. */
58-static void
59-os_pager_draw_bitmap (GdkBitmap *bitmap)
60-{
61- cairo_t *cr_surface;
62- cairo_surface_t *surface;
63- gint width, height;
64-
65- gdk_pixmap_get_size (bitmap, &width, &height);
66-
67- surface = cairo_xlib_surface_create_for_bitmap
68- (GDK_DRAWABLE_XDISPLAY (bitmap), gdk_x11_drawable_get_xid (bitmap),
69- GDK_SCREEN_XSCREEN (gdk_drawable_get_screen (bitmap)), width, height);
70-
71- cr_surface = cairo_create (surface);
72-
73- cairo_paint (cr_surface);
74-
75- cairo_destroy (cr_surface);
76-
77- cairo_surface_destroy (surface);
78 }
79
80 /* Type definition. */
81@@ -257,6 +240,9 @@
82
83 priv = pager->priv;
84
85+ if (!rectangle_changed (priv->mask, mask))
86+ return;
87+
88 priv->mask = mask;
89
90 if (priv->parent == NULL)
91@@ -376,6 +362,9 @@
92
93 priv = pager->priv;
94
95+ if (!rectangle_changed (priv->allocation, rectangle))
96+ return;
97+
98 priv->allocation = rectangle;
99
100 if (priv->parent == NULL)
101
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 static gboolean thumb_leave_notify_event_cb (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data);
107 static gboolean thumb_motion_notify_event_cb (GtkWidget *widget, GdkEventMotion *event, gpointer user_data);
108 static void pager_move (OsScrollbar *scrollbar);
109-static void pager_set_allocation (OsScrollbar *scrollbar);
110 static void pager_set_state (OsScrollbar *scrollbar);
111 static void adjustment_changed_cb (GtkAdjustment *adjustment, gpointer user_data);
112 static void adjustment_value_changed_cb (GtkAdjustment *adjustment, gpointer user_data);
113@@ -656,8 +655,6 @@
114
115 priv->pointer_x = event->x;
116 priv->pointer_y = event->y;
117-
118- gtk_widget_queue_draw (widget);
119 }
120 }
121
122@@ -703,8 +700,6 @@
123
124 priv->button_press_event = FALSE;
125 priv->motion_notify_event = FALSE;
126-
127- gtk_widget_queue_draw (widget);
128 }
129 }
130
131@@ -782,9 +777,6 @@
132 priv->value_changed_event = FALSE;
133 }
134
135- if (!priv->motion_notify_event)
136- gtk_widget_queue_draw (widget);
137-
138 priv->motion_notify_event = TRUE;
139
140 os_scrollbar_move (scrollbar, event->x_root, event->y_root);
141@@ -875,40 +867,6 @@
142 os_pager_move_resize (OS_PAGER (priv->pager), mask);
143 }
144
145-/* Resize the overlay window. */
146-static void
147-pager_set_allocation (OsScrollbar *scrollbar)
148-{
149- GdkRectangle rect;
150- OsScrollbarPrivate *priv;
151- gint offset;
152-
153- priv = scrollbar->priv;
154-
155- if (GTK_IS_SCROLLED_WINDOW (priv->parent) &&
156- gtk_scrolled_window_get_shadow_type (GTK_SCROLLED_WINDOW (priv->parent)) != GTK_SHADOW_NONE)
157- offset = 1;
158- else
159- offset = 0;
160-
161- if (priv->orientation == GTK_ORIENTATION_VERTICAL)
162- {
163- rect.x = priv->overlay_all.x;
164- rect.y = priv->overlay_all.y + offset;
165- rect.width = DEFAULT_PAGER_WIDTH;
166- rect.height = priv->overlay_all.height - offset * 2;
167- }
168- else
169- {
170- rect.x = priv->overlay_all.x + offset;
171- rect.y = priv->overlay_all.y;
172- rect.width = priv->overlay_all.width - offset * 2;
173- rect.height = DEFAULT_PAGER_WIDTH;
174- }
175-
176- os_pager_size_allocate (OS_PAGER (priv->pager), rect);
177-}
178-
179 static void
180 pager_set_state (OsScrollbar *scrollbar)
181 {
182@@ -1005,6 +963,7 @@
183 GtkAllocation *allocation,
184 gpointer user_data)
185 {
186+ GdkRectangle rect;
187 OsScrollbar *scrollbar;
188 OsScrollbarPrivate *priv;
189 gint offset;
190@@ -1032,6 +991,11 @@
191 priv->slider.height = DEFAULT_SCROLLBAR_HEIGHT;
192 priv->overlay_all.x = allocation->x + allocation->width - DEFAULT_PAGER_WIDTH - offset;
193 priv->thumb_all.x = allocation->x + allocation->width - offset;
194+
195+ rect.x = priv->overlay_all.x;
196+ rect.y = priv->overlay_all.y + offset;
197+ rect.width = DEFAULT_PAGER_WIDTH;
198+ rect.height = priv->overlay_all.height - offset * 2;
199 }
200 else
201 {
202@@ -1039,6 +1003,11 @@
203 priv->slider.height = DEFAULT_SCROLLBAR_WIDTH;
204 priv->overlay_all.y = allocation->y + allocation->height - DEFAULT_PAGER_WIDTH - offset;
205 priv->thumb_all.y = allocation->y + allocation->height - offset;
206+
207+ rect.x = priv->overlay_all.x + offset;
208+ rect.y = priv->overlay_all.y;
209+ rect.width = priv->overlay_all.width - offset * 2;
210+ rect.height = DEFAULT_PAGER_WIDTH;
211 }
212
213 if (priv->adjustment != NULL)
214@@ -1047,7 +1016,8 @@
215 os_scrollbar_calc_layout_slider (scrollbar, priv->adjustment->value);
216 }
217
218- pager_set_allocation (scrollbar);
219+ os_pager_size_allocate (OS_PAGER (priv->pager), rect);
220+
221 pager_move (scrollbar);
222
223 if (gtk_widget_get_realized (widget))
224@@ -1094,15 +1064,13 @@
225
226 os_scrollbar_calc_layout_pager (scrollbar, priv->adjustment->value);
227 os_scrollbar_calc_layout_slider (scrollbar, priv->adjustment->value);
228+
229 os_scrollbar_move_thumb (scrollbar,
230 event->x + priv->thumb_all.x + priv->slider.x,
231 event->y + priv->thumb_all.y + priv->slider.y);
232
233 os_scrollbar_store_window_position (scrollbar);
234
235- pager_set_allocation (scrollbar);
236- pager_move (scrollbar);
237-
238 return FALSE;
239 }
240
241@@ -1132,9 +1100,6 @@
242 /* get the motion_notify_event trough XEvent */
243 if (xevent->type == MotionNotify)
244 {
245- os_scrollbar_calc_layout_pager (scrollbar, priv->adjustment->value);
246- os_scrollbar_calc_layout_slider (scrollbar, priv->adjustment->value);
247-
248 /* proximity area */
249 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
250 {
251
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 gint radius;
257
258 thumb = OS_THUMB (widget);
259- priv = thumb->priv;;
260+ priv = thumb->priv;
261
262 state_type_down = GTK_STATE_NORMAL;
263 state_type_up = GTK_STATE_NORMAL;

Subscribers

People subscribed via source and target branches