| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef EMBEDDERS_OPENGLUI_COMMON_DART_HOST_H_ | 5 #ifndef EMBEDDERS_OPENGLUI_COMMON_DART_HOST_H_ |
| 6 #define EMBEDDERS_OPENGLUI_COMMON_DART_HOST_H_ | 6 #define EMBEDDERS_OPENGLUI_COMMON_DART_HOST_H_ |
| 7 | 7 |
| 8 #include "embedders/openglui/common/context.h" | 8 #include "embedders/openglui/common/context.h" |
| 9 #include "embedders/openglui/common/graphics_handler.h" | 9 #include "embedders/openglui/common/graphics_handler.h" |
| 10 #include "embedders/openglui/common/input_handler.h" | 10 #include "embedders/openglui/common/input_handler.h" |
| 11 #include "embedders/openglui/common/lifecycle_handler.h" | 11 #include "embedders/openglui/common/lifecycle_handler.h" |
| 12 #include "embedders/openglui/common/sound_handler.h" | 12 #include "embedders/openglui/common/sound_handler.h" |
| 13 #include "embedders/openglui/common/timer.h" | 13 #include "embedders/openglui/common/timer.h" |
| 14 #include "embedders/openglui/common/vm_glue.h" | 14 #include "embedders/openglui/common/vm_glue.h" |
| 15 #include "include/dart_api.h" | 15 #include "include/dart_api.h" |
| 16 | 16 |
| 17 // Currently the life cycle management is very crude. We conservatively | |
| 18 // shutdown the main isolate when we lose focus and create a new one when | |
| 19 // we resume. This needs to be improved later when we understand this better, | |
| 20 // and we need some hooks to tell the Dart script to save/restore state | |
| 21 // (and an API that will support that). | |
| 22 | |
| 23 class DartHost : public LifeCycleHandler { | 17 class DartHost : public LifeCycleHandler { |
| 24 public: | 18 public: |
| 25 explicit DartHost(Context* context); | 19 explicit DartHost(Context* context); |
| 26 virtual ~DartHost(); | 20 virtual ~DartHost(); |
| 27 | 21 |
| 28 void OnStart(); | 22 int32_t OnStart(); |
| 29 void OnResume(); | |
| 30 void OnPause(); | |
| 31 void OnStop(); | |
| 32 void OnDestroy(); | |
| 33 void OnSaveState(void** data, size_t* size); | 23 void OnSaveState(void** data, size_t* size); |
| 34 void OnConfigurationChanged(); | 24 void OnConfigurationChanged(); |
| 35 void OnLowMemory(); | 25 void OnLowMemory(); |
| 36 void OnCreateWindow(); | 26 int32_t Activate(); |
| 37 void OnDestroyWindow(); | 27 void Deactivate(); |
| 38 void OnGainedFocus(); | 28 void Pause(); |
| 39 void OnLostFocus(); | 29 int32_t Resume(); |
| 40 int32_t OnActivate(); | 30 void FreeAllResources(); |
| 41 void OnDeactivate(); | |
| 42 int32_t OnStep(); | 31 int32_t OnStep(); |
| 43 | 32 |
| 44 private: | 33 private: |
| 45 void Clear(); | 34 void Clear(); |
| 46 int32_t Activate(); | |
| 47 void Deactivate(); | |
| 48 | 35 |
| 49 GraphicsHandler* graphics_handler_; | 36 GraphicsHandler* graphics_handler_; |
| 50 InputHandler* input_handler_; | 37 InputHandler* input_handler_; |
| 51 SoundHandler* sound_handler_; | 38 SoundHandler* sound_handler_; |
| 52 Timer* timer_; | 39 Timer* timer_; |
| 53 VMGlue* vm_glue_; | 40 VMGlue* vm_glue_; |
| 41 bool has_context_; |
| 42 bool started_; |
| 54 bool active_; | 43 bool active_; |
| 55 }; | 44 }; |
| 56 | 45 |
| 57 #endif // EMBEDDERS_OPENGLUI_COMMON_DART_HOST_H_ | 46 #endif // EMBEDDERS_OPENGLUI_COMMON_DART_HOST_H_ |
| 58 | 47 |
| OLD | NEW |