diff options
author | Sven Gothel <[email protected]> | 2013-10-16 14:28:27 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-10-16 14:28:27 +0200 |
commit | b831ebadcaea1eea7370f7ec0bffc59eaba7a5ba (patch) | |
tree | da1bbe7671b27db55859b5beb9dc0fe6fc750e3b | |
parent | 12d1142d197afb17828056252282fb5a6186b325 (diff) |
Add efficient set(..all..) to Dimension, Insets, Point and Rectangle of NativeWindow's util types.
19 files changed, 50 insertions, 79 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java index deab8bc3e..999db77a9 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java @@ -188,8 +188,7 @@ public class TileRenderer extends TileRendererBase { if( null == imageClippingDim ) { imageClippingDim = new Dimension(width, height); } else { - imageClippingDim.setWidth(width); - imageClippingDim.setHeight(height); + imageClippingDim.set(width, height); } reset(); } @@ -245,10 +244,8 @@ public class TileRenderer extends TileRendererBase { throw new IllegalArgumentException("Tile size must be > 0x0 minus 2*border"); } tileBorder = border; - tileSize.setWidth( width ); - tileSize.setHeight( height ); - tileSizeNB.setWidth( width - 2 * border ); - tileSizeNB.setHeight( height - 2 * border ); + tileSize.set( width, height ); + tileSizeNB.set( width - 2 * border, height - 2 * border ); reset(); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java index d6c36aa14..0553d5673 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java @@ -286,8 +286,7 @@ public abstract class TileRendererBase { * @param height The height of the final image */ public void setImageSize(int width, int height) { - imageSize.setWidth(width); - imageSize.setHeight(height); + imageSize.set(width, height); } /** @see #setImageSize(int, int) */ diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index 6e198d961..38a46f214 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -243,17 +243,11 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, System.err.println("JAWTWindow.updateBounds: "+bounds+" -> "+jb); // Thread.dumpStack(); } - bounds.setX(jawtBounds.getX()); - bounds.setY(jawtBounds.getY()); - bounds.setWidth(jawtBounds.getWidth()); - bounds.setHeight(jawtBounds.getHeight()); + bounds.set(jawtBounds.getX(), jawtBounds.getY(), jawtBounds.getWidth(), jawtBounds.getHeight()); if(component instanceof Container) { - java.awt.Insets contInsets = ((Container)component).getInsets(); - insets.setLeftWidth(contInsets.left); - insets.setRightWidth(contInsets.right); - insets.setTopHeight(contInsets.top); - insets.setBottomHeight(contInsets.bottom); + final java.awt.Insets contInsets = ((Container)component).getInsets(); + insets.set(contInsets.left, contInsets.right, contInsets.top, contInsets.bottom); } } return changed; diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java index b52414146..17b4930c5 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java @@ -58,22 +58,26 @@ public class Dimension implements Cloneable, DimensionImmutable { } @Override - public int getWidth() { return width; } + public final int getWidth() { return width; } @Override - public int getHeight() { return height; } + public final int getHeight() { return height; } - public void setWidth(int width) { + public final void set(int width, int height) { + this.width = width; + this.height = height; + } + public final void setWidth(int width) { this.width = width; } - public void setHeight(int height) { + public final void setHeight(int height) { this.height = height; } - public Dimension scale(int s) { + public final Dimension scale(int s) { width *= s; height *= s; return this; } - public Dimension add(Dimension pd) { + public final Dimension add(Dimension pd) { width += pd.width ; height += pd.height ; return this; diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java b/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java index f22668f55..942c12c2b 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java @@ -70,10 +70,13 @@ public class Insets implements Cloneable, InsetsImmutable { @Override public final int getTotalHeight() { return t + b; } - public void setLeftWidth(int left) { l = left; } - public void setRightWidth(int right) { r = right; } - public void setTopHeight(int top) { t = top; } - public void setBottomHeight(int bottom) { b = bottom; } + public final void set(int left, int right, int top, int bottom) { + l = left; r = right; t = top; b = bottom; + } + public final void setLeftWidth(int left) { l = left; } + public final void setRightWidth(int right) { r = right; } + public final void setTopHeight(int top) { t = top; } + public final void setBottomHeight(int bottom) { b = bottom; } @Override public boolean equals(Object obj) { diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java index a30d3030e..4c233bb16 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java @@ -99,22 +99,23 @@ public class Point implements Cloneable, PointImmutable { return new String( x + " / " + y ); } - public void setX(int x) { this.x = x; } - public void setY(int y) { this.y = y; } + public final void set(int x, int y) { this.x = x; this.y = y; } + public final void setX(int x) { this.x = x; } + public final void setY(int y) { this.y = y; } - public Point translate(Point pd) { + public final Point translate(Point pd) { x += pd.x ; y += pd.y ; return this; } - public Point translate(int dx, int dy) { + public final Point translate(int dx, int dy) { x += dx ; y += dy ; return this; } - public Point scale(int sx, int sy) { + public final Point scale(int sx, int sy) { x *= sx ; y *= sy ; return this; diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java index 7576f4ec7..bbbfa2932 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java @@ -68,6 +68,12 @@ public class Rectangle implements Cloneable, RectangleImmutable { @Override public final int getHeight() { return height; } + public final void set(int x, int y, int width, int height) { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + } public final void setX(int x) { this.x = x; } public final void setY(int y) { this.y = y; } public final void setWidth(int width) { this.width = width; } @@ -100,10 +106,7 @@ public class Rectangle implements Cloneable, RectangleImmutable { y1 = Math.min(y1, vp.getY()); y2 = Math.max(y2, vp.getY() + vp.getHeight()); } - setX(x1); - setY(y1); - setWidth(x2 - x1); - setHeight(y2 - y1); + set(x1, y1, x2 - x1, y2 - y1); return this; } diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index dc32bd58c..0d498fa54 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -113,8 +113,7 @@ public class OSXUtil implements ToolkitProperties { if(topLevel) { // top-level position -> client window position final Insets insets = GetInsets(windowOrView); - los.setX(los.getX() + insets.getLeftWidth()); - los.setY(los.getY() + insets.getTopHeight()); + los.set(los.getX() + insets.getLeftWidth(), los.getY() + insets.getTopHeight()); } return los; } diff --git a/src/newt/classes/com/jogamp/newt/MonitorDevice.java b/src/newt/classes/com/jogamp/newt/MonitorDevice.java index 8bc7f40e3..42ac34240 100644 --- a/src/newt/classes/com/jogamp/newt/MonitorDevice.java +++ b/src/newt/classes/com/jogamp/newt/MonitorDevice.java @@ -183,10 +183,7 @@ public abstract class MonitorDevice { y1 = Math.min(y1, vp.getY()); y2 = Math.max(y2, vp.getY() + vp.getHeight()); } - result.setX(x1); - result.setY(y1); - result.setWidth(x2 - x1); - result.setHeight(y2 - y1); + result.set(x1, y1, x2 - x1, y2 - y1); return result; } diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index 2fa83e0e2..a2135273b 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -497,8 +497,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { if( isOSX ) { final Point los = OSXUtil.GetLocationOnScreen(nativeWindowHandle, false, 0, 0); // top-level position -> client window position - los.setX(los.getX() + insets.getLeftWidth()); - los.setY(los.getY() + insets.getTopHeight()); + los.set(los.getX() + insets.getLeftWidth(), los.getY() + insets.getTopHeight()); if(null!=point) { return point.translate(los); } else { diff --git a/src/newt/classes/jogamp/newt/OffscreenWindow.java b/src/newt/classes/jogamp/newt/OffscreenWindow.java index 911d371d5..0a302d76b 100644 --- a/src/newt/classes/jogamp/newt/OffscreenWindow.java +++ b/src/newt/classes/jogamp/newt/OffscreenWindow.java @@ -132,8 +132,7 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { @Override public Point getLocationOnScreen(Point storage) { if(null!=storage) { - storage.setX(0); - storage.setY(0); + storage.set(0, 0); return storage; } return new Point(0,0); diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index 5ffa2ebbf..7068d7464 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -285,10 +285,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { */ protected void updateVirtualScreenOriginAndSize() { if(null != usrSize ) { - vOriginSize.setX(0); - vOriginSize.setY(0); - vOriginSize.setWidth(usrSize.getWidth()); - vOriginSize.setHeight(usrSize.getHeight()); + vOriginSize.set(0, 0, usrSize.getWidth(), usrSize.getHeight()); if(DEBUG) { System.err.println("Update user virtual screen viewport @ "+Thread.currentThread().getName()+": "+vOriginSize); } diff --git a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java index c45a5ae3b..77daa556f 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java @@ -177,11 +177,8 @@ public class WindowDriver extends WindowImpl { } protected void updateInsetsImpl(javax.media.nativewindow.util.Insets insets) { - Insets contInsets = awtContainer.getInsets(); - insets.setLeftWidth(contInsets.left); - insets.setRightWidth(contInsets.right); - insets.setTopHeight(contInsets.top); - insets.setBottomHeight(contInsets.bottom); + final Insets contInsets = awtContainer.getInsets(); + insets.set(contInsets.left, contInsets.right, contInsets.top, contInsets.bottom); } private void setCanvasSizeImpl(int width, int height) { diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java index afaedffe3..abe2908b0 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java @@ -101,10 +101,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { } protected void calcVirtualScreenOriginAndSize(Rectangle vOriginSize) { - vOriginSize.setX(0); - vOriginSize.setY(0); - vOriginSize.setWidth(fixedWidth); // FIXME - vOriginSize.setHeight(fixedHeight); // FIXME + vOriginSize.set(0, 0, fixedWidth, fixedHeight); // FIXME } //---------------------------------------------------------------------- diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java index f7973def8..be99052d7 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java @@ -95,10 +95,7 @@ public class ScreenDriver extends ScreenImpl { @Override protected void calcVirtualScreenOriginAndSize(Rectangle vOriginSize) { - vOriginSize.setX(0); - vOriginSize.setY(0); - vOriginSize.setWidth(cachedWidth); - vOriginSize.setHeight(cachedHeight); + vOriginSize.set(0, 0, cachedWidth, cachedHeight); } /** Called from {@link #initNative()}. */ diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java index 4c47eb0d8..27b776562 100644 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java @@ -103,10 +103,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { } protected void calcVirtualScreenOriginAndSize(Rectangle vOriginSize) { - vOriginSize.setX(0); - vOriginSize.setY(0); - vOriginSize.setWidth(cachedWidth); - vOriginSize.setHeight(cachedHeight); + vOriginSize.set(0, 0, cachedWidth, cachedHeight); } //---------------------------------------------------------------------- diff --git a/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java index dc87c3c08..f893275ca 100644 --- a/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java @@ -99,10 +99,7 @@ public class ScreenDriver extends ScreenImpl { } protected void calcVirtualScreenOriginAndSize(Rectangle vOriginSize) { - vOriginSize.setX(0); - vOriginSize.setY(0); - vOriginSize.setWidth(cachedWidth); - vOriginSize.setHeight(cachedHeight); + vOriginSize.set(0, 0, cachedWidth, cachedHeight); } protected void sizeChanged(int w, int h) { diff --git a/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java index 342829691..621091320 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java @@ -155,10 +155,7 @@ public class ScreenDriver extends ScreenImpl { @Override protected void calcVirtualScreenOriginAndSize(Rectangle vOriginSize) { - vOriginSize.setX(getVirtualOriginX0()); - vOriginSize.setY(getVirtualOriginY0()); - vOriginSize.setWidth(getVirtualWidthImpl0()); - vOriginSize.setHeight(getVirtualHeightImpl0()); + vOriginSize.set(getVirtualOriginX0(), getVirtualOriginY0(), getVirtualWidthImpl0(), getVirtualHeightImpl0()); } // Native calls diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java index f37556dd7..c01d899f8 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -237,10 +237,7 @@ public class ScreenDriver extends ScreenImpl { } else */ { runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable<Object>() { public Object run(long dpy) { - vOriginSize.setX(0); - vOriginSize.setY(0); - vOriginSize.setWidth(getWidth0(dpy, screen_idx)); - vOriginSize.setHeight(getHeight0(dpy, screen_idx)); + vOriginSize.set(0, 0, getWidth0(dpy, screen_idx), getHeight0(dpy, screen_idx)); return null; } } ); if( DEBUG ) { |