Revision: 4028 http://vexi.svn.sourceforge.net/vexi/?rev=4028&view=rev Author: clrg Date: 2011-02-09 13:56:55 +0000 (Wed, 09 Feb 2011)
Log Message: ----------- Some optimizations: - comment out screenDirtyRegions (no longer used) - avoid synchronized on Refresh in most cases Modified Paths: -------------- trunk/org.vexi-core.main/src/main/java/org/vexi/core/Surface.java Modified: trunk/org.vexi-core.main/src/main/java/org/vexi/core/Surface.java =================================================================== --- trunk/org.vexi-core.main/src/main/java/org/vexi/core/Surface.java 2011-02-09 13:53:44 UTC (rev 4027) +++ trunk/org.vexi-core.main/src/main/java/org/vexi/core/Surface.java 2011-02-09 13:56:55 UTC (rev 4028) @@ -125,7 +125,7 @@ int last_press_x = Integer.MAX_VALUE; ///< the x-position of the mouse the last time a Press message was enqueued int last_press_y = Integer.MAX_VALUE; ///< the y-position of the mouse the last time a Press message was enqueued - int lastClickButton = 0; ///< the last button to recieve a Click message; used for simulating DoubleClick's + int lastClickButton = 0; ///< the last button to receive a Click message; used for simulating DoubleClick's long lastClickTime = 0; ///< the last time a Click message was processed; used for simulating DoubleClick's @@ -352,7 +352,7 @@ private boolean forceOnRoot; public Object run(Object o) throws Exception { if (preevent==null) { - // no preevent JS means a single trigger on the root box + // no pre-event JS means a single trigger on the root box JS ret = surface.root.justTriggerTraps(event, value); if (Interpreter.CASCADE_PREVENTED != ret && (event==SC_Close)) { surface.dispose(true); @@ -534,14 +534,20 @@ // Core Surface Logic /////////////////////////////////////////////////////////////////////////////// - /** Refresh handles interacting with the scheduler - it needs - * to be synchronized to prevent scheduled + /** Refresh handles interacting with the scheduler - it needs to be + * synchronized to prevent scheduling the surface multiple times */ private boolean scheduled = false; - final public synchronized void Refresh() { + final public void Refresh() { if (!scheduled) { - Main.SCHEDULER.add(this); - scheduled = true; + synchronized (this) { + // scheduled check needs repeating as it is not guaranteed + // to be accurate outside of the synchronized clause + if (!scheduled) { + scheduled = true; + Main.SCHEDULER.add(this); + } + } } } @@ -722,7 +728,7 @@ final int[] dirt = dirtyRegions.flush(); if (dirt==null) return null; - final PixelBuffer buff = getPixelBuffer(); + final PixelBuffer buf = getPixelBuffer(); final int rwidth = root.width; final int rheight = root.height; final int scar_y = rheight-scarImage.height; @@ -745,10 +751,10 @@ continue; } - root.render(0, 0, x, y, w, h, buff); + root.render(0, 0, x, y, w, h, buf); if (scarImage != null) { if (scarImage.width > x && scar_y < h) { - buff.drawPicture(scarImage, 0, scar_y, x, y, w, h); + buf.drawPicture(scarImage, 0, scar_y, x, y, w, h); } } @@ -785,7 +791,7 @@ public DoubleBufferedSurface(Box root) { super(root); } public PixelBuffer getPixelBuffer() { return this; } protected PixelBuffer backbuffer = Platform.createPixelBuffer(Platform.getScreenBounds().width, Platform.getScreenBounds().height, this); - final private DirtyList screenDirtyRegions = new DirtyList(); +// final private DirtyList screenDirtyRegions = new DirtyList(); /** draw an unscaled image onto the backbuffer where: * (dx,dy) is the offset within the picture from where to start sampling @@ -803,6 +809,10 @@ backbuffer.drawPicture(source, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2); } + /** draw an unscaled glyph onto the backbuffer where: + * (dx1,dy1) is the top-left point of the glyph when placed on the backbuffer + * (cx1,cy1) to (cx2,cy2) describe the clipping area on the backbuffer + */ public void drawGlyph(Font.Glyph source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int argb) { backbuffer.drawGlyph(source, dx, dy, cx1, cy1, cx2, cy2, argb); } @@ -854,10 +864,10 @@ blit(backbuffer, x, y, x, y, x + w, y + h); } - public void dirty(int x, int y, int w, int h) { - screenDirtyRegions.dirty(x, y, w, h); - super.dirty(x, y, w, h); - } +// public void dirty(int x, int y, int w, int h) { +// screenDirtyRegions.dirty(x, y, w, h); +// super.dirty(x, y, w, h); +// } // copies a region from the doublebuffer to this surface public abstract void blit(PixelBuffer source, int sx, int sy, int dx, int dy, int dx2, int dy2); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: Pinpoint memory and threading errors before they happen. Find and fix more than 250 security defects in the development cycle. Locate bottlenecks in serial and parallel code that limit performance. http://p.sf.net/sfu/intel-dev2devfeb _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn