changeset 5493:fece64961749

RT-28486 lens/prism shared porting layer reviewed: kselle, dblaukopf
author ddhill
date Tue, 22 Oct 2013 18:00:28 -0400
parents b6f0445dbd07
children c8cdab5d10df
files buildSrc/android.gradle buildSrc/armv6hf.gradle buildSrc/armv6sf.gradle buildSrc/x86egl.gradle modules/graphics/src/main/native-glass/lens/LensApplication.c modules/graphics/src/main/native-glass/lens/LensCommon.h modules/graphics/src/main/native-glass/lens/cursor/fbCursor/fbCursor.c modules/graphics/src/main/native-glass/lens/lensport/dispmanCursor.c modules/graphics/src/main/native-glass/lens/lensport/fbRobot.c modules/graphics/src/main/native-glass/lens/lensport/imx6Cursor.c modules/graphics/src/main/native-glass/lens/lensport/initPlatform.c modules/graphics/src/main/native-glass/lens/lensport/lensPort.h modules/graphics/src/main/native-glass/lens/lensport/lensPortInternal.h modules/graphics/src/main/native-glass/lens/lensport/lensPortLogger.h modules/graphics/src/main/native-glass/lens/lensport/omapCursor.c modules/graphics/src/main/native-glass/lens/lensport/wrapped_bcm.h modules/graphics/src/main/native-glass/lens/lensport/wrapped_functions.c modules/graphics/src/main/native-glass/lens/platform-util/dispmanCursor.c modules/graphics/src/main/native-glass/lens/platform-util/fbRobot.c modules/graphics/src/main/native-glass/lens/platform-util/imx6Cursor.c modules/graphics/src/main/native-glass/lens/platform-util/initPlatform.c modules/graphics/src/main/native-glass/lens/platform-util/omapCursor.c modules/graphics/src/main/native-glass/lens/platform-util/platformUtil.h modules/graphics/src/main/native-glass/lens/platform-util/utilInternal.h modules/graphics/src/main/native-glass/lens/platform-util/wrapped_bcm.c modules/graphics/src/main/native-glass/lens/platform-util/wrapped_bcm.h modules/graphics/src/main/native-glass/lens/wm/LensWindowManager.c modules/graphics/src/main/native-glass/lens/wm/screen/fbdevScreen.c modules/graphics/src/main/native-prism-es2/eglfb/EGLFBGLContext.c modules/graphics/src/main/native-prism-es2/eglfb/eglUtils.c modules/graphics/src/main/native-prism-es2/eglfb/wrapped_egl.c modules/graphics/src/main/native-prism-es2/eglfb/wrapped_egl.h
diffstat 32 files changed, 2444 insertions(+), 2289 deletions(-) [+]
line wrap: on
line diff
--- a/buildSrc/android.gradle	Tue Oct 22 14:31:11 2013 -0700
+++ b/buildSrc/android.gradle	Tue Oct 22 18:00:28 2013 -0400
@@ -452,7 +452,7 @@
     file("modules/graphics/src/main/native-glass/lens/cursor/nullCursor"),
     file("modules/graphics/src/main/native-glass/lens/input/android"),
     file("modules/graphics/src/main/native-glass/lens/wm/screen/androidScreen.c"),
-    file("modules/graphics/src/main/native-glass/lens/platform-util")]
+    file("modules/graphics/src/main/native-glass/lens/lensport")]
 ANDROID.glass.eglfb.compiler = compiler
 ANDROID.glass.eglfb.linker = linker
 ANDROID.glass.eglfb.lib = "glass_lens_eglfb"
--- a/buildSrc/armv6hf.gradle	Tue Oct 22 14:31:11 2013 -0700
+++ b/buildSrc/armv6hf.gradle	Tue Oct 22 18:00:28 2013 -0400
@@ -262,7 +262,7 @@
 
 ARMV6HF.glass.lensport = [:]
 ARMV6HF.glass.lensport.nativeSource = [
-    file("modules/graphics/src/main/native-glass/lens/platform-util") ]
+    file("modules/graphics/src/main/native-glass/lens/lensport") ]
 ARMV6HF.glass.lensport.compiler = compiler
 ARMV6HF.glass.lensport.ccFlags = ["-ffast-math", extraCFlags, "-DLINUX", "-DISEGLFB",
     "-DLENSPORT", "-I", file("modules/graphics/src/main/native-glass/lens/") ].flatten()
@@ -283,9 +283,7 @@
     file("modules/graphics/src/main/native-glass/lens/wm"),
     file("modules/graphics/src/main/native-glass/lens/cursor/fbCursor"),
     file("modules/graphics/src/main/native-glass/lens/input/udev"),
-    file("modules/graphics/src/main/native-glass/lens/wm/screen/fbdevScreen.c"),
-    file("modules/graphics/src/main/native-glass/lens/platform-util") ]
-    //file("modules/graphics/src/main/native-glass/lens/wm/screen")]
+    file("modules/graphics/src/main/native-glass/lens/wm/screen/fbdevScreen.c") ]
 ARMV6HF.glass.eglfb.compiler = compiler
 ARMV6HF.glass.eglfb.ccFlags = ["-ffast-math", extraCFlags, "-DLINUX", "-DISEGLFB"].flatten()
 ARMV6HF.glass.eglfb.linker = linker
@@ -298,9 +296,7 @@
     file("modules/graphics/src/main/native-glass/lens/wm"),
     file("modules/graphics/src/main/native-glass/lens/cursor/fbCursor"),
     file("modules/graphics/src/main/native-glass/lens/input/udev"),
-    file("modules/graphics/src/main/native-glass/lens/wm/screen/dfbScreen.c"),
-    file("modules/graphics/src/main/native-glass/lens/platform-util") ]
-    //file("modules/graphics/src/main/native-glass/lens/wm/screen")]
+    file("modules/graphics/src/main/native-glass/lens/wm/screen/dfbScreen.c") ]
 ARMV6HF.glass.directfb.compiler = compiler
 ARMV6HF.glass.directfb.ccFlags = ["-ffast-math", extraCFlags, "-I$sdk/usr/include/directfb", "-DLINUX"].flatten()
 ARMV6HF.glass.directfb.linker = linker
@@ -313,9 +309,7 @@
     file("modules/graphics/src/main/native-glass/lens/wm"),
     file("modules/graphics/src/main/native-glass/lens/cursor/fbCursor"),
     file("modules/graphics/src/main/native-glass/lens/input/udev"),
-    file("modules/graphics/src/main/native-glass/lens/wm/screen/fbdevScreen.c"),
-    file("modules/graphics/src/main/native-glass/lens/platform-util") ]
-    //file("modules/graphics/src/main/native-glass/lens/wm/screen")]
+    file("modules/graphics/src/main/native-glass/lens/wm/screen/fbdevScreen.c") ]
 ARMV6HF.glass.fb.compiler = compiler
 ARMV6HF.glass.fb.ccFlags = ["-ffast-math", extraCFlags, "-DLINUX"].flatten()
 ARMV6HF.glass.fb.linker = linker
@@ -391,7 +385,7 @@
     file("modules/graphics/src/main/native-prism-es2/eglfb")
 ]
 ARMV6HF.prismES2.eglfb.compiler = compiler
-ARMV6HF.prismES2.eglfb.ccFlags = es2EglfbCFlags
+ARMV6HF.prismES2.eglfb.ccFlags = [ es2EglfbCFlags, "-I", ARMV6HF.glass.lensport.nativeSource ].flatten()
 ARMV6HF.prismES2.eglfb.linker = linker
 ARMV6HF.prismES2.eglfb.linkFlags = es2EglfbLFlags
 ARMV6HF.prismES2.eglfb.lib = "prism_es2_eglfb"
--- a/buildSrc/armv6sf.gradle	Tue Oct 22 14:31:11 2013 -0700
+++ b/buildSrc/armv6sf.gradle	Tue Oct 22 18:00:28 2013 -0400
@@ -281,7 +281,7 @@
 
 ARMV6SF.glass.lensport = [:]
 ARMV6SF.glass.lensport.nativeSource = [
-    file("modules/graphics/src/main/native-glass/lens/platform-util") ]
+    file("modules/graphics/src/main/native-glass/lens/lensport") ]
 ARMV6SF.glass.lensport.compiler = compiler
 ARMV6SF.glass.lensport.ccFlags = ["-ffast-math", extraCFlags, "-DLINUX", "-DISEGLFB",
     "-DLENSPORT", "-I", file("modules/graphics/src/main/native-glass/lens/")].flatten()
@@ -302,7 +302,6 @@
     file("modules/graphics/src/main/native-glass/lens/wm"),
     file("modules/graphics/src/main/native-glass/lens/cursor/fbCursor"),
     file("modules/graphics/src/main/native-glass/lens/input/udev"),
-    file("modules/graphics/src/main/native-glass/lens/platform-util"),
     file("modules/graphics/src/main/native-glass/lens/wm/screen/fbdevScreen.c")]
 ARMV6SF.glass.eglfb.compiler = compiler
 ARMV6SF.glass.eglfb.ccFlags = ["-ffast-math", extraCFlags, "-DLINUX", "-DISEGLFB"].flatten()
@@ -316,7 +315,6 @@
     file("modules/graphics/src/main/native-glass/lens/wm"),
     file("modules/graphics/src/main/native-glass/lens/cursor/fbCursor"),
     file("modules/graphics/src/main/native-glass/lens/input/udev"),
-    file("modules/graphics/src/main/native-glass/lens/platform-util"),
     file("modules/graphics/src/main/native-glass/lens/wm/screen/dfbScreen.c")]
 ARMV6SF.glass.directfb.compiler = compiler
 ARMV6SF.glass.directfb.ccFlags = ["-ffast-math", extraCFlags, "-I$sdk/usr/include/directfb", "-DLINUX"].flatten()
@@ -330,8 +328,7 @@
     file("modules/graphics/src/main/native-glass/lens/wm"),
     file("modules/graphics/src/main/native-glass/lens/cursor/fbCursor"),
     file("modules/graphics/src/main/native-glass/lens/input/udev"),
-    file("modules/graphics/src/main/native-glass/lens/wm/screen/fbdevScreen.c"),
-    file("modules/graphics/src/main/native-glass/lens/platform-util") ]
+    file("modules/graphics/src/main/native-glass/lens/wm/screen/fbdevScreen.c") ]
 ARMV6SF.glass.fb.compiler = compiler
 ARMV6SF.glass.fb.ccFlags = ["-ffast-math", extraCFlags, "-DLINUX"].flatten()
 ARMV6SF.glass.fb.linker = linker
@@ -371,9 +368,9 @@
 ARMV6SF.prism.javahInclude = ["com/sun/prism/impl/**/*", "com/sun/prism/PresentableState*"]
 ARMV6SF.prism.nativeSource = file("modules/graphics/src/main/native-prism")
 ARMV6SF.prism.compiler = compiler
-ARMV6SF.prism.ccFlags = es2CFlags // or es2EglfbCFlags? or es2X11CFlags?
+ARMV6SF.prism.ccFlags = es2CFlags
 ARMV6SF.prism.linker = linker
-ARMV6SF.prism.linkFlags = es2LFlags // or es2EglfbLFlags or es2X11LFlags?
+ARMV6SF.prism.linkFlags = es2LFlags 
 ARMV6SF.prism.lib = "prism_common"
 
 ARMV6SF.prismSW = [:]
@@ -407,7 +404,7 @@
     file("modules/graphics/src/main/native-prism-es2/eglfb")
 ]
 ARMV6SF.prismES2.eglfb.compiler = compiler
-ARMV6SF.prismES2.eglfb.ccFlags = es2EglfbCFlags
+ARMV6SF.prismES2.eglfb.ccFlags = [ es2EglfbCFlags, "-I", ARMV6SF.glass.lensport.nativeSource ].flatten()
 ARMV6SF.prismES2.eglfb.linker = linker
 ARMV6SF.prismES2.eglfb.linkFlags = es2EglfbLFlags
 ARMV6SF.prismES2.eglfb.lib = "prism_es2_eglfb"
--- a/buildSrc/x86egl.gradle	Tue Oct 22 14:31:11 2013 -0700
+++ b/buildSrc/x86egl.gradle	Tue Oct 22 18:00:28 2013 -0400
@@ -221,7 +221,7 @@
 
 X86EGL.glass.lensport = [:]
 X86EGL.glass.lensport.nativeSource = [
-    file("modules/graphics/src/main/native-glass/lens/platform-util") ]
+    file("modules/graphics/src/main/native-glass/lens/lensport") ]
 X86EGL.glass.lensport.compiler = compiler
 X86EGL.glass.lensport.ccFlags = ["-ffast-math", extraCFlags, "-DLINUX", "-DISEGLFB",
     "-DLENSPORT", "-I", file("modules/graphics/src/main/native-glass/lens/") ].flatten()
@@ -242,7 +242,7 @@
     file("modules/graphics/src/main/native-glass/lens/cursor/fbCursor"),
     file("modules/graphics/src/main/native-glass/lens/input/udev"),
     file("modules/graphics/src/main/native-glass/lens/wm/screen/x11ContainerScreen.c"),
-    file("modules/graphics/src/main/native-glass/lens/platform-util") ]
+    file("modules/graphics/src/main/native-glass/lens/lensport") ]
     //file("modules/graphics/src/main/native-glass/lens/wm/screen")]
 X86EGL.glass.eglfb.compiler = compiler
 X86EGL.glass.eglfb.ccFlags = ["-ffast-math", extraCFlags, "-DLINUX"].flatten()
@@ -257,7 +257,7 @@
     file("modules/graphics/src/main/native-glass/lens/cursor/fbCursor"),
     file("modules/graphics/src/main/native-glass/lens/input/udev"),
     file("modules/graphics/src/main/native-glass/lens/wm/screen/dfbScreen.c"),
-    file("modules/graphics/src/main/native-glass/lens/platform-util") ]
+    file("modules/graphics/src/main/native-glass/lens/lensport") ]
     //file("modules/graphics/src/main/native-glass/lens/wm/screen")]
 X86EGL.glass.directfb.compiler = compiler
 X86EGL.glass.directfb.ccFlags = ["-ffast-math", extraCFlags, "-I/usr/include/directfb", "-DLINUX"].flatten()
@@ -272,7 +272,7 @@
     file("modules/graphics/src/main/native-glass/lens/cursor/fbCursor"),
     file("modules/graphics/src/main/native-glass/lens/input/udev"),
     file("modules/graphics/src/main/native-glass/lens/wm/screen/fbdevScreen.c"),
-    file("modules/graphics/src/main/native-glass/lens/platform-util") ]
+    file("modules/graphics/src/main/native-glass/lens/lensport") ]
     //file("modules/graphics/src/main/native-glass/lens/wm/screen")]
 X86EGL.glass.fb.compiler = compiler
 X86EGL.glass.fb.ccFlags = ["-ffast-math", extraCFlags, "-DLINUX"].flatten()
--- a/modules/graphics/src/main/native-glass/lens/LensApplication.c	Tue Oct 22 14:31:11 2013 -0700
+++ b/modules/graphics/src/main/native-glass/lens/LensApplication.c	Tue Oct 22 18:00:28 2013 -0400
@@ -22,7 +22,7 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
- 
+
 #include "LensCommon.h"
 #include "wm/LensWindowManager.h"
 #include "com_sun_glass_ui_lens_LensApplication.h"
@@ -31,8 +31,14 @@
 #include "com_sun_glass_events_KeyEvent.h"
 #include "com_sun_glass_events_WindowEvent.h"
 
+#if ! ((defined(ANDROID_NDK) || defined(EGL_X11_FB_CONTAINER)))
+#ifndef __USE_GNU // required for dladdr() & Dl_info
+#define __USE_GNU
+#endif
+#include <dlfcn.h>
 #include <signal.h>
-
+#endif
+ 
 //********************************************************
 
 // JNI handles ******************************************
@@ -76,6 +82,8 @@
 static JavaVM *pGlassVm;
 static int trapCtrlC = 0;
 
+LensNativePort lensPort;
+
 jint JNI_OnLoad(JavaVM *vm, void *reserved) {
     JNIEnv *env;
     char *javafxDebug;
@@ -188,6 +196,47 @@
     initIDs(env);
 }
 
