Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: samples/android_sample/jni/dart_host.cc

Issue 11416343: Refactored Android samples / embedder. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix type error on playBackground Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « samples/android_sample/jni/dart_host.h ('k') | samples/android_sample/jni/eventloop.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
1 #include "jni/dart_host.h" 5 #include "jni/dart_host.h"
2 6
3 #include <math.h> 7 #include <math.h>
4 #include <unistd.h> 8 #include <unistd.h>
5 9
6 #include "bin/eventhandler.h" 10 #include "jni/log.h"
7 #include "bin/isolate_data.h"
8 #include "bin/log.h"
9 #include "bin/platform.h"
10 #include "bin/process.h"
11 #include "vm/flags.h"
12 11
13 DartHost::DartHost(Context *context) 12 DartHost::DartHost(Context *context)
14 : graphics_(context->graphics), 13 : graphics_(context->graphics),
15 input_handler_(context->input_handler), 14 input_handler_(context->input_handler),
16 sound_service_(context->sound_service), 15 sound_service_(context->sound_service),
17 timer_(context->timer), 16 timer_(context->timer),
18 vm_glue_(context->vm_glue), 17 vm_glue_(context->vm_glue),
19 active_(false) { 18 active_(false) {
20 Log::Print("Creating DartHost"); 19 LOGI("Creating DartHost");
21 } 20 }
22 21
23 DartHost::~DartHost() { 22 DartHost::~DartHost() {
24 Log::Print("Freeing DartHost"); 23 LOGI("Freeing DartHost");
25 } 24 }
26 25
27 int32_t DartHost::OnActivate() { 26 int32_t DartHost::OnActivate() {
28 return Activate(); 27 return Activate();
29 } 28 }
30 29
31 int32_t DartHost::Activate() { 30 int32_t DartHost::Activate() {
32 if (!active_) { 31 if (!active_) {
33 Log::Print("Activating DartHost"); 32 LOGI("Activating DartHost");
34 if (graphics_->Start() != 0) { 33 if (graphics_->Start() != 0) {
35 return -1; 34 return -1;
36 } 35 }
37 if (sound_service_->Start() != 0) { 36 if (sound_service_->Start() != 0) {
38 return -1; 37 return -1;
39 } 38 }
40 if (input_handler_->Start() != 0) { 39 if (input_handler_->Start() != 0) {
41 return -1; 40 return -1;
42 } 41 }
43 timer_->reset(); 42 timer_->reset();
44 Log::Print("Starting main isolate"); 43 LOGI("Starting main isolate");
45 int result = vm_glue_->StartMainIsolate(); 44 int result = vm_glue_->StartMainIsolate();
46 if (result != 0) { 45 if (result != 0) {
47 Log::PrintErr("startMainIsolate returned %d", result); 46 LOGE("startMainIsolate returned %d", result);
48 return -1; 47 return -1;
49 } 48 }
50 active_ = true; 49 active_ = true;
51 vm_glue_->CallSetup(); 50 vm_glue_->CallSetup();
52 } 51 }
53 return 0; 52 return 0;
54 } 53 }
55 54
56 void DartHost::OnDeactivate() { 55 void DartHost::OnDeactivate() {
57 Deactivate(); 56 Deactivate();
58 } 57 }
59 58
60 void DartHost::Deactivate() { 59 void DartHost::Deactivate() {
61 if (active_) { 60 if (active_) {
62 active_ = false; 61 active_ = false;
63 vm_glue_->FinishMainIsolate(); 62 vm_glue_->FinishMainIsolate();
64 Log::Print("Deactivating DartHost"); 63 LOGI("Deactivating DartHost");
65 sound_service_->Stop(); 64 sound_service_->Stop();
66 graphics_->Stop(); 65 graphics_->Stop();
67 } 66 }
68 } 67 }
69 68
70 int32_t DartHost::OnStep() { 69 int32_t DartHost::OnStep() {
71 timer_->update(); 70 timer_->update();
72 vm_glue_->CallUpdate(); 71 vm_glue_->CallUpdate();
73 if (graphics_->Update() != 0) { 72 if (graphics_->Update() != 0) {
74 return -1; 73 return -1;
75 } 74 }
76 return 0; 75 return 0;
77 } 76 }
78 77
79 void DartHost::OnStart() { 78 void DartHost::OnStart() {
80 Log::Print("Starting DartHost"); 79 LOGI("Starting DartHost");
81 } 80 }
82 81
83 void DartHost::OnResume() { 82 void DartHost::OnResume() {
84 Log::Print("Resuming DartHost"); 83 LOGI("Resuming DartHost");
85 } 84 }
86 85
87 void DartHost::OnPause() { 86 void DartHost::OnPause() {
88 Log::Print("Pausing DartHost"); 87 LOGI("Pausing DartHost");
89 } 88 }
90 89
91 void DartHost::OnStop() { 90 void DartHost::OnStop() {
92 Log::Print("Stopping DartHost"); 91 LOGI("Stopping DartHost");
93 } 92 }
94 93
95 void DartHost::OnDestroy() { 94 void DartHost::OnDestroy() {
96 Log::Print("Destroying DartHost"); 95 LOGI("Destroying DartHost");
97 } 96 }
98 97
99 void DartHost::OnSaveState(void** data, size_t size) { 98 void DartHost::OnSaveState(void** data, size_t size) {
100 Log::Print("Saving DartHost state"); 99 LOGI("Saving DartHost state");
101 } 100 }
102 101
103 void DartHost::OnConfigurationChanged() { 102 void DartHost::OnConfigurationChanged() {
104 Log::Print("DartHost config changed"); 103 LOGI("DartHost config changed");
105 } 104 }
106 105
107 void DartHost::OnLowMemory() { 106 void DartHost::OnLowMemory() {
108 Log::Print("DartHost low on memory"); 107 LOGI("DartHost low on memory");
109 } 108 }
110 109
111 void DartHost::OnCreateWindow() { 110 void DartHost::OnCreateWindow() {
112 Log::Print("DartHost creating window"); 111 LOGI("DartHost creating window");
113 } 112 }
114 113
115 void DartHost::OnDestroyWindow() { 114 void DartHost::OnDestroyWindow() {
116 Log::Print("DartHost destroying window"); 115 LOGI("DartHost destroying window");
117 } 116 }
118 117
119 void DartHost::OnGainedFocus() { 118 void DartHost::OnGainedFocus() {
120 Log::Print("DartHost gained focus"); 119 LOGI("DartHost gained focus");
121 } 120 }
122 121
123 void DartHost::OnLostFocus() { 122 void DartHost::OnLostFocus() {
124 Log::Print("DartHost lost focus"); 123 LOGI("DartHost lost focus");
125 } 124 }
126 125
127 void DartHost::Clear() { 126 void DartHost::Clear() {
128 memset(window_buffer_.bits, 0, 127 memset(window_buffer_.bits, 0,
129 window_buffer_.stride * window_buffer_.height * sizeof(int32_t)); 128 window_buffer_.stride * window_buffer_.height * sizeof(int32_t));
130 } 129 }
131
OLDNEW
« no previous file with comments | « samples/android_sample/jni/dart_host.h ('k') | samples/android_sample/jni/eventloop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698