/* * 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. */ package com.sun.glass.ui.monocle; import java.nio.Buffer; import java.nio.IntBuffer; import com.sun.glass.ui.monocle.linux.LinuxSystem; import java.lang.reflect.Method; import java.util.Locale; public abstract class NativeScreen { private static long glesLibraryHandle; private static long eglLibraryHandle; private static long nativeDisplayType; private static boolean initialized; public abstract int getDepth(); public abstract int getNativeFormat(); public abstract int getWidth(); public abstract int getHeight(); public abstract int getDPI(); public abstract long getNativeHandle(); public abstract void shutdown(); public static long platformGetNativeDisplay() {return 0L;}; public abstract void uploadPixels(Buffer b, int x, int y, int width, int height, float alpha); public abstract void swapBuffers(); public abstract IntBuffer getScreenCapture(); protected static boolean initPlatformLibraries() { LinuxSystem ls = LinuxSystem.getLinuxSystem(); glesLibraryHandle = ls.dlopen("libGLESv2.so", LinuxSystem.RTLD_LAZY | LinuxSystem.RTLD_GLOBAL); eglLibraryHandle = ls.dlopen("libEGL.so", LinuxSystem.RTLD_LAZY | LinuxSystem.RTLD_GLOBAL); return true; } public static synchronized long getNativeDisplay() { String platformNativeScreenName; if (initialized) { // already initialized return nativeDisplayType; } String platformName = NativePlatformFactory.getNativePlatformName(); platformNativeScreenName = "com.sun.glass.ui.monocle." + platformName + "." + platformName.toUpperCase(Locale.ROOT) + "Screen"; initPlatformLibraries(); try { Method platformMethod = Class.forName(platformNativeScreenName).getMethod("platformGetNativeDisplay"); nativeDisplayType = (long)platformMethod.invoke(null); } catch (Exception e){ e.printStackTrace(); } initialized = true; return nativeDisplayType; } }