Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrant Gayed2010-05-03 19:40:50 +0000
committerGrant Gayed2010-05-03 19:40:50 +0000
commit60a955bc70eee77ee38ed2f9e535707353a6cb1b (patch)
tree973ad0268728506a8129fe951b1ba428a2d6e5dc /bundles/org.eclipse.swt/Eclipse SWT/emulated
parent8bf573ee7c876cf0329fbd1d4a8ab0c1b4560a42 (diff)
downloadeclipse.platform.swt-60a955bc70eee77ee38ed2f9e535707353a6cb1b.tar.gz
eclipse.platform.swt-60a955bc70eee77ee38ed2f9e535707353a6cb1b.tar.xz
eclipse.platform.swt-60a955bc70eee77ee38ed2f9e535707353a6cb1b.zip
310932 - Poor table scrolling performance due to multiple XQueryColor calls per widget
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/emulated')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Table.java43
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Tree.java35
2 files changed, 68 insertions, 10 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Table.java
index e5b4972744..93888fa748 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Table.java
@@ -72,6 +72,7 @@ public class Table extends Composite {
TableItem[] items = new TableItem [0];
TableItem[] selectedItems = new TableItem [0];
TableItem focusItem, anchorItem, lastClickedItem;
+ Color cachedBackground, cachedForeground;
Event lastSelectionEvent;
boolean linesVisible, ignoreKey, ignoreDispose, customHeightSet;
int itemsCount = 0;
@@ -791,6 +792,11 @@ Image getArrowDownImage () {
Image getArrowUpImage () {
return (Image) display.getData (ID_ARROWUP);
}
+public Color getBackground () {
+ checkWidget ();
+ if (cachedBackground != null) return cachedBackground;
+ return super.getBackground ();
+}
int getCellPadding () {
return MARGIN_CELL + WIDTH_CELL_HIGHLIGHT;
}
@@ -936,6 +942,11 @@ public TableColumn[] getColumns () {
System.arraycopy (columns, 0, result, 0, columns.length);
return result;
}
+public Color getForeground () {
+ checkWidget ();
+ if (cachedForeground != null) return cachedForeground;
+ return super.getForeground ();
+}
Image getGrayUncheckedImage () {
return (Image) display.getData (ID_GRAYUNCHECKED);
}
@@ -2035,6 +2046,7 @@ void onDispose (Event event) {
lastSelectionEvent = null;
header = null;
resizeColumn = sortColumn = null;
+ cachedBackground = cachedForeground = null;
}
void onEnd (int stateMask) {
int lastAvailableIndex = itemsCount - 1;
@@ -2684,7 +2696,8 @@ void onPaint (Event event) {
endIndex = Math.min (endIndex, itemsCount - 1);
/* fill background not handled by items */
- gc.setBackground (getBackground ());
+ cachedBackground = getBackground ();
+ gc.setBackground (cachedBackground);
gc.setClipping (clipping);
int bottomY = endIndex >= 0 ? getItemY (items [endIndex]) + itemHeight : 0;
int fillHeight = Math.max (0, clientArea.height - bottomY);
@@ -2703,6 +2716,7 @@ void onPaint (Event event) {
boolean noFocusDraw = false;
int[] lineDash = gc.getLineDash ();
int lineWidth = gc.getLineWidth ();
+ cachedForeground = getForeground ();
for (int i = startIndex; i <= Math.min (endIndex, itemsCount - 1); i++) {
TableItem item = items [i];
if (!item.isDisposed ()) { /* ensure that item was not disposed in a callback */
@@ -2717,13 +2731,20 @@ void onPaint (Event event) {
if (!item.isDisposed ()) { /* ensure that item was not disposed in a callback */
noFocusDraw = item.paint (gc, orderedColumns [j], false) || noFocusDraw;
}
- if (isDisposed () || gc.isDisposed ()) return; /* ensure that receiver was not disposed in a callback */
+ if (isDisposed () || gc.isDisposed ()) { /* ensure that receiver was not disposed in a callback */
+ cachedBackground = cachedForeground = null;
+ return;
+ }
}
}
}
}
- if (isDisposed () || gc.isDisposed ()) return; /* ensure that receiver was not disposed in a callback */
+ if (isDisposed () || gc.isDisposed ()) { /* ensure that receiver was not disposed in a callback */
+ cachedBackground = cachedForeground = null;
+ return;
+ }
}
+ cachedBackground = cachedForeground = null;
/* repaint grid lines */
gc.setClipping(clipping);
@@ -3290,10 +3311,9 @@ public void setBackground (Color color) {
if (color == null) color = display.getSystemColor (SWT.COLOR_LIST_BACKGROUND);
super.setBackground (color);
}
-public void setForeground (Color color) {
- checkWidget ();
- if (color == null) color = display.getSystemColor (SWT.COLOR_LIST_FOREGROUND);
- super.setForeground (color);
+void setBackgroundPixel (int pixel) {
+ super.setBackgroundPixel (pixel);
+ cachedBackground = null;
}
/**
* Sets the order that the items in the receiver should
@@ -3412,6 +3432,15 @@ public void setFont (Font value) {
}
redraw ();
}
+public void setForeground (Color color) {
+ checkWidget ();
+ if (color == null) color = display.getSystemColor (SWT.COLOR_LIST_FOREGROUND);
+ super.setForeground (color);
+}
+void setForegroundPixel (int pixel) {
+ super.setForegroundPixel (pixel);
+ cachedForeground = null;
+}
void setHeaderImageHeight (int value) {
headerImageHeight = value;
Point headerSize = header.getSize ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Tree.java
index 1420337702..3a980acf7c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Tree.java
@@ -81,6 +81,7 @@ public class Tree extends Composite {
TreeItem[] selectedItems = NO_ITEMS;
TreeItem focusItem, anchorItem, insertMarkItem;
TreeItem lastClickedItem;
+ Color cachedBackground, cachedForeground;
Event lastSelectionEvent;
int availableItemsCount = 0;
boolean insertMarkPrecedes = false;
@@ -825,6 +826,11 @@ Image getArrowDownImage () {
Image getArrowUpImage () {
return (Image) display.getData (ID_ARROWUP);
}
+public Color getBackground () {
+ checkWidget ();
+ if (cachedBackground != null) return cachedBackground;
+ return super.getBackground ();
+}
int getCellPadding () {
return MARGIN_CELL + WIDTH_CELL_HIGHLIGHT;
}
@@ -985,6 +991,11 @@ Color getConnectorColor () {
Image getExpandedImage () {
return (Image) display.getData (ID_EXPANDED);
}
+public Color getForeground () {
+ checkWidget ();
+ if (cachedForeground != null) return cachedForeground;
+ return super.getForeground ();
+}
Image getGrayUncheckedImage () {
return (Image) display.getData (ID_GRAYUNCHECKED);
}
@@ -2298,6 +2309,7 @@ void onDispose (Event event) {
header = null;
resizeColumn = sortColumn = null;
expanderBounds = null;
+ cachedBackground = cachedForeground = null;
}
void onEnd (int stateMask) {
int lastAvailableIndex = availableItemsCount - 1;
@@ -2973,7 +2985,8 @@ void onPaint (Event event) {
endIndex = Math.min (endIndex, availableItemsCount - 1);
/* fill background not handled by items */
- gc.setBackground (getBackground ());
+ cachedBackground = getBackground ();
+ gc.setBackground (cachedBackground);
gc.setClipping (clipping);
int bottomY = endIndex >= 0 ? getItemY (availableItems [endIndex]) + itemHeight : 0;
int fillHeight = Math.max (0, clientArea.height - bottomY);
@@ -2992,6 +3005,7 @@ void onPaint (Event event) {
boolean noFocusDraw = false;
int[] lineDash = gc.getLineDash ();
int lineWidth = gc.getLineWidth ();
+ cachedForeground = getForeground ();
for (int i = startIndex; i <= Math.min (endIndex, availableItemsCount - 1); i++) {
TreeItem item = availableItems [i];
if (!item.isDisposed ()) { /* ensure that item was not disposed in a callback */
@@ -3006,13 +3020,20 @@ void onPaint (Event event) {
if (!item.isDisposed ()) { /* ensure that item was not disposed in a callback */
noFocusDraw = item.paint (gc, orderedColumns [j], false) || noFocusDraw;
}
- if (isDisposed () || gc.isDisposed ()) return; /* ensure that receiver was not disposed in a callback */
+ if (isDisposed () || gc.isDisposed ()) { /* ensure that receiver was not disposed in a callback */
+ cachedBackground = cachedForeground = null;
+ return;
+ }
}
}
}
}
- if (isDisposed () || gc.isDisposed ()) return; /* ensure that receiver was not disposed in a callback */
+ if (isDisposed () || gc.isDisposed ()) { /* ensure that receiver was not disposed in a callback */
+ cachedBackground = cachedForeground = null;
+ return;
+ }
}
+ cachedBackground = cachedForeground = null;
/* repaint grid lines */
gc.setClipping(clipping);
@@ -3465,6 +3486,10 @@ public void setBackground (Color color) {
if (color == null) color = display.getSystemColor (SWT.COLOR_LIST_BACKGROUND);
super.setBackground (color);
}
+void setBackgroundPixel (int pixel) {
+ super.setBackgroundPixel (pixel);
+ cachedBackground = null;
+}
/**
* Sets the order that the items in the receiver should
* be displayed in to the given argument which is described
@@ -3603,6 +3628,10 @@ public void setForeground (Color color) {
if (color == null) color = display.getSystemColor (SWT.COLOR_LIST_FOREGROUND);
super.setForeground (color);
}
+void setForegroundPixel (int pixel) {
+ super.setForegroundPixel (pixel);
+ cachedForeground = null;
+}
void setHeaderImageHeight (int value) {
headerImageHeight = value;
Point headerSize = header.getSize ();

Back to the top