Jogamp
Bug 741 HiDPI: Simplify ScalableSurface (2): Add request pixelScale API entry, fixed...
authorSven Gothel <sgothel@jausoft.com>
Sun, 8 Jun 2014 16:04:51 +0000 (18:04 +0200)
committerSven Gothel <sgothel@jausoft.com>
Sun, 8 Jun 2014 16:04:51 +0000 (18:04 +0200)
We require the requested pixelScale in NewtCanvasAWT if the NEWT window (child)
is not yet realized, so the JAWTWindow can receive the request,
since realized/current pixelScale is still 1.

Remove return value (requested pixel scale):
  -  public int[] setSurfaceScale(final int[] result, final int[] pixelScale);
  +  public void setSurfaceScale(final int[] pixelScale);

Add API hook to query requested pixel scale:
  +  int[] getRequestedSurfaceScale(final int[] result);

Unique name for get[Current]*:
  -  public int[] getSurfaceScale(final int[] result);
  +  public int[] getCurrentSurfaceScale(final int[] result);

17 files changed:
make/scripts/tests.sh
src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
src/nativewindow/classes/javax/media/nativewindow/ScalableSurface.java
src/nativewindow/classes/jogamp/nativewindow/SurfaceScaleUtils.java
src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java
src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
src/newt/classes/jogamp/newt/WindowImpl.java
src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java
src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java
src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java
src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java

index 08a4603..3c79ebb 100644 (file)
@@ -361,9 +361,9 @@ function testawtswt() {
 # HiDPI
 #
 #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
-testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $*
+#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $*
 #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $*
-#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $*
+testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $*
 #testawt com.jogamp.opengl.test.junit.jogl.awt.ManualHiDPIBufferedImage01AWT $*
 
 #
index e95491f..12db864 100644 (file)
@@ -663,29 +663,31 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
   }
 
   @Override
