summaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-01-31 04:49:43 +0100
committerSven Gothel <[email protected]>2023-01-31 04:49:43 +0100
commitcfc35549810d3a0fb5eeb866c9450417e48cd8a1 (patch)
treea6a513d134c9a4157d7fc3f47f1ecfda45d27f1c /src/nativewindow/classes/jogamp
parentef206c881a9fd462e52241fac506bee5441902ad (diff)
NEWT Soft-PixelScale (p1): WindowImpl: Separate window and pixel units for size and position via atomic-replacable int arrays
NEWT's Soft-PixelScale supports software pixel-scale by multiplying the underlying surface pixel-size with the scale-factor and dividing the window position and size by same scale-factor. Hence the window position and size space is kept virtually steady at virtually assumed DPI 96 at higher actual screen DPI and the surface size is adjusted. +++ This window- and pixel-unit separation also includes all callbacks for the native driver implementations, hence the changes native code - allowing to determine whether window- or pixel-units were given.
Diffstat (limited to 'src/nativewindow/classes/jogamp')
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/SurfaceScaleUtils.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/SurfaceScaleUtils.java b/src/nativewindow/classes/jogamp/nativewindow/SurfaceScaleUtils.java
index c42dc613d..f5804cd12 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/SurfaceScaleUtils.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/SurfaceScaleUtils.java
@@ -1,4 +1,5 @@
/**
+ * Copyright 2014-2023 Gothel Software e.K. All rights reserved.
* Copyright 2014 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
@@ -70,11 +71,40 @@ public class SurfaceScaleUtils {
* @param pixelScale the float[2] scale factors
* @return the result for chaining
*/
+ public static int[] scale(final int[] result, final int x, final int y, final float[] pixelScale) {
+ result[0] = (int) ( x * pixelScale[0] + 0.5f );
+ result[1] = (int) ( y * pixelScale[1] + 0.5f );
+ return result;
+ }
+
+ /**
+ * Returns integer rounded product, i.e. {@code (int) ( a / pixelScale + 0.5f )}
+ *
+ * @param result the int[2] result, may be {@code a} for in-place operation
+ * @param a the int[2] values
+ * @param pixelScale the float[2] scale factors
+ * @return the result for chaining
+ */
+ public static int[] scaleInv(final int[] result, final int x, final int y, final float[] pixelScale) {
+ result[0] = (int) ( x / pixelScale[0] + 0.5f );
+ result[1] = (int) ( y / pixelScale[1] + 0.5f );
+ return result;
+ }
+
+ /**
+ * Returns integer rounded product, i.e. {@code (int) ( a * pixelScale + 0.5f )}
+ *
+ * @param result the int[2] result, may be {@code a} for in-place operation
+ * @param a the int[2] values
+ * @param pixelScale the float[2] scale factors
+ * @return the result for chaining
+ */
public static int[] scale(final int[] result, final int[] a, final float[] pixelScale) {
result[0] = (int) ( a[0] * pixelScale[0] + 0.5f );
result[1] = (int) ( a[1] * pixelScale[1] + 0.5f );
return result;
}
+
/**
* Returns integer rounded product, i.e. {@code (int) ( a / pixelScale + 0.5f )}
*