[cp-patches] FYI: Rasterizer stuff
This adds some infrastructure to the rasterizer, this is needed for the upcoming quality improvements, but does not improve the rendering for itself. 2007-05-24 Roman Kennke [EMAIL PROTECTED] * gnu/java/awt/java2d/ScanlineCoverage.java (Iterator): New class. (Range): New class. (Coverage.covDelta): Made field package private. (Coverage.xPos): Made field package private. (iterator): New field. Stores the iterator that is reused. (ScanlineCoverage): Initialize iterator. (assertion): Removed. (isEmpty): Refined conditions. (iterate): Return Iterator instance. (next): Removed. This is done by the Iterator class now. (test): Removed. * gnu/java/awt/java2d/ScanlineConverter.java (main): Removed. * gnu/java/awt/peer/x/XGraphics2D.java (renderScanline): Adjust to new coverage iterator stuff. * gnu/java/awt/java2d/AbstractGraphics2D.java (renderScanline): Adjust to new coverage iterator stuff. /Roman -- Dipl.-Inf. Roman Kennke, Software Engineer, http://kennke.org aicas Allerton Interworks Computer Automated Systems GmbH Haid-und-Neu-Straße 18 * D-76131 Karlsruhe * Germany http://www.aicas.com * Tel: +49-721-663 968-0 USt-Id: DE216375633, Handelsregister HRB 109481, AG Karlsruhe Geschäftsführer: Dr. James J. Hunt Index: gnu/java/awt/peer/x/XGraphics2D.java === RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/x/XGraphics2D.java,v retrieving revision 1.3 diff -u -1 -5 -r1.3 XGraphics2D.java --- gnu/java/awt/peer/x/XGraphics2D.java 22 May 2007 13:12:56 - 1.3 +++ gnu/java/awt/peer/x/XGraphics2D.java 24 May 2007 16:26:25 - @@ -207,64 +207,60 @@ //System.err.println(tx: + tx + , ty: + ty + , pixel: + pixel[0] + , + pixel[1] + , + pixel[2]); // 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]); } } xdrawable.put_image(xgc, zPixmap, x, y); } } public void renderScanline(int y, ScanlineCoverage c) { -ScanlineCoverage.Coverage start = c.iterate(); -ScanlineCoverage.Coverage end = c.next(); -assert (start != null); -assert (end != null); -int coverageAlpha = 0; +ScanlineCoverage.Iterator iter = c.iterate(); +float coverageAlpha = 0; int maxCoverage = c.getMaxCoverage(); Color old = getColor(); Color col = getColor(); if (col == null) col = Color.BLACK; -do +while (iter.hasNext()) { +ScanlineCoverage.Range range = iter.next(); // TODO: Dumb implementation for testing. -coverageAlpha = coverageAlpha + start.getCoverageDelta(); +coverageAlpha = range.getCoverage(); if (coverageAlpha 0) { int red = col.getRed(); int green = col.getGreen(); int blue = col.getBlue(); if (coverageAlpha c.getMaxCoverage()) { float alpha = coverageAlpha / maxCoverage; red = 255 - (int) ((255 - red) * alpha); green = 255 - (int) ((255 - green) * alpha); blue = 255 - (int) ((255 - blue) * alpha); } xgc.set_foreground(red 16 | green 8 | blue); -int x0 = start.getXPos(); -int x1 = end.getXPos(); -xdrawable.fill_rectangle(xgc, x0, y, x1 - x0, 1); +int x0 = range.getXPos(); +int l = range.getLength(); +xdrawable.fill_rectangle(xgc, x0, y, l, 1); } -start = end; -end = c.next(); - } while (end != null); + } xgc.set_foreground(old.getRGB()); } protected void fillScanline(int x0, int x1, int y) { xdrawable.segment(xgc, x0, y, x1, y); } protected void fillScanlineAA(int x0, int x1, int y, int alpha) { //System.err.println(fillScanlineAA: + x0 + , + x1 + , + y + , + alpha); // FIXME: This is for testing only. Color c = getColor(); setColor(new Color(255-alpha, 255-alpha, 255-alpha)); xdrawable.segment(xgc, x0, y, x1, y); Index: gnu/java/awt/java2d/AbstractGraphics2D.java === RCS file: /cvsroot/classpath/classpath/gnu/java/awt/java2d/AbstractGraphics2D.java,v retrieving revision 1.16 diff -u -1 -5 -r1.16 AbstractGraphics2D.java --- gnu/java/awt/java2d/AbstractGraphics2D.java 18 May 2007 16:22:40 - 1.16 +++ gnu/java/awt/java2d/AbstractGraphics2D.java 24 May 2007 16:26:26 - @@ -1549,31 +1549,30 @@ { // Determine if we need to antialias stuff.
Re: [cp-patches] Gnu classpath permission patch ?
Hello, in a different test context, it works. But I do not manage to get the java.policy file read, so my code aborts very soon. Does someone knows whether the supported syntax of this file is identical as in the sun jvm ? It seems that jamvm+Gnu Classpath has some difficulties in reading the properties that are defined (such a -Djava.security.policy). Any idea ? Pierre Quoting David Daney [EMAIL PROTECTED]: Pierre Parrend wrote: Hello, I am looking for a small and efficient java class project to program secure java application. The Gnu Classpath seems to be very efficient, but there seem to be no java permission support. Is there some specific patch that would already be available ? Are you sure? The last time I checked (about 30 seconds ago), there were quite a few Permission checks. You can grep the source code for the strings checkPermission checkRead, etc. to see that there are several places were we do the checks. Is there a particular place that you believe a check is missing? David Daney -- Pierre Parrend doctorant, moniteur laboratoire CITI, 21, Av. Jean Capelle 69621 Villeurbanne Cedex [EMAIL PROTECTED] www.rzo.free.fr
Re: [cp-patches] Gnu classpath permission patch ?
On May 24, 2007, at 11:03 AM, Pierre Parrend wrote: Hello, in a different test context, it works. But I do not manage to get the java.policy file read, so my code aborts very soon. Does someone knows whether the supported syntax of this file is identical as in the sun jvm ? It seems that jamvm+Gnu Classpath has some difficulties in reading the properties that are defined (such a - Djava.security.policy). Any idea ? We do have a Policy implementation that reads Sun-style policy files, but we don't know if it is 100% compatible. If there is something we don't correctly support, I'd encourage you to file a bug report. We can't offer any more help unless you can be more specific about what error you are running into.
[cp-patches] FYI: More rasterizer goodness
This improves the rasterizer alot. It increases the accuracy of the calculation of the pixel coverage by a factor of 16, without any performance impact (because we already know the intersection points, but haven't used this knowledge before). 2007-05-24 Roman Kennke [EMAIL PROTECTED] * gnu/java/awt/java2d/AbstractGraphics2D.java (fillShape): Pass rendering hints to scanline converter. * gnu/java/awt/java2d/ScanlineConverter.java (ONE): New constant for the number 1 as fixed point number. (Y_RESOLUTION): New constant for the Y resolution. (doScanline): Handle the Y resolution. (renderShape): Accept rendering hints. (setResolution): Adjust maximum resolution with Y resolution. * gnu/java/awt/java2d/ScanlineCoverage.java (Iterator.handledPixelCoverage): New field. (Iterator.next): Handle single pixel coverage. (Iterator.hasNext): Handle single pixel coverage. (Iterator.reset): Reset single pixel coverage. (Range.toString): New method. (Coverage.pixelCoverage): New field. (add): Include Y (pixel) coverage. (findOrInsert): Reset Y coverage in reused entries. /Roman -- Dipl.-Inf. Roman Kennke, Software Engineer, http://kennke.org aicas Allerton Interworks Computer Automated Systems GmbH Haid-und-Neu-Straße 18 * D-76131 Karlsruhe * Germany http://www.aicas.com * Tel: +49-721-663 968-0 USt-Id: DE216375633, Handelsregister HRB 109481, AG Karlsruhe Geschäftsführer: Dr. James J. Hunt Index: gnu/java/awt/java2d/AbstractGraphics2D.java === RCS file: /cvsroot/classpath/classpath/gnu/java/awt/java2d/AbstractGraphics2D.java,v retrieving revision 1.17 diff -u -1 -5 -r1.17 AbstractGraphics2D.java --- gnu/java/awt/java2d/AbstractGraphics2D.java 24 May 2007 16:26:57 - 1.17 +++ gnu/java/awt/java2d/AbstractGraphics2D.java 24 May 2007 20:27:48 - @@ -1556,31 +1556,31 @@ antialias = (v == RenderingHints.VALUE_TEXT_ANTIALIAS_ON || v == RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT); } else { Object v = renderingHints.get(RenderingHints.KEY_ANTIALIASING); antialias = (v == RenderingHints.VALUE_ANTIALIAS_ON); } ScanlineConverter sc = getScanlineConverter(); int resolution = 0; if (antialias) { // Adjust resolution according to rendering hints. resolution = 2; } -sc.renderShape(this, s, clip, transform, resolution); +sc.renderShape(this, s, clip, transform, resolution, renderingHints); } /** * Returns the color model of this Graphics object. * * @return the color model of this Graphics object */ protected abstract ColorModel getColorModel(); /** * Returns the bounds of the target. * * @return the bounds of the target */ protected Rectangle getDeviceBounds() Index: gnu/java/awt/java2d/ScanlineConverter.java === RCS file: /cvsroot/classpath/classpath/gnu/java/awt/java2d/ScanlineConverter.java,v retrieving revision 1.4 diff -u -1 -5 -r1.4 ScanlineConverter.java --- gnu/java/awt/java2d/ScanlineConverter.java 24 May 2007 16:26:57 - 1.4 +++ gnu/java/awt/java2d/ScanlineConverter.java 24 May 2007 20:27:48 - @@ -28,46 +28,57 @@ 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.java2d; import gnu.java.math.Fixed; +import java.awt.RenderingHints; import java.awt.Shape; import java.awt.geom.AffineTransform; import java.awt.geom.PathIterator; /** * Rasterizes [EMAIL PROTECTED] Shape} objects on an AbstractGraphics2D. */ public final class ScanlineConverter { /** * The number of digits to use for fixed point arithmetics. */ private static int FIXED_DIGITS = 6; /** + * The fixed point constant for the number one. + */ + private static int ONE = Fixed.fixedValue(FIXED_DIGITS, 1); + + /** + * The number of significant bits for the Y resolution. + */ + private static int Y_RESOLUTION = 4; + + /** * The actual number of scanlines. */ private int numScanlines; /** * The number of scanlines. This can contain more elements than we have * scanlines. The real number of scanlines is stored in * [EMAIL PROTECTED] #numScanlines}. This can also contain null values for empty
[cp-patches] FYI: New fixed point math method
This new method in the Fixed class is needed by the new rasterizer code. It truncates a fixed point number so that only the digits after the point are left. 2007-05-24 Roman Kennke [EMAIL PROTECTED] * gnu/java/math/Fixed.java (trunc): New method. /Roman -- Dipl.-Inf. Roman Kennke, Software Engineer, http://kennke.org aicas Allerton Interworks Computer Automated Systems GmbH Haid-und-Neu-Straße 18 * D-76131 Karlsruhe * Germany http://www.aicas.com * Tel: +49-721-663 968-0 USt-Id: DE216375633, Handelsregister HRB 109481, AG Karlsruhe Geschäftsführer: Dr. James J. Hunt Index: gnu/java/math/Fixed.java === RCS file: /cvsroot/classpath/classpath/gnu/java/math/Fixed.java,v retrieving revision 1.1 diff -u -1 -5 -r1.1 Fixed.java --- gnu/java/math/Fixed.java 1 Jan 2007 23:12:09 - 1.1 +++ gnu/java/math/Fixed.java 24 May 2007 20:56:03 - @@ -97,30 +97,43 @@ /** * Returns the floor value of a fixed point value codea/code with * coden/code digits. * * @param n the number of digits * @param a the fixed point value * * @return codefloor(a)/code as fixed point value */ public static int floor(int n, int a) { return a -(1 n); } /** + * Truncates the number so that only the digits after the point are left. + * + * @param n the number of digits + * @param a the fixed point value + * + * @return the truncated value + */ + public static int trunc(int n, int a) + { +return a (0x 32 - n); + } + + /** * Returns the round value of a fixed point value codea/code with * the coden/code digits. * * @param n the number of digits * @param a the fixed point value * * @return coderound(a)/code as fixed point value */ public static int round(int n, int a) { return (a + (1 (n - 1))) -(1 n); } /** * Returns the fixed point value codea/code with coden/code digits
Re: [cp-patches] Gnu classpath permission patch ?
On May 24, 2007, at 1:58 PM, Pierre Parrend wrote: Hello, for instance, I have the following command: jamvm -Djava.security.manager -Djava.security.policy=conf/ java.policy -cp bin/felix.jar: org.apache.felix.main.Main (jamvm uses the Gnu classpath, with default configuration) with following conf/java.policy file: grant codeBase /code/osgi-projects/sfelix/sfelix0.2.2/main/- { permission java.io.FilePermission /home/pierre/.felix/ testSF, read; permission java.lang.RuntimePermission exitVM; }; which gives me following error: Error creating bundle cache: permission (java.io.FilePermission /home/pierre/.felix/testSF read) not granted: no protection domains Could not create framework: java.security.AccessControlException: permission (java.lang.RuntimePermission exitVM ) not granted: no protection domains java.security.AccessControlException: permission (java.lang.RuntimePermission exitVM ) not granted: no protection domains at java.security.AccessControlContext.checkPermission (AccessControlContext.java:149) at java.security.AccessController.checkPermission (AccessController.java:76) at java.lang.SecurityManager.checkPermission (SecurityManager.java:356) at java.lang.SecurityManager.checkExit(SecurityManager.java:475) at java.lang.Runtime.exit(Runtime.java:171) at java.lang.System.exit(System.java:506) at org.apache.felix.framework.util.SecureAction$Actions.run (SecureAction.java:843) at java.security.AccessController.doPrivileged (AccessController.java:195) at org.apache.felix.framework.util.SecureAction.exit (SecureAction.java:624) at org.apache.felix.framework.Felix.start(Felix.java:276) at org.apache.felix.main.Main.main(Main.java:208) (executed platform is the Felix OSGi implementation, which work well without the security set) One problem here is that Classpath still unfortunately uses a bogus DefaultPolicy class for its policy, not the one that reads policy files. You can force using the policy file reader by adding the option: -Dpolicy.provider=gnu.java.security.PolicyFile ...I don't know why the default policy would reject the permission checks, though, since (AFAIK) the default policy grants AllPermission.