diff options
author | Dianne Hackborn <hackbod@google.com> | 2010-07-01 16:04:02 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-07-01 16:04:02 -0700 |
commit | 738639ccd0f12b06d17df3d3b3ee68f506311331 (patch) | |
tree | b8a1c104c9683f03dfa1408e1467478531ff4e39 /native | |
parent | 3cd310f18dd5e8dc451583319c67270bac4e4b4f (diff) | |
parent | 58f35ff41601769ca4f357575a9385f16c01b991 (diff) | |
download | frameworks_base-738639ccd0f12b06d17df3d3b3ee68f506311331.zip frameworks_base-738639ccd0f12b06d17df3d3b3ee68f506311331.tar.gz frameworks_base-738639ccd0f12b06d17df3d3b3ee68f506311331.tar.bz2 |
am 58f35ff4: am 54a181b1: Make real API for native code to get its window.
Merge commit '58f35ff41601769ca4f357575a9385f16c01b991'
* commit '58f35ff41601769ca4f357575a9385f16c01b991':
Make real API for native code to get its window.
Diffstat (limited to 'native')
-rw-r--r-- | native/android/Android.mk | 3 | ||||
-rw-r--r-- | native/android/native_window.cpp | 41 | ||||
-rw-r--r-- | native/include/android/native_activity.h | 31 | ||||
-rw-r--r-- | native/include/android/native_window.h | 17 |
4 files changed, 73 insertions, 19 deletions
diff --git a/native/android/Android.mk b/native/android/Android.mk index 8c621b6..fe8ed00 100644 --- a/native/android/Android.mk +++ b/native/android/Android.mk @@ -7,7 +7,8 @@ include $(CLEAR_VARS) # LOCAL_SRC_FILES:= \ activity.cpp \ - input.cpp + input.cpp \ + native_window.cpp LOCAL_SHARED_LIBRARIES := \ libandroid_runtime \ diff --git a/native/android/native_window.cpp b/native/android/native_window.cpp new file mode 100644 index 0000000..7a6eb6d --- /dev/null +++ b/native/android/native_window.cpp @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "Surface" +#include <utils/Log.h> + +#include <android/native_window.h> +#include <surfaceflinger/Surface.h> + +using android::Surface; + +static int32_t getWindowProp(ANativeWindow* window, int what) { + int value; + int res = window->query(window, what, &value); + return res < 0 ? res : value; +} + +int32_t ANativeWindow_getWidth(ANativeWindow* window) { + return getWindowProp(window, NATIVE_WINDOW_WIDTH); +} + +int32_t ANativeWindow_getHeight(ANativeWindow* window) { + return getWindowProp(window, NATIVE_WINDOW_HEIGHT); +} + +int32_t ANativeWindow_getFormat(ANativeWindow* window) { + return getWindowProp(window, NATIVE_WINDOW_FORMAT); +} diff --git a/native/include/android/native_activity.h b/native/include/android/native_activity.h index c5c8f9d..d23e40f 100644 --- a/native/include/android/native_activity.h +++ b/native/include/android/native_activity.h @@ -24,15 +24,12 @@ #include <jni.h> #include <android/input.h> +#include <android/native_window.h> #ifdef __cplusplus extern "C" { #endif -// Temporary until native surface API is defined. -struct ASurfaceHolder; -typedef struct ASurfaceHolder ASurfaceHolder; - struct ANativeActivityCallbacks; /** @@ -129,30 +126,28 @@ typedef struct ANativeActivityCallbacks { void (*onWindowFocusChanged)(ANativeActivity* activity, int hasFocus); /** - * The drawing surface for this native activity has been created. You - * can use the given surface object to start drawing. NOTE: surface - * drawing API is not yet defined. + * The drawing window for this native activity has been created. You + * can use the given native window object to start drawing. */ - void (*onSurfaceCreated)(ANativeActivity* activity, ASurfaceHolder* surface); + void (*onNativeWindowCreated)(ANativeActivity* activity, ANativeWindow* window); /** - * The drawing surface for this native activity has changed. The surface - * given here is guaranteed to be the same as the one last given to - * onSurfaceCreated. This is simply to inform you about interesting - * changed to that surface. + * The drawing window for this native activity has changed. During this time, + * old ANativeWindow object is still valid but no longer active and drawing + * should switch to the new ANativeWindow given here. After returning from + * this function, you must not touch the old window. */ - void (*onSurfaceChanged)(ANativeActivity* activity, ASurfaceHolder* surface, - int format, int width, int height); + void (*onNativeWindowChanged)(ANativeActivity* activity, ANativeWindow* window); /** - * The drawing surface for this native activity is going to be destroyed. - * You MUST ensure that you do not touch the surface object after returning - * from this function: in the common case of drawing to the surface from + * The drawing window for this native activity is going to be destroyed. + * You MUST ensure that you do not touch the window object after returning + * from this function: in the common case of drawing to the window from * another thread, that means the implementation of this callback must * properly synchronize with the other thread to stop its drawing before * returning from here. */ - void (*onSurfaceDestroyed)(ANativeActivity* activity, ASurfaceHolder* surface); + void (*onNativeWindowDestroyed)(ANativeActivity* activity, ANativeWindow* window); /** * The input queue for this native activity's window has been created. diff --git a/native/include/android/native_window.h b/native/include/android/native_window.h index e6d5fea..b3f47b2 100644 --- a/native/include/android/native_window.h +++ b/native/include/android/native_window.h @@ -25,6 +25,23 @@ extern "C" { struct ANativeWindow; typedef struct ANativeWindow ANativeWindow; +/* + * Return the current width in pixels of the window surface. Returns a + * negative value on error. + */ +int32_t ANativeWindow_getWidth(ANativeWindow* window); + +/* + * Return the current height in pixels of the window surface. Returns a + * negative value on error. + */ +int32_t ANativeWindow_getHeight(ANativeWindow* window); + +/* + * Return the current pixel format of the window surface. Returns a + * negative value on error. + */ +int32_t ANativeWindow_getFormat(ANativeWindow* window); #ifdef __cplusplus }; |