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

Side by Side Diff: runtime/embedders/openglui/common/dart_host.cc

Issue 25081002: Remove openglui embedder code (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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
(Empty)
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
5 #include "embedders/openglui/common/dart_host.h"
6
7 #include <math.h>
8 #include <unistd.h>
9
10 #include "embedders/openglui/common/image_cache.h"
11 #include "embedders/openglui/common/log.h"
12
13 DartHost::DartHost(Context *context)
14 : graphics_handler_(context->graphics_handler),
15 input_handler_(context->input_handler),
16 sound_handler_(context->sound_handler),
17 timer_(context->timer),
18 vm_glue_(context->vm_glue),
19 has_context_(false),
20 started_(false),
21 active_(false) {
22 ImageCache::Init(graphics_handler_->resource_path());
23 }
24
25 DartHost::~DartHost() {
26 }
27
28 int32_t DartHost::OnStart() {
29 int result = vm_glue_->StartMainIsolate();
30 if (result != 0) {
31 LOGE("startMainIsolate returned %d", result);
32 return -1;
33 }
34 started_ = true;
35 return 0;
36 }
37
38 int32_t DartHost::Activate() {
39 if (!has_context_) {
40 if (graphics_handler_->Start() != 0) {
41 return -1;
42 }
43 if (sound_handler_->Start() != 0) {
44 graphics_handler_->Stop();
45 return -1;
46 }
47 if (input_handler_->Start() != 0) {
48 sound_handler_->Stop();
49 graphics_handler_->Stop();
50 return -1;
51 }
52 int32_t rtn = vm_glue_->CallSetup(true);
53 timer_->Reset();
54 has_context_ = true;
55 return rtn;
56 }
57 return 0;
58 }
59
60 void DartHost::Deactivate() {
61 Pause();
62 if (has_context_) {
63 vm_glue_->CallShutdown();
64 input_handler_->Stop();
65 sound_handler_->Stop();
66 graphics_handler_->Stop();
67 has_context_ = false;
68 }
69 }
70
71 int32_t DartHost::OnStep() {
72 if (active_) {
73 timer_->Update();
74 if (vm_glue_->CallUpdate() != 0 ||
75 graphics_handler_->Update() != 0) {
76 return -1;
77 }
78 }
79 return 0;
80 }
81
82 int32_t DartHost::Resume() {
83 if (!active_) {
84 if (Activate() == 0) {
85 sound_handler_->Resume();
86 active_ = true;
87 }
88 }
89 return 0;
90 }
91
92 void DartHost::Pause() {
93 if (active_) {
94 active_ = false; // This stops update() calls.
95 sound_handler_->Suspend();
96 }
97 }
98
99 void DartHost::FreeAllResources() {
100 if (started_) {
101 vm_glue_->FinishMainIsolate();
102 started_ = false;
103 }
104 }
105
106 void DartHost::OnSaveState(void** data, size_t* size) {
107 LOGI("Saving DartHost state");
108 }
109
110 void DartHost::OnConfigurationChanged() {
111 LOGI("DartHost config changed");
112 }
113
114 void DartHost::OnLowMemory() {
115 LOGI("DartHost low on memory");
116 }
117
OLDNEW
« no previous file with comments | « runtime/embedders/openglui/common/dart_host.h ('k') | runtime/embedders/openglui/common/events.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698