All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jogamp.nativewindow.DelegatedUpstreamSurfaceHookWithSurfaceSize Maven / Gradle / Ivy

package com.jogamp.nativewindow;

import com.jogamp.nativewindow.NativeSurface;
import com.jogamp.nativewindow.ProxySurface;
import com.jogamp.nativewindow.UpstreamSurfaceHook;

public class DelegatedUpstreamSurfaceHookWithSurfaceSize implements UpstreamSurfaceHook {
    final UpstreamSurfaceHook upstream;
    final NativeSurface surface;

    /**
     * @param upstream optional upstream UpstreamSurfaceHook used for {@link #create(ProxySurface)} and {@link #destroy(ProxySurface)}.
     * @param surface mandatory {@link NativeSurface} used for {@link #getSurfaceWidth(ProxySurface)} and {@link #getSurfaceHeight(ProxySurface)}, not used for {@link #getUpstreamSurface()}.
     */
    public DelegatedUpstreamSurfaceHookWithSurfaceSize(final UpstreamSurfaceHook upstream, final NativeSurface surface) {
        this.upstream = upstream;
        this.surface = surface;
        if(null == surface) {
            throw new IllegalArgumentException("given surface is null");
        }
    }

    /**
     * {@inheritDoc}
     * 

* Returns null. *

*/ @Override public final NativeSurface getUpstreamSurface() { return null; } @Override public final void create(final ProxySurface s) { if(null != upstream) { upstream.create(s); } } @Override public final void destroy(final ProxySurface s) { if(null != upstream) { upstream.destroy(s); } } @Override public final int getSurfaceWidth(final ProxySurface s) { return surface.getSurfaceWidth(); } @Override public final int getSurfaceHeight(final ProxySurface s) { return surface.getSurfaceHeight(); } @Override public String toString() { final String us_s = null != surface ? ( surface.getClass().getName() + ": 0x" + Long.toHexString(surface.getSurfaceHandle()) + " " +surface.getSurfaceWidth() + "x" + surface.getSurfaceHeight() ) : "nil"; return getClass().getSimpleName()+"["+upstream+", "+us_s+"]"; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy