1 /* 2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 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 #ifdef ANDROID_NDK 27 28 #include "LensCommon.h" 29 #include "wm/LensWindowManager.h" 30 #include "input/android/androidInput.h" 31 #include "input/android/androidLens.h" 32 33 static struct _NativeScreen localScreen; 34 static int windowIndex = 1; 35 36 NativeScreen lens_screen_initialize(JNIEnv *env) { 37 38 ANativeWindow *androidWindow = getAndroidNativeWindow(); 39 int32_t width = ANativeWindow_getWidth(androidWindow); 40 int32_t height = ANativeWindow_getHeight(androidWindow); 41 42 localScreen.width = width; 43 localScreen.height = height; 44 localScreen.visibleWidth = width; 45 localScreen.visibleHeight = height; 46 localScreen.x = 0; 47 localScreen.y = 0; 48 localScreen.depth = 24; //????? Samsung has 16 49 50 // convert pixels/mm to pixels/inch 51 localScreen.resolutionX = 100; 52 localScreen.resolutionY = 100; 53 54 return &localScreen; 55 } 56 57 jboolean glass_application_initialize(JNIEnv *env) { 58 //nothing to do 59 return JNI_TRUE; 60 } 61 62 jboolean glass_window_setAlpha(JNIEnv *env, NativeWindow window, float alpha) { 63 window->alpha = alpha; 64 lens_wm_repaint(env, window); 65 return JNI_TRUE; 66 } 67 68 LensResult glass_view_PlatformViewData_create(NativeView view) { 69 view->data = NULL; 70 return LENS_OK; 71 } 72 73 LensResult glass_view_PlatformViewRelease(JNIEnv *env, NativeView view) { 74 // No data to free 75 return LENS_OK; 76 } 77 78 LensResult glass_window_PlatformWindowData_create(JNIEnv *env, 79 NativeWindow window) { 80 81 window->id = windowIndex++; 82 window->data = NULL; //no platfrom specific data 83 84 return LENS_OK; 85 } 86 87 LensResult glass_window_PlatformWindowRelease(JNIEnv *env, NativeWindow window) { 88 // No data to free 89 return LENS_OK; 90 } 91 92 void *glass_window_getPlatformWindow(JNIEnv *env, NativeWindow window) { 93 return getAndroidNativeWindow(); 94 } 95 96 void lens_platform_shutdown(JNIEnv *env) { 97 lens_input_shutdown(); 98 } 99 100 void glass_screen_clear() { 101 // NOOP 102 } 103 104 void glass_pixel_attachIntBuffer(JNIEnv *env, jint *src, 105 NativeWindow window, 106 jint width, jint height, int offset) { 107 GLASS_LOG_FINE("androidScreen: glass_pixel_attachIntBuffer not implemented!"); 108 } 109 110 jboolean glass_screen_capture(jint x, 111 jint y, 112 jint width, 113 jint height, 114 jint *pixels) { 115 GLASS_LOG_FINE("androidScreen: glass_screen_capture not implemented!"); 116 } 117 118 LensResult lens_platform_windowMinimize(JNIEnv *env, 119 NativeWindow window, 120 jboolean toMinimize) { 121 //noop for fb 122 return LENS_OK; 123 } 124 125 LensResult lens_platform_windowSetVisible(JNIEnv *env, 126 NativeWindow window, 127 jboolean visible) { 128 return LENS_OK; 129 } 130 131 #endif /* ANDROID_NDK */