diff options
author | Bogdan Gheorghe <gheorghe@ca.ibm.com> | 2012-01-17 17:28:50 -0500 |
---|---|---|
committer | Bogdan Gheorghe <gheorghe@ca.ibm.com> | 2012-01-17 17:28:50 -0500 |
commit | 9b6f622a04ffc6428b9bddee8e107bf304da0051 (patch) | |
tree | f41590ce756ce8011bcb661092853e157767c938 | |
parent | f09fa17598b171271add9842e034e13ff6ff6c75 (diff) | |
download | eclipse.platform.swt-9b6f622a04ffc6428b9bddee8e107bf304da0051.tar.gz eclipse.platform.swt-9b6f622a04ffc6428b9bddee8e107bf304da0051.tar.xz eclipse.platform.swt-9b6f622a04ffc6428b9bddee8e107bf304da0051.zip |
GC CopyArea for scrolling
11 files changed, 56 insertions, 7 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDragSourceEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDragSourceEffect.java index b3656bb1da..63b02999fe 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDragSourceEffect.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDragSourceEffect.java @@ -116,6 +116,7 @@ public class TableDragSourceEffect extends DragSourceEffect { yy[i] = rect.y; hh[i] = h[0]; } + //TODO: Use Cairo int /*long*/ source = OS.gdk_pixmap_new(OS.GDK_ROOT_PARENT(), width, height, -1); int /*long*/ gcSource = OS.gdk_gc_new(source); int /*long*/ mask = OS.gdk_pixmap_new(OS.GDK_ROOT_PARENT(), width, height, 1); diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TreeDragSourceEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TreeDragSourceEffect.java index f6e0067a4a..5a49a38ff7 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TreeDragSourceEffect.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TreeDragSourceEffect.java @@ -115,6 +115,7 @@ public class TreeDragSourceEffect extends DragSourceEffect { yy[i] = rect.y; hh[i] = h[0]; } + //TODO: Use Cairo int /*long*/ source = OS.gdk_pixmap_new(OS.GDK_ROOT_PARENT(), width, height, -1); int /*long*/ gcSource = OS.gdk_gc_new(source); int /*long*/ mask = OS.gdk_pixmap_new(OS.GDK_ROOT_PARENT(), width, height, 1); diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java index ada18dffde..884bf533e2 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java @@ -570,7 +570,7 @@ public class OS extends C { static { boolean useCairo = false; if (!"false".equals(System.getProperty("org.eclipse.swt.internal.gtk.useCairo"))) { - useCairo = GTK_VERSION >= VERSION(2, 17, 0);//TODO this should probably be 2.22.0 + useCairo = GTK_VERSION >= VERSION(2, 24, 0); } USE_CAIRO = useCairo; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java index 951d07f9f7..8c3baded82 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java @@ -14,6 +14,7 @@ package org.eclipse.swt.graphics; import org.eclipse.swt.internal.cairo.*; import org.eclipse.swt.internal.gtk.*; import org.eclipse.swt.internal.*; +import org.eclipse.swt.widgets.*; import org.eclipse.swt.*; /** @@ -450,6 +451,7 @@ public void copyArea(Image image, int x, int y) { if (image.type != SWT.BITMAP || image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); if (OS.USE_CAIRO) { int /*long*/ cairo = Cairo.cairo_create(image.surface); + if (cairo == 0) SWT.error(SWT.ERROR_NO_HANDLES); Cairo.cairo_translate(cairo, -x, -y); if (data.image != null) { Cairo.cairo_set_source_surface(cairo, data.image.surface, 0, 0); @@ -469,6 +471,7 @@ public void copyArea(Image image, int x, int y) { } else { return; } + Cairo.cairo_set_operator(cairo, Cairo.CAIRO_OPERATOR_SOURCE); Cairo.cairo_paint(cairo); Cairo.cairo_destroy(cairo); return; @@ -522,12 +525,51 @@ public void copyArea(int srcX, int srcY, int width, int height, int destX, int d if (width <= 0 || height <= 0) return; int deltaX = destX - srcX, deltaY = destY - srcY; if (deltaX == 0 && deltaY == 0) return; - //TODO fix for USE_CAIRO int /*long*/ drawable = data.drawable; - if (data.image == null && paint) OS.gdk_gc_set_exposures(handle, true); - OS.gdk_draw_drawable(drawable, handle, drawable, srcX, srcY, destX, destY, width, height); + if (OS.USE_CAIRO) { + if (data.image != null) { + Cairo.cairo_set_source_surface(handle, data.image.surface, deltaX, deltaY); + Cairo.cairo_rectangle(handle, destX, destY, width, height); + Cairo.cairo_set_operator(handle, Cairo.CAIRO_OPERATOR_SOURCE); + Cairo.cairo_fill(handle); + } else if (drawable != 0) { + Cairo.cairo_save(handle); + Cairo.cairo_rectangle(handle, destX, destY, width, height); + Cairo.cairo_clip(handle); + Cairo.cairo_translate(handle, deltaX, deltaY); + Cairo.cairo_set_operator(handle, Cairo.CAIRO_OPERATOR_SOURCE); + Cairo.cairo_push_group(handle); + OS.gdk_cairo_set_source_window(handle, drawable, 0, 0); + Cairo.cairo_paint(handle); + Cairo.cairo_pop_group_to_source(handle); + Cairo.cairo_rectangle(handle, destX - deltaX, destY - deltaY, width, height); + Cairo.cairo_clip(handle); + Cairo.cairo_paint(handle); + Cairo.cairo_restore(handle); + if (paint) { + int /*long*/ visibleRegion = OS.gdk_drawable_get_visible_region (drawable); + GdkRectangle srcRect = new GdkRectangle (); + srcRect.x = srcX; + srcRect.y = srcY; + srcRect.width = width; + srcRect.height = height; + int /*long*/ copyRegion = OS.gdk_region_rectangle (srcRect); + OS.gdk_region_intersect(copyRegion, visibleRegion); + int /*long*/ invalidateRegion = OS.gdk_region_rectangle (srcRect); + OS.gdk_region_subtract (invalidateRegion, visibleRegion); + OS.gdk_region_offset (invalidateRegion, deltaX, deltaY); + OS.gdk_window_invalidate_region(drawable, invalidateRegion, false); + OS.gdk_region_destroy (visibleRegion); + OS.gdk_region_destroy (copyRegion); + OS.gdk_region_destroy (invalidateRegion); + } + } + } else { + if (data.image == null && paint) OS.gdk_gc_set_exposures(handle, true); + OS.gdk_draw_drawable(drawable, handle, drawable, srcX, srcY, destX, destY, width, height); + } if (data.image == null & paint) { - OS.gdk_gc_set_exposures(handle, false); + if (!OS.USE_CAIRO) OS.gdk_gc_set_exposures(handle, false); boolean disjoint = (destX + width < srcX) || (srcX + width < destX) || (destY + height < srcY) || (srcY + height < destY); GdkRectangle rect = new GdkRectangle (); if (disjoint) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java index 10d181cd5f..e1137cfb64 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java @@ -264,7 +264,7 @@ public Image(Device device, Image srcImage, int flag) { if (surface == 0) SWT.error(SWT.ERROR_NO_HANDLES); int /*long*/ cairo = Cairo.cairo_create(surface); if (cairo == 0) SWT.error(SWT.ERROR_NO_HANDLES); - Cairo.cairo_set_operator(cairo, Cairo.CAIRO_OPERATOR_SRC); + Cairo.cairo_set_operator(cairo, Cairo.CAIRO_OPERATOR_SOURCE); Cairo.cairo_set_source_surface (cairo, imageSurface, 0, 0); Cairo.cairo_paint (cairo); Cairo.cairo_destroy(cairo); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java index 9de4dbeff5..c678e49ccc 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java @@ -36,7 +36,7 @@ public static int /*long*/ convertSurface(Image image) { if (newSurface == 0) SWT.error(SWT.ERROR_NO_HANDLES); int /*long*/ cairo = Cairo.cairo_create(newSurface); if (cairo == 0) SWT.error(SWT.ERROR_NO_HANDLES); - Cairo.cairo_set_operator(cairo, Cairo.CAIRO_OPERATOR_SRC); + Cairo.cairo_set_operator(cairo, Cairo.CAIRO_OPERATOR_SOURCE); Cairo.cairo_set_source_surface (cairo, image.surface, 0, 0); Cairo.cairo_paint (cairo); Cairo.cairo_destroy(cairo); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java index 3fd382caa5..1799563854 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java @@ -275,6 +275,7 @@ public void scroll (int destX, int destY, int x, int y, int width, int height, b // GC gc = new GC (this); // gc.copyArea (x, y, width, height, destX, destY); // gc.dispose (); + //TODO: Use Cairo int /*long*/ gdkGC = OS.gdk_gc_new (window); OS.gdk_gc_set_exposures (gdkGC, true); OS.gdk_draw_drawable (window, gdkGC, window, copyRect.x, copyRect.y, copyRect.x + deltaX, copyRect.y + deltaY, copyRect.width, copyRect.height); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java index 3b2fe88b2b..f6cd1151fc 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java @@ -144,6 +144,7 @@ void createHandle (int index) { void drawBand (int x, int y, int width, int height) { if ((style & SWT.SMOOTH) != 0) return; + //TODO: Use Cairo int /*long*/ window = OS.GTK_WIDGET_WINDOW (parent.paintHandle()); if (window == 0) return; byte [] bits = {-86, 85, -86, 85, -86, 85, -86, 85}; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java index 25c926a5ef..a969c2b307 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java @@ -1398,6 +1398,7 @@ int /*long*/ gtk_expose_event (int /*long*/ widget, int /*long*/ event) { case SWT.CENTER: x = (width - rect.width) / 2; break; case SWT.RIGHT: x = rtl ? innerBorder.left : width - rect.width; break; } + //TODO: Use Cairo int /*long*/ gc = OS.gdk_gc_new (window); int /*long*/ style = OS.gtk_widget_get_style (handle); GdkColor textColor = new GdkColor (); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java index ebc7219de2..a3b3746401 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java @@ -470,6 +470,7 @@ int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) { int /*long*/ gtk_expose_event (int /*long*/ widget, int /*long*/ eventPtr) { if ((state & OBSCURED) != 0) return 0; int /*long*/ window = OS.GTK_WIDGET_WINDOW (handle); + //TODO: Use Cairo int /*long*/ gdkGC = OS.gdk_gc_new (window); OS.gdk_draw_polygon (window, gdkGC, 0, borderPolygon, borderPolygon.length / 2); int x = BORDER + PADDING; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java index 9bb9bc74e2..a67dc3ece1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java @@ -311,6 +311,7 @@ void drawRectangles (Rectangle [] rects) { window = OS.GTK_WIDGET_WINDOW (parent.paintHandle()); } if (window == 0) return; + //TODO: Use Cairo int /*long*/ gc = OS.gdk_gc_new (window); if (gc == 0) return; int /*long*/ colormap = OS.gdk_colormap_get_system (); |