diff options
author | Sven Gothel <[email protected]> | 2014-05-23 00:00:48 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-05-23 00:00:48 +0200 |
commit | 98ed02cdb7b325d8afde596a5ef04f97be2018d4 (patch) | |
tree | 57969bdf241d493cc110b29422d3c488fcfacc65 /src/nativewindow | |
parent | fb57c652fee6be133990cd7afbbd2fdfc084afaa (diff) |
Bug 742 HiDPI: [Core API Change] Distinguish window-units and pixel-units: Refine commit fb57c652fee6be133990cd7afbbd2fdfc084afaa
- NEWT Screen, Monitor, MonitorMode, ..
- All Units are in pixel units, not window units!
- On OSX HiDPI, we report the current scaled monitor resolution,
instead of the native pixel sized.
Need to filter out those, i.e. report only native unscaled resolutions,
since out MonitorMode analogy is per MonitorDevice and not per window!
- Fix usage (one by one) of
- Screen and Monitor viewport usage
Diffstat (limited to 'src/nativewindow')
3 files changed, 44 insertions, 13 deletions
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java index d0d8bfb13..57535c26e 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java @@ -40,7 +40,7 @@ public class Rectangle implements Cloneable, RectangleImmutable { this(0, 0, 0, 0); } - public Rectangle(int x, int y, int width, int height) { + public Rectangle(final int x, final int y, final int width, final int height) { this.x=x; this.y=y; this.width=width; @@ -70,16 +70,16 @@ 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) { + public final void set(final int x, final int y, final int width, final 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; } - public final void setHeight(int height) { this.height = height; } + public final void setX(final int x) { this.x = x; } + public final void setY(final int y) { this.y = y; } + public final void setWidth(final int width) { this.width = width; } + public final void setHeight(final int height) { this.height = height; } @Override public final RectangleImmutable union(final RectangleImmutable r) { @@ -113,7 +113,7 @@ public class Rectangle implements Cloneable, RectangleImmutable { } @Override - public final RectangleImmutable intersection(RectangleImmutable r) { + public final RectangleImmutable intersection(final RectangleImmutable r) { return intersection(r.getX(), r.getY(), r.getX() + r.getWidth(), r.getY() + r.getHeight()); } @Override @@ -140,13 +140,43 @@ public class Rectangle implements Cloneable, RectangleImmutable { return new Rectangle (ix, iy, iwidth, iheight); } @Override - public final float coverage(RectangleImmutable r) { + public final float coverage(final RectangleImmutable r) { final RectangleImmutable isect = intersection(r); - final float sqI = (float) ( isect.getWidth()*isect.getHeight() ); - final float sqT = (float) ( width*height ); + final float sqI = isect.getWidth()*isect.getHeight(); + final float sqT = width*height; return sqI / sqT; } + /** + * Scale this instance's components, + * i.e. multiply them by the given scale factors. + * @param sx scale factor for x + * @param sy scale factor for y + * @return this instance for scaling + */ + public final Rectangle scale(int sx, int sy) { + x *= sx ; + y *= sy ; + width *= sx ; + height *= sy ; + return this; + } + + /** + * Inverse scale this instance's components, + * i.e. divide them by the given scale factors. + * @param sx inverse scale factor for x + * @param sy inverse scale factor for y + * @return this instance for scaling + */ + public final Rectangle scaleInv(int sx, int sy) { + x /= sx ; + y /= sy ; + width /= sx ; + height /= sy ; + return this; + } + @Override public int compareTo(final RectangleImmutable d) { { diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java index 77619731f..6b4d2f19c 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java @@ -32,7 +32,7 @@ package javax.media.nativewindow.util; /** * Immutable SurfaceSize Class, consisting of it's read only components:<br> * <ul> - * <li>{@link javax.media.nativewindow.util.DimensionImmutable} size in pixels</li> + * <li>{@link javax.media.nativewindow.util.DimensionImmutable size in pixels}</li> * <li><code>bits per pixel</code></li> * </ul> */ @@ -48,6 +48,7 @@ public class SurfaceSize implements Comparable<SurfaceSize> { this.bitsPerPixel=bitsPerPixel; } + /** Returns the resolution in pixel units */ public final DimensionImmutable getResolution() { return resolution; } @@ -58,7 +59,7 @@ public class SurfaceSize implements Comparable<SurfaceSize> { @Override public final String toString() { - return "[ "+resolution+" x "+bitsPerPixel+" bpp ]"; + return "[ "+resolution+" pixels x "+bitsPerPixel+" bpp ]"; } /** diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m index 15547ffee..0250bb7d1 100644 --- a/src/nativewindow/native/macosx/OSXmisc.m +++ b/src/nativewindow/native/macosx/OSXmisc.m @@ -41,7 +41,7 @@ #include <jawt_md.h> -#define VERBOSE 1 +// #define VERBOSE 1 // #ifdef VERBOSE // #define DBG_PRINT(...) NSLog(@ ## __VA_ARGS__) |