12 : activity_(activity) {
14
15 activity->instance = this;
16
17 activity->callbacks->onStart = [](ANativeActivity* activity) {
19 };
20 activity->callbacks->onStop = [](ANativeActivity* activity) {
22 };
23 activity->callbacks->onPause = [](ANativeActivity* activity) {
25 };
26 activity->callbacks->onResume = [](ANativeActivity* activity) {
28 };
29 activity->callbacks->onDestroy = [](ANativeActivity* activity) {
31 };
32 activity->callbacks->onSaveInstanceState = [](ANativeActivity* activity,
33 size_t* out_size) -> void* {
34 auto mapping =
reinterpret_cast<NativeActivity*
>(activity->instance)
36 if (mapping == nullptr || mapping->GetMapping() == nullptr) {
37 *out_size = 0;
38 return nullptr;
39 }
40
41
42 auto copied =
malloc(mapping->GetSize());
44 << "Allocation failure while saving instance state.";
45 memcpy(copied, mapping->GetMapping(), mapping->GetSize());
46 *out_size = mapping->GetSize();
47 return copied;
48 };
49 activity->callbacks->onWindowFocusChanged = [](ANativeActivity* activity,
50 int has_focus) {
53 };
54 activity->callbacks->onNativeWindowCreated = [](ANativeActivity* activity,
58 };
59 activity->callbacks->onNativeWindowResized = [](ANativeActivity* activity,
63 };
64 activity->callbacks->onNativeWindowRedrawNeeded =
68 };
69 activity->callbacks->onNativeWindowDestroyed = [](ANativeActivity* activity,
73 };
74 activity->callbacks->onInputQueueCreated = [](ANativeActivity* activity,
78 };
79 activity->callbacks->onInputQueueDestroyed = [](ANativeActivity* activity,
83 };
84 activity->callbacks->onConfigurationChanged = [](ANativeActivity* activity) {
87 };
88 activity->callbacks->onLowMemory = [](ANativeActivity* activity) {
90 };
91}
virtual void OnNativeWindowCreated(ANativeWindow *window)
virtual void OnNativeWindowResized(ANativeWindow *window)
virtual void OnInputQueueDestroyed(AInputQueue *queue)
virtual void OnNativeWindowRedrawNeeded(ANativeWindow *window)
virtual void OnNativeWindowDestroyed(ANativeWindow *window)
virtual void OnLowMemory()
NativeActivity(ANativeActivity *activity)
virtual void OnInputQueueCreated(AInputQueue *queue)
virtual void OnConfigurationChanged()
virtual std::shared_ptr< fml::Mapping > OnSaveInstanceState()
virtual void OnWindowFocusChanged(bool has_focus)
static void EnsureInitializedForCurrentThread()
#define FML_CHECK(condition)
void * malloc(size_t size)
struct ANativeWindow ANativeWindow