From fb57c652fee6be133990cd7afbbd2fdfc084afaa Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 22 May 2014 07:09:23 +0200 Subject: Bug 742 HiDPI: [Core API Change] Distinguish window-units and pixel-units: Refine commit f9a00b91dcd146c72a50237b62270f33bd0da98e - Using comment tag 'FIXME HiDPI' to locate remaining issues - Fix remaining 'getPixel*(..)' -> 'getSurface*(..)' - UpstreamSurfaceHook - Fix usage (one by one) of - NativeWindow: getWindowWidth() / getWindowHeight() - NativeSurface/GLDrawable: getSurfaceWidth() / getSurfaceHeight() - mention window- or pixel units in API doc where required - use 'setSurfaceSize(..)' where appropriate to match 'getSurface*()' - GLFBODrawable - GLOffscreenAutoDrawable - UpstreamSurfaceHook.MutableSize - NativeWindow's Point: Add API doc and 'Point scaleInv(..)' - NativeSurface Simplify new conversion methods and use single in-place storage - 'int[] getWindowUnitXY(int[], int[])' -> 'int[] convertToWindowUnits(int[], int[])' - 'int[] getPixelUnitXY(int[], int[])' -> 'int[] convertToPixelUnits(int[], int[])' - NEWT Screen/Monitor - Assume screen/window units - TODO: Refine semantics - Monitor resolution probably is in pixel units ?! - Including the Rectangle/Monitor association etc etc - NEWT Window - Add setSurfaceSize(..) for convenience - Add 'Point convertToWindowUnits(final Point pixelUnitsAndResult)', etc .. - All window ops are using window units (size, pos, ..), but methods operating on the surface/drawable: windowRepaint(..) .. - TODO: Consider changing method names 'window*(..)' to 'surface*(..)' actually operating on surface/drawable - Window.windowRepaint(..) - GLAutoDrawableDelegate.windowResizedOp(..) (maybe all similar methods in here) - NEWT Mouse/Pointer Events - Using pixel units --- .../test/junit/graph/demos/GPURegionNewtDemo.java | 2 +- .../test/junit/graph/demos/GPUTextNewtDemo.java | 2 +- .../test/junit/graph/demos/GPUUISceneNewtDemo.java | 8 ++--- .../graph/demos/ui/GLEventListenerButton.java | 2 +- .../test/junit/graph/demos/ui/UINewtDemo01.java | 2 +- .../jogl/acore/TestFBOAutoDrawableFactoryNEWT.java | 6 ++-- ...tFBOOffThreadSharedContextMix2DemosES2NEWT.java | 4 +-- .../TestFBOOnThreadSharedContext1DemoES2NEWT.java | 2 +- ...estGLAutoDrawableFactoryES2OffscrnCapsNEWT.java | 4 +-- ...estGLAutoDrawableFactoryGL2OffscrnCapsNEWT.java | 4 +-- ...TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.java | 4 +-- .../opengl/test/junit/jogl/demos/es1/GearsES1.java | 6 +++- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 2 +- .../jogl/demos/es2/TextureSequenceCubeES2.java | 6 +++- .../test/junit/jogl/demos/es2/av/MovieCube.java | 4 +-- .../test/junit/jogl/demos/es2/av/MovieSimple.java | 22 +++++++------- .../opengl/test/junit/jogl/demos/gl2/Gears.java | 6 +++- .../opengl/test/junit/newt/TestWindows01NEWT.java | 34 +++++++++++----------- .../opengl/test/junit/util/AWTRobotUtil.java | 4 +-- 19 files changed, 68 insertions(+), 56 deletions(-) (limited to 'src/test') diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo.java index 7897d0a00..5c217a7dc 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo.java @@ -108,7 +108,7 @@ public class GPURegionNewtDemo { final GLWindow window = GLWindow.create(caps); window.setPosition(10, 10); - window.setSize(800, 400); + window.setSurfaceSize(800, 400); window.setTitle("GPU Curve Region Newt Demo - graph[vbaa"+GraphVBAASamples+" msaa"+GraphMSAASamples+"], msaa "+SceneMSAASamples); RenderState rs = RenderState.createRenderState(SVertex.factory()); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo.java index e6b1f9c9c..09cf706ce 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo.java @@ -106,7 +106,7 @@ public class GPUTextNewtDemo { final GLWindow window = GLWindow.create(caps); window.setPosition(10, 10); - window.setSize(800, 400); + window.setSurfaceSize(800, 400); window.setTitle("GPU Text Newt Demo - graph[vbaa"+GraphVBAASamples+" msaa"+GraphMSAASamples+"], msaa "+SceneMSAASamples); RenderState rs = RenderState.createRenderState(SVertex.factory()); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java index 79f6d7bb8..c26cb467a 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java @@ -21,7 +21,7 @@ public class GPUUISceneNewtDemo { static boolean GraphMSAAMode = false; public static void main(String[] args) { - int wwidth = 800, wheight = 400; + int swidth = 800, sheight = 400; if( 0 != args.length ) { for(int i=0; i pixel units! height=comp.getHeight(); } else { throw new RuntimeException("Event source neither Window nor Component: "+source); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index 09fd911a7..b2b1dd642 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -619,7 +619,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL height = glad.getSurfaceHeight(); } else if (GLProfile.isAWTAvailable() && source instanceof java.awt.Component) { java.awt.Component comp = (java.awt.Component) source; - width=comp.getWidth(); + width=comp.getWidth(); // FIXME HiDPI: May need to convert window units -> pixel units! height=comp.getHeight(); } else { throw new RuntimeException("Event source neither Window nor Component: "+source); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java index 17332a4e2..db0e11734 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java @@ -98,9 +98,13 @@ public class TextureSequenceCubeES2 implements GLEventListener { window = (Window) source; width=window.getSurfaceWidth(); height=window.getSurfaceHeight(); + } else if (source instanceof GLAutoDrawable) { + GLAutoDrawable glad = (GLAutoDrawable) source; + width = glad.getSurfaceWidth(); + height = glad.getSurfaceHeight(); } else if (GLProfile.isAWTAvailable() && source instanceof java.awt.Component) { java.awt.Component comp = (java.awt.Component) source; - width=comp.getWidth(); + width=comp.getWidth(); // FIXME HiDPI: May need to convert window units -> pixel units! height=comp.getHeight(); } else { throw new RuntimeException("Event source neither Window nor Component: "+source); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java index 730e6e562..116d5d245 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java @@ -561,7 +561,7 @@ public class MovieCube implements GLEventListener { anim.stop(); } }); - window.setSize(width, height); + window.setSurfaceSize(width, height); window.setVisible(true); System.err.println("Chosen: "+window.getChosenGLCapabilities()); anim.start(); @@ -577,7 +577,7 @@ public class MovieCube implements GLEventListener { System.err.println("MovieCube State: "+mp); if( 0 != ( GLMediaEventListener.EVENT_CHANGE_SIZE & event_mask ) ) { if( origSize ) { - window.setSize(mp.getWidth(), mp.getHeight()); + window.setSurfaceSize(mp.getWidth(), mp.getHeight()); } // window.disposeGLEventListener(ms, false /* remove */ ); mc.resetGLState(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java index 7afd31352..1997739e3 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java @@ -94,7 +94,7 @@ public class MovieSimple implements GLEventListener { private static final String PLAYER = "player"; private static boolean waitForKey = false; - private int winWidth, winHeight; + private int surfWidth, surfHeight; private int prevMouseX; // , prevMouseY; private int rotate = 0; private boolean orthoProjection = true; @@ -213,7 +213,7 @@ public class MovieSimple implements GLEventListener { private final MouseListener mouseAction = new MouseAdapter() { public void mousePressed(MouseEvent e) { - if(e.getY()<=winHeight/2 && null!=mPlayer && 1 == e.getClickCount()) { + if(e.getY()<=surfHeight/2 && null!=mPlayer && 1 == e.getClickCount()) { if(GLMediaPlayer.State.Playing == mPlayer.getState()) { mPlayer.pause(false); } else { @@ -222,7 +222,7 @@ public class MovieSimple implements GLEventListener { } } public void mouseReleased(MouseEvent e) { - if(e.getY()<=winHeight/2) { + if(e.getY()<=surfHeight/2) { rotate = -1; zoom = zoom0; System.err.println("zoom: "+zoom); @@ -236,8 +236,8 @@ public class MovieSimple implements GLEventListener { int x = e.getX(); int y = e.getY(); - if(y>winHeight/2) { - final float dp = (float)(x-prevMouseX)/(float)winWidth; + if(y>surfHeight/2) { + final float dp = (float)(x-prevMouseX)/(float)surfWidth; final int pts0 = GLMediaPlayer.STREAM_ID_NONE != mPlayer.getVID() ? mPlayer.getVideoPTS() : mPlayer.getAudioPTS(); mPlayer.seek(pts0 + (int) (mPlayer.getDuration() * dp)); } else { @@ -602,8 +602,8 @@ public class MovieSimple implements GLEventListener { final Window window = (Window) upstreamWidget; window.addMouseListener(mouseAction); window.addKeyListener(keyAction); - winWidth = window.getSurfaceWidth(); - winHeight = window.getSurfaceHeight(); + surfWidth = window.getSurfaceWidth(); + surfHeight = window.getSurfaceHeight(); } final int rmode = drawable.getChosenGLCapabilities().getSampleBuffers() ? 0 : Region.VBAA_RENDERING_BIT; final boolean lowPerfDevice = gl.isGLES(); @@ -669,8 +669,8 @@ public class MovieSimple implements GLEventListener { public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { final GL2ES2 gl = drawable.getGL().getGL2ES2(); if(null == mPlayer) { return; } - winWidth = width; - winHeight = height; + surfWidth = width; + surfHeight = height; if(null != st) { reshapePMV(width, height); @@ -827,7 +827,7 @@ public class MovieSimple implements GLEventListener { if( 0 != ( GLMediaEventListener.EVENT_CHANGE_SIZE & event_mask ) ) { System.err.println("MovieSimple State: CHANGE_SIZE"); if( origSize ) { - window.setSize(mp.getWidth(), mp.getHeight()); + window.setSurfaceSize(mp.getWidth(), mp.getHeight()); } // window.disposeGLEventListener(ms, false /* remove */ ); ms.resetGLState(); @@ -1050,7 +1050,7 @@ public class MovieSimple implements GLEventListener { mss[i].mPlayer.addEventListener(myGLMediaEventListener); windows[i].setTitle("Player "+i); - windows[i].setSize(width, height); + windows[i].setSurfaceSize(width, height); windows[i].setVisible(true); anim.add(windows[i]); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java index 049945bda..9c5d1e249 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java @@ -501,9 +501,13 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList Window window = (Window) source; width=window.getSurfaceWidth(); height=window.getSurfaceHeight(); + } else if (source instanceof GLAutoDrawable) { + GLAutoDrawable glad = (GLAutoDrawable) source; + width = glad.getSurfaceWidth(); + height = glad.getSurfaceHeight(); } else if (GLProfile.isAWTAvailable() && source instanceof java.awt.Component) { java.awt.Component comp = (java.awt.Component) source; - width=comp.getWidth(); + width=comp.getWidth(); // FIXME HiDPI: May need to convert window units -> pixel units! height=comp.getHeight(); } else { throw new RuntimeException("Event source neither Window nor Component: "+source); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestWindows01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestWindows01NEWT.java index 19b6fbd07..082a900a0 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestWindows01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestWindows01NEWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.newt; import org.junit.Assert; @@ -54,14 +54,14 @@ public class TestWindows01NEWT extends UITestCase { static Window createWindow(Capabilities caps, int x, int y, int width, int height, boolean onscreen, boolean undecorated) throws InterruptedException { final boolean userPos = x>=0 && y>=0 ; // user has specified a position - + Assert.assertNotNull(caps); caps.setOnscreen(onscreen); // System.out.println("Requested: "+caps); // // Create native windowing resources .. X11/Win/OSX - // + // Window window = NewtFactory.createWindow(caps); Assert.assertNotNull(window); Screen screen = window.getScreen(); @@ -75,13 +75,13 @@ public class TestWindows01NEWT extends UITestCase { Assert.assertEquals(false,window.isVisible()); window.setVisible(true); // System.err.println("************* Created: "+window); - - Assert.assertEquals(true,display.isNativeValid()); + + Assert.assertEquals(true,display.isNativeValid()); Assert.assertEquals(true,screen.isNativeValid()); Assert.assertEquals(true,window.isVisible()); Assert.assertEquals(true,window.isNativeValid()); - Assert.assertEquals(width, window.getSurfaceWidth()); - Assert.assertEquals(height, window.getSurfaceHeight()); + Assert.assertEquals(width, window.getWindowWidth()); + Assert.assertEquals(height, window.getWindowHeight()); /** we don't sync on position - unreliable test Point p0 = window.getLocationOnScreen(null); @@ -98,7 +98,7 @@ public class TestWindows01NEWT extends UITestCase { Assert.assertTrue(chosenCapabilities.getBlueBits()>=5); Assert.assertTrue(chosenCapabilities.getRedBits()>=5); Assert.assertEquals(chosenCapabilities.isOnscreen(),onscreen); - + return window; } @@ -115,7 +115,7 @@ public class TestWindows01NEWT extends UITestCase { Assert.assertEquals(false,display.isNativeValid()); } else { Assert.assertEquals(true,screen.isNativeValid()); - Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,display.isNativeValid()); } Assert.assertEquals(false,window.isNativeValid()); Assert.assertEquals(false,window.isVisible()); @@ -148,16 +148,16 @@ public class TestWindows01NEWT extends UITestCase { Window window = createWindow(caps, -1, -1, width, height, true /* onscreen */, false /* undecorated */); destroyWindow(window, true); - + window.setVisible(true); Assert.assertEquals(true,window.isNativeValid()); Assert.assertEquals(true,window.isVisible()); - Assert.assertEquals(width, window.getSurfaceWidth()); - Assert.assertEquals(height, window.getSurfaceHeight()); + Assert.assertEquals(width, window.getWindowWidth()); + Assert.assertEquals(height, window.getWindowHeight()); destroyWindow(window, true); } - + @Test public void testWindowDecorDestroyWinTwiceA() throws InterruptedException { Capabilities caps = new Capabilities(); diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java index 45df52220..a9fc53eec 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java @@ -137,9 +137,9 @@ public class AWTRobotUtil { javax.media.nativewindow.util.Point p0 = win.getLocationOnScreen(null); if( onTitleBarIfWindow ) { javax.media.nativewindow.util.InsetsImmutable insets = win.getInsets(); - p0.translate(win.getSurfaceWidth()/2, insets.getTopHeight()/2); + p0.translate(win.getWindowWidth()/2, insets.getTopHeight()/2); } else { - p0.translate(win.getSurfaceWidth()/2, win.getSurfaceHeight()/2); + p0.translate(win.getWindowWidth()/2, win.getWindowHeight()/2); } return new int[] { p0.getX(), p0.getY() }; } -- cgit v1.2.3