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

Side by Side Diff: runtime/embedders/openglui/android/eventloop.cc

Issue 12186002: Canvas API. There are still a number of things to do: (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 months 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
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 #include "embedders/openglui/android/eventloop.h" 5 #include "embedders/openglui/android/eventloop.h"
6 6
7 #include "embedders/openglui/common/log.h" 7 #include "embedders/openglui/common/log.h"
8 8
9 EventLoop::EventLoop(android_app* application) 9 EventLoop::EventLoop(android_app* application)
10 : enabled_(false), 10 : enabled_(false),
11 quit_(false), 11 quit_(false),
12 application_(application), 12 application_(application),
13 lifecycle_handler_(NULL), 13 lifecycle_handler_(NULL),
14 input_handler_(NULL) { 14 input_handler_(NULL) {
15 application_->onAppCmd = ActivityCallback; 15 application_->onAppCmd = ActivityCallback;
16 application_->onInputEvent = InputCallback; 16 application_->onInputEvent = InputCallback;
17 application_->userData = this; 17 application_->userData = this;
18 } 18 }
19 19
20 void EventLoop::Run(LifeCycleHandler* lifecycle_handler, 20 void EventLoop::Run(LifeCycleHandler* lifecycle_handler,
21 InputHandler* input_handler) { 21 InputHandler* input_handler) {
22 int32_t result; 22 int32_t result;
23 int32_t events; 23 int32_t events;
24 android_poll_source* source; 24 android_poll_source* source;
25 25
26 lifecycle_handler_ = lifecycle_handler; 26 lifecycle_handler_ = lifecycle_handler;
27 input_handler_ = input_handler; 27 input_handler_ = input_handler;
28 LOGI("Starting event loop"); 28 LOGI("Starting event loop");
29 while (true) { 29 while (true) {
30 // If not enabled, block on events. If enabled, don't block 30 // If not enabled, block indefinitely on events. If enabled, block
31 // so we can do useful work in onStep. 31 // briefly so we can do useful work in onStep. Ultimately this is
32 while ((result = ALooper_pollAll(enabled_ ? 0 : -1, 32 // where we would want to look at elapsed time since the last call
33 // to onStep completed and use a delay that gives us ~60fps.
34 while ((result = ALooper_pollAll(enabled_ ? (1000/60) : -1,
33 NULL, 35 NULL,
34 &events, 36 &events,
35 reinterpret_cast<void**>(&source))) >= 0) { 37 reinterpret_cast<void**>(&source))) >= 0) {
36 if (source != NULL) { 38 if (source != NULL) {
37 source->process(application_, source); 39 source->process(application_, source);
38 } 40 }
39 if (application_->destroyRequested) { 41 if (application_->destroyRequested) {
40 return; 42 return;
41 } 43 }
42 } 44 }
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 EventLoop* event_loop = reinterpret_cast<EventLoop*>(application->userData); 231 EventLoop* event_loop = reinterpret_cast<EventLoop*>(application->userData);
230 event_loop->ProcessActivityEvent(command); 232 event_loop->ProcessActivityEvent(command);
231 } 233 }
232 234
233 int32_t EventLoop::InputCallback(android_app* application, 235 int32_t EventLoop::InputCallback(android_app* application,
234 AInputEvent* event) { 236 AInputEvent* event) {
235 EventLoop* event_loop = reinterpret_cast<EventLoop*>(application->userData); 237 EventLoop* event_loop = reinterpret_cast<EventLoop*>(application->userData);
236 return event_loop->ProcessInputEvent(event); 238 return event_loop->ProcessInputEvent(event);
237 } 239 }
238 240
OLDNEW
« no previous file with comments | « runtime/embedders/openglui/android/android_graphics_handler.cc ('k') | runtime/embedders/openglui/build_skia.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698