summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilenio Quarti <silenio>2006-06-09 16:04:08 +0000
committerSilenio Quarti <silenio>2006-06-09 16:04:08 +0000
commit97b6f960eb84f0c679e3237277aa638f11493e36 (patch)
tree4eeae235ff59a1ec1aa6d56c64766e4e41ed638b
parent06674d2ebfecae9b037256972f960a0c65f4990b (diff)
downloadeclipse.platform.swt-97b6f960eb84f0c679e3237277aa638f11493e36.tar.gz
eclipse.platform.swt-97b6f960eb84f0c679e3237277aa638f11493e36.tar.xz
eclipse.platform.swt-97b6f960eb84f0c679e3237277aa638f11493e36.zip
create right PangoContext for cairo
-rw-r--r--bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c113
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java36
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java91
7 files changed, 217 insertions, 50 deletions
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties
index ee52c2347b..b019435d74 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties
@@ -4424,6 +4424,17 @@ OS__pango_attr_weight_new_0=
OS__pango_cairo_create_layout=flags=dynamic
OS__pango_cairo_create_layout_0=
+OS__pango_cairo_font_map_create_context=flags=dynamic
+OS__pango_cairo_font_map_create_context_0=
+
+OS__pango_cairo_font_map_get_default=flags=dynamic
+
+OS__pango_cairo_font_map_new=flags=dynamic
+
+OS__pango_cairo_font_map_set_resolution=flags=dynamic
+OS__pango_cairo_font_map_set_resolution_0=
+OS__pango_cairo_font_map_set_resolution_1=
+
OS__pango_cairo_layout_path=flags=dynamic
OS__pango_cairo_layout_path_0=
OS__pango_cairo_layout_path_1=
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
index 601afe1c94..0461f2e802 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
@@ -12704,6 +12704,119 @@ JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1cairo_1create_1layout)
}
#endif
+#ifndef NO__1pango_1cairo_1font_1map_1create_1context
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1cairo_1font_1map_1create_1context)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ jint rc = 0;
+ OS_NATIVE_ENTER(env, that, _1pango_1cairo_1font_1map_1create_1context_FUNC);
+/*
+ rc = (jint)pango_cairo_font_map_create_context(arg0);
+*/
+ {
+ static int initialized = 0;
+ static void *handle = NULL;
+ typedef jint (*FPTR)(jint);
+ static FPTR fptr;
+ rc = 0;
+ if (!initialized) {
+ if (!handle) handle = dlopen(pango_cairo_font_map_create_context_LIB, RTLD_LAZY);
+ if (handle) fptr = (FPTR)dlsym(handle, "pango_cairo_font_map_create_context");
+ initialized = 1;
+ }
+ if (fptr) {
+ rc = (jint)(*fptr)(arg0);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1pango_1cairo_1font_1map_1create_1context_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1pango_1cairo_1font_1map_1get_1default
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1cairo_1font_1map_1get_1default)
+ (JNIEnv *env, jclass that)
+{
+ jint rc = 0;
+ OS_NATIVE_ENTER(env, that, _1pango_1cairo_1font_1map_1get_1default_FUNC);
+/*
+ rc = (jint)pango_cairo_font_map_get_default();
+*/
+ {
+ static int initialized = 0;
+ static void *handle = NULL;
+ typedef jint (*FPTR)();
+ static FPTR fptr;
+ rc = 0;
+ if (!initialized) {
+ if (!handle) handle = dlopen(pango_cairo_font_map_get_default_LIB, RTLD_LAZY);
+ if (handle) fptr = (FPTR)dlsym(handle, "pango_cairo_font_map_get_default");
+ initialized = 1;
+ }
+ if (fptr) {
+ rc = (jint)(*fptr)();
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1pango_1cairo_1font_1map_1get_1default_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1pango_1cairo_1font_1map_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1cairo_1font_1map_1new)
+ (JNIEnv *env, jclass that)
+{
+ jint rc = 0;
+ OS_NATIVE_ENTER(env, that, _1pango_1cairo_1font_1map_1new_FUNC);
+/*
+ rc = (jint)pango_cairo_font_map_new();
+*/
+ {
+ static int initialized = 0;
+ static void *handle = NULL;
+ typedef jint (*FPTR)();
+ static FPTR fptr;
+ rc = 0;
+ if (!initialized) {
+ if (!handle) handle = dlopen(pango_cairo_font_map_new_LIB, RTLD_LAZY);
+ if (handle) fptr = (FPTR)dlsym(handle, "pango_cairo_font_map_new");
+ initialized = 1;
+ }
+ if (fptr) {
+ rc = (jint)(*fptr)();
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1pango_1cairo_1font_1map_1new_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1pango_1cairo_1font_1map_1set_1resolution
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1cairo_1font_1map_1set_1resolution)
+ (JNIEnv *env, jclass that, jint arg0, jdouble arg1)
+{
+ OS_NATIVE_ENTER(env, that, _1pango_1cairo_1font_1map_1set_1resolution_FUNC);
+/*
+ pango_cairo_font_map_set_resolution(arg0, arg1);
+*/
+ {
+ static int initialized = 0;
+ static void *handle = NULL;
+ typedef void (*FPTR)(jint, jdouble);
+ static FPTR fptr;
+ if (!initialized) {
+ if (!handle) handle = dlopen(pango_cairo_font_map_set_resolution_LIB, RTLD_LAZY);
+ if (handle) fptr = (FPTR)dlsym(handle, "pango_cairo_font_map_set_resolution");
+ initialized = 1;
+ }
+ if (fptr) {
+ (*fptr)(arg0, arg1);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1pango_1cairo_1font_1map_1set_1resolution_FUNC);
+}
+#endif
+
#ifndef NO__1pango_1cairo_1layout_1path
JNIEXPORT void JNICALL OS_NATIVE(_1pango_1cairo_1layout_1path)
(JNIEnv *env, jclass that, jint arg0, jint arg1)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
index 6cb8b75b12..755a711437 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
@@ -75,6 +75,10 @@
#define pango_cairo_create_layout_LIB "libpangocairo-1.0.so.0"
#define pango_cairo_layout_path_LIB "libpangocairo-1.0.so.0"
#define pango_cairo_show_layout_LIB "libpangocairo-1.0.so.0"
+#define pango_cairo_font_map_create_context_LIB "libpangocairo-1.0.so.0"
+#define pango_cairo_font_map_new_LIB "libpangocairo-1.0.so.0"
+#define pango_cairo_font_map_get_default_LIB "libpangocairo-1.0.so.0"
+#define pango_cairo_font_map_set_resolution_LIB "libpangocairo-1.0.so.0"
/* Field accessors */
#define GTK_ACCEL_LABEL_SET_ACCEL_STRING(arg0, arg1) (arg0)->accel_string = arg1
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
index d6f6bb66bd..bb82884752 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
@@ -18,8 +18,8 @@
#ifdef NATIVE_STATS
-int OS_nativeFunctionCount = 1108;
-int OS_nativeFunctionCallCount[1108];
+int OS_nativeFunctionCount = 1112;
+int OS_nativeFunctionCallCount[1112];
char * OS_nativeFunctionNames[] = {
"Call",
"GDK_1EVENT_1TYPE",
@@ -987,6 +987,10 @@ char * OS_nativeFunctionNames[] = {
"_1pango_1attr_1underline_1new",
"_1pango_1attr_1weight_1new",
"_1pango_1cairo_1create_1layout",
+ "_1pango_1cairo_1font_1map_1create_1context",
+ "_1pango_1cairo_1font_1map_1get_1default",
+ "_1pango_1cairo_1font_1map_1new",
+ "_1pango_1cairo_1font_1map_1set_1resolution",
"_1pango_1cairo_1layout_1path",
"_1pango_1cairo_1show_1layout",
"_1pango_1context_1get_1base_1dir",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
index 39de275409..2aed007a1f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
@@ -991,6 +991,10 @@ typedef enum {
_1pango_1attr_1underline_1new_FUNC,
_1pango_1attr_1weight_1new_FUNC,
_1pango_1cairo_1create_1layout_FUNC,
+ _1pango_1cairo_1font_1map_1create_1context_FUNC,
+ _1pango_1cairo_1font_1map_1get_1default_FUNC,
+ _1pango_1cairo_1font_1map_1new_FUNC,
+ _1pango_1cairo_1font_1map_1set_1resolution_FUNC,
_1pango_1cairo_1layout_1path_FUNC,
_1pango_1cairo_1show_1layout_FUNC,
_1pango_1context_1get_1base_1dir_FUNC,
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 ee228c450f..ffc01143a6 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
@@ -8571,6 +8571,33 @@ public static final int /*long*/ pango_attr_weight_new(int weight) {
lock.unlock();
}
}
+public static final native int /*long*/ _pango_cairo_font_map_get_default();
+public static final int /*long*/ pango_cairo_font_map_get_default() {
+ lock.lock();
+ try {
+ return _pango_cairo_font_map_get_default();
+ } finally {
+ lock.unlock();
+ }
+}
+public static final native int /*long*/ _pango_cairo_font_map_new();
+public static final int /*long*/ pango_cairo_font_map_new() {
+ lock.lock();
+ try {
+ return _pango_cairo_font_map_new();
+ } finally {
+ lock.unlock();
+ }
+}
+public static final native int /*long*/ _pango_cairo_font_map_create_context(int /*long*/ fontmap);
+public static final int /*long*/ pango_cairo_font_map_create_context(int /*long*/ fontmap) {
+ lock.lock();
+ try {
+ return _pango_cairo_font_map_create_context(fontmap);
+ } finally {
+ lock.unlock();
+ }
+}
public static final native int /*long*/ _pango_cairo_create_layout(int /*long*/ cairo);
public static final int /*long*/ pango_cairo_create_layout(int /*long*/ cairo) {
lock.lock();
@@ -8580,6 +8607,15 @@ public static final int /*long*/ pango_cairo_create_layout(int /*long*/ cairo) {
lock.unlock();
}
}
+public static final native void _pango_cairo_font_map_set_resolution(int /*long*/ fontmap, double dpi);
+public static final void pango_cairo_font_map_set_resolution(int /*long*/ fontmap, double dpi) {
+ lock.lock();
+ try {
+ _pango_cairo_font_map_set_resolution(fontmap, dpi);
+ } finally {
+ lock.unlock();
+ }
+}
public static final native void _pango_cairo_layout_path(int /*long*/ cairo, int /*long*/ layout);
public static final void pango_cairo_layout_path(int /*long*/ cairo, int /*long*/ layout) {
lock.lock();
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 1418373889..d4e33025ec 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
@@ -258,6 +258,36 @@ public void copyArea(int srcX, int srcY, int width, int height, int destX, int d
}
}
+void createLayout() {
+ int /*long*/ layout, context, cairo = data.cairo;
+ if (cairo != 0 && OS.GTK_VERSION >= OS.VERSION(2, 8, 0)) {
+ int /*long*/ fontmap = OS.pango_cairo_font_map_get_default();
+ context = OS.pango_cairo_font_map_create_context(fontmap);
+ } else {
+ context = OS.gdk_pango_context_get();
+ }
+ if (context == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ data.context = context;
+ layout = OS.pango_layout_new(context);
+ if (layout == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ data.layout = layout;
+ OS.pango_context_set_language(context, OS.gtk_get_default_language());
+ OS.pango_context_set_base_dir(context, OS.PANGO_DIRECTION_LTR);
+ OS.gdk_pango_context_set_colormap(context, OS.gdk_colormap_get_system());
+ if (OS.GTK_VERSION >= OS.VERSION(2, 4, 0)) {
+ OS.pango_layout_set_auto_dir(layout, false);
+ }
+ int /*long*/ font = data.font;
+ if (font != 0) OS.pango_layout_set_font_description(layout, font);
+}
+
+void disposeLayout() {
+ data.string = null;
+ if (data.context != 0) OS.g_object_unref(data.context);
+ if (data.layout != 0) OS.g_object_unref(data.layout);
+ data.layout = data.context = 0;
+}
+
/**
* Disposes of the operating system resources associated with
* the graphics context. Applications must dispose of all GCs
@@ -282,16 +312,13 @@ public void dispose() {
if (image.transparentPixel != -1) image.createMask();
}
- int /*long*/ context = data.context;
- if (context != 0) OS.g_object_unref(context);
- int /*long*/ layout = data.layout;
- if (layout != 0) OS.g_object_unref(layout);
+ disposeLayout();
/* Dispose the GC */
Device device = data.device;
drawable.internal_dispose_GC(handle, data);
- data.layout = data.context = data.drawable = data.clipRgn = 0;
+ data.drawable = data.clipRgn = 0;
drawable = null;
handle = 0;
data.image = null;
@@ -2105,6 +2132,7 @@ public Font getFont() {
*/
public FontMetrics getFontMetrics() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (data.context == 0) createLayout();
int /*long*/ context = data.context;
int /*long*/ lang = OS.pango_context_get_language(context);
int /*long*/ metrics = OS.pango_context_get_metrics(context, data.font, lang);
@@ -2433,25 +2461,10 @@ public int hashCode() {
}
void init(Drawable drawable, GCData data, int /*long*/ gdkGC) {
- int /*long*/ context = OS.gdk_pango_context_get();
- if (context == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- OS.pango_context_set_language(context, OS.gtk_get_default_language());
- OS.pango_context_set_base_dir(context, OS.PANGO_DIRECTION_LTR);
- OS.gdk_pango_context_set_colormap(context, OS.gdk_colormap_get_system());
- data.context = context;
- int /*long*/ layout = data.cairo != 0 ? OS.pango_cairo_create_layout(data.cairo) : OS.pango_layout_new(context);
- if (layout == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- data.layout = layout;
-
- if (OS.GTK_VERSION >= OS.VERSION(2, 4, 0)) {
- OS.pango_layout_set_auto_dir(layout, false);
- }
GdkColor foreground = data.foreground;
if (foreground != null) OS.gdk_gc_set_foreground(gdkGC, foreground);
GdkColor background = data.background;
- if (background != null) OS.gdk_gc_set_background(gdkGC, background);
- int /*long*/ font = data.font;
- if (font != 0) OS.pango_layout_set_font_description(layout, font);
+ if (background != null) OS.gdk_gc_set_background(gdkGC, background);
Image image = data.image;
if (image != null) {
@@ -2497,19 +2510,7 @@ void initCairo() {
Cairo.cairo_surface_destroy(surface);
if (cairo == 0) SWT.error(SWT.ERROR_NO_HANDLES);
data.disposeCairo = true;
- if (OS.GTK_VERSION >= OS.VERSION(2, 8, 0)) {
- int /*long*/ oldlayout = data.layout;
- if (oldlayout != 0) OS.g_object_unref(oldlayout);
- int /*long*/ layout = OS.pango_cairo_create_layout(data.cairo);
- if (layout == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- data.layout = layout;
- data.string = null;
- int /*long*/ font = data.font;
- if (font != 0) OS.pango_layout_set_font_description(layout, font);
- if (OS.GTK_VERSION >= OS.VERSION(2, 4, 0)) {
- OS.pango_layout_set_auto_dir(layout, false);
- }
- }
+ disposeLayout();
Cairo.cairo_set_fill_rule(cairo, Cairo.CAIRO_FILL_RULE_EVEN_ODD);
GdkGCValues values = new GdkGCValues();
OS.gdk_gc_get_values(handle, values);
@@ -2540,7 +2541,9 @@ void initCairo() {
}
Cairo.cairo_set_dash(cairo, dashes, dashes.length, 0);
}
- setCairoFont(cairo, data.font);
+ if (OS.GTK_VERSION < OS.VERSION(2, 8, 0)) {
+ setCairoFont(cairo, data.font);
+ }
setCairoClip(cairo, data.clipRgn);
}
@@ -2639,18 +2642,7 @@ public void setAdvanced(boolean advanced) {
data.interpolation = SWT.DEFAULT;
data.backgroundPattern = data.foregroundPattern = null;
setClipping(0);
- if (OS.GTK_VERSION >= OS.VERSION(2, 8, 0)) {
- int /*long*/ context = data.context;
- int /*long*/ oldlayout = data.layout;
- if (oldlayout != 0) OS.g_object_unref(oldlayout);
- int /*long*/ layout = OS.pango_layout_new(context);
- if (layout == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- data.layout = layout;
- data.string = null;
- if (OS.GTK_VERSION >= OS.VERSION(2, 4, 0)) {
- OS.pango_layout_set_auto_dir(layout, false);
- }
- }
+ disposeLayout();
}
}
@@ -2974,7 +2966,9 @@ public void setFont(Font font) {
if (font == null) font = data.device.systemFont;
if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
int /*long*/ fontHandle = data.font = font.handle;
- OS.pango_layout_set_font_description(data.layout, fontHandle);
+ if (data.layout != 0) {
+ OS.pango_layout_set_font_description(data.layout, fontHandle);
+ }
data.stringWidth = data.stringHeight = -1;
if (OS.GTK_VERSION < OS.VERSION(2, 8, 0)) {
int /*long*/ cairo = data.cairo;
@@ -3362,6 +3356,7 @@ public void setLineWidth(int lineWidth) {
}
void setString(String string, int flags) {
+ if (data.layout == 0) createLayout();
if (string == data.string && (flags & ~SWT.DRAW_TRANSPARENT) == (data.drawFlags & ~SWT.DRAW_TRANSPARENT)) {
return;
}