+static void load_porting_library() {
+#if ! ((defined(ANDROID_NDK) || defined(EGL_X11_FB_CONTAINER)))
+
+    jboolean (*lens_platform_init)(LensNativePort*) = 0;
+
+    Dl_info dlinfo;
+    if (dladdr(&lens_wm_initialize, &dlinfo)) {
+
+        size_t rslash = (size_t)rindex(dlinfo.dli_fname,'/');
+        if (rslash) {
+            char *b = (char *) alloca(strlen(dlinfo.dli_fname)+20);
+            rslash = rslash + 1 - (size_t)dlinfo.dli_fname;
+            strncpy(b, dlinfo.dli_fname,rslash);
+            strcpy(b + rslash, "liblens_porting.so");
+
+            void *dlhand = dlopen(b,RTLD_NOW); 
+            if (dlhand) {
+                lens_platform_init = dlsym(dlhand, "lens_platform_initialize");
+                if (!lens_platform_init) {
+                    fprintf(stderr,"lens_platform_initialize missing in liblens_porting.so\n");
+                    exit(-1);
+                }
+            } else {
+                fprintf(stderr,"LENS FAILED TO OPEN %s\n",b);
+                fprintf(stderr,"dlopen reports %s\n",dlerror());
+                exit(-1);
+            }
+        }
+    } else {
+        fprintf(stderr,"Did not get DLINFO\n");
+        exit(-1);
+    }
+
+    lensPort.version = NATIVE_LENS_PORT_VERSION;
+    (*lens_platform_init)(&lensPort);
+
+    // set the current logging information
+    lensPort.setLogger(&glass_logf, glass_log_level);
+#endif
+}
+
 /*
  * Class:     com_sun_glass_ui_lens_LensApplication
  * Method:    _initialize
@@ -196,6 +245,8 @@
 JNIEXPORT jboolean JNICALL Java_com_sun_glass_ui_lens_LensApplication__1initialize
 (JNIEnv *env, jclass jApplicationClass) {
 
+    load_porting_library();
+
     return lens_wm_initialize(env);
 }
 
--- a/modules/graphics/src/main/native-glass/lens/LensCommon.h	Tue Oct 22 14:31:11 2013 -0700
+++ b/modules/graphics/src/main/native-glass/lens/LensCommon.h	Tue Oct 22 18:00:28 2013 -0400
@@ -29,8 +29,8 @@
 #ifdef ANDROID_NDK
 #include <stdio.h>
 #endif
-#include "stdlib.h"
-#include "string.h"
+#include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
 
 #include <jni.h>
@@ -1524,4 +1524,7 @@
 
 #include "LensLogger.h"
 
+#include "lensport/lensPort.h"
+extern LensNativePort lensPort;
+
 #endif // LENS_COMMON_H
--- a/modules/graphics/src/main/native-glass/lens/cursor/fbCursor/fbCursor.c	Tue Oct 22 14:31:11 2013 -0700
+++ b/modules/graphics/src/main/native-glass/lens/cursor/fbCursor/fbCursor.c	Tue Oct 22 18:00:28 2013 -0400
@@ -27,6 +27,7 @@
 
 #if defined(OMAP3) || defined(IMX6_PLATFORM)
 
+#include <assert.h>
 #include <fcntl.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -34,76 +35,54 @@
 #include <linux/omapfb.h>
 #include <sys/ioctl.h>
 
-#include "platform-util/platformUtil.h"
-
 static void fbCreateCursor(jbyte *cursorImage, int width, int height, int bpp) {
-    if (fbPlatformCreateCursor) {
-        (*fbPlatformCreateCursor)(cursorImage, width, height, bpp);
-    } 
-    else {fprintf(stderr, "missing native fbPlatformCreateCursor"); }
+    assert (lensPort.createCursor);
+    (*lensPort.createCursor)(cursorImage, width, height, bpp);
 }
 
 void fbCursorInitialize(int screenWidth, int screenHeight) {
-    if (fbPlatformCursorInitialize) {
-        (*fbPlatformCursorInitialize)(screenWidth, screenHeight);
-    }
-    else {fprintf(stderr, "missing native fbPlatformCursorInitialize"); }
+    assert (lensPort.cursorInitialize);
+    (*lensPort.cursorInitialize)(screenWidth, screenHeight);
 }
 
 void fbCursorSetPosition(int x, int y) {
-
-    if (fbPlatformCursorSetPosition) {
-        return (*fbPlatformCursorSetPosition)(x, y);
-    }
-    else {fprintf(stderr, "missing native fbPlatformCursorSetPosition"); }
+    assert (lensPort.cursorSetPosition);
+    return (*lensPort.cursorSetPosition)(x, y);
 }
 
 
 void fbCursorClose() {
-    if (fbPlatformCursorClose) {
-        (*fbPlatformCursorClose)();
-    }
-    else {fprintf(stderr, "missing native fbPlatformCursorClose"); }
+    assert (lensPort.cursorClose);
+    (*lensPort.cursorClose)();
 }
 
 void glass_cursor_setVisible(jboolean isVisible) {
-    if (fbPlatformSetVisible) {
-        (*fbPlatformSetVisible)(isVisible);
-    }
-    else {fprintf(stderr, "missing native fbPlatformSetVisible"); }
+    assert (lensPort.setVisible);
+    (*lensPort.setVisible)(isVisible);
 }
 
 void glass_cursor_setNativeCursor(jlong nativeCursorPointer) {
-    if (fbPlatformSetNativeCursor) {
-        (*fbPlatformSetNativeCursor)(nativeCursorPointer);
-    }
-    else {fprintf(stderr, "missing native fbPlatformSetNativeCursor"); }
+    assert (lensPort.setNativeCursor);
+    (*lensPort.setNativeCursor)(nativeCursorPointer);
 }
 
 void glass_cursor_releaseNativeCursor(jlong nativeCursorPointer) {
-    if (fbPlatformReleaseNativeCursor) {
-         (*fbPlatformReleaseNativeCursor)(nativeCursorPointer);
-    }
-    else {fprintf(stderr, "missing native fbPlatformReleaseNativeCursor"); }
+    assert (lensPort.releaseNativeCursor);
+    (*lensPort.releaseNativeCursor)(nativeCursorPointer);
 }
 
 
 jlong glass_cursor_createNativeCursor(JNIEnv *env, jint x, jint y, jbyte *srcArray, jint width, jint height) {
-    if (fbPlatformCreateNativeCursor) {
-        return (*fbPlatformCreateNativeCursor)(env, x, y, srcArray, width, height);
-    } else {
-       fprintf(stderr, "missing native fbPlatformCreateNativeCursor"); 
-        return 0;
-    } 
+    assert (lensPort.createNativeCursor);
+    return (*lensPort.createNativeCursor)(env, x, y, srcArray, width, height);
 }
 
 
 jboolean glass_cursor_supportsTranslucency() {
-    return fbPlatformCursorTranslucency;
+    return lensPort.cursorTranslucency;
 }
 
 
-
 void glass_cursor_terminate(void) {
     fbCursorClose();
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/graphics/src/main/native-glass/lens/lensport/dispmanCursor.c	Tue Oct 22 18:00:28 2013 -0400
@@ -0,0 +1,520 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+ 
+#include <stdio.h>
+#include <pthread.h>
+#include <semaphore.h>
+#include <unistd.h>
+#include <jni.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <linux/fb.h>
+#include <sys/ioctl.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "lensPort.h"
+#include "lensPortInternal.h"
+#include "lensPortLogger.h"
+
+#ifdef USE_DISPMAN
+#include "wrapped_bcm.h"
+
+#define FB_DEVICE "/dev/fb0"
+
+typedef struct {
+    DISPMANX_ELEMENT_HANDLE_T element;
+    int screenWidth, screenHeight;
+    pthread_t thread;
+    pthread_mutex_t mutex;
+    sem_t semaphore;
+    int x, y;
+    int cursorWidth, cursorHeight;
+    jlong currentCursor;
+    jboolean isVisible;
+} DispManCursor;
+
+
+typedef struct {
+    jint width;
+    jint height;
+    jint x;
+    jint y;
+    DISPMANX_RESOURCE_HANDLE_T resource;
+} DispmanCursorImage;
+
+
+static DispManCursor cursor;
+
+static void *fbCursorUpdater(void *data);
+static void fbDispmanAddDispmanxElement(void);
+static void fbDispmanRemoveDispmanxElement(void);
+
+
+static void fbDispmanSetNativeCursor(jlong nativeCursorHandle) {
+
+    DISPMANX_UPDATE_HANDLE_T update;
+    DispmanCursorImage *cursorImage = (DispmanCursorImage *)jlong_to_ptr(nativeCursorHandle);
+
+    if (cursorImage != NULL && cursor.element != 0) {
+
+        if (cursorImage->width != cursor.cursorWidth ||
+                cursorImage->height != cursor.cursorHeight) {
+
+            fbDispmanRemoveDispmanxElement();
+
+            cursor.cursorWidth = cursorImage->width;
+            cursor.cursorHeight = cursorImage->height;
+
+            fbDispmanAddDispmanxElement();
+        }
+        cursor.currentCursor = nativeCursorHandle;
+
+        if (cursor.isVisible) {
+            update = vc_dispmanx_update_start(0);
+            vc_dispmanx_element_change_source(update, cursor.element, cursorImage->resource);
+            vc_dispmanx_update_submit_sync(update);
+        }
+
+    }
+}
+
+
+static void fbDispmanAddDispmanxElement(void) {
+
+    DISPMANX_DISPLAY_HANDLE_T display = 0;
+    DISPMANX_UPDATE_HANDLE_T update;
+    VC_DISPMANX_ALPHA_T alpha;
+    VC_RECT_T dst;
+    VC_RECT_T src = { 0, 0, cursor.cursorWidth << 16, cursor.cursorHeight << 16};
+    VC_RECT_T pixelRect = { 0, 0, cursor.cursorWidth, cursor.cursorHeight };
+    int rc;
+
+    display = vc_dispmanx_display_open(0 /* LCD */);
+    if (display == 0) {
+        GLASS_LOG_SEVERE("Cannot open display");
+        return;
+    }
+
+    update = vc_dispmanx_update_start(0);
+    alpha.flags = DISPMANX_FLAGS_ALPHA_FROM_SOURCE;
+    alpha.opacity = 0xff;
+    alpha.mask = (DISPMANX_RESOURCE_HANDLE_T) 0;
+    dst.x = cursor.x;
+    dst.y = cursor.y;
+    dst.width = cursor.cursorWidth;
+    dst.height = cursor.cursorHeight;
+    cursor.element = vc_dispmanx_element_add(
+                         update,
+                         display,
+                         2 /*layer*/,
+                         &dst,
+                         0 /*resource*/,
+                         &src,
+                         DISPMANX_PROTECTION_NONE,
+                         &alpha,
+                         0 /*clamp*/,
+                         0 /*transform*/);
+
+    vc_dispmanx_update_submit_sync(update);
+
+}
+
+
+static void fbDispmanRemoveDispmanxElement(void) {
+
+    if (cursor.element) {
+        DISPMANX_UPDATE_HANDLE_T update;
+        update = vc_dispmanx_update_start(0);
+        vc_dispmanx_element_remove(update, cursor.element);
+        vc_dispmanx_update_submit_sync(update);
+
+        cursor.element = 0;
+    }
+}
+
+static void fbDispmanCursorInitialize(int screenWidth, int screenHeight) {
+
+    // Init cursor fields
+    cursor.element = 0;
+    cursor.cursorWidth = 16;
+    cursor.cursorHeight = 16;
+    cursor.x = 0;
+    cursor.y = 0;
+    cursor.currentCursor = 0;
+    cursor.isVisible = 0;
+
+    cursor.screenWidth = screenWidth;
+    cursor.screenHeight = screenHeight;
+
+    fbDispmanAddDispmanxElement();
+
+    sem_init(&cursor.semaphore, 0, 0);
+    pthread_mutex_init(&cursor.mutex, NULL);
+    pthread_create(&cursor.thread, NULL, fbCursorUpdater, NULL);
+
+}
+
+
+static jlong fbDispmanCreateNativeCursor(JNIEnv *env, jint x, jint y,  jbyte *srcArray, jint width, jint height) {
+
+    VC_RECT_T pixelRect;
+    int rc;
+    uint32_t imagePtr;
+    jbyte *allocatedBuffer = NULL;
+    DispmanCursorImage *cursorImage = (DispmanCursorImage *)malloc(sizeof(DispmanCursorImage));
+
+    //Width should be aligned to 16 pixels
+    if (width % 16 != 0) {
+        int newWidth = width + 16 - (width % 16);
+        allocatedBuffer = (jbyte *)malloc(newWidth * height * 4);
+        int i;
+        int offset = 0;
+        for (i = 0; i < height; ++i) {
+            memcpy(allocatedBuffer + offset, srcArray, width * 4);
+            memset(allocatedBuffer + offset + (width * 4), 0, (newWidth - width) * 4);
+            offset += newWidth * 4;
+            srcArray += width * 4;
+        }
+
+        width = newWidth;
+        srcArray = allocatedBuffer;
+    }
+
+    pixelRect.x = 0;
+    pixelRect.y = 0;
+    pixelRect.width = width;
+    pixelRect.height = height;
+
+    cursorImage->x = x;
+    cursorImage->y = y;
+    cursorImage->width = width;
+    cursorImage->height = height;
+    cursorImage->resource = vc_dispmanx_resource_create(VC_IMAGE_ARGB8888,
+                            width,
+                            height,
+                            &imagePtr);
+    if (cursorImage->resource == 0) {
+        GLASS_LOG_SEVERE("Cannot create resource");
+        if (allocatedBuffer != NULL) {
+            free(allocatedBuffer);
+            allocatedBuffer = NULL;
+        }
+        free(cursorImage);
+        return 0;
+    }
+
+    rc = vc_dispmanx_resource_write_data(cursorImage->resource,
+                                         VC_IMAGE_ARGB8888,
+                                         width * 4,
+                                         srcArray,
+                                         &pixelRect);
+
+    if (allocatedBuffer != NULL) {
+        free(allocatedBuffer);
+        allocatedBuffer = NULL;
+    }
+
+    if (rc != 0) {
+        GLASS_LOG_SEVERE("Cannot write pixels");
+        free(cursorImage);
+        return 0;
+    }
+
+    return ptr_to_jlong(cursorImage);
+}
+
+
+
+
+static void fbDispmanReleaseNativeCursor(jlong nativeCursorHandle) {
+
+    DispmanCursorImage *cursorImage = (DispmanCursorImage *)jlong_to_ptr(nativeCursorHandle);
+
+    if (cursorImage != NULL && cursorImage->resource != 0) {
+        if (cursor.currentCursor == nativeCursorHandle && cursor.isVisible) {
+            DISPMANX_UPDATE_HANDLE_T update;
+            update = vc_dispmanx_update_start(0);
+            vc_dispmanx_element_change_source(update, 
+                                              cursor.element, 0 /* resource*/);
+            vc_dispmanx_update_submit_sync(update);
+        }
+        vc_dispmanx_resource_delete(cursorImage->resource);
+    }
+
+    free(cursorImage);
+    if (cursor.currentCursor == nativeCursorHandle) {
+        cursor.currentCursor = 0;
+    }
+}
+
+
+static void fbDispmanSetVisible(jboolean isVisible) {
+
+    if (isVisible) {
+        if (!cursor.isVisible && cursor.currentCursor != 0) {
+            fbDispmanSetNativeCursor(cursor.currentCursor);
+            DispmanCursorImage *cursorImage = 
+                (DispmanCursorImage *)jlong_to_ptr(cursor.currentCursor);
+            DISPMANX_UPDATE_HANDLE_T update = vc_dispmanx_update_start(0);
+            vc_dispmanx_element_change_source(update, cursor.element, 
+                                              cursorImage->resource);
+            vc_dispmanx_update_submit_sync(update);
+        }
+    } else {
+        DISPMANX_UPDATE_HANDLE_T update;
+        update = vc_dispmanx_update_start(0);
+        vc_dispmanx_element_change_source(update, cursor.element, 0 );
+        vc_dispmanx_update_submit_sync(update);
+    }
+    cursor.isVisible = isVisible;
+}
+
+
+
+static void *fbCursorUpdater(void *data) {
+    while (1) {
+        DISPMANX_UPDATE_HANDLE_T update;
+        VC_RECT_T dst;
+        sem_wait(&cursor.semaphore);
+        pthread_mutex_lock(&cursor.mutex);
+        dst.x = cursor.x;
+        dst.y = cursor.y;
+        dst.width = cursor.cursorWidth;
+        dst.height = cursor.cursorHeight;
+        pthread_mutex_unlock(&cursor.mutex);
+        update = vc_dispmanx_update_start(0);
+        vc_dispmanx_element_change_attributes(update,
+                                              cursor.element,
+                                              0x4 ,
+                                              0 , 0, 
+                                              &dst,
+                                              0 ,
+                                              0 , 0 );
+        vc_dispmanx_update_submit_sync(update);
+        usleep(16666); /* sleep a sixtieth of a second before moving again */
+    }
+    return NULL;
+}
+
+static void fbDispmanCursorSetPosition(int x, int y) {
+
+    if (cursor.element) {
+        int posted;
+        pthread_mutex_lock(&cursor.mutex);
+        cursor.x = x;
+        cursor.y = y;
+        sem_getvalue(&cursor.semaphore, &posted);
+        pthread_mutex_unlock(&cursor.mutex);
+        if (posted == 0) {
+            sem_post(&cursor.semaphore);
+        }
+    } else {
+        cursor.x = x;
+        cursor.y = y;
+    }
+}
+
+static void _fbDispmanCursorClose() {
+
+    fbDispmanRemoveDispmanxElement();
+    cursor.isVisible = 0;
+}
+
+static jboolean fbDispmanRobotScreenCapture(jint x, jint y,
+                                            jint width, jint height,
+                                            jint *pixels) {
+    FILE *fb;
+    unsigned int *pixelBuffer = NULL;
+    unsigned char *pixelBufferPtr = NULL;
+    unsigned char *dst = (unsigned char *) pixels;
+    int i = 0;
+    int fbFileHandle;
+    struct fb_var_screeninfo screenInfo;
+    unsigned int dstByteStride = width * 4;
+    VC_IMAGE_TRANSFORM_T transform = 0;
+    DISPMANX_RESOURCE_HANDLE_T resource = 0;
+    DISPMANX_DISPLAY_HANDLE_T display = 0;
+    DISPMANX_RESOURCE_HANDLE_T screenResource = 0;
+    uint32_t imagePtr;
+    int rc;
+
+    GLASS_LOG_FINE("Capture %i,%i+%ix%i", x, y, width, height);
+
+    if (width < 1 || height < 1) {
+        GLASS_LOG_SEVERE("Failed. width/height values must be at least = 1");
+        return JNI_FALSE;
+    }
+
+    GLASS_LOG_FINE("open(%s, O_RDONLY)", FB_DEVICE);
+    fbFileHandle = open(FB_DEVICE, O_RDONLY);
+    if (fbFileHandle < 0) {
+        GLASS_LOG_SEVERE("Cannot open framebuffer");
+        return JNI_FALSE;
+    }
+
+    GLASS_LOG_FINE("ioctl(%s, FBIOGET_VSCREENINFO)", FB_DEVICE);
+    if (ioctl(fbFileHandle, FBIOGET_VSCREENINFO, &screenInfo)) {
+        GLASS_LOG_SEVERE("Cannot get screen info");
+        GLASS_LOG_FINE("close(%s)", FB_DEVICE);
+        close(fbFileHandle);
+        return JNI_FALSE;
+    }
+    GLASS_LOG_FINE("Read screen info: res=%ix%i, offset=%ix%i",
+                   screenInfo.xres, screenInfo.yres,
+                   screenInfo.xoffset, screenInfo.yoffset);
+    GLASS_LOG_FINE("close(%s)", FB_DEVICE);
+    close(fbFileHandle);
+
+    VC_RECT_T pixelRect = { 0, 0, screenInfo.xres, screenInfo.yres };
+
+    int pixelBufferLength = screenInfo.xres * screenInfo.yres * 4;
+    pixelBuffer = (unsigned int *) malloc(pixelBufferLength);
+    pixelBufferPtr = (unsigned char *) pixelBuffer;
+
+    if (pixelBuffer == NULL) {
+        printf("Failed to allocate temporary pixel buffer\n");
+        return JNI_FALSE;
+    }
+
+    GLASS_LOG_FINE("fopen(%s, \"r\") to read %ix%i pixels at bit depth %i\n",
+                   FB_DEVICE, width, height, screenInfo.bits_per_pixel);
+
+    display = vc_dispmanx_display_open(0 /* LCD */);
+    if (display == 0) {
+        fprintf(stderr, "fbRobotScreenCapture: Dispman: Cannot open display\n");
+        free(pixelBuffer);
+        return JNI_FALSE;
+    }
+
+    // create the resource for the snapshot
+    screenResource = vc_dispmanx_resource_create(VC_IMAGE_ARGB8888, screenInfo.xres, screenInfo.yres, &imagePtr);
+    if (!screenResource) {
+        fprintf(stderr, "fbRobotScreenCapture: Cannot create resource\n");
+        vc_dispmanx_display_close(display);
+        free(pixelBuffer);
+        return JNI_FALSE;
+    }
+
+    rc = vc_dispmanx_snapshot(display, screenResource, transform);
+    rc = 0;
+    if (rc) {
+        fprintf(stderr, "fbRobotScreenCapture: snapshot failed\n");
+        vc_dispmanx_display_close(display);
+        free(pixelBuffer);
+        return JNI_FALSE;
+    }
+
+    rc = vc_dispmanx_resource_read_data(screenResource, &pixelRect, pixelBuffer, screenInfo.xres * 4);
+
+    if (rc) {
+        fprintf(stderr, "fbRobotScreenCapture: Cannot read pixels %d\n", rc);
+        vc_dispmanx_display_close(display);
+        free(pixelBuffer);
+        return JNI_FALSE;
+    }
+
+    rc = vc_dispmanx_resource_delete(screenResource);
+    if (rc) {
+        fprintf(stderr, "fbRobotScreenCapture: failed to free buffer %d\n", rc);
+        vc_dispmanx_display_close(display);
+        free(pixelBuffer);
+        return JNI_FALSE;
+    }
+    screenResource = 0;
+
+    if (x < 0) {
+        pixelBuffer += -x;
+        width += x;
+        x = 0;
+    }
+    if (y < 0) {
+        pixelBuffer += -y * (int)screenInfo.xres;
+        height += y;
+        y = 0;
+    }
+
+    int widthLimit = width;
+    int heightLimit = height;
+
+    // Required height is larger than screen's height
+    if ((int) screenInfo.yres < height) {
+        heightLimit = (int) screenInfo.yres;
+    }
+    // Required width is larger than screen's width
+    if ((int) screenInfo.xres < width) {
+        widthLimit = (int) screenInfo.xres;
+    }
+    // Required height is out of range
+    if (((int) screenInfo.yres - y) < height) {
+        heightLimit = (int) screenInfo.yres - y;
+    }
+    // Required width is out of range
+    if (((int) screenInfo.xres - x) < width) {
+        widthLimit = (int) screenInfo.xres - x;
+    }
+
+    if (widthLimit > 0 && heightLimit > 0) {
+        // copy the relevant portion of the screen to the supplied pixel array
+        int offset = y * screenInfo.xres * 4 + x * 4;
+        for (i = 0; i < heightLimit; i++) {
+            memcpy(dst + i * dstByteStride, pixelBufferPtr + offset, widthLimit * 4);
+            offset += screenInfo.xres * 4;
+        }
+    } else {
+        GLASS_LOG_SEVERE("Failed to take a snapshot, some of parameters are illegal");
+        free(pixelBuffer);
+        return JNI_FALSE;
+    }
+
+    vc_dispmanx_display_close(display);
+    free(pixelBuffer);
+    return JNI_TRUE;
+}
+
+static char * platformName = "dispman";
+extern int load_bcm_symbols();
+
+jboolean select_dispman_cursor(LensNativePort *lensPort) {
+    if (!load_bcm_symbols()) {
+        return JNI_FALSE;
+    }
+
+    lensPort->platformName = platformName;
+    lensPort->setNativeCursor = fbDispmanSetNativeCursor;
+    lensPort->cursorInitialize = fbDispmanCursorInitialize;
+    lensPort->cursorSetPosition = fbDispmanCursorSetPosition;
+    lensPort->cursorClose = _fbDispmanCursorClose;
+    lensPort->createNativeCursor = fbDispmanCreateNativeCursor;
+    lensPort->releaseNativeCursor = fbDispmanReleaseNativeCursor;
+    lensPort->setVisible = fbDispmanSetVisible;
+    lensPort->robotScreenCapture = fbDispmanRobotScreenCapture;
+    lensPort->cursorTranslucency = JNI_TRUE;
+
+    return JNI_TRUE;
+}
+
+#endif //USE_DISPMAN
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/graphics/src/main/native-glass/lens/lensport/fbRobot.c	Tue Oct 22 18:00:28 2013 -0400
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <linux/fb.h>
+
+#include "lensPort.h"
+#include "lensPortInternal.h"
+#include "lensPortLogger.h"
+
+#if defined(OMAP3) || defined(IMX6_PLATFORM) 
+# ifndef USE_FB_ROBOT
+    #define USE_FB_ROBOT
+# endif
+#endif
+
+#ifdef OMAP3 
+#include <linux/omapfb.h>
+#endif
+
+#ifdef USE_FB_ROBOT
+
+jboolean fbFBRobotScreen(jint x, jint y,
+                                    jint width, jint height,
+                                    jint *pixels) {
+
+    FILE *fb;
+    unsigned char *pixelBuffer = NULL;
+    unsigned char *dst = (unsigned char *) pixels;
+    unsigned int dstByteStride = width * 4;
+    int i = 0;
+    int fbFileHandle;
+    struct fb_var_screeninfo screenInfo;
+    int depth; // pixel size in bytes
+
+    GLASS_LOG_FINE("Capture %i,%i+%ix%i", x, y, width, height);
+    jboolean result = JNI_FALSE;
+
+    if (width < 1 || height < 1) {
+        GLASS_LOG_SEVERE("Failed. width/height values must be at least = 1");
+        return JNI_FALSE;
+    }
+
+    GLASS_LOG_FINE("open(%s, O_RDONLY)", FB_DEVICE);
+    fbFileHandle = open(FB_DEVICE, O_RDONLY);
+    if (fbFileHandle < 0) {
+        GLASS_LOG_SEVERE("Cannot open framebuffer");
+        return JNI_FALSE;
+    }
+    GLASS_LOG_FINE("ioctl(%s, FBIOGET_VSCREENINFO)", FB_DEVICE);
+    if (ioctl(fbFileHandle, FBIOGET_VSCREENINFO, &screenInfo)) {
+        GLASS_LOG_SEVERE("Cannot get screen info");
+        return JNI_FALSE;
+    }
+    GLASS_LOG_FINE("Read screen info: res=%ix%i, offset=%ix%i",
+                   screenInfo.xres, screenInfo.yres,
+                   screenInfo.xoffset, screenInfo.yoffset);
+    GLASS_LOG_FINE("close(%s)", FB_DEVICE);
+    close(fbFileHandle);
+    depth = screenInfo.bits_per_pixel / 8;
+    int pixelBufferLength = screenInfo.xres * screenInfo.yres * depth;
+    pixelBuffer = (unsigned char *) malloc(pixelBufferLength);
+    if (pixelBuffer == NULL) {
+        GLASS_LOG_SEVERE("Failed to allocate temporary pixel buffer");
+        return JNI_FALSE;
+    }
+
+    GLASS_LOG_FINE("fopen(%s, \"r\") to read %ix%i pixels at bit depth %i",
+                   FB_DEVICE, width, height, screenInfo.bits_per_pixel);
+    fb = fopen(FB_DEVICE, "r");
+    if (fb == NULL) {
+        GLASS_LOG_SEVERE("FB: Cannot open framebuffer for reading");
+        free(pixelBuffer);
+        return JNI_FALSE;
+    }
+
+    fseek(fb, screenInfo.yoffset * screenInfo.xres * depth, SEEK_SET);
+    int numRead = fread(pixelBuffer, 1,
+                        pixelBufferLength,
+                        fb);
+
+    if (x < 0) {
+        dst += -x * 4;
+        width += x;
+        x = 0;
+    }
+    if (y < 0) {
+        dst += -y * dstByteStride;
+        height += y;
+        y = 0;
+    }
+
+    int widthLimit = width;
+    int heightLimit = height;
+
+    // Required height is larger than screen's height
+    if ((int) screenInfo.yres < height) {
+        heightLimit = (int) screenInfo.yres;
+    }
+    // Required width is larger than screen's width
+    if ((int) screenInfo.xres < width) {
+        widthLimit = (int) screenInfo.xres;
+    }
+    // Required height is out of range
+    if (((int) screenInfo.yres - y) < height) {
+        heightLimit = (int) screenInfo.yres - y;
+    }
+    // Required width is out of range
+    if (((int) screenInfo.xres - x) < width) {
+        widthLimit = (int) screenInfo.xres - x;
+    }
+
+    if (widthLimit > 0 && heightLimit > 0) {
+        // copy the relevant portion of the screen to the supplied pixel array
+        int offset = y * screenInfo.xres * depth + x * depth;
+        for (i = 0; i < heightLimit; i++) {
+            memcpy(dst + i * dstByteStride, pixelBuffer + offset, widthLimit * depth);
+            offset += screenInfo.xres * depth;
+        }
+    } else {
+        free(pixelBuffer);
+        fclose(fb);
+        GLASS_LOG_FINE("fclose(%s)", FB_DEVICE);
+        GLASS_LOG_SEVERE("Failed to take a snapshot, some of parameters are illegal");
+        return JNI_FALSE;
+    }
+
+    free(pixelBuffer);
+    GLASS_LOG_FINE("fclose(%s)", FB_DEVICE);
+    fclose(fb);
+    return JNI_TRUE;
+}
+
+#endif // USE_FB_ROBOT
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/graphics/src/main/native-glass/lens/lensport/imx6Cursor.c	Tue Oct 22 18:00:28 2013 -0400
@@ -0,0 +1,366 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+ 
+#ifdef IMX6_PLATFORM
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <linux/fb.h>
+#include <sys/ioctl.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <dlfcn.h>
+#include <errno.h>
+#include <linux/mxcfb.h>  // note: i.MX unique header
+
+#include "lensPort.h"
+#include "lensPortInternal.h"
+#include "lensPortLogger.h"
+
+
+#define RGB565TOCOLORKEY(rgb)                              \
+      ( ((rgb & 0xf800)<<8)  |  ((rgb & 0xe000)<<3)  |     \
+        ((rgb & 0x07e0)<<5)  |  ((rgb & 0x0600)>>1)  |     \
+        ((rgb & 0x001f)<<3)  |  ((rgb & 0x001c)>>2)  )  
+
+
+#define LENSFB_IMX6_CURSOR_DEVICE "/dev/fb1"
+#define LENSFB_IMX6_CURSOR_COLOR_KEY 0xABAB
+#define LENSFB_IMX6_CURSOR_SIZE 16
+
+typedef struct {
+    int fd;
+    int width;
+    int height;
+    int x,y;
+    int screenWidth;
+    int screenHeight;
+    jlong currentCursor;
+    jboolean isVisible;
+} Imx6FBCursor;
+
+static Imx6FBCursor cursor = { .fd = -1, .width = 0, .height = 0, .x = 0, .y = 0, .currentCursor = 0, .isVisible = 0};
+
+//TODO : platform supports 32 and 16 bits, how do we choose what to use ?
+static int use32bit = 0;
+
+typedef struct {
+    jint width;
+    jint height;
+    jint x;
+    jint y;
+    jbyte* buffer;
+    jint bufferSize;
+} Imx6CursorImage;
+
+
+static int fbImx6ChangeCursorSize(int width, int height) {
+
+    struct fb_var_screeninfo screenInfo;
+    if (ioctl(cursor.fd, FBIOGET_VSCREENINFO, &screenInfo)) {
+        GLASS_LOG_SEVERE("Error %s in getting screen info", strerror(errno));
+        return -1;
+    }
+
+    screenInfo.xres = width;
+    screenInfo.yres = height;
+    screenInfo.xres_virtual = 0;
+    screenInfo.yres_virtual = 0;
+    screenInfo.xoffset = 0;
+    screenInfo.yoffset = 0;
+    screenInfo.activate = 0;
+
+    if(ioctl(cursor.fd, FBIOPUT_VSCREENINFO, &screenInfo)) {
+        GLASS_LOG_SEVERE("Error %s in setting screen info", strerror(errno));
+        return -1;
+    }
+
+    cursor.width = width;
+    cursor.height = height;
+
+    return 0;
+}
+
+
+
+static void fbImx6CursorInitialize(int screenWidth, int screenHeight) {
+
+    struct fb_var_screeninfo screenInfo;
+    int rc;
+    char * zero = "0\n";
+    int fbc = -1;
+    int fbo = -1;
+ 
+    //TODO : the following 2 settings can be moved to a setup script procedure
+    if ((fbc = open("/sys/class/graphics/fbcon/cursor_blink",O_RDWR)) < 0) {
+        GLASS_LOG_SEVERE("Error %s in opening /sys/class/graphics/fbcon/cursor_blink", strerror(errno));
+    } else {
+        write(fbc,zero,1);
+        close(fbc);
+    }
+    if ((fbo = open("/sys/class/graphics/fb1/blank", O_RDWR)) < 0) {
+        GLASS_LOG_SEVERE("Error %s in opening /sys/class/graphics/fb1/blank", strerror(errno));
+    } else {
+        write(fbo,zero,1);
+        close(fbo);
+    }
+
+    // Init cursor global variable fields
+    cursor.width = LENSFB_IMX6_CURSOR_SIZE;
+    cursor.height = LENSFB_IMX6_CURSOR_SIZE;
+    cursor.x = 0;
+    cursor.y = 0;
+    cursor.currentCursor = 0;
+    cursor.isVisible = 0;
+    cursor.screenWidth = screenWidth;
+    cursor.screenHeight = screenHeight;
+
+    cursor.fd = open(LENSFB_IMX6_CURSOR_DEVICE, O_RDWR);
+    if (cursor.fd < 0) {
+        GLASS_LOG_SEVERE("Cannot open framebuffer device %s",LENSFB_IMX6_CURSOR_DEVICE);
+        return;
+    }
+
+    if (ioctl(cursor.fd, FBIOGET_VSCREENINFO, &screenInfo)) {
+        GLASS_LOG_SEVERE("Error %s in getting screen info", strerror(errno));
+        return;
+    }
+
+    GLASS_LOG_INFO("Initializing %d bits pixel %dx%d cursor, current %d bits\n",
+                   (use32bit ? 32 : 16), LENSFB_IMX6_CURSOR_SIZE, LENSFB_IMX6_CURSOR_SIZE, screenInfo.bits_per_pixel);
+
+    screenInfo.xres = LENSFB_IMX6_CURSOR_SIZE;
+    screenInfo.yres = LENSFB_IMX6_CURSOR_SIZE;
+    screenInfo.xres_virtual = 0;
+    screenInfo.yres_virtual = 0;
+    screenInfo.xoffset = 0;
+    screenInfo.yoffset = 0;
+    screenInfo.activate = 0;
+
+    if (use32bit) {
+        screenInfo.bits_per_pixel = 32;
+        screenInfo.red.length = 8;
+        screenInfo.red.offset = 16;
+        screenInfo.green.length = 8;
+        screenInfo.green.offset = 8;
+        screenInfo.blue.length = 8;
+        screenInfo.blue.offset = 0;
+        screenInfo.transp.length = 8;
+        screenInfo.transp.offset = 24;
+    }  else {
+        // 565
+        screenInfo.bits_per_pixel = 16;
+        screenInfo.red.length = 5;
+        screenInfo.red.offset = 11;
+        screenInfo.green.length = 6;
+        screenInfo.green.offset = 5;
+        screenInfo.blue.length = 5;
+        screenInfo.blue.offset = 0;
+        screenInfo.transp.length = 0;
+        screenInfo.transp.offset = 0;
+    }
+
+    if(ioctl(cursor.fd, FBIOPUT_VSCREENINFO, &screenInfo)) {
+        GLASS_LOG_SEVERE("Error %s in setting screen info", strerror(errno));
+        return;
+    }
+
+    if(ioctl(cursor.fd, FBIOBLANK, FB_BLANK_UNBLANK)) {
+         GLASS_LOG_SEVERE("Error %s in gstting cursor no-blanking", strerror(errno));
+         return;
+    }
+
+
+    if (use32bit) {
+        // alpha is taken from each pixel
+        struct mxcfb_loc_alpha loc_alpha;
+        loc_alpha.enable = 1;
+        loc_alpha.alpha_in_pixel = 1;
+        if (ioctl(cursor.fd, MXCFB_SET_LOC_ALPHA, &loc_alpha) < 0) {
+            GLASS_LOG_SEVERE("Error %s in setting local alpha", strerror(errno));
+        } 
+
+    } else {
+        struct mxcfb_color_key color_key;
+        color_key.color_key = RGB565TOCOLORKEY(LENSFB_IMX6_CURSOR_COLOR_KEY);
+        color_key.enable = 1;
+        if ( ioctl(cursor.fd, MXCFB_SET_CLR_KEY, &color_key) < 0) {
+            GLASS_LOG_SEVERE("Error %s in setting 16 bits color key", strerror(errno));
+        }
+
+        struct mxcfb_gbl_alpha gbl_alpha;
+        gbl_alpha.alpha = 255;
+        gbl_alpha.enable = 1;
+        if(ioctl(cursor.fd, MXCFB_SET_GBL_ALPHA, &gbl_alpha) < 0) {
+              GLASS_LOG_SEVERE("Error %s in setting global alpha", strerror(errno));
+        }
+    }
+
+    struct mxcfb_pos cpos = {(screenWidth - 16)/2, (screenHeight - 16)/2};
+    if (ioctl(cursor.fd, MXCFB_SET_OVERLAY_POS, &cpos)) {
+        GLASS_LOG_SEVERE("Error %s in setting overlay position", strerror(errno));
+    }
+}
+
+
+
+static jlong fbImx6CreateNativeCursor(JNIEnv *env, jint x, jint y,  jbyte *srcArray, jint width, jint height) {
+
+    Imx6CursorImage *cursorImage = (Imx6CursorImage *)malloc(sizeof(Imx6CursorImage));
+    cursorImage->x = x;
+    cursorImage->y = y;
+    cursorImage->width = width;
+    cursorImage->height = height;
+    cursorImage->bufferSize = width * height * (use32bit ? 4 : 2);
+    cursorImage->buffer = (jbyte*)malloc(cursorImage->bufferSize);
+
+    GLASS_LOG_INFO("Creating x : %d y : %d width : %d height : %d cursor %d bits per pixel",x, y, width, height, (use32bit ? 32 : 16));
+
+    if (use32bit) {
+        memcpy((void*)(cursorImage->buffer), srcArray, cursorImage->bufferSize);
+    } else {
+        //565
+        int i;
+        uint16_t* dst = (uint16_t*)(cursorImage->buffer);
+        uint32_t* src = (uint32_t*)srcArray;
+        for (i = 0; i < cursorImage->bufferSize; i += 2) {
+            int pixel = *src++;
+            if ((pixel & 0xff000000) != 0) {
+                *dst++ = ((pixel >> 8) & 0xf800)
+                         | ((pixel >> 5) & 0x7e0)
+                         | ((pixel >> 3) & 0x1f);
+            } else {
+                *dst++ = LENSFB_IMX6_CURSOR_COLOR_KEY;
+            }
+        }
+    }
+
+    return ptr_to_jlong(cursorImage);   
+}
+
+
+static void fbImx6ReleaseNativeCursor(jlong nativeCursorHandle) {
+
+    Imx6CursorImage *cursorImage = (Imx6CursorImage *)jlong_to_ptr(nativeCursorHandle);
+
+    if (cursorImage->buffer != NULL) {
+        free(cursorImage->buffer);
+    }
+
+    free(cursorImage);
+}
+
+
+static void fbImx6SetNativeCursor(jlong nativeCursorHandle) {
+
+    Imx6CursorImage *cursorImage = (Imx6CursorImage *)jlong_to_ptr(nativeCursorHandle);
+
+    if (cursor.fd != -1 && cursor.currentCursor != nativeCursorHandle && 
+        cursorImage != NULL && cursorImage->buffer != NULL) 
+    {
+        if (cursorImage->width != cursor.width || cursorImage->height != cursor.height) {
+            if (fbImx6ChangeCursorSize(cursorImage->width, cursorImage->height)) {
+                GLASS_LOG_SEVERE("Error in fbImx6ChangeCursorSize() w : %d h : %d", cursorImage->width, cursorImage->height);
+                return;
+            }
+        }
+
+        GLASS_LOG_INFO("Writing cursor size %d to fd : %d", cursorImage->bufferSize, cursor.fd);
+        if (write(cursor.fd, cursorImage->buffer, cursorImage->bufferSize) < cursorImage->bufferSize) {
+            GLASS_LOG_SEVERE("Error %s in writing cursor image", strerror(errno));
+            return;
+        }
+
+        cursor.isVisible = 1;
+        cursor.currentCursor = nativeCursorHandle;
+    }
+}
+
+
+
+static void fbImx6CursorSetPosition(int x, int y) {
+
+    cursor.x = x;
+    cursor.y = y;
+
+    if (cursor.isVisible) {
+        struct mxcfb_pos cpos = {x, y};
+        if (ioctl(cursor.fd, MXCFB_SET_OVERLAY_POS, &cpos)) {
+            GLASS_LOG_SEVERE("Error %s in setting overlay position", strerror(errno));
+        }
+    }
+}
+
+
+void fbImx6CursorClose() {
+
+    if (cursor.fd >= 0) {
+        close(cursor.fd);
+        cursor.fd = -1;
+        cursor.isVisible = 0;
+        cursor.currentCursor = 0;
+        cursor.width = 0;
+        cursor.height = 0;
+    }
+}
+
+static void fbImx6SetVisible(jboolean isVisible) {
+    if (isVisible) {
+        if (!cursor.isVisible && cursor.currentCursor != 0) {
+            fbImx6SetNativeCursor(cursor.currentCursor);
+        }
+    } else {
+        if (cursor.isVisible) {
+            write(cursor.fd,"",0);
+        }
+        cursor.isVisible = 0;
+    }
+}
+
+static char * platformName = "imx6";
+
+jboolean check_imx6_cursor(LensNativePort *lensPort) {
+
+    if (dlopen("libVIVANTE.so", RTLD_LAZY)) {
+        lensPort->platformName = platformName;
+        lensPort->setNativeCursor = fbImx6SetNativeCursor;
+        lensPort->cursorInitialize = fbImx6CursorInitialize;
+        lensPort->cursorSetPosition = fbImx6CursorSetPosition;
+        lensPort->cursorClose = fbImx6CursorClose;
+        lensPort->createNativeCursor = fbImx6CreateNativeCursor;
+        lensPort->releaseNativeCursor = fbImx6ReleaseNativeCursor;
+        lensPort->setVisible = fbImx6SetVisible;
+        lensPort->cursorTranslucency = (use32bit ? JNI_TRUE : JNI_FALSE);
+
+        return JNI_TRUE;
+    } 
+    
+    return JNI_FALSE;
+}
+
+#endif // IMX6_PLATFORM
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/graphics/src/main/native-glass/lens/lensport/initPlatform.c	Tue Oct 22 18:00:28 2013 -0400
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "lensPort.h"
+#include "lensPortInternal.h"
+
+int platform_log_level = 0;
+
+Platform_Logger *platform_logf = 0;
+
+static void setPlatformLogging(Platform_Logger *logger, int level) {
+    platform_logf = logger;
+    platform_log_level = level;
+}
+
+#ifdef USE_DISPMAN
+extern jboolean select_dispman_cursor(LensNativePort *lensPort);
+#endif // USE_DISPMAN
+
+#if defined(OMAP3) || defined(IMX6_PLATFORM)
+extern jboolean fbFBRobotScreen(jint x, jint y,
+                                    jint width, jint height,
+                                    jint *pixels); 
+#endif
+
+#ifdef OMAP3
+extern jboolean select_omap_cursor(LensNativePort *lensPort);
+#endif
+
+#ifdef IMX6_PLATFORM
+extern jboolean check_imx6_cursor(LensNativePort *lensPort);
+#endif
+
+jboolean lens_platform_initialize(LensNativePort* lensPort) {
+
+    // check if we are within the range of what we can accept
+    if ((!lensPort) || lensPort->version != NATIVE_PRISM_PORT_VERSION) {
+        // something is really wrong here !
+        printf("lensPort VERSION FAILED\n");
+        return JNI_FALSE;
+    }
+
+    // report the version we actually are
+    lensPort->version = NATIVE_LENS_PORT_VERSION;
+    lensPort->setLogger = &setPlatformLogging;
+
+#ifdef USE_DISPMAN
+    if (select_dispman_cursor(lensPort)) {
+        return JNI_TRUE;
+    } 
+#endif // USE_DISPMAN
+
+#ifdef IMX6_PLATFORM
+    if (check_imx6_cursor(lensPort)) {
+        lensPort->robotScreenCapture = fbFBRobotScreen;
+        return JNI_TRUE;
+    }
+#endif //IMX6_PLATFORM
+
+#ifdef OMAP3
+    { // this is our default, no real test
+        select_omap_cursor(lensPort);
+        lensPort->robotScreenCapture = fbFBRobotScreen;
+        return JNI_TRUE;
+    }
+#endif //OMAP3
+
+    // Fatal Error
+    fprintf(stderr,"Fatal error loading native porting layer in Lens\n");
+    exit(-1);
+
+    return JNI_FALSE;
+}
+
+// fix these return values?
+extern void* util_getNativeWindowType(void);
+extern void* util_getNativeDisplayType(void);
+extern void* util_wr_eglGetDisplay(void *);
+extern void* util_getLibGLEShandle(void);
+
+jboolean prism_platform_initialize(PrismNativePort* prismPort) {
+
+    // check if we are within the range of what we can accept
+    if ((!prismPort) || prismPort->version != NATIVE_PRISM_PORT_VERSION) {
+        // something is really wrong here !
+        fprintf(stderr,"failed (version?) in prism_platform_initialize\n");
+        exit(-1);
+    }
+
+    prismPort->version = NATIVE_PRISM_PORT_VERSION;
+    prismPort->getNativeWindowType = &util_getNativeWindowType;
+    prismPort->getNativeDisplayType = &util_getNativeDisplayType;
+    prismPort->wr_eglGetDisplay = &util_wr_eglGetDisplay;
+    prismPort->getLibGLEShandle = &util_getLibGLEShandle;
+
+    return JNI_TRUE;
+}
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/graphics/src/main/native-glass/lens/lensport/lensPort.h	Tue Oct 22 18:00:28 2013 -0400
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#ifndef PLATFORM_UTIL_H
+#define PLATFORM_UTIL_H
+
+#include <jni.h>
+
+#define NATIVE_LENS_PORT_VERSION 1
+#define NATIVE_PRISM_PORT_VERSION 1
+
+#define LENSPORT_LIBRARY_NAME "liblens_porting.so"
+
+typedef void Platform_Logger(int level,
+                const char *func,
+                const char *file,
+                int line,
+                const char *format, ...);
+
+typedef struct _lens_native_port {
+    int version;
+    char *platformName;
+    void (*setLogger)(Platform_Logger *logger, int level);
+    // Cursor Specific Entries
+    void (*createCursor)(jbyte *cursorImage, int width, int height, int bpp);
+    void (*setNativeCursor)(jlong nativeCursorPointer);
+    void (*cursorInitialize)(int screenWidth, int screenHeight);
+    void (*cursorSetPosition)(int x, int y);
+    void (*cursorClose)();
+    void (*cursorTerminate)();
+    jlong (*createNativeCursor)(JNIEnv *env, jint x, jint y,  jbyte *srcArray, jint width, jint height);
+    void (*releaseNativeCursor)(jlong nativeCursorPointer);
+    void (*setVisible)(jboolean isVisible);
+    jboolean cursorTranslucency;
+
+    // Robot Specific Entries
+    jboolean (*robotScreenCapture)(jint x, jint y, jint width, jint height, jint *pixels);
+} LensNativePort;
+
+typedef struct _prism_native_port {
+    int version;
+    char *platformName;
+    //returns a EGLNativeWindowType
+    void * (*getNativeWindowType)();
+    //returns a EGLNativeDisplayType
+    void * (*getNativeDisplayType)();
+    void * (*wr_eglGetDisplay)(void *id);
+    void * (*getLibGLEShandle)();
+} PrismNativePort;
+
+// Called to initialize the lens specific platform functions.
+// Must be called prior to other utility calls.
+// return of true on success
+extern jboolean lens_platform_initialize(LensNativePort *lensPort);
+
+// Called to initialize the prism specific platform functions.
+// Must be called prior to other utility calls.
+// return of true on success
+extern jboolean prism_platform_initialize(PrismNativePort *prismsPort);
+
+#endif // PLATFORM_UTIL_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/graphics/src/main/native-glass/lens/lensport/lensPortInternal.h	Tue Oct 22 18:00:28 2013 -0400
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#ifndef PLATFORM_INTERNAL_H
+#define PLATFORM_INTERNAL_H
+
+#ifndef FB_DEVICE
+#define FB_DEVICE "/dev/fb0"
+#endif
+
+#ifndef FB_CURSOR_DEVICE
+#define FB_CURSOR_DEVICE "/dev/fb1"
+#endif
+
+#define LENSFB_CURSOR_COLOR_KEY 0xABABABAB
+
+/**
+ * The bellow macros will convert pointers to long
+ * representation, which is how java is keeping native pointers,
+ * and vice versa.
+ * This code will work in both 32 and 64 bit systems
+ */
+#if defined (_LP64) || defined(_WIN64)
+#define jlong_to_ptr(a) ((void*)(a))
+#define ptr_to_jlong(a) ((jlong)(a))
+#else
+#define jlong_to_ptr(a) ((void*)(int)(a))
+#define ptr_to_jlong(a) ((jlong)(int)(a))
+#endif
+
+#endif // PLATFORM_INTERNAL_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/graphics/src/main/native-glass/lens/lensport/lensPortLogger.h	Tue Oct 22 18:00:28 2013 -0400
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#ifndef PLATFORM_LOGGER_H
+#define PLATFORM_LOGGER_H
+
+/**
+ * Log a message at the given logging level.
+ * Not used directly. GLASS_LOG should be used instead.
+ */
+extern void (*platform_logf)(int level,
+                const char *func,
+                const char *file,
+                int line,
+                const char *format, ...);
+
+/**
+ * The logging level.
+ * Not used directly. GLASS_LOG and GLASS_IF_LOG should be used instead.
+ */
+extern jint platform_log_level;
+
+/**
+ * Begins a conditional statement that is only run if the current logging level
+ * is less than or equal to "level".
+ * For example, GLASS_IF_LOG(LOG_WARNING) { f(); } will call f() if and only if
+ * the current logging settings include printing warning messages.
+ * @param level The logging level to be tested against.
+ */
+#define GLASS_IF_LOG(level) if ((platform_logf) && (level >= platform_log_level))
+
+/**
+ * Logs a message at the given logging level
+ * @param level the logging level (e.g. LOG_WARNING)
+ * @param ... a format string and parameters in printf format
+ */
+/** Logging levels, with same meanings as in java.util.logging.Level */
+#define GLASS_LOG_LEVEL_SEVERE  1000
+#define GLASS_LOG_LEVEL_WARNING 900
+#define GLASS_LOG_LEVEL_INFO    800
+#define GLASS_LOG_LEVEL_CONFIG  700
+#define GLASS_LOG_LEVEL_FINE    500
+#define GLASS_LOG_LEVEL_FINER   400
+#define GLASS_LOG_LEVEL_FINEST  300
+
+#ifdef ANDROID_NDK
+// Can't use java logger in jvm8 on Android. Remove when this issue is fixed.
+#include <android/log.h>
+#define TAG "GLASS"
+#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, __VA_ARGS__))
+#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, __VA_ARGS__))
+#define LOGV(...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, __VA_ARGS__))
+#define GLASS_LOG(level,...) \
+        LOGI(TAG, __VA_ARGS__)
+#else
+#define GLASS_LOG(level,...) \
+    GLASS_IF_LOG(level) \
+    (*platform_logf)(level, __func__, __FILE__, __LINE__, __VA_ARGS__)
+
+#define GLASS_IF_LOG_SEVERE  GLASS_IF_LOG(GLASS_LOG_LEVEL_SEVERE)
+#define GLASS_IF_LOG_WARNING GLASS_IF_LOG(GLASS_LOG_LEVEL_WARNING)
+#define GLASS_IF_LOG_INFO    GLASS_IF_LOG(GLASS_LOG_LEVEL_INFO)
+#define GLASS_IF_LOG_CONFIG  GLASS_IF_LOG(GLASS_LOG_LEVEL_CONFIG)
+#define GLASS_IF_LOG_FINE    GLASS_IF_LOG(GLASS_LOG_LEVEL_FINE)
+#define GLASS_IF_LOG_FINER   GLASS_IF_LOG(GLASS_LOG_LEVEL_FINER)
+#define GLASS_IF_LOG_FINEST  GLASS_IF_LOG(GLASS_LOG_LEVEL_FINEST)
+#endif
+
+#ifdef NO_LOGGING
+#define GLASS_LOG_SEVERE(...)  (void)0, ##__VA_ARGS__
+#define GLASS_LOG_WARNING(...) (void)0, ##__VA_ARGS__
+#define GLASS_LOG_INFO(...) (void)0, ##__VA_ARGS__
+#define GLASS_LOG_CONFIG(...) (void)0, ##__VA_ARGS__
+#define GLASS_LOG_FINE(...) (void)0, ##__VA_ARGS__
+#define GLASS_LOG_FINER(...) (void)0, ##__VA_ARGS__
+#define GLASS_LOG_FINEST(...) (void)0, ##__VA_ARGS__
+#else
+#define GLASS_LOG_SEVERE(...) GLASS_LOG(GLASS_LOG_LEVEL_SEVERE, __VA_ARGS__)
+#define GLASS_LOG_WARNING(...) GLASS_LOG(GLASS_LOG_LEVEL_WARNING, __VA_ARGS__)
+#define GLASS_LOG_INFO(...) GLASS_LOG(GLASS_LOG_LEVEL_INFO, __VA_ARGS__)
+#define GLASS_LOG_CONFIG(...) GLASS_LOG(GLASS_LOG_LEVEL_CONFIG, __VA_ARGS__)
+#define GLASS_LOG_FINE(...) GLASS_LOG(GLASS_LOG_LEVEL_FINE, __VA_ARGS__)
+#define GLASS_LOG_FINER(...) GLASS_LOG(GLASS_LOG_LEVEL_FINER, __VA_ARGS__)
+#define GLASS_LOG_FINEST(...) GLASS_LOG(GLASS_LOG_LEVEL_FINEST, __VA_ARGS__)
+#endif
+
+#endif // PLATFORM_LOGGER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/graphics/src/main/native-glass/lens/lensport/omapCursor.c	Tue Oct 22 18:00:28 2013 -0400
@@ -0,0 +1,370 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+ 
+#include <fcntl.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <linux/fb.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+
+#include "lensPort.h"
+#include "lensPortInternal.h"
+#include "lensPortLogger.h"
+
+#if defined(OMAP3)
+
+#include <linux/omapfb.h>
+
+typedef struct {
+    int fd;
+    struct omapfb_plane_info plane;
+    int x;
+    int y;
+    int width;
+    int height;
+    int screenWidth;
+    int screenHeight;
+    jlong currentCursor;
+    jboolean isVisible;
+    // When the cursor is at the extreme right or bottom of the screen, it
+    // needs to be shifted to show in the correct location. OMAP doesn't let us
+    // position the framebuffer so that it is only partically visible.
+    int xShift;
+    int yShift;
+} FBCursor;
+
+typedef struct {
+    int width;
+    int height;
+    int bpp;
+    jbyte *buffer;
+} FBCursorImage;
+
+
+FBCursor cursor = { .fd = -1, .x = 0, .y = 0,
+                    .width = 0, .height = 0,
+                    .currentCursor = 0, .isVisible = 0,
+                    .xShift = 0, .yShift = 0 };
+
+/* Writes an image into the cursor framebuffer with the given x and y offsets. */
+static void fbOmapWriteCursor(int fd, jbyte *cursorImage, int bpp);
+
+/* Updates values of xShift and yShift based on the cursor location */
+static void fbOmapAdjustShift();
+
+void fbOmapCursorClose() {
+    if (cursor.fd >= 0) {
+        cursor.plane.enabled = 0;
+        if (ioctl(cursor.fd, OMAPFB_SETUP_PLANE, &cursor.plane)) {
+            GLASS_LOG_SEVERE("Failed to disable cursor plane");
+        }
+        close(cursor.fd);
+        cursor.fd = -1;
+        cursor.isVisible = 0;
+    }
+}
+
+void fbOmapCreateCursor(jbyte *cursorImage, int width, int height, int bpp) {
+    struct fb_var_screeninfo screenInfo;
+    cursor.width = width;
+    cursor.height = height;
+
+    GLASS_LOG_FINE("open(%s, O_RDWR)", FB_CURSOR_DEVICE);
+    cursor.fd = open(FB_CURSOR_DEVICE, O_RDWR);
+    if (cursor.fd < 0) {
+        GLASS_LOG_SEVERE("Cannot open frame buffer device for cursor");
+        return;
+    }
+    if (ioctl(cursor.fd, FBIOGET_VSCREENINFO, &screenInfo)) {
+        GLASS_LOG_SEVERE("Cannot query screen info");
+        fbOmapCursorClose();
+        return;
+    }
+    screenInfo.xoffset = 0;
+    screenInfo.yoffset = 0;
+    screenInfo.xres = screenInfo.xres_virtual = cursor.width;
+    screenInfo.yres = screenInfo.yres_virtual = cursor.height;
+
+    if (ioctl(cursor.fd, FBIOPUT_VSCREENINFO, &screenInfo)) {
+        GLASS_LOG_SEVERE("Cannot set screen info");
+        fbOmapCursorClose();
+        return;
+    }
+    cursor.plane.enabled = 1;
+    cursor.plane.out_width = cursor.width;
+    cursor.plane.out_height = cursor.height;
+    if (ioctl(cursor.fd, OMAPFB_SETUP_PLANE, &cursor.plane)) {
+        GLASS_LOG_SEVERE("Cannot set plane info");
+        fbOmapCursorClose();
+        return;
+    }
+
+    if (ioctl(cursor.fd, OMAPFB_QUERY_PLANE, &cursor.plane)) {
+        GLASS_LOG_SEVERE("Cannot query plane info");
+        fbOmapCursorClose();
+        return;
+    }
+
+    // Set up the color key
+    struct omapfb_color_key color_key;
+    if (ioctl(cursor.fd, OMAPFB_GET_COLOR_KEY, &color_key)) {
+        GLASS_LOG_SEVERE("Cannot set color key");
+        return;
+    }
+
+    color_key.key_type = OMAPFB_COLOR_KEY_VID_SRC;
+    color_key.trans_key = LENSFB_CURSOR_COLOR_KEY;
+    if (ioctl(cursor.fd, OMAPFB_SET_COLOR_KEY, &color_key)) {
+        GLASS_LOG_SEVERE("OMAPFB_SET_COLOR_KEY");
+        return;
+    }
+
+    fbOmapAdjustShift();
+    fbOmapWriteCursor(cursor.fd, cursorImage, bpp);
+}
+
+static void fbOmapWriteCursor(int fd, jbyte *cursorImage, int bpp) {
+    unsigned i, j, k;
+    char buffer[256];
+    size_t cursorSize = cursor.width * cursor.height * bpp;
+    unsigned xShift = (unsigned) cursor.xShift;
+    unsigned yShift = (unsigned) cursor.yShift;
+    GLASS_LOG_FINEST("Cursor shift = (%i, %i) at (%i, %i)\n",
+                     xShift, yShift, cursor.x, cursor.y);
+    if (xShift == 0 && yShift == 0) {
+        GLASS_LOG_FINEST("write(cursor.fd, .. %i)", cursorSize);
+        if (write(cursor.fd, cursorImage, cursorSize) < (int) cursorSize) {
+            GLASS_LOG_SEVERE("Cannot write cursor plane");
+        }
+        return;
+    }
+    for (i = 0; i < yShift; i++) {
+        for (j = 0; j < (unsigned) cursor.width * bpp; j += sizeof(buffer)) {
+            size_t n = cursor.width * bpp - j;
+            if (n > sizeof(buffer)) {
+                n = sizeof(buffer);
+            }
+            for (k = 0; k < n; k += bpp) {
+                // 171 == 0xAB of the color key.
+                buffer[k] = 171;
+                buffer[k + 1] = 171;
+                buffer[k + 2] = 171;
+                buffer[k + 3] = 171;
+            }
+            GLASS_LOG_FINEST("write(cursor.fd, .. %u)", n);
+            if (write(cursor.fd, buffer, n) < (int) n) {
+                GLASS_LOG_SEVERE("Cannot write cursor plane");
+                return;
+            }
+        }
+    }
+    for (i = 0; i < cursor.height - yShift; i++) {
+        for (j = 0; j < xShift * bpp; j += sizeof(buffer)) {
+            size_t n = xShift * bpp;
+            if (n > sizeof(buffer)) {
+                n = sizeof(buffer);
+            }
+            for (k = 0; k < n; k += bpp) {
+                // 171 == 0xAB of the color key.
+                buffer[k] = 171;
+                buffer[k + 1] = 171;
+                buffer[k + 2] = 171;
+                buffer[k + 3] = 171;
+            }
+            GLASS_LOG_FINEST("write(cursor.fd, .. %u)", n);
+            if (write(cursor.fd, buffer, n) < (int) n) {
+                GLASS_LOG_SEVERE("Cannot write cursor plane");
+                return;
+            }
+        }
+        size_t n = (cursor.width - xShift) * bpp;
+        GLASS_LOG_FINEST("write(cursor.fd, .. %u)", n);
+        if (write(cursor.fd, cursorImage + i * cursor.width * bpp, n) < (int) n) {
+            GLASS_LOG_SEVERE("Cannot write cursor plane");
+            return;
+        }
+    }
+}
+
+jlong fbOmapCreateNativeCursor(JNIEnv *env, jint x, jint y,  jbyte *srcArray, jint width, jint height) {
+    FBCursorImage *cursorImage;
+    int imageSize = width * height * 4;
+    cursorImage = (FBCursorImage *)malloc(sizeof(FBCursorImage) + imageSize);
+
+    cursorImage->width = width;
+    cursorImage->height = height;
+    cursorImage->bpp = 4;
+    cursorImage->buffer = (jbyte *)(cursorImage + 1);
+
+    {
+        int i;
+        for (i = 0; (i + 3) < imageSize; i += 4) {
+            if (srcArray[i + 3] != 0) {
+                cursorImage->buffer[i] = srcArray[i];
+                cursorImage->buffer[i + 1] = srcArray[i + 1];
+                cursorImage->buffer[i + 2] = srcArray[i + 2];
+                cursorImage->buffer[i + 3] = srcArray[i + 3];
+            } else {
+                // 171 == 0xAB of the color key.
+                cursorImage->buffer[i] = 171;
+                cursorImage->buffer[i + 1] = 171;
+                cursorImage->buffer[i + 2] = 171;
+                cursorImage->buffer[i + 3] = 171;
+            }
+        }
+    }
+    return ptr_to_jlong(cursorImage);
+}
+
+void fbOmapCursorInitialize(int screenWidth, int screenHeight) {
+    cursor.screenWidth = screenWidth;
+    cursor.screenHeight = screenHeight;
+}
+
+void fbOmapAdjustShift() {
+    if (cursor.x > cursor.screenWidth - cursor.width) {
+        cursor.xShift = cursor.width + cursor.x - cursor.screenWidth;
+    } else {
+        cursor.xShift = 0;
+    }
+    if (cursor.y > cursor.screenHeight - cursor.height) {
+        cursor.yShift = cursor.height + cursor.y - cursor.screenHeight;
+    } else {
+        cursor.yShift = 0;
+    }
+}
+
+void fbOmapCursorSetPosition(int x, int y) {
+    int xShift = cursor.xShift;
+    int yShift = cursor.yShift;
+    if (x < 0) {
+        x = 0;
+    }
+    if (y < 0) {
+        y = 0;
+    }
+    if (x > cursor.screenWidth - 1) {
+        x = cursor.screenWidth - 1;
+    }
+    if (y > cursor.screenHeight - 1) {
+        y = cursor.screenHeight - 1;
+    }
+    cursor.x = x;
+    cursor.y = y;
+    fbOmapAdjustShift();
+    x -= cursor.xShift;
+    y -= cursor.yShift;
+    if (xShift != cursor.xShift || yShift != cursor.yShift) {
+        GLASS_LOG_FINEST("Calling lseek to rewind cursor fd");
+        if (lseek(cursor.fd, 0, SEEK_SET) == -1) {
+            GLASS_LOG_SEVERE("Cannot rewrite cursor image");
+        } else {
+            FBCursorImage *fbCursorImage = (FBCursorImage *)
+                jlong_to_ptr(cursor.currentCursor);
+            fbOmapWriteCursor(cursor.fd, fbCursorImage->buffer, fbCursorImage->bpp);
+        }
+    }
+    cursor.plane.enabled = 1;
+    cursor.plane.pos_x = x;
+    cursor.plane.pos_y = y;
+    if (cursor.fd >= 0) {
+        if (ioctl(cursor.fd, OMAPFB_SETUP_PLANE, &cursor.plane)) {
+            GLASS_LOG_SEVERE("Cannot set plane info to show cursor at %i,%i", x, y);
+        }
+    }
+}
+
+void fbOmapSetNativeCursor(jlong nativeCursorPointer) {
+    FBCursorImage *cursorImage = (FBCursorImage *)jlong_to_ptr(nativeCursorPointer);
+    if (cursor.currentCursor == nativeCursorPointer) {
+        return;
+    }
+
+    cursor.currentCursor = nativeCursorPointer;
+
+    if (cursor.isVisible) {
+        fbOmapCursorClose();
+        fbOmapCreateCursor(cursorImage->buffer, cursorImage->width, cursorImage->height, cursorImage->bpp);
+        // reset the visibility - because closing the cursor also makes it 
+        // not visible
+        cursor.isVisible = 1;
+    } 
+}
+
+void fbOmapReleaseNativeCursor(jlong nativeCursorPointer) {
+    if (nativeCursorPointer != 0) {
+        FBCursorImage *cursorImage = (FBCursorImage *)jlong_to_ptr(nativeCursorPointer);
+        free(cursorImage);
+    }
+
+    if (cursor.currentCursor == nativeCursorPointer) {
+        fbOmapCursorClose();
+        cursor.currentCursor = 0;
+    }
+}
+
+void fbOmapSetVisible(jboolean isVisible) {
+    if (isVisible) {
+        if (!cursor.isVisible && cursor.currentCursor != 0) {
+            FBCursorImage *cursorImage = 
+                (FBCursorImage *)jlong_to_ptr(cursor.currentCursor);
+            fbOmapCreateCursor(cursorImage->buffer, cursorImage->width, 
+                               cursorImage->height, cursorImage->bpp);
+        }
+    } else {
+        fbOmapCursorClose();
+    }
+
+    cursor.isVisible = isVisible;
+}
+
+
+jboolean fbOmapPlatformCursorTranslucency() {
+    return JNI_FALSE;
+}
+
+void fbOmapCursorTerminate(void) {
+    fbOmapCursorClose();
+}
+
+static char * platformName = "omap";
+
+jboolean select_omap_cursor(LensNativePort *lensPort) {
+    lensPort->platformName = platformName;
+    lensPort->setNativeCursor = fbOmapSetNativeCursor;
+    lensPort->cursorInitialize = fbOmapCursorInitialize;
+    lensPort->cursorSetPosition = fbOmapCursorSetPosition;
+    lensPort->cursorClose = fbOmapCursorClose;
+    lensPort->createNativeCursor = fbOmapCreateNativeCursor;
+    lensPort->releaseNativeCursor = fbOmapReleaseNativeCursor;
+    lensPort->setVisible = fbOmapSetVisible;
+    lensPort->createCursor = fbOmapCreateCursor;
+
+    return JNI_TRUE;
+}
+
+#endif // OMAP3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/graphics/src/main/native-glass/lens/lensport/wrapped_bcm.h	Tue Oct 22 18:00:28 2013 -0400
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+#ifndef __WRAPPED_BCM__
+#define __WRAPPED_BCM__
+
+#ifndef WRAPPEDAPI
+#define WRAPPEDAPI extern
+#endif
+
+#ifdef USE_DISPMAN
+
+#ifndef BCM_HOST_H
+#include <bcm_host.h>
+#endif
+
+#if !defined(_VC_DISPMANX_H_)
+/* for Debian 6.0 libraries */
+typedef enum {
+   VC_IMAGE_ARGB8888 = 43,  /* 32bpp with 8bit alpha at MS byte, with R, G, B (LS byte) */
+} VC_IMAGE_TYPE_T;
+#endif
+
+#define vc_dispmanx_display_close(display) (*wr_vc_dispmanx_display_close)(display)
+
+#define vc_dispmanx_display_open(device) (*wr_vc_dispmanx_display_open)(device)
+
+#define vc_dispmanx_element_add(update, display, layer, dest_rect, src, src_rect, protection, alpha, clamp, transform) (*wr_vc_dispmanx_element_add)(update, display, layer, dest_rect, src, src_rect, protection, alpha, clamp, transform)
+
+#define vc_dispmanx_update_start(priority) (*wr_vc_dispmanx_update_start)(priority)
+
+#define vc_dispmanx_update_submit_sync(update) (*wr_vc_dispmanx_update_submit_sync)(update)
+
+#define vc_dispmanx_resource_read_data(handle, p_rect, dst_address, dst_pitch) (*wr_vc_dispmanx_resource_read_data) (handle, p_rect, dst_address, dst_pitch)
+
+#define vc_dispmanx_resource_write_data(res, src_type, src_pitch, src_address, rect) (*wr_vc_dispmanx_resource_write_data)(res, src_type,src_pitch, src_address, rect)
+
+#define vc_dispmanx_element_remove(update, element) (*wr_vc_dispmanx_element_remove) (update, element)
+
+#define vc_dispmanx_element_change_attributes(update, element, change_flags, layer, opacity, dest_rect, src_rect, mask, transform) (*wr_vc_dispmanx_element_change_attributes) (update, element, change_flags, layer, opacity, dest_rect, src_rect, mask, transform)
+
+#define vc_dispmanx_resource_create(type, width, height, native_image_handle) (*wr_vc_dispmanx_resource_create) (type, width, height, native_image_handle)
+
+#define vc_dispmanx_resource_delete(res) (*wr_vc_dispmanx_resource_delete)(res )
+
+#define vc_dispmanx_snapshot(display, snapshot_resource, transform) (*wr_vc_dispmanx_snapshot) (display, snapshot_resource, transform )
+
+#define vc_dispmanx_element_change_source(update, element, src) (*wr_vc_dispmanx_element_change_source) (update, element, src )
+
+/* wrapped method declarations */
+
+WRAPPEDAPI int (*wr_vc_dispmanx_display_close)(DISPMANX_DISPLAY_HANDLE_T display);
+
+WRAPPEDAPI DISPMANX_DISPLAY_HANDLE_T (*wr_vc_dispmanx_display_open)
+                                      (uint32_t device);
+
+WRAPPEDAPI DISPMANX_ELEMENT_HANDLE_T (*wr_vc_dispmanx_element_add) 
+                                      (DISPMANX_UPDATE_HANDLE_T update,
+                                       DISPMANX_DISPLAY_HANDLE_T display,
+                                       int32_t layer, const VC_RECT_T *dest_rect, 
+                                       DISPMANX_RESOURCE_HANDLE_T src,
+                                       const VC_RECT_T *src_rect, 
+                                       DISPMANX_PROTECTION_T protection,
+                                       VC_DISPMANX_ALPHA_T *alpha, 
+                                       DISPMANX_CLAMP_T *clamp, 
+                                       DISPMANX_TRANSFORM_T transform);
+
+WRAPPEDAPI DISPMANX_UPDATE_HANDLE_T (*wr_vc_dispmanx_update_start)
+                                     (int32_t priority);
+
+WRAPPEDAPI int (*wr_vc_dispmanx_update_submit_sync)
+                (DISPMANX_UPDATE_HANDLE_T update);
+
+WRAPPEDAPI int (*wr_vc_dispmanx_resource_read_data)
+                (DISPMANX_RESOURCE_HANDLE_T handle,
+                 const VC_RECT_T *p_rect, void *dst_address, uint32_t dst_pitch);
+
+WRAPPEDAPI int (*wr_vc_dispmanx_resource_write_data)
+                (DISPMANX_RESOURCE_HANDLE_T res, VC_IMAGE_TYPE_T src_type,
+                 int src_pitch, void *src_address, const VC_RECT_T *rect);
+
+WRAPPEDAPI int (*wr_vc_dispmanx_element_remove)
+                (DISPMANX_UPDATE_HANDLE_T update,
+                 DISPMANX_ELEMENT_HANDLE_T element);
+
+WRAPPEDAPI int (*wr_vc_dispmanx_element_change_attributes)
+                (DISPMANX_UPDATE_HANDLE_T update,
+                 DISPMANX_ELEMENT_HANDLE_T element, uint32_t change_flags,
+                 int32_t layer, uint8_t opacity, const VC_RECT_T *dest_rect,
+                 const VC_RECT_T *src_rect, DISPMANX_RESOURCE_HANDLE_T mask,
+                 VC_IMAGE_TRANSFORM_T transform);
+
+WRAPPEDAPI DISPMANX_RESOURCE_HANDLE_T (*wr_vc_dispmanx_resource_create)
+                                       (VC_IMAGE_TYPE_T type, uint32_t width, 
+                                        uint32_t height, 
+                                        uint32_t *native_image_handle);
+
+WRAPPEDAPI int (*wr_vc_dispmanx_resource_delete)
+                (DISPMANX_RESOURCE_HANDLE_T res);
+
+WRAPPEDAPI int (*wr_vc_dispmanx_snapshot) (DISPMANX_DISPLAY_HANDLE_T display, 
+                DISPMANX_RESOURCE_HANDLE_T snapshot_resource,
+                VC_IMAGE_TRANSFORM_T transform);
+
+WRAPPEDAPI int (*wr_vc_dispmanx_element_change_source)
+                (DISPMANX_UPDATE_HANDLE_T update, 
+                 DISPMANX_ELEMENT_HANDLE_T element,
+                 DISPMANX_RESOURCE_HANDLE_T src);
+
+WRAPPEDAPI int (*wr_vc_dispmanx_display_get_info)(DISPMANX_DISPLAY_HANDLE_T display, DISPMANX_MODEINFO_T *pinfo);
+
+#endif // __WRAPPED_BCM__
+#endif // USE_DISPMAN
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/graphics/src/main/native-glass/lens/lensport/wrapped_functions.c	Tue Oct 22 18:00:28 2013 -0400
@@ -0,0 +1,335 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * an EGL library wrapper
+ *
+ * The why of this GL/EGL library wrapper:
+ * Vendors provide very different versions of the libraries, and linking
+ * directly with those libraries introduces a loader depenancy chain.
+ * But using this wrapper allows us to avoid this at the code of loading
+ * all the symbols needed at runtime and one level of indirection.
+ *
+ * to use, simply link this file, as well as the provided stub versions of -lEGL -lGLESv2
+ * call openNativeFramebuffer() to get the NativeDisplayType and the NativeWindowType
+ * that match the platform.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/fb.h>
+#include <fcntl.h>
+#include <dlfcn.h>
+#include <sys/ioctl.h>
+
+#include <string.h>
+#include <strings.h>
+
+#include "lensPort.h"
+
+#include <EGL/egl.h>
+
+#ifdef USE_DISPMAN
+//Broadcom specials
+
+#ifndef BCM_HOST_H
+#include "bcm_host.h"
+#endif
+
+#define WRAPPEDAPI
+#include "wrapped_bcm.h"
+static void (*wr_bcm_host_init)(void);
+#endif /* USE_DISPMAN */
+
+//Vivante specials
+static EGLNativeDisplayType (*wr_fbGetDisplayByIndex)(int DisplayIndex);
+static EGLNativeWindowType (*wr_fbCreateWindow)(EGLNativeDisplayType Display, int X, int Y, int Width, int Height);
+int useDispman = 0;
+int useVivanteFB = 0;
+
+#define DEBUG
+#ifdef DEBUG
+
+// This method is good for early debug, but is unneeded for general use
+static void *get_check_symbol(void *handle, const char *name) {
+    void *ret = dlsym(handle, name);
+    if (!ret) {
+        fprintf(stderr, "failed to load symbol %s\n", name);
+    }
+    return ret;
+}
+#define GET_SYMBOL(handle,name) get_check_symbol(handle,name)
+
+#else // #ifdef DEBUG
+
+#define GET_SYMBOL(handle,name) dlsym(handle,name)
+
+#endif
+
+void *libglesv2;
+void *libegl;
+
+
+/***************************** Special cases  ***************************/
+
+static EGLDisplay(*_eglGetDisplay)(EGLNativeDisplayType display_id);
+
+EGLDisplay util_wr_eglGetDisplay(EGLNativeDisplayType display_id) {
+    EGLDisplay ret = (*_eglGetDisplay)(display_id);
+    return ret;
+}
+
+/***************************** EGL *************************************/
+
+static int load_egl_symbols(void *lib) {
+    int error = 0;
+
+    if (!(_eglGetDisplay = GET_SYMBOL(lib, "eglGetDisplay"))) {
+        error++;
+    }
+
+    if (error) {
+        // handle error conditions better ?
+        fprintf(stderr, "failed to load all EGL symbols %d\n", error);
+        return 1;
+    }
+    return 0;
+}
+
+/*************************************** BROADCOM ******************************************/
+
+static int bcm_loaded = 0;
+
+int load_bcm_symbols() {
+#ifdef USE_DISPMAN
+    if (bcm_loaded) {
+        return useDispman;
+    }
+    bcm_loaded = 1;
+
+    void *lib = dlopen("libbcm_host.so", RTLD_LAZY);
+    if (!lib) {
+        return 0;
+    }
+
+    int error = 0;
+
+    if (!(wr_bcm_host_init = dlsym(lib,"bcm_host_init"))) error++;
+    if (!(wr_vc_dispmanx_display_close = dlsym(lib,"vc_dispmanx_display_close"))) error++;
+    if (!(wr_vc_dispmanx_display_open = dlsym(lib,"vc_dispmanx_display_open"))) error++;
+    if (!(wr_vc_dispmanx_display_get_info = dlsym(lib, "vc_dispmanx_display_get_info")))  error++; //
+    if (!(wr_vc_dispmanx_element_add = dlsym(lib,"vc_dispmanx_element_add"))) error++;
+    if (!(wr_vc_dispmanx_update_start = dlsym(lib,"vc_dispmanx_update_start"))) error++;
+    if (!(wr_vc_dispmanx_update_submit_sync = dlsym(lib,"vc_dispmanx_update_submit_sync"))) error++;
+    if (!(wr_vc_dispmanx_resource_write_data = dlsym(lib, "vc_dispmanx_resource_write_data"))) error++;
+    if (!(wr_vc_dispmanx_resource_read_data = dlsym(lib, "vc_dispmanx_resource_read_data"))) error++;
+    if (!(wr_vc_dispmanx_element_remove = dlsym(lib, "vc_dispmanx_element_remove"))) error++;
+    if (!(wr_vc_dispmanx_element_change_attributes = dlsym(lib, "vc_dispmanx_element_change_attributes"))) error++;
+    if (!(wr_vc_dispmanx_resource_create = dlsym(lib, "vc_dispmanx_resource_create"))) error++;
+    if (!(wr_vc_dispmanx_resource_delete = dlsym(lib, "vc_dispmanx_resource_delete"))) error++;
+    if (!(wr_vc_dispmanx_snapshot = dlsym(lib, "vc_dispmanx_snapshot"))) error++;
+    if (!(wr_vc_dispmanx_element_change_source = dlsym(lib, "vc_dispmanx_element_change_source"))) error++;
+
+    if (error) {
+        // handle error conditions better ?
+        fprintf(stderr, "failed to load all bcm_host symbols %d\n", error);
+        return 1;
+    }
+
+    useDispman = 1; 
+
+    return 0;
+#else
+    return 1;
+#endif /* USE_DISPMAN */
+}
+
+static int load_vivante_symbols(void *lib) {
+    int error = 0;
+    if (!(wr_fbGetDisplayByIndex = GET_SYMBOL(lib, "fbGetDisplayByIndex"))) {
+        error++;
+    }
+    if (!(wr_fbCreateWindow = GET_SYMBOL(lib, "fbCreateWindow"))) {
+        error++;
+    }
+    if (error != 0) {
+        fprintf(stderr, "failed to load all Vivante symbols %d\n", error);
+        return 1;
+    }
+    return error;
+}
+static int done_loading_symbols = 0;
+
+/***************************** UTILITY ********************************/
+
+void * util_getLibGLEShandle() {
+    return libglesv2;
+}
+
+int load_wrapped_gles_symbols() {
+
+    if (done_loading_symbols)  {
+        return 0;
+    }
+    done_loading_symbols = 1;
+
+    //Note that there is an order depenacy here - The PI wants GLES first.
+    // Other platfroms needs the RTLD_GLOBAL to resolve symbols correctly.
+
+    libglesv2 = dlopen("libGLESv2.so", RTLD_LAZY | RTLD_GLOBAL);
+    if (!libglesv2) {
+        fprintf(stderr, "Did not find libGLESv2.so %s\n", dlerror());
+        return 0;
+    }
+
+    libegl = dlopen("libEGL.so", RTLD_LAZY | RTLD_GLOBAL);
+    if (!libegl) {
+        fprintf(stderr, "Did not find libEGL.so %s\n", dlerror());
+        return 0;
+    }
+
+    void *libbcm = dlopen("libbcm_host.so", RTLD_LAZY);
+
+    int error = 0;
+
+    if (load_bcm_symbols()) {
+        // useDispman
+    } else if (dlopen("libVIVANTE.so", RTLD_LAZY)) {
+        useVivanteFB = 1;
+        error += load_vivante_symbols(libegl);
+    }
+
+    error += load_egl_symbols(libegl);
+
+    return error;
+}
+
+EGLNativeDisplayType util_getNativeDisplayType() {
+    static EGLNativeDisplayType cachedNativeDisplayType;
+    static int cached = 0;
+
+    if (!done_loading_symbols) {
+        load_wrapped_gles_symbols();
+    }
+
+    if (!cached) {
+        if (useDispman) {
+            cachedNativeDisplayType = EGL_DEFAULT_DISPLAY;
+        } else if (useVivanteFB)  {
+            cachedNativeDisplayType = wr_fbGetDisplayByIndex(0);
+        } else {
+            cachedNativeDisplayType = (EGLNativeDisplayType)NULL;
+        }
+
+        cached ++;
+    }
+
+
+    return cachedNativeDisplayType;
+}
+
+EGLNativeWindowType util_getNativeWindowType() {
+    static NativeWindowType cachedWindowType;
+    static int cached = 0;
+
+    if (!cached) {
+
+        if (!done_loading_symbols) {
+            load_wrapped_gles_symbols();
+        }
+
+        if (useDispman) {
+#ifdef USE_DISPMAN
+
+            EGL_DISPMANX_WINDOW_T *dispmanWindow;
+            DISPMANX_DISPLAY_HANDLE_T display = 0;
+            DISPMANX_ELEMENT_HANDLE_T element;
+            DISPMANX_UPDATE_HANDLE_T update;
+            VC_RECT_T dst = { 0, 0, 0, 0 };
+            VC_RECT_T src = { 0, 0, 0, 0 };
+
+            (*wr_bcm_host_init)();
+
+            dispmanWindow = (EGL_DISPMANX_WINDOW_T *)calloc(sizeof(EGL_DISPMANX_WINDOW_T), 1);
+
+            display = (*wr_vc_dispmanx_display_open)(0 /* LCD */);
+            if (display == 0) {
+                fprintf(stderr, "Dispman: Cannot open display\n");
+                return 0;
+            }
+            int fbFileHandle;
+            struct fb_var_screeninfo screenInfo;
+            fbFileHandle = open("/dev/fb0", O_RDONLY);
+            if (fbFileHandle < 0) {
+                fprintf(stderr, "Cannot open framebuffer\n");
+                return 0;
+            }
+            if (ioctl(fbFileHandle, FBIOGET_VSCREENINFO, &screenInfo)) {
+                fprintf(stderr, "Cannot get screen info\n");
+                return 0;
+            }
+            close(fbFileHandle);
+
+            dst.width = screenInfo.xres;
+            dst.height = screenInfo.yres;
+            src.width = screenInfo.xres << 16;
+            src.height = screenInfo.yres << 16;
+
+            VC_DISPMANX_ALPHA_T alpha;
+            alpha.flags = DISPMANX_FLAGS_ALPHA_FROM_SOURCE;
+            alpha.opacity = 0xff;
+            alpha.mask = (DISPMANX_RESOURCE_HANDLE_T) 0;
+            update = (*wr_vc_dispmanx_update_start)(0);
+            element = (*wr_vc_dispmanx_element_add)(
+                          update,
+                          display,
+                          1 /*layer*/,
+                          &dst,
+                          0 /*src*/,
+                          &src,
+                          DISPMANX_PROTECTION_NONE,
+                          &alpha,
+                          0 /*clamp*/,
+                          0 /*transform*/);
+
+            dispmanWindow->element = element;
+            dispmanWindow->width = screenInfo.xres;
+            dispmanWindow->height = screenInfo.yres;
+            (*wr_vc_dispmanx_update_submit_sync)(update);
+
+            cachedWindowType = (NativeWindowType)dispmanWindow;
+#endif /* USE_DISPMAN */
+        } else if (useVivanteFB)  {
+            cachedWindowType = (*wr_fbCreateWindow)(util_getNativeDisplayType(), 0, 0, 0, 0);
+        } else {
+            cachedWindowType = NULL;      // hence the EGL NULL
+        }
+        cached ++;
+    }
+
+    return cachedWindowType;
+}
+
--- a/modules/graphics/src/main/native-glass/lens/platform-util/dispmanCursor.c	Tue Oct 22 14:31:11 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,514 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
- 
-#include <stdio.h>
-#include <pthread.h>
-#include <semaphore.h>
-#include <unistd.h>
-#include <jni.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <linux/fb.h>
-#include <sys/ioctl.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "LensCommon.h"
-#include "LensLogger.h"
-
-#ifdef USE_DISPMAN
-#include "wrapped_bcm.h"
-
-#define FB_DEVICE "/dev/fb0"
-
-#include "utilInternal.h"
-#include "platformUtil.h"
-
-typedef struct {
-    DISPMANX_ELEMENT_HANDLE_T element;
-    int screenWidth, screenHeight;
-    pthread_t thread;
-    pthread_mutex_t mutex;
-    sem_t semaphore;
-    int x, y;
-    int cursorWidth, cursorHeight;
-    jlong currentCursor;
-    jboolean isVisible;
-} DispManCursor;
-
-
-typedef struct {
-    jint width;
-    jint height;
-    jint x;
-    jint y;
-    DISPMANX_RESOURCE_HANDLE_T resource;
-} DispmanCursorImage;
-
-
-static DispManCursor cursor;
-
-static void *fbCursorUpdater(void *data);
-static void fbDispmanAddDispmanxElement(void);
-static void fbDispmanRemoveDispmanxElement(void);
-
-
-static void fbDispmanSetNativeCursor(jlong nativeCursorHandle) {
-
-    DISPMANX_UPDATE_HANDLE_T update;
-    DispmanCursorImage *cursorImage = (DispmanCursorImage *)jlong_to_ptr(nativeCursorHandle);
-
-    if (cursorImage != NULL && cursor.element != 0) {
-
-        if (cursorImage->width != cursor.cursorWidth ||
-                cursorImage->height != cursor.cursorHeight) {
-
-            fbDispmanRemoveDispmanxElement();
-
-            cursor.cursorWidth = cursorImage->width;
-            cursor.cursorHeight = cursorImage->height;
-
-            fbDispmanAddDispmanxElement();
-        }
-        cursor.currentCursor = nativeCursorHandle;
-
-        if (cursor.isVisible) {
-            update = vc_dispmanx_update_start(0);
-            vc_dispmanx_element_change_source(update, cursor.element, cursorImage->resource);
-            vc_dispmanx_update_submit_sync(update);
-        }
-
-    }
-}
-
-
-static void fbDispmanAddDispmanxElement(void) {
-
-    DISPMANX_DISPLAY_HANDLE_T display = 0;
-    DISPMANX_UPDATE_HANDLE_T update;
-    VC_DISPMANX_ALPHA_T alpha;
-    VC_RECT_T dst;
-    VC_RECT_T src = { 0, 0, cursor.cursorWidth << 16, cursor.cursorHeight << 16};
-    VC_RECT_T pixelRect = { 0, 0, cursor.cursorWidth, cursor.cursorHeight };
-    int rc;
-
-    display = vc_dispmanx_display_open(0 /* LCD */);
-    if (display == 0) {
-        GLASS_LOG_SEVERE("Cannot open display");
-        return;
-    }
-
-    update = vc_dispmanx_update_start(0);
-    alpha.flags = DISPMANX_FLAGS_ALPHA_FROM_SOURCE;
-    alpha.opacity = 0xff;
-    alpha.mask = (DISPMANX_RESOURCE_HANDLE_T) 0;
-    dst.x = cursor.x;
-    dst.y = cursor.y;
-    dst.width = cursor.cursorWidth;
-    dst.height = cursor.cursorHeight;
-    cursor.element = vc_dispmanx_element_add(
-                         update,
-                         display,
-                         2 /*layer*/,
-                         &dst,
-                         0 /*resource*/,
-                         &src,
-                         DISPMANX_PROTECTION_NONE,
-                         &alpha,
-                         0 /*clamp*/,
-                         0 /*transform*/);
-
-    vc_dispmanx_update_submit_sync(update);
-
-}
-
-
-static void fbDispmanRemoveDispmanxElement(void) {
-
-    if (cursor.element) {
-        DISPMANX_UPDATE_HANDLE_T update;
-        update = vc_dispmanx_update_start(0);
-        vc_dispmanx_element_remove(update, cursor.element);
-        vc_dispmanx_update_submit_sync(update);
-
-        cursor.element = 0;
-    }
-}
-
-static void fbDispmanCursorInitialize(int screenWidth, int screenHeight) {
-
-    // Init cursor fields
-    cursor.element = 0;
-    cursor.cursorWidth = 16;
-    cursor.cursorHeight = 16;
-    cursor.x = 0;
-    cursor.y = 0;
-    cursor.currentCursor = 0;
-    cursor.isVisible = 0;
-
-    cursor.screenWidth = screenWidth;
-    cursor.screenHeight = screenHeight;
-
-    fbDispmanAddDispmanxElement();
-
-    sem_init(&cursor.semaphore, 0, 0);
-    pthread_mutex_init(&cursor.mutex, NULL);
-    pthread_create(&cursor.thread, NULL, fbCursorUpdater, NULL);
-
-}
-
-
-static jlong fbDispmanCreateNativeCursor(JNIEnv *env, jint x, jint y,  jbyte *srcArray, jint width, jint height) {
-
-    VC_RECT_T pixelRect;
-    int rc;
-    uint32_t imagePtr;
-    jbyte *allocatedBuffer = NULL;
-    DispmanCursorImage *cursorImage = (DispmanCursorImage *)malloc(sizeof(DispmanCursorImage));
-
-    //Width should be aligned to 16 pixels
-    if (width % 16 != 0) {
-        int newWidth = width + 16 - (width % 16);
-        allocatedBuffer = (jbyte *)malloc(newWidth * height * 4);
-        int i;
-        int offset = 0;
-        for (i = 0; i < height; ++i) {
-            memcpy(allocatedBuffer + offset, srcArray, width * 4);
-            memset(allocatedBuffer + offset + (width * 4), 0, (newWidth - width) * 4);
-            offset += newWidth * 4;
-            srcArray += width * 4;
-        }
-
-        width = newWidth;
-        srcArray = allocatedBuffer;
-    }
-
-    pixelRect.x = 0;
-    pixelRect.y = 0;
-    pixelRect.width = width;
-    pixelRect.height = height;
-
-    cursorImage->x = x;
-    cursorImage->y = y;
-    cursorImage->width = width;
-    cursorImage->height = height;
-    cursorImage->resource = vc_dispmanx_resource_create(VC_IMAGE_ARGB8888,
-                            width,
-                            height,
-                            &imagePtr);
-    if (cursorImage->resource == 0) {
-        GLASS_LOG_SEVERE("Cannot create resource");
-        if (allocatedBuffer != NULL) {
-            free(allocatedBuffer);
-            allocatedBuffer = NULL;
-        }
-        free(cursorImage);
-        return 0;
-    }
-
-    rc = vc_dispmanx_resource_write_data(cursorImage->resource,
-                                         VC_IMAGE_ARGB8888,
-                                         width * 4,
-                                         srcArray,
-                                         &pixelRect);
-
-    if (allocatedBuffer != NULL) {
-        free(allocatedBuffer);
-        allocatedBuffer = NULL;
-    }
-
-    if (rc != 0) {
-        GLASS_LOG_SEVERE("Cannot write pixels");
-        free(cursorImage);
-        return 0;
-    }
-
-    return ptr_to_jlong(cursorImage);
-}
-
-
-
-
-static void fbDispmanReleaseNativeCursor(jlong nativeCursorHandle) {
-
-    DispmanCursorImage *cursorImage = (DispmanCursorImage *)jlong_to_ptr(nativeCursorHandle);
-
-    if (cursorImage != NULL && cursorImage->resource != 0) {
-        if (cursor.currentCursor == nativeCursorHandle && cursor.isVisible) {
-            DISPMANX_UPDATE_HANDLE_T update;
-            update = vc_dispmanx_update_start(0);
-            vc_dispmanx_element_change_source(update, 
-                                              cursor.element, 0 /* resource*/);
-            vc_dispmanx_update_submit_sync(update);
-        }
-        vc_dispmanx_resource_delete(cursorImage->resource);
-    }
-
-    free(cursorImage);
-    if (cursor.currentCursor == nativeCursorHandle) {
-        cursor.currentCursor = 0;
-    }
-}
-
-
-static void fbDispmanSetVisible(jboolean isVisible) {
-
-    if (isVisible) {
-        if (!cursor.isVisible && cursor.currentCursor != 0) {
-            fbDispmanSetNativeCursor(cursor.currentCursor);
-            DispmanCursorImage *cursorImage = 
-                (DispmanCursorImage *)jlong_to_ptr(cursor.currentCursor);
-            DISPMANX_UPDATE_HANDLE_T update = vc_dispmanx_update_start(0);
-            vc_dispmanx_element_change_source(update, cursor.element, 
-                                              cursorImage->resource);
-            vc_dispmanx_update_submit_sync(update);
-        }
-    } else {
-        DISPMANX_UPDATE_HANDLE_T update;
-        update = vc_dispmanx_update_start(0);
-        vc_dispmanx_element_change_source(update, cursor.element, 0 );
-        vc_dispmanx_update_submit_sync(update);
-    }
-    cursor.isVisible = isVisible;
-}
-
-
-
-static void *fbCursorUpdater(void *data) {
-    while (1) {
-        DISPMANX_UPDATE_HANDLE_T update;
-        VC_RECT_T dst;
-        sem_wait(&cursor.semaphore);
-        pthread_mutex_lock(&cursor.mutex);
-        dst.x = cursor.x;
-        dst.y = cursor.y;
-        dst.width = cursor.cursorWidth;
-        dst.height = cursor.cursorHeight;
-        pthread_mutex_unlock(&cursor.mutex);
-        update = vc_dispmanx_update_start(0);
-        vc_dispmanx_element_change_attributes(update,
-                                              cursor.element,
-                                              0x4 ,
-                                              0 , 0, 
-                                              &dst,
-                                              0 ,
-                                              0 , 0 );
-        vc_dispmanx_update_submit_sync(update);
-        usleep(16666); /* sleep a sixtieth of a second before moving again */
-    }
-    return NULL;
-}
-
-static void fbDispmanCursorSetPosition(int x, int y) {
-
-    if (cursor.element) {
-        int posted;
-        pthread_mutex_lock(&cursor.mutex);
-        cursor.x = x;
-        cursor.y = y;
-        sem_getvalue(&cursor.semaphore, &posted);
-        pthread_mutex_unlock(&cursor.mutex);
-        if (posted == 0) {
-            sem_post(&cursor.semaphore);
-        }
-    } else {
-        cursor.x = x;
-        cursor.y = y;
-    }
-}
-
-static void _fbDispmanCursorClose() {
-
-    fbDispmanRemoveDispmanxElement();
-    cursor.isVisible = 0;
-}
-
-static jboolean fbDispmanRobotScreenCapture(jint x, jint y,
-                                            jint width, jint height,
-                                            jint *pixels) {
-    FILE *fb;
-    unsigned int *pixelBuffer = NULL;
-    unsigned char *pixelBufferPtr = NULL;
-    unsigned char *dst = (unsigned char *) pixels;
-    int i = 0;
-    int fbFileHandle;
-    struct fb_var_screeninfo screenInfo;
-    unsigned int dstByteStride = width * 4;
-    VC_IMAGE_TRANSFORM_T transform = 0;
-    DISPMANX_RESOURCE_HANDLE_T resource = 0;
-    DISPMANX_DISPLAY_HANDLE_T display = 0;
-    DISPMANX_RESOURCE_HANDLE_T screenResource = 0;
-    uint32_t imagePtr;
-    int rc;
-
-    GLASS_LOG_FINE("Capture %i,%i+%ix%i", x, y, width, height);
-
-    if (width < 1 || height < 1) {
-        GLASS_LOG_SEVERE("Failed. width/height values must be at least = 1");
-        return JNI_FALSE;
-    }
-
-    GLASS_LOG_FINE("open(%s, O_RDONLY)", FB_DEVICE);
-    fbFileHandle = open(FB_DEVICE, O_RDONLY);
-    if (fbFileHandle < 0) {
-        GLASS_LOG_SEVERE("Cannot open framebuffer");
-        return JNI_FALSE;
-    }
-
-    GLASS_LOG_FINE("ioctl(%s, FBIOGET_VSCREENINFO)", FB_DEVICE);
-    if (ioctl(fbFileHandle, FBIOGET_VSCREENINFO, &screenInfo)) {
-        GLASS_LOG_SEVERE("Cannot get screen info");
-        GLASS_LOG_FINE("close(%s)", FB_DEVICE);
-        close(fbFileHandle);
-        return JNI_FALSE;
-    }
-    GLASS_LOG_FINE("Read screen info: res=%ix%i, offset=%ix%i",
-                   screenInfo.xres, screenInfo.yres,
-                   screenInfo.xoffset, screenInfo.yoffset);
-    GLASS_LOG_FINE("close(%s)", FB_DEVICE);
-    close(fbFileHandle);
-
-    VC_RECT_T pixelRect = { 0, 0, screenInfo.xres, screenInfo.yres };
-
-    int pixelBufferLength = screenInfo.xres * screenInfo.yres * 4;
-    pixelBuffer = (unsigned int *) malloc(pixelBufferLength);
-    pixelBufferPtr = (unsigned char *) pixelBuffer;
-
-    if (pixelBuffer == NULL) {
-        printf("Failed to allocate temporary pixel buffer\n");
-        return JNI_FALSE;
-    }
-
-    GLASS_LOG_FINE("fopen(%s, \"r\") to read %ix%i pixels at bit depth %i\n",
-                   FB_DEVICE, width, height, screenInfo.bits_per_pixel);
-
-    display = vc_dispmanx_display_open(0 /* LCD */);
-    if (display == 0) {
-        fprintf(stderr, "fbRobotScreenCapture: Dispman: Cannot open display\n");
-        free(pixelBuffer);
-        return JNI_FALSE;
-    }
-
-    // create the resource for the snapshot
-    screenResource = vc_dispmanx_resource_create(VC_IMAGE_ARGB8888, screenInfo.xres, screenInfo.yres, &imagePtr);
-    if (!screenResource) {
-        fprintf(stderr, "fbRobotScreenCapture: Cannot create resource\n");
-        vc_dispmanx_display_close(display);
-        free(pixelBuffer);
-        return JNI_FALSE;
-    }
-
-    rc = vc_dispmanx_snapshot(display, screenResource, transform);
-    rc = 0;
-    if (rc) {
-        fprintf(stderr, "fbRobotScreenCapture: snapshot failed\n");
-        vc_dispmanx_display_close(display);
-        free(pixelBuffer);
-        return JNI_FALSE;
-    }
-
-    rc = vc_dispmanx_resource_read_data(screenResource, &pixelRect, pixelBuffer, screenInfo.xres * 4);
-
-    if (rc) {
-        fprintf(stderr, "fbRobotScreenCapture: Cannot read pixels %d\n", rc);
-        vc_dispmanx_display_close(display);
-        free(pixelBuffer);
-        return JNI_FALSE;
-    }
-
-    rc = vc_dispmanx_resource_delete(screenResource);
-    if (rc) {
-        fprintf(stderr, "fbRobotScreenCapture: failed to free buffer %d\n", rc);
-        vc_dispmanx_display_close(display);
-        free(pixelBuffer);
-        return JNI_FALSE;
-    }
-    screenResource = 0;
-
-    if (x < 0) {
-        pixelBuffer += -x;
-        width += x;
-        x = 0;
-    }
-    if (y < 0) {
-        pixelBuffer += -y * (int)screenInfo.xres;
-        height += y;
-        y = 0;
-    }
-
-    int widthLimit = width;
-    int heightLimit = height;
-
-    // Required height is larger than screen's height
-    if ((int) screenInfo.yres < height) {
-        heightLimit = (int) screenInfo.yres;
-    }
-    // Required width is larger than screen's width
-    if ((int) screenInfo.xres < width) {
-        widthLimit = (int) screenInfo.xres;
-    }
-    // Required height is out of range
-    if (((int) screenInfo.yres - y) < height) {
-        heightLimit = (int) screenInfo.yres - y;
-    }
-    // Required width is out of range
-    if (((int) screenInfo.xres - x) < width) {
-        widthLimit = (int) screenInfo.xres - x;
-    }
-
-    if (widthLimit > 0 && heightLimit > 0) {
-        // copy the relevant portion of the screen to the supplied pixel array
-        int offset = y * screenInfo.xres * 4 + x * 4;
-        for (i = 0; i < heightLimit; i++) {
-            memcpy(dst + i * dstByteStride, pixelBufferPtr + offset, widthLimit * 4);
-            offset += screenInfo.xres * 4;
-        }
-    } else {
-        GLASS_LOG_SEVERE("Failed to take a snapshot, some of parameters are illegal");
-        free(pixelBuffer);
-        return JNI_FALSE;
-    }
-
-    vc_dispmanx_display_close(display);
-    free(pixelBuffer);
-    return JNI_TRUE;
-}
-
-void select_dispman() {
-    fbPlatformSetNativeCursor = fbDispmanSetNativeCursor;
-    fbPlatformCursorInitialize = fbDispmanCursorInitialize;
-    fbPlatformCursorSetPosition = fbDispmanCursorSetPosition;
-    fbPlatformCursorClose = _fbDispmanCursorClose;
-    fbPlatformCreateNativeCursor = fbDispmanCreateNativeCursor;
-    fbPlatformReleaseNativeCursor = fbDispmanReleaseNativeCursor;
-    fbPlatformSetVisible = fbDispmanSetVisible;
-    fbRobotScreenCapture = fbDispmanRobotScreenCapture;
-    fbPlatformCursorTranslucency = JNI_TRUE;
-}
-
-#else // !USE_DISPMAN
-void select_dispman() {}
-#endif //USE_DISPMAN
--- a/modules/graphics/src/main/native-glass/lens/platform-util/fbRobot.c	Tue Oct 22 14:31:11 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,152 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-#include <sys/ioctl.h>
-#include <linux/fb.h>
-
-#include "utilInternal.h"
-#include "platformUtil.h"
-
-#include "LensLogger.h"
-
-#ifdef USE_FB_ROBOT
-
-jboolean fbFBRobotScreen(jint x, jint y,
-                                    jint width, jint height,
-                                    jint *pixels) {
-
-    FILE *fb;
-    unsigned char *pixelBuffer = NULL;
-    unsigned char *dst = (unsigned char *) pixels;
-    unsigned int dstByteStride = width * 4;
-    int i = 0;
-    int fbFileHandle;
-    struct fb_var_screeninfo screenInfo;
-    int depth; // pixel size in bytes
-
-    GLASS_LOG_FINE("Capture %i,%i+%ix%i", x, y, width, height);
-    jboolean result = JNI_FALSE;
-
-    if (width < 1 || height < 1) {
-        GLASS_LOG_SEVERE("Failed. width/height values must be at least = 1");
-        return JNI_FALSE;
-    }
-
-    GLASS_LOG_FINE("open(%s, O_RDONLY)", FB_DEVICE);
-    fbFileHandle = open(FB_DEVICE, O_RDONLY);
-    if (fbFileHandle < 0) {
-        GLASS_LOG_SEVERE("Cannot open framebuffer");
-        return JNI_FALSE;
-    }
-    GLASS_LOG_FINE("ioctl(%s, FBIOGET_VSCREENINFO)", FB_DEVICE);
-    if (ioctl(fbFileHandle, FBIOGET_VSCREENINFO, &screenInfo)) {
-        GLASS_LOG_SEVERE("Cannot get screen info");
-        return JNI_FALSE;
-    }
-    GLASS_LOG_FINE("Read screen info: res=%ix%i, offset=%ix%i",
-                   screenInfo.xres, screenInfo.yres,
-                   screenInfo.xoffset, screenInfo.yoffset);
-    GLASS_LOG_FINE("close(%s)", FB_DEVICE);
-    close(fbFileHandle);
-    depth = screenInfo.bits_per_pixel / 8;
-    int pixelBufferLength = screenInfo.xres * screenInfo.yres * depth;
-    pixelBuffer = (unsigned char *) malloc(pixelBufferLength);
-    if (pixelBuffer == NULL) {
-        GLASS_LOG_SEVERE("Failed to allocate temporary pixel buffer");
-        return JNI_FALSE;
-    }
-
-    GLASS_LOG_FINE("fopen(%s, \"r\") to read %ix%i pixels at bit depth %i",
-                   FB_DEVICE, width, height, screenInfo.bits_per_pixel);
-    fb = fopen(FB_DEVICE, "r");
-    if (fb == NULL) {
-        GLASS_LOG_SEVERE("FB: Cannot open framebuffer for reading");
-        free(pixelBuffer);
-        return JNI_FALSE;
-    }
-
-    fseek(fb, screenInfo.yoffset * screenInfo.xres * depth, SEEK_SET);
-    int numRead = fread(pixelBuffer, 1,
-                        pixelBufferLength,
-                        fb);
-
-    if (x < 0) {
-        dst += -x * 4;
-        width += x;
-        x = 0;
-    }
-    if (y < 0) {
-        dst += -y * dstByteStride;
-        height += y;
-        y = 0;
-    }
-
-    int widthLimit = width;
-    int heightLimit = height;
-
-    // Required height is larger than screen's height
-    if ((int) screenInfo.yres < height) {
-        heightLimit = (int) screenInfo.yres;
-    }
-    // Required width is larger than screen's width
-    if ((int) screenInfo.xres < width) {
-        widthLimit = (int) screenInfo.xres;
-    }
-    // Required height is out of range
-    if (((int) screenInfo.yres - y) < height) {
-        heightLimit = (int) screenInfo.yres - y;
-    }
-    // Required width is out of range
-    if (((int) screenInfo.xres - x) < width) {
-        widthLimit = (int) screenInfo.xres - x;
-    }
-
-    if (widthLimit > 0 && heightLimit > 0) {
-        // copy the relevant portion of the screen to the supplied pixel array
-        int offset = y * screenInfo.xres * depth + x * depth;
-        for (i = 0; i < heightLimit; i++) {
-            memcpy(dst + i * dstByteStride, pixelBuffer + offset, widthLimit * depth);
-            offset += screenInfo.xres * depth;
-        }
-    } else {
-        free(pixelBuffer);
-        fclose(fb);
-        GLASS_LOG_FINE("fclose(%s)", FB_DEVICE);
-        GLASS_LOG_SEVERE("Failed to take a snapshot, some of parameters are illegal");
-        return JNI_FALSE;
-    }
-
-    free(pixelBuffer);
-    GLASS_LOG_FINE("fclose(%s)", FB_DEVICE);
-    fclose(fb);
-    return JNI_TRUE;
-}
-
-#endif // USE_FB_ROBOT
--- a/modules/graphics/src/main/native-glass/lens/platform-util/imx6Cursor.c	Tue Oct 22 14:31:11 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,360 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
- 
-#ifdef IMX6_PLATFORM
-
-#include <stdio.h>
-#include <fcntl.h>
-#include <linux/fb.h>
-#include <sys/ioctl.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <dlfcn.h>
-#include <errno.h>
-#include <linux/mxcfb.h>
-#include "LensCommon.h"
-#include "platformUtil.h"
-
-
-#define RGB565TOCOLORKEY(rgb)                              \
-      ( ((rgb & 0xf800)<<8)  |  ((rgb & 0xe000)<<3)  |     \
-        ((rgb & 0x07e0)<<5)  |  ((rgb & 0x0600)>>1)  |     \
-        ((rgb & 0x001f)<<3)  |  ((rgb & 0x001c)>>2)  )  
-
-
-#define LENSFB_IMX6_CURSOR_DEVICE "/dev/fb1"
-#define LENSFB_IMX6_CURSOR_COLOR_KEY 0xABAB
-#define LENSFB_IMX6_CURSOR_SIZE 16
-
-typedef struct {
-    int fd;
-    int width;
-    int height;
-    int x,y;
-    int screenWidth;
-    int screenHeight;
-    jlong currentCursor;
-    jboolean isVisible;
-} Imx6FBCursor;
-
-static Imx6FBCursor cursor = { .fd = -1, .width = 0, .height = 0, .x = 0, .y = 0, .currentCursor = 0, .isVisible = 0};
-
-//TODO : platform supports 32 and 16 bits, how do we choose what to use ?
-static int use32bit = 0;
-
-typedef struct {
-    jint width;
-    jint height;
-    jint x;
-    jint y;
-    jbyte* buffer;
-    jint bufferSize;
-} Imx6CursorImage;
-
-
-static int fbImx6ChangeCursorSize(int width, int height) {
-
-    struct fb_var_screeninfo screenInfo;
-    if (ioctl(cursor.fd, FBIOGET_VSCREENINFO, &screenInfo)) {
-        GLASS_LOG_SEVERE("Error %s in getting screen info", strerror(errno));
-        return -1;
-    }
-
-    screenInfo.xres = width;
-    screenInfo.yres = height;
-    screenInfo.xres_virtual = 0;
-    screenInfo.yres_virtual = 0;
-    screenInfo.xoffset = 0;
-    screenInfo.yoffset = 0;
-    screenInfo.activate = 0;
-
-    if(ioctl(cursor.fd, FBIOPUT_VSCREENINFO, &screenInfo)) {
-        GLASS_LOG_SEVERE("Error %s in setting screen info", strerror(errno));
-        return -1;
-    }
-
-    cursor.width = width;
-    cursor.height = height;
-
-    return 0;
-}
-
-
-
-static void fbImx6CursorInitialize(int screenWidth, int screenHeight) {
-
-    struct fb_var_screeninfo screenInfo;
-    int rc;
-    char * zero = "0\n";
-    int fbc = -1;
-    int fbo = -1;
- 
-    //TODO : the following 2 settings can be moved to a setup script procedure
-    if ((fbc = open("/sys/class/graphics/fbcon/cursor_blink",O_RDWR)) < 0) {
-        GLASS_LOG_SEVERE("Error %s in opening /sys/class/graphics/fbcon/cursor_blink", strerror(errno));
-    } else {
-        write(fbc,zero,1);
-        close(fbc);
-    }
-    if ((fbo = open("/sys/class/graphics/fb1/blank", O_RDWR)) < 0) {
-        GLASS_LOG_SEVERE("Error %s in opening /sys/class/graphics/fb1/blank", strerror(errno));
-    } else {
-        write(fbo,zero,1);
-        close(fbo);
-    }
-
-    // Init cursor global variable fields
-    cursor.width = LENSFB_IMX6_CURSOR_SIZE;
-    cursor.height = LENSFB_IMX6_CURSOR_SIZE;
-    cursor.x = 0;
-    cursor.y = 0;
-    cursor.currentCursor = 0;
-    cursor.isVisible = 0;
-    cursor.screenWidth = screenWidth;
-    cursor.screenHeight = screenHeight;
-
-    cursor.fd = open(LENSFB_IMX6_CURSOR_DEVICE, O_RDWR);
-    if (cursor.fd < 0) {
-        GLASS_LOG_SEVERE("Cannot open framebuffer device %s",LENSFB_IMX6_CURSOR_DEVICE);
-        return;
-    }
-
-    if (ioctl(cursor.fd, FBIOGET_VSCREENINFO, &screenInfo)) {
-        GLASS_LOG_SEVERE("Error %s in getting screen info", strerror(errno));
-        return;
-    }
-
-    GLASS_LOG_INFO("Initializing %d bits pixel %dx%d cursor, current %d bits\n",
-                   (use32bit ? 32 : 16), LENSFB_IMX6_CURSOR_SIZE, LENSFB_IMX6_CURSOR_SIZE, screenInfo.bits_per_pixel);
-
-    screenInfo.xres = LENSFB_IMX6_CURSOR_SIZE;
-    screenInfo.yres = LENSFB_IMX6_CURSOR_SIZE;
-    screenInfo.xres_virtual = 0;
-    screenInfo.yres_virtual = 0;
-    screenInfo.xoffset = 0;
-    screenInfo.yoffset = 0;
-    screenInfo.activate = 0;
-
-    if (use32bit) {
-        screenInfo.bits_per_pixel = 32;
-        screenInfo.red.length = 8;
-        screenInfo.red.offset = 16;
-        screenInfo.green.length = 8;
-        screenInfo.green.offset = 8;
-        screenInfo.blue.length = 8;
-        screenInfo.blue.offset = 0;
-        screenInfo.transp.length = 8;
-        screenInfo.transp.offset = 24;
-    }  else {
-        // 565
-        screenInfo.bits_per_pixel = 16;
-        screenInfo.red.length = 5;
-        screenInfo.red.offset = 11;
-        screenInfo.green.length = 6;
-        screenInfo.green.offset = 5;
-        screenInfo.blue.length = 5;
-        screenInfo.blue.offset = 0;
-        screenInfo.transp.length = 0;
-        screenInfo.transp.offset = 0;
-    }
-
-    if(ioctl(cursor.fd, FBIOPUT_VSCREENINFO, &screenInfo)) {
-        GLASS_LOG_SEVERE("Error %s in setting screen info", strerror(errno));
-        return;
-    }
-
-    if(ioctl(cursor.fd, FBIOBLANK, FB_BLANK_UNBLANK)) {
-         GLASS_LOG_SEVERE("Error %s in gstting cursor no-blanking", strerror(errno));
-         return;
-    }
-
-
-    if (use32bit) {
-        // alpha is taken from each pixel
-        struct mxcfb_loc_alpha loc_alpha;
-        loc_alpha.enable = 1;
-        loc_alpha.alpha_in_pixel = 1;
-        if (ioctl(cursor.fd, MXCFB_SET_LOC_ALPHA, &loc_alpha) < 0) {
-            GLASS_LOG_SEVERE("Error %s in setting local alpha", strerror(errno));
-        } 
-
-    } else {
-        struct mxcfb_color_key color_key;
-        color_key.color_key = RGB565TOCOLORKEY(LENSFB_IMX6_CURSOR_COLOR_KEY);
-        color_key.enable = 1;
-        if ( ioctl(cursor.fd, MXCFB_SET_CLR_KEY, &color_key) < 0) {
-            GLASS_LOG_SEVERE("Error %s in setting 16 bits color key", strerror(errno));
-        }
-
-        struct mxcfb_gbl_alpha gbl_alpha;
-        gbl_alpha.alpha = 255;
-        gbl_alpha.enable = 1;
-        if(ioctl(cursor.fd, MXCFB_SET_GBL_ALPHA, &gbl_alpha) < 0) {
-              GLASS_LOG_SEVERE("Error %s in setting global alpha", strerror(errno));
-        }
-    }
-
-    struct mxcfb_pos cpos = {(screenWidth - 16)/2, (screenHeight - 16)/2};
-    if (ioctl(cursor.fd, MXCFB_SET_OVERLAY_POS, &cpos)) {
-        GLASS_LOG_SEVERE("Error %s in setting overlay position", strerror(errno));
-    }
-}
-
-
-
-static jlong fbImx6CreateNativeCursor(JNIEnv *env, jint x, jint y,  jbyte *srcArray, jint width, jint height) {
-
-    Imx6CursorImage *cursorImage = (Imx6CursorImage *)malloc(sizeof(Imx6CursorImage));
-    cursorImage->x = x;
-    cursorImage->y = y;
-    cursorImage->width = width;
-    cursorImage->height = height;
-    cursorImage->bufferSize = width * height * (use32bit ? 4 : 2);
-    cursorImage->buffer = (jbyte*)malloc(cursorImage->bufferSize);
-
-    GLASS_LOG_INFO("Creating x : %d y : %d width : %d height : %d cursor %d bits per pixel",x, y, width, height, (use32bit ? 32 : 16));
-
-    if (use32bit) {
-        memcpy((void*)(cursorImage->buffer), srcArray, cursorImage->bufferSize);
-    } else {
-        //565
-        int i;
-        uint16_t* dst = (uint16_t*)(cursorImage->buffer);
-        uint32_t* src = (uint32_t*)srcArray;
-        for (i = 0; i < cursorImage->bufferSize; i += 2) {
-            int pixel = *src++;
-            if ((pixel & 0xff000000) != 0) {
-                *dst++ = ((pixel >> 8) & 0xf800)
-                         | ((pixel >> 5) & 0x7e0)
-                         | ((pixel >> 3) & 0x1f);
-            } else {
-                *dst++ = LENSFB_IMX6_CURSOR_COLOR_KEY;
-            }
-        }
-    }
-
-    return ptr_to_jlong(cursorImage);   
-}
-
-
-static void fbImx6ReleaseNativeCursor(jlong nativeCursorHandle) {
-
-    Imx6CursorImage *cursorImage = (Imx6CursorImage *)jlong_to_ptr(nativeCursorHandle);
-
-    if (cursorImage->buffer != NULL) {
-        free(cursorImage->buffer);
-    }
-
-    free(cursorImage);
-}
-
-
-static void fbImx6SetNativeCursor(jlong nativeCursorHandle) {
-
-    Imx6CursorImage *cursorImage = (Imx6CursorImage *)jlong_to_ptr(nativeCursorHandle);
-
-    if (cursor.fd != -1 && cursor.currentCursor != nativeCursorHandle && 
-        cursorImage != NULL && cursorImage->buffer != NULL) 
-    {
-        if (cursorImage->width != cursor.width || cursorImage->height != cursor.height) {
-            if (fbImx6ChangeCursorSize(cursorImage->width, cursorImage->height)) {
-                GLASS_LOG_SEVERE("Error in fbImx6ChangeCursorSize() w : %d h : %d", cursorImage->width, cursorImage->height);
-                return;
-            }
-        }
-
-        GLASS_LOG_INFO("Writing cursor size %d to fd : %d", cursorImage->bufferSize, cursor.fd);
-        if (write(cursor.fd, cursorImage->buffer, cursorImage->bufferSize) < cursorImage->bufferSize) {
-            GLASS_LOG_SEVERE("Error %s in writing cursor image", strerror(errno));
-            return;
-        }
-
-        cursor.isVisible = 1;
-        cursor.currentCursor = nativeCursorHandle;
-    }
-}
-
-
-
-static void fbImx6CursorSetPosition(int x, int y) {
-
-    cursor.x = x;
-    cursor.y = y;
-
-    if (cursor.isVisible) {
-        struct mxcfb_pos cpos = {x, y};
-        if (ioctl(cursor.fd, MXCFB_SET_OVERLAY_POS, &cpos)) {
-            GLASS_LOG_SEVERE("Error %s in setting overlay position", strerror(errno));
-        }
-    }
-}
-
-
-void fbImx6CursorClose() {
-
-    if (cursor.fd >= 0) {
-        close(cursor.fd);
-        cursor.fd = -1;
-        cursor.isVisible = 0;
-        cursor.currentCursor = 0;
-        cursor.width = 0;
-        cursor.height = 0;
-    }
-}
-
-static void fbImx6SetVisible(jboolean isVisible) {
-    if (isVisible) {
-        if (!cursor.isVisible && cursor.currentCursor != 0) {
-            fbImx6SetNativeCursor(cursor.currentCursor);
-        }
-    } else {
-        if (cursor.isVisible) {
-            write(cursor.fd,"",0);
-        }
-        cursor.isVisible = 0;
-    }
-}
-
-
-jboolean check_imx6_cursor() {
-
-    if (dlopen("libVIVANTE.so", RTLD_LAZY)) {
-        fbPlatformSetNativeCursor = fbImx6SetNativeCursor;
-        fbPlatformCursorInitialize = fbImx6CursorInitialize;
-        fbPlatformCursorSetPosition = fbImx6CursorSetPosition;
-        fbPlatformCursorClose = fbImx6CursorClose;
-        fbPlatformCreateNativeCursor = fbImx6CreateNativeCursor;
-        fbPlatformReleaseNativeCursor = fbImx6ReleaseNativeCursor;
-        fbPlatformSetVisible = fbImx6SetVisible;
-        fbPlatformCursorTranslucency = (use32bit ? JNI_TRUE : JNI_FALSE);
-
-        return JNI_TRUE;
-    } 
-    
-    return JNI_FALSE;
-}
-
-
-#endif // IMX6_PLATFORM
--- a/modules/graphics/src/main/native-glass/lens/platform-util/initPlatform.c	Tue Oct 22 14:31:11 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,124 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-
-// this define causes us to define our static vars in this module
-#define FB_PLATFORM_DECLARE
-
-#include "utilInternal.h"
-#include "platformUtil.h"
-
-//this is a hack until we can figure out how to share between glass/prism/port
-int glass_log_level = 0;
-
-#ifdef USE_DISPMAN
-extern int load_bcm_symbols();
-extern void select_dispman();
-
-static jboolean try_dispman() {
-    if (load_bcm_symbols()) {
-        select_dispman();
-        return JNI_TRUE;
-    } 
-    return JNI_FALSE;
-}
-#else
-static jboolean try_dispman() { return JNI_FALSE; }
-#endif // USE_DISPMAN
-
-
-
-#if defined(OMAP3) || defined(IMX6_PLATFORM)
-extern jboolean fbFBRobotScreen(jint x, jint y,
-                                    jint width, jint height,
-                                    jint *pixels); 
-#endif
-
-#ifdef OMAP3
-extern void select_omap_cursor();
-
-static jboolean try_omap3() { 
-    select_omap_cursor();
-    fbRobotScreenCapture = fbFBRobotScreen;
-    return JNI_TRUE;
-}
-#else
-static jboolean try_omap3() { return JNI_FALSE; }
-#endif
-
-#ifdef ANDROID_NDK
-static jboolean try_android() { return JNI_TRUE; }
-#else
-static jboolean try_android() { return JNI_FALSE; }
-#endif
-
-#ifdef EGL_X11_FB_CONTAINER
-static jboolean try_x11_container() { return JNI_TRUE; }
-#else
-static jboolean try_x11_container() { return JNI_FALSE; }
-#endif
-
-
-#ifdef IMX6_PLATFORM
-extern jboolean check_imx6_cursor();
-static jboolean try_imx6() { 
-    fbRobotScreenCapture = fbFBRobotScreen;
-    return check_imx6_cursor();
-}
-#else
-static jboolean try_imx6() { return JNI_FALSE; }
-#endif
-
-
-void platform_initialize() {
-    if(try_dispman()) {
-       return;
-    }
-
-    //Since the try_omap3() assumes the Beagle is present, 
-    //we will try the imx6 first.
-    if(try_imx6()) {
-        return;
-    }
-
-    if(try_omap3()) {
-        return;
-    }
-
-    if(try_android()) {
-        return;
-    }
-
-    if(try_x11_container()) {
-        return;
-    }
-
-    // Fatal Error
-    fprintf(stderr,"Fatal error loading native porting layer in Lens\n");
-    exit(-1);
-}
- 
--- a/modules/graphics/src/main/native-glass/lens/platform-util/omapCursor.c	Tue Oct 22 14:31:11 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,368 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
- 
-#include "input/LensInput.h"
-
-#include "utilInternal.h"
-#include "platformUtil.h"
-
-#include <fcntl.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <linux/fb.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-
-#if defined(OMAP3)
-
-#include <linux/omapfb.h>
-
-typedef struct {
-    int fd;
-    struct omapfb_plane_info plane;
-    int x;
-    int y;
-    int width;
-    int height;
-    int screenWidth;
-    int screenHeight;
-    jlong currentCursor;
-    jboolean isVisible;
-    // When the cursor is at the extreme right or bottom of the screen, it
-    // needs to be shifted to show in the correct location. OMAP doesn't let us
-    // position the framebuffer so that it is only partically visible.
-    int xShift;
-    int yShift;
-} FBCursor;
-
-typedef struct {
-    int width;
-    int height;
-    int bpp;
-    jbyte *buffer;
-} FBCursorImage;
-
-
-FBCursor cursor = { .fd = -1, .x = 0, .y = 0,
-                    .width = 0, .height = 0,
-                    .currentCursor = 0, .isVisible = 0,
-                    .xShift = 0, .yShift = 0 };
-
-/* Writes an image into the cursor framebuffer with the given x and y offsets. */
-static void fbOmapWriteCursor(int fd, jbyte *cursorImage, int bpp);
-
-/* Updates values of xShift and yShift based on the cursor location */
-static void fbOmapAdjustShift();
-
-void fbOmapCursorClose() {
-    if (cursor.fd >= 0) {
-        cursor.plane.enabled = 0;
-        if (ioctl(cursor.fd, OMAPFB_SETUP_PLANE, &cursor.plane)) {
-            GLASS_LOG_SEVERE("Failed to disable cursor plane");
-        }
-        close(cursor.fd);
-        cursor.fd = -1;
-        cursor.isVisible = 0;
-    }
-}
-
-void fbOmapCreateCursor(jbyte *cursorImage, int width, int height, int bpp) {
-    struct fb_var_screeninfo screenInfo;
-    cursor.width = width;
-    cursor.height = height;
-
-    GLASS_LOG_FINE("open(%s, O_RDWR)", FB_CURSOR_DEVICE);
-    cursor.fd = open(FB_CURSOR_DEVICE, O_RDWR);
-    if (cursor.fd < 0) {
-        GLASS_LOG_SEVERE("Cannot open frame buffer device for cursor");
-        return;
-    }
-    if (ioctl(cursor.fd, FBIOGET_VSCREENINFO, &screenInfo)) {
-        GLASS_LOG_SEVERE("Cannot query screen info");
-        fbOmapCursorClose();
-        return;
-    }
-    screenInfo.xoffset = 0;
-    screenInfo.yoffset = 0;
-    screenInfo.xres = screenInfo.xres_virtual = cursor.width;
-    screenInfo.yres = screenInfo.yres_virtual = cursor.height;
-
-    if (ioctl(cursor.fd, FBIOPUT_VSCREENINFO, &screenInfo)) {
-        GLASS_LOG_SEVERE("Cannot set screen info");
-        fbOmapCursorClose();
-        return;
-    }
-    cursor.plane.enabled = 1;
-    cursor.plane.out_width = cursor.width;
-    cursor.plane.out_height = cursor.height;
-    if (ioctl(cursor.fd, OMAPFB_SETUP_PLANE, &cursor.plane)) {
-        GLASS_LOG_SEVERE("Cannot set plane info");
-        fbOmapCursorClose();
-        return;
-    }
-
-    if (ioctl(cursor.fd, OMAPFB_QUERY_PLANE, &cursor.plane)) {
-        GLASS_LOG_SEVERE("Cannot query plane info");
-        fbOmapCursorClose();
-        return;
-    }
-
-    // Set up the color key
-    struct omapfb_color_key color_key;
-    if (ioctl(cursor.fd, OMAPFB_GET_COLOR_KEY, &color_key)) {
-        GLASS_LOG_SEVERE("Cannot set color key");
-        return;
-    }
-
-    color_key.key_type = OMAPFB_COLOR_KEY_VID_SRC;
-    color_key.trans_key = LENSFB_CURSOR_COLOR_KEY;
-    if (ioctl(cursor.fd, OMAPFB_SET_COLOR_KEY, &color_key)) {
-        GLASS_LOG_SEVERE("OMAPFB_SET_COLOR_KEY");
-        return;
-    }
-
-    fbOmapAdjustShift();
-    fbOmapWriteCursor(cursor.fd, cursorImage, bpp);
-}
-
-static void fbOmapWriteCursor(int fd, jbyte *cursorImage, int bpp) {
-    unsigned i, j, k;
-    char buffer[256];
-    size_t cursorSize = cursor.width * cursor.height * bpp;
-    unsigned xShift = (unsigned) cursor.xShift;
-    unsigned yShift = (unsigned) cursor.yShift;
-    GLASS_LOG_FINEST("Cursor shift = (%i, %i) at (%i, %i)\n",
-                     xShift, yShift, cursor.x, cursor.y);
-    if (xShift == 0 && yShift == 0) {
-        GLASS_LOG_FINEST("write(cursor.fd, .. %i)", cursorSize);
-        if (write(cursor.fd, cursorImage, cursorSize) < (int) cursorSize) {
-            GLASS_LOG_SEVERE("Cannot write cursor plane");
-        }
-        return;
-    }
-    for (i = 0; i < yShift; i++) {
-        for (j = 0; j < (unsigned) cursor.width * bpp; j += sizeof(buffer)) {
-            size_t n = cursor.width * bpp - j;
-            if (n > sizeof(buffer)) {
-                n = sizeof(buffer);
-            }
-            for (k = 0; k < n; k += bpp) {
-                // 171 == 0xAB of the color key.
-                buffer[k] = 171;
-                buffer[k + 1] = 171;
-                buffer[k + 2] = 171;
-                buffer[k + 3] = 171;
-            }
-            GLASS_LOG_FINEST("write(cursor.fd, .. %u)", n);
-            if (write(cursor.fd, buffer, n) < (int) n) {
-                GLASS_LOG_SEVERE("Cannot write cursor plane");
-                return;
-            }
-        }
-    }
-    for (i = 0; i < cursor.height - yShift; i++) {
-        for (j = 0; j < xShift * bpp; j += sizeof(buffer)) {
-            size_t n = xShift * bpp;
-            if (n > sizeof(buffer)) {
-                n = sizeof(buffer);
-            }
-            for (k = 0; k < n; k += bpp) {
-                // 171 == 0xAB of the color key.
-                buffer[k] = 171;
-                buffer[k + 1] = 171;
-                buffer[k + 2] = 171;
-                buffer[k + 3] = 171;
-            }
-            GLASS_LOG_FINEST("write(cursor.fd, .. %u)", n);
-            if (write(cursor.fd, buffer, n) < (int) n) {
-                GLASS_LOG_SEVERE("Cannot write cursor plane");
-                return;
-            }
-        }
-        size_t n = (cursor.width - xShift) * bpp;
-        GLASS_LOG_FINEST("write(cursor.fd, .. %u)", n);
-        if (write(cursor.fd, cursorImage + i * cursor.width * bpp, n) < (int) n) {
-            GLASS_LOG_SEVERE("Cannot write cursor plane");
-            return;
-        }
-    }
-}
-
-jlong fbOmapCreateNativeCursor(JNIEnv *env, jint x, jint y,  jbyte *srcArray, jint width, jint height) {
-    FBCursorImage *cursorImage;
-    int imageSize = width * height * 4;
-    cursorImage = (FBCursorImage *)malloc(sizeof(FBCursorImage) + imageSize);
-
-    cursorImage->width = width;
-    cursorImage->height = height;
-    cursorImage->bpp = 4;
-    cursorImage->buffer = (jbyte *)(cursorImage + 1);
-
-    {
-        int i;
-        for (i = 0; (i + 3) < imageSize; i += 4) {
-            if (srcArray[i + 3] != 0) {
-                cursorImage->buffer[i] = srcArray[i];
-                cursorImage->buffer[i + 1] = srcArray[i + 1];
-                cursorImage->buffer[i + 2] = srcArray[i + 2];
-                cursorImage->buffer[i + 3] = srcArray[i + 3];
-            } else {
-                // 171 == 0xAB of the color key.
-                cursorImage->buffer[i] = 171;
-                cursorImage->buffer[i + 1] = 171;
-                cursorImage->buffer[i + 2] = 171;
-                cursorImage->buffer[i + 3] = 171;
-            }
-        }
-    }
-    return ptr_to_jlong(cursorImage);
-}
-
-void fbOmapCursorInitialize(int screenWidth, int screenHeight) {
-    cursor.screenWidth = screenWidth;
-    cursor.screenHeight = screenHeight;
-}
-
-void fbOmapAdjustShift() {
-    if (cursor.x > cursor.screenWidth - cursor.width) {
-        cursor.xShift = cursor.width + cursor.x - cursor.screenWidth;
-    } else {
-        cursor.xShift = 0;
-    }
-    if (cursor.y > cursor.screenHeight - cursor.height) {
-        cursor.yShift = cursor.height + cursor.y - cursor.screenHeight;
-    } else {
-        cursor.yShift = 0;
-    }
-}
-
-void fbOmapCursorSetPosition(int x, int y) {
-    int xShift = cursor.xShift;
-    int yShift = cursor.yShift;
-    if (x < 0) {
-        x = 0;
-    }
-    if (y < 0) {
-        y = 0;
-    }
-    if (x > cursor.screenWidth - 1) {
-        x = cursor.screenWidth - 1;
-    }
-    if (y > cursor.screenHeight - 1) {
-        y = cursor.screenHeight - 1;
-    }
-    cursor.x = x;
-    cursor.y = y;
-    fbOmapAdjustShift();
-    x -= cursor.xShift;
-    y -= cursor.yShift;
-    if (xShift != cursor.xShift || yShift != cursor.yShift) {
-        GLASS_LOG_FINEST("Calling lseek to rewind cursor fd");
-        if (lseek(cursor.fd, 0, SEEK_SET) == -1) {
-            GLASS_LOG_SEVERE("Cannot rewrite cursor image");
-        } else {
-            FBCursorImage *fbCursorImage = (FBCursorImage *)
-                jlong_to_ptr(cursor.currentCursor);
-            fbOmapWriteCursor(cursor.fd, fbCursorImage->buffer, fbCursorImage->bpp);
-        }
-    }
-    cursor.plane.enabled = 1;
-    cursor.plane.pos_x = x;
-    cursor.plane.pos_y = y;
-    if (cursor.fd >= 0) {
-        if (ioctl(cursor.fd, OMAPFB_SETUP_PLANE, &cursor.plane)) {
-            GLASS_LOG_SEVERE("Cannot set plane info to show cursor at %i,%i", x, y);
-        }
-    }
-}
-
-void fbOmapSetNativeCursor(jlong nativeCursorPointer) {
-    FBCursorImage *cursorImage = (FBCursorImage *)jlong_to_ptr(nativeCursorPointer);
-    if (cursor.currentCursor == nativeCursorPointer) {
-        return;
-    }
-
-    cursor.currentCursor = nativeCursorPointer;
-
-    if (cursor.isVisible) {
-        fbOmapCursorClose();
-        fbOmapCreateCursor(cursorImage->buffer, cursorImage->width, cursorImage->height, cursorImage->bpp);
-        // reset the visibility - because closing the cursor also makes it 
-        // not visible
-        cursor.isVisible = 1;
-    } 
-}
-
-void fbOmapReleaseNativeCursor(jlong nativeCursorPointer) {
-    if (nativeCursorPointer != 0) {
-        FBCursorImage *cursorImage = (FBCursorImage *)jlong_to_ptr(nativeCursorPointer);
-        free(cursorImage);
-    }
-
-    if (cursor.currentCursor == nativeCursorPointer) {
-        fbCursorClose();
-        cursor.currentCursor = 0;
-    }
-}
-
-void fbOmapSetVisible(jboolean isVisible) {
-    if (isVisible) {
-        if (!cursor.isVisible && cursor.currentCursor != 0) {
-            FBCursorImage *cursorImage = 
-                (FBCursorImage *)jlong_to_ptr(cursor.currentCursor);
-            fbOmapCreateCursor(cursorImage->buffer, cursorImage->width, 
-                               cursorImage->height, cursorImage->bpp);
-        }
-    } else {
-        fbOmapCursorClose();
-    }
-
-    cursor.isVisible = isVisible;
-}
-
-
-jboolean fbOmapPlatformCursorTranslucency() {
-    return JNI_FALSE;
-}
-
-void fbOmapCursorTerminate(void) {
-    fbOmapCursorClose();
-}
-
-void select_omap_cursor() {
-    fbPlatformSetNativeCursor = fbOmapSetNativeCursor;
-    fbPlatformCursorInitialize = fbOmapCursorInitialize;
-    fbPlatformCursorSetPosition = fbOmapCursorSetPosition;
-    fbPlatformCursorClose = fbOmapCursorClose;
-    fbPlatformCreateNativeCursor = fbOmapCreateNativeCursor;
-    fbPlatformReleaseNativeCursor = fbOmapReleaseNativeCursor;
-    fbPlatformSetVisible = fbOmapSetVisible;
-    fbPlatformCreateCursor = fbOmapCreateCursor;
-}
-
-#else // !OMAP3
-void select_omap_cursor() { }
-#endif // OMAP3
--- a/modules/graphics/src/main/native-glass/lens/platform-util/platformUtil.h	Tue Oct 22 14:31:11 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include <jni.h>
-
-#define FB_DEVICE "/dev/fb0"
-
-#define FB_CURSOR_DEVICE "/dev/fb1"
-#define LENSFB_CURSOR_COLOR_KEY 0xABABABAB
-
-#if defined(OMAP3)
-#include <linux/omapfb.h>
-#endif
-
-#ifndef FB_PLATFORM_DECLARE
-#define FB_PLATFORM_DECLARE extern
-#endif
-
-// Called to intitialize the platform specific functions.
-// Must be called prior to other utility calls.
-extern void platform_initialize();
-
-// Cursor Specific Entries
-FB_PLATFORM_DECLARE void (*fbPlatformCreateCursor)(jbyte *cursorImage, int width, int height, int bpp);
-FB_PLATFORM_DECLARE void (*fbPlatformSetNativeCursor)(jlong nativeCursorPointer);
-FB_PLATFORM_DECLARE void (*fbPlatformCursorInitialize)(int screenWidth, int screenHeight);
-FB_PLATFORM_DECLARE void (*fbPlatformCursorSetPosition)(int x, int y);
-FB_PLATFORM_DECLARE void (*fbPlatformCursorClose)();
-FB_PLATFORM_DECLARE void (*fbPlatformCursorTerminate)();
-FB_PLATFORM_DECLARE jlong (*fbPlatformCreateNativeCursor)(JNIEnv *env, jint x, jint y,  jbyte *srcArray, jint width, jint height);
-FB_PLATFORM_DECLARE void (*fbPlatformReleaseNativeCursor)(jlong nativeCursorPointer);
-FB_PLATFORM_DECLARE void (*fbPlatformSetVisible)(jboolean isVisible);
-FB_PLATFORM_DECLARE jboolean fbPlatformCursorTranslucency;
-
-// Robot Specific Entries
-FB_PLATFORM_DECLARE jboolean (*fbRobotScreenCapture)(jint x, jint y, jint width, jint height, jint *pixels);
-
-/*
-  todo:
-     extern void load_bcm_symbols();
-     static int loadedBcm = 0;
-     #ifdef USE_DISPMAN
-*/
--- a/modules/graphics/src/main/native-glass/lens/platform-util/utilInternal.h	Tue Oct 22 14:31:11 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#if defined(OMAP3) || defined(IMX6_PLATFORM) 
-# ifndef USE_FB_ROBOT
-    #define USE_FB_ROBOT
-# endif
-#endif
-
--- a/modules/graphics/src/main/native-glass/lens/platform-util/wrapped_bcm.c	Tue Oct 22 14:31:11 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,206 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-#include <stdio.h>
-#include <dlfcn.h>
-
-#define WRAPPEDAPI
-#include "wrapped_bcm.h"
-
-#ifdef USE_DISPMAN
-static int useDispman = 1;
-
-int load_bcm_symbols();
-
-/*************************************** BROADCOM ******************************************/
-void (*_bcm_host_init)(void);
-/*
-static int (*wr_vc_dispmanx_display_close)(DISPMANX_DISPLAY_HANDLE_T display);
-static DISPMANX_DISPLAY_HANDLE_T (*wr_vc_dispmanx_display_open) (uint32_t device);
-static DISPMANX_ELEMENT_HANDLE_T (*wr_vc_dispmanx_element_add) (DISPMANX_UPDATE_HANDLE_T update,
-        DISPMANX_DISPLAY_HANDLE_T display,
-        int32_t layer, const VC_RECT_T *dest_rect, DISPMANX_RESOURCE_HANDLE_T src,
-        const VC_RECT_T *src_rect, DISPMANX_PROTECTION_T protection,
-        VC_DISPMANX_ALPHA_T *alpha, DISPMANX_CLAMP_T *clamp, DISPMANX_TRANSFORM_T transform);
-static DISPMANX_UPDATE_HANDLE_T (*wr_vc_dispmanx_update_start)( int32_t priority);
-static int (*wr_vc_dispmanx_update_submit_sync)(DISPMANX_UPDATE_HANDLE_T update);
-static int (*wr_vc_dispmanx_resource_read_data)(DISPMANX_RESOURCE_HANDLE_T handle,
-                                                      const VC_RECT_T *p_rect, void *dst_address, uint32_t dst_pitch);
-static int (*wr_vc_dispmanx_resource_write_data)(DISPMANX_RESOURCE_HANDLE_T res, VC_IMAGE_TYPE_T src_type,
-                     int src_pitch, void *src_address, const VC_RECT_T *rect);
-static int (*wr_vc_dispmanx_element_remove)(DISPMANX_UPDATE_HANDLE_T update,
-                                                   DISPMANX_ELEMENT_HANDLE_T element);
-static int (*wr_vc_dispmanx_element_change_attributes)(DISPMANX_UPDATE_HANDLE_T update,
-                                                             DISPMANX_ELEMENT_HANDLE_T element,
-                                                             uint32_t change_flags,
-                                                             int32_t layer, uint8_t opacity,
-                                                             const VC_RECT_T *dest_rect,
-                                                             const VC_RECT_T *src_rect,
-                                                             DISPMANX_RESOURCE_HANDLE_T mask,
-                                                             VC_IMAGE_TRANSFORM_T transform);
-static DISPMANX_RESOURCE_HANDLE_T (*wr_vc_dispmanx_resource_create)(VC_IMAGE_TYPE_T type,
-                                                                          uint32_t width, uint32_t height,
-                                                                          uint32_t *native_image_handle);
-static int (*wr_vc_dispmanx_resource_delete)( DISPMANX_RESOURCE_HANDLE_T res );
-static int (*wr_vc_dispmanx_snapshot)(DISPMANX_DISPLAY_HANDLE_T display,
-                                             DISPMANX_RESOURCE_HANDLE_T snapshot_resource,
-                                             VC_IMAGE_TRANSFORM_T transform );
-
-static int (*wr_vc_dispmanx_element_change_source)( DISPMANX_UPDATE_HANDLE_T update, DISPMANX_ELEMENT_HANDLE_T element,
-                                                        DISPMANX_RESOURCE_HANDLE_T src );
-*/
-
-void bcm_host_init(void) {
-    if (!_bcm_host_init) {
-        load_bcm_symbols();
-    }
-    return (*_bcm_host_init)();
-}
-
-/*
-int vc_dispmanx_display_close(DISPMANX_DISPLAY_HANDLE_T display) {
-    return (*wr_vc_dispmanx_display_close)(display);
-}
-
-DISPMANX_DISPLAY_HANDLE_T vc_dispmanx_display_open(uint32_t device) {
-    return (*wr_vc_dispmanx_display_open)(device);
-}
-
-DISPMANX_ELEMENT_HANDLE_T vc_dispmanx_element_add (DISPMANX_UPDATE_HANDLE_T update,
-                                                            DISPMANX_DISPLAY_HANDLE_T display,
-                                                            int32_t layer, const VC_RECT_T *dest_rect,
-                                                            DISPMANX_RESOURCE_HANDLE_T src,
-                                                            const VC_RECT_T *src_rect,
-                                                            DISPMANX_PROTECTION_T protection,
-                                                            VC_DISPMANX_ALPHA_T *alpha,
-                                                            DISPMANX_CLAMP_T *clamp,
-                                                            DISPMANX_TRANSFORM_T transform) {
-
-    return (*wr_vc_dispmanx_element_add) (update, display, layer, dest_rect, src, src_rect, 
-        protection, alpha, clamp, transform);
-}
-
-DISPMANX_UPDATE_HANDLE_T vc_dispmanx_update_start( int32_t priority) {
-    return (*wr_vc_dispmanx_update_start)(priority);
-}
-
-int vc_dispmanx_update_submit_sync(DISPMANX_UPDATE_HANDLE_T update) {
-    return (*wr_vc_dispmanx_update_submit_sync)(update);
-}
-
-int vc_dispmanx_resource_write_data(DISPMANX_RESOURCE_HANDLE_T res, VC_IMAGE_TYPE_T src_type,
-                         int src_pitch, void *src_address, const VC_RECT_T *rect ) {
-    return (*wr_vc_dispmanx_resource_write_data)(res, src_type, src_pitch, src_address, rect);
-}
-
-int vc_dispmanx_resource_read_data(DISPMANX_RESOURCE_HANDLE_T handle,
-                                            const VC_RECT_T *p_rect, void *dst_address, uint32_t dst_pitch) {
-    return (*wr_vc_dispmanx_resource_read_data)(handle, p_rect, dst_address, dst_pitch);
-}
-
-int vc_dispmanx_element_remove(DISPMANX_UPDATE_HANDLE_T update,
-                                                    DISPMANX_ELEMENT_HANDLE_T element) {
-    return (*wr_vc_dispmanx_element_remove)(update, element);
-}
-
-int vc_dispmanx_element_change_attributes(DISPMANX_UPDATE_HANDLE_T update,
-                                                   DISPMANX_ELEMENT_HANDLE_T element, uint32_t change_flags,
-                                                   int32_t layer, uint8_t opacity,
-                                                   const VC_RECT_T *dest_rect,
-                                                   const VC_RECT_T *src_rect,
-                                                   DISPMANX_RESOURCE_HANDLE_T mask,
-                                                   VC_IMAGE_TRANSFORM_T transform) {
-    return (*wr_vc_dispmanx_element_change_attributes)(update, element, change_flags, layer, opacity, dest_rect,
-                                                     src_rect, mask, transform);
-}
-
-DISPMANX_RESOURCE_HANDLE_T vc_dispmanx_resource_create(VC_IMAGE_TYPE_T type,
-                                                                uint32_t width, uint32_t height,
-                                                                uint32_t *native_image_handle) {
-    return (*wr_vc_dispmanx_resource_create)(type, width, height, native_image_handle);
-}
-
-int vc_dispmanx_resource_delete( DISPMANX_RESOURCE_HANDLE_T res ) {
-    return (*wr_vc_dispmanx_resource_delete)(res);
-}
-
-int vc_dispmanx_snapshot(DISPMANX_DISPLAY_HANDLE_T display,
-                                   DISPMANX_RESOURCE_HANDLE_T snapshot_resource,
-                                   VC_IMAGE_TRANSFORM_T transform) {
-    return (*wr_vc_dispmanx_snapshot)(display, snapshot_resource, transform);
-}
-
-int vc_dispmanx_element_change_source(DISPMANX_UPDATE_HANDLE_T update, 
-                                               DISPMANX_ELEMENT_HANDLE_T element,
-                                               DISPMANX_RESOURCE_HANDLE_T src )
-{
-   return  (*wr_vc_dispmanx_element_change_source)(update,element,src);
-}
-*/
-
-int load_bcm_symbols() {
-    int error = 0;
-    void *lib = dlopen("libbcm_host.so", RTLD_NOW); // there is a couple of choices?
-
-    if (_bcm_host_init) {
-        fprintf(stderr,"BCM symbols already loaded\n");
-        // already loaded
-        return useDispman;
-    }
-
-    if (!lib) {
-        useDispman = 0;
-        return useDispman;
-    } else {
-        useDispman = 1;
-    }
-
-    if (!(_bcm_host_init = dlsym(lib,"bcm_host_init"))) error++;
-    if (!(wr_vc_dispmanx_display_close = dlsym(lib,"vc_dispmanx_display_close"))) error++;
-    if (!(wr_vc_dispmanx_display_open = dlsym(lib,"vc_dispmanx_display_open"))) error++;
-    if (!(wr_vc_dispmanx_element_add = dlsym(lib,"vc_dispmanx_element_add"))) error++;
-    if (!(wr_vc_dispmanx_update_start = dlsym(lib,"vc_dispmanx_update_start"))) error++;
-    if (!(wr_vc_dispmanx_update_submit_sync = dlsym(lib,"vc_dispmanx_update_submit_sync"))) error++;
-    if (!(wr_vc_dispmanx_resource_write_data = dlsym(lib, "vc_dispmanx_resource_write_data"))) error++;
-    if (!(wr_vc_dispmanx_resource_read_data = dlsym(lib, "vc_dispmanx_resource_read_data"))) error++;
-    if (!(wr_vc_dispmanx_element_remove = dlsym(lib, "vc_dispmanx_element_remove"))) error++;
-    if (!(wr_vc_dispmanx_element_change_attributes = dlsym(lib, "vc_dispmanx_element_change_attributes"))) error++;
-    if (!(wr_vc_dispmanx_resource_create = dlsym(lib, "vc_dispmanx_resource_create"))) error++;
-    if (!(wr_vc_dispmanx_resource_delete = dlsym(lib, "vc_dispmanx_resource_delete"))) error++;
-    if (!(wr_vc_dispmanx_snapshot = dlsym(lib, "vc_dispmanx_snapshot"))) error++;
-    if (!(wr_vc_dispmanx_element_change_source = dlsym(lib, "vc_dispmanx_element_change_source"))) error++;
-
-    if (error) {
-        // handle error conditions better ?
-        fprintf(stderr,"failed to load all bcm_host symbols %d\n",error);
-        useDispman = 0;
-    }
-    return useDispman;
-}
-#else
-
-int load_bcm_symbols() {
-    return 0;
-}
-#endif /* USE_DISPMAN */
--- a/modules/graphics/src/main/native-glass/lens/platform-util/wrapped_bcm.h	Tue Oct 22 14:31:11 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,131 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-#ifndef __WRAPPED_BCM__
-#define __WRAPPED_BCM__
-
-#ifndef WRAPPEDAPI
-#define WRAPPEDAPI extern
-#endif
-
-#ifdef USE_DISPMAN
-
-#ifndef BCM_HOST_H
-#include <bcm_host.h>
-#endif
-
-#if !defined(_VC_DISPMANX_H_)
-/* for Debian 6.0 libraries */
-typedef enum {
-   VC_IMAGE_ARGB8888 = 43,  /* 32bpp with 8bit alpha at MS byte, with R, G, B (LS byte) */
-} VC_IMAGE_TYPE_T;
-#endif
-
-#define vc_dispmanx_display_close(display) (*wr_vc_dispmanx_display_close)(display)
-
-#define vc_dispmanx_display_open(device) (*wr_vc_dispmanx_display_open)(device)
-
-#define vc_dispmanx_element_add(update, display, layer, dest_rect, src, src_rect, protection, alpha, clamp, transform) (*wr_vc_dispmanx_element_add)(update, display, layer, dest_rect, src, src_rect, protection, alpha, clamp, transform)
-
-#define vc_dispmanx_update_start(priority) (*wr_vc_dispmanx_update_start)(priority)
-
-#define vc_dispmanx_update_submit_sync(update) (*wr_vc_dispmanx_update_submit_sync)(update)
-
-#define vc_dispmanx_resource_read_data(handle, p_rect, dst_address, dst_pitch) (*wr_vc_dispmanx_resource_read_data) (handle, p_rect, dst_address, dst_pitch)
-
-#define vc_dispmanx_resource_write_data(res, src_type, src_pitch, src_address, rect) (*wr_vc_dispmanx_resource_write_data)(res, src_type,src_pitch, src_address, rect)
-
-#define vc_dispmanx_element_remove(update, element) (*wr_vc_dispmanx_element_remove) (update, element)
-
-#define vc_dispmanx_element_change_attributes(update, element, change_flags, layer, opacity, dest_rect, src_rect, mask, transform) (*wr_vc_dispmanx_element_change_attributes) (update, element, change_flags, layer, opacity, dest_rect, src_rect, mask, transform)
-
-#define vc_dispmanx_resource_create(type, width, height, native_image_handle) (*wr_vc_dispmanx_resource_create) (type, width, height, native_image_handle)
-
-#define vc_dispmanx_resource_delete(res) (*wr_vc_dispmanx_resource_delete)(res )
-
-#define vc_dispmanx_snapshot(display, snapshot_resource, transform) (*wr_vc_dispmanx_snapshot) (display, snapshot_resource, transform )
-
-#define vc_dispmanx_element_change_source(update, element, src) (*wr_vc_dispmanx_element_change_source) (update, element, src )
-
-/* wrapped method declarations */
-WRAPPEDAPI int (*wr_vc_dispmanx_display_close)(DISPMANX_DISPLAY_HANDLE_T display);
-
-WRAPPEDAPI DISPMANX_DISPLAY_HANDLE_T (*wr_vc_dispmanx_display_open)
-                                      (uint32_t device);
-
-WRAPPEDAPI DISPMANX_ELEMENT_HANDLE_T (*wr_vc_dispmanx_element_add) 
-                                      (DISPMANX_UPDATE_HANDLE_T update,
-                                       DISPMANX_DISPLAY_HANDLE_T display,
-                                       int32_t layer, const VC_RECT_T *dest_rect, 
-                                       DISPMANX_RESOURCE_HANDLE_T src,
-                                       const VC_RECT_T *src_rect, 
-                                       DISPMANX_PROTECTION_T protection,
-                                       VC_DISPMANX_ALPHA_T *alpha, 
-                                       DISPMANX_CLAMP_T *clamp, 
-                                       DISPMANX_TRANSFORM_T transform);
-
-WRAPPEDAPI DISPMANX_UPDATE_HANDLE_T (*wr_vc_dispmanx_update_start)
-                                     (int32_t priority);
-
-WRAPPEDAPI int (*wr_vc_dispmanx_update_submit_sync)
-                (DISPMANX_UPDATE_HANDLE_T update);
-
-WRAPPEDAPI int (*wr_vc_dispmanx_resource_read_data)
-                (DISPMANX_RESOURCE_HANDLE_T handle,
-                 const VC_RECT_T *p_rect, void *dst_address, uint32_t dst_pitch);
-
-WRAPPEDAPI int (*wr_vc_dispmanx_resource_write_data)
-                (DISPMANX_RESOURCE_HANDLE_T res, VC_IMAGE_TYPE_T src_type,
-                 int src_pitch, void *src_address, const VC_RECT_T *rect);
-
-WRAPPEDAPI int (*wr_vc_dispmanx_element_remove)
-                (DISPMANX_UPDATE_HANDLE_T update,
-                 DISPMANX_ELEMENT_HANDLE_T element);
-
-WRAPPEDAPI int (*wr_vc_dispmanx_element_change_attributes)
-                (DISPMANX_UPDATE_HANDLE_T update,
-                 DISPMANX_ELEMENT_HANDLE_T element, uint32_t change_flags,
-                 int32_t layer, uint8_t opacity, const VC_RECT_T *dest_rect,
-                 const VC_RECT_T *src_rect, DISPMANX_RESOURCE_HANDLE_T mask,
-                 VC_IMAGE_TRANSFORM_T transform);
-
-WRAPPEDAPI DISPMANX_RESOURCE_HANDLE_T (*wr_vc_dispmanx_resource_create)
-                                       (VC_IMAGE_TYPE_T type, uint32_t width, 
-                                        uint32_t height, 
-                                        uint32_t *native_image_handle);
-
-WRAPPEDAPI int (*wr_vc_dispmanx_resource_delete)
-                (DISPMANX_RESOURCE_HANDLE_T res);
-
-WRAPPEDAPI int (*wr_vc_dispmanx_snapshot) (DISPMANX_DISPLAY_HANDLE_T display, 
-                DISPMANX_RESOURCE_HANDLE_T snapshot_resource,
-                VC_IMAGE_TRANSFORM_T transform);
-
-WRAPPEDAPI int (*wr_vc_dispmanx_element_change_source)
-                (DISPMANX_UPDATE_HANDLE_T update, 
-                 DISPMANX_ELEMENT_HANDLE_T element,
-                 DISPMANX_RESOURCE_HANDLE_T src);
-
-#endif // __WRAPPED_BCM__
-#endif // USE_DISPMAN
--- a/modules/graphics/src/main/native-glass/lens/wm/LensWindowManager.c	Tue Oct 22 14:31:11 2013 -0700
+++ b/modules/graphics/src/main/native-glass/lens/wm/LensWindowManager.c	Tue Oct 22 18:00:28 2013 -0400
@@ -35,7 +35,6 @@
 #include <stdio.h>
 #include <pthread.h>
 
