summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Fitzsimmons <fitzsim@redhat.com>2006-05-25 15:29:35 +0000
committerThomas Fitzsimmons <fitzsim@redhat.com>2006-05-25 15:29:35 +0000
commitac0458b48bb89814a0e46637af1de173dce48f5c (patch)
tree1a1f4699fa86eb4f8defa551be7fe73f0feddd2f
parentb328da9bdcbab6bbab0aa50546e19a326343b507 (diff)
downloadclasspath-ac0458b48bb89814a0e46637af1de173dce48f5c.tar.gz
2006-05-25 Thomas Fitzsimmons <fitzsim@redhat.com>
* INSTALL: Bump GTK requirement to 2.8 or higher. Do not mention Cairo version requirement. Do not mention --enable-gtk-cairo configure option. * NEWS: Add entry for GdkGraphics2D. * configure.ac: Remove --enable-gtk-cairo and explicit checks for Cairo library and headers. * .externalToolBuilders/Configure.launch: Remove --enable-gtk-cairo from configure line. * gnu/classpath/Configuration.java.in (GTK_CAIRO_ENABLED): Remove field. * gnu/java/awt/BitwiseXORComposite.java: Fix javadoc typo. * gnu/java/awt/peer/gtk/GdkFontPeer.java, native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c : Remove useGraphics2D references. Always assume Graphics2D is enabled. * gnu/java/awt/peer/gtk/GdkGraphics.java, native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c: Remove. * gnu/java/awt/peer/gtk/GdkGraphics2D.java, native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c: Remove Unlocked method variants. Remove GTK_CAIRO_ENABLED and useGraphics2D references. Always assume Graphics2D is enabled. * gnu/java/awt/peer/gtk/GdkTextLayout.java: Remove instanceof Graphics2D check. Always assume Graphics2D is enabled. * gnu/java/awt/peer/gtk/GtkCanvasPeer.java, native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c (realize): Remove method. * gnu/java/awt/peer/gtk/GtkComponentPeer.java, native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c (isRealized): Remove method. (realize): Implement as a native method. Remove useGraphics2D references. Always assume Graphics2D is enabled. * gnu/java/awt/peer/gtk/GtkImage.java, native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c: Replace GdkGraphics references with GdkGraphics2D references. * gnu/java/awt/peer/gtk/GtkToolkit.java, native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c: Remove useGraphics2D references. Always assume Graphics2D is enabled. * include/Makefile.am (GTKPEER_H_FILES): Remove gnu_java_awt_peer_gtk_GdkGraphics.h. * include/gnu_java_awt_peer_gtk_GdkFontPeer.h: Regenerate. * include/gnu_java_awt_peer_gtk_GdkGraphics.h: Remove. * include/gnu_java_awt_peer_gtk_GdkGraphics2D.h: Regenerate. * include/gnu_java_awt_peer_gtk_GtkCanvasPeer.h: Likewise. * include/gnu_java_awt_peer_gtk_GtkComponentPeer.h: Likewise. * native/jawt/Makefile.am (AM_LDFLAGS): Remove CAIRO_LIBS. * native/jni/gtk-peer/Makefile.am (libgtkpeer_la_SOURCES): Remove gnu_java_awt_peer_gtk_GdkGraphics.c. Include gnu_java_awt_peer_gtk_GdkGraphics2D.c unconditionally. (AM_LDFLAGS): Remove CAIRO_LIBS. (AM_CFLAGS): Remove CAIRO_CFLAGS. * native/jni/gtk-peer/gtkcairopeer.h: Remove. Move declarations to ... * native/jni/gtk-peer/gtkpeer.h: Add Graphics2D declarations.
-rw-r--r--.externalToolBuilders/Configure.launch15
-rw-r--r--ChangeLog55
-rw-r--r--INSTALL6
-rw-r--r--NEWS4
-rw-r--r--configure.ac24
-rw-r--r--gnu/classpath/Configuration.java.in6
-rw-r--r--gnu/java/awt/BitwiseXORComposite.java2
-rw-r--r--gnu/java/awt/peer/gtk/GdkFontPeer.java11
-rw-r--r--gnu/java/awt/peer/gtk/GdkGraphics.java519
-rw-r--r--gnu/java/awt/peer/gtk/GdkGraphics2D.java201
-rw-r--r--gnu/java/awt/peer/gtk/GdkTextLayout.java57
-rw-r--r--gnu/java/awt/peer/gtk/GtkCanvasPeer.java1
-rw-r--r--gnu/java/awt/peer/gtk/GtkComponentPeer.java22
-rw-r--r--gnu/java/awt/peer/gtk/GtkImage.java10
-rw-r--r--gnu/java/awt/peer/gtk/GtkToolkit.java49
-rw-r--r--include/Makefile.am1
-rw-r--r--include/gnu_java_awt_peer_gtk_GdkFontPeer.h4
-rw-r--r--include/gnu_java_awt_peer_gtk_GdkGraphics.h47
-rw-r--r--include/gnu_java_awt_peer_gtk_GdkGraphics2D.h12
-rw-r--r--include/gnu_java_awt_peer_gtk_GtkCanvasPeer.h1
-rw-r--r--include/gnu_java_awt_peer_gtk_GtkComponentPeer.h2
-rw-r--r--native/jawt/Makefile.am4
-rw-r--r--native/jni/gtk-peer/Makefile.am18
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c21
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c758
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c506
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c14
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c38
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c40
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c4
-rw-r--r--native/jni/gtk-peer/gtkcairopeer.h93
-rw-r--r--native/jni/gtk-peer/gtkpeer.h75
32 files changed, 377 insertions, 2243 deletions
diff --git a/.externalToolBuilders/Configure.launch b/.externalToolBuilders/Configure.launch
index 96bcda0fe..d2347ae84 100644
--- a/.externalToolBuilders/Configure.launch
+++ b/.externalToolBuilders/Configure.launch
@@ -1,2 +1,13 @@
-<?xml version='1.0'?>
-<launchConfiguration type='org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType'><stringAttribute key='org.eclipse.debug.core.ATTR_REFRESH_SCOPE' value='${project}'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS' value='full,incremental,auto,'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE' value='${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;launchConfigurationWorkingSet factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; name=&quot;workingSet&quot; editPageId=&quot;org.eclipse.ui.resourceWorkingSetPage&quot;&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/classpath/Makefile.in&quot; type=&quot;1&quot;/&gt;&#10;&lt;/launchConfigurationWorkingSet&gt;}'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_LOCATION' value='${build_project}/configure'/><booleanAttribute key='org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED' value='true'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY' value='${build_project}'/><booleanAttribute key='org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED' value='true'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS' value='--prefix=${build_project}/install --enable-regen-headers --enable-gtk-cairo'/><booleanAttribute key='org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND' value='false'/><booleanAttribute key='org.eclipse.debug.core.appendEnvironmentVariables' value='true'/></launchConfiguration> \ No newline at end of file
+<?xml version="1.0" encoding="UTF-8"?>
+<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
+<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="true"/>
+<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;launchConfigurationWorkingSet editPageId=&quot;org.eclipse.ui.resourceWorkingSetPage&quot; factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; name=&quot;workingSet&quot;&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/classpath/Makefile.in&quot; type=&quot;1&quot;/&gt;&#10;&lt;/launchConfigurationWorkingSet&gt;}"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="--prefix=${build_project}/install --enable-regen-headers --with-ecj"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,"/>
+<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${project}"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${build_project}"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${build_project}/configure"/>
+<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
+<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+</launchConfiguration>
diff --git a/ChangeLog b/ChangeLog
index 6eae9f2e4..fa592d8b6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,58 @@
+2006-05-25 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * INSTALL: Bump GTK requirement to 2.8 or higher. Do not mention
+ Cairo version requirement. Do not mention --enable-gtk-cairo
+ configure option.
+ * NEWS: Add entry for GdkGraphics2D.
+ * configure.ac: Remove --enable-gtk-cairo and explicit checks for
+ Cairo library and headers.
+ * .externalToolBuilders/Configure.launch: Remove
+ --enable-gtk-cairo from configure line.
+ * gnu/classpath/Configuration.java.in (GTK_CAIRO_ENABLED): Remove
+ field.
+ * gnu/java/awt/BitwiseXORComposite.java: Fix javadoc typo.
+ * gnu/java/awt/peer/gtk/GdkFontPeer.java,
+ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c : Remove
+ useGraphics2D references. Always assume Graphics2D is enabled.
+ * gnu/java/awt/peer/gtk/GdkGraphics.java,
+ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c: Remove.
+ * gnu/java/awt/peer/gtk/GdkGraphics2D.java,
+ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c: Remove
+ Unlocked method variants. Remove GTK_CAIRO_ENABLED and
+ useGraphics2D references. Always assume Graphics2D is enabled.
+ * gnu/java/awt/peer/gtk/GdkTextLayout.java: Remove instanceof
+ Graphics2D check. Always assume Graphics2D is enabled.
+ * gnu/java/awt/peer/gtk/GtkCanvasPeer.java,
+ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c
+ (realize): Remove method.
+ * gnu/java/awt/peer/gtk/GtkComponentPeer.java,
+ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
+ (isRealized): Remove method.
+ (realize): Implement as a native method. Remove useGraphics2D
+ references. Always assume Graphics2D is enabled.
+ * gnu/java/awt/peer/gtk/GtkImage.java,
+ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c: Replace
+ GdkGraphics references with GdkGraphics2D references.
+ * gnu/java/awt/peer/gtk/GtkToolkit.java,
+ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c: Remove
+ useGraphics2D references. Always assume Graphics2D is enabled.
+ * include/Makefile.am (GTKPEER_H_FILES): Remove
+ gnu_java_awt_peer_gtk_GdkGraphics.h.
+ * include/gnu_java_awt_peer_gtk_GdkFontPeer.h: Regenerate.
+ * include/gnu_java_awt_peer_gtk_GdkGraphics.h: Remove.
+ * include/gnu_java_awt_peer_gtk_GdkGraphics2D.h: Regenerate.
+ * include/gnu_java_awt_peer_gtk_GtkCanvasPeer.h: Likewise.
+ * include/gnu_java_awt_peer_gtk_GtkComponentPeer.h: Likewise.
+ * native/jawt/Makefile.am (AM_LDFLAGS): Remove CAIRO_LIBS.
+ * native/jni/gtk-peer/Makefile.am (libgtkpeer_la_SOURCES): Remove
+ gnu_java_awt_peer_gtk_GdkGraphics.c. Include
+ gnu_java_awt_peer_gtk_GdkGraphics2D.c unconditionally.
+ (AM_LDFLAGS): Remove CAIRO_LIBS.
+ (AM_CFLAGS): Remove CAIRO_CFLAGS.
+ * native/jni/gtk-peer/gtkcairopeer.h: Remove. Move declarations
+ to ...
+ * native/jni/gtk-peer/gtkpeer.h: Add Graphics2D declarations.
+
2006-05-25 Lillian Angel <langel@redhat.com>
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
diff --git a/INSTALL b/INSTALL
index 7dabbf866..97983fdce 100644
--- a/INSTALL
+++ b/INSTALL
@@ -46,14 +46,11 @@ Suggested Software
are required unless --disable-gtk-peer is used as an argument to
configure.
- - GTK+ 2.4.x (or higher)
+ - GTK+ 2.8.x (or higher)
- gdk-pixbuf
- XTest Extension (libXtst) for GdkRobot support in java.awt.
- For building the Cairo GdkGraphics2D backend you need at least
- Cairo 0.5.0.
-
For building gcjwebplugin you'll need the Mozilla plugin
support headers and libraries.
@@ -116,7 +113,6 @@ gives a complete list.
--enable-java compile Java source default=yes
--enable-jni compile JNI source default=yes
--enable-gtk-peer compile GTK native peers default=yes
- --enable-gtk-cairo compile cairo based Graphics2D default=no
--enable-qt-peer compile Qt4 native peers default=no
--enable-default-toolkit
fully qualified class name of default AWT toolkit
diff --git a/NEWS b/NEWS
index 2f5d3e093..aad12db29 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,9 @@
New in release 0.92 (UNRELEASED)
+* The GdkGraphics2D backend has been made the default. There is no
+ longer an explicit dependency on Cairo, the --enable-gtk-cairo
+ configure option is gone, and GTK 2.8 or higher is now required to
+ build the GTK peers.
* A Mozilla plugin, 'gcjwebplugin', is now included. It introduces a
dependency on the Mozilla plugin support headers and libraries.
* Several new tools are now included:
diff --git a/configure.ac b/configure.ac
index 75d5b1d8e..c2b344ac8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -165,23 +165,6 @@ dnl GTK native peer error checking
dnl -----------------------------------------------------------
AC_ARG_ENABLE([gtk-peers],,AC_MSG_ERROR([No --enable-gtk-peers (or --disable-gtk-peers) option; you want --enable-gtk-peer]))
-dnl ------------------------------------------------------------
-dnl determine whether to enable the cairo GTK Graphics2D backend
-dnl ------------------------------------------------------------
-AC_ARG_ENABLE([gtk-cairo],
- [AS_HELP_STRING(--enable-gtk-cairo,build the cairo Graphics2D implementation on GTK [default=no])],
- [case "${enableval}" in
- yes) GTK_CAIRO_ENABLED=true ;;
- no) GTK_CAIRO_ENABLED=false ;;
- *) GTK_CAIRO_ENABLED=true ;;
- esac],
- [GTK_CAIRO_ENABLED=false])
-AC_SUBST(GTK_CAIRO_ENABLED)
-if test "x${GTK_CAIRO_ENABLED}" = xtrue; then
- AC_DEFINE(GTK_CAIRO, 1, [defined if cairo support was built in])
-fi
-AM_CONDITIONAL(GTK_CAIRO, test "x${GTK_CAIRO_ENABLED}" = xtrue)
-
dnl -----------------------------------------------------------
dnl Qt native peer (disabled by default)
dnl -----------------------------------------------------------
@@ -401,18 +384,11 @@ if test "x${COMPILE_JNI}" = xyes; then
[AC_MSG_ERROR([libXtst NOT found, required for GdkRobot])],
[${X_LIBS}])
PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.4 gthread-2.0 >= 2.2 gdk-pixbuf-2.0)
-
- if test "x${enable_gtk_cairo}" = xyes; then
- PKG_CHECK_MODULES(CAIRO, cairo >= 0.5.0)
- fi
-
PKG_CHECK_MODULES(FREETYPE2, freetype2)
PKG_CHECK_MODULES(PANGOFT2, pangoft2)
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
- AC_SUBST(CAIRO_LIBS)
- AC_SUBST(CAIRO_CFLAGS)
AC_SUBST(FREETYPE2_LIBS)
AC_SUBST(FREETYPE2_CFLAGS)
AC_SUBST(PANGOFT2_LIBS)
diff --git a/gnu/classpath/Configuration.java.in b/gnu/classpath/Configuration.java.in
index 569ccf541..7f490d529 100644
--- a/gnu/classpath/Configuration.java.in
+++ b/gnu/classpath/Configuration.java.in
@@ -95,10 +95,4 @@ public interface Configuration
*/
boolean JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION =
@JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION@;
-
- /**
- * Set to true if Cairo was found and enabled during configure,
- * false otherwise.
- */
- boolean GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@;
}
diff --git a/gnu/java/awt/BitwiseXORComposite.java b/gnu/java/awt/BitwiseXORComposite.java
index b568e1108..9205df1dd 100644
--- a/gnu/java/awt/BitwiseXORComposite.java
+++ b/gnu/java/awt/BitwiseXORComposite.java
@@ -59,7 +59,7 @@ import java.awt.image.WritableRaster;
* />
*
* <p>The above screen shot shows the result of applying six different
- * BitwiseXORComposites. They were constructed with the colors colors
+ * BitwiseXORComposites. They were constructed with the colors
* white, blue, black, orange, green, and brown, respectively. Each
* composite was used to paint a fully white rectangle on top of the
* blue bar in the background.
diff --git a/gnu/java/awt/peer/gtk/GdkFontPeer.java b/gnu/java/awt/peer/gtk/GdkFontPeer.java
index f85ee24bf..544efa3c9 100644
--- a/gnu/java/awt/peer/gtk/GdkFontPeer.java
+++ b/gnu/java/awt/peer/gtk/GdkFontPeer.java
@@ -85,15 +85,14 @@ public class GdkFontPeer extends ClasspathFontPeer
private native void initState ();
private native void dispose ();
- private native void setFont (String family, int style, int size, boolean useGraphics2D);
+ private native void setFont (String family, int style, int size);
native void getFontMetrics(double [] metrics);
native void getTextMetrics(String str, double [] metrics);
protected void finalize ()
{
- if (GtkToolkit.useGraphics2D ())
- GdkGraphics2D.releasePeerGraphicsResource(this);
+ GdkGraphics2D.releasePeerGraphicsResource(this);
dispose ();
}
@@ -143,16 +142,14 @@ public class GdkFontPeer extends ClasspathFontPeer
{
super(name, style, size);
initState ();
- setFont (this.familyName, this.style, (int)this.size,
- GtkToolkit.useGraphics2D());
+ setFont (this.familyName, this.style, (int)this.size);
}
public GdkFontPeer (String name, Map attributes)
{
super(name, attributes);
initState ();
- setFont (this.familyName, this.style, (int)this.size,
- GtkToolkit.useGraphics2D());
+ setFont (this.familyName, this.style, (int)this.size);
}
/**
diff --git a/gnu/java/awt/peer/gtk/GdkGraphics.java b/gnu/java/awt/peer/gtk/GdkGraphics.java
deleted file mode 100644
index a5b9ff135..000000000
--- a/gnu/java/awt/peer/gtk/GdkGraphics.java
+++ /dev/null
@@ -1,519 +0,0 @@
-/* GdkGraphics.java
- Copyright (C) 1998, 1999, 2002, 2005 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package gnu.java.awt.peer.gtk;
-
-import gnu.classpath.Configuration;
-import gnu.java.awt.AWTUtilities;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Font;
-import java.awt.FontMetrics;
-import java.awt.Graphics;
-import java.awt.Image;
-import java.awt.Rectangle;
-import java.awt.Shape;
-import java.awt.Toolkit;
-import java.awt.image.ImageObserver;
-import java.text.AttributedCharacterIterator;
-
-public class GdkGraphics extends Graphics
-{
- static
- {
- if (Configuration.INIT_LOAD_LIBRARY)
- {
- System.loadLibrary("gtkpeer");
- }
- initStaticState ();
- }
-
- static native void initStaticState();
- private final int native_state = GtkGenericPeer.getUniqueInteger ();
-
- Color color, xorColor;
- GtkComponentPeer component;
- Font font = new Font ("Dialog", Font.PLAIN, 12);
- Rectangle clip;
- GtkImage image;
-
- int xOffset = 0;
- int yOffset = 0;
-
- static final int GDK_COPY = 0, GDK_XOR = 2;
-
- native void initState (GtkComponentPeer component);
- native void initStateUnlocked (GtkComponentPeer component);
- native void initState (int width, int height);
- native void initFromImage (GtkImage image);
- native void nativeCopyState (GdkGraphics g);
-
- /**
- * A cached instance that is used by {@link #create} in order to avoid
- * massive allocation of graphics contexts.
- */
- GdkGraphics cached = null;
-
- /**
- * A link to the parent context. This is used in {@link #dispose} to put
- * this graphics context into the cache.
- */
- GdkGraphics parent = null;
-
- GdkGraphics (GdkGraphics g)
- {
- parent = g;
- copyState (g);
- }
-
- GdkGraphics (int width, int height)
- {
- initState (width, height);
- color = Color.black;
- clip = new Rectangle (0, 0, width, height);
- font = new Font ("Dialog", Font.PLAIN, 12);
- }
-
- GdkGraphics (GtkImage image)
- {
- this.image = image;
- initFromImage (image);
- color = Color.black;
- clip = new Rectangle (0, 0,
- image.getWidth(null), image.getHeight(null));
- font = new Font ("Dialog", Font.PLAIN, 12);
- }
-
- GdkGraphics (GtkComponentPeer component)
- {
- this.component = component;
- color = Color.black;
-
- if (component.isRealized ())
- initComponentGraphics ();
- else
- connectSignals (component);
- }
-
- void initComponentGraphics ()
- {
- initState (component);
- color = component.awtComponent.getForeground ();
- if (color == null)
- color = Color.BLACK;
- Dimension d = component.awtComponent.getSize ();
- clip = new Rectangle (0, 0, d.width, d.height);
- }
-
- // called back by native side: realize_cb
- void initComponentGraphicsUnlocked ()
- {
- initStateUnlocked (component);
- color = component.awtComponent.getForeground ();
- if (color == null)
- color = Color.BLACK;
- Dimension d = component.awtComponent.getSize ();
- clip = new Rectangle (0, 0, d.width, d.height);
- }
-
- native void connectSignals (GtkComponentPeer component);
-
- public native void clearRect(int x, int y, int width, int height);
-
- public void clipRect (int x, int y, int width, int height)
- {
- if (component != null && ! component.isRealized ())
- return;
-
- computeIntersection(x, y, width, height, clip);
- setClipRectangle (clip.x, clip.y, clip.width, clip.height);
- }
-
- public native void copyArea(int x, int y, int width, int height,
- int dx, int dy);
-
- /**
- * Creates a copy of this GdkGraphics instance. This implementation can
- * reuse a cached instance to avoid massive instantiation of Graphics objects
- * during painting.
- *
- * @return a copy of this graphics context
- */
- public Graphics create()
- {
- GdkGraphics copy = cached;
- if (copy == null)
- copy = new GdkGraphics(this);
- else
- {
- copy.copyState(this);
- cached = null;
- }
- return copy;
- }
-
- public native void nativeDispose();
-
- /**
- * Disposes this graphics object. This puts this graphics context into the
- * cache of its parent graphics if there is one.
- */
- public void dispose()
- {
- if (parent != null)
- {
- parent.cached = this;
- parent = null;
- }
- else
- nativeDispose();
- }
-
- /**
- * This is called when this object gets finalized by the garbage collector.
- * In addition to {@link Graphics#finalize()} this calls nativeDispose() to
- * make sure the native resources are freed before the graphics context is
- * thrown away.
- */
- public void finalize()
- {
- super.finalize();
- nativeDispose();
- }
-
- public boolean drawImage (Image img, int x, int y,
- Color bgcolor, ImageObserver observer)
- {
- if (img != null)
- return drawImage(img, x, y, img.getWidth(null), img.getHeight(null),
- bgcolor, observer);
- return false;
- }
-
- public boolean drawImage (Image img, int x, int y, ImageObserver observer)
- {
- return drawImage (img, x, y, null, observer);
- }
-
- public boolean drawImage(Image img, int x, int y, int width, int height,
- Color bgcolor, ImageObserver observer)
- {
- if (img != null)
- {
- if (img instanceof GtkImage)
- return ((GtkImage) img).drawImage(this, x, y, width, height, bgcolor,
- observer);
- return (new GtkImage(img.getSource())).drawImage(this, x, y, width,
- height, bgcolor,
- observer);
- }
- return false;
- }
-
- public boolean drawImage (Image img, int x, int y, int width, int height,
- ImageObserver observer)
- {
- return drawImage (img, x, y, width, height, null, observer);
- }
-
- public boolean drawImage (Image img, int dx1, int dy1, int dx2, int dy2,
- int sx1, int sy1, int sx2, int sy2,
- Color bgcolor, ImageObserver observer)
- {
- if (img != null)
- {
- if (img instanceof GtkImage)
- return ((GtkImage) img).drawImage(this, dx1, dy1, dx2, dy2, sx1, sy1,
- sx2, sy2, bgcolor, observer);
- return (new GtkImage(img.getSource())).drawImage(this, dx1, dy1, dx2,
- dy2, sx1, sy1, sx2,
- sy2, bgcolor, observer);
- }
- return false;
- }
-
- public boolean drawImage (Image img, int dx1, int dy1, int dx2, int dy2,
- int sx1, int sy1, int sx2, int sy2,
- ImageObserver observer)
- {
- return drawImage (img, dx1, dy1, dx2, dy2,
- sx1, sy1, sx2, sy2,
- null, observer);
- }
-
- public native void drawLine(int x1, int y1, int x2, int y2);
-
- public native void drawArc(int x, int y, int width, int height,
- int startAngle, int arcAngle);
- public native void fillArc(int x, int y, int width, int height,
- int startAngle, int arcAngle);
- public native void drawOval(int x, int y, int width, int height);
- public native void fillOval(int x, int y, int width, int height);
-
- public native void drawPolygon(int[] xPoints, int[] yPoints, int nPoints);
- public native void fillPolygon(int[] xPoints, int[] yPoints, int nPoints);
-
- public native void drawPolyline(int[] xPoints, int[] yPoints, int nPoints);
-
- public native void drawRect(int x, int y, int width, int height);
- public native void fillRect(int x, int y, int width, int height);
-
- GdkFontPeer getFontPeer()
- {
- return (GdkFontPeer) getFont().getPeer();
- }
-
- native void drawString (GdkFontPeer f, String str, int x, int y);
- public void drawString (String str, int x, int y)
- {
- drawString(getFontPeer(), str, x, y);
- }
-
- public void drawString (AttributedCharacterIterator ci, int x, int y)
- {
- throw new Error ("not implemented");
- }
-
- public void drawRoundRect(int x, int y, int width, int height,
- int arcWidth, int arcHeight)
- {
- if (arcWidth > width)
- arcWidth = width;
- if (arcHeight > height)
- arcHeight = height;
-
- int xx = x + width - arcWidth;
- int yy = y + height - arcHeight;
-
- drawArc (x, y, arcWidth, arcHeight, 90, 90);
- drawArc (xx, y, arcWidth, arcHeight, 0, 90);
- drawArc (xx, yy, arcWidth, arcHeight, 270, 90);
- drawArc (x, yy, arcWidth, arcHeight, 180, 90);
-
- int y1 = y + arcHeight / 2;
- int y2 = y + height - arcHeight / 2;
- drawLine (x, y1, x, y2);
- drawLine (x + width, y1, x + width, y2);
-
- int x1 = x + arcWidth / 2;
- int x2 = x + width - arcWidth / 2;
- drawLine (x1, y, x2, y);
- drawLine (x1, y + height, x2, y + height);
- }
-
- public void fillRoundRect (int x, int y, int width, int height,
- int arcWidth, int arcHeight)
- {
- if (arcWidth > width)
- arcWidth = width;
- if (arcHeight > height)
- arcHeight = height;
-
- int xx = x + width - arcWidth;
- int yy = y + height - arcHeight;
-
- fillArc (x, y, arcWidth, arcHeight, 90, 90);
- fillArc (xx, y, arcWidth, arcHeight, 0, 90);
- fillArc (xx, yy, arcWidth, arcHeight, 270, 90);
- fillArc (x, yy, arcWidth, arcHeight, 180, 90);
-
- fillRect (x, y + arcHeight / 2, width, height - arcHeight + 1);
- fillRect (x + arcWidth / 2, y, width - arcWidth + 1, height);
- }
-
- public Shape getClip ()
- {
- return getClipBounds ();
- }
-
- public Rectangle getClipBounds ()
- {
- if (clip == null)
- return null;
- else
- return clip.getBounds();
- }
-
- public Color getColor ()
- {
- return color;
- }
-
- public Font getFont ()
- {
- return font;
- }
-
- public FontMetrics getFontMetrics (Font font)
- {
- // Get the font metrics through GtkToolkit to take advantage of
- // the metrics cache.
- return Toolkit.getDefaultToolkit().getFontMetrics (font);
- }
-
- native void setClipRectangle (int x, int y, int width, int height);
-
- public void setClip (int x, int y, int width, int height)
- {
- if ((component != null && ! component.isRealized ())
- || clip == null)
- return;
-
- clip.x = x;
- clip.y = y;
- clip.width = width;
- clip.height = height;
-
- setClipRectangle (x, y, width, height);
- }
-
- public void setClip (Rectangle clip)
- {
- setClip (clip.x, clip.y, clip.width, clip.height);
- }
-
- public void setClip (Shape clip)
- {
- if (clip == null)
- {
- // Reset clipping.
- Dimension d = component.awtComponent.getSize();
- setClip(new Rectangle (0, 0, d.width, d.height));
- }
- else
- setClip(clip.getBounds());
- }
-
- private native void setFGColor(int red, int green, int blue);
-
- public void setColor (Color c)
- {
- if (c == null)
- color = Color.BLACK;
- else
- color = c;
-
- if (xorColor == null) /* paint mode */
- setFGColor (color.getRed (), color.getGreen (), color.getBlue ());
- else /* xor mode */
- setFGColor (color.getRed () ^ xorColor.getRed (),
- color.getGreen () ^ xorColor.getGreen (),
- color.getBlue () ^ xorColor.getBlue ());
- }
-
- public void setFont (Font font)
- {
- if (font != null)
- this.font = font;
- }
-
- native void setFunction (int gdk_func);
-
- public void setPaintMode ()
- {
- xorColor = null;
-
- setFunction (GDK_COPY);
- setFGColor (color.getRed (), color.getGreen (), color.getBlue ());
- }
-
- public void setXORMode (Color c)
- {
- xorColor = c;
-
- setFunction (GDK_XOR);
- setFGColor (color.getRed () ^ xorColor.getRed (),
- color.getGreen () ^ xorColor.getGreen (),
- color.getBlue () ^ xorColor.getBlue ());
- }
-
- public native void translateNative(int x, int y);
-
- public void translate (int x, int y)
- {
- if (component != null && ! component.isRealized ())
- return;
-
- clip.x -= x;
- clip.y -= y;
-
- translateNative (x, y);
- }
-
- /**
- * Copies over the state of another GdkGraphics to this instance. This is
- * used by the {@link #GdkGraphics(GdkGraphics)} constructor and the
- * {@link #create()} method.
- *
- * @param g the GdkGraphics object to copy the state from
- */
- private void copyState(GdkGraphics g)
- {
- color = g.color;
- xorColor = g.xorColor;
- font = g.font;
- if (font == null)
- font = new Font ("Dialog", Font.PLAIN, 12);
- clip = new Rectangle (g.clip);
- component = g.component;
- nativeCopyState(g);
- }
-
- private Rectangle computeIntersection(int x, int y, int w, int h,
- Rectangle rect)
- {
- int x2 = (int) rect.x;
- int y2 = (int) rect.y;
- int w2 = (int) rect.width;
- int h2 = (int) rect.height;
-
- int dx = (x > x2) ? x : x2;
- int dy = (y > y2) ? y : y2;
- int dw = (x + w < x2 + w2) ? (x + w - dx) : (x2 + w2 - dx);
- int dh = (y + h < y2 + h2) ? (y + h - dy) : (y2 + h2 - dy);
-
- if (dw >= 0 && dh >= 0)
- rect.setBounds(dx, dy, dw, dh);
- else
- rect.setBounds(0, 0, 0, 0);
-
- return rect;
- }
-
-}
diff --git a/gnu/java/awt/peer/gtk/GdkGraphics2D.java b/gnu/java/awt/peer/gtk/GdkGraphics2D.java
index 323d5614a..0a42d7fd5 100644
--- a/gnu/java/awt/peer/gtk/GdkGraphics2D.java
+++ b/gnu/java/awt/peer/gtk/GdkGraphics2D.java
@@ -100,10 +100,6 @@ public class GdkGraphics2D extends Graphics2D
static
{
- if (! Configuration.GTK_CAIRO_ENABLED)
- throw new Error("Graphics2D not implemented. "
- + "Cairo was not found or disabled at configure time");
-
if (Configuration.INIT_LOAD_LIBRARY)
System.loadLibrary("gtkpeer");
@@ -132,15 +128,12 @@ public class GdkGraphics2D extends Graphics2D
Composite comp;
private Stack stateStack;
- private native void initStateUnlocked(GtkComponentPeer component);
private native void initState(GtkComponentPeer component);
private native void initState(int width, int height);
private native void initState(int[] pixes, int width, int height);
private native void copyState(GdkGraphics2D g);
public native void dispose();
private native void cairoSurfaceSetFilter(int filter);
- private native void cairoSurfaceSetFilterUnlocked(int filter);
- native void connectSignals(GtkComponentPeer component);
public void finalize()
{
@@ -157,19 +150,8 @@ public class GdkGraphics2D extends Graphics2D
return new GdkGraphics2D(this, x, y, width, height);
}
- private void fail_g2d ()
- {
- System.err.println ("Attempted to instantiate GdkGraphics2D"
- + " but Graphics2D not enabled. Try again with"
- + " -Dgnu.java.awt.peer.gtk.Graphics=Graphics2D");
- System.exit (1);
- }
-
GdkGraphics2D(GdkGraphics2D g)
{
- if (!GtkToolkit.useGraphics2D ())
- fail_g2d ();
-
paint = g.paint;
stroke = g.stroke;
setRenderingHints(g.hints);
@@ -221,9 +203,6 @@ public class GdkGraphics2D extends Graphics2D
GdkGraphics2D(int width, int height)
{
- if (!GtkToolkit.useGraphics2D ())
- fail_g2d ();
-
initState(width, height);
setColor(Color.black);
@@ -239,15 +218,9 @@ public class GdkGraphics2D extends Graphics2D
GdkGraphics2D(GtkComponentPeer component)
{
- if (!GtkToolkit.useGraphics2D ())
- fail_g2d ();
-
this.component = component;
- if (component.isRealized())
- initComponentGraphics2D();
- else
- connectSignals(component);
+ initComponentGraphics2D();
}
void initComponentGraphics2D()
@@ -265,21 +238,6 @@ public class GdkGraphics2D extends Graphics2D
stateStack = new Stack();
}
- void initComponentGraphics2DUnlocked()
- {
- initStateUnlocked(component);
-
- setColorUnlocked(component.awtComponent.getForeground());
- setBackgroundUnlocked(component.awtComponent.getBackground());
- setPaintUnlocked(getColorUnlocked());
- setTransformUnlocked(new AffineTransform());
- setStrokeUnlocked(new BasicStroke());
- setRenderingHintsUnlocked(getDefaultHints());
- setFontUnlocked(new Font("SansSerif", Font.PLAIN, 12));
-
- stateStack = new Stack();
- }
-
GdkGraphics2D(BufferedImage bimage)
{
this.bimage = bimage;
@@ -324,37 +282,25 @@ public class GdkGraphics2D extends Graphics2D
// drawing utility methods
private native void drawPixels(int[] pixels, int w, int h, int stride,
double[] i2u);
- private native void setTexturePixelsUnlocked(int[] pixels, int w, int h, int stride);
private native void setTexturePixels(int[] pixels, int w, int h, int stride);
private native void setGradient(double x1, double y1, double x2, double y2,
int r1, int g1, int b1, int a1, int r2,
int g2, int b2, int a2, boolean cyclic);
- private native void setGradientUnlocked(double x1, double y1, double x2, double y2,
- int r1, int g1, int b1, int a1, int r2,
- int g2, int b2, int a2, boolean cyclic);
-
+
// simple passthroughs to cairo
private native void cairoSave();
private native void cairoRestore();
private native void cairoSetMatrix(double[] m);
- private native void cairoSetMatrixUnlocked(double[] m);
private native void cairoSetOperator(int cairoOperator);
private native void cairoSetRGBAColor(double red, double green,
double blue, double alpha);
- private native void cairoSetRGBAColorUnlocked(double red, double green,
- double blue, double alpha);
private native void cairoSetFillRule(int cairoFillRule);
private native void cairoSetLineWidth(double width);
- private native void cairoSetLineWidthUnlocked(double width);
private native void cairoSetLineCap(int cairoLineCap);
- private native void cairoSetLineCapUnlocked(int cairoLineCap);
private native void cairoSetLineJoin(int cairoLineJoin);
- private native void cairoSetLineJoinUnlocked(int cairoLineJoin);
private native void cairoSetDash(double[] dashes, int ndash, double offset);
- private native void cairoSetDashUnlocked(double[] dashes, int ndash, double offset);
private native void cairoSetMiterLimit(double limit);
- private native void cairoSetMiterLimitUnlocked(double limit);
private native void cairoNewPath();
private native void cairoMoveTo(double x, double y);
private native void cairoLineTo(double x, double y);
@@ -745,49 +691,6 @@ public class GdkGraphics2D extends Graphics2D
throw new java.lang.UnsupportedOperationException();
}
- public void setPaintUnlocked(Paint p)
- {
- if (paint == null)
- return;
-
- paint = p;
- if (paint instanceof Color)
- {
- setColorUnlocked((Color) paint);
- }
- else if (paint instanceof TexturePaint)
- {
- TexturePaint tp = (TexturePaint) paint;
- BufferedImage img = tp.getImage();
-
- // map the image to the anchor rectangle
- int width = (int) tp.getAnchorRect().getWidth();
- int height = (int) tp.getAnchorRect().getHeight();
-
- double scaleX = width / (double) img.getWidth();
- double scaleY = width / (double) img.getHeight();
-
- AffineTransform at = new AffineTransform(scaleX, 0, 0, scaleY, 0, 0);
- AffineTransformOp op = new AffineTransformOp(at, getRenderingHints());
- BufferedImage texture = op.filter(img, null);
- int[] pixels = texture.getRGB(0, 0, width, height, null, 0, width);
- setTexturePixelsUnlocked(pixels, width, height, width);
- }
- else if (paint instanceof GradientPaint)
- {
- GradientPaint gp = (GradientPaint) paint;
- Point2D p1 = gp.getPoint1();
- Point2D p2 = gp.getPoint2();
- Color c1 = gp.getColor1();
- Color c2 = gp.getColor2();
- setGradientUnlocked(p1.getX(), p1.getY(), p2.getX(), p2.getY(), c1.getRed(),
- c1.getGreen(), c1.getBlue(), c1.getAlpha(), c2.getRed(),
- c2.getGreen(), c2.getBlue(), c2.getAlpha(), gp.isCyclic());
- }
- else
- throw new java.lang.UnsupportedOperationException();
- }
-
public void setTransform(AffineTransform tx)
{
transform = tx;
@@ -799,17 +702,6 @@ public class GdkGraphics2D extends Graphics2D
}
}
- public void setTransformUnlocked(AffineTransform tx)
- {
- transform = tx;
- if (transform != null)
- {
- double[] m = new double[6];
- transform.getMatrix(m);
- cairoSetMatrixUnlocked(m);
- }
- }
-
public void transform(AffineTransform tx)
{
if (transform == null)
@@ -899,42 +791,18 @@ public class GdkGraphics2D extends Graphics2D
}
}
- public void setStrokeUnlocked(Stroke st)
- {
- stroke = st;
- if (stroke instanceof BasicStroke)
- {
- BasicStroke bs = (BasicStroke) stroke;
- cairoSetLineCapUnlocked(bs.getEndCap());
- cairoSetLineWidthUnlocked(bs.getLineWidth());
- cairoSetLineJoinUnlocked(bs.getLineJoin());
- cairoSetMiterLimitUnlocked(bs.getMiterLimit());
- float[] dashes = bs.getDashArray();
- if (dashes != null)
- {
- double[] double_dashes = new double[dashes.length];
- for (int i = 0; i < dashes.length; i++)
- double_dashes[i] = dashes[i];
- cairoSetDashUnlocked(double_dashes, double_dashes.length,
- (double) bs.getDashPhase());
- }
- else
- cairoSetDashUnlocked(new double[0], 0, 0.0);
- }
- }
-
////////////////////////////////////////////////
////// Implementation of Graphics Methods //////
////////////////////////////////////////////////
public void setPaintMode()
{
- setComposite(java.awt.AlphaComposite.SrcOver);
+ setComposite(AlphaComposite.SrcOver);
}
public void setXORMode(Color c)
{
- setComposite(new gnu.java.awt.BitwiseXORComposite(c));
+ // FIXME: implement
}
public void setColor(Color c)
@@ -948,27 +816,11 @@ public class GdkGraphics2D extends Graphics2D
fg.getBlue() / 255.0, fg.getAlpha() / 255.0);
}
- public void setColorUnlocked(Color c)
- {
- if (c == null)
- c = Color.BLACK;
-
- fg = c;
- paint = c;
- cairoSetRGBAColorUnlocked(fg.getRed() / 255.0, fg.getGreen() / 255.0,
- fg.getBlue() / 255.0, fg.getAlpha() / 255.0);
- }
-
public Color getColor()
{
return fg;
}
- public Color getColorUnlocked()
- {
- return getColor();
- }
-
public void clipRect(int x, int y, int width, int height)
{
clip(new Rectangle(x, y, width, height));
@@ -1096,11 +948,6 @@ public class GdkGraphics2D extends Graphics2D
bg = c;
}
- public void setBackgroundUnlocked(Color c)
- {
- setBackground(c);
- }
-
public Color getBackground()
{
return bg;
@@ -1290,7 +1137,10 @@ public class GdkGraphics2D extends Graphics2D
(int) (a.getAlpha() * ((float) c.getAlpha()))));
}
else
- throw new java.lang.UnsupportedOperationException();
+ {
+ // FIXME: implement general Composite support
+ throw new java.lang.UnsupportedOperationException();
+ }
}
public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
@@ -1355,36 +1205,6 @@ public class GdkGraphics2D extends Graphics2D
|| hints.containsValue(RenderingHints.VALUE_STROKE_DEFAULT);
}
- public void setRenderingHintsUnlocked(Map hints)
- {
- this.hints = new RenderingHints(getDefaultHints());
- this.hints.add(new RenderingHints(hints));
-
- if (hints.containsKey(RenderingHints.KEY_INTERPOLATION))
- {
- if (hints.containsValue(RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR))
- cairoSurfaceSetFilterUnlocked(0);
-
- else if (hints.containsValue(RenderingHints.VALUE_INTERPOLATION_BILINEAR))
- cairoSurfaceSetFilterUnlocked(1);
- }
-
- if (hints.containsKey(RenderingHints.KEY_ALPHA_INTERPOLATION))
- {
- if (hints.containsValue(RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED))
- cairoSurfaceSetFilterUnlocked(2);
-
- else if (hints.containsValue(RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY))
- cairoSurfaceSetFilterUnlocked(3);
-
- else if (hints.containsValue(RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT))
- cairoSurfaceSetFilterUnlocked(4);
- }
-
- shiftDrawCalls = hints.containsValue(RenderingHints.VALUE_STROKE_NORMALIZE)
- || hints.containsValue(RenderingHints.VALUE_STROKE_DEFAULT);
- }
-
public void addRenderingHints(Map hints)
{
this.hints.add(new RenderingHints(hints));
@@ -1657,11 +1477,6 @@ public class GdkGraphics2D extends Graphics2D
.getFont(f.getName(), f.getAttributes());
}
- public void setFontUnlocked(Font f)
- {
- setFont (f);
- }
-
public String toString()
{
return (getClass().getName()
diff --git a/gnu/java/awt/peer/gtk/GdkTextLayout.java b/gnu/java/awt/peer/gtk/GdkTextLayout.java
index c3ae581b1..9189bd4b7 100644
--- a/gnu/java/awt/peer/gtk/GdkTextLayout.java
+++ b/gnu/java/awt/peer/gtk/GdkTextLayout.java
@@ -201,60 +201,9 @@ public class GdkTextLayout
public void draw (Graphics2D g2, float x, float y)
{
- if (g2 instanceof GdkGraphics2D)
- {
- // we share pango structures directly with GdkGraphics2D
- // when legal
- GdkGraphics2D gg2 = (GdkGraphics2D) g2;
- gg2.drawGdkTextLayout(this, x, y);
- }
- else
- {
- // falling back to a rather tedious layout algorithm when
- // not legal
- AttributedCharacterIterator ci = attributedString.getIterator ();
- CharacterIteratorProxy proxy = new CharacterIteratorProxy (ci);
- Font defFont = g2.getFont ();
-
- /* Note: this implementation currently only interprets FONT text
- * attributes. There is a reasonable argument to be made for some
- * attributes being interpreted out here, where we have control of the
- * Graphics2D and can construct or derive new fonts, and some
- * attributes being interpreted by the GlyphVector itself. So far, for
- * all attributes except FONT we do neither.
- */
-
- for (char c = ci.first ();
- c != CharacterIterator.DONE;
- c = ci.next ())
- {
- proxy.begin = ci.getIndex ();
- proxy.limit = ci.getRunLimit(TextAttribute.FONT);
- if (proxy.limit <= proxy.begin)
- continue;
-
- proxy.index = proxy.begin;
-
- Object fnt = ci.getAttribute(TextAttribute.FONT);
- GlyphVector gv;
- if (fnt instanceof Font)
- gv = ((Font)fnt).createGlyphVector (fontRenderContext, proxy);
- else
- gv = defFont.createGlyphVector (fontRenderContext, proxy);
-
- g2.drawGlyphVector (gv, x, y);
-
- int n = gv.getNumGlyphs ();
- for (int i = 0; i < n; ++i)
- {
- GlyphMetrics gm = gv.getGlyphMetrics (i);
- if (gm.getAdvanceX() == gm.getAdvance ())
- x += gm.getAdvanceX ();
- else
- y += gm.getAdvanceY ();
- }
- }
- }
+ // we share pango structures directly with GdkGraphics2D
+ GdkGraphics2D gg2 = (GdkGraphics2D) g2;
+ gg2.drawGdkTextLayout(this, x, y);
}
public TextHitInfo getStrongCaret (TextHitInfo hit1,
diff --git a/gnu/java/awt/peer/gtk/GtkCanvasPeer.java b/gnu/java/awt/peer/gtk/GtkCanvasPeer.java
index 797d653d2..edfc9ceee 100644
--- a/gnu/java/awt/peer/gtk/GtkCanvasPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkCanvasPeer.java
@@ -45,7 +45,6 @@ import java.awt.peer.CanvasPeer;
public class GtkCanvasPeer extends GtkComponentPeer implements CanvasPeer
{
native void create ();
- native void realize ();
public GtkCanvasPeer (Canvas c)
{
diff --git a/gnu/java/awt/peer/gtk/GtkComponentPeer.java b/gnu/java/awt/peer/gtk/GtkComponentPeer.java
index 1a85de5fe..3e464ab1a 100644
--- a/gnu/java/awt/peer/gtk/GtkComponentPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkComponentPeer.java
@@ -109,14 +109,7 @@ public class GtkComponentPeer extends GtkGenericPeer
native void gtkWidgetRequestFocus ();
native void gtkWidgetDispatchKeyEvent (int id, long when, int mods,
int keyCode, int keyLocation);
-
- native boolean isRealized ();
-
- void realize ()
- {
- // Default implementation does nothing
- }
-
+ native void realize();
native void setNativeEventMask ();
void create ()
@@ -149,6 +142,9 @@ public class GtkComponentPeer extends GtkGenericPeer
setNativeEventMask ();
+ // This peer is guaranteed to have an X window upon construction.
+ // That is, native methods such as those in GdkGraphics can rely
+ // on this component's widget->window field being non-null.
realize ();
if (awtComponent.isCursorSet())
@@ -212,10 +208,7 @@ public class GtkComponentPeer extends GtkGenericPeer
public Image createImage (int width, int height)
{
Image image;
- if (GtkToolkit.useGraphics2D ())
- image = new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB);
- else
- image = new GtkImage (width, height);
+ image = new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
g.setColor(getBackground());
@@ -247,10 +240,7 @@ public class GtkComponentPeer extends GtkGenericPeer
// never return null.
public Graphics getGraphics ()
{
- if (GtkToolkit.useGraphics2D ())
- return new GdkGraphics2D (this);
- else
- return new GdkGraphics (this);
+ return new GdkGraphics2D (this);
}
public Point getLocationOnScreen ()
diff --git a/gnu/java/awt/peer/gtk/GtkImage.java b/gnu/java/awt/peer/gtk/GtkImage.java
index 5e5f1de01..83ce2cbef 100644
--- a/gnu/java/awt/peer/gtk/GtkImage.java
+++ b/gnu/java/awt/peer/gtk/GtkImage.java
@@ -168,7 +168,7 @@ public class GtkImage extends Image
* Should be called with the GdkPixbufDecoder.pixbufLock held.
* Also acquires global gdk lock for drawing.
*/
- private native void drawPixelsScaled (GdkGraphics gc,
+ private native void drawPixelsScaled (GdkGraphics2D gc,
int bg_red, int bg_green, int bg_blue,
int x, int y, int width, int height,
boolean composite);
@@ -178,7 +178,7 @@ public class GtkImage extends Image
* Should be called with the GdkPixbufDecoder.pixbufLock held.
* Also acquires global gdk lock for drawing.
*/
- private native void drawPixelsScaledFlipped (GdkGraphics gc,
+ private native void drawPixelsScaledFlipped (GdkGraphics2D gc,
int bg_red, int bg_green,
int bg_blue,
boolean flipX, boolean flipY,
@@ -466,7 +466,7 @@ public class GtkImage extends Image
if (!isLoaded)
return null;
if (offScreen)
- return new GdkGraphics(this);
+ return null; // FIXME: (Graphics) new GdkGraphics(this);
else
throw new IllegalAccessError("This method only works for off-screen"
+" Images.");
@@ -540,7 +540,7 @@ public class GtkImage extends Image
/**
* Draws an image with eventual scaling/transforming.
*/
- public boolean drawImage (GdkGraphics g, int dx1, int dy1, int dx2, int dy2,
+ public boolean drawImage (GdkGraphics2D g, int dx1, int dy1, int dx2, int dy2,
int sx1, int sy1, int sx2, int sy2,
Color bgcolor, ImageObserver observer)
{
@@ -613,7 +613,7 @@ public class GtkImage extends Image
* Draws an image to the GdkGraphics context, at (x,y) scaled to
* width and height, with optional compositing with a background color.
*/
- public boolean drawImage (GdkGraphics g, int x, int y, int width, int height,
+ public boolean drawImage (GdkGraphics2D g, int x, int y, int width, int height,
Color bgcolor, ImageObserver observer)
{
if (addObserver(observer))
diff --git a/gnu/java/awt/peer/gtk/GtkToolkit.java b/gnu/java/awt/peer/gtk/GtkToolkit.java
index 7757db0c5..8e342cb92 100644
--- a/gnu/java/awt/peer/gtk/GtkToolkit.java
+++ b/gnu/java/awt/peer/gtk/GtkToolkit.java
@@ -78,31 +78,12 @@ import javax.imageio.spi.IIORegistry;
this class. If getPeer() ever goes away, we can implement a hash table
that will keep up with every window's peer, but for now this is faster. */
-/**
- * This class accesses a system property called
- * <tt>gnu.java.awt.peer.gtk.Graphics</tt>. If the property is defined and
- * equal to "Graphics2D", the cairo-based GdkGraphics2D will be used in
- * drawing contexts. Any other value will cause the older GdkGraphics
- * object to be used.
- */
public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
{
Hashtable containers = new Hashtable();
static EventQueue q;
- static boolean useGraphics2dSet;
- static boolean useGraphics2d;
static Thread mainThread;
- public static boolean useGraphics2D()
- {
- if (useGraphics2dSet)
- return useGraphics2d;
- useGraphics2d = System.getProperty("gnu.java.awt.peer.gtk.Graphics",
- "Graphics").equals("Graphics2D");
- useGraphics2dSet = true;
- return useGraphics2d;
- }
-
static native void gtkInit(int portableNativeSync);
static
@@ -179,10 +160,7 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
Image image;
try
{
- if (useGraphics2D())
- image = GdkPixbufDecoder.createBufferedImage(filename);
- else
- image = new GtkImage(filename);
+ image = GdkPixbufDecoder.createBufferedImage(filename);
}
catch (IllegalArgumentException iae)
{
@@ -196,11 +174,8 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
Image image;
try
{
- if (useGraphics2D())
- image = GdkPixbufDecoder.createBufferedImage(url);
- else
- image = new GtkImage(url);
- }
+ image = GdkPixbufDecoder.createBufferedImage(url);
+ }
catch (IllegalArgumentException iae)
{
image = null;
@@ -213,10 +188,7 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
Image image;
try
{
- if (useGraphics2D())
- image = GdkPixbufDecoder.createBufferedImage(producer);
- else
- image = new GtkImage(producer);
+ image = GdkPixbufDecoder.createBufferedImage(producer);
}
catch (IllegalArgumentException iae)
{
@@ -231,16 +203,9 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
Image image;
try
{
- if (useGraphics2D())
- image = GdkPixbufDecoder.createBufferedImage(imagedata,
- imageoffset,
- imagelength);
- else
- {
- byte[] datacopy = new byte[imagelength];
- System.arraycopy(imagedata, imageoffset, datacopy, 0, imagelength);
- return new GtkImage(datacopy);
- }
+ image = GdkPixbufDecoder.createBufferedImage(imagedata,
+ imageoffset,
+ imagelength);
}
catch (IllegalArgumentException iae)
{
diff --git a/include/Makefile.am b/include/Makefile.am
index 5cda78e88..8b43e31cb 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -38,7 +38,6 @@ $(top_srcdir)/include/gnu_xml_libxmlj_transform_GnomeTransformerFactory.h
GTKPEER_H_FILES = \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkFontPeer.h \
-$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkGraphics.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkGraphics2D.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkPixbufDecoder.h \
diff --git a/include/gnu_java_awt_peer_gtk_GdkFontPeer.h b/include/gnu_java_awt_peer_gtk_GdkFontPeer.h
index 80d69be75..745be47d6 100644
--- a/include/gnu_java_awt_peer_gtk_GdkFontPeer.h
+++ b/include/gnu_java_awt_peer_gtk_GdkFontPeer.h
@@ -13,11 +13,11 @@ extern "C"
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_initStaticState (JNIEnv *env, jclass);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_initState (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_dispose (JNIEnv *env, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_setFont (JNIEnv *env, jobject, jstring, jint, jint, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_setFont (JNIEnv *env, jobject, jstring, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_getFontMetrics (JNIEnv *env, jobject, jdoubleArray);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_getTextMetrics (JNIEnv *env, jobject, jstring, jdoubleArray);
-JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_getGlyphVector (JNIEnv *env, jobject, jstring, jobject, jobject);
JNIEXPORT jbyteArray JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_getTrueTypeTable (JNIEnv *env, jobject, jbyte, jbyte, jbyte, jbyte);
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_getGlyphVector (JNIEnv *env, jobject, jstring, jobject, jobject);
#ifdef __cplusplus
}
diff --git a/include/gnu_java_awt_peer_gtk_GdkGraphics.h b/include/gnu_java_awt_peer_gtk_GdkGraphics.h
deleted file mode 100644
index 8a87738f2..000000000
--- a/include/gnu_java_awt_peer_gtk_GdkGraphics.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
-
-#ifndef __gnu_java_awt_peer_gtk_GdkGraphics__
-#define __gnu_java_awt_peer_gtk_GdkGraphics__
-
-#include <jni.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_initStaticState (JNIEnv *env, jclass);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__Lgnu_java_awt_peer_gtk_GtkComponentPeer_2 (JNIEnv *env, jobject, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_initStateUnlocked (JNIEnv *env, jobject, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__II (JNIEnv *env, jobject, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_initFromImage (JNIEnv *env, jobject, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_nativeCopyState (JNIEnv *env, jobject, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_connectSignals (JNIEnv *env, jobject, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_clearRect (JNIEnv *env, jobject, jint, jint, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_copyArea (JNIEnv *env, jobject, jint, jint, jint, jint, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_nativeDispose (JNIEnv *env, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_drawLine (JNIEnv *env, jobject, jint, jint, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_drawArc (JNIEnv *env, jobject, jint, jint, jint, jint, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_fillArc (JNIEnv *env, jobject, jint, jint, jint, jint, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_drawOval (JNIEnv *env, jobject, jint, jint, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_fillOval (JNIEnv *env, jobject, jint, jint, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_drawPolygon (JNIEnv *env, jobject, jintArray, jintArray, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_fillPolygon (JNIEnv *env, jobject, jintArray, jintArray, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_drawPolyline (JNIEnv *env, jobject, jintArray, jintArray, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_drawRect (JNIEnv *env, jobject, jint, jint, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_fillRect (JNIEnv *env, jobject, jint, jint, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_drawString (JNIEnv *env, jobject, jobject, jstring, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_setClipRectangle (JNIEnv *env, jobject, jint, jint, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_setFGColor (JNIEnv *env, jobject, jint, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_setFunction (JNIEnv *env, jobject, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_translateNative (JNIEnv *env, jobject, jint, jint);
-#undef gnu_java_awt_peer_gtk_GdkGraphics_GDK_COPY
-#define gnu_java_awt_peer_gtk_GdkGraphics_GDK_COPY 0L
-#undef gnu_java_awt_peer_gtk_GdkGraphics_GDK_XOR
-#define gnu_java_awt_peer_gtk_GdkGraphics_GDK_XOR 2L
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __gnu_java_awt_peer_gtk_GdkGraphics__ */
diff --git a/include/gnu_java_awt_peer_gtk_GdkGraphics2D.h b/include/gnu_java_awt_peer_gtk_GdkGraphics2D.h
index 2d29cfc73..6bf66b7aa 100644
--- a/include/gnu_java_awt_peer_gtk_GdkGraphics2D.h
+++ b/include/gnu_java_awt_peer_gtk_GdkGraphics2D.h
@@ -11,39 +11,27 @@ extern "C"
#endif
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initStaticState (JNIEnv *env, jclass);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initStateUnlocked (JNIEnv *env, jobject, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState__Lgnu_java_awt_peer_gtk_GtkComponentPeer_2 (JNIEnv *env, jobject, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState__II (JNIEnv *env, jobject, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState___3III (JNIEnv *env, jobject, jintArray, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_copyState (JNIEnv *env, jobject, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_dispose (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSurfaceSetFilter (JNIEnv *env, jobject, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSurfaceSetFilterUnlocked (JNIEnv *env, jobject, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_connectSignals (JNIEnv *env, jobject, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_gdkDrawDrawable (JNIEnv *env, jobject, jobject, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_drawPixels (JNIEnv *env, jobject, jintArray, jint, jint, jint, jdoubleArray);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixelsUnlocked (JNIEnv *env, jobject, jintArray, jint, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixels (JNIEnv *env, jobject, jintArray, jint, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradient (JNIEnv *env, jobject, jdouble, jdouble, jdouble, jdouble, jint, jint, jint, jint, jint, jint, jint, jint, jboolean);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradientUnlocked (JNIEnv *env, jobject, jdouble, jdouble, jdouble, jdouble, jint, jint, jint, jint, jint, jint, jint, jint, jboolean);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSave (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoRestore (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrix (JNIEnv *env, jobject, jdoubleArray);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrixUnlocked (JNIEnv *env, jobject, jdoubleArray);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetOperator (JNIEnv *env, jobject, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBAColor (JNIEnv *env, jobject, jdouble, jdouble, jdouble, jdouble);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBAColorUnlocked (JNIEnv *env, jobject, jdouble, jdouble, jdouble, jdouble);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetFillRule (JNIEnv *env, jobject, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineWidth (JNIEnv *env, jobject, jdouble);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineWidthUnlocked (JNIEnv *env, jobject, jdouble);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCap (JNIEnv *env, jobject, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCapUnlocked (JNIEnv *env, jobject, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoin (JNIEnv *env, jobject, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoinUnlocked (JNIEnv *env, jobject, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDash (JNIEnv *env, jobject, jdoubleArray, jint, jdouble);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDashUnlocked (JNIEnv *env, jobject, jdoubleArray, jint, jdouble);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMiterLimit (JNIEnv *env, jobject, jdouble);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMiterLimitUnlocked (JNIEnv *env, jobject, jdouble);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoNewPath (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoMoveTo (JNIEnv *env, jobject, jdouble, jdouble);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoLineTo (JNIEnv *env, jobject, jdouble, jdouble);
diff --git a/include/gnu_java_awt_peer_gtk_GtkCanvasPeer.h b/include/gnu_java_awt_peer_gtk_GtkCanvasPeer.h
index 44ab6870c..e774713a7 100644
--- a/include/gnu_java_awt_peer_gtk_GtkCanvasPeer.h
+++ b/include/gnu_java_awt_peer_gtk_GtkCanvasPeer.h
@@ -11,7 +11,6 @@ extern "C"
#endif
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkCanvasPeer_create (JNIEnv *env, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkCanvasPeer_realize (JNIEnv *env, jobject);
#ifdef __cplusplus
}
diff --git a/include/gnu_java_awt_peer_gtk_GtkComponentPeer.h b/include/gnu_java_awt_peer_gtk_GtkComponentPeer.h
index 207e08d05..f2014595f 100644
--- a/include/gnu_java_awt_peer_gtk_GtkComponentPeer.h
+++ b/include/gnu_java_awt_peer_gtk_GtkComponentPeer.h
@@ -26,7 +26,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetS
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetParent (JNIEnv *env, jobject, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetRequestFocus (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetDispatchKeyEvent (JNIEnv *env, jobject, jint, jlong, jint, jint, jint);
-JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_isRealized (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_realize (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_setNativeEventMask (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_connectSignals (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_setNativeBounds (JNIEnv *env, jobject, jint, jint, jint, jint);
diff --git a/native/jawt/Makefile.am b/native/jawt/Makefile.am
index b6e6f0af0..060f88c89 100644
--- a/native/jawt/Makefile.am
+++ b/native/jawt/Makefile.am
@@ -7,10 +7,10 @@ libjawtgnu_la_LIBADD = $(top_builddir)/native/jni/gtk-peer/libgtkpeer.la
#
# libjawtgnu_la_LDFLAGS = -Wl,-soname -Wl,libjawt.so
-AM_LDFLAGS = @CLASSPATH_MODULE@ @GTK_LIBS@ @CAIRO_LIBS@ @PANGOFT2_LIBS@ @X_LIBS@ -lXtst
+AM_LDFLAGS = @CLASSPATH_MODULE@ @GTK_LIBS@ @PANGOFT2_LIBS@ @X_LIBS@ -lXtst
AM_CPPFLAGS = @CLASSPATH_INCLUDES@
# Just the WARNING_CFLAGS. We cannot use the strict flags since the gtk
# headers contain broken prototypes (by design, see gtkitemfactory.h).
AM_CFLAGS = @WARNING_CFLAGS@ @ERROR_CFLAGS@ \
- @GTK_CFLAGS@ @CAIRO_CFLAGS@ @PANGOFT2_CFLAGS@
+ @GTK_CFLAGS@ @PANGOFT2_CFLAGS@
diff --git a/native/jni/gtk-peer/Makefile.am b/native/jni/gtk-peer/Makefile.am
index 9c373cb4d..7b3aab2d9 100644
--- a/native/jni/gtk-peer/Makefile.am
+++ b/native/jni/gtk-peer/Makefile.am
@@ -1,17 +1,9 @@
nativeexeclib_LTLIBRARIES = libgtkpeer.la
-# Gtk/Cairo JNI sources.
-if GTK_CAIRO
- gtk_cairo_c_source_files = \
- gnu_java_awt_peer_gtk_GdkGraphics2D.c
-else
- gtk_cairo_c_source_files =
-endif
-
-libgtkpeer_la_SOURCES = $(gtk_cairo_c_source_files) \
- gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c \
+# GTK JNI sources.
+libgtkpeer_la_SOURCES = gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c \
gnu_java_awt_peer_gtk_GdkFontPeer.c \
- gnu_java_awt_peer_gtk_GdkGraphics.c \
+ gnu_java_awt_peer_gtk_GdkGraphics2D.c \
gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c \
gnu_java_awt_peer_gtk_GdkPixbufDecoder.c \
gnu_java_awt_peer_gtk_GdkRobotPeer.c \
@@ -54,12 +46,12 @@ libgtkpeer_la_SOURCES = $(gtk_cairo_c_source_files) \
libgtkpeer_la_LIBADD = $(top_builddir)/native/jni/classpath/native_state.lo \
$(top_builddir)/native/jni/classpath/jcl.lo
-AM_LDFLAGS = @CLASSPATH_MODULE@ @GTK_LIBS@ @CAIRO_LIBS@ @FREETYPE2_LIBS@ \
+AM_LDFLAGS = @CLASSPATH_MODULE@ @GTK_LIBS@ @FREETYPE2_LIBS@ \
@PANGOFT2_LIBS@ @X_PRE_LIBS@ @X_LIBS@ @X_EXTRA_LIBS@ -lX11 -lXtst
AM_CPPFLAGS = @CLASSPATH_INCLUDES@
# Just the WARNING_CFLAGS. We cannot use the strict flags since the gtk
# headers contain broken prototypes (by design, see gtkitemfactory.h).
AM_CFLAGS = @WARNING_CFLAGS@ @ERROR_CFLAGS@ \
- @GTK_CFLAGS@ @CAIRO_CFLAGS@ @FREETYPE2_CFLAGS@ @PANGOFT2_CFLAGS@ \
+ @GTK_CFLAGS@ @FREETYPE2_CFLAGS@ @PANGOFT2_CFLAGS@ \
@X_CFLAGS@
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c
index 51ae193c8..c0f776b20 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c
@@ -396,7 +396,7 @@ Java_gnu_java_awt_peer_gtk_GdkFontPeer_getTextMetrics
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkFontPeer_setFont
- (JNIEnv *env, jobject self, jstring family_name_str, jint style_int, jint size, jboolean useGraphics2D)
+ (JNIEnv *env, jobject self, jstring family_name_str, jint style_int, jint size)
{
struct peerfont *pfont = NULL;
char const *family_name = NULL;
@@ -433,22 +433,11 @@ Java_gnu_java_awt_peer_gtk_GdkFontPeer_setFont
if (style & java_awt_font_ITALIC)
pango_font_description_set_style (pfont->desc, PANGO_STYLE_ITALIC);
- if (useGraphics2D)
+ pango_font_description_set_size (pfont->desc, size * PANGO_SCALE);
+ if (pfont->ctx == NULL)
{
- pango_font_description_set_size (pfont->desc, size * PANGO_SCALE);
- if (pfont->ctx == NULL)
- {
- ft2_map = PANGO_FT2_FONT_MAP(pango_ft2_font_map_for_display ());
- pfont->ctx = pango_ft2_font_map_create_context (ft2_map);
- }
- }
- else
- {
- /* GDK uses a slightly different DPI setting. */
- pango_font_description_set_size (pfont->desc,
- size * cp_gtk_dpi_conversion_factor);
- if (pfont->ctx == NULL)
- pfont->ctx = gdk_pango_context_get();
+ ft2_map = PANGO_FT2_FONT_MAP(pango_ft2_font_map_for_display ());
+ pfont->ctx = pango_ft2_font_map_create_context (ft2_map);
}
g_assert (pfont->ctx != NULL);
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
deleted file mode 100644
index 29bc1855b..000000000
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
+++ /dev/null
@@ -1,758 +0,0 @@
-/* gdkgraphics.c
- Copyright (C) 1999 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-#include "gtkpeer.h"
-#include "gdkfont.h"
-#include "gnu_java_awt_peer_gtk_GdkGraphics.h"
-#include <gdk/gdkprivate.h>
-#include <gdk/gdkx.h>
-
-static jmethodID initComponentGraphicsUnlockedID;
-
-/*
- * AWT applications may call Graphics methods from threads other than
- * the GDK main thread, so we must call XFlush after each batch of
- * drawing operations, otherwise animations flicker. Flushing after
- * every graphics operation is excessive and negatively affects
- * performance (PR 26486). We set the maximum frequency to 50 times
- * per second, or a minimum period of 20 milliseconds between calls to
- * XFlush. See gnu.classpath.examples.awt.AnimationApplet for an
- * example applet that requires these XFlush calls.
- */
-
-static short flush_scheduled = 0;
-
-static gboolean flush (gpointer data __attribute__((unused)))
-{
- gdk_threads_enter ();
-
- XFlush (GDK_DISPLAY ());
- flush_scheduled = 0;
-
- gdk_threads_leave ();
-
- return FALSE;
-}
-
-/* The minimum time period between calls to XFlush, in
- milliseconds. */
-#define MINIMUM_FLUSH_PERIOD 20
-
-/* schedule_flush must be called with the GDK lock held. */
-static void
-schedule_flush ()
-{
- if (!flush_scheduled)
- {
- g_timeout_add (MINIMUM_FLUSH_PERIOD, flush, NULL);
- flush_scheduled = 1;
- }
-}
-
-void
-cp_gtk_graphics_init_jni (void)
-{
- jclass gdkgraphics;
-
- gdkgraphics = (*cp_gtk_gdk_env())->FindClass (cp_gtk_gdk_env(),
- "gnu/java/awt/peer/gtk/GdkGraphics");
-
- initComponentGraphicsUnlockedID =
- (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gdkgraphics,
- "initComponentGraphicsUnlocked",
- "()V");
-}
-
-struct state_table *cp_gtk_native_graphics_state_table;
-
-static struct state_table *native_graphics_global_ref_table;
-
-#define NSA_GLOBAL_G_INIT(env, clazz) \
- native_graphics_global_ref_table = cp_gtk_init_state_table (env, clazz)
-
-#define NSA_GET_GLOBAL_G_REF(env, obj) \
- cp_gtk_get_state (env, obj, native_graphics_global_ref_table)
-
-#define NSA_SET_GLOBAL_G_REF(env, obj) \
- do {jobject *globRefPtr; \
- globRefPtr = (jobject *) malloc (sizeof (jobject)); \
- *globRefPtr = (*env)->NewGlobalRef (env, obj); \
- cp_gtk_set_state (env, obj, native_graphics_global_ref_table, (void *)globRefPtr);} while (0)
-
-#define NSA_DEL_GLOBAL_G_REF(env, obj) \
- do {jobject *globRefPtr = cp_gtk_get_state (env, obj, native_graphics_global_ref_table); \
- cp_gtk_remove_state_slot (env, obj, native_graphics_global_ref_table); \
- (*env)->DeleteGlobalRef (env, *globRefPtr); \
- free (globRefPtr);} while (0)
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_initStaticState
- (JNIEnv *env, jclass clazz)
-{
- gdk_threads_enter();
-
- NSA_G_INIT (env, clazz);
- NSA_GLOBAL_G_INIT (env, clazz);
-
- gdk_threads_leave();
-}
-
-#define GDK_STABLE_IS_PIXMAP(d) (GDK_IS_PIXMAP(d))
-
-static GdkPoint *translate_points (JNIEnv *env, jintArray xpoints,
- jintArray ypoints, jint npoints,
- jint x_offset, jint y_offset);
-static void realize_cb (GtkWidget *widget, jobject jgraphics);
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_nativeCopyState
- (JNIEnv *env, jobject obj, jobject old)
-{
- struct graphics *g = NULL;
- struct graphics *g_old = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) g_malloc (sizeof (struct graphics));
- g_old = (struct graphics *) NSA_GET_G_PTR (env, old);
-
- *g = *g_old;
-
- g->gc = gdk_gc_new (g->drawable);
- gdk_gc_copy (g->gc, g_old->gc);
-
- if (GDK_STABLE_IS_PIXMAP (g->drawable))
- g_object_ref (g->drawable);
- else /* GDK_IS_WINDOW (g->drawable) */
- g_object_ref (g->drawable);
-
- if (g->cm != NULL)
- g_object_ref (g->cm);
-
- NSA_SET_G_PTR (env, obj, g);
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__II
- (JNIEnv *env, jobject obj, jint width, jint height)
-{
- struct graphics *g = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) g_malloc (sizeof (struct graphics));
- g->x_offset = g->y_offset = 0;
-
- g->drawable = (GdkDrawable *) gdk_pixmap_new (NULL, width, height,
- gdk_rgb_get_visual ()->depth);
- g->cm = gdk_rgb_get_colormap ();
-
- if (g->cm != NULL)
- g_object_ref (g->cm);
- g->gc = gdk_gc_new (g->drawable);
-
- NSA_SET_G_PTR (env, obj, g);
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_initFromImage
- (JNIEnv *env, jobject obj, jobject source)
-{
- struct graphics *g = NULL;
- GdkPixmap *pixmap = NULL;
-
- gdk_threads_enter ();
-
- pixmap = cp_gtk_image_get_pixmap (env, source);
- g_assert(pixmap != NULL);
- g_object_ref (pixmap);
-
- g = (struct graphics *) g_malloc (sizeof (struct graphics));
- g->x_offset = g->y_offset = 0;
-
- g->drawable = (GdkDrawable *)pixmap;
-
- g->cm = gdk_drawable_get_colormap (g->drawable);
-
- if (g->cm != NULL)
- g_object_ref (g->cm);
- g->gc = gdk_gc_new (g->drawable);
-
- NSA_SET_G_PTR (env, obj, g);
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_initStateUnlocked
- (JNIEnv *env, jobject obj, jobject peer)
-{
- struct graphics *g = NULL;
- void *ptr = NULL;
- GtkWidget *widget = NULL;
- GdkColor color;
-
- g = (struct graphics *) g_malloc (sizeof (struct graphics));
- ptr = NSA_GET_PTR (env, peer);
- g->x_offset = 0;
- g->y_offset = 0;
-
- widget = GTK_WIDGET (ptr);
- g->drawable = (GdkDrawable *) widget->window;
-
- g_object_ref (g->drawable);
- g->cm = gtk_widget_get_colormap (widget);
-
- if (g->cm != NULL)
- g_object_ref (g->cm);
-
- g->gc = gdk_gc_new (g->drawable);
- gdk_gc_copy (g->gc, widget->style->fg_gc[GTK_STATE_NORMAL]);
- color = widget->style->fg[GTK_STATE_NORMAL];
-
- NSA_SET_G_PTR (env, obj, g);
-}
-
-/* copy the native state of the peer (GtkWidget *) to the native state
- of the graphics object */
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__Lgnu_java_awt_peer_gtk_GtkComponentPeer_2
- (JNIEnv *env, jobject obj, jobject peer)
-{
- gdk_threads_enter ();
- Java_gnu_java_awt_peer_gtk_GdkGraphics_initStateUnlocked
- (env, obj, peer);
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_connectSignals
- (JNIEnv *env, jobject obj, jobject peer)
-{
- void *ptr = NULL;
- jobject *gref = NULL;
-
- gdk_threads_enter ();
-
- NSA_SET_GLOBAL_G_REF (env, obj);
- gref = NSA_GET_GLOBAL_G_REF (env, obj);
-
- ptr = NSA_GET_PTR (env, peer);
-
- g_signal_connect_after (G_OBJECT (ptr), "realize",
- G_CALLBACK (realize_cb), *gref);
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_nativeDispose
- (JNIEnv *env, jobject obj)
-{
- struct graphics *g = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_DEL_G_PTR (env, obj);
-
- /* check if dispose has been called already */
- if (!g)
- {
- gdk_threads_leave ();
- return;
- }
-
- XFlush (GDK_DISPLAY ());
-
- if (g->gc != NULL)
- g_object_unref (g->gc);
-
- if (GDK_STABLE_IS_PIXMAP (g->drawable))
- g_object_unref (g->drawable);
- else if (g->drawable != NULL)
- g_object_unref (g->drawable);
-
- if (g->cm != NULL)
- g_object_unref (g->cm);
-
- g_free (g);
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_translateNative
- (JNIEnv *env, jobject obj, jint x, jint y)
-{
- struct graphics *g = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
-
- g->x_offset += x;
- g->y_offset += y;
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_drawString
- (JNIEnv *env, jobject obj, jobject font, jstring str, jint x, jint y)
-{
- struct peerfont *pfont = NULL;
- struct graphics *g = NULL;
- const char *cstr = NULL;
- const char *sTmp = NULL;
- char *tmp = NULL;
- char *p = NULL;
- int count = 0;
- int charSize = 0;
- int baseline_y = 0;
- PangoLayoutIter *iter = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
- g_assert (g != NULL);
-
- pfont = (struct peerfont *)NSA_GET_FONT_PTR (env, font);
- g_assert (pfont != NULL);
-
- cstr = (*env)->GetStringUTFChars (env, str, NULL);
- g_assert (cstr != NULL);
-
- charSize = sizeof(char);
- p = malloc((strlen(cstr) + 1) * charSize);
- g_assert (p != NULL);
-
- tmp = p;
- sTmp = cstr;
- for (; *sTmp != '\0'; sTmp++)
- if (((unsigned char) *sTmp) >= ' ')
- {
- *p = *sTmp;
- count++;
- p++;
- }
- *p = '\0';
-
- p = realloc(tmp, (count + 1) * charSize);
- g_assert (p != NULL);
- pango_layout_set_text (pfont->layout, p, -1);
- free(p);
-
- pango_layout_set_font_description (pfont->layout, pfont->desc);
- iter = pango_layout_get_iter (pfont->layout);
-
- baseline_y = pango_layout_iter_get_baseline (iter);
-
- gdk_draw_layout (g->drawable, g->gc,
- x + g->x_offset,
- y + g->y_offset - PANGO_PIXELS (baseline_y),
- pfont->layout);
-
- pango_layout_iter_free (iter);
- pango_layout_set_text (pfont->layout, "", -1);
-
- schedule_flush ();
-
- (*env)->ReleaseStringUTFChars (env, str, cstr);
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_drawLine
- (JNIEnv *env, jobject obj, jint x, jint y, jint x2, jint y2)
-{
- struct graphics *g = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
-
- gdk_draw_line (g->drawable, g->gc,
- x + g->x_offset, y + g->y_offset,
- x2 + g->x_offset, y2 + g->y_offset);
- schedule_flush ();
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_fillRect
- (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
-{
- struct graphics *g = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
-
- gdk_draw_rectangle (g->drawable, g->gc, TRUE,
- x + g->x_offset, y + g->y_offset, width, height);
- schedule_flush ();
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_drawRect
- (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
-{
- struct graphics *g = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
-
- gdk_draw_rectangle (g->drawable, g->gc, FALSE,
- x + g->x_offset, y + g->y_offset, width, height);
- schedule_flush ();
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_copyArea
- (JNIEnv *env, jobject obj, jint x, jint y,
- jint width, jint height, jint dx, jint dy)
-{
- struct graphics *g = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
-
- gdk_draw_drawable ((GdkWindow *)g->drawable,
- g->gc,
- (GdkWindow *)g->drawable,
- x + g->x_offset, y + g->y_offset,
- x + g->x_offset + dx, y + g->y_offset + dy,
- width, height);
- schedule_flush ();
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_clearRect
- (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
-{
- struct graphics *g = NULL;
- GdkGCValues saved;
- GtkWidget *widget = NULL;
- union widget_union w;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
-
- if (!g)
- {
- gdk_threads_leave ();
- return;
- }
-
- if (GDK_IS_WINDOW (g->drawable))
- {
- w.widget = &widget;
- gdk_window_get_user_data (GDK_WINDOW (g->drawable), w.void_widget);
- if (widget == NULL || !GTK_IS_EVENT_BOX (widget))
- gdk_window_clear_area ((GdkWindow *) g->drawable,
- x + g->x_offset, y + g->y_offset,
- width, height);
- }
- else
- {
- gdk_gc_get_values (g->gc, &saved);
- gdk_gc_set_background (g->gc, &(saved.background));
- gdk_draw_rectangle (g->drawable, g->gc, TRUE,
- x + g->x_offset, y + g->y_offset, width, height);
- gdk_gc_set_foreground (g->gc, &(saved.foreground));
- }
-
- schedule_flush ();
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_setFunction
- (JNIEnv *env, jobject obj, jint func)
-{
- struct graphics *g = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
-
- gdk_gc_set_function (g->gc, func);
-
- gdk_threads_leave ();
-}
-
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_setFGColor
- (JNIEnv *env, jobject obj, jint red, jint green, jint blue)
-{
- GdkColor color;
- struct graphics *g = NULL;
-
- gdk_threads_enter ();
-
- color.red = red << 8;
- color.green = green << 8;
- color.blue = blue << 8;
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
-
- if (g->cm != NULL)
- gdk_colormap_alloc_color (g->cm, &color, TRUE, TRUE);
-
- gdk_gc_set_foreground (g->gc, &color);
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_drawArc
- (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height,
- jint angle1, jint angle2)
-{
- struct graphics *g = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
-
- gdk_draw_arc (g->drawable, g->gc, FALSE,
- x + g->x_offset, y + g->y_offset,
- width, height, angle1 << 6, angle2 << 6);
- schedule_flush ();
-
- gdk_threads_leave ();
-}
-
-static GdkPoint *
-translate_points (JNIEnv *env, jintArray xpoints, jintArray ypoints,
- jint npoints, jint x_offset, jint y_offset)
-{
- GdkPoint *points;
- jint *x, *y;
- int i;
-
- /* allocate one more point than necessary, in case we need to tack
- on an extra due to the semantics of Java polygons. */
- points = g_malloc (sizeof (GdkPoint) * (npoints + 1));
-
- x = (*env)->GetIntArrayElements (env, xpoints, NULL);
- y = (*env)->GetIntArrayElements (env, ypoints, NULL);
-
- for (i = 0; i < npoints; i++)
- {
- points[i].x = x[i] + x_offset;
- points[i].y = y[i] + y_offset;
- }
-
- (*env)->ReleaseIntArrayElements (env, xpoints, x, JNI_ABORT);
- (*env)->ReleaseIntArrayElements (env, ypoints, y, JNI_ABORT);
-
- return points;
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_drawPolyline
- (JNIEnv *env, jobject obj, jintArray xpoints, jintArray ypoints,
- jint npoints)
-{
- struct graphics *g = NULL;
- GdkPoint *points = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
- points = translate_points (env, xpoints, ypoints, npoints,
- g->x_offset, g->y_offset);
-
- gdk_draw_lines (g->drawable, g->gc, points, npoints);
- schedule_flush ();
-
- g_free (points);
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_drawPolygon
- (JNIEnv *env, jobject obj, jintArray xpoints, jintArray ypoints,
- jint npoints)
-{
- struct graphics *g = NULL;
- GdkPoint *points = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
- points = translate_points (env, xpoints, ypoints, npoints,
- g->x_offset, g->y_offset);
-
- /* make sure the polygon is closed, per Java semantics.
- if it's not, we close it. */
- if (points[0].x != points[npoints-1].x || points[0].y != points[npoints-1].y)
- points[npoints++] = points[0];
-
- gdk_draw_lines (g->drawable, g->gc, points, npoints);
- schedule_flush ();
-
- g_free (points);
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_fillPolygon
- (JNIEnv *env, jobject obj, jintArray xpoints, jintArray ypoints,
- jint npoints)
-{
- struct graphics *g = NULL;
- GdkPoint *points = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
- points = translate_points (env, xpoints, ypoints, npoints,
- g->x_offset, g->y_offset);
- gdk_draw_polygon (g->drawable, g->gc, TRUE, points, npoints);
- schedule_flush ();
-
- g_free (points);
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_fillArc
- (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height,
- jint angle1, jint angle2)
-{
- struct graphics *g = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
-
- gdk_draw_arc (g->drawable, g->gc, TRUE,
- x + g->x_offset, y + g->y_offset,
- width, height, angle1 << 6, angle2 << 6);
- schedule_flush ();
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_drawOval
- (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
-{
- struct graphics *g = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
-
- gdk_draw_arc (g->drawable, g->gc, FALSE,
- x + g->x_offset, y + g->y_offset,
- width, height, 0, 23040);
- schedule_flush ();
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_fillOval
- (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
-{
- struct graphics *g = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
-
- gdk_draw_arc (g->drawable, g->gc, TRUE,
- x + g->x_offset, y + g->y_offset,
- width, height, 0, 23040);
- schedule_flush ();
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_setClipRectangle
- (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
-{
- struct graphics *g = NULL;
- GdkRectangle rectangle;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
-
- rectangle.x = x + g->x_offset;
- rectangle.y = y + g->y_offset;
- rectangle.width = width;
- rectangle.height = height;
-
- gdk_gc_set_clip_rectangle (g->gc, &rectangle);
-
- gdk_threads_leave ();
-}
-
-static void
-realize_cb (GtkWidget *widget __attribute__ ((unused)), jobject jgraphics)
-{
- (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(),
- jgraphics,
- initComponentGraphicsUnlockedID);
-
- NSA_DEL_GLOBAL_G_REF (cp_gtk_gdk_env(), jgraphics);
-}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
index b42f649a1..32c4cb8d1 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
@@ -1,42 +1,41 @@
/* gnu_java_awt_peer_gtk_GdkGraphics2d.c
Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc.
- This file is part of GNU Classpath.
+This file is part of GNU Classpath.
- GNU Classpath is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
- GNU Classpath is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with GNU Classpath; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301 USA.
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
- Linking this library statically or dynamically with other modules is
- making a combined work based on this library. Thus, the terms and
- conditions of the GNU General Public License cover the whole
- combination.
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
- As a special exception, the copyright holders of this library give you
- permission to link this library with independent modules to produce an
- executable, regardless of the license terms of these independent
- modules, and to copy and distribute the resulting executable under
- terms of your choice, provided that you also meet, for each linked
- independent module, the terms and conditions of the license of that
- module. An independent module is a module which is not derived from
- or based on this library. If you modify this library, you may extend
- this exception to your version of the library, but you are not
- obligated to do so. If you do not wish to do so, delete this
- exception statement from your version. */
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
#include "jcl.h"
-#include "gtkcairopeer.h"
#include "gdkfont.h"
#include "gnu_java_awt_peer_gtk_GdkGraphics2D.h"
#include <gdk/gdktypes.h>
@@ -53,37 +52,7 @@
#include <stdio.h>
#include <stdlib.h>
-static jmethodID initComponentGraphics2DUnlockedID;
-
-void
-cp_gtk_graphics2d_init_jni (void)
-{
- jclass gdkgraphics2d;
- JNIEnv *env = cp_gtk_gdk_env();
-
- gdkgraphics2d = (*env)->FindClass (env,
- "gnu/java/awt/peer/gtk/GdkGraphics2D");
- if ((*env)->ExceptionOccurred(env))
- return;
-
- initComponentGraphics2DUnlockedID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gdkgraphics2d,
- "initComponentGraphics2DUnlocked",
- "()V");
-}
-
-static struct state_table *native_graphics2d_state_table;
-
-#define NSA_G2D_INIT(env, clazz) \
- native_graphics2d_state_table = cp_gtk_init_state_table (env, clazz)
-
-#define NSA_GET_G2D_PTR(env, obj) \
- cp_gtk_get_state (env, obj, native_graphics2d_state_table)
-
-#define NSA_SET_G2D_PTR(env, obj, ptr) \
- cp_gtk_set_state (env, obj, native_graphics2d_state_table, (void *)ptr)
-
-#define NSA_DEL_G2D_PTR(env, obj) \
- cp_gtk_remove_state_slot (env, obj, native_graphics2d_state_table)
+struct state_table *cp_gtk_native_graphics2d_state_table;
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initStaticState
@@ -157,8 +126,6 @@ peer_is_disposed(JNIEnv *env, jobject obj)
jclass cls;
jobject peer;
- return 0;
-
if (fid == NULL)
{
cls = (*env)->GetObjectClass(env, obj);
@@ -170,12 +137,9 @@ peer_is_disposed(JNIEnv *env, jobject obj)
if (peer == NULL || NSA_GET_PTR (env, peer) != NULL)
return 0;
else
- {
- return 1;
- }
+ return 1;
}
-
static void
grab_current_drawable (GtkWidget *widget, GdkDrawable **draw, GdkWindow **win)
{
@@ -389,14 +353,6 @@ check_for_debug (struct graphics2d *gr)
gr->debug = (gboolean)(getenv("DEBUGJ2D") != NULL);
}
-static void
-realize_cb (GtkWidget *widget __attribute__ ((unused)), jobject peer)
-{
- (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(),
- peer,
- initComponentGraphics2DUnlockedID);
-}
-
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_copyState
(JNIEnv *env, jobject obj, jobject old)
@@ -553,7 +509,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState__II
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_gdkDrawDrawable
- (JNIEnv *env, jobject self, jobject other, jint x, jint y)
+ (JNIEnv *env, jobject obj, jobject other, jint x, jint y)
{
struct graphics2d *src = NULL;
struct graphics2d *dst = NULL;
@@ -567,15 +523,15 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_gdkDrawDrawable
cairo_operator_t tmp_op;
gdk_threads_enter();
-
- if (peer_is_disposed(env, self))
+
+ if (peer_is_disposed(env, obj))
{
gdk_threads_leave();
return;
}
src = (struct graphics2d *)NSA_GET_G2D_PTR (env, other);
- dst = (struct graphics2d *)NSA_GET_G2D_PTR (env, self);
+ dst = (struct graphics2d *)NSA_GET_G2D_PTR (env, obj);
g_assert (src != NULL);
g_assert (dst != NULL);
@@ -585,8 +541,8 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_gdkDrawDrawable
/* gdk_flush(); */
- if (!GDK_IS_DRAWABLE (src->drawable) ||
- !GDK_IS_DRAWABLE (dst->drawable))
+ if (!GDK_IS_DRAWABLE (src->drawable) ||
+ !GDK_IS_DRAWABLE (dst->drawable))
{
gdk_threads_leave ();
return;
@@ -621,43 +577,6 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_gdkDrawDrawable
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initStateUnlocked
- (JNIEnv *env, jobject obj, jobject peer)
-{
- struct graphics2d *gr = NULL;
- GtkWidget *widget = NULL;
- void *ptr = NULL;
-
- if (peer_is_disposed(env, obj))
- return;
-
- ptr = NSA_GET_PTR (env, peer);
- g_assert (ptr != NULL);
-
- gr = (struct graphics2d *) g_malloc (sizeof (struct graphics2d));
- g_assert (gr != NULL);
- memset (gr, 0, sizeof(struct graphics2d));
-
- check_for_debug (gr);
-
- widget = GTK_WIDGET (ptr);
- g_assert (widget != NULL);
-
- grab_current_drawable (widget, &(gr->drawable), &(gr->win));
- g_assert (gr->drawable != NULL);
-
- gr->width = widget->allocation.width;
- gr->height = widget->allocation.height;
-
- if (x_server_has_render_extension ())
- init_graphics2d_as_renderable (gr);
- else
- init_graphics2d_as_pixbuf (gr);
-
- NSA_SET_G2D_PTR (env, obj, gr);
-}
-
-JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState__Lgnu_java_awt_peer_gtk_GtkComponentPeer_2
(JNIEnv *env, jobject obj, jobject peer)
{
@@ -669,7 +588,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState__Lgnu_java_awt_peer_gtk_GtkCo
if (peer_is_disposed(env, obj))
{
- gdk_threads_leave ();
+ gdk_threads_leave();
return;
}
@@ -702,62 +621,58 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState__Lgnu_java_awt_peer_gtk_GtkCo
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_connectSignals
- (JNIEnv *env, jobject obj, jobject peer)
-{
- void *ptr;
-
- gdk_threads_enter ();
-
- ptr = NSA_GET_PTR (env, peer);
-
- g_signal_connect_after (G_OBJECT (ptr), "realize",
- G_CALLBACK (realize_cb), obj);
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_dispose
(JNIEnv *env, jobject obj)
{
struct graphics2d *gr = NULL;
- gdk_threads_enter();
-
gr = (struct graphics2d *) NSA_DEL_G2D_PTR (env, obj);
- if (gr == NULL)
+ /* dispose has been called more than once */
+ if (gr == NULL)
+ return;
+
+ gdk_threads_enter();
+
+ if (peer_is_disposed(env, obj))
{
gdk_threads_leave();
- return; /* dispose has been called more than once */
+ return;
}
if (gr->surface)
cairo_surface_destroy (gr->surface);
+ gr->surface = NULL;
cairo_destroy (gr->cr);
+ gr->cr = NULL;
if (gr->drawbuf)
g_object_unref (gr->drawbuf);
+ gr->drawbuf = NULL;
if (gr->drawable)
g_object_unref (gr->drawable);
+ gr->drawable = NULL;
if (gr->pattern)
cairo_pattern_destroy (gr->pattern);
+ gr->pattern = NULL;
if (gr->pattern_surface)
cairo_surface_destroy (gr->pattern_surface);
+ gr->pattern_surface = NULL;
if (gr->pattern_pixels)
g_free (gr->pattern_pixels);
+ gr->pattern_pixels = NULL;
if (gr->mode == MODE_JAVA_ARRAY)
{
(*env)->DeleteGlobalRef (env, gr->jarray);
if (gr->javabuf_copy)
g_free (gr->javabuf_copy);
+ gr->javabuf_copy = NULL;
}
if (gr->debug) printf ("disposed of graphics2d\n");
@@ -768,27 +683,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_dispose
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradient
- (JNIEnv *env, jobject obj,
- jdouble x1, jdouble y1,
- jdouble x2, jdouble y2,
- jint r1, jint g1, jint b1, jint a1,
- jint r2, jint g2, jint b2, jint a2,
- jboolean cyclic)
-{
- gdk_threads_enter();
- Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradientUnlocked
- (env, obj,
- x1, y1, x2, y2,
- r1, g1, b1, a1,
- r2, g2, b2, a2,
- cyclic);
-
- gdk_threads_leave();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradientUnlocked
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradient
(JNIEnv *env, jobject obj,
jdouble x1, jdouble y1,
jdouble x2, jdouble y2,
@@ -804,11 +699,16 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradientUnlocked
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
+ gdk_threads_enter();
+
if (peer_is_disposed(env, obj))
- return;
+ {
+ gdk_threads_leave();
+ return;
+ }
if (gr->debug)
- printf ("setGradientUnlocked (%f,%f) -> (%f,%f); (%d,%d,%d,%d) -> (%d,%d,%d,%d)\n",
+ printf ("setGradient (%f,%f) -> (%f,%f); (%d,%d,%d,%d) -> (%d,%d,%d,%d)\n",
x1, y1,
x2, y2,
r1, g1, b1, a1,
@@ -907,35 +807,30 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradientUnlocked
gr->pattern = cairo_pattern_create_for_surface(surf);
cairo_set_source (gr->cr, gr->pattern);
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixels
- (JNIEnv *env, jobject obj, jintArray jarr, jint w, jint h, jint stride)
-{
- gdk_threads_enter();
-
- Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixelsUnlocked
- (env, obj, jarr, w, h, stride);
gdk_threads_leave();
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixelsUnlocked
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixels
(JNIEnv *env, jobject obj, jintArray jarr, jint w, jint h, jint stride)
{
struct graphics2d *gr = NULL;
jint *jpixels = NULL;
+ gdk_threads_enter();
+
if (peer_is_disposed(env, obj))
- return;
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug)
- printf ("setTexturePixelsUnlocked (%d pixels, %dx%d, stride: %d)\n",
+ printf ("setTexturePixels (%d pixels, %dx%d, stride: %d)\n",
(*env)->GetArrayLength (env, jarr), w, h, stride);
if (gr->pattern)
@@ -967,6 +862,8 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixelsUnlocked
g_assert (gr->pattern != NULL);
cairo_pattern_set_extend (gr->pattern, CAIRO_EXTEND_REPEAT);
cairo_set_source (gr->cr, gr->pattern);
+
+ gdk_threads_leave();
}
JNIEXPORT void JNICALL
@@ -1079,34 +976,22 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoRestore
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrix
- (JNIEnv *env, jobject obj, jdoubleArray java_matrix)
-{
- gdk_threads_enter();
-
- Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrixUnlocked
- (env, obj, java_matrix);
-
- gdk_threads_leave();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrixUnlocked
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrix
(JNIEnv *env, jobject obj, jdoubleArray java_matrix)
{
struct graphics2d *gr = NULL;
jdouble *native_matrix = NULL;
+ gdk_threads_enter();
+
if (peer_is_disposed(env, obj))
- return;
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
- /* cairoSetMatrix was called before this graphics object's component
- was realized. */
- if (gr == NULL)
- return;
-
native_matrix = (*env)->GetDoubleArrayElements (env, java_matrix, NULL);
g_assert (native_matrix != NULL);
g_assert ((*env)->GetArrayLength (env, java_matrix) == 6);
@@ -1130,6 +1015,8 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrixUnlocked
(*env)->ReleaseDoubleArrayElements (env, java_matrix, native_matrix, 0);
update_pattern_transform (gr);
+
+ gdk_threads_leave();
}
static void
@@ -1142,37 +1029,43 @@ install_font_peer(cairo_t *cr,
g_assert(cr != NULL);
g_assert(pfont != NULL);
-
+
if (pfont->graphics_resource == NULL)
{
face = pango_ft2_font_get_face (pfont->font);
g_assert (face != NULL);
-
+
ft = cairo_ft_font_face_create_for_ft_face (face, 0);
g_assert (ft != NULL);
-
- if (debug) printf ("install_font_peer made new cairo font for '%s' at %f\n",
+
+ if (debug) printf ("install_font_peer made new cairo font for '%s' at %f\n",
face->family_name,
- (pango_font_description_get_size (pfont->desc) /
+ (pango_font_description_get_size (pfont->desc) /
(double)PANGO_SCALE));
-
- cairo_set_font_face (cr, ft);
+
+ cairo_set_font_face (cr, ft);
cairo_font_face_destroy (ft);
- cairo_set_font_size (cr,
- (pango_font_description_get_size (pfont->desc) /
- (double)PANGO_SCALE));
+ cairo_set_font_size (cr,
+ (pango_font_description_get_size (pfont->desc) /
+ (double)PANGO_SCALE));
ft = cairo_get_font_face (cr);
pfont->graphics_resource = ft;
}
else
{
- if (debug) printf ("install_font_peer reused existing font resource\n");
+ if (debug) printf ("install_font_peer reused existing font resource"
+ " for '%s' at %f\n",
+ pango_font_description_get_family(pfont->desc),
+ (pango_font_description_get_size (pfont->desc) /
+ (double)PANGO_SCALE));
ft = (cairo_font_face_t *) pfont->graphics_resource;
- cairo_set_font_face (cr, ft);
+ cairo_set_font_face (cr, ft);
+ cairo_set_font_size (cr,
+ (pango_font_description_get_size (pfont->desc) /
+ (double)PANGO_SCALE));
}
}
-
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_releasePeerGraphicsResource
(JNIEnv *env, jclass clazz __attribute__ ((unused)), jobject java_font)
@@ -1253,7 +1146,7 @@ paint_glyph_run(JNIEnv *env,
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoDrawGlyphVector
- (JNIEnv *env, jobject self,
+ (JNIEnv *env, jobject obj,
jobject font,
jfloat x, jfloat y, jint n,
jintArray java_codes,
@@ -1269,17 +1162,17 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoDrawGlyphVector
gdk_threads_enter ();
- g_assert (self != NULL);
- g_assert (java_codes != NULL);
- g_assert (java_positions != NULL);
-
- if (peer_is_disposed(env, self))
+ if (peer_is_disposed(env, obj))
{
gdk_threads_leave();
return;
}
- gr = (struct graphics2d *)NSA_GET_G2D_PTR (env, self);
+ g_assert (obj != NULL);
+ g_assert (java_codes != NULL);
+ g_assert (java_positions != NULL);
+
+ gr = (struct graphics2d *)NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
pfont = (struct peerfont *)NSA_GET_FONT_PTR (env, font);
@@ -1314,7 +1207,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoDrawGlyphVector
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoDrawGdkTextLayout
- (JNIEnv *env, jobject self, jobject java_layout, jfloat x, jfloat y)
+ (JNIEnv *env, jobject obj, jobject java_layout, jfloat x, jfloat y)
{
/*
* FIXME: Some day we expect either cairo or pango will know how to make
@@ -1328,12 +1221,10 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoDrawGdkTextLayout
cairo_glyph_t *glyphs = NULL;
gint n_glyphs = 0;
- gdk_threads_enter ();
-
- g_assert (self != NULL);
+ g_assert (obj != NULL);
g_assert (java_layout != NULL);
- gr = (struct graphics2d *)NSA_GET_G2D_PTR (env, self);
+ gr = (struct graphics2d *)NSA_GET_G2D_PTR (env, obj);
tl = (struct textlayout *)NSA_GET_TEXT_LAYOUT_PTR (env, java_layout);
g_assert (gr != NULL);
@@ -1342,7 +1233,9 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoDrawGdkTextLayout
if (gr->debug) printf ("painting pango layout\n");
- if (peer_is_disposed(env, self))
+ gdk_threads_enter ();
+
+ if (peer_is_disposed(env, obj))
{
gdk_threads_leave();
return;
@@ -1443,25 +1336,18 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetOperator
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBAColor
- (JNIEnv *env, jobject obj, jdouble r, jdouble g, jdouble b, jdouble a)
-{
- gdk_threads_enter();
-
- Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBAColorUnlocked
- (env, obj, r, g, b, a);
-
- gdk_threads_leave();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBAColorUnlocked
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBAColor
(JNIEnv *env, jobject obj, jdouble r, jdouble g, jdouble b, jdouble a)
{
struct graphics2d *gr = NULL;
+ gdk_threads_enter();
+
if (peer_is_disposed(env, obj))
- return;
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@@ -1478,6 +1364,8 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBAColorUnlocked
cairo_set_source_rgba (gr->cr, b, g, r, a);
else
cairo_set_source_rgba (gr->cr, r, g, b, a);
+
+ gdk_threads_leave();
}
JNIEXPORT void JNICALL
@@ -1505,58 +1393,46 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetFillRule
case java_awt_geom_path_iterator_WIND_EVEN_ODD:
cairo_set_fill_rule (gr->cr, CAIRO_FILL_RULE_EVEN_ODD);
break;
- }
-
- gdk_threads_leave();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineWidth
- (JNIEnv *env, jobject obj, jdouble width)
-{
- gdk_threads_enter();
-
- Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineWidthUnlocked
- (env, obj, width);
+ }
gdk_threads_leave();
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineWidthUnlocked
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineWidth
(JNIEnv *env, jobject obj, jdouble width)
{
struct graphics2d *gr = NULL;
+ gdk_threads_enter();
+
if (peer_is_disposed(env, obj))
- return;
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_set_line_width %f\n", width);
cairo_set_line_width (gr->cr, width);
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCap
- (JNIEnv *env, jobject obj, jint cap)
-{
- gdk_threads_enter();
-
- Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCapUnlocked
- (env, obj, cap);
gdk_threads_leave();
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCapUnlocked
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCap
(JNIEnv *env, jobject obj, jint cap)
{
struct graphics2d *gr = NULL;
+ gdk_threads_enter();
+
if (peer_is_disposed(env, obj))
- return;
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@@ -1575,28 +1451,23 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCapUnlocked
cairo_set_line_cap (gr->cr, CAIRO_LINE_CAP_SQUARE);
break;
}
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoin
- (JNIEnv *env, jobject obj, jint join)
-{
- gdk_threads_enter();
-
- Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoinUnlocked
- (env, obj, join);
gdk_threads_leave();
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoinUnlocked
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoin
(JNIEnv *env, jobject obj, jint join)
{
struct graphics2d *gr = NULL;
+ gdk_threads_enter();
+
if (peer_is_disposed(env, obj))
- return;
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@@ -1615,29 +1486,24 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoinUnlocked
cairo_set_line_join (gr->cr, CAIRO_LINE_JOIN_BEVEL);
break;
}
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDash
- (JNIEnv *env, jobject obj, jdoubleArray dashes, jint ndash, jdouble offset)
-{
- gdk_threads_enter();
-
- Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDashUnlocked
- (env, obj, dashes, ndash, offset);
gdk_threads_leave();
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDashUnlocked
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDash
(JNIEnv *env, jobject obj, jdoubleArray dashes, jint ndash, jdouble offset)
{
struct graphics2d *gr = NULL;
jdouble *dasharr = NULL;
+ gdk_threads_enter();
+
if (peer_is_disposed(env, obj))
- return;
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@@ -1646,33 +1512,30 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDashUnlocked
g_assert (dasharr != NULL);
cairo_set_dash (gr->cr, dasharr, ndash, offset);
(*env)->ReleaseDoubleArrayElements (env, dashes, dasharr, 0);
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMiterLimit
- (JNIEnv *env, jobject obj, jdouble miter)
-{
- gdk_threads_enter();
-
- Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMiterLimitUnlocked
- (env, obj, miter);
gdk_threads_leave();
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMiterLimitUnlocked
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMiterLimit
(JNIEnv *env, jobject obj, jdouble miter)
{
struct graphics2d *gr = NULL;
+ gdk_threads_enter();
+
if (peer_is_disposed(env, obj))
- return;
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_set_miter_limit %f\n", miter);
cairo_set_miter_limit (gr->cr, miter);
+
+ gdk_threads_leave();
}
JNIEXPORT void JNICALL
@@ -1681,6 +1544,8 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoNewPath
{
struct graphics2d *gr = NULL;
+ gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
+
gdk_threads_enter();
if (peer_is_disposed(env, obj))
@@ -1689,14 +1554,6 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoNewPath
return;
}
- gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
-
- if (gr == NULL)
- {
- gdk_threads_leave ();
- return;
- }
-
if (gr->debug) printf ("cairo_new_path\n");
cairo_new_path (gr->cr);
@@ -1845,6 +1702,8 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoRectangle
{
struct graphics2d *gr = NULL;
+ gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
+
gdk_threads_enter();
if (peer_is_disposed(env, obj))
@@ -1853,14 +1712,6 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoRectangle
return;
}
- gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
-
- if (gr == NULL)
- {
- gdk_threads_leave ();
- return;
- }
-
if (gr->debug)
printf ("cairo_rectangle (%f, %f) (%f, %f)\n", x, y, width, height);
cairo_rectangle (gr->cr, x, y, width, height);
@@ -1944,6 +1795,8 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoClip
{
struct graphics2d *gr = NULL;
+ gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
+
gdk_threads_enter();
if (peer_is_disposed(env, obj))
@@ -1952,14 +1805,6 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoClip
return;
}
- gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
-
- if (gr == NULL)
- {
- gdk_threads_leave ();
- return;
- }
-
if (gr->debug) printf ("cairo_clip\n");
begin_drawing_operation (env, gr);
cairo_reset_clip (gr->cr);
@@ -1973,22 +1818,15 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSurfaceSetFilter
(JNIEnv *env, jobject obj, jint filter)
{
- gdk_threads_enter();
-
- Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSurfaceSetFilterUnlocked
- (env, obj, filter);
-
- gdk_threads_leave();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSurfaceSetFilterUnlocked
- (JNIEnv *env, jobject obj, jint filter)
-{
struct graphics2d *gr = NULL;
+ gdk_threads_enter();
+
if (peer_is_disposed(env, obj))
- return;
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@@ -2015,4 +1853,6 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSurfaceSetFilterUnlocked
cairo_pattern_set_filter (gr->pattern, CAIRO_FILTER_BEST);
break;
}
+
+ gdk_threads_leave();
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c
index f44361972..ef9ac1207 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c
@@ -56,17 +56,3 @@ Java_gnu_java_awt_peer_gtk_GtkCanvasPeer_create
gdk_threads_leave ();
}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GtkCanvasPeer_realize (JNIEnv *env, jobject obj)
-{
- void *ptr;
-
- gdk_threads_enter ();
-
- ptr = NSA_GET_PTR (env, obj);
-
- gtk_widget_realize (GTK_WIDGET (ptr));
-
- gdk_threads_leave ();
-}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
index acf646591..4cd80a73f 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
@@ -754,6 +754,20 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetForeground
}
JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkComponentPeer_realize (JNIEnv *env, jobject obj)
+{
+ void *ptr;
+
+ gdk_threads_enter ();
+
+ ptr = NSA_GET_PTR (env, obj);
+
+ gtk_widget_realize (GTK_WIDGET (ptr));
+
+ gdk_threads_leave ();
+}
+
+JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkComponentPeer_setVisibleNative
(JNIEnv *env, jobject obj, jboolean visible)
{
@@ -798,30 +812,6 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_isEnabled
}
JNIEXPORT jboolean JNICALL
-Java_gnu_java_awt_peer_gtk_GtkComponentPeer_isRealized
- (JNIEnv *env, jobject obj)
-{
- void *ptr;
- jboolean ret_val;
-
- gdk_threads_enter ();
-
- ptr = NSA_GET_PTR (env, obj);
-
- if (ptr == NULL)
- {
- gdk_threads_leave ();
- return FALSE;
- }
-
- ret_val = GTK_WIDGET_REALIZED (get_widget(GTK_WIDGET (ptr)));
-
- gdk_threads_leave ();
-
- return ret_val;
-}
-
-JNIEXPORT jboolean JNICALL
Java_gnu_java_awt_peer_gtk_GtkComponentPeer_modalHasGrab
(JNIEnv *env __attribute__((unused)), jclass clazz __attribute__((unused)))
{
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
index b40e86289..dad6a1182 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
@@ -37,8 +37,10 @@ exception statement from your version. */
#include "jcl.h"
#include "gtkpeer.h"
+#include <cairo-xlib.h>
+#include <gdk/gdkx.h>
+
#include "gnu_java_awt_peer_gtk_GtkImage.h"
-#include <gdk-pixbuf/gdk-pixbuf.h>
/* The constant fields in java.awt.Image */
#define SCALE_DEFAULT 1
@@ -324,7 +326,7 @@ Java_gnu_java_awt_peer_gtk_GtkImage_drawPixelsScaled
jint x, jint y, jint width, jint height, jboolean composite)
{
GdkPixbuf* dst;
- struct graphics *g;
+ struct graphics2d *g;
guint32 bgColor;
gdk_threads_enter ();
@@ -338,7 +340,7 @@ Java_gnu_java_awt_peer_gtk_GtkImage_drawPixelsScaled
bgColor = ((bg_red & 0xFF) << 16) |
((bg_green & 0xFF) << 8) | (bg_blue & 0xFF);
- g = (struct graphics *) NSA_GET_G_PTR (env, gc_obj);
+ g = (struct graphics2d *) NSA_GET_G2D_PTR (env, gc_obj);
if (!g || !GDK_IS_DRAWABLE (g->drawable))
{
@@ -365,24 +367,16 @@ Java_gnu_java_awt_peer_gtk_GtkImage_drawPixelsScaled
width, height,
GDK_INTERP_BILINEAR);
- gdk_draw_pixbuf (g->drawable,
- g->gc,
- dst,
- 0, 0,
- x + g->x_offset, y + g->y_offset,
- width, height,
- GDK_RGB_DITHER_NORMAL, 0, 0);
+ gdk_cairo_set_source_pixbuf (g->cr, dst, (double) x, (double) y);
gdk_pixbuf_unref (dst);
} else {
/* Get a pixmap */
GdkPixmap* pixmap = (GdkPixmap *)getData (env, obj);
- gdk_draw_drawable (g->drawable,
- g->gc,
- pixmap,
- 0, 0, /* src x,y */
- x + g->x_offset, y + g->y_offset,
- width, height);
+ cairo_xlib_surface_set_drawable (g->surface,
+ GDK_PIXMAP_XID(pixmap),
+ width,
+ height);
}
gdk_threads_leave ();
@@ -408,7 +402,7 @@ Java_gnu_java_awt_peer_gtk_GtkImage_drawPixelsScaledFlipped
{
GdkPixbuf *pixbuf;
GdkPixbuf *tmp, *dst;
- struct graphics *g;
+ struct graphics2d *g;
guint32 bgColor;
gdk_threads_enter ();
@@ -423,7 +417,7 @@ Java_gnu_java_awt_peer_gtk_GtkImage_drawPixelsScaledFlipped
bgColor = ((bg_red & 0xFF) << 16) |
((bg_green & 0xFF) << 8) | (bg_blue & 0xFF);
- g = (struct graphics *) NSA_GET_G_PTR (env, gc_obj);
+ g = (struct graphics2d *) NSA_GET_G2D_PTR (env, gc_obj);
if (!g || !GDK_IS_DRAWABLE (g->drawable))
{
@@ -492,14 +486,8 @@ Java_gnu_java_awt_peer_gtk_GtkImage_drawPixelsScaledFlipped
GDK_INTERP_BILINEAR);
gdk_pixbuf_unref (tmp);
- gdk_draw_pixbuf (g->drawable,
- g->gc,
- dst,
- 0, 0,
- dstx + g->x_offset, dsty + g->y_offset,
- dstwidth, dstheight,
- GDK_RGB_DITHER_NORMAL, 0, 0);
-
+ gdk_cairo_set_source_pixbuf (g->cr, dst, (double) dstx,
+ (double) dsty);
gdk_pixbuf_unref (dst);
gdk_threads_leave ();
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
index b14330e5f..c966f6331 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
@@ -185,10 +185,6 @@ Java_gnu_java_awt_peer_gtk_GtkToolkit_gtkInit (JNIEnv *env,
old_glog_func = g_log_set_default_handler (&glog_func, NULL);
#endif
-#if GTK_CAIRO
- cp_gtk_graphics2d_init_jni ();
-#endif
- cp_gtk_graphics_init_jni ();
cp_gtk_button_init_jni ();
cp_gtk_checkbox_init_jni ();
cp_gtk_choice_init_jni ();
diff --git a/native/jni/gtk-peer/gtkcairopeer.h b/native/jni/gtk-peer/gtkcairopeer.h
deleted file mode 100644
index dee843c8a..000000000
--- a/native/jni/gtk-peer/gtkcairopeer.h
+++ /dev/null
@@ -1,93 +0,0 @@
-#ifndef __GTKCAIROPEER_H__
-#define __GTKCAIROPEER_H__
-
-/* gtkcairopeer.h -- Some global variables and #defines
- Copyright (C) 1998, 1999 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-#include "gtkpeer.h"
-#include <cairo.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
-
-/*
- A graphics2d struct is both simpler and uglier than a graphics
- struct.
-
- Most of the graphics2d drawing state is held in the referenced cairo_t
- and corresponding cairo_surface_t, so we can ignore it.
-
- In addition to the cairo_t, we need to hold an extra reference to the
- underlying GdkDrawable so its refcount matches the lifecycle of the java
- Graphics object which is peering with us; also a reference to a byte
- buffer and cairo_surface_t which contain the pattern you're drawing from
- (if it exists).
-
- Finally, it is possible that we are using a non-RENDER capable X server,
- therefore we will be drawing to an cairo_surface_t which is actually a
- pixbuf. When this is the case, the pointer to a GdkPixbuf will be
- non-NULL and any drawing operation needs to be bracketed by pixbuf
- load/save operations. If the GdkPixbuf pointer is NULL, we will treat
- the cairo_surface_t as RENDER-capable.
- */
-
-struct graphics2d
-{
- cairo_t *cr;
- cairo_surface_t *surface;
- GdkDrawable *drawable;
- GdkWindow *win;
- GdkPixbuf *drawbuf;
- char *pattern_pixels;
- cairo_surface_t *pattern_surface;
- cairo_pattern_t *pattern;
- gboolean debug;
- enum
- {
- MODE_DRAWABLE_WITH_RENDER,
- MODE_DRAWABLE_NO_RENDER,
- MODE_JAVA_ARRAY
- }
- mode;
-
- /* Support for MODE_JAVA_ARRAY */
- jintArray jarray;
- jint width, height;
- jint *javabuf;
- jint *javabuf_copy;
- jboolean isCopy;
-};
-
-#endif /* __GTKCAIROPEER_H */
diff --git a/native/jni/gtk-peer/gtkpeer.h b/native/jni/gtk-peer/gtkpeer.h
index 9a1590b81..6ae7b06ae 100644
--- a/native/jni/gtk-peer/gtkpeer.h
+++ b/native/jni/gtk-peer/gtkpeer.h
@@ -36,12 +36,14 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+#include <cairo.h>
#include <gtk/gtk.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <config.h>
#include "native_state.h"
+#include <gdk-pixbuf/gdk-pixbuf.h>
#include <jni.h>
@@ -54,6 +56,7 @@ exception statement from your version. */
extern struct state_table *cp_gtk_native_state_table;
extern struct state_table *cp_gtk_native_global_ref_table;
+extern struct state_table *cp_gtk_native_graphics2d_state_table;
#define NSA_INIT(env, clazz) \
do {cp_gtk_native_state_table = cp_gtk_init_state_table (env, clazz); \
@@ -83,32 +86,66 @@ extern struct state_table *cp_gtk_native_global_ref_table;
(*env)->DeleteGlobalRef (env, *globRefPtr); \
free (globRefPtr);} while (0)
-extern struct state_table *cp_gtk_native_graphics_state_table;
+#define NSA_G2D_INIT(env, clazz) \
+ cp_gtk_native_graphics2d_state_table = cp_gtk_init_state_table (env, clazz)
-#define NSA_G_INIT(env, clazz) \
- cp_gtk_native_graphics_state_table = cp_gtk_init_state_table (env, clazz)
+#define NSA_GET_G2D_PTR(env, obj) \
+ cp_gtk_get_state (env, obj, cp_gtk_native_graphics2d_state_table)
-#define NSA_GET_G_PTR(env, obj) \
- cp_gtk_get_state (env, obj, cp_gtk_native_graphics_state_table)
+#define NSA_SET_G2D_PTR(env, obj, ptr) \
+ cp_gtk_set_state (env, obj, cp_gtk_native_graphics2d_state_table, (void *)ptr)
-#define NSA_SET_G_PTR(env, obj, ptr) \
- cp_gtk_set_state (env, obj, cp_gtk_native_graphics_state_table, (void *)ptr)
-
-#define NSA_DEL_G_PTR(env, obj) \
- cp_gtk_remove_state_slot (env, obj, cp_gtk_native_graphics_state_table)
+#define NSA_DEL_G2D_PTR(env, obj) \
+ cp_gtk_remove_state_slot (env, obj, cp_gtk_native_graphics2d_state_table)
#define SWAPU32(w) \
(((w) << 24) | (((w) & 0xff00) << 8) | (((w) >> 8) & 0xff00) | ((w) >> 24))
-struct graphics
+/*
+ A graphics2d struct is both simpler and uglier than a graphics
+ struct.
+
+ Most of the graphics2d drawing state is held in the referenced cairo_t
+ and corresponding cairo_surface_t, so we can ignore it.
+
+ In addition to the cairo_t, we need to hold an extra reference to the
+ underlying GdkDrawable so its refcount matches the lifecycle of the java
+ Graphics object which is peering with us; also a reference to a byte
+ buffer and cairo_surface_t which contain the pattern you're drawing from
+ (if it exists).
+
+ Finally, it is possible that we are using a non-RENDER capable X server,
+ therefore we will be drawing to an cairo_surface_t which is actually a
+ pixbuf. When this is the case, the pointer to a GdkPixbuf will be
+ non-NULL and any drawing operation needs to be bracketed by pixbuf
+ load/save operations. If the GdkPixbuf pointer is NULL, we will treat
+ the cairo_surface_t as RENDER-capable.
+ */
+struct graphics2d
{
+ cairo_t *cr;
+ cairo_surface_t *surface;
GdkDrawable *drawable;
- GdkGC *gc;
- GdkColormap *cm;
- PangoFontDescription *pango_font;
- PangoContext *pango_context;
- PangoLayout *pango_layout;
- jint x_offset, y_offset;
+ GdkWindow *win;
+ GdkPixbuf *drawbuf;
+ char *pattern_pixels;
+ cairo_surface_t *pattern_surface;
+ cairo_pattern_t *pattern;
+ gboolean debug;
+ enum
+ {
+ MODE_DRAWABLE_WITH_RENDER,
+ MODE_DRAWABLE_NO_RENDER,
+ MODE_JAVA_ARRAY
+ }
+ mode;
+
+ /* Support for MODE_JAVA_ARRAY */
+ jintArray jarray;
+ jint width, height;
+ jint *javabuf;
+ jint *javabuf_copy;
+ jboolean isCopy;
};
/* New-style event masks. */
@@ -196,10 +233,6 @@ GdkPixmap *cp_gtk_image_get_pixmap (JNIEnv *env, jobject obj);
jboolean cp_gtk_image_is_offscreen (JNIEnv *env, jobject obj);
/* JNI initialization functions */
-#if GTK_CAIRO
-void cp_gtk_graphics2d_init_jni (void);
-#endif
-void cp_gtk_graphics_init_jni (void);
void cp_gtk_button_init_jni (void);
void cp_gtk_checkbox_init_jni (void);
void cp_gtk_choice_init_jni (void);