Skip to content

Commit

Permalink
Merge pull request #52 from xranby/bcm.vc.iv-autodetect
Browse files Browse the repository at this point in the history
_getNativeWindowingType() TYPE_BCM_VC_IV autodetection.
  • Loading branch information
sgothel committed Sep 29, 2012
2 parents 43891be + 8351d51 commit 20a2a4f
Showing 1 changed file with 20 additions and 0 deletions.
Expand Up @@ -33,6 +33,7 @@

package javax.media.nativewindow;

import java.io.File;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
Expand Down Expand Up @@ -65,6 +66,9 @@ public abstract class NativeWindowFactory {
/** X11 type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}. */
public static final String TYPE_X11 = ".x11".intern();

/** Broadcom VC IV/EGL type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}. */
public static final String TYPE_BCM_VC_IV = ".bcm.vc.iv".intern();

/** Android/EGL type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}.*/
public static final String TYPE_ANDROID = ".android".intern();

Expand Down Expand Up @@ -102,6 +106,19 @@ public abstract class NativeWindowFactory {
protected NativeWindowFactory() {
}

private static final boolean guessBroadcomVCIV() {
return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
private final File vcliblocation = new File(
"/opt/vc/lib/libbcm_host.so");
public Boolean run() {
if ( vcliblocation.isFile() ) {
return new Boolean(true);
}
return new Boolean(false);
}
} ).booleanValue();
}

private static String _getNativeWindowingType() {
switch(Platform.OS_TYPE) {
case ANDROID:
Expand All @@ -118,6 +135,9 @@ private static String _getNativeWindowingType() {
case SUNOS:
case HPUX:
default:
if( guessBroadcomVCIV() ) {
return TYPE_BCM_VC_IV;
}
return TYPE_X11;
}
}
Expand Down

0 comments on commit 20a2a4f

Please sign in to comment.