1e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian/*
2e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Copyright (C) 2010 The Android Open Source Project
3e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian *
4e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Licensed under the Apache License, Version 2.0 (the "License");
5e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * you may not use this file except in compliance with the License.
6e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * You may obtain a copy of the License at
7e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian *
8e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian *      http://www.apache.org/licenses/LICENSE-2.0
9e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian *
10e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Unless required by applicable law or agreed to in writing, software
11e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * distributed under the License is distributed on an "AS IS" BASIS,
12e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * See the License for the specific language governing permissions and
14e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * limitations under the License.
15e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */
16e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
17bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
18bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * @addtogroup NativeActivity Native Activity
19bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * @{
20bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine */
21bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine
22bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
23bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * @file native_window_jni.h
24bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine */
25bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine
26e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#ifndef ANDROID_NATIVE_WINDOW_JNI_H
27e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#define ANDROID_NATIVE_WINDOW_JNI_H
28e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
29494ed550f5aea1332984fb9f0f11036fc58bd716Dan Albert#include <sys/cdefs.h>
30494ed550f5aea1332984fb9f0f11036fc58bd716Dan Albert
31e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#include <android/native_window.h>
32e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
33e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#include <jni.h>
34e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
35e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#ifdef __cplusplus
36e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianextern "C" {
37e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#endif
38e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
39e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian/**
40e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Return the ANativeWindow associated with a Java Surface object,
41e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * for interacting with it through native code.  This acquires a reference
42e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * on the ANativeWindow that is returned; be sure to use ANativeWindow_release()
43e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * when done with it so that it doesn't leak.
44e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */
45e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias AgopianANativeWindow* ANativeWindow_fromSurface(JNIEnv* env, jobject surface);
46e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
47494ed550f5aea1332984fb9f0f11036fc58bd716Dan Albert#if __ANDROID_API__ >= 13
48494ed550f5aea1332984fb9f0f11036fc58bd716Dan Albert/**
49494ed550f5aea1332984fb9f0f11036fc58bd716Dan Albert * Return the ANativeWindow associated with a Java SurfaceTexture object,
50494ed550f5aea1332984fb9f0f11036fc58bd716Dan Albert * for interacting with it through native code.  This acquires a reference
51494ed550f5aea1332984fb9f0f11036fc58bd716Dan Albert * on the ANativeWindow that is returned; be sure to use ANativeWindow_release()
52494ed550f5aea1332984fb9f0f11036fc58bd716Dan Albert * when done with it so that it doesn't leak.
53494ed550f5aea1332984fb9f0f11036fc58bd716Dan Albert */
54494ed550f5aea1332984fb9f0f11036fc58bd716Dan AlbertANativeWindow* ANativeWindow_fromSurfaceTexture(JNIEnv* env, jobject surfaceTexture);
55494ed550f5aea1332984fb9f0f11036fc58bd716Dan Albert#endif
56494ed550f5aea1332984fb9f0f11036fc58bd716Dan Albert
57ee6cff0d38888fe816def8634eaa47e13ed145ddJiwen 'Steve' Cai#if __ANDROID_API__ >= 26
58ee6cff0d38888fe816def8634eaa47e13ed145ddJiwen 'Steve' Cai/**
59ee6cff0d38888fe816def8634eaa47e13ed145ddJiwen 'Steve' Cai * Return a Java Surface object derived from the ANativeWindow, for interacting
60ee6cff0d38888fe816def8634eaa47e13ed145ddJiwen 'Steve' Cai * with it through Java code. The returned Java object acquires a reference on
61ee6cff0d38888fe816def8634eaa47e13ed145ddJiwen 'Steve' Cai * the ANativeWindow; maintains it through general Java object's life cycle;
62ee6cff0d38888fe816def8634eaa47e13ed145ddJiwen 'Steve' Cai * and will automatically release the reference when the Java object gets garbage
63ee6cff0d38888fe816def8634eaa47e13ed145ddJiwen 'Steve' Cai * collected.
64ee6cff0d38888fe816def8634eaa47e13ed145ddJiwen 'Steve' Cai */
65ee6cff0d38888fe816def8634eaa47e13ed145ddJiwen 'Steve' Caijobject ANativeWindow_toSurface(JNIEnv* env, ANativeWindow* window);
66ee6cff0d38888fe816def8634eaa47e13ed145ddJiwen 'Steve' Cai#endif
67ee6cff0d38888fe816def8634eaa47e13ed145ddJiwen 'Steve' Cai
68e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#ifdef __cplusplus
69e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian};
70e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#endif
71e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
72e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#endif // ANDROID_NATIVE_WINDOW_H
73bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine
74bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/** @} */
75