| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 #ifndef DART_HOST_H | |
| 6 #define DART_HOST_H | |
| 7 | |
| 8 #include <android_native_app_glue.h> | |
| 9 #include "include/dart_api.h" | |
| 10 #include "jni/activity_handler.h" | |
| 11 #include "jni/context.h" | |
| 12 #include "jni/graphics.h" | |
| 13 #include "jni/input_service.h" | |
| 14 #include "jni/sound_service.h" | |
| 15 #include "jni/timer.h" | |
| 16 #include "jni/vm_glue.h" | |
| 17 | |
| 18 // Currently the life cycle management is very crude. We conservatively | |
| 19 // shutdown the main isolate when we lose focus and create a new one when | |
| 20 // we resume. This needs to be improved later when we understand this better, | |
| 21 // and we need some hooks to tell the Dart script to save/restore state | |
| 22 // (and an API that will support that). | |
| 23 | |
| 24 class DartHost : public ActivityHandler { | |
| 25 public: | |
| 26 explicit DartHost(Context* context); | |
| 27 virtual ~DartHost(); | |
| 28 | |
| 29 protected: | |
| 30 int32_t OnActivate(); | |
| 31 void OnDeactivate(); | |
| 32 int32_t OnStep(); | |
| 33 | |
| 34 void OnStart(); | |
| 35 void OnResume(); | |
| 36 void OnPause(); | |
| 37 void OnStop(); | |
| 38 void OnDestroy(); | |
| 39 | |
| 40 void OnSaveState(void** data, size_t size); | |
| 41 void OnConfigurationChanged(); | |
| 42 void OnLowMemory(); | |
| 43 void OnCreateWindow(); | |
| 44 void OnDestroyWindow(); | |
| 45 void OnGainedFocus(); | |
| 46 void OnLostFocus(); | |
| 47 | |
| 48 private: | |
| 49 void Clear(); | |
| 50 int32_t Activate(); | |
| 51 void Deactivate(); | |
| 52 | |
| 53 ANativeWindow_Buffer window_buffer_; | |
| 54 InputHandler* input_handler_; | |
| 55 Graphics* graphics_; | |
| 56 SoundService* sound_service_; | |
| 57 Timer* timer_; | |
| 58 VMGlue* vm_glue_; | |
| 59 bool active_; | |
| 60 }; | |
| 61 | |
| 62 #endif | |
| 63 | |
| OLD | NEW |