JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
GenericUpstreamSurfacelessHook.java
Go to the documentation of this file.
1/**
2 * Copyright 2014-2023 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28package com.jogamp.nativewindow;
29
31 /**
32 * @param width the initial width as returned by {@link NativeSurface#getSurfaceWidth()} via {@link UpstreamSurfaceHook#getSurfaceWidth(ProxySurface)},
33 * not the actual dummy surface width.
34 * The latter is platform specific and small
35 * @param height the initial height as returned by {@link NativeSurface#getSurfaceHeight()} via {@link UpstreamSurfaceHook#getSurfaceHeight(ProxySurface)},
36 * not the actual dummy surface height,
37 * The latter is platform specific and small
38 */
39 public GenericUpstreamSurfacelessHook(final int width, final int height) {
40 super(width, height);
41 }
42
43 @Override
44 public final void create(final ProxySurface s) {
46 device.lock();
47 try {
48 if(0 == device.getHandle()) {
49 device.open();
51 }
52 if( 0 != s.getSurfaceHandle() ) {
53 throw new InternalError("Upstream surface not null: "+s);
54 }
58 } finally {
59 device.unlock();
60 }
61 }
62
63 @Override
64 public final void destroy(final ProxySurface s) {
68 throw new InternalError("Owns upstream surface, but not a valid zero surface: "+s);
69 }
70 if( 0 != s.getSurfaceHandle() ) {
71 throw new InternalError("Owns upstream valid zero surface, but non zero surface: "+s);
72 }
73 device.lock();
74 try {
76 } finally {
77 device.unlock();
78 }
79 }
80 }
81}
final void create(final ProxySurface s)
called within ProxySurface#createNotify() within lock, before using surface.
final void destroy(final ProxySurface s)
called within ProxySurface#destroyNotify() within lock, before clearing fields.
AbstractGraphicsScreen getScreen()
Return the screen this graphics configuration is valid for.
A interface describing a graphics device in a toolkit-independent manner.
void lock()
Optionally locking the device, utilizing eg com.jogamp.nativewindow.ToolkitLock#lock().
void unlock()
Optionally unlocking the device, utilizing eg com.jogamp.nativewindow.ToolkitLock#unlock().
long getHandle()
Returns the native handle of the underlying native device, if such thing exist.
boolean open()
Optionally [re]opening the device if handle is null.
AbstractGraphicsDevice getDevice()
Return the device this graphics configuration is valid for.
AbstractGraphicsConfiguration getGraphicsConfiguration()
Returns the graphics configuration corresponding to this window.
long getSurfaceHandle()
Returns the handle to the surface for this NativeSurface.
Provides a mutable NativeSurface, i.e.
static final int OPT_PROXY_OWNS_UPSTREAM_SURFACE
Implementation specific bit-value stating this ProxySurface owns the upstream's surface handle.
void addUpstreamOptionBits(int v)
Add the given bit-mask to this instance upstream-option-bits using bit-or w/ v.
void clearUpstreamOptionBits(int v)
Clear the given bit-mask from this instance upstream-option-bits using bit-and w/ ~v
boolean containsUpstreamOptionBits(int v)
Returns true if the give bit-mask v is set in this instance upstream-option-bits, otherwise false.
static final int OPT_UPSTREAM_SURFACELESS
Implementation specific bitvalue stating the upstream's NativeSurface's zero handle is valid.
static final int OPT_PROXY_OWNS_UPSTREAM_DEVICE
Implementation specific bit-value stating this ProxySurface owns the upstream's AbstractGraphicsDevic...
static final int OPT_UPSTREAM_WINDOW_INVISIBLE
Implementation specific bitvalue stating the upstream's NativeSurface is an invisible window,...