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

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

Issue 11434046: Android rayshader sample. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: 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
OLDNEW
(Empty)
1 #include "dart_host.h"
2
3 #include <unistd.h>
4 #include <math.h>
5
6 #include "vm/flags.h"
7 #include "bin/eventhandler.h"
8 #include "bin/isolate_data.h"
9 #include "bin/log.h"
10 #include "bin/platform.h"
11 #include "bin/process.h"
12
13 DartHost::DartHost(Context *pContext) :
14 mInputHandler(pContext->mInputHandler),
15 mTimer(pContext->mTimer),
16 mGraphics(pContext->mGraphics),
17 mVmGlue(pContext->mVmGlue),
18 mActive(false) {
19 Log::Print("Creating DartHost");
20 }
21
22 DartHost::~DartHost() {
23 Log::Print("Freeing DartHost");
24 }
25
26 int32_t DartHost::onActivate() {
27 return activate();
28 }
29
30 int32_t DartHost::activate() {
31 if (!mActive) {
32 Log::Print("Activating DartHost");
33 if (mGraphics->start() != 0) {
34 return -1;
35 }
36 if (mInputHandler->start() != 0) {
37 return -1;
38 }
39 mTimer->reset();
40 Log::Print("Starting main isolate");
41 int result = mVmGlue->startMainIsolate();
42 if (result != 0) {
43 Log::PrintErr("startMainIsolate returned %d", result);
44 return -1;
45 }
46 mActive = true;
47 mVmGlue->callSetup();
48 }
49 return 0;
50 }
51
52 void DartHost::onDeactivate() {
53 deactivate();
54 }
55
56 void DartHost::deactivate() {
57 if (mActive) {
58 mActive = false;
59 mVmGlue->finishMainIsolate();
60 Log::Print("Deactivating DartHost");
61 mGraphics->stop();
62 }
63 }
64
65 int32_t DartHost::onStep() {
66 mTimer->update();
67 mVmGlue->callUpdate();
68 if (mGraphics->update() != 0) {
69 return -1;
70 }
71 return 0;
72 }
73
74 void DartHost::onStart() {
75 Log::Print("Starting DartHost");
76 }
77
78 void DartHost::onResume() {
79 Log::Print("Resuming DartHost");
80 }
81
82 void DartHost::onPause() {
83 Log::Print("Pausing DartHost");
84 }
85
86 void DartHost::onStop() {
87 Log::Print("Stopping DartHost");
88 }
89
90 void DartHost::onDestroy() {
91 Log::Print("Destroying DartHost");
92 }
93
94 void DartHost::onSaveState(void** pData, int32_t pSize) {
95 Log::Print("Saving DartHost state");
96 }
97
98 void DartHost::onConfigurationChanged() {
99 Log::Print("DartHost config changed");
100 }
101
102 void DartHost::onLowMemory() {
103 Log::Print("DartHost low on memory");
104 }
105
106 void DartHost::onCreateWindow() {
107 Log::Print("DartHost creating window");
108 }
109
110 void DartHost::onDestroyWindow() {
111 Log::Print("DartHost destroying window");
112 }
113
114 void DartHost::onGainedFocus() {
115 Log::Print("DartHost gained focus");
116 }
117
118 void DartHost::onLostFocus() {
119 Log::Print("DartHost lost focus");
120 }
121
122 void DartHost::clear() {
123 memset(mWindowBuffer.bits, 0,
124 mWindowBuffer.stride * mWindowBuffer.height * sizeof(int32_t));
125 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698