Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Williams2016-01-04 21:08:15 +0000
committerEric Williams2016-01-05 15:57:30 +0000
commit5cd53fd10251fa9c8547fd06882b3d69b5c275a1 (patch)
tree62f2aea2bb1cf1ce7792693fb74a514a7ceab176
parent428cc3497ee844b9262d1bdc7cb09a8332eee87c (diff)
downloadeclipse.platform.swt-5cd53fd10251fa9c8547fd06882b3d69b5c275a1.tar.gz
eclipse.platform.swt-5cd53fd10251fa9c8547fd06882b3d69b5c275a1.tar.xz
eclipse.platform.swt-5cd53fd10251fa9c8547fd06882b3d69b5c275a1.zip
Bug 484729: [GTK3] Eclipse IDE consumes CPU when idle
Bug 479998 introduced a call to getClientArea() in Composite.gtk_draw(). This calls forceResize() in both the Composite and the parent Control, which causes unnecessary overhead. It also causes a paint loop in CTabFolder, with never ending calls to gdk_cairo_region_create_from_surface(). The looped system calls to GDK cause high CPU usage. To remedy this we can use a GtkAllocation instead of calling getClientArea(): this is far more efficient and does not trigger any additional SWT machinery. Tested on GTK3.18.6, 3.14, and 2.24. AllNonBrowser JUnit tests pass on GTK3 and GTK2. Change-Id: Ib1e5900e5c9339e9c0555a9436e8b2a9949b6372 Signed-off-by: Eric Williams <ericwill@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
index 4aef32c917..f45f78e801 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
@@ -355,9 +355,14 @@ void createHandle (int index, boolean fixed, boolean scrolled) {
@Override
long /*int*/ gtk_draw (long /*int*/ widget, long /*int*/ cairo) {
if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
- Rectangle area = getClientArea();
long /*int*/ context = OS.gtk_widget_get_style_context(widget);
- OS.gtk_render_background(context, cairo, area.x, area.y, area.width, area.height);
+ GtkAllocation allocation = new GtkAllocation();
+ OS.gtk_widget_get_allocation (widget, allocation);
+ int width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
+ int height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
+ // We specify a 0 value for x & y as we want the whole widget to be
+ // colored, not some portion of it.
+ OS.gtk_render_background(context, cairo, 0, 0, width, height);
}
return super.gtk_draw(widget, cairo);
}

Back to the top