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
=== modified file 'os/os-pager.c'
--- os/os-pager.c 2011-03-15 18:03:47 +0000
+++ os/os-pager.c 2011-03-16 15:43:24 +0000
@@ -40,15 +40,27 @@
40 gint height;40 gint height;
41};41};
4242
43static gboolean rectangle_changed (GdkRectangle rectangle1, GdkRectangle rectangle2);
43static void os_pager_dispose (GObject *object);44static void os_pager_dispose (GObject *object);
44static void os_pager_finalize (GObject *object);45static void os_pager_finalize (GObject *object);
45static void os_pager_create (OsPager *pager);46static void os_pager_create (OsPager *pager);
46static void os_pager_draw (OsPager *pager);47static void os_pager_draw (OsPager *pager);
47static void os_pager_draw_bitmap (GdkPixmap *pixmap);
48static void os_pager_mask (OsPager *pager);48static void os_pager_mask (OsPager *pager);
4949
50/* Private functions */50/* Private functions */
5151
52static gboolean
53rectangle_changed (GdkRectangle rectangle1,
54 GdkRectangle rectangle2)
55{
56 if (rectangle1.x != rectangle2.x) return TRUE;
57 if (rectangle1.y != rectangle2.y) return TRUE;
58 if (rectangle1.width != rectangle2.width) return TRUE;
59 if (rectangle1.height != rectangle2.height) return TRUE;
60
61 return FALSE;
62}
63
52/* Create a pager. */64/* Create a pager. */
53static void65static void
54os_pager_create (OsPager *pager)66os_pager_create (OsPager *pager)
@@ -106,44 +118,15 @@
106static void118static void
107os_pager_mask (OsPager *pager)119os_pager_mask (OsPager *pager)
108{120{
109 GdkBitmap *bitmap;
110 OsPagerPrivate *priv;121 OsPagerPrivate *priv;
111122
112 priv = pager->priv;123 priv = pager->priv;
113124
114 bitmap = gdk_pixmap_new (NULL, MAX (1, priv->mask.width),125 gdk_window_shape_combine_region (priv->pager_window,
115 MAX (1, priv->mask.height), 1);126 gdk_region_rectangle (&priv->mask),
116 os_pager_draw_bitmap (bitmap);127 0, 0);
117
118 gdk_window_shape_combine_mask (priv->pager_window, bitmap,
119 priv->mask.x, priv->mask.y);
120128
121 gdk_window_clear (priv->pager_window);129 gdk_window_clear (priv->pager_window);
122
123 g_object_unref (bitmap);
124}
125
126/* Draw on the bitmap of the pager, to get a mask. */
127static void
128os_pager_draw_bitmap (GdkBitmap *bitmap)
129{
130 cairo_t *cr_surface;
131 cairo_surface_t *surface;
132 gint width, height;
133
134 gdk_pixmap_get_size (bitmap, &width, &height);
135
136 surface = cairo_xlib_surface_create_for_bitmap
137 (GDK_DRAWABLE_XDISPLAY (bitmap), gdk_x11_drawable_get_xid (bitmap),
138 GDK_SCREEN_XSCREEN (gdk_drawable_get_screen (bitmap)), width, height);
139
140 cr_surface = cairo_create (surface);
141
142 cairo_paint (cr_surface);
143
144 cairo_destroy (cr_surface);
145
146 cairo_surface_destroy (surface);
147}130}
148131
149/* Type definition. */132/* Type definition. */
@@ -257,6 +240,9 @@
257240
258 priv = pager->priv;241 priv = pager->priv;
259242
243 if (!rectangle_changed (priv->mask, mask))
244 return;
245
260 priv->mask = mask;246 priv->mask = mask;
261247
262 if (priv->parent == NULL)248 if (priv->parent == NULL)
@@ -376,6 +362,9 @@
376362
377 priv = pager->priv;363 priv = pager->priv;
378364
365 if (!rectangle_changed (priv->allocation, rectangle))
366 return;
367
379 priv->allocation = rectangle;368 priv->allocation = rectangle;
380369
381 if (priv->parent == NULL)370 if (priv->parent == NULL)
382371
=== modified file 'os/os-scrollbar.c'
--- os/os-scrollbar.c 2011-03-15 15:43:22 +0000
+++ os/os-scrollbar.c 2011-03-16 15:43:24 +0000
@@ -101,7 +101,6 @@
101static gboolean thumb_leave_notify_event_cb (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data);101static gboolean thumb_leave_notify_event_cb (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data);
102static gboolean thumb_motion_notify_event_cb (GtkWidget *widget, GdkEventMotion *event, gpointer user_data);102static gboolean thumb_motion_notify_event_cb (GtkWidget *widget, GdkEventMotion *event, gpointer user_data);
103static void pager_move (OsScrollbar *scrollbar);103static void pager_move (OsScrollbar *scrollbar);
104static void pager_set_allocation (OsScrollbar *scrollbar);
105static void pager_set_state (OsScrollbar *scrollbar);104static void pager_set_state (OsScrollbar *scrollbar);
106static void adjustment_changed_cb (GtkAdjustment *adjustment, gpointer user_data);105static void adjustment_changed_cb (GtkAdjustment *adjustment, gpointer user_data);
107static void adjustment_value_changed_cb (GtkAdjustment *adjustment, gpointer user_data);106static void adjustment_value_changed_cb (GtkAdjustment *adjustment, gpointer user_data);
@@ -656,8 +655,6 @@
656655
657 priv->pointer_x = event->x;656 priv->pointer_x = event->x;
658 priv->pointer_y = event->y;657 priv->pointer_y = event->y;
659
660 gtk_widget_queue_draw (widget);
661 }658 }
662 }659 }
663660
@@ -703,8 +700,6 @@
703700
704 priv->button_press_event = FALSE;701 priv->button_press_event = FALSE;
705 priv->motion_notify_event = FALSE;702 priv->motion_notify_event = FALSE;
706
707 gtk_widget_queue_draw (widget);
708 }703 }
709 }704 }
710705
@@ -782,9 +777,6 @@
782 priv->value_changed_event = FALSE;777 priv->value_changed_event = FALSE;
783 }778 }
784779
785 if (!priv->motion_notify_event)
786 gtk_widget_queue_draw (widget);
787
788 priv->motion_notify_event = TRUE;780 priv->motion_notify_event = TRUE;
789781
790 os_scrollbar_move (scrollbar, event->x_root, event->y_root);782 os_scrollbar_move (scrollbar, event->x_root, event->y_root);
@@ -875,40 +867,6 @@
875 os_pager_move_resize (OS_PAGER (priv->pager), mask);867 os_pager_move_resize (OS_PAGER (priv->pager), mask);
876}868}
877869
878/* Resize the overlay window. */
879static void
880pager_set_allocation (OsScrollbar *scrollbar)
881{
882 GdkRectangle rect;
883 OsScrollbarPrivate *priv;
884 gint offset;
885
886 priv = scrollbar->priv;
887
888 if (GTK_IS_SCROLLED_WINDOW (priv->parent) &&
889 gtk_scrolled_window_get_shadow_type (GTK_SCROLLED_WINDOW (priv->parent)) != GTK_SHADOW_NONE)
890 offset = 1;
891 else
892 offset = 0;
893
894 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
895 {
896 rect.x = priv->overlay_all.x;
897 rect.y = priv->overlay_all.y + offset;
898 rect.width = DEFAULT_PAGER_WIDTH;
899 rect.height = priv->overlay_all.height - offset * 2;
900 }
901 else
902 {
903 rect.x = priv->overlay_all.x + offset;
904 rect.y = priv->overlay_all.y;
905 rect.width = priv->overlay_all.width - offset * 2;
906 rect.height = DEFAULT_PAGER_WIDTH;
907 }
908
909 os_pager_size_allocate (OS_PAGER (priv->pager), rect);
910}
911
912static void870static void
913pager_set_state (OsScrollbar *scrollbar)871pager_set_state (OsScrollbar *scrollbar)
914{872{
@@ -1005,6 +963,7 @@
1005 GtkAllocation *allocation,963 GtkAllocation *allocation,
1006 gpointer user_data)964 gpointer user_data)
1007{965{
966 GdkRectangle rect;
1008 OsScrollbar *scrollbar;967 OsScrollbar *scrollbar;
1009 OsScrollbarPrivate *priv;968 OsScrollbarPrivate *priv;
1010 gint offset;969 gint offset;
@@ -1032,6 +991,11 @@
1032 priv->slider.height = DEFAULT_SCROLLBAR_HEIGHT;991 priv->slider.height = DEFAULT_SCROLLBAR_HEIGHT;
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;
1034 priv->thumb_all.x = allocation->x + allocation->width - offset;993 priv->thumb_all.x = allocation->x + allocation->width - offset;
994
995 rect.x = priv->overlay_all.x;
996 rect.y = priv->overlay_all.y + offset;
997 rect.width = DEFAULT_PAGER_WIDTH;
998 rect.height = priv->overlay_all.height - offset * 2;
1035 }999 }
1036 else1000 else
1037 {1001 {
@@ -1039,6 +1003,11 @@
1039 priv->slider.height = DEFAULT_SCROLLBAR_WIDTH;1003 priv->slider.height = DEFAULT_SCROLLBAR_WIDTH;
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;
1041 priv->thumb_all.y = allocation->y + allocation->height - offset;1005 priv->thumb_all.y = allocation->y + allocation->height - offset;
1006
1007 rect.x = priv->overlay_all.x + offset;
1008 rect.y = priv->overlay_all.y;
1009 rect.width = priv->overlay_all.width - offset * 2;
1010 rect.height = DEFAULT_PAGER_WIDTH;
1042 }1011 }
10431012
1044 if (priv->adjustment != NULL)1013 if (priv->adjustment != NULL)
@@ -1047,7 +1016,8 @@
1047 os_scrollbar_calc_layout_slider (scrollbar, priv->adjustment->value);1016 os_scrollbar_calc_layout_slider (scrollbar, priv->adjustment->value);
1048 }1017 }
10491018
1050 pager_set_allocation (scrollbar);1019 os_pager_size_allocate (OS_PAGER (priv->pager), rect);
1020
1051 pager_move (scrollbar);1021 pager_move (scrollbar);
10521022
1053 if (gtk_widget_get_realized (widget))1023 if (gtk_widget_get_realized (widget))
@@ -1094,15 +1064,13 @@
10941064
1095 os_scrollbar_calc_layout_pager (scrollbar, priv->adjustment->value);1065 os_scrollbar_calc_layout_pager (scrollbar, priv->adjustment->value);
1096 os_scrollbar_calc_layout_slider (scrollbar, priv->adjustment->value);1066 os_scrollbar_calc_layout_slider (scrollbar, priv->adjustment->value);
1067
1097 os_scrollbar_move_thumb (scrollbar,1068 os_scrollbar_move_thumb (scrollbar,
1098 event->x + priv->thumb_all.x + priv->slider.x,1069 event->x + priv->thumb_all.x + priv->slider.x,
1099 event->y + priv->thumb_all.y + priv->slider.y);1070 event->y + priv->thumb_all.y + priv->slider.y);
11001071
1101 os_scrollbar_store_window_position (scrollbar);1072 os_scrollbar_store_window_position (scrollbar);
11021073
1103 pager_set_allocation (scrollbar);
1104 pager_move (scrollbar);
1105
1106 return FALSE;1074 return FALSE;
1107}1075}
11081076
@@ -1132,9 +1100,6 @@
1132 /* get the motion_notify_event trough XEvent */1100 /* get the motion_notify_event trough XEvent */
1133 if (xevent->type == MotionNotify)1101 if (xevent->type == MotionNotify)
1134 {1102 {
1135 os_scrollbar_calc_layout_pager (scrollbar, priv->adjustment->value);
1136 os_scrollbar_calc_layout_slider (scrollbar, priv->adjustment->value);
1137
1138 /* proximity area */1103 /* proximity area */
1139 if (priv->orientation == GTK_ORIENTATION_VERTICAL)1104 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
1140 {1105 {
11411106
=== modified file 'os/os-thumb.c'
--- os/os-thumb.c 2011-03-14 15:17:25 +0000
+++ os/os-thumb.c 2011-03-16 15:43:24 +0000
@@ -266,7 +266,7 @@
266 gint radius;266 gint radius;
267267
268 thumb = OS_THUMB (widget);268 thumb = OS_THUMB (widget);
269 priv = thumb->priv;;269 priv = thumb->priv;
270270
271 state_type_down = GTK_STATE_NORMAL;271 state_type_down = GTK_STATE_NORMAL;
272 state_type_up = GTK_STATE_NORMAL;272 state_type_up = GTK_STATE_NORMAL;

Subscribers

People subscribed via source and target branches