-#include "platform-util/platformUtil.h"
 
 static pthread_mutex_t renderMutex = PTHREAD_MUTEX_INITIALIZER;
 
@@ -83,7 +82,7 @@
     jboolean result;
 
     GLASS_LOG_FINE("Init device");
-    platform_initialize();
+    
     result = glass_application_initialize(env);
     if (result) {
         GLASS_LOG_FINE("Init screen");
--- a/modules/graphics/src/main/native-glass/lens/wm/screen/fbdevScreen.c	Tue Oct 22 14:31:11 2013 -0700
+++ b/modules/graphics/src/main/native-glass/lens/wm/screen/fbdevScreen.c	Tue Oct 22 18:00:28 2013 -0400
@@ -37,8 +37,7 @@
 #include <string.h>
 #include <linux/fb.h>
 #include <sys/ioctl.h>
-
-#include "platform-util/platformUtil.h"
+#include <assert.h>
 
 static struct _NativeScreen fbScreen;
 
@@ -323,10 +322,8 @@
                                     jint width, jint height,
                                     jint *pixels) {
 
-    if (fbRobotScreenCapture) {
-       return (*fbRobotScreenCapture)(x, y, width, height, pixels);
-    }
-    return 0;
+    assert (lensPort.robotScreenCapture);
+    return (*lensPort.robotScreenCapture)(x, y, width, height, pixels);
 }
 
 LensResult lens_platform_windowMinimize(JNIEnv *env,
--- a/modules/graphics/src/main/native-prism-es2/eglfb/EGLFBGLContext.c	Tue Oct 22 14:31:11 2013 -0700
+++ b/modules/graphics/src/main/native-prism-es2/eglfb/EGLFBGLContext.c	Tue Oct 22 18:00:28 2013 -0400
@@ -93,7 +93,7 @@
     jboolean vSyncNeeded;
 
     if (!eglMakeCurrent(dInfo->egldisplay, dInfo->eglsurface, dInfo->eglsurface, ctxInfo->context)) {
-        fprintf(stderr, "Failed in eglMakeCurrent for %ld %ld %d\n", dInfo->eglsurface, ctxInfo->context, eglGetError());
+        fprintf(stderr, "Failed in eglMakeCurrent for %p %p %d\n", dInfo->eglsurface, ctxInfo->context, eglGetError());
     }
     vSyncNeeded = ctxInfo->vSyncRequested && dInfo->onScreen;
     if (vSyncNeeded == ctxInfo->state.vSyncEnabled) {
--- a/modules/graphics/src/main/native-prism-es2/eglfb/eglUtils.c	Tue Oct 22 14:31:11 2013 -0700
+++ b/modules/graphics/src/main/native-prism-es2/eglfb/eglUtils.c	Tue Oct 22 18:00:28 2013 -0400
@@ -92,7 +92,7 @@
                                   EGLConfig cfg,
                                   void *nativeWindow) {
     if (sharedWindowSurface == NULL) {
-        EGLNativeWindowType window;
+        EGLNativeWindowType window = 0;
 #if EGL_X11_FB_CONTAINER
         window = (EGLNativeWindowType)nativeWindow;
 #else
@@ -200,8 +200,8 @@
     const char *glVendor = (char *)glGetString(GL_VENDOR);
     const char *glRenderer = (char *)glGetString(GL_RENDERER);
     // Make a copy, at least one platform does not preserve the string beyond the call.
-    const char *glExtensions = strdup((char *)glGetString(GL_EXTENSIONS));
-    const char *eglExtensions = strdup((char *)eglQueryString(dpy, EGL_EXTENSIONS));
+    char *glExtensions = strdup((char *)glGetString(GL_EXTENSIONS));
+    char *eglExtensions = strdup((char *)eglQueryString(dpy, EGL_EXTENSIONS));
 
     /* find out the version, major and minor version number */
     char *tmpVersionStr = strdup(glVersion);
@@ -226,7 +226,7 @@
     free(eglExtensions);
 
     // from the wrapped_egl.c
-    void *handle = libglesv2;
+    void *handle = getLibGLEShandle();
 
     /* set function pointers */
     ctxInfo->glActiveTexture = (PFNGLACTIVETEXTUREPROC)
--- a/modules/graphics/src/main/native-prism-es2/eglfb/wrapped_egl.c	Tue Oct 22 14:31:11 2013 -0700
+++ b/modules/graphics/src/main/native-prism-es2/eglfb/wrapped_egl.c	Tue Oct 22 18:00:28 2013 -0400
@@ -42,288 +42,113 @@
 #include <stdlib.h>
 #include <linux/fb.h>
 #include <fcntl.h>
+#ifndef __USE_GNU // required for dladdr() & Dl_info
+#define __USE_GNU
+#endif
 #include <dlfcn.h>
 #include <sys/ioctl.h>
 
+#include <string.h>
+#include <strings.h>
+
+#if ! ((defined(ANDROID_NDK) || defined(EGL_X11_FB_CONTAINER)))
+#include "lensPort.h"
+#endif
+
 #define WRAPPEDAPI
 #include "wrapped_egl.h"
 
-#ifdef USE_DISPMAN
-//Broadcom specials
+int load_wrapped_gles_symbols(void);
+void *libglesv2;
+void *libegl;
+int done_loading_symbols = 0;
 
-#ifndef BCM_HOST_H
-#include "bcm_host.h"
-#endif
+/***************************** UTILITY ********************************/
 
-static void (*wr_bcm_host_init)(void);
-static  int (*wr_vc_dispmanx_display_close)(DISPMANX_DISPLAY_HANDLE_T display);
-static  int (*wr_vc_dispmanx_display_get_info)(DISPMANX_DISPLAY_HANDLE_T display, DISPMANX_MODEINFO_T *pinfo);
-static  DISPMANX_DISPLAY_HANDLE_T(*wr_vc_dispmanx_display_open)(uint32_t device);
-static  DISPMANX_ELEMENT_HANDLE_T(*wr_vc_dispmanx_element_add)(
-    DISPMANX_UPDATE_HANDLE_T update, DISPMANX_DISPLAY_HANDLE_T display,
-    int32_t layer, const VC_RECT_T *dest_rect, DISPMANX_RESOURCE_HANDLE_T src,
-    const VC_RECT_T *src_rect, DISPMANX_PROTECTION_T protection,
-    VC_DISPMANX_ALPHA_T *alpha, DISPMANX_CLAMP_T *clamp, DISPMANX_TRANSFORM_T transform);
-static  DISPMANX_UPDATE_HANDLE_T(*wr_vc_dispmanx_update_start)(int32_t priority);
-static  int (*wr_vc_dispmanx_update_submit_sync)(DISPMANX_UPDATE_HANDLE_T update);
-#endif /* USE_DISPMAN */
+#ifdef ANDROID_NDK
 
-//Vivante specials
-static EGLNativeDisplayType (*wr_fbGetDisplayByIndex)(int DisplayIndex);
-static EGLNativeWindowType (*wr_fbCreateWindow)(EGLNativeDisplayType Display, int X, int Y, int Width, int Height);
-int useDispman = 0;
-int useVivanteFB = 0;
+static EGLDisplay(*_eglGetDisplay)(EGLNativeDisplayType display_id);
+static EGLNativeWindowType(*_ANDROID_getNativeWindow)();
 
-#define DEBUG
-#ifdef DEBUG
+#else 
 
-// This method is good for early debug, but is unneeded for general use
-static void *get_check_symbol(void *handle, const char *name) {
-    void *ret = dlsym(handle, name);
-    if (!ret) {
-        fprintf(stderr, "failed to load symbol %s\n", name);
-    }
-    return ret;
-}
-#define GET_SYMBOL(handle,name) get_check_symbol(handle,name)
-
-#else // #ifdef DEBUG
-
-#define GET_SYMBOL(handle,name) dlsym(handle,name)
+PrismNativePort prismPort;
 
 #endif
 
-void *libglesv2;
-void *libegl;
-
-
-/***************************** Special cases  ***************************/
-
-static EGLDisplay(*_eglGetDisplay)(EGLNativeDisplayType display_id);
-
-EGLDisplay wr_eglGetDisplay(EGLNativeDisplayType display_id) {
-    EGLDisplay ret = (*_eglGetDisplay)(display_id);
-    return ret;
-}
-
-static EGLNativeWindowType(*_ANDROID_getNativeWindow)();
-
-/***************************** EGL *************************************/
-
-static int load_egl_symbols(void *lib) {
-    int error = 0;
-
-    if (!(_eglGetDisplay = GET_SYMBOL(lib, "eglGetDisplay"))) {
-        error++;
-    }
-
-    if (error) {
-        // handle error conditions better ?
-        fprintf(stderr, "failed to load all EGL symbols %d\n", error);
-        return 1;
-    }
-    return 0;
-}
-
-/*************************************** BROADCOM ******************************************/
-
-static int load_bcm_symbols(void *lib) {
-#ifdef USE_DISPMAN
-    int error = 0;
-
-    if (!(wr_bcm_host_init = GET_SYMBOL(lib, "bcm_host_init"))) {
-        error++;
-    }
-    if (!(wr_vc_dispmanx_display_close = GET_SYMBOL(lib, "vc_dispmanx_display_close"))) {
-        error++;
-    }
-    if (!(wr_vc_dispmanx_display_get_info = GET_SYMBOL(lib, "vc_dispmanx_display_get_info"))) {
-        error++;
-    }
-    if (!(wr_vc_dispmanx_display_open = GET_SYMBOL(lib, "vc_dispmanx_display_open"))) {
-        error++;
-    }
-    if (!(wr_vc_dispmanx_element_add = GET_SYMBOL(lib, "vc_dispmanx_element_add"))) {
-        error++;
-    }
-    if (!(wr_vc_dispmanx_update_start = GET_SYMBOL(lib, "vc_dispmanx_update_start"))) {
-        error++;
-    }
-    if (!(wr_vc_dispmanx_update_submit_sync = GET_SYMBOL(lib, "vc_dispmanx_update_submit_sync"))) {
-        error++;
-    }
-
-    if (error) {
-        // handle error conditions better ?
-        fprintf(stderr, "failed to load all bcm_host symbols %d\n", error);
-        return 1;
-    }
-    return 0;
-#else
-    return 1;
-#endif /* USE_DISPMAN */
-}
-
-static int load_vivante_symbols(void *lib) {
-    int error = 0;
-    if (!(wr_fbGetDisplayByIndex = GET_SYMBOL(lib, "fbGetDisplayByIndex"))) {
-        error++;
-    }
-    if (!(wr_fbCreateWindow = GET_SYMBOL(lib, "fbCreateWindow"))) {
-        error++;
-    }
-    if (error != 0) {
-        fprintf(stderr, "failed to load all Vivante symbols %d\n", error);
-        return 1;
-    }
-    return error;
-}
-static int done_loading_symbols = 0;
-
-/***************************** UTILITY ********************************/
-
 int load_wrapped_gles_symbols() {
-
     if (done_loading_symbols)  {
         return 0;
     }
     done_loading_symbols = 1;
 
-    //Note that there is an order depenacy here - The PI wants GLES first.
-    // Other platfroms needs the RTLD_GLOBAL to resolve symbols correctly.
-
-
+#ifdef ANDROID_NDK
     libglesv2 = dlopen("libGLESv2.so", RTLD_LAZY | RTLD_GLOBAL);
     if (!libglesv2) {
         fprintf(stderr, "Did not find libGLESv2.so %s\n", dlerror());
         return 0;
     }
 
-    libegl = dlopen("libEGL.so", RTLD_LAZY | RTLD_GLOBAL);
-    if (!libegl) {
-        fprintf(stderr, "Did not find libEGL.so %s\n", dlerror());
-        return 0;
+    _eglGetDisplay = dlsym(libglesv2, "eglGetDisplay");
+#else
+    
+    Dl_info dlinfo;
+    if (dladdr(&load_wrapped_gles_symbols, &dlinfo)) {
+
+        size_t rslash = (size_t)rindex(dlinfo.dli_fname,'/');
+        if (rslash) {
+            char *b = (char *) alloca(strlen(dlinfo.dli_fname)+20);
+            rslash = rslash + 1 - (size_t)dlinfo.dli_fname;
+            strncpy(b, dlinfo.dli_fname,rslash);
+            strcpy(b + rslash, LENSPORT_LIBRARY_NAME);
+
+            jboolean (*prism_platform_init)(PrismNativePort*) =  0;
+
+            void *dlhand = dlopen(b,RTLD_NOW); 
+            if (dlhand) {
+                prism_platform_init =  dlsym(dlhand, "prism_platform_initialize");
+                if (!prism_platform_init) {
+                    fprintf(stderr,"prism_platform_initialize missing in %s\n",LENSPORT_LIBRARY_NAME);
+                    exit(-1);
+                }
+            } else {
+                fprintf(stderr,"Prism FAILED TO OPEN %s\n",b);
+                fprintf(stderr,"dlopen reports %s\n",dlerror());
+                exit(-1);
+            }
+            prismPort.version = NATIVE_PRISM_PORT_VERSION;
+
+            if (!(*prism_platform_init)(&prismPort)) {
+                fprintf(stderr,"prism_platform_initialize failed\n");
+                exit(-1);
+            }
+        }
+    } else {
+        printf("Did not get DLINFO\n");
+        exit(-1);
     }
 
-    void *libbcm = dlopen("libbcm_host.so", RTLD_LAZY);
-
-    int error = 0;
-
-    if (libbcm) {
-        useDispman = 1;
-        error += load_bcm_symbols(libbcm);
-    } else if (dlopen("libVIVANTE.so", RTLD_LAZY)) {
-        useVivanteFB = 1;
-        error += load_vivante_symbols(libegl);
-    }
-
-    error += load_egl_symbols(libegl);
-
-    return error;
+#endif
+    return 1;
 }
 
 EGLNativeDisplayType getNativeDisplayType() {
-    static EGLNativeDisplayType cachedNativeDisplayType;
-    static int cached = 0;
+    if (!done_loading_symbols) {
+        load_wrapped_gles_symbols();
+    }
+#ifdef ANDROID_NDK
+    return (EGLNativeDisplayType) NULL;
+#else
+    return (EGLNativeDisplayType) (*prismPort.getNativeDisplayType)();
+#endif
 
+}
+
+EGLNativeWindowType getNativeWindowType() {
     if (!done_loading_symbols) {
         load_wrapped_gles_symbols();
     }
 
-    if (!cached) {
-        if (useDispman) {
-            cachedNativeDisplayType = EGL_DEFAULT_DISPLAY;
-        } else if (useVivanteFB)  {
-            cachedNativeDisplayType = wr_fbGetDisplayByIndex(0);
-        } else {
-            cachedNativeDisplayType = (EGLNativeDisplayType)NULL;
-        }
-
-        cached ++;
-    }
-
-
-    return cachedNativeDisplayType;
-}
-
-EGLNativeWindowType getNativeWindowType() {
-    static NativeWindowType cachedWindowType;
-    static int cached = 0;
-
-    if (!cached) {
-
-        if (!done_loading_symbols) {
-            load_wrapped_gles_symbols();
-        }
-
-        if (useDispman) {
-#ifdef USE_DISPMAN
-
-            EGL_DISPMANX_WINDOW_T *dispmanWindow;
-            DISPMANX_DISPLAY_HANDLE_T display = 0;
-            DISPMANX_ELEMENT_HANDLE_T element;
-            DISPMANX_UPDATE_HANDLE_T update;
-            VC_RECT_T dst = { 0, 0, };
-            VC_RECT_T src = { 0, 0, };
-
-            (*wr_bcm_host_init)();
-
-            dispmanWindow = (EGL_DISPMANX_WINDOW_T *)calloc(sizeof(EGL_DISPMANX_WINDOW_T), 1);
-
-            display = (*wr_vc_dispmanx_display_open)(0 /* LCD */);
-            if (display == 0) {
-                fprintf(stderr, "Dispman: Cannot open display\n");
-                return 0;
-            }
-            int fbFileHandle;
-            struct fb_var_screeninfo screenInfo;
-            fbFileHandle = open("/dev/fb0", O_RDONLY);
-            if (fbFileHandle < 0) {
-                fprintf(stderr, "Cannot open framebuffer\n");
-                return 0;
-            }
-            if (ioctl(fbFileHandle, FBIOGET_VSCREENINFO, &screenInfo)) {
-                fprintf(stderr, "Cannot get screen info\n");
-                return 0;
-            }
-            close(fbFileHandle);
-
-            dst.width = screenInfo.xres;
-            dst.height = screenInfo.yres;
-            src.width = screenInfo.xres << 16;
-            src.height = screenInfo.yres << 16;
-
-            VC_DISPMANX_ALPHA_T alpha;
-            alpha.flags = DISPMANX_FLAGS_ALPHA_FROM_SOURCE;
-            alpha.opacity = 0xff;
-            alpha.mask = (DISPMANX_RESOURCE_HANDLE_T) 0;
-            update = (*wr_vc_dispmanx_update_start)(0);
-            element = (*wr_vc_dispmanx_element_add)(
-                          update,
-                          display,
-                          1 /*layer*/,
-                          &dst,
-                          0 /*src*/,
-                          &src,
-                          DISPMANX_PROTECTION_NONE,
-                          &alpha,
-                          0 /*clamp*/,
-                          0 /*transform*/);
-
-            dispmanWindow->element = element;
-            dispmanWindow->width = screenInfo.xres;
-            dispmanWindow->height = screenInfo.yres;
-            (*wr_vc_dispmanx_update_submit_sync)(update);
-
-            cachedWindowType = (NativeWindowType)dispmanWindow;
-#endif /* USE_DISPMAN */
-        } else if (useVivanteFB)  {
-            cachedWindowType = (*wr_fbCreateWindow)(getNativeDisplayType(), 0, 0, 0, 0);
-        } else {
-            cachedWindowType = NULL;      // hence the EGL NULL
-        }
-        cached ++;
-    }
 #ifdef ANDROID_NDK
     //don't cache for Android!
     printf("Using getAndroidNativeWindow() from glass.\n");
@@ -332,21 +157,30 @@
         fprintf(stderr, "Did not find libglass_lens_android.so %s\n", dlerror());
            return NULL;
     }
-    _ANDROID_getNativeWindow = GET_SYMBOL(libglass_android, "ANDROID_getNativeWindow");
+    _ANDROID_getNativeWindow = dlsym(libglass_android, "ANDROID_getNativeWindow");
     if (!_ANDROID_getNativeWindow) {
        fprintf(stderr, "Did not find symbol \"ANDROID_getNativeWindow\" %s\n", dlerror());
        return NULL;
     }
     return (*_ANDROID_getNativeWindow)();
+#else
+    return (EGLNativeWindowType) (*prismPort.getNativeWindowType)();
 #endif
-
-    return cachedWindowType;
 }
 
+EGLDisplay wr_eglGetDisplay(EGLNativeDisplayType display_id) {
+#ifdef ANDROID_NDK
+    return  (*_eglGetDisplay)(display_id);
+#else
+    return (EGLDisplay) (*prismPort.wr_eglGetDisplay)((void*)display_id);
+#endif
+}
 
+void * getLibGLEShandle() {
+#ifdef ANDROID_NDK
+    return libglesv2;
+#else
+    return (*prismPort.getLibGLEShandle)();
+#endif
+}
 
-//void __attribute__ ((constructor)) wr_init(void) {
-//    printf("LOADING IN INIT\n");
-//    load_wrapped_gles_symbols();
-//}
-
--- a/modules/graphics/src/main/native-prism-es2/eglfb/wrapped_egl.h	Tue Oct 22 14:31:11 2013 -0700
+++ b/modules/graphics/src/main/native-prism-es2/eglfb/wrapped_egl.h	Tue Oct 22 18:00:28 2013 -0400
@@ -35,13 +35,11 @@
 #endif
 
 // Call load_wrapped_gles_symbols to initialize everything up front.
-WRAPPEDAPI int load_wrapped_gles_symbols(void);
-WRAPPEDAPI int useDispman;
-WRAPPEDAPI void *libglesv2;
-WRAPPEDAPI void *libegl;
 WRAPPEDAPI EGLNativeWindowType getNativeWindowType();
 WRAPPEDAPI EGLNativeDisplayType getNativeDisplayType();
 
+WRAPPEDAPI void * getLibGLEShandle();
+
 WRAPPEDAPI EGLDisplay wr_eglGetDisplay(EGLNativeDisplayType display_id);
 //This is needed until we can make sure load_wrapped_gles_symbols
 #define eglGetDisplay(display_id) (*wr_eglGetDisplay)(display_id)