From: megacz Date: Fri, 30 Jan 2004 07:42:51 +0000 (+0000) Subject: 2003/12/13 08:13:34 X-Git-Tag: RC3~269 X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=commitdiff_plain;h=8d5c8bc003e624cb59618a516367e1f1e68382fe 2003/12/13 08:13:34 darcs-hash:20040130074251-2ba56-178483257e92f54bfc6e8be118aeedc2185f77ef.gz --- diff --git a/src/org/xwt/plat/AWT.java b/src/org/xwt/plat/AWT.java index bcde5f0..b7f3b3b 100644 --- a/src/org/xwt/plat/AWT.java +++ b/src/org/xwt/plat/AWT.java @@ -16,7 +16,7 @@ public class AWT extends JVM { protected String getDescriptiveName() { return "Generic JDK 1.1+ with AWT"; } protected PixelBuffer _createPixelBuffer(int w, int h, Surface owner) { return new AWTPixelBuffer(w, h); } - protected Picture _createPicture(int[] b, int w, int h) { return new AWTPicture(b, w, h); } + protected Picture _createPicture() { return new AWTPicture(); } protected int _getScreenWidth() { return Toolkit.getDefaultToolkit().getScreenSize().width; } protected int _getScreenHeight() { return Toolkit.getDefaultToolkit().getScreenSize().height; } protected Surface _createSurface(Box b, boolean framed) { return new AWTSurface(b, framed); } @@ -115,18 +115,41 @@ public class AWT extends JVM { // Inner Classes ///////////////////////////////////////////////////////////////////////////////////// - protected static class AWTPicture extends Picture { - public int getHeight() { return i.getHeight(null); } - public int getWidth() { return i.getWidth(null); } - public int[] getData() { return data; } + protected org.xwt.Font.Glyph _createGlyph(org.xwt.Font f, char c) { return new AWTGlyph(f, c); } + protected static class AWTGlyph extends org.xwt.Font.Glyph { + private Image i = null; + static ColorModel cmodel = new DirectColorModel(8, 0x00000000, 0x00000000, 0x00000000, 0xFF); + public AWTGlyph(org.xwt.Font f, char c) { super(f, c); } + Image getImage() { + if (i == null && isLoaded) { + i = Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(width, height, cmodel, data, 0, width)); + MediaTracker mediatracker = new MediaTracker(new Canvas()); + mediatracker.addImage(i, 1); + try { mediatracker.waitForAll(); } catch (InterruptedException e) { } + mediatracker.removeImage(i); + synchronized(AWTPixelBuffer.class) { + if (AWTPixelBuffer.component == null) { + AWTPixelBuffer.component = new Frame(); + AWTPixelBuffer.component.setVisible(false); + AWTPixelBuffer.component.addNotify(); + } + } + data = null; + } + return i; + } + } + protected static class AWTPicture extends Picture { int[] data = null; public Image i = null; private static ColorModel cmodel = new DirectColorModel(32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000); - public AWTPicture(int[] b, int w, int h) { - data = b; - i = Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(w, h, cmodel, b, 0, w)); + boolean initialized = false; + public void init() { + if (initialized) return; + initialized = true; + i = Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(width, height, cmodel, data, 0, width)); MediaTracker mediatracker = new MediaTracker(new Canvas()); mediatracker.addImage(i, 1); try { mediatracker.waitForAll(); } catch (InterruptedException e) { } @@ -166,13 +189,14 @@ public class AWT extends JVM { public int getWidth() { return i == null ? 0 : i.getWidth(null); } public void drawPicture(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2) { + ((AWTPicture)source).init(); g.setClip(cx1, cy1, cx2 - cx1, cy2 - cy1); g.drawImage(((AWTPicture)source).i, dx, dy, null); g.setClip(0, 0, i.getWidth(null), i.getHeight(null)); } /** implemented with java.awt 1.1's setXORMode() */ - public void drawPictureAlphaOnly(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int rgb) { + public void drawGlyph(org.xwt.Font.Glyph source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int rgb) { // XOR the target region g.setXORMode(new Color((rgb & 0x00ff0000) >> 16, (rgb & 0x0000ff00) >> 8, rgb & 0x000000ff)); @@ -181,7 +205,9 @@ public class AWT extends JVM { // blacken the area we want the glyph to cover g.setPaintMode(); - drawPicture(source, dx, dy, cx1, cy1, cx2, cy2); + g.setClip(cx1, cy1, cx2 - cx1, cy2 - cy1); + g.drawImage(((AWTGlyph)source).getImage(), dx, dy, null); + g.setClip(0, 0, i.getWidth(null), i.getHeight(null)); // XOR back, turning black into the chosen rgb color g.setXORMode(new Color((rgb & 0x00ff0000) >> 16, (rgb & 0x0000ff00) >> 8, rgb & 0x000000ff)); @@ -437,7 +463,7 @@ public class AWT extends JVM { } } - protected Picture _decodeJPEG(InputStream is, String name) { + protected void _decodeJPEG(InputStream is, Picture p) { try { Image i = Toolkit.getDefaultToolkit().createImage(InputStreamToByteArray.convert(is)); MediaTracker mediatracker = new MediaTracker(new Canvas()); @@ -449,15 +475,14 @@ public class AWT extends JVM { final int[] data = new int[width * height]; PixelGrabber pg = new PixelGrabber(i, 0, 0, width, height, data, 0, width); pg.grabPixels(); - if ((pg.getStatus() & ImageObserver.ABORT) != 0) { - Log.log(this, "PixelGrabber reported an error while decoding JPEG image " + name); - return null; - } - return Platform.createPicture(data, width, height); + if ((pg.getStatus() & ImageObserver.ABORT) != 0) + Log.log(this, "PixelGrabber reported an error while decoding JPEG image"); + p.width = width; + p.height = height; + p.data = data; } catch (Exception e) { - Log.log(this, "Exception caught while decoding JPEG image " + name); + Log.log(this, "Exception caught while decoding JPEG image"); Log.log(this, e); - return null; } } } diff --git a/src/org/xwt/plat/Darwin.java b/src/org/xwt/plat/Darwin.java index 07c2fe5..84bec1c 100644 --- a/src/org/xwt/plat/Darwin.java +++ b/src/org/xwt/plat/Darwin.java @@ -77,11 +77,7 @@ public class Darwin extends POSIX { private static native final boolean isJaguar(); - // Called by main thread after initialization, this is the event handler - protected native void runApplicationEventLoop(); - - public void init() { - super.init(); + public void postInit() { jaguar = isJaguar(); try { openGL = new CarbonOpenGL(); @@ -94,7 +90,13 @@ public class Darwin extends POSIX { natInit(); } - public void _running() { runApplicationEventLoop(); } + protected native void runApplicationEventLoop(); + private class DarwinScheduler extends org.xwt.Scheduler { + public void run() { + new Thread() { public void run() { defaultRun(); } }.start(); + runApplicationEventLoop(); + } + } private final class CarbonOpenGL extends OpenGL { public RawData rawPixelFormat; @@ -316,17 +318,17 @@ public class Darwin extends POSIX { else return /*new QZCarbonSufrace(b,framed)*/ null; } - protected Picture _createPicture(int[] data, int w, int h) { + protected Picture _createPicture() { if(openGL != null) - return openGL.createPicture(data,w,h); + return openGL._createPicture(true); else return /*new QZCarbonPicture(data,w,h);*/ null; } - protected Picture _createAlphaOnlyPicture(byte[] data, int w, int h) { + protected org.xwt.Font.Glyph _createGlyph(org.xwt.Font f, char c) { if(openGL != null) - return openGL.createAlphaOnlyPicture(data,w,h); + return openGL._createGlyph(f, c); else - return super.createAlphaOnlyPicture(data,w,h); + return super.createGlyph(f, c); } /* A message that is sent through the carbon event queue */ diff --git a/src/org/xwt/plat/GCJ.cc b/src/org/xwt/plat/GCJ.cc index 474e640..a70c952 100644 --- a/src/org/xwt/plat/GCJ.cc +++ b/src/org/xwt/plat/GCJ.cc @@ -98,13 +98,10 @@ void skip_input_data (j_decompress_ptr cinfo, long num_bytes) { src->pub.bytes_in_buffer -= num_bytes; } -org::xwt::Picture* org::xwt::plat::GCJ::_decodeJPEG(java::io::InputStream* is, jstring name) { +void org::xwt::plat::GCJ::_decodeJPEG(java::io::InputStream* is, org::xwt::Picture* p) { struct jpeg_decompress_struct cinfo; my_error_mgr_t jerr; my_source_mgr_t src; - jintArray data; - jint width; - jint height; src.is = is; src.buf = JvNewByteArray(16384); @@ -123,7 +120,7 @@ org::xwt::Picture* org::xwt::plat::GCJ::_decodeJPEG(java::io::InputStream* is, j (jerr.pub.format_message)((j_common_ptr)&cinfo, msgbuf); Log::log(&GCJ::class$,JvNewStringLatin1(msgbuf)); jpeg_destroy_decompress(&cinfo); - return 0; + return; } jpeg_create_decompress(&cinfo); @@ -135,9 +132,9 @@ org::xwt::Picture* org::xwt::plat::GCJ::_decodeJPEG(java::io::InputStream* is, j jpeg_read_header(&cinfo,TRUE); jpeg_start_decompress(&cinfo); - width = cinfo.output_width; - height = cinfo.output_height; - data = JvNewIntArray(width * height); + p->width = cinfo.output_width; + p->height = cinfo.output_height; + p->data = JvNewIntArray(width * height); while (cinfo.output_scanline < cinfo.output_height) { JSAMPLE *dest = (JSAMPLE*) (elements(data) + cinfo.output_scanline * width); @@ -148,8 +145,6 @@ org::xwt::Picture* org::xwt::plat::GCJ::_decodeJPEG(java::io::InputStream* is, j for(int i=0;ilength;i++) elements(data)[i] |= 0xff000000; // alpha channel - - return org::xwt::Platform::createPicture(data, width, height); } // C++ new/delete operators (JvMalloc never fails) diff --git a/src/org/xwt/plat/GCJ.java b/src/org/xwt/plat/GCJ.java index 028f0ba..cad7e61 100644 --- a/src/org/xwt/plat/GCJ.java +++ b/src/org/xwt/plat/GCJ.java @@ -21,7 +21,7 @@ public abstract class GCJ extends Platform { protected native InputStream _getBuiltinInputStream(); - protected native Picture _decodeJPEG(InputStream is, String name); + protected native void _decodeJPEG(InputStream is, Picture p); // FEATURE: This could be optimized (a lot) by using a custom hashtable public final static class Retainer { diff --git a/src/org/xwt/plat/Java2.java b/src/org/xwt/plat/Java2.java index 10b003f..8a6ed7c 100644 --- a/src/org/xwt/plat/Java2.java +++ b/src/org/xwt/plat/Java2.java @@ -17,17 +17,12 @@ import java.lang.reflect.*; public class Java2 extends AWT { private boolean isJava14 = false; - protected boolean _supressDirtyOnResize() { - return false; - //return (isJava14 && !System.getProperty("os.name", "").equals("Mac OS X"))? false : true; - } public Java2() { // disable the focus manager so we can intercept the tab key String versionString = System.getProperty("java.version", ""); int secondDecimal = versionString.substring(versionString.indexOf('.') + 1).indexOf('.'); if (secondDecimal != -1) versionString = versionString.substring(0, secondDecimal); - /* double version = Double.parseDouble(versionString); if (version >= 1.4) { isJava14 = true; @@ -40,7 +35,6 @@ public class Java2 extends AWT { Log.log(this, e); } } - */ javax.swing.FocusManager.setCurrentManager(new javax.swing.FocusManager() { public void processKeyEvent(Component focusedComponent, KeyEvent anEvent) { } public void focusPreviousComponent(Component aComponent) { } @@ -183,8 +177,9 @@ public class Java2 extends AWT { private SampleModel sm = null; private DataBuffer buf = null; - public void drawPictureAlphaOnly(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int rgb) { + public void drawGlyph(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int rgb) { AWTPicture src = (AWTPicture)source; + src.init(); Graphics2D g2 = (Graphics2D)i.getGraphics(); g2.setComposite(AlphaComposite.DstOut); g2.setClip(cx1, cy1, cx2 - cx1, cy2 - cy1); diff --git a/src/org/xwt/plat/OpenGL.java b/src/org/xwt/plat/OpenGL.java index 16f8d75..6268ad5 100644 --- a/src/org/xwt/plat/OpenGL.java +++ b/src/org/xwt/plat/OpenGL.java @@ -80,8 +80,8 @@ abstract class OpenGL { //System.out.println("drawString(): " + text); } - public void drawPictureAlphaOnly(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int rgb) { - drawPicture_(source, dx, dy, cx1, cy1, cx2, cy2, rgb); + public void drawGlyph(org.xwt.Font.Glyph source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int rgb) { + drawPicture_(((org.xwt.Platform.DefaultGlyph)source).getPicture(), dx, dy, cx1, cy1, cx2, cy2, rgb); } public void drawPicture(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2) { drawPicture_(source, dx, dy, cx1, cy1, cx2, cy2, 0xffffffff); @@ -90,32 +90,60 @@ abstract class OpenGL { private void drawPicture_(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int color) { activateInterpreter(); setColor(color); - GLPicture p = (GLPicture) source; + GLPicture p = getInnerPicture(source, gl); p.draw(dx,dy,cx1,cy1,cx2,cy2); } } + + // FIXME ugly + public static OpenGL gl = null; + public OpenGL() { gl = this; } public final static int roundToPowerOf2(int n) { if(((n-1)&n)==0) return n; for(int x=2;x!=0;x<<=1) if(n < x) return x; return 0; } - - private Picture _createPicture(Object data, int w, int h, boolean alphaOnly) { - if(rectangularTextures && w <= maxRectTexSize && h <= maxRectTexSize) new RectGLPicture(data,w,h,alphaOnly,this); - if(w <= maxTexSize && h <= maxTexSize) return new SquareGLPicture(data,w,h,alphaOnly,this); - return new MosaicGLPicture(data,w,h,alphaOnly,this); - } - public Picture createPicture(int[] data, int w, int h) { - if(w*h > data.length) throw new Error("should never happen"); - return _createPicture(data,w,h,false); + private static GLPicture getInnerPicture(Picture p, OpenGL gl) { + OpenGLPicture oglp = (OpenGLPicture)p; + if (!oglp.isLoaded || oglp.realPicture != null) return oglp.realPicture; + if (gl.rectangularTextures && p.width <= gl.maxRectTexSize && p.height <= gl.maxRectTexSize) + oglp.realPicture = new RectGLPicture(p.data,p.width,p.height,oglp.alphaOnly,gl); + else if (p.width <= gl.maxTexSize && p.height <= gl.maxTexSize) + oglp.realPicture = new SquareGLPicture(p.data,p.width,p.height,oglp.alphaOnly,gl); + else + oglp.realPicture = new MosaicGLPicture(p.data,p.width,p.height,oglp.alphaOnly,gl); + p.data = null; + return oglp.realPicture; } - public Picture createAlphaOnlyPicture(byte[] data, int w, int h) { - if(w*h > data.length) throw new Error("should never happen"); - return _createPicture(data,w,h,true); + + public Picture _createPicture(boolean alphaOnly) { return new OpenGLPicture(alphaOnly); } + + public static class OpenGLPicture extends Picture { + public OpenGLPicture(boolean a) { alphaOnly = a; } + boolean alphaOnly; + GLPicture realPicture = null; } + + public Font.Glyph _createGlyph(org.xwt.Font f, char c) { return new OpenGLGlyph(f, c); } + public static class OpenGLGlyph extends Font.Glyph { + private Picture p = null; + public OpenGLGlyph(org.xwt.Font f, char c) { super(f, c); } + Picture getPicture() { + if (p == null && isLoaded) { + p = new OpenGLPicture(true); + p.data = new int[data.length]; + for(int i=0; i= cx2 || cy1 >= cy2) return; - slowDrawPicture(source, dx, dy, cx1, cy1, cx2, cy2, rgb, true); + slowDrawPicture(((DefaultGlyph)source).getPicture(), dx, dy, cx1, cy1, cx2, cy2, rgb, true); } public void drawPicture(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2) { cx1 = Math.max(dx, cx1); cy1 = Math.max(dy, cy1); - cx2 = Math.min(dx + source.getWidth(), cx2); - cy2 = Math.min(dy + source.getHeight(), cy2); + cx2 = Math.min(dx + source.width, cx2); + cy2 = Math.min(dy + source.height, cy2); if (cx1 >= cx2 || cy1 >= cy2) return; + ((X11Picture)source).init(); if (((X11Picture)source).doublebuf != null) fastDrawPicture(source, dx, dy, cx1, cy1, cx2, cy2); else diff --git a/src/org/xwt/translators/Freetype.java b/src/org/xwt/translators/Freetype.java index f1e11fe..55dbf68 100644 --- a/src/org/xwt/translators/Freetype.java +++ b/src/org/xwt/translators/Freetype.java @@ -40,10 +40,6 @@ public class Freetype { } public synchronized void renderGlyph(Font.Glyph glyph) throws IOException { - int width = 0; - int height = 0; - byte[] data = null; - try { if (loadedStream != glyph.font.res) loadFontByteStream(glyph.font.res); vm.setUserInfo(2, (int)glyph.c); @@ -56,15 +52,13 @@ public class Freetype { glyph.baseline = vm.getUserInfo(10); glyph.advance = vm.getUserInfo(11); - width = vm.getUserInfo(6); - height = vm.getUserInfo(7); + glyph.width = vm.getUserInfo(6); + glyph.height = vm.getUserInfo(7); - data = new byte[width * height]; + glyph.data = new byte[glyph.width * glyph.height]; int addr = vm.getUserInfo(5); - vm.copyin(addr,data,width*height); + vm.copyin(addr, glyph.data, glyph.width * glyph.height); - if (width == 0 || height == 0) Log.log(Freetype.class, "warning glyph has zero width/height"); - glyph.p = Platform.createAlphaOnlyPicture(data, width, height); } catch (Exception e) { Log.log(this, e); } diff --git a/src/org/xwt/translators/GIF.java b/src/org/xwt/translators/GIF.java index 4ac420f..53dca2b 100644 --- a/src/org/xwt/translators/GIF.java +++ b/src/org/xwt/translators/GIF.java @@ -55,31 +55,33 @@ public class GIF { // Public Methods ///////////////////////////////////////////////////////// - public GIF() { } + private GIF() { } - public int[] getData() { return data; } - public int getWidth() { return width; } - public int getHeight() { return height; } + private static Queue instances = new Queue(10); - /** Processes an image from InputStream is; returns null if there is an error - @param name A string describing the image; used for error reporting. - */ - public Picture fromInputStream(InputStream is, String name) { + public static void load(InputStream is, Picture p) { + GIF g = (GIF)instances.remove(); + if (g == null) g = new GIF(); try { - if (is instanceof BufferedInputStream) _in = (BufferedInputStream)is; - else _in = new BufferedInputStream(is); - decodeAsBufferedImage(0); - return Platform.createPicture(data, width, height); + g._load(is, p); } catch (Exception e) { if (Log.on) Log.log(GIF.class, e); - return null; + return; } + // FIXME: must reset fields + // if (instances.size() < 10) instances.append(g); } + private void _load(InputStream is, Picture p) throws IOException { + this.p = p; + if (is instanceof BufferedInputStream) _in = (BufferedInputStream)is; + else _in = new BufferedInputStream(is); + decodeAsBufferedImage(0); + p.isLoaded = true; + p = null; + _in = null; + } - // Private Methods ///////////////////////////////////////////////////////// - - private int[] data = null; /** Decode a particular frame from the GIF file. Frames must be decoded in order, starting with 0. */ private void decodeAsBufferedImage(int page) throws IOException, IOException { @@ -110,7 +112,7 @@ public class GIF { if (block_identifier != ',') continue; if (!readLocalImageDescriptor()) throw new IOException("Unexpected EOF(3)"); - data = new int[width * height]; + p.data = new int[p.width * p.height]; readImage(); // If we did not decode the requested index, need to go on @@ -131,8 +133,8 @@ public class GIF { /** Actually read the image data */ private void readImage() throws IOException, IOException { - int len = width; - int rows = height; + int len = p.width; + int rows = p.height; int initialCodeSize; int v; int xpos = 0, ypos = 0, pass = 0, i; @@ -249,7 +251,7 @@ public class GIF { if (v < 0) return; // Finally, we can set a pixel! Joy! - data[xpos + ypos * width] = cmap[v]; + p.data[xpos + ypos * p.width] = cmap[v]; xpos++; } @@ -334,8 +336,8 @@ public class GIF { left = _buf[0] | (_buf[1] << 8); top = _buf[2] | (_buf[3] << 8); - width = _buf[4] | (_buf[5] << 8); - height = _buf[6] | (_buf[7] << 8); + p.width = _buf[4] | (_buf[5] << 8); + p.height = _buf[6] | (_buf[7] << 8); packed = _buf[8]; hascmap = (packed & LOCALCOLORMAP) == LOCALCOLORMAP; cmapsize = 2 << (packed & 0x07); @@ -396,6 +398,8 @@ public class GIF { // Private Data ////////////////////////////////////////////////////////// + private Picture p; + // State management stuff private int index = -1; private BufferedInputStream _in = null; @@ -415,8 +419,6 @@ public class GIF { // Local image descriptor contents private int left = 0; private int top = 0; - private int width = 0; - private int height = 0; private int cmapsize = 0; private boolean hascmap = false; private boolean interlaced = false; diff --git a/src/org/xwt/translators/PNG.java b/src/org/xwt/translators/PNG.java index 19e382f..a514ff4 100644 --- a/src/org/xwt/translators/PNG.java +++ b/src/org/xwt/translators/PNG.java @@ -26,23 +26,42 @@ public class PNG { public PNG() { } + private static Queue instances = new Queue(10); + + public static void load(InputStream is, Picture p) { + PNG g = (PNG)instances.remove(); + if (g == null) g = new PNG(); + try { + g._load(is, p); + } catch (Exception e) { + if (Log.on) Log.log(PNG.class, e); + return; + } + // FIXME: must reset fields + // if (instances.size() < 10) instances.append(g); + } + // Public Methods /////////////////////////////////////////////////////////////////////////////// + private Picture p; + /** process a PNG as an inputstream; returns null if there is an error @param name A string describing the image, to be used when logging errors */ - public Picture fromInputStream(InputStream is, String name) throws IOException { - underlyingStream = is; + private void _load(InputStream is, Picture p) throws IOException { + this.p = p; + if (is instanceof BufferedInputStream) underlyingStream = (BufferedInputStream)is; + else underlyingStream = new BufferedInputStream(is); target_offset = 0; inputStream = new DataInputStream(underlyingStream); // consume the header if ((inputStream.read() != 137) || (inputStream.read() != 80) || (inputStream.read() != 78) || (inputStream.read() != 71) || (inputStream.read() != 13) || (inputStream.read() != 10) || (inputStream.read() != 26) || (inputStream.read() != 10)) { - Log.log(this, "PNG: error: input file " + name + " is not a PNG file"); + Log.log(this, "PNG: error: input file is not a PNG file"); data = new int[] { }; - width = height = 0; - return null; + p.width = p.height = 0; + return; } DONE: while (!error) { @@ -79,15 +98,14 @@ public class PNG { int crc = inputStream.readInt(); needChunkInfo = true; } - - return Platform.createPicture(data, width, height); + p.isLoaded = true; } // Chunk Handlers /////////////////////////////////////////////////////////////////////// /** handle data chunk */ private void handleIDAT() throws IOException { - if (width == -1 || height == -1) throw new IOException("never got image width/height"); + if (p.width == -1 || p.height == -1) throw new IOException("never got image width/height"); switch (depth) { case 1: mask = 0x1; break; case 2: mask = 0x3; break; @@ -98,7 +116,7 @@ public class PNG { if (depth < 8) smask = mask << depth; else smask = mask << 8; - int count = width * height; + int count = p.width * p.height; switch (colorType) { case 0: @@ -123,8 +141,8 @@ public class PNG { private void handleIHDR() throws IOException { if (headerFound) throw new IOException("Extraneous IHDR chunk encountered."); if (chunkLength != 13) throw new IOException("IHDR chunk length wrong: " + chunkLength); - width = inputStream.readInt(); - height = inputStream.readInt(); + p.width = inputStream.readInt(); + p.height = inputStream.readInt(); depth = inputStream.read(); colorType = inputStream.read(); compressionMethod = inputStream.read(); @@ -196,21 +214,21 @@ public class PNG { int rInc = rowInc[pass]; int cInc = colInc[pass]; int sCol = startingCol[pass]; - int val = (width - sCol + cInc - 1) / cInc; + int val = (p.width - sCol + cInc - 1) / cInc; int samples = val * filterOffset; int rowSize = (val * bps)>>3; int sRow = startingRow[pass]; - if (height <= sRow || rowSize == 0) continue; - int sInc = rInc * width; + if (p.height <= sRow || rowSize == 0) continue; + int sInc = rInc * p.width; byte inbuf[] = new byte[rowSize]; int pix[] = new int[rowSize]; int upix[] = null; int temp[] = new int[rowSize]; int nextY = sRow; // next Y value and number of rows to report to sendPixels int rows = 0; - int rowStart = sRow * width; + int rowStart = sRow * p.width; - for (int y = sRow; y < height; y += rInc, rowStart += sInc) { + for (int y = sRow; y < p.height; y += rInc, rowStart += sInc) { rows += rInc; int rowFilter = dis.read(); dis.readFully(inbuf); @@ -406,7 +424,7 @@ public class PNG { private void blockFill(int rowStart) { int counter; - int dw = width; + int dw = p.width; int pass = this.pass; int w = blockWidth[pass]; int sCol = startingCol[pass]; @@ -532,8 +550,6 @@ public class PNG { // Private Data /////////////////////////////////////////////////////////////////////////////////////// private int target_offset = 0; - private int width = -1; - private int height = -1; private int sigmask = 0xffff; private Object pixels = null; private int ipixels[] = null; diff --git a/src/org/xwt/util/Cache.java b/src/org/xwt/util/Cache.java index 3099a5d..1822363 100644 --- a/src/org/xwt/util/Cache.java +++ b/src/org/xwt/util/Cache.java @@ -9,6 +9,8 @@ package org.xwt.util; import java.util.*; +// FIXME needs to be a weak hash + /** * A Hash table with a fixed size; drops extraneous elements. Uses * LRU strategy. diff --git a/src/org/xwt/util/SSL.java b/src/org/xwt/util/SSL.java index 08d6fef..c27bace 100644 --- a/src/org/xwt/util/SSL.java +++ b/src/org/xwt/util/SSL.java @@ -1,4 +1,4 @@ -// Copyright (C) 2002 Adam Megacz all rights reserved. +// Copyright (C) 2003 Adam Megacz all rights reserved. // // You may modify, copy, and redistribute this code under the terms of // the GNU Library Public License version 2.1, with the exception of diff --git a/src/org/xwt/util/XML.java b/src/org/xwt/util/XML.java index 18b86ca..ca1d713 100644 --- a/src/org/xwt/util/XML.java +++ b/src/org/xwt/util/XML.java @@ -762,13 +762,13 @@ public abstract class XML * beginning of this character segment, which can be processed in a * line-by-line fashion due to the above newline restriction.

*/ - public abstract void characters(char[] ch, int start, int length) throws SchemaException; + public abstract void characters(char[] ch, int start, int length) throws SchemaException, IOException; /** Represents a line of ignorable whitespace. */ - public abstract void whitespace(char[] ch, int start, int length) throws SchemaException; + public abstract void whitespace(char[] ch, int start, int length) throws SchemaException, IOException; /** Represents the end of an Element. */ - public abstract void endElement(Element e) throws SchemaException; + public abstract void endElement(Element e) throws SchemaException, IOException; /////////////////////////////////////////////////////////////////////////////////////////////