10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package com.sun.glass.ui.monocle; 27 28 import java.nio.Buffer; 29 import java.nio.IntBuffer; 30 31 public interface NativeScreen { 32 33 public int getDepth(); 34 public int getNativeFormat(); 35 public int getWidth(); 36 public int getHeight(); 37 public int getDPI(); 38 public long getNativeHandle(); 39 public void shutdown(); 40 41 public void uploadPixels(Buffer b, 42 int x, int y, int width, int height, float alpha); 43 44 public void swapBuffers(); 45 46 public IntBuffer getScreenCapture(); 47 48 } | 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package com.sun.glass.ui.monocle; 27 28 import java.nio.Buffer; 29 import java.nio.IntBuffer; 30 import com.sun.glass.ui.monocle.linux.LinuxSystem; 31 import java.lang.reflect.Method; 32 import java.util.Locale; 33 34 public abstract class NativeScreen { 35 private static long glesLibraryHandle; 36 private static long eglLibraryHandle; 37 private static long nativeDisplayType; 38 private static boolean initialized; 39 40 public abstract int getDepth(); 41 public abstract int getNativeFormat(); 42 public abstract int getWidth(); 43 public abstract int getHeight(); 44 public abstract int getDPI(); 45 public abstract long getNativeHandle(); 46 public abstract void shutdown(); 47 public static long platformGetNativeDisplay() {return 0L;}; 48 49 50 public abstract void uploadPixels(Buffer b, 51 int x, int y, int width, int height, float alpha); 52 53 public abstract void swapBuffers(); 54 55 public abstract IntBuffer getScreenCapture(); 56 57 protected static boolean initPlatformLibraries() { 58 LinuxSystem ls = LinuxSystem.getLinuxSystem(); 59 glesLibraryHandle = ls.dlopen("libGLESv2.so", LinuxSystem.RTLD_LAZY | LinuxSystem.RTLD_GLOBAL); 60 eglLibraryHandle = ls.dlopen("libEGL.so", LinuxSystem.RTLD_LAZY | LinuxSystem.RTLD_GLOBAL); 61 return true; 62 } 63 64 public static synchronized long getNativeDisplay() { 65 String platformNativeScreenName; 66 67 if (initialized) { 68 // already initialized 69 return nativeDisplayType; 70 } 71 String platformName = NativePlatformFactory.getNativePlatformName(); 72 platformNativeScreenName = "com.sun.glass.ui.monocle." + platformName + "." + 73 platformName.toUpperCase(Locale.ROOT) + "Screen"; 74 initPlatformLibraries(); 75 try { 76 Method platformMethod = Class.forName(platformNativeScreenName).getMethod("platformGetNativeDisplay"); 77 nativeDisplayType = (long)platformMethod.invoke(null); 78 } catch (Exception e){ 79 e.printStackTrace(); 80 } 81 82 initialized = true; 83 return nativeDisplayType; 84 } 85 86 } |