aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/egl/EGLWrappedSurface.java
blob: e6d43d95745b3ebca2ccd720cbadfe1dd21ad6c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package jogamp.opengl.egl;

import javax.media.nativewindow.NativeSurface;

import jogamp.nativewindow.WrappedSurface;

/**
 * <pre>
 * EGLWrappedSurface [ is_a -> WrappedSurface -> ProxySurfaceImpl -> ProxySurface -> MutableSurface -> NativeSurface] has_a
 *     EGLUpstreamSurfaceHook [ is_a -> UpstreamSurfaceHook.MutableSize -> UpstreamSurfaceHook ] has_a
 *        NativeSurface (i.e. native X11 surface)
 * </pre>
 */
public class EGLWrappedSurface extends WrappedSurface {

    public static EGLWrappedSurface get(NativeSurface surface) {
        if(surface instanceof EGLWrappedSurface) {
            return (EGLWrappedSurface)surface;
        }
        return new EGLWrappedSurface(surface);
    }

    public EGLWrappedSurface(NativeSurface surface) {
        super(surface.getGraphicsConfiguration(), EGL.EGL_NO_SURFACE, new EGLUpstreamSurfaceHook(surface), false /* tbd in UpstreamSurfaceHook */);
        if(EGLDrawableFactory.DEBUG) {
            System.err.println("EGLWrappedSurface.ctor(): "+this);
        }
    }

    @Override
    public final NativeSurface getUpstreamSurface() {
        return ((EGLUpstreamSurfaceHook)super.getUpstreamSurfaceHook()).getUpstreamSurface();
    }
}