From 35b507d5c70a8d3da945cd0bc4734e0dd4a1b522 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 22 Dec 2015 11:39:10 +0000 Subject: [PATCH] Bug 366471 - Improve OSX scroll performance by overriding isOpaque() Update Composite.isOpaque() so that it delegates to protected method which can be overridden by StyledText. Prior to this commit, calls to StyledText.isOpaque() on OSX (with hidden scrollbars) would always result in false. This meant that optimizations usually performed by the OS could not happen. There were two reasons that false was returned: 1) The `background` is usually set to `null`, meaning that the `background != null && background[3]` test always failed. 2) isObscured() always returns `true` due to the scrollbars that fade in and out as scrolling occurs. See Bug 292281 for details of why isObscured() is tested in isOpaque(). Signed-off-by: Phillip Webb --- .../common/org/eclipse/swt/custom/StyledText.java | 4 ++++ .../cocoa/org/eclipse/swt/widgets/Composite.java | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java index d983b3eeaff..fe0aa90600d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java @@ -3452,6 +3452,10 @@ public Color getBackground() { } return background; } +@Override +protected boolean isOpaque() { + return background == null || background.getAlpha() == 255; +} /** * Returns the baseline, in pixels. * diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Composite.java index 980413e3341..e6d018f2bb2 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Composite.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Composite.java @@ -587,12 +587,16 @@ public boolean isLayoutDeferred () { boolean isOpaque (long /*int*/ id, long /*int*/ sel) { if ((state & CANVAS) != 0) { if (id == view.id) { - return region == null && background != null && background[3] == 1 && !isObscured (); + return region == null && isOpaque(); } } return super.isOpaque (id, sel); } +protected boolean isOpaque() { + return background != null && background[3] == 1 && !isObscured(); +} + @Override boolean isTabGroup () { if ((state & CANVAS) != 0) return true;