eclipse/eclipse-bug-484729.patch

48 lines
2.1 KiB
Diff
Raw Normal View History

From 34e5c7b13772787f8eadaec8a3936b78d0831f23 Mon Sep 17 00:00:00 2001
From: Eric Williams <ericwill@redhat.com>
Date: Mon, 4 Jan 2016 16:08:15 -0500
Subject: [PATCH] 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>
---
.../Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java | 7 +++++--
1 file changed, 5 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 4aef32c..80c396c 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,12 @@ 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;
+ OS.gtk_render_background(context, cairo, 0, 0, width, height);
}
return super.gtk_draw(widget, cairo);
}
--
2.5.0