47041fe
From 34e5c7b13772787f8eadaec8a3936b78d0831f23 Mon Sep 17 00:00:00 2001
47041fe
From: Eric Williams <ericwill@redhat.com>
47041fe
Date: Mon, 4 Jan 2016 16:08:15 -0500
47041fe
Subject: [PATCH] Bug 484729: [GTK3] Eclipse IDE consumes CPU when idle
47041fe
47041fe
Bug 479998 introduced a call to getClientArea() in Composite.gtk_draw().
47041fe
This calls forceResize() in both the Composite and the parent Control,
47041fe
which causes unnecessary overhead. It also causes a paint loop in
47041fe
CTabFolder, with never ending calls to
47041fe
gdk_cairo_region_create_from_surface(). The looped system calls to GDK
47041fe
cause high CPU usage.
47041fe
47041fe
To remedy this we can use a GtkAllocation instead of calling
47041fe
getClientArea(): this is far more efficient and does not trigger any
47041fe
additional SWT machinery.
47041fe
47041fe
Tested on GTK3.18.6, 3.14, and 2.24. AllNonBrowser JUnit tests pass on
47041fe
GTK3 and GTK2.
47041fe
47041fe
Change-Id: Ib1e5900e5c9339e9c0555a9436e8b2a9949b6372
47041fe
Signed-off-by: Eric Williams <ericwill@redhat.com>
47041fe
---
47041fe
 .../Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java         | 7 +++++--
47041fe
 1 file changed, 5 insertions(+), 2 deletions(-)
47041fe
47041fe
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
47041fe
index 4aef32c..80c396c 100644
47041fe
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java	
47041fe
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java	
47041fe
@@ -355,9 +355,12 @@ void createHandle (int index, boolean fixed, boolean scrolled) {
47041fe
 @Override
47041fe
 long /*int*/ gtk_draw (long /*int*/ widget, long /*int*/ cairo) {
47041fe
 	if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
47041fe
-		Rectangle area = getClientArea();
47041fe
 		long /*int*/ context = OS.gtk_widget_get_style_context(widget);
47041fe
-		OS.gtk_render_background(context, cairo, area.x, area.y, area.width, area.height);
47041fe
+		GtkAllocation allocation = new GtkAllocation();
47041fe
+		OS.gtk_widget_get_allocation (widget, allocation);
47041fe
+		int width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
47041fe
+		int height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
47041fe
+		OS.gtk_render_background(context, cairo, 0, 0, width, height);
47041fe
 	}
47041fe
 	return super.gtk_draw(widget, cairo);
47041fe
 }
47041fe
-- 
47041fe
2.5.0
47041fe