summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilenio Quarti <Silenio_Quarti@ca.ibm.com>2011-10-21 14:59:49 -0400
committerSilenio Quarti <Silenio_Quarti@ca.ibm.com>2011-10-21 14:59:49 -0400
commitabfdcfb2a80c73d1ca40740cee6b7363f053a0e4 (patch)
treeb325423da22d2d81758119f56ffa996fe8f8d561
parentbce33e0833e5ea22e197f70bbd36284a765724a8 (diff)
downloadeclipse.platform.swt-abfdcfb2a80c73d1ca40740cee6b7363f053a0e4.tar.gz
eclipse.platform.swt-abfdcfb2a80c73d1ca40740cee6b7363f053a0e4.tar.xz
eclipse.platform.swt-abfdcfb2a80c73d1ca40740cee6b7363f053a0e4.zip
fix Control.setBackgroundImage()
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo.c20
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_custom.h1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.c5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.h1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cairo/org/eclipse/swt/internal/cairo/Cairo.java13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java31
7 files changed, 68 insertions, 4 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo.c
index cfefce37a6..375feecc23 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo.c
@@ -1775,6 +1775,26 @@ JNIEXPORT jintLong JNICALL Cairo_NATIVE(_1cairo_1xlib_1surface_1create_1for_1bit
}
#endif
+#ifndef NO__1cairo_1xlib_1surface_1get_1drawable
+JNIEXPORT jintLong JNICALL Cairo_NATIVE(_1cairo_1xlib_1surface_1get_1drawable)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jintLong rc = 0;
+ Cairo_NATIVE_ENTER(env, that, _1cairo_1xlib_1surface_1get_1drawable_FUNC);
+/*
+ rc = (jintLong)cairo_xlib_surface_get_drawable((cairo_surface_t *)arg0);
+*/
+ {
+ Cairo_LOAD_FUNCTION(fp, cairo_xlib_surface_get_drawable)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(cairo_surface_t *))fp)((cairo_surface_t *)arg0);
+ }
+ }
+ Cairo_NATIVE_EXIT(env, that, _1cairo_1xlib_1surface_1get_1drawable_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1cairo_1xlib_1surface_1get_1height
JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1xlib_1surface_1get_1height)
(JNIEnv *env, jclass that, jintLong arg0)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_custom.h b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_custom.h
index c16af1c283..ad41fb9fc5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_custom.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_custom.h
@@ -36,6 +36,7 @@
#define cairo_image_surface_get_data_LIB LIB_CAIRO
#define cairo_image_surface_get_format_LIB LIB_CAIRO
#define cairo_image_surface_get_stride_LIB LIB_CAIRO
+#define cairo_xlib_surface_get_drawable_LIB LIB_CAIRO
#define cairo_xlib_surface_get_height_LIB LIB_CAIRO
#define cairo_xlib_surface_get_width_LIB LIB_CAIRO
#define cairo_surface_get_content_LIB LIB_CAIRO \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.c
index ce3627f4a9..efa425155e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.c
@@ -24,8 +24,8 @@
#ifdef NATIVE_STATS
-int Cairo_nativeFunctionCount = 152;
-int Cairo_nativeFunctionCallCount[152];
+int Cairo_nativeFunctionCount = 153;
+int Cairo_nativeFunctionCallCount[153];
char * Cairo_nativeFunctionNames[] = {
"CAIRO_1VERSION_1ENCODE",
"_1cairo_1append_1path",
@@ -168,6 +168,7 @@ char * Cairo_nativeFunctionNames[] = {
"_1cairo_1user_1to_1device_1distance",
"_1cairo_1xlib_1surface_1create",
"_1cairo_1xlib_1surface_1create_1for_1bitmap",
+ "_1cairo_1xlib_1surface_1get_1drawable",
"_1cairo_1xlib_1surface_1get_1height",
"_1cairo_1xlib_1surface_1get_1width",
"_1cairo_1xlib_1surface_1set_1size",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.h
index 435725ae82..27b582cb6a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.h
@@ -176,6 +176,7 @@ typedef enum {
_1cairo_1user_1to_1device_1distance_FUNC,
_1cairo_1xlib_1surface_1create_FUNC,
_1cairo_1xlib_1surface_1create_1for_1bitmap_FUNC,
+ _1cairo_1xlib_1surface_1get_1drawable_FUNC,
_1cairo_1xlib_1surface_1get_1height_FUNC,
_1cairo_1xlib_1surface_1get_1width_FUNC,
_1cairo_1xlib_1surface_1set_1size_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/org/eclipse/swt/internal/cairo/Cairo.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/org/eclipse/swt/internal/cairo/Cairo.java
index c52f924977..1ed26761c6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/org/eclipse/swt/internal/cairo/Cairo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/org/eclipse/swt/internal/cairo/Cairo.java
@@ -1627,6 +1627,19 @@ public static final void cairo_xlib_surface_set_size(int /*long*/ surface, int w
* @method flags=dynamic
* @param surface cast=(cairo_surface_t *)
*/
+public static final native int /*long*/ _cairo_xlib_surface_get_drawable(int /*long*/ surface);
+public static final int /*long*/ cairo_xlib_surface_get_drawable(int /*long*/ surface) {
+ lock.lock();
+ try {
+ return _cairo_xlib_surface_get_drawable(surface);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ * @param surface cast=(cairo_surface_t *)
+ */
public static final native int _cairo_xlib_surface_get_height(int /*long*/ surface);
public static final int cairo_xlib_surface_get_height(int /*long*/ surface) {
lock.lock();
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 084b3c59de..8f4c8f4059 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
@@ -1440,6 +1440,7 @@ void init(ImageData image) {
}
}
OS.memmove(data, buffer, stride * height);
+ //TODO convert to XLIB surface if opaque for better performance
return;
}
int /*long*/ pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, false, 8, width, height);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
index 3b60996697..07688d5c99 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
@@ -114,6 +114,10 @@ void drawBackground (Control control, int /*long*/ window, int /*long*/ region,
if (cairo == 0) error (SWT.ERROR_NO_HANDLES);
if (region != 0) OS.gdk_cairo_region(cairo, region);
if (control.backgroundImage != null) {
+ Point pt = display.map (this, control, 0, 0);
+ Cairo.cairo_translate (cairo, -pt.x, -pt.y);
+ x += pt.x;
+ y += pt.y;
int /*long*/ pattern = Cairo.cairo_pattern_create_for_surface (control.backgroundImage.surface);
if (pattern == 0) error (SWT.ERROR_NO_HANDLES);
Cairo.cairo_pattern_set_extend (pattern, Cairo.CAIRO_EXTEND_REPEAT);
@@ -3810,7 +3814,18 @@ void setBackgroundPixmap (Image image) {
if (image.pixmap != 0) {
OS.gdk_window_set_back_pixmap (window, image.pixmap, false);
} else if (image.surface != 0) {
- //TODO we need to either create xlib surfaces for opaque images in Image.java or create a pixmap from the surface
+ // TODO background pixmap does not have colormap. For now draw background in windowProc()
+ // Another option would be to create a pixmap from the surface
+// int /*long*/ surface = image.surface;
+// int type = Cairo.cairo_surface_get_type(surface);
+// switch (type) {
+// case Cairo.CAIRO_SURFACE_TYPE_XLIB:
+// int /*long*/ pixmap = OS.gdk_pixmap_foreign_new(Cairo.cairo_xlib_surface_get_drawable(surface));
+// OS.gdk_window_set_back_pixmap (window, pixmap, false);
+// OS.g_object_unref(pixmap);
+// break;
+// }
+//
}
}
}
@@ -5032,7 +5047,19 @@ void updateLayout (boolean all) {
int /*long*/ windowProc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ user_data) {
switch ((int)/*64*/user_data) {
case EXPOSE_EVENT_INVERSE: {
- if ((OS.GTK_VERSION < OS.VERSION (2, 8, 0)) && ((state & OBSCURED) == 0)) {
+ if ((state & OBSCURED) != 0) break;
+ if (OS.USE_CAIRO) {
+ Control control = findBackgroundControl ();
+ if (control != null && control.backgroundImage != null) {
+ GdkEventExpose gdkEvent = new GdkEventExpose ();
+ OS.memmove (gdkEvent, arg0, GdkEventExpose.sizeof);
+ int /*long*/ paintWindow = paintWindow();
+ int /*long*/ window = gdkEvent.window;
+ if (window != paintWindow) break;
+ drawBackground(control, window, gdkEvent.region, gdkEvent.area_y, gdkEvent.area_y, gdkEvent.area_width, gdkEvent.area_height);
+ }
+ }
+ if (OS.GTK_VERSION < OS.VERSION (2, 8, 0)) {
Control control = findBackgroundControl ();
if (control != null && control.backgroundImage != null) {
GdkEventExpose gdkEvent = new GdkEventExpose ();