OLD | NEW |
---|---|
1 #include "jni/dart_host.h" | 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. | |
2 | 4 |
3 #include <math.h> | 5 #include <math.h> |
4 #include <unistd.h> | 6 #include <unistd.h> |
5 | 7 |
6 #include "bin/eventhandler.h" | 8 #include "jni/dart_host.h" |
gram
2012/12/04 22:03:42
This should come first: http://www.corp.google.com
vsm
2012/12/04 23:03:08
Done.
| |
7 #include "bin/isolate_data.h" | 9 #include "jni/log.h" |
8 #include "bin/log.h" | |
9 #include "bin/platform.h" | |
10 #include "bin/process.h" | |
11 #include "vm/flags.h" | |
12 | 10 |
13 DartHost::DartHost(Context *context) | 11 DartHost::DartHost(Context *context) |
14 : input_handler_(context->input_handler), | 12 : input_handler_(context->input_handler), |
15 timer_(context->timer), | 13 timer_(context->timer), |
16 graphics_(context->graphics), | 14 graphics_(context->graphics), |
17 vm_glue_(context->vm_glue), | 15 vm_glue_(context->vm_glue), |
18 active_(false) { | 16 active_(false) { |
19 Log::Print("Creating DartHost"); | 17 LOGI("Creating DartHost"); |
20 } | 18 } |
21 | 19 |
22 DartHost::~DartHost() { | 20 DartHost::~DartHost() { |
23 Log::Print("Freeing DartHost"); | 21 LOGI("Freeing DartHost"); |
24 } | 22 } |
25 | 23 |
26 int32_t DartHost::OnActivate() { | 24 int32_t DartHost::OnActivate() { |
27 return Activate(); | 25 return Activate(); |
28 } | 26 } |
29 | 27 |
30 int32_t DartHost::Activate() { | 28 int32_t DartHost::Activate() { |
31 if (!active_) { | 29 if (!active_) { |
32 Log::Print("Activating DartHost"); | 30 LOGI("Activating DartHost"); |
33 if (graphics_->Start() != 0) { | 31 if (graphics_->Start() != 0) { |
34 return -1; | 32 return -1; |
35 } | 33 } |
36 if (input_handler_->Start() != 0) { | 34 if (input_handler_->Start() != 0) { |
37 return -1; | 35 return -1; |
38 } | 36 } |
39 timer_->reset(); | 37 timer_->reset(); |
40 Log::Print("Starting main isolate"); | 38 LOGI("Starting main isolate"); |
41 int result = vm_glue_->StartMainIsolate(); | 39 int result = vm_glue_->StartMainIsolate(); |
42 if (result != 0) { | 40 if (result != 0) { |
43 Log::PrintErr("startMainIsolate returned %d", result); | 41 LOGE("startMainIsolate returned %d", result); |
44 return -1; | 42 return -1; |
45 } | 43 } |
46 active_ = true; | 44 active_ = true; |
47 vm_glue_->CallSetup(); | 45 vm_glue_->CallSetup(); |
48 } | 46 } |
49 return 0; | 47 return 0; |
50 } | 48 } |
51 | 49 |
52 void DartHost::OnDeactivate() { | 50 void DartHost::OnDeactivate() { |
53 Deactivate(); | 51 Deactivate(); |
54 } | 52 } |
55 | 53 |
56 void DartHost::Deactivate() { | 54 void DartHost::Deactivate() { |
57 if (active_) { | 55 if (active_) { |
58 active_ = false; | 56 active_ = false; |
59 vm_glue_->FinishMainIsolate(); | 57 vm_glue_->FinishMainIsolate(); |
60 Log::Print("Deactivating DartHost"); | 58 LOGI("Deactivating DartHost"); |
61 graphics_->Stop(); | 59 graphics_->Stop(); |
62 } | 60 } |
63 } | 61 } |
64 | 62 |
65 int32_t DartHost::OnStep() { | 63 int32_t DartHost::OnStep() { |
66 timer_->update(); | 64 timer_->update(); |
67 vm_glue_->CallUpdate(); | 65 vm_glue_->CallUpdate(); |
68 if (graphics_->Update() != 0) { | 66 if (graphics_->Update() != 0) { |
69 return -1; | 67 return -1; |
70 } | 68 } |
71 return 0; | 69 return 0; |
72 } | 70 } |
73 | 71 |
74 void DartHost::OnStart() { | 72 void DartHost::OnStart() { |
75 Log::Print("Starting DartHost"); | 73 LOGI("Starting DartHost"); |
76 } | 74 } |
77 | 75 |
78 void DartHost::OnResume() { | 76 void DartHost::OnResume() { |
79 Log::Print("Resuming DartHost"); | 77 LOGI("Resuming DartHost"); |
80 } | 78 } |
81 | 79 |
82 void DartHost::OnPause() { | 80 void DartHost::OnPause() { |
83 Log::Print("Pausing DartHost"); | 81 LOGI("Pausing DartHost"); |
84 } | 82 } |
85 | 83 |
86 void DartHost::OnStop() { | 84 void DartHost::OnStop() { |
87 Log::Print("Stopping DartHost"); | 85 LOGI("Stopping DartHost"); |
88 } | 86 } |
89 | 87 |
90 void DartHost::OnDestroy() { | 88 void DartHost::OnDestroy() { |
91 Log::Print("Destroying DartHost"); | 89 LOGI("Destroying DartHost"); |
92 } | 90 } |
93 | 91 |
94 void DartHost::OnSaveState(void** data, size_t size) { | 92 void DartHost::OnSaveState(void** data, size_t size) { |
95 Log::Print("Saving DartHost state"); | 93 LOGI("Saving DartHost state"); |
96 } | 94 } |
97 | 95 |
98 void DartHost::OnConfigurationChanged() { | 96 void DartHost::OnConfigurationChanged() { |
99 Log::Print("DartHost config changed"); | 97 LOGI("DartHost config changed"); |
100 } | 98 } |
101 | 99 |
102 void DartHost::OnLowMemory() { | 100 void DartHost::OnLowMemory() { |
103 Log::Print("DartHost low on memory"); | 101 LOGI("DartHost low on memory"); |
104 } | 102 } |
105 | 103 |
106 void DartHost::OnCreateWindow() { | 104 void DartHost::OnCreateWindow() { |
107 Log::Print("DartHost creating window"); | 105 LOGI("DartHost creating window"); |
108 } | 106 } |
109 | 107 |
110 void DartHost::OnDestroyWindow() { | 108 void DartHost::OnDestroyWindow() { |
111 Log::Print("DartHost destroying window"); | 109 LOGI("DartHost destroying window"); |
112 } | 110 } |
113 | 111 |
114 void DartHost::OnGainedFocus() { | 112 void DartHost::OnGainedFocus() { |
115 Log::Print("DartHost gained focus"); | 113 LOGI("DartHost gained focus"); |
116 } | 114 } |
117 | 115 |
118 void DartHost::OnLostFocus() { | 116 void DartHost::OnLostFocus() { |
119 Log::Print("DartHost lost focus"); | 117 LOGI("DartHost lost focus"); |
120 } | 118 } |
121 | 119 |
122 void DartHost::Clear() { | 120 void DartHost::Clear() { |
123 memset(window_buffer_.bits, 0, | 121 memset(window_buffer_.bits, 0, |
124 window_buffer_.stride * window_buffer_.height * sizeof(int32_t)); | 122 window_buffer_.stride * window_buffer_.height * sizeof(int32_t)); |
125 } | 123 } |
126 | |
OLD | NEW |