diff options
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java')
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java | 152 |
1 files changed, 106 insertions, 46 deletions
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 35099e42bc..bdc8a4d524 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 @@ -2424,41 +2424,80 @@ public Rectangle getClipping() { long /*int*/ cairo = data.cairo; long /*int*/ clipRgn = data.clipRgn; long /*int*/ damageRgn = data.damageRgn; + long /*int*/ rgn = 0; if (clipRgn != 0 || damageRgn != 0 || cairo != 0) { - long /*int*/ rgn = cairo_region_create (); - GdkRectangle rect = new GdkRectangle(); - rect.width = width; - rect.height = height; - OS.gdk_region_union_with_rect(rgn, rect); - if (damageRgn != 0) { - cairo_region_intersect (rgn, damageRgn); - } - /* Intersect visible bounds with clipping */ - if (clipRgn != 0) { - /* Convert clipping to device space if needed */ - if (data.clippingTransform != null) { - clipRgn = convertRgn(clipRgn, data.clippingTransform); - cairo_region_intersect (rgn, clipRgn); - cairo_region_destroy (clipRgn); - } else { - cairo_region_intersect (rgn, clipRgn); + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + rgn = Cairo.cairo_region_create (); + cairo_rectangle_int_t rect = new cairo_rectangle_int_t (); + rect.width = width; + rect.height = height; + Cairo.cairo_region_union_rectangle (rgn, rect); + if (damageRgn != 0) { + Cairo.cairo_region_intersect (rgn, damageRgn); } - } - /* Convert to user space */ - if (cairo != 0) { - double[] matrix = new double[6]; - Cairo.cairo_get_matrix(cairo, matrix); - Cairo.cairo_matrix_invert(matrix); - clipRgn = convertRgn(rgn, matrix); + /* Intersect visible bounds with clipping */ + if (clipRgn != 0) { + /* Convert clipping to device space if needed */ + if (data.clippingTransform != null) { + clipRgn = convertRgn(clipRgn, data.clippingTransform); + Cairo.cairo_region_intersect (rgn, clipRgn); + Cairo.cairo_region_destroy (clipRgn); + } else { + Cairo.cairo_region_intersect (rgn, clipRgn); + } + } + /* Convert to user space */ + if (cairo != 0) { + double[] matrix = new double[6]; + Cairo.cairo_get_matrix(cairo, matrix); + Cairo.cairo_matrix_invert(matrix); + clipRgn = convertRgn(rgn, matrix); + cairo_region_destroy (rgn); + rgn = clipRgn; + } + Cairo.cairo_region_get_extents (rgn, rect); cairo_region_destroy (rgn); - rgn = clipRgn; + x = rect.x; + y = rect.y; + width = rect.width; + height = rect.height; + } else { + rgn = OS.gdk_region_new (); + GdkRectangle rect = new GdkRectangle(); + rect.width = width; + rect.height = height; + OS.gdk_region_union_with_rect(rgn, rect); + if (damageRgn != 0) { + OS.gdk_region_intersect (rgn, damageRgn); + } + /* Intersect visible bounds with clipping */ + if (clipRgn != 0) { + /* Convert clipping to device space if needed */ + if (data.clippingTransform != null) { + clipRgn = convertRgn(clipRgn, data.clippingTransform); + OS.gdk_region_intersect (rgn, clipRgn); + OS.gdk_region_destroy (clipRgn); + } else { + OS.gdk_region_intersect (rgn, clipRgn); + } + } + /* Convert to user space */ + if (cairo != 0) { + double[] matrix = new double[6]; + Cairo.cairo_get_matrix(cairo, matrix); + Cairo.cairo_matrix_invert(matrix); + clipRgn = convertRgn(rgn, matrix); + cairo_region_destroy (rgn); + rgn = clipRgn; + } + OS.gdk_region_get_clipbox(rgn, rect); + OS.gdk_region_destroy (rgn); + x = rect.x; + y = rect.y; + width = rect.width; + height = rect.height; } - OS.gdk_region_get_clipbox(rgn, rect); - cairo_region_destroy (rgn); - x = rect.x; - y = rect.y; - width = rect.width; - height = rect.height; + } return new Rectangle(x, y, width, height); } @@ -2486,12 +2525,21 @@ public void getClipping(Region region) { long /*int*/ cairo = data.cairo; long /*int*/ clipRgn = data.clipRgn; if (clipRgn == 0) { - GdkRectangle rect = new GdkRectangle(); - int[] width = new int[1], height = new int[1]; - getSize(width, height); - rect.width = width[0]; - rect.height = height[0]; - OS.gdk_region_union_with_rect(clipping, rect); + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + cairo_rectangle_int_t rect = new cairo_rectangle_int_t (); + int[] width = new int[1], height = new int[1]; + getSize(width, height); + rect.width = width[0]; + rect.height = height[0]; + Cairo.cairo_region_union_rectangle (clipping, rect); + } else { + GdkRectangle rect = new GdkRectangle(); + int[] width = new int[1], height = new int[1]; + getSize(width, height); + rect.width = width[0]; + rect.height = height[0]; + OS.gdk_region_union_with_rect(clipping, rect); + } } else { /* Convert clipping to device space if needed */ if (data.clippingTransform != null) { @@ -3410,15 +3458,27 @@ public void setClipping(int x, int y, int width, int height) { y = y + height; height = -height; } - GdkRectangle rect = new GdkRectangle(); - rect.x = x; - rect.y = y; - rect.width = width; - rect.height = height; - long /*int*/ clipRgn = cairo_region_create (); - OS.gdk_region_union_with_rect(clipRgn, rect); - setClipping(clipRgn); - cairo_region_destroy (clipRgn); + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + cairo_rectangle_int_t rect = new cairo_rectangle_int_t (); + rect.x = x; + rect.y = y; + rect.width = width; + rect.height = height; + long /*int*/ clipRgn = cairo_region_create (); + Cairo.cairo_region_union_rectangle (clipRgn, rect); + setClipping(clipRgn); + Cairo.cairo_region_destroy (clipRgn); + } else { + GdkRectangle rect = new GdkRectangle(); + rect.x = x; + rect.y = y; + rect.width = width; + rect.height = height; + long /*int*/ clipRgn = cairo_region_create (); + OS.gdk_region_union_with_rect(clipRgn, rect); + setClipping(clipRgn); + OS.gdk_region_destroy (clipRgn); + } } /** |