SOURCES: eclipse-swt-cairo.patch (NEW) - stolen from debian

freetz freetz at pld-linux.org
Sun Dec 11 15:54:26 CET 2005


Author: freetz                       Date: Sun Dec 11 14:54:26 2005 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- stolen from debian

---- Files affected:
SOURCES:
   eclipse-swt-cairo.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/eclipse-swt-cairo.patch
diff -u /dev/null SOURCES/eclipse-swt-cairo.patch:1.1
--- /dev/null	Sun Dec 11 15:54:26 2005
+++ SOURCES/eclipse-swt-cairo.patch	Sun Dec 11 15:54:20 2005
@@ -0,0 +1,4958 @@
+diff -P -r -u --exclude='*.rej' --exclude='*.orig' ../source-tree.orig/plugins/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.java source-tree/plugins/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.java
+--- ../source-tree.orig/plugins/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.java	2005-10-02 00:08:15.000000000 +0200
++++ source-tree/plugins/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.java	2005-10-02 00:10:44.000000000 +0200
+@@ -62,7 +62,10 @@
+ 	if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ 	this.device = device;
+ 	device.checkCairo();
+-	handle = Cairo.cairo_create();
++	int /*long*/ surface = Cairo.cairo_image_surface_create(Cairo.CAIRO_FORMAT_ARGB32, 1, 1);
++	if (surface == 0) SWT.error(SWT.ERROR_NO_HANDLES);
++	handle = Cairo.cairo_create(surface);
++	Cairo.cairo_surface_destroy(surface);
+ 	if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ 	if (device.tracking) device.new_Object(this);
+ }
+@@ -99,16 +102,23 @@
+ public void addArc(float x, float y, float width, float height, float startAngle, float arcAngle) {
+ 	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 	move = true;
+-	int /*long*/ matrix = Cairo.cairo_matrix_create();
+-	Cairo.cairo_current_matrix(handle, matrix);
+-	double lineWidth = Cairo.cairo_current_line_width(handle);
+-	Cairo.cairo_translate(handle, x + width / 2f, y + height / 2f);
+-	Cairo.cairo_scale(handle, width / 2f, height / 2f);
+-	Cairo.cairo_set_line_width(handle, lineWidth / (width / 2f));
+-	Cairo.cairo_arc_negative(handle, 0, 0, 1, -startAngle * (float)Compatibility.PI / 180, -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
+-	Cairo.cairo_set_line_width(handle, lineWidth);
+-	Cairo.cairo_set_matrix(handle, matrix);
+-	Cairo.cairo_destroy(matrix);
++	if (width == height) {
++		if (arcAngle >= 0) {
++			Cairo.cairo_arc_negative(handle, x + width / 2f, y + height / 2f, width / 2f, -startAngle * (float)Compatibility.PI / 180, -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
++		} else {
++			Cairo.cairo_arc(handle, x + width / 2f, y + height / 2f, width / 2f, -startAngle * (float)Compatibility.PI / 180, -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
++		}
++	} else {
++		Cairo.cairo_save(handle);
++		Cairo.cairo_translate(handle, x + width / 2f, y + height / 2f);
++		Cairo.cairo_scale(handle, width / 2f, height / 2f);
++		if (arcAngle >= 0) {
++			Cairo.cairo_arc_negative(handle, 0, 0, 1, -startAngle * (float)Compatibility.PI / 180, -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
++		} else {
++			Cairo.cairo_arc(handle, 0, 0, 1, -startAngle * (float)Compatibility.PI / 180, -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
++		}
++		Cairo.cairo_restore(handle);
++	}
+ }
+ 
+ /**
+@@ -129,7 +139,10 @@
+ 	if (path == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ 	if (path.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ 	move = false;
+-	Cairo.cairo_add_path(handle, path.handle);
++	int /*long*/ copy = Cairo.cairo_copy_path(path.handle);
++	if (copy == 0) SWT.error(SWT.ERROR_NO_HANDLES);
++	Cairo.cairo_append_path(handle, copy);
++	Cairo.cairo_path_destroy(copy);
+ }
+ 
+ /**
+@@ -174,7 +187,7 @@
+ 	move = false;
+ 	GC.setCairoFont(handle, font);
+ 	cairo_font_extents_t extents = new cairo_font_extents_t();
+-	Cairo.cairo_current_font_extents(handle, extents);
++	Cairo.cairo_font_extents(handle, extents);
+ 	double baseline = y + extents.ascent;
+ 	Cairo.cairo_move_to(handle, x, baseline);
+ 	byte[] buffer = Converter.wcsToMbcs(null, string, true);
+@@ -227,7 +240,10 @@
+ 	gc.initCairo();
+ 	boolean result = false;
+ 	int /*long*/ cairo = gc.data.cairo;
+-	Cairo.cairo_add_path(cairo, handle);
++	int /*long*/ copy = Cairo.cairo_copy_path(handle);
++	if (copy == 0) SWT.error(SWT.ERROR_NO_HANDLES);
++	Cairo.cairo_append_path(cairo, copy);
++	Cairo.cairo_path_destroy(copy);
+ 	if (outline) {
+ 		result = Cairo.cairo_in_stroke(cairo, x, y) != 0;		
+ 	} else {
+@@ -255,7 +271,7 @@
+ 	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 	if (!move) {
+ 		double[] currentX = new double[1], currentY = new double[1];
+-		Cairo.cairo_current_point(handle, currentX, currentY);
++		Cairo.cairo_get_current_point(handle, currentX, currentY);
+ 		Cairo.cairo_move_to(handle, currentX[0], currentY[0]);
+ 	}
+ 	move = true;
+@@ -281,12 +297,58 @@
+ 	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 	if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ 	if (bounds.length < 4) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+-	double[] extents = new double[4];
+-	Cairo.cairo_extents(handle, extents);
+-	bounds[0] = (float)extents[0];
+-	bounds[1] = (float)extents[1];
+-	bounds[2] = (float)(extents[2] - extents[0]);
+-	bounds[3] = (float)(extents[3] - extents[1]);
++	int /*long*/ copy = Cairo.cairo_copy_path(handle);
++	if (copy == 0) SWT.error(SWT.ERROR_NO_HANDLES);
++	cairo_path_t path = new cairo_path_t();
++	Cairo.memmove(path, copy, cairo_path_t.sizeof);
++	double minX = 0, minY = 0, maxX = 0, maxY = 0;
++	if (path.num_data > 0) {
++		int i = 0;
++		double[] points = new double[6]; 
++		cairo_path_data_t data = new cairo_path_data_t();
++		while (i < path.num_data) {
++			int /*long*/ offset = path.data + i * cairo_path_data_t.sizeof;
++			Cairo.memmove(data, offset, cairo_path_data_t.sizeof);
++			switch (data.type) {
++				case Cairo.CAIRO_PATH_MOVE_TO:
++					Cairo.memmove(points, offset + cairo_path_data_t.sizeof, cairo_path_data_t.sizeof);
++					minX = Math.min(minX, points[0]);
++					minY = Math.min(minY, points[1]);
++					maxX = Math.max(maxX, points[0]);
++					maxY = Math.max(maxY, points[1]);
++					break;
++				case Cairo.CAIRO_PATH_LINE_TO:
++					Cairo.memmove(points, offset + cairo_path_data_t.sizeof, cairo_path_data_t.sizeof);
++					minX = Math.min(minX, points[0]);
++					minY = Math.min(minY, points[1]);
++					maxX = Math.max(maxX, points[0]);
++					maxY = Math.max(maxY, points[1]);
++					break;
++				case Cairo.CAIRO_PATH_CURVE_TO:
++					Cairo.memmove(points, offset + cairo_path_data_t.sizeof, cairo_path_data_t.sizeof * 3);
++					minX = Math.min(minX, points[0]);
++					minY = Math.min(minY, points[1]);
++					maxX = Math.max(maxX, points[0]);
++					maxY = Math.max(maxY, points[1]);
++					minX = Math.min(minX, points[2]);
++					minY = Math.min(minY, points[3]);
++					maxX = Math.max(maxX, points[2]);
++					maxY = Math.max(maxY, points[3]);
++					minX = Math.min(minX, points[4]);
++					minY = Math.min(minY, points[5]);
++					maxX = Math.max(maxX, points[4]);
++					maxY = Math.max(maxY, points[5]);
++					break;
++				case Cairo.CAIRO_PATH_CLOSE_PATH: break;
++			}
++			i += data.length;
++		}
++	}
++	bounds[0] = (float)minX;
++	bounds[1] = (float)minY;
++	bounds[2] = (float)(maxX - minX);
++	bounds[3] = (float)(maxY - minY);
++	Cairo.cairo_path_destroy(copy);
+ }
+ 
+ /**
+@@ -308,7 +370,7 @@
+ 	if (point == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ 	if (point.length < 2) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ 	double[] x = new double[1], y = new double[1];
+-	Cairo.cairo_current_point(handle, x, y);
++	Cairo.cairo_get_current_point(handle, x, y);
+ 	point[0] = (float)x[0];
+ 	point[1] = (float)y[0];
+ }
+@@ -326,15 +388,64 @@
+  */
+ public PathData getPathData() {
+ 	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+-	int[] n_types = new int[1];
+-	int[] n_points = new int[1];
+-	Cairo.cairo_points(handle, n_types, n_points, null, null);
+-	byte[] types = new byte[n_types[0]];
+-	float[] points = new float[n_points[0] * 2];
+-	Cairo.cairo_points(handle, n_types, n_points, types, points);
++	int /*long*/ copy = Cairo.cairo_copy_path(handle);
++	if (copy == 0) SWT.error(SWT.ERROR_NO_HANDLES);
++	cairo_path_t path = new cairo_path_t();
++	Cairo.memmove(path, copy, cairo_path_t.sizeof);
++	byte[] types = new byte[path.num_data];
++	float[] pts = new float[path.num_data * 6];
++	int typeIndex = 0, ptsIndex = 0;
++	if (path.num_data > 0) {
++		int i = 0;
++		double[] points = new double[6]; 
++		cairo_path_data_t data = new cairo_path_data_t();
++		while (i < path.num_data) {
++			int /*long*/ offset = path.data + i * cairo_path_data_t.sizeof;
++			Cairo.memmove(data, offset, cairo_path_data_t.sizeof);
++			switch (data.type) {
++				case Cairo.CAIRO_PATH_MOVE_TO:
++					types[typeIndex++] = SWT.PATH_MOVE_TO;
++					Cairo.memmove(points, offset + cairo_path_data_t.sizeof, cairo_path_data_t.sizeof);
++					pts[ptsIndex++] = (float)points[0];
++					pts[ptsIndex++] = (float)points[1];
++					break;
++				case Cairo.CAIRO_PATH_LINE_TO:
++					types[typeIndex++] = SWT.PATH_LINE_TO;
++					Cairo.memmove(points, offset + cairo_path_data_t.sizeof, cairo_path_data_t.sizeof);
++					pts[ptsIndex++] = (float)points[0];
++					pts[ptsIndex++] = (float)points[1];
++					break;
++				case Cairo.CAIRO_PATH_CURVE_TO:
++					types[typeIndex++] = SWT.PATH_CUBIC_TO;
++					Cairo.memmove(points, offset + cairo_path_data_t.sizeof, cairo_path_data_t.sizeof * 3);
++					pts[ptsIndex++] = (float)points[0];
++					pts[ptsIndex++] = (float)points[1];
++					pts[ptsIndex++] = (float)points[2];
++					pts[ptsIndex++] = (float)points[3];
++					pts[ptsIndex++] = (float)points[4];
++					pts[ptsIndex++] = (float)points[5];
++					break;
++				case Cairo.CAIRO_PATH_CLOSE_PATH:
++					types[typeIndex++] = SWT.PATH_CLOSE;
++					break;
++			}
++			i += data.length;
++		}
++	}
++	if (typeIndex != types.length) {
++		byte[] newTypes = new byte[typeIndex];
++		System.arraycopy(types, 0, newTypes, 0, typeIndex);
++		types = newTypes;
++	}
++	if (ptsIndex != pts.length) {
++		float[] newPts = new float[ptsIndex];
++		System.arraycopy(pts, 0, newPts, 0, ptsIndex);
++		pts = newPts;
++	}
++	Cairo.cairo_path_destroy(copy);
+ 	PathData result = new PathData();
+ 	result.types = types;
+-	result.points = points;
++	result.points = pts;
+ 	return result;
+ }
+ 
+@@ -353,7 +464,7 @@
+ 	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 	if (!move) {
+ 		double[] currentX = new double[1], currentY = new double[1];
+-		Cairo.cairo_current_point(handle, currentX, currentY);
++		Cairo.cairo_get_current_point(handle, currentX, currentY);
+ 		Cairo.cairo_move_to(handle, currentX[0], currentY[0]);
+ 	}
+ 	move = true;
+@@ -400,7 +511,7 @@
+ public void quadTo(float cx, float cy, float x, float y) {
+ 	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 	double[] currentX = new double[1], currentY = new double[1];
+-	Cairo.cairo_current_point(handle, currentX, currentY);
++	Cairo.cairo_get_current_point(handle, currentX, currentY);
+ 	if (!move) {
+ 		Cairo.cairo_move_to(handle, currentX[0], currentY[0]);
+ 	}
+diff -P -r -u --exclude='*.rej' --exclude='*.orig' ../source-tree.orig/plugins/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Pattern.java source-tree/plugins/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Pattern.java
+--- ../source-tree.orig/plugins/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Pattern.java	2005-10-02 00:08:15.000000000 +0200
++++ source-tree/plugins/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Pattern.java	2005-10-02 00:10:44.000000000 +0200
+@@ -94,6 +94,9 @@
+  * @see #dispose()
+  */
+ public Pattern(Device device, float x1, float y1, float x2, float y2, Color color1, Color color2) {
++	this(device, x1, y1, x2, y2, color1, 0xFF, color2, 0xFF);
++}
++public Pattern(Device device, float x1, float y1, float x2, float y2, Color color1, int alpha1, Color color2, int alpha2) {
+ 	if (device == null) device = Device.getDevice();
+ 	if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ 	if (color1 == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+@@ -104,9 +107,8 @@
+ 	device.checkCairo();
+ 	handle = Cairo.cairo_pattern_create_linear(x1, y1, x2, y2);
+ 	if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+-	//TODO - how about alpha?
+-	GC.setCairoPatternColor(handle, 0, color1);
+-	GC.setCairoPatternColor(handle, 1, color2);
++	GC.setCairoPatternColor(handle, 0, color1, alpha1);
++	GC.setCairoPatternColor(handle, 1, color2, alpha2);
+ 	Cairo.cairo_pattern_set_extend(handle, Cairo.CAIRO_EXTEND_REPEAT);
+ 	if (device.tracking) device.new_Object(this);
+ }
+diff -P -r -u --exclude='*.rej' --exclude='*.orig' ../source-tree.orig/plugins/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Transform.java source-tree/plugins/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Transform.java
+--- ../source-tree.orig/plugins/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Transform.java	2005-10-02 00:08:15.000000000 +0200
++++ source-tree/plugins/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Transform.java	2005-10-02 00:10:44.000000000 +0200
+@@ -36,7 +36,7 @@
+ 	 * platforms and should never be accessed from application code.
+ 	 * </p>
+ 	 */
+-	public int /*long*/ handle;
++	public double[] handle;
+ 	
+ /**
+  * Constructs a new identity Transform.
+@@ -103,9 +103,9 @@
+ 	if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ 	this.device = device;
+ 	device.checkCairo();
+-	handle = Cairo.cairo_matrix_create();
+-	if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+-	Cairo.cairo_matrix_set_affine(handle, m11, m12, m21, m22, dx, dy);
++	handle = new double[6];
++	if (handle == null) SWT.error(SWT.ERROR_NO_HANDLES);
++	Cairo.cairo_matrix_init(handle, m11, m12, m21, m22, dx, dy);
+ 	if (device.tracking) device.new_Object(this);
+ }
+ 
+@@ -121,10 +121,9 @@
+  * they allocate.
+  */
+ public void dispose() {
+-	if (handle == 0) return;
++	if (handle == null) return;
+ 	if (device.isDisposed()) return;
+-	Cairo.cairo_matrix_destroy(handle);
+-	handle = 0;
++	handle = null;
+ 	if (device.tracking) device.dispose_Object(this);
+ 	device = null;
+ }
+@@ -148,15 +147,12 @@
+ 	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 	if (elements == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ 	if (elements.length < 6) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+-	double[] a = new double[1], b = new double[1], c = new double[1], d = new double[1];
+-	double[] tx = new double[1], ty = new double[1];
+-	Cairo.cairo_matrix_get_affine(handle, a, b, c, d, tx, ty);
+-	elements[0] = (float)a[0];
+-	elements[1] = (float)b[0];
+-	elements[2] = (float)c[0];
+-	elements[3] = (float)d[0];
+-	elements[4] = (float)tx[0];
+-	elements[5] = (float)ty[0];
++	elements[0] = (float)handle[0];
++	elements[1] = (float)handle[1];
++	elements[2] = (float)handle[2];
++	elements[3] = (float)handle[3];
++	elements[4] = (float)handle[4];
++	elements[5] = (float)handle[5];
+ }
+ 
+ /**
+@@ -186,7 +182,7 @@
+  * @return <code>true</code> when the Transform is disposed, and <code>false</code> otherwise
+  */
+ public boolean isDisposed() {
+-	return handle == 0;
++	return handle == null;
+ }
+ 
+ /**
+@@ -275,7 +271,7 @@
+  */
+ public void setElements(float m11, float m12, float m21, float m22, float dx, float dy) {
+ 	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+-	Cairo.cairo_matrix_set_affine(handle, m11, m12, m21, m22, dx, dy);
++	Cairo.cairo_matrix_init(handle, m11, m12, m21, m22, dx, dy);
+ }
+ 
+ /** 
+diff -P -r -u --exclude='*.rej' --exclude='*.orig' ../source-tree.orig/plugins/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GCData.java source-tree/plugins/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GCData.java
+--- ../source-tree.orig/plugins/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GCData.java	2005-10-02 00:08:13.000000000 +0200
++++ source-tree/plugins/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GCData.java	2005-10-02 00:10:44.000000000 +0200
+@@ -41,12 +41,13 @@
+ 	public int lineStyle = SWT.LINE_SOLID;
+ 	public int[] dashes;
+ 	public boolean xorMode;
++	public int alpha = 0xFF;
+ 	public int antialias = SWT.DEFAULT;
+ 	public int textAntialias = SWT.DEFAULT;
+ 	public int interpolation = SWT.DEFAULT;
+ 
+ 	public int /*long*/ cairo;
+-	public int /*long*/ matrix, inverseMatrix;
++	public double[] matrix, inverseMatrix;
+ 
+ 	public String string;
+ 	public int stringWidth = -1;
+diff -P -r -u --exclude='*.rej' --exclude='*.orig' ../source-tree.orig/plugins/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java source-tree/plugins/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
+--- ../source-tree.orig/plugins/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java	2005-10-02 00:08:13.000000000 +0200
++++ source-tree/plugins/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java	2005-10-02 00:10:44.000000000 +0200
+@@ -145,6 +145,7 @@
+ public static GC gtk_new(Drawable drawable, GCData data) {
+ 	GC gc = new GC();
+ 	int /*long*/ gdkGC = drawable.internal_new_GC(data);
++	gc.device = data.device;
+ 	gc.init(drawable, data, gdkGC);
+ 	return gc;
+ }
+@@ -268,11 +269,8 @@
+ 	
+ 	int /*long*/ cairo = data.cairo;
+ 	if (cairo != 0) Cairo.cairo_destroy(cairo);
+-	int /*long*/ matrix = data.matrix;
+-	if (matrix != 0) Cairo.cairo_matrix_destroy(matrix);
+-	int /*long*/ inverseMatrix = data.inverseMatrix;
+-	if (inverseMatrix != 0) Cairo.cairo_matrix_destroy(inverseMatrix);
+-	data.cairo = data.matrix = data.inverseMatrix = 0;
++	data.cairo = 0;
++	data.matrix = data.inverseMatrix = null;
+ 
+ 	/* Free resources */
+ 	int /*long*/ clipRgn = data.clipRgn;
+@@ -344,14 +342,25 @@
+ 	if (width == 0 || height == 0 || arcAngle == 0) return;
+ 	int /*long*/ cairo = data.cairo;
+ 	if (cairo != 0) {
+-		Cairo.cairo_save(cairo);
+ 		float offset = data.lineWidth == 0 || (data.lineWidth % 2) == 1 ? 0.5f : 0f;
+-		Cairo.cairo_translate(cairo, x + offset + width / 2f, y + offset + height / 2f);
+-		Cairo.cairo_scale(cairo, width / 2f, height / 2f);
+-		Cairo.cairo_set_line_width(cairo, Cairo.cairo_current_line_width(cairo) / (width / 2f));
+-		Cairo.cairo_arc_negative(cairo, 0, 0, 1, -startAngle * (float)Compatibility.PI / 180, -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
++		if (width == height) {
++            if (arcAngle >= 0) {
++                Cairo.cairo_arc_negative(cairo, x + offset + width / 2f, y + offset + height / 2f, width / 2f, -startAngle * (float)Compatibility.PI / 180, -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
++            } else { 
++                Cairo.cairo_arc(cairo, x + offset + width / 2f, y + offset + height / 2f, width / 2f, -startAngle * (float)Compatibility.PI / 180, -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
++            }
++		} else {
++			Cairo.cairo_save(cairo);
++			Cairo.cairo_translate(cairo, x + offset + width / 2f, y + offset + height / 2f);
++			Cairo.cairo_scale(cairo, width / 2f, height / 2f);
++            if (arcAngle >= 0) {
++                Cairo.cairo_arc_negative(cairo, 0, 0, 1, -startAngle * (float)Compatibility.PI / 180, -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
++            } else {
++                Cairo.cairo_arc(cairo, 0, 0, 1, -startAngle * (float)Compatibility.PI / 180, -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
++            }
++			Cairo.cairo_restore(cairo);
++		}
+ 		Cairo.cairo_stroke(cairo);
+-		Cairo.cairo_restore(cairo);
+ 		return;
+ 	}
+ 	OS.gdk_draw_arc(data.drawable, handle, 0, x, y, width, height, startAngle * 64, arcAngle * 64);
+@@ -472,6 +481,39 @@
+ 			SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ 		}
+  	}
++	int /*long*/ cairo = data.cairo;
++	if (cairo != 0) {
++		if (data.alpha != 0) {
++			srcImage.createSurface();
++			Cairo.cairo_save(cairo);
++			Cairo.cairo_rectangle(cairo, destX + 0.5, destY + 0.5, destWidth, destHeight);
++			Cairo.cairo_clip(cairo);
++			Cairo.cairo_translate(cairo, destX - srcX + 0.5, destY - srcY + 0.5);
++			if (srcWidth != destWidth || srcHeight != destHeight) {
++				Cairo.cairo_scale(cairo, destWidth / (float)srcWidth,  destHeight / (float)srcHeight);
++			}
++			int filter = Cairo.CAIRO_FILTER_GOOD;
++			switch (data.interpolation) {
++				case SWT.DEFAULT: filter = Cairo.CAIRO_FILTER_GOOD; break;
++				case SWT.NONE: filter = Cairo.CAIRO_FILTER_NEAREST; break;
++				case SWT.LOW: filter = Cairo.CAIRO_FILTER_FAST; break;
++				case SWT.HIGH: filter = Cairo.CAIRO_FILTER_BEST; break;
++			}
++			int /*long*/ pattern = Cairo.cairo_pattern_create_for_surface(srcImage.surface);
++			if (pattern == 0) SWT.error(SWT.ERROR_NO_HANDLES);
++			Cairo.cairo_pattern_set_filter(pattern, filter);
++			Cairo.cairo_pattern_set_extend(pattern, Cairo.CAIRO_EXTEND_REFLECT);
++			Cairo.cairo_set_source(cairo, pattern);
++			if (data.alpha != 0xFF) {
++				Cairo.cairo_paint_with_alpha(cairo, data.alpha / (float)0xFF);
++			} else {
++				Cairo.cairo_paint(cairo);
++			}
++			Cairo.cairo_restore(cairo);
++			Cairo.cairo_pattern_destroy(pattern);
++		}
++		return;
++	}
+ 	if (srcImage.alpha != -1 || srcImage.alphaData != null) {
+ 		drawImageAlpha(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight);
+ 	} else if (srcImage.transparentPixel != -1 || srcImage.mask != 0) {
+@@ -481,33 +523,6 @@
+ 	}
+ }
+ void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple, int imgWidth, int imgHeight) {
+-	int /*long*/ cairo = data.cairo;
+-	if (cairo != 0) {
+-		srcImage.createSurface();
+-		Cairo.cairo_save(cairo);
+-		//TODO - draw a piece of the image
+-//		if (srcX != 0 || srcY != 0) {
+-//			Cairo.cairo_rectangle(cairo, destX, destY, destWidth, destHeight);
+-//			Cairo.cairo_clip(cairo);
+-//			Cairo.cairo_new_path(cairo);
+-//		}
+-		//TODO - need 0.5 to draw at 0,0 with no transformation ???
+-		Cairo.cairo_translate(cairo, destX - srcX + 0.5, destY - srcY);
+-		if (srcWidth != destWidth || srcHeight != destHeight) {
+-			Cairo.cairo_scale(cairo, destWidth / (float)srcWidth,  destHeight / (float)srcHeight);
+-		}
+-		int filter = Cairo.CAIRO_FILTER_GOOD;
+-		switch (data.interpolation) {
+-			case SWT.DEFAULT: filter = Cairo.CAIRO_FILTER_GOOD; break;
+-			case SWT.NONE: filter = Cairo.CAIRO_FILTER_NEAREST; break;
+-			case SWT.LOW: filter = Cairo.CAIRO_FILTER_FAST; break;
+-			case SWT.HIGH: filter = Cairo.CAIRO_FILTER_BEST; break;
+-		}
+-		Cairo.cairo_surface_set_filter(srcImage.surface, filter);
+-		Cairo.cairo_show_surface(cairo, srcImage.surface, imgWidth, imgHeight);
+-		Cairo.cairo_restore(cairo);
+-		return;
+-	}
+ 	if (srcWidth == destWidth && srcHeight == destHeight) {
+ 		OS.gdk_draw_drawable(data.drawable, handle, srcImage.pixmap, srcX, srcY, destX, destY, destWidth, destHeight);
+ 	} else {
+@@ -718,14 +733,17 @@
+ 	}
+ 	int /*long*/ cairo = data.cairo;
+ 	if (cairo != 0) {
+-		Cairo.cairo_save(cairo);
+ 		float offset = data.lineWidth == 0 || (data.lineWidth % 2) == 1 ? 0.5f : 0f;
+-		Cairo.cairo_translate(cairo, x + offset + width / 2f, y + offset + height / 2f);
+-		Cairo.cairo_scale(cairo, width / 2f, height / 2f);
+-		Cairo.cairo_set_line_width(cairo, Cairo.cairo_current_line_width(cairo) / (width / 2f));
+-		Cairo.cairo_arc_negative(cairo, 0, 0, 1, 0, -2 * (float)Compatibility.PI);
++		if (width == height) {
++			Cairo.cairo_arc_negative(cairo, x + offset + width / 2f, y + offset + height / 2f, width / 2f, 0, -2 * (float)Compatibility.PI);
++		} else {
++			Cairo.cairo_save(cairo);
++			Cairo.cairo_translate(cairo, x + offset + width / 2f, y + offset + height / 2f);
++			Cairo.cairo_scale(cairo, width / 2f, height / 2f);
++			Cairo.cairo_arc_negative(cairo, 0, 0, 1, 0, -2 * (float)Compatibility.PI);
++			Cairo.cairo_restore(cairo);
++		}
+ 		Cairo.cairo_stroke(cairo);
+-		Cairo.cairo_restore(cairo);
+ 		return;
+ 	}
+ 	OS.gdk_draw_arc(data.drawable, handle, 0, x, y, width, height, 0, 23040);
+@@ -757,7 +775,10 @@
+ 	Cairo.cairo_save(cairo);
+ 	float offset = data.lineWidth == 0 || (data.lineWidth % 2) == 1 ? 0.5f : 0f;
+ 	Cairo.cairo_translate(cairo, offset, offset);
+-	Cairo.cairo_add_path(cairo, path.handle);
++	int /*long*/ copy = Cairo.cairo_copy_path(path.handle);
++	if (copy == 0) SWT.error(SWT.ERROR_NO_HANDLES);
++	Cairo.cairo_append_path(cairo, copy);
++	Cairo.cairo_path_destroy(copy);
+ 	Cairo.cairo_stroke(cairo);
+ 	Cairo.cairo_restore(cairo);
+ }
+@@ -964,13 +985,13 @@
+ 		Cairo.cairo_translate(cairo, nx + offset, ny + offset);
+ 		Cairo.cairo_scale(cairo, naw2, nah2);
+ 		Cairo.cairo_move_to(cairo, fw - 1, 0);
+-//		Cairo.cairo_arc_to(cairo, 0, 0, 0, 1, 1);
+-//		Cairo.cairo_arc_to(cairo, 0, fh, 1, fh, 1);
+-//		Cairo.cairo_arc_to(cairo, fw, fh, fw, fh - 1, 1);
+-//		Cairo.cairo_arc_to(cairo, fw, 0, fw - 1, 0, 1);
++	    Cairo.cairo_arc(cairo, fw - 1, 1, 1, Math.PI + Math.PI/2.0, Math.PI*2.0);
++	    Cairo.cairo_arc(cairo, fw - 1, fh - 1, 1, 0, Math.PI/2.0);
++	    Cairo.cairo_arc(cairo, 1, fh - 1, 1, Math.PI/2, Math.PI);
++	    Cairo.cairo_arc(cairo, 1, 1, 1, Math.PI, 270.0*Math.PI/180.0);
+ 		Cairo.cairo_close_path(cairo);
+-		Cairo.cairo_stroke(cairo);
+ 		Cairo.cairo_restore(cairo);
++		Cairo.cairo_stroke(cairo);
+ 		return;
+ 	}
+ 	int naw2 = naw / 2;
+@@ -1139,12 +1160,11 @@
+ 	if (cairo != 0) {
+ 		//TODO - honor flags
+ 		cairo_font_extents_t extents = new cairo_font_extents_t();
+-		Cairo.cairo_current_font_extents(cairo, extents);
++		Cairo.cairo_font_extents(cairo, extents);
+ 		double baseline = y + extents.ascent;
+ 		Cairo.cairo_move_to(cairo, x, baseline);
+ 		byte[] buffer = Converter.wcsToMbcs(null, string, true);
+-		Cairo.cairo_text_path(cairo, buffer);
+-		Cairo.cairo_fill(cairo);
++		Cairo.cairo_show_text(cairo, buffer);
+ 		return;
+ 	}
+ 	setString(string, flags);
+@@ -1251,18 +1271,32 @@
+ 	color.pixel = values.background_pixel;
+ 	int /*long*/ cairo = data.cairo;
+ 	if (cairo != 0) {
+-		int /*long*/ colormap = OS.gdk_colormap_get_system();
+-		OS.gdk_colormap_query_color(colormap, color.pixel, color);
++		if (width == height) {
++            if (arcAngle >= 0) {
++            	Cairo.cairo_arc_negative(cairo, x + width / 2f, y + height / 2f, width / 2f, -startAngle * (float)Compatibility.PI / 180,  -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
++            } else {
++            	Cairo.cairo_arc(cairo, x + width / 2f, y + height / 2f, width / 2f, -startAngle * (float)Compatibility.PI / 180,  -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
++            }
++			Cairo.cairo_line_to(cairo, x + width / 2f, y + height / 2f);
++		} else {
<<Diff was trimmed, longer than 597 lines>>



More information about the pld-cvs-commit mailing list