Index: gnu/java/awt/peer/gtk/GdkGraphics2D.java =================================================================== RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GdkGraphics2D.java,v retrieving revision 1.26 diff -u -r1.26 GdkGraphics2D.java --- gnu/java/awt/peer/gtk/GdkGraphics2D.java 28 Nov 2004 08:54:21 -0000 1.26 +++ gnu/java/awt/peer/gtk/GdkGraphics2D.java 26 Dec 2004 13:15:57 -0000 @@ -99,18 +99,20 @@ ////////////////////////////////////// ////// State Management Methods ////// ////////////////////////////////////// - static - { - if (Configuration.INIT_LOAD_LIBRARY) - System.loadLibrary("gtkpeer"); - if (GtkToolkit.useGraphics2D()) - initStaticState(); - } + static + { + if (Configuration.INIT_LOAD_LIBRARY) + System.loadLibrary("gtkpeer"); + if (GtkToolkit.useGraphics2D()) + initStaticState(); + } + static native void initStaticState(); + + private final int native_state = GtkGenericPeer.getUniqueInteger(); - private final int native_state = GtkGenericPeer.getUniqueInteger(); private Paint paint; private Stroke stroke; private Color fg; @@ -125,17 +127,11 @@ private Stack stateStack; private native void initState(GtkComponentPeer component); - private native void initState(int width, int height); - private native void copyState(GdkGraphics2D g); - public native void dispose(); - private native int[] getImagePixels(); - private native void cairoSurfaceSetFilter(int filter); - native void connectSignals(GtkComponentPeer component); public void finalize() @@ -258,74 +254,52 @@ //////////////////////////////////// ////// Native Drawing Methods ////// //////////////////////////////////// + // GDK drawing methods private native void gdkDrawDrawable(GdkGraphics2D other, int x, int y); // drawing utility methods private native void drawPixels(int[] pixels, int w, int h, int stride, double[] i2u); - 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); // simple passthroughs to cairo private native void cairoSave(); - private native void cairoRestore(); - private native void cairoSetMatrix(double[] m); - private native void cairoSetOperator(int cairoOperator); - private native void cairoSetRGBColor(double red, double green, double blue); - private native void cairoSetAlpha(double alpha); - private native void cairoSetFillRule(int cairoFillRule); - private native void cairoSetLineWidth(double width); - private native void cairoSetLineCap(int cairoLineCap); - private native void cairoSetLineJoin(int cairoLineJoin); - private native void cairoSetDash(double[] dashes, int ndash, double offset); private native void cairoSetMiterLimit(double limit); - private native void cairoNewPath(); - private native void cairoMoveTo(double x, double y); - private native void cairoLineTo(double x, double y); - private native void cairoCurveTo(double x1, double y1, double x2, double y2, double x3, double y3); - private native void cairoRelMoveTo(double dx, double dy); - private native void cairoRelLineTo(double dx, double dy); - private native void cairoRelCurveTo(double dx1, double dy1, double dx2, double dy2, double dx3, double dy3); - private native void cairoRectangle(double x, double y, double width, double height); - private native void cairoClosePath(); - private native void cairoStroke(); - private native void cairoFill(); - private native void cairoClip(); ///////////////////////////////////////////// ////// General Drawing Support Methods ////// ///////////////////////////////////////////// + private class DrawState { private Paint paint; @@ -556,6 +530,7 @@ ////////////////////////////////////////////////// ////// Implementation of Graphics2D Methods ////// ////////////////////////////////////////////////// + public void draw(Shape s) { if (stroke != null && ! (stroke instanceof BasicStroke)) @@ -591,6 +566,7 @@ } else walkPath(s.getPathIterator(null), false); + cairoFill(); if (isBufferedImageGraphics()) @@ -645,7 +621,9 @@ paint = p; if (paint instanceof Color) - setColor((Color) paint); + { + setColor((Color) paint); + } else if (paint instanceof TexturePaint) { TexturePaint tp = (TexturePaint) paint; @@ -780,6 +758,7 @@ //////////////////////////////////////////////// ////// Implementation of Graphics Methods ////// //////////////////////////////////////////////// + public void setPaintMode() { setComposite(java.awt.AlphaComposite.SrcOver); @@ -1092,6 +1071,7 @@ /////////////////////////////////////////////// ////// Unimplemented Stubs and Overloads ////// /////////////////////////////////////////////// + public boolean hit(Rectangle rect, Shape text, boolean onStroke) { throw new java.lang.UnsupportedOperationException(); @@ -1259,6 +1239,7 @@ // Get the subimage of the source enclosed in the // rectangle specified by sx1, sy1, sx2, sy2 + if (img instanceof BufferedImage) { BufferedImage b = (BufferedImage) img; @@ -1422,6 +1403,7 @@ // Until such time as pango is happy to talk directly to cairo, we // actually need to redirect some calls from the GtkFontPeer and // GtkFontMetrics into the drawing kit and ask cairo ourselves. + static native void releasePeerGraphicsResource(GdkFontPeer f); static native void getPeerTextMetrics(GdkFontPeer f, String str, @@ -1448,15 +1430,16 @@ if (f.getPeer() instanceof GdkFontPeer) font = f; else - font = ((ClasspathToolkit) (Toolkit.getDefaultToolkit())).getFont(f - .getName(), - f - .getAttributes()); + font = + ((ClasspathToolkit)(Toolkit.getDefaultToolkit())) + .getFont(f.getName(), f.getAttributes()); } public String toString() { - return getClass().getName() + "[font=" + font.toString() + ",color=" - + fg.toString() + "]"; + return (getClass().getName() + + "[font=" + font.toString() + + ",color=" + fg.toString() + + "]"); } }