From 0504548696e73ed8e85a9f8d88ac00a2de9be404 Mon Sep 17 00:00:00 2001 From: Arun Thondapu Date: Mon, 14 Nov 2011 11:03:46 -0500 Subject: Bug 354978 - Use Cairo as backend for graphics operations (comment#5 patch) --- .../gtk/org/eclipse/swt/graphics/GC.java | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java') 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 995ef3f6d4..626664589f 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 @@ -448,7 +448,26 @@ public void copyArea(Image image, int x, int y) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (image.type != SWT.BITMAP || image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - //TODO fix for USE_CAIRO + if (OS.USE_CAIRO) { + int /*long*/ cairo = Cairo.cairo_create(image.surface); + if (data.image != null) { + Cairo.cairo_set_source_surface(cairo, data.image.surface, x, y); + } else if (OS.GTK_VERSION >= OS.VERSION(2, 24, 0)) { + OS.gdk_cairo_set_source_window(cairo, data.drawable, x, y); + } else { + int[] w = new int[1], h = new int[1]; + OS.gdk_drawable_get_size(data.drawable, w, h); + int width = w[0], height = h[0]; + int /*long*/ xDisplay = OS.GDK_DISPLAY(); + int /*long*/ xDrawable = OS.gdk_x11_drawable_get_xid(data.drawable); + int /*long*/ xVisual = OS.gdk_x11_visual_get_xvisual(OS.gdk_visual_get_system()); + int /*long*/ srcSurface = Cairo.cairo_xlib_surface_create(xDisplay, xDrawable, xVisual, width, height); + Cairo.cairo_set_source_surface(cairo, srcSurface, x, y); + } + Cairo.cairo_paint(cairo); + Cairo.cairo_destroy(cairo); + return; + } Rectangle rect = image.getBounds(); int /*long*/ gdkGC = OS.gdk_gc_new(image.pixmap); if (gdkGC == 0) SWT.error(SWT.ERROR_NO_HANDLES); -- cgit