Home | History | Annotate | Download | only in android
      1 /*-------------------------------------------------------------------------
      2  * drawElements Quality Program Tester Core
      3  * ----------------------------------------
      4  *
      5  * Copyright 2014 The Android Open Source Project
      6  *
      7  * Licensed under the Apache License, Version 2.0 (the "License");
      8  * you may not use this file except in compliance with the License.
      9  * You may obtain a copy of the License at
     10  *
     11  *      http://www.apache.org/licenses/LICENSE-2.0
     12  *
     13  * Unless required by applicable law or agreed to in writing, software
     14  * distributed under the License is distributed on an "AS IS" BASIS,
     15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16  * See the License for the specific language governing permissions and
     17  * limitations under the License.
     18  *
     19  *//*!
     20  * \file
     21  * \brief Android Native Activity.
     22  *//*--------------------------------------------------------------------*/
     23 
     24 #include "tcuAndroidNativeActivity.hpp"
     25 #include "deMemory.h"
     26 
     27 DE_BEGIN_EXTERN_C
     28 
     29 static void onStartCallback (ANativeActivity* activity)
     30 {
     31 	static_cast<tcu::Android::NativeActivity*>(activity->instance)->onStart();
     32 }
     33 
     34 static void onResumeCallback (ANativeActivity* activity)
     35 {
     36 	static_cast<tcu::Android::NativeActivity*>(activity->instance)->onResume();
     37 }
     38 
     39 static void* onSaveInstanceStateCallback (ANativeActivity* activity, size_t* outSize)
     40 {
     41 	return static_cast<tcu::Android::NativeActivity*>(activity->instance)->onSaveInstanceState(outSize);
     42 }
     43 
     44 static void onPauseCallback (ANativeActivity* activity)
     45 {
     46 	return static_cast<tcu::Android::NativeActivity*>(activity->instance)->onPause();
     47 }
     48 
     49 static void onStopCallback (ANativeActivity* activity)
     50 {
     51 	static_cast<tcu::Android::NativeActivity*>(activity->instance)->onStop();
     52 }
     53 
     54 static void onDestroyCallback (ANativeActivity* activity)
     55 {
     56 	static_cast<tcu::Android::NativeActivity*>(activity->instance)->onDestroy();
     57 }
     58 
     59 static void onWindowFocusChangedCallback (ANativeActivity* activity, int hasFocus)
     60 {
     61 	static_cast<tcu::Android::NativeActivity*>(activity->instance)->onWindowFocusChanged(hasFocus);
     62 }
     63 
     64 static void onNativeWindowCreatedCallback (ANativeActivity* activity, ANativeWindow* window)
     65 {
     66 	static_cast<tcu::Android::NativeActivity*>(activity->instance)->onNativeWindowCreated(window);
     67 }
     68 
     69 static void onNativeWindowResizedCallback (ANativeActivity* activity, ANativeWindow* window)
     70 {
     71 	static_cast<tcu::Android::NativeActivity*>(activity->instance)->onNativeWindowResized(window);
     72 }
     73 
     74 static void onNativeWindowRedrawNeededCallback (ANativeActivity* activity, ANativeWindow* window)
     75 {
     76 	static_cast<tcu::Android::NativeActivity*>(activity->instance)->onNativeWindowRedrawNeeded(window);
     77 }
     78 
     79 static void onNativeWindowDestroyedCallback (ANativeActivity* activity, ANativeWindow* window)
     80 {
     81 	static_cast<tcu::Android::NativeActivity*>(activity->instance)->onNativeWindowDestroyed(window);
     82 }
     83 
     84 static void onInputQueueCreatedCallback (ANativeActivity* activity, AInputQueue* queue)
     85 {
     86 	static_cast<tcu::Android::NativeActivity*>(activity->instance)->onInputQueueCreated(queue);
     87 }
     88 
     89 static void onInputQueueDestroyedCallback (ANativeActivity* activity, AInputQueue* queue)
     90 {
     91 	static_cast<tcu::Android::NativeActivity*>(activity->instance)->onInputQueueDestroyed(queue);
     92 }
     93 
     94 static void onContentRectChangedCallback (ANativeActivity* activity, const ARect* rect)
     95 {
     96 	static_cast<tcu::Android::NativeActivity*>(activity->instance)->onContentRectChanged(rect);
     97 }
     98 
     99 static void onConfigurationChangedCallback (ANativeActivity* activity)
    100 {
    101 	static_cast<tcu::Android::NativeActivity*>(activity->instance)->onConfigurationChanged();
    102 }
    103 
    104 static void onLowMemoryCallback (ANativeActivity* activity)
    105 {
    106 	static_cast<tcu::Android::NativeActivity*>(activity->instance)->onLowMemory();
    107 }
    108 
    109 DE_END_EXTERN_C
    110 
    111 namespace tcu
    112 {
    113 namespace Android
    114 {
    115 
    116 NativeActivity::NativeActivity (ANativeActivity* activity)
    117 	: m_activity(activity)
    118 {
    119 	activity->instance								= (void*)this;
    120 	activity->callbacks->onStart					= onStartCallback;
    121 	activity->callbacks->onResume					= onResumeCallback;
    122 	activity->callbacks->onSaveInstanceState		= onSaveInstanceStateCallback;
    123 	activity->callbacks->onPause					= onPauseCallback;
    124 	activity->callbacks->onStop						= onStopCallback;
    125 	activity->callbacks->onDestroy					= onDestroyCallback;
    126 	activity->callbacks->onWindowFocusChanged		= onWindowFocusChangedCallback;
    127 	activity->callbacks->onNativeWindowCreated		= onNativeWindowCreatedCallback;
    128 	activity->callbacks->onNativeWindowResized		= onNativeWindowResizedCallback;
    129 	activity->callbacks->onNativeWindowRedrawNeeded	= onNativeWindowRedrawNeededCallback;
    130 	activity->callbacks->onNativeWindowDestroyed	= onNativeWindowDestroyedCallback;
    131 	activity->callbacks->onInputQueueCreated		= onInputQueueCreatedCallback;
    132 	activity->callbacks->onInputQueueDestroyed		= onInputQueueDestroyedCallback;
    133 	activity->callbacks->onContentRectChanged		= onContentRectChangedCallback;
    134 	activity->callbacks->onConfigurationChanged		= onConfigurationChangedCallback;
    135 	activity->callbacks->onLowMemory				= onLowMemoryCallback;
    136 }
    137 
    138 NativeActivity::~NativeActivity (void)
    139 {
    140 }
    141 
    142 void NativeActivity::onStart (void)
    143 {
    144 }
    145 
    146 void NativeActivity::onResume (void)
    147 {
    148 }
    149 
    150 void* NativeActivity::onSaveInstanceState (size_t* outSize)
    151 {
    152 	*outSize = 0;
    153 	return DE_NULL;
    154 }
    155 
    156 void NativeActivity::onPause (void)
    157 {
    158 }
    159 
    160 void NativeActivity::onStop (void)
    161 {
    162 }
    163 
    164 void NativeActivity::onDestroy (void)
    165 {
    166 }
    167 
    168 void NativeActivity::onWindowFocusChanged (int hasFocus)
    169 {
    170 	DE_UNREF(hasFocus);
    171 }
    172 
    173 void NativeActivity::onNativeWindowCreated (ANativeWindow* window)
    174 {
    175 	DE_UNREF(window);
    176 }
    177 
    178 void NativeActivity::onNativeWindowResized (ANativeWindow* window)
    179 {
    180 	DE_UNREF(window);
    181 }
    182 
    183 void NativeActivity::onNativeWindowRedrawNeeded (ANativeWindow* window)
    184 {
    185 	DE_UNREF(window);
    186 }
    187 
    188 void NativeActivity::onNativeWindowDestroyed (ANativeWindow* window)
    189 {
    190 	DE_UNREF(window);
    191 }
    192 
    193 void NativeActivity::onInputQueueCreated (AInputQueue* queue)
    194 {
    195 	DE_UNREF(queue);
    196 }
    197 
    198 void NativeActivity::onInputQueueDestroyed (AInputQueue* queue)
    199 {
    200 	DE_UNREF(queue);
    201 }
    202 
    203 void NativeActivity::onContentRectChanged (const ARect* rect)
    204 {
    205 	DE_UNREF(rect);
    206 }
    207 
    208 void NativeActivity::onConfigurationChanged (void)
    209 {
    210 }
    211 
    212 void NativeActivity::onLowMemory (void)
    213 {
    214 }
    215 
    216 void NativeActivity::finish (void)
    217 {
    218 	ANativeActivity_finish(m_activity);
    219 }
    220 
    221 } // Android
    222 } // tcu
    223