Hello all.
First I would like to apologize my absense these days, I had some exams on
univ. :/
But I cleaned up the patch, it's on the attach.
I also created a google code
page<http://code.google.com/p/gsoc-classpath-escher-marcosroriz/>
Should I clone and put the escher repo there (? - I'm still learning mercury
^_^, it's cool) .
I also found this excellent book: Xlib Programming
Manual<http://www.sbin.org/doc/Xlib/index_contents.html>it's about
Xlib but address lots of stuff on X.
I'm reading and it's an excellent reference.
Regards,
Marcos Roriz
2010/5/3 Mario Torre <[email protected]>
> Il giorno dom, 02/05/2010 alle 02.57 -0300, Marcos Roriz ha scritto:
> > I finished up a patch that compiles the current Escher (Hg) with the
> > current GNU Classpath (CVS). The major problems in the compilation was
> > the difference between method name and the number/types of parameters
> > in classpath and escher. After some fixing everything is fine. Now
> > I'll generate some simple application tests (Hello World GUI, as Mario
> > Torre said =D).
> >
> > Regards,
> >
> > Marcos Roriz
>
> Hi Marcos,
>
> Thanks for the patch!
>
> I see there are a number of white space changes that make difficult to
> read the patch.
>
> Those white space changes are also affecting the formatting, so it's not
> OK, because they break the GNU coding guidelines.
>
> Please, try to export the patch ignoring white spaces changes and
> resubmit.
>
> Other than that, it looks good though, so now post a screen shot of your
> first Escher based HelloWorld somewhere!! :)
>
> Cheers,
> Mario
> --
> pgp key: http://subkeys.pgp.net/ PGP Key ID: 80F240CF
> Fingerprint: BA39 9666 94EC 8B73 27FA FC7C 4086 63E3 80F2 40CF
>
> Proud GNU Classpath developer: http://www.classpath.org/
> Read About us at: http://planet.classpath.org
> OpenJDK: http://openjdk.java.net/projects/caciocavallo/
>
> Please, support open standards:
> http://endsoftpatents.org/
>
>
--
Marcos Roriz
Bacharelando em Ciência da Computação
Universidade Federal de Goiás
E-mail: [email protected]
Home Page:http://marcosroriz.wordpress.com
### Eclipse Workspace Patch 1.0
#P classpath
Index: gnu/java/awt/peer/x/PixmapVolatileImage.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/x/PixmapVolatileImage.java,v
retrieving revision 1.2
diff -u -r1.2 PixmapVolatileImage.java
--- gnu/java/awt/peer/x/PixmapVolatileImage.java 16 Jul 2007 15:04:53 -0000 1.2
+++ gnu/java/awt/peer/x/PixmapVolatileImage.java 5 May 2010 02:02:57 -0000
@@ -37,6 +37,7 @@
package gnu.java.awt.peer.x;
+import gnu.x11.EscherUnsupportedScreenBitDepthException;
import gnu.x11.GC;
import gnu.x11.Pixmap;
import gnu.x11.image.Image;
@@ -124,6 +125,8 @@
@Override
public BufferedImage getSnapshot()
{
+ try
+ {
// TODO: Support non-24-bit resolutions.
int w = pixmap.width;
int h = pixmap.height;
@@ -140,8 +143,15 @@
WritableRaster raster = Raster.createWritableRaster(sm, buffer,
new Point(0, 0));
return new BufferedImage(cm, raster, false, null);
+ }
+ catch (EscherUnsupportedScreenBitDepthException e)
+ {
+ // TODO See this exception
+ e.printStackTrace();
+ return null;
+ }
}
-
+
@Override
public int getWidth()
{
Index: gnu/java/awt/peer/x/XGraphics2D.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/x/XGraphics2D.java,v
retrieving revision 1.12
diff -u -r1.12 XGraphics2D.java
--- gnu/java/awt/peer/x/XGraphics2D.java 15 Jun 2008 18:14:55 -0000 1.12
+++ gnu/java/awt/peer/x/XGraphics2D.java 5 May 2010 02:02:59 -0000
@@ -62,7 +62,9 @@
import gnu.java.awt.java2d.ScanlineCoverage;
import gnu.x11.Colormap;
import gnu.x11.Drawable;
+import gnu.x11.EscherUnsupportedScreenBitDepthException;
import gnu.x11.GC;
+import gnu.x11.RGB;
import gnu.x11.image.ZPixmap;
public class XGraphics2D
@@ -215,10 +217,12 @@
*/
protected void updateRaster(Raster raster, int x, int y, int w, int h)
{
+ try
+ {
if (w > 0 && h > 0)
{
- ZPixmap zPixmap = new ZPixmap(xdrawable.display, w, h,
- xdrawable.display.default_pixmap_format);
+ ZPixmap zPixmap = new ZPixmap(xdrawable.display, w, h, xdrawable.display.default_pixmap_format,
+ xdrawable.display.getVisualInfo(xdrawable.display.display_no));
int[] pixel = null;
int x1 = x + w;
int y1 = y + h;
@@ -231,13 +235,17 @@
// System.err.print("r: " + pixel[0]);
// System.err.print(", g: " + pixel[1]);
// System.err.println(", b: " + pixel[2]);
- zPixmap.set_red(tx - x, ty - y, pixel[0]);
- zPixmap.set_green(tx - x, ty - y, pixel[1]);
- zPixmap.set_blue(tx - x, ty - y, pixel[2]);
+ zPixmap.putRGB(tx - x, ty - y, new RGB(pixel[0], pixel[1], pixel[2]));
}
}
xdrawable.put_image(xgc, zPixmap, x, y);
}
+ }
+ catch (EscherUnsupportedScreenBitDepthException e)
+ {
+ // TODO See this exception
+ e.printStackTrace();
+ }
}
@Override
@@ -264,6 +272,8 @@
}
else if (coverageAlpha > 0)
{
+ try
+ {
// Composite the current color with the existing pixels.
int x1 = x0 + l;
x0 = Math.min(Math.max(0, x0), xdrawable.width - 1);
@@ -284,9 +294,10 @@
int red = col.getRed();
int green = col.getGreen();
int blue = col.getBlue();
- int redOut = existing.get_red(x, 0);
- int greenOut = existing.get_green(x, 0);
- int blueOut = existing.get_blue(x, 0);
+ RGB exRGB = existing.getRGB(x, 0);
+ int redOut = exRGB.red;
+ int greenOut = exRGB.green;
+ int blueOut = exRGB.blue;
int outAlpha = maxCoverage - coverageAlpha;
redOut = redOut * outAlpha + red * coverageAlpha;
redOut = redOut / maxCoverage;
@@ -294,10 +305,16 @@
greenOut = greenOut / maxCoverage;
blueOut = blueOut * outAlpha + blue * coverageAlpha;
blueOut = blueOut / maxCoverage;
- existing.set(x, 0, redOut, greenOut, blueOut);
+ existing.putRGB(x, 0, redOut, greenOut, blueOut);
}
xdrawable.put_image(xgc, existing, x0, y);
- }
+ }
+ catch (EscherUnsupportedScreenBitDepthException e)
+ {
+ // TODO See this exception
+ e.printStackTrace();
+ }
+ }
}
}
@@ -381,20 +398,34 @@
}
else if (transparency == Transparency.OPAQUE || RENDER_OPAQUE)
{
+ try
+ {
XGraphicsDevice gd = XToolkit.getDefaultDevice();
- ZPixmap zpixmap = new ZPixmap(gd.getDisplay(), w, h);
+ ZPixmap zpixmap = new ZPixmap(gd.getDisplay(), w, h,
+ xdrawable.display.getVisualInfo(xdrawable.display.display_no));
for (int yy = 0; yy < h; yy++)
{
for (int xx = 0; xx < w; xx++)
{
int rgb = bi.getRGB(xx, yy);
- zpixmap.set(xx, yy, rgb);
+ int currentRed = 0xFF & (rgb >> 16);
+ int currentGreen = 0xFF & (rgb >> 8);
+ int currentBlue = 0xFF & rgb;
+ zpixmap.putRGB(xx, yy, currentRed, currentGreen, currentBlue);
}
}
xdrawable.put_image(xgc, zpixmap, x, y);
imageCache.put(image, zpixmap);
- } else {
-
+ }
+ catch (EscherUnsupportedScreenBitDepthException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ else
+ {
+ try
+ {
// TODO optimize reusing the rectangles
Rectangle source =
new Rectangle(0, 0, xdrawable.width, xdrawable.height);
@@ -416,40 +447,49 @@
for (int xx = 0; xx < w; xx++)
{
int rgb = bi.getRGB(xx, yy);
+ int currentRed = 0xFF & (rgb >> 16);
+ int currentGreen = 0xFF & (rgb >> 8);
+ int currentBlue = 0xFF & rgb;
int alpha = 0xff & (rgb >> 24);
if (alpha == 0)
{
// Completely translucent.
- rgb = zpixmap.get_red(xx, yy) << 16
- | zpixmap.get_green(xx, yy) << 8
- | zpixmap.get_blue(xx, yy);
+ //rgb = zpixmap.get_red(xx, yy) << 16
+ // | zpixmap.get_green(xx, yy) << 8
+ // | zpixmap.get_blue(xx, yy);
}
else if (alpha < 255)
{
// Composite pixels.
int red = 0xff & (rgb >> 16);
- red = red * alpha
- + (255 - alpha) * zpixmap.get_red(xx, yy);
+ red = red * alpha + (255 - alpha) * currentRed;
red = red / 255;
int green = 0xff & (rgb >> 8);
- green = green * alpha
- + (255 - alpha) * zpixmap.get_green(xx, yy);
+ green = green * alpha + (255 - alpha) * currentGreen;
green = green / 255;
int blue = 0xff & rgb;
- blue = blue * alpha
- + (255 - alpha) * zpixmap.get_blue(xx, yy);
+ blue = blue * alpha + (255 - alpha) * currentBlue;
blue = blue / 255;
+
+ currentRed = red;
+ currentGreen = green;
+ currentBlue = blue;
rgb = red << 16 | green << 8 | blue;
}
// else keep rgb value from source image.
- zpixmap.set(xx, yy, rgb);
+ zpixmap.putRGB(xx, yy, currentRed, currentGreen, currentBlue);
}
}
xdrawable.put_image(xgc, zpixmap, x, y);
// We can't cache prerendered translucent images, because
// we never know how the background changes.
}
+ catch (EscherUnsupportedScreenBitDepthException e)
+ {
+ e.printStackTrace();
+ }
+ }
ret = true;
}
}
Index: gnu/java/awt/peer/x/XWindowPeer.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/x/XWindowPeer.java,v
retrieving revision 1.8
diff -u -r1.8 XWindowPeer.java
--- gnu/java/awt/peer/x/XWindowPeer.java 19 May 2008 14:16:18 -0000 1.8
+++ gnu/java/awt/peer/x/XWindowPeer.java 5 May 2010 02:03:04 -0000
@@ -103,7 +103,7 @@
int y = Math.max(window.getY(), 0);
int w = Math.max(window.getWidth(), 1);
int h = Math.max(window.getHeight(), 1);
- xwindow = new Window(dev.getDisplay().default_root, x, y, w, h, 0, atts);
+ xwindow = new Window(dev.getDisplay().getRootWindow(), x, y, w, h, 0, atts);
xwindow.select_input(standardSelect);
dev.getEventPump().registerWindow(xwindow, window);
Index: gnu/java/awt/peer/x/ZPixmapDataBuffer.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/x/ZPixmapDataBuffer.java,v
retrieving revision 1.2
diff -u -r1.2 ZPixmapDataBuffer.java
--- gnu/java/awt/peer/x/ZPixmapDataBuffer.java 20 Sep 2007 14:01:09 -0000 1.2
+++ gnu/java/awt/peer/x/ZPixmapDataBuffer.java 5 May 2010 02:03:04 -0000
@@ -1,6 +1,7 @@
package gnu.java.awt.peer.x;
import gnu.x11.Display;
+import gnu.x11.EscherUnsupportedScreenBitDepthException;
import gnu.x11.image.ZPixmap;
import java.awt.GraphicsEnvironment;
@@ -33,7 +34,14 @@
GraphicsEnvironment.getLocalGraphicsEnvironment();
XGraphicsDevice dev = (XGraphicsDevice) env.getDefaultScreenDevice();
Display d = dev.getDisplay();
- zpixmap = new ZPixmap(d, w, h, d.default_pixmap_format);
+ try
+ {
+ zpixmap = new ZPixmap(d, w, h, d.default_pixmap_format, d.getVisualInfo(d.display_no));
+ }
+ catch (EscherUnsupportedScreenBitDepthException e)
+ {
+ e.printStackTrace();
+ }
}
/**
@@ -43,20 +51,20 @@
*/
ZPixmapDataBuffer(ZPixmap zpixmap)
{
- super(TYPE_BYTE, zpixmap.get_data_length());
+ super(TYPE_BYTE, zpixmap.getDataLength());
this.zpixmap = zpixmap;
}
@Override
public int getElem(int bank, int i)
{
- return 0xff & zpixmap.get_data_element(i);
+ return 0xff & zpixmap.getDataElement(i);
}
@Override
public void setElem(int bank, int i, int val)
{
- zpixmap.set_data_element(i, (byte) val);
+ zpixmap.setDataElement(i, (byte) val);
}
ZPixmap getZPixmap()
Index: gnu/java/awt/peer/x/XImage.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/x/XImage.java,v
retrieving revision 1.6
diff -u -r1.6 XImage.java
--- gnu/java/awt/peer/x/XImage.java 1 Sep 2008 17:29:53 -0000 1.6
+++ gnu/java/awt/peer/x/XImage.java 5 May 2010 02:03:00 -0000
@@ -38,6 +38,7 @@
package gnu.java.awt.peer.x;
+import gnu.x11.EscherUnsupportedScreenBitDepthException;
import gnu.x11.Pixmap;
import gnu.x11.image.ZPixmap;
@@ -146,6 +147,8 @@
for (ImageConsumer consumer : this.consumers)
{
+ try
+ {
int width = XImage.this.getWidth(null);
int height = XImage.this.getHeight(null);
@@ -158,12 +161,12 @@
0xffffffff,
gnu.x11.image.Image.Format.ZPIXMAP);
- int size = zpixmap.get_data_length();
+ int size = zpixmap.getDataLength();
System.out.println("size: " + size + ", w = " + width + ", h = " + height);
int [] pixel = new int[size];
for (int i = 0; i < size; i++)
- pixel[i] = zpixmap.get_data_element(i);
+ pixel[i] = zpixmap.getDataLength();
consumer.setHints(ImageConsumer.SINGLEPASS);
@@ -171,7 +174,11 @@
consumer.setPixels(0, 0, width, height, model, pixel, 0, width);
consumer.imageComplete(ImageConsumer.STATICIMAGEDONE);
}
-
+ catch (EscherUnsupportedScreenBitDepthException e)
+ {
+ e.printStackTrace();
+ }
+ }
System.out.println("done!");
}
}