-  public final int[] setSurfaceScale(final int[] result, final int[] pixelScale) {
+  public final void setSurfaceScale(final int[] pixelScale) {
       SurfaceScaleUtils.validateReqPixelScale(reqPixelScale, pixelScale, DEBUG ? getClass().getSimpleName() : null);
-      if( null != result ) {
-          System.arraycopy(reqPixelScale, 0, result, 0, 2);
-      }
       if( isRealized() ) {
           final ScalableSurface ns = jawtWindow;
           if( null != ns ) {
-              ns.setSurfaceScale(result, reqPixelScale);
+              ns.setSurfaceScale(reqPixelScale);
               final int hadPixelScaleX = hasPixelScale[0];
               final int hadPixelScaleY = hasPixelScale[1];
-              ns.getSurfaceScale(hasPixelScale);
+              ns.getCurrentSurfaceScale(hasPixelScale);
               if( hadPixelScaleX != hasPixelScale[0] || hadPixelScaleY != hasPixelScale[1] ) {
                   reshapeImpl(getWidth(), getHeight());
                   display();
               }
           }
       }
+  }
+
+  @Override
+  public final int[] getRequestedSurfaceScale(final int[] result) {
+      System.arraycopy(reqPixelScale, 0, result, 0, 2);
       return result;
   }
 
   @Override
-  public final int[] getSurfaceScale(final int[] result) {
+  public final int[] getCurrentSurfaceScale(final int[] result) {
       System.arraycopy(hasPixelScale, 0, result, 0, 2);
       return result;
   }
@@ -694,12 +696,12 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
     if ( !Beans.isDesignTime() ) {
         jawtWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(this, awtConfig);
         jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer);
-        jawtWindow.setSurfaceScale(null, reqPixelScale);
+        jawtWindow.setSurfaceScale(reqPixelScale);
         jawtWindow.lockSurface();
         try {
             drawable = (GLDrawableImpl) GLDrawableFactory.getFactory(capsReqUser.getGLProfile()).createGLDrawable(jawtWindow);
             createContextImpl(drawable);
-            jawtWindow.getSurfaceScale(hasPixelScale);
+            jawtWindow.getCurrentSurfaceScale(hasPixelScale);
         } finally {
             jawtWindow.unlockSurface();
         }
index 2f3cead..223badf 100644 (file)
@@ -559,16 +559,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
   private final void updateWrappedSurfaceScale(final GLDrawable d) {
       final NativeSurface s = d.getNativeSurface();
       if( s instanceof WrappedSurface ) {
-          ((WrappedSurface)s).setSurfaceScale(null, hasPixelScale);
+          ((WrappedSurface)s).setSurfaceScale(hasPixelScale);
       }
   }
 
   @Override
-  public final int[] setSurfaceScale(final int[] result, final int[] pixelScale) { // HiDPI support
+  public final void setSurfaceScale(final int[] pixelScale) { // HiDPI support
       SurfaceScaleUtils.validateReqPixelScale(reqPixelScale, pixelScale, DEBUG ? getClass().getSimpleName() : null);
-      if( null != result ) {
-          System.arraycopy(reqPixelScale, 0, result, 0, 2);
-      }
       final Backend b = backend;
       if ( isInitialized && null != b ) {
           final int[] pixelScaleInt;
@@ -585,11 +582,16 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
               display();
           }
       }
+  }
+
+  @Override
+  public final int[] getRequestedSurfaceScale(final int[] result) {
+      System.arraycopy(reqPixelScale, 0, result, 0, 2);
       return result;
   }
 
   @Override
-  public final int[] getSurfaceScale(final int[] result) {
+  public final int[] getCurrentSurfaceScale(final int[] result) {
       System.arraycopy(hasPixelScale, 0, result, 0, 2);
       return result;
   }
index d235a2a..1cc8fdb 100644 (file)
@@ -277,16 +277,18 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
    * </p>
    */
   @Override
-  public int[] setSurfaceScale(final int[] result, final int[] pixelScale) {
+  public void setSurfaceScale(final int[] pixelScale) {
       SurfaceScaleUtils.validateReqPixelScale(reqPixelScale, pixelScale, DEBUG ? getClass().getSimpleName() : null);
-      if( null != result ) {
-          System.arraycopy(reqPixelScale, 0, result, 0, 2);
-      }
+  }
+
+  @Override
+  public final int[] getRequestedSurfaceScale(final int[] result) {
+      System.arraycopy(reqPixelScale, 0, result, 0, 2);
       return result;
   }
 
   @Override
-  public final int[] getSurfaceScale(final int[] result) {
+  public final int[] getCurrentSurfaceScale(final int[] result) {
       System.arraycopy(hasPixelScale, 0, result, 0, 2);
       return result;
   }
index f610103..de6ba51 100644 (file)
@@ -30,7 +30,7 @@ package javax.media.nativewindow;
 
 /**
  * Adding mutable surface pixel scale property to implementing class, usually to a {@link NativeSurface} implementation,
- * see {@link #setSurfaceScale(int[], int[])}.
+ * see {@link #setSurfaceScale(int[])}.
  */
 public interface ScalableSurface {
   /** Setting surface-pixel-scale of {@value}, results in same pixel- and window-units. */
@@ -39,8 +39,7 @@ public interface ScalableSurface {
   public static final int AUTOMAX_PIXELSCALE = 0;
 
   /**
-   * Request a pixel scale in x- and y-direction for the associated {@link NativeSurface}
-   * and return the validated requested value, see below.
+   * Request a pixel scale in x- and y-direction for the associated {@link NativeSurface}.
    * <p>
    * Default pixel scale request for both directions is {@link #AUTOMAX_PIXELSCALE}.
    * </p>
@@ -51,17 +50,24 @@ public interface ScalableSurface {
    * <p>
    * The <i>requested</i> pixel scale will be validated against platform limits before native scale-setup,
    * i.e. clipped to {@link #IDENTITY_PIXELSCALE} if not supported or clipped to the platform maximum.
+   * It can be queried via {@link #getRequestedSurfaceScale(int[])}.
    * </p>
    * <p>
    * The actual <i>realized</i> pixel scale values of the {@link NativeSurface}
-   * can be queried via {@link #getSurfaceScale(int[])} or
+   * can be queried via {@link #getCurrentSurfaceScale(int[])} or
    * computed via <code>surface.{@link NativeSurface#convertToPixelUnits(int[]) convertToPixelUnits}(new int[] { 1, 1 })</code>
    * </p>
-   * @param result int[2] storage for the result, maybe null
-   * @param pixelScale <i>requested</i> surface pixel scale int[2] values for x- and y-direction.
-   * @return the passed storage containing the validated requested pixelSize for chaining, if storage is not null
+ * @param pixelScale <i>requested</i> surface pixel scale int[2] values for x- and y-direction.
    */
-  public int[] setSurfaceScale(final int[] result, final int[] pixelScale);
+  public void setSurfaceScale(final int[] pixelScale);
+
+  /**
+   * Returns the requested pixel scale of the associated {@link NativeSurface}.
+   *
+   * @param result int[2] storage for the result
+   * @return the passed storage containing the requested pixelSize for chaining
+   */
+  int[] getRequestedSurfaceScale(final int[] result);
 
   /**
    * Returns the current pixel scale of the associated {@link NativeSurface}.
@@ -69,6 +75,6 @@ public interface ScalableSurface {
    * @param result int[2] storage for the result
    * @return the passed storage containing the current pixelSize for chaining
    */
-  public int[] getSurfaceScale(final int[] result);
+  public int[] getCurrentSurfaceScale(final int[] result);
 }
 
index 4586812..22e67ec 100644 (file)
@@ -95,7 +95,7 @@ public class SurfaceScaleUtils {
      * Validate the given requested pixelScale value pair, i.e. clip it to the
      * limits of {@link ScalableSurface#AUTOMAX_PIXELSCALE} and {@link #getPlatformMaxPixelScale(int[])}
      * <p>
-     * To be used by {@link ScalableSurface#setSurfaceScale(int[], int[])} implementations.
+     * To be used by {@link ScalableSurface#setSurfaceScale(int[])} implementations.
      * </p>
      *
      * @param result int[2] storage for result
index 96862cb..8f93791 100644 (file)
@@ -104,7 +104,7 @@ public class WrappedSurface extends ProxySurfaceImpl implements ScalableSurface
   /**
    * {@inheritDoc}
    * <p>
-   * {@link WrappedSurface}'s implementation uses the {@link #setSurfaceScale(int[], int[]) given pixelScale} directly.
+   * {@link WrappedSurface}'s implementation uses the {@link #setSurfaceScale(int[]) given pixelScale} directly.
    * </p>
    */
   @Override
@@ -117,7 +117,7 @@ public class WrappedSurface extends ProxySurfaceImpl implements ScalableSurface
   /**
    * {@inheritDoc}
    * <p>
-   * {@link WrappedSurface}'s implementation uses the {@link #setSurfaceScale(int[], int[]) given pixelScale} directly.
+   * {@link WrappedSurface}'s implementation uses the {@link #setSurfaceScale(int[]) given pixelScale} directly.
    * </p>
    */
   @Override
@@ -147,17 +147,19 @@ public class WrappedSurface extends ProxySurfaceImpl implements ScalableSurface
    * </p>
    */
   @Override
-  public final int[] setSurfaceScale(final int[] result, final int[] pixelScale) {
+  public final void setSurfaceScale(final int[] pixelScale) {
       hasPixelScale[0] = pixelScale[0];
       hasPixelScale[1] = pixelScale[1];
-      if( null != result ) {
-          System.arraycopy(hasPixelScale, 0, result, 0, 2);
-      }
+  }
+
+  @Override
+  public final int[] getRequestedSurfaceScale(final int[] result) {
+      System.arraycopy(hasPixelScale, 0, result, 0, 2);
       return result;
   }
 
   @Override
-  public final int[] getSurfaceScale(final int[] result) {
+  public final int[] getCurrentSurfaceScale(final int[] result) {
       System.arraycopy(hasPixelScale, 0, result, 0, 2);
       return result;
   }
index 695fdac..3728bfb 100644 (file)
@@ -114,8 +114,8 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface {
   }
 
   @Override
-  public int[] setSurfaceScale(final int[] result, final int[] pixelScale) {
-      super.setSurfaceScale(result, pixelScale);
+  public void setSurfaceScale(final int[] pixelScale) {
+      super.setSurfaceScale(pixelScale);
       if( 0 != getWindowHandle() ) { // locked at least once !
           final int hadPixelScaleX = getPixelScaleX();
           updatePixelScale();
@@ -132,7 +132,6 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface {
               });
           }
       }
-      return result;
   }
 
   @Override
index f5e4ff4..48c7cd5 100644 (file)
@@ -860,12 +860,19 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
       }
       final int w = getWidth();
       final int h = getHeight();
+      final boolean isNValid = newtChild.isNativeValid();
       if(DEBUG) {
-          System.err.println("NewtCanvasAWT.attachNewtChild.2: size "+w+"x"+h);
+          System.err.println("NewtCanvasAWT.attachNewtChild.2: size "+w+"x"+h+", isNValid "+isNValid);
       }
       newtChild.setVisible(false);
       newtChild.setSize(w, h);
-      jawtWindow.setSurfaceScale(null, newtChild.getSurfaceScale(new int[2]));
+      final int[] reqSurfaceScale = new int[2];
+      if( isNValid ) {
+          newtChild.getCurrentSurfaceScale(reqSurfaceScale);
+      } else {
+          newtChild.getRequestedSurfaceScale(reqSurfaceScale);
+      }
+      jawtWindow.setSurfaceScale(reqSurfaceScale);
       newtChild.reparentWindow(jawtWindow, -1, -1, Window.REPARENT_HINT_BECOMES_VISIBLE);
       newtChild.addSurfaceUpdatedListener(jawtWindow);
       if( jawtWindow.isOffscreenLayerSurfaceEnabled() &&
index ae99b74..2529791 100644 (file)
@@ -404,13 +404,18 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind
     }
 
     @Override
-    public final int[] setSurfaceScale(final int[] result, final int[] pixelScale) {
-        return window.setSurfaceScale(result, pixelScale);
+    public final void setSurfaceScale(final int[] pixelScale) {
+        window.setSurfaceScale(pixelScale);
     }
 
     @Override
-    public final int[] getSurfaceScale(final int[] result) {
-        return window.getSurfaceScale(result);
+    public final int[] getRequestedSurfaceScale(final int[] result) {
+        return window.getRequestedSurfaceScale(result);
+    }
+
+    @Override
+    public final int[] getCurrentSurfaceScale(final int[] result) {
+        return window.getCurrentSurfaceScale(result);
     }
 
     @Override
index d68a1df..0df105f 100644 (file)
@@ -1968,16 +1968,18 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
     }
 
     @Override
-    public int[] setSurfaceScale(final int[] result, final int[] pixelScale) {
+    public void setSurfaceScale(final int[] pixelScale) {
         SurfaceScaleUtils.validateReqPixelScale(reqPixelScale, pixelScale, DEBUG_IMPLEMENTATION ? getClass().getSimpleName() : null);
-        if( null != result ) {
-            System.arraycopy(reqPixelScale, 0, result, 0, 2);
-        }
+    }
+
+    @Override
+    public final int[] getRequestedSurfaceScale(final int[] result) {
+        System.arraycopy(reqPixelScale, 0, result, 0, 2);
         return result;
     }
 
     @Override
-    public final int[] getSurfaceScale(final int[] result) {
+    public final int[] getCurrentSurfaceScale(final int[] result) {
         System.arraycopy(hasPixelScale, 0, result, 0, 2);
         return result;
     }
index e3c4e3b..540d9b7 100644 (file)
@@ -146,9 +146,9 @@ public class AWTCanvas extends Canvas {
     {
         jawtWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(this, awtConfig);
         // trigger initialization cycle
-        jawtWindow.setSurfaceScale(null, upstreamScale.getReqPixelScale() );
+        jawtWindow.setSurfaceScale(upstreamScale.getReqPixelScale() );
         jawtWindow.lockSurface();
-        upstreamScale.setHasPixelScale(jawtWindow.getSurfaceScale(new int[2]));
+        upstreamScale.setHasPixelScale(jawtWindow.getCurrentSurfaceScale(new int[2]));
         jawtWindow.unlockSurface();
     }
 
index 07d31ac..4985566 100644 (file)
@@ -135,11 +135,8 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
     }
 
     @Override
-    public final int[] setSurfaceScale(final int[] result, final int[] pixelScale) {
+    public final void setSurfaceScale(final int[] pixelScale) {
         SurfaceScaleUtils.validateReqPixelScale(reqPixelScale, pixelScale, DEBUG_IMPLEMENTATION ? getClass().getName() : null);
-        if( null != result ) {
-            System.arraycopy(reqPixelScale, 0, result, 0, 2);
-        }
 
         final int[] resPixelScale;
         if( isNativeValid() ) {
@@ -147,8 +144,8 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
                 final NativeWindow pWin = getParent();
                 if( pWin instanceof ScalableSurface ) {
                     final ScalableSurface sSurf = (ScalableSurface)pWin;
-                    sSurf.setSurfaceScale(result, reqPixelScale);
-                    final int[] pPixelScale = sSurf.getSurfaceScale(new int[2]);
+                    sSurf.setSurfaceScale(reqPixelScale);
+                    final int[] pPixelScale = sSurf.getCurrentSurfaceScale(new int[2]);
                     updatePixelScale(true /* sendEvent */, true /* defer */, pPixelScale[0]); // HiDPI: uniformPixelScale
                 } else {
                     // just notify updated pixelScale if offscreen
@@ -175,7 +172,6 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
                                 reqPixelScale[0]+"x"+reqPixelScale[1]+" (validated) -> "+
                                 resPixelScale[0]+"x"+resPixelScale[1]+" (result) - realized "+isNativeValid());
         }
-        return result;
     }
 
     @Override
index 374c065..6fb972b 100644 (file)
@@ -170,7 +170,8 @@ public class TestGearsES2AWT extends UITestCase {
         final GLCanvas glCanvas = new GLCanvas(caps);
         Assert.assertNotNull(glCanvas);
         setSize(resizeBy, frame, false, glCanvas, new Dimension(width, height));
-        final int[] valReqSurfacePixelScale = glCanvas.setSurfaceScale(new int[2], reqSurfacePixelScale);
+        glCanvas.setSurfaceScale(reqSurfacePixelScale);
+        final int[] valReqSurfacePixelScale = glCanvas.getRequestedSurfaceScale(new int[2]);
         frame.setLocation(xpos, ypos);
 
         switch( frameLayout) {
@@ -253,7 +254,7 @@ public class TestGearsES2AWT extends UITestCase {
                     return;
                 }
                 if(e.getKeyChar()=='x') {
-                    final int[] hadSurfacePixelScale = glCanvas.getSurfaceScale(new int[2]);
+                    final int[] hadSurfacePixelScale = glCanvas.getCurrentSurfaceScale(new int[2]);
                     final int[] reqSurfacePixelScale;
                     if( hadSurfacePixelScale[0] == ScalableSurface.IDENTITY_PIXELSCALE ) {
                         reqSurfacePixelScale = new int[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE };
@@ -261,9 +262,10 @@ public class TestGearsES2AWT extends UITestCase {
                         reqSurfacePixelScale = new int[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE };
                     }
                     System.err.println("[set PixelScale pre]: had "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" -> req "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]);
-                    final int[] valReqSurfacePixelScale = glCanvas.setSurfaceScale(new int[2], reqSurfacePixelScale);
+                    glCanvas.setSurfaceScale(reqSurfacePixelScale);
+                    final int[] valReqSurfacePixelScale = glCanvas.getRequestedSurfaceScale(new int[2]);
                     final int[] hasSurfacePixelScale0 = glCanvas.getNativeSurface().convertToPixelUnits(new int[] { 1, 1 });
-                    final int[] hasSurfacePixelScale1 = glCanvas.getSurfaceScale(new int[2]);
+                    final int[] hasSurfacePixelScale1 = glCanvas.getCurrentSurfaceScale(new int[2]);
                     System.err.println("[set PixelScale post]: "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" (had) -> "+
                                        reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+
                                        valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+
@@ -287,7 +289,7 @@ public class TestGearsES2AWT extends UITestCase {
         Assert.assertEquals(true,  AWTRobotUtil.waitForRealized(glCanvas, true));
 
         final int[] hasSurfacePixelScale0 = glCanvas.getNativeSurface().convertToPixelUnits(new int[] { 1, 1 });
-        final int[] hasSurfacePixelScale1 = glCanvas.getSurfaceScale(new int[2]);
+        final int[] hasSurfacePixelScale1 = glCanvas.getCurrentSurfaceScale(new int[2]);
         System.err.println("HiDPI PixelScale: "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+
                            valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+
                            hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)");
index 244cd8c..551b27c 100644 (file)
@@ -124,7 +124,8 @@ public class TestGearsES2GLJPanelAWT extends UITestCase {
         glJPanel.setMinimumSize(wsize);
         glJPanel.setPreferredSize(wsize);
         glJPanel.setSize(wsize);
-        final int[] valReqSurfacePixelScale = glJPanel.setSurfaceScale(new int[2], reqSurfacePixelScale);
+        glJPanel.setSurfaceScale(reqSurfacePixelScale);
+        final int[] valReqSurfacePixelScale = glJPanel.getRequestedSurfaceScale(new int[2]);
         if( caps.isBitmap() || caps.getGLProfile().isGL2() ) {
             final Gears gears = new Gears(swapInterval);
             gears.setFlipVerticalInGLOrientation(skipGLOrientationVerticalFlip);
@@ -170,7 +171,7 @@ public class TestGearsES2GLJPanelAWT extends UITestCase {
         Assert.assertEquals(true,  AWTRobotUtil.waitForRealized(glJPanel, true));
 
         final int[] hasSurfacePixelScale0 = glJPanel.getNativeSurface().convertToPixelUnits(new int[] { 1, 1 });
-        final int[] hasSurfacePixelScale1 = glJPanel.getSurfaceScale(new int[2]);
+        final int[] hasSurfacePixelScale1 = glJPanel.getCurrentSurfaceScale(new int[2]);
         System.err.println("HiDPI PixelScale: "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+
                            valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+
                            hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)");
@@ -194,7 +195,7 @@ public class TestGearsES2GLJPanelAWT extends UITestCase {
                     return;
                 }
                 if(e.getKeyChar()=='x') {
-                    final int[] hadSurfacePixelScale = glJPanel.getSurfaceScale(new int[2]);
+                    final int[] hadSurfacePixelScale = glJPanel.getCurrentSurfaceScale(new int[2]);
                     final int[] reqSurfacePixelScale;
                     if( hadSurfacePixelScale[0] == ScalableSurface.IDENTITY_PIXELSCALE ) {
                         reqSurfacePixelScale = new int[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE };
@@ -202,9 +203,10 @@ public class TestGearsES2GLJPanelAWT extends UITestCase {
                         reqSurfacePixelScale = new int[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE };
                     }
                     System.err.println("[set PixelScale pre]: had "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" -> req "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]);
-                    final int[] valReqSurfacePixelScale = glJPanel.setSurfaceScale(new int[2], reqSurfacePixelScale);
+                    glJPanel.setSurfaceScale(reqSurfacePixelScale);
+                    final int[] valReqSurfacePixelScale = glJPanel.getRequestedSurfaceScale(new int[2]);
                     final int[] hasSurfacePixelScale0 = glJPanel.getNativeSurface().convertToPixelUnits(new int[] { 1, 1 });
-                    final int[] hasSurfacePixelScale1 = glJPanel.getSurfaceScale(new int[2]);
+                    final int[] hasSurfacePixelScale1 = glJPanel.getCurrentSurfaceScale(new int[2]);
                     System.err.println("[set PixelScale post]: "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" (had) -> "+
                                        reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+
                                        valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+
index 458536d..3e78360 100644 (file)
@@ -130,7 +130,8 @@ public class TestGearsES2NEWT extends UITestCase {
         Screen screen = NewtFactory.createScreen(dpy, screenIdx);
         final GLWindow glWindow = GLWindow.create(screen, caps);
         Assert.assertNotNull(glWindow);
-        final int[] valReqSurfacePixelScale = glWindow.setSurfaceScale(new int[2], reqSurfacePixelScale);
+        glWindow.setSurfaceScale(reqSurfacePixelScale);
+        final int[] valReqSurfacePixelScale = glWindow.getRequestedSurfaceScale(new int[2]);
         glWindow.setSize(wsize.getWidth(), wsize.getHeight());
         if(null != wpos) {
             glWindow.setPosition(wpos.getX(), wpos.getY());
@@ -347,7 +348,7 @@ public class TestGearsES2NEWT extends UITestCase {
                             glWindow.setExclusiveContextThread(t);
                     } }.start();
                 } else if(e.getKeyChar()=='x') {
-                    final int[] hadSurfacePixelScale = glWindow.getSurfaceScale(new int[2]);
+                    final int[] hadSurfacePixelScale = glWindow.getCurrentSurfaceScale(new int[2]);
                     final int[] reqSurfacePixelScale;
                     if( hadSurfacePixelScale[0] == ScalableSurface.IDENTITY_PIXELSCALE ) {
                         reqSurfacePixelScale = new int[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE };
@@ -355,9 +356,10 @@ public class TestGearsES2NEWT extends UITestCase {
                         reqSurfacePixelScale = new int[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE };
                     }
                     System.err.println("[set PixelScale pre]: had "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" -> req "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]);
-                    final int[] valReqSurfacePixelScale = glWindow.setSurfaceScale(new int[2], reqSurfacePixelScale);
+                    glWindow.setSurfaceScale(reqSurfacePixelScale);
+                    final int[] valReqSurfacePixelScale = glWindow.getRequestedSurfaceScale(new int[2]);
                     final int[] hasSurfacePixelScale0 = glWindow.convertToPixelUnits(new int[] { 1, 1 });
-                    final int[] hasSurfacePixelScale1 = glWindow.getSurfaceScale(new int[2]);
+                    final int[] hasSurfacePixelScale1 = glWindow.getCurrentSurfaceScale(new int[2]);
                     System.err.println("[set PixelScale post]: "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" (had) -> "+
                                        reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+
                                        valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+
@@ -437,7 +439,7 @@ public class TestGearsES2NEWT extends UITestCase {
         System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", "+glWindow.getInsets());
 
         final int[] hasSurfacePixelScale0 = glWindow.convertToPixelUnits(new int[] { 1, 1 });
-        final int[] hasSurfacePixelScale1 = glWindow.getSurfaceScale(new int[2]);
+        final int[] hasSurfacePixelScale1 = glWindow.getCurrentSurfaceScale(new int[2]);
         System.err.println("HiDPI PixelScale: "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+
                            valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+
                            hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)");
index 22c1bc4..694efea 100644 (file)
@@ -191,7 +191,8 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase {
         Screen screen = NewtFactory.createScreen(dpy, screenIdx);
         final GLWindow glWindow = GLWindow.create(screen, caps);
         Assert.assertNotNull(glWindow);
-        final int[] valReqSurfacePixelScale = glWindow.setSurfaceScale(new int[2], reqSurfacePixelScale);
+        glWindow.setSurfaceScale(reqSurfacePixelScale);
+        final int[] valReqSurfacePixelScale = glWindow.getRequestedSurfaceScale(new int[2]);
 
         final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow);
         if ( shallUseOffscreenFBOLayer ) {
@@ -306,7 +307,7 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase {
                     return;
                 }
                 if(e.getKeyChar()=='x') {
-                    final int[] hadSurfacePixelScale = glWindow.getSurfaceScale(new int[2]);
+                    final int[] hadSurfacePixelScale = glWindow.getCurrentSurfaceScale(new int[2]);
                     final int[] reqSurfacePixelScale;
                     if( hadSurfacePixelScale[0] == ScalableSurface.IDENTITY_PIXELSCALE ) {
                         reqSurfacePixelScale = new int[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE };
@@ -314,9 +315,10 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase {
                         reqSurfacePixelScale = new int[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE };
                     }
                     System.err.println("[set PixelScale pre]: had "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" -> req "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]);
-                    final int[] valReqSurfacePixelScale = glWindow.setSurfaceScale(new int[2], reqSurfacePixelScale);
+                    glWindow.setSurfaceScale(reqSurfacePixelScale);
+                    final int[] valReqSurfacePixelScale = glWindow.getRequestedSurfaceScale(new int[2]);
                     final int[] hasSurfacePixelScale0 = glWindow.convertToPixelUnits(new int[] { 1, 1 });
-                    final int[] hasSurfacePixelScale1 = glWindow.getSurfaceScale(new int[2]);
+                    final int[] hasSurfacePixelScale1 = glWindow.getCurrentSurfaceScale(new int[2]);
                     System.err.println("[set PixelScale post]: "+hadSurfacePixelScale[0]+"x"+hadSurfacePixelScale[1]+" (had) -> "+
                                        reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+
                                        valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+
@@ -356,7 +358,7 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase {
         System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getSurfaceWidth()+"x"+glWindow.getSurfaceHeight()+", "+glWindow.getInsets());
 
         final int[] hasSurfacePixelScale0 = glWindow.convertToPixelUnits(new int[] { 1, 1 });
-        final int[] hasSurfacePixelScale1 = glWindow.getSurfaceScale(new int[2]);
+        final int[] hasSurfacePixelScale1 = glWindow.getCurrentSurfaceScale(new int[2]);
         System.err.println("HiDPI PixelScale: "+reqSurfacePixelScale[0]+"x"+reqSurfacePixelScale[1]+" (req) -> "+
                            valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+
                            hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)");
http://JogAmp.org git info: FAQ, tutorial and man pages.