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

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

Issue 12340036: Android improvements: (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 <math.h> 5 #include <math.h>
6 #include <stdarg.h> 6 #include <stdarg.h>
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <string.h> 9 #include <string.h>
10 #include <sys/stat.h> 10 #include <sys/stat.h>
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 191
192 Dart_Handle url = CheckError(Dart_NewStringFromCString(main_script_)); 192 Dart_Handle url = CheckError(Dart_NewStringFromCString(main_script_));
193 Dart_Handle source = LoadSourceFromFile(main_script_); 193 Dart_Handle source = LoadSourceFromFile(main_script_);
194 CheckError(Dart_LoadScript(url, source)); 194 CheckError(Dart_LoadScript(url, source));
195 195
196 Dart_ExitScope(); 196 Dart_ExitScope();
197 Dart_ExitIsolate(); 197 Dart_ExitIsolate();
198 return 0; 198 return 0;
199 } 199 }
200 200
201 int VMGlue::CallSetup() { 201 int VMGlue::CallSetup(bool force) {
202 if (!initialized_script_) { 202 // TODO(gram): See if we actually need this flag guard here, or if
203 // we can eliminate it along with the need for the force parameter.
204 if (!initialized_script_ || force) {
203 initialized_script_ = true; 205 initialized_script_ = true;
204 LOGI("Invoking setup(NULL, %d,%d)", surface_->width(), surface_->height()); 206 LOGI("Invoking setup(NULL, %d,%d)", surface_->width(), surface_->height());
205 Dart_EnterIsolate(isolate_); 207 Dart_EnterIsolate(isolate_);
206 Dart_EnterScope(); 208 Dart_EnterScope();
207 Dart_Handle args[3]; 209 Dart_Handle args[3];
208 args[0] = CheckError(Dart_Null()); 210 args[0] = CheckError(Dart_Null());
209 args[1] = CheckError(Dart_NewInteger(surface_->width())); 211 args[1] = CheckError(Dart_NewInteger(surface_->width()));
210 args[2] = CheckError(Dart_NewInteger(surface_->height())); 212 args[2] = CheckError(Dart_NewInteger(surface_->height()));
211 int rtn = Invoke("setup", 3, args); 213 int rtn = Invoke("setup", 3, args);
212 214
(...skipping 13 matching lines...) Expand all
226 Dart_ExitScope(); 228 Dart_ExitScope();
227 Dart_ExitIsolate(); 229 Dart_ExitIsolate();
228 LOGI("Done setup"); 230 LOGI("Done setup");
229 return rtn; 231 return rtn;
230 } 232 }
231 return 0; 233 return 0;
232 } 234 }
233 235
234 int VMGlue::CallUpdate() { 236 int VMGlue::CallUpdate() {
235 if (initialized_script_) { 237 if (initialized_script_) {
236 LOGI("Invoking update"); 238 // LOGI("Invoking update");
vsm 2013/02/23 00:25:25 Maybe these commented out LOGIs could just be dele
237 Dart_EnterIsolate(isolate_); 239 Dart_EnterIsolate(isolate_);
238 Dart_EnterScope(); 240 Dart_EnterScope();
239 int rtn = Invoke("update", 0, 0); 241 int rtn = Invoke("update", 0, 0);
240 Dart_ExitScope(); 242 Dart_ExitScope();
241 Dart_ExitIsolate(); 243 Dart_ExitIsolate();
242 LOGI("Done update"); 244 // LOGI("Done update");
245 return rtn;
246 }
247 return -1;
248 }
249
250 int VMGlue::CallShutdown() {
251 if (initialized_script_) {
252 // LOGI("Invoking update");
253 Dart_EnterIsolate(isolate_);
254 Dart_EnterScope();
255 int rtn = Invoke("shutdown", 0, 0);
256 Dart_ExitScope();
257 Dart_ExitIsolate();
258 // LOGI("Done update");
243 return rtn; 259 return rtn;
244 } 260 }
245 return -1; 261 return -1;
246 } 262 }
247 263
248 int VMGlue::OnMotionEvent(const char* pFunction, int64_t pWhen, 264 int VMGlue::OnMotionEvent(const char* pFunction, int64_t pWhen,
249 float pMoveX, float pMoveY) { 265 float pMoveX, float pMoveY) {
250 if (initialized_script_) { 266 if (initialized_script_) {
251 LOGI("Invoking %s", pFunction); 267 LOGI("Invoking %s", pFunction);
252 Dart_EnterIsolate(isolate_); 268 Dart_EnterIsolate(isolate_);
(...skipping 29 matching lines...) Expand all
282 LOGI("Done %s", function); 298 LOGI("Done %s", function);
283 return rtn; 299 return rtn;
284 } 300 }
285 return -1; 301 return -1;
286 } 302 }
287 303
288 int VMGlue::Invoke(const char* function, 304 int VMGlue::Invoke(const char* function,
289 int argc, 305 int argc,
290 Dart_Handle* args, 306 Dart_Handle* args,
291 bool failIfNotDefined) { 307 bool failIfNotDefined) {
292 LOGI("in invoke(%s)", function); 308 // LOGI("in invoke(%s)", function);
293 309
294 // Lookup the library of the root script. 310 // Lookup the library of the root script.
295 LOGI("looking up the root library"); 311 // LOGI("looking up the root library");
296 Dart_Handle library = Dart_RootLibrary(); 312 Dart_Handle library = Dart_RootLibrary();
297 if (Dart_IsNull(library)) { 313 if (Dart_IsNull(library)) {
298 LOGE("Unable to find root library\n"); 314 LOGE("Unable to find root library\n");
299 return -1; 315 return -1;
300 } 316 }
301 317
302 Dart_Handle nameHandle = Dart_NewStringFromCString(function); 318 Dart_Handle nameHandle = Dart_NewStringFromCString(function);
303 319
304 LOGI("invoking %s", function); 320 // LOGI("invoking %s", function);
305 Dart_Handle result = Dart_Invoke(library, nameHandle, argc, args); 321 Dart_Handle result = Dart_Invoke(library, nameHandle, argc, args);
306 322
307 if (Dart_IsError(result)) { 323 if (Dart_IsError(result)) {
308 const char* error = Dart_GetError(result); 324 const char* error = Dart_GetError(result);
309 LOGE("Invoke %s failed: %s", function, error); 325 LOGE("Invoke %s failed: %s", function, error);
310 if (failIfNotDefined) { 326 if (failIfNotDefined) {
311 return -1; 327 return -1;
312 } 328 }
313 } 329 }
314 330
315 // TODO(vsm): I don't think we need this. 331 // TODO(vsm): I don't think we need this.
316 // Keep handling messages until the last active receive port is closed. 332 // Keep handling messages until the last active receive port is closed.
317 LOGI("Entering Dart message loop"); 333 // LOGI("Entering Dart message loop");
318 result = Dart_RunLoop(); 334 result = Dart_RunLoop();
319 if (Dart_IsError(result)) { 335 if (Dart_IsError(result)) {
320 LOGE("Dart_RunLoop: %s\n", Dart_GetError(result)); 336 LOGE("Dart_RunLoop: %s\n", Dart_GetError(result));
321 return -1; 337 return -1;
322 } 338 }
323 339
324 LOGI("out invoke"); 340 // LOGI("out invoke");
325 return 0; 341 return 0;
326 } 342 }
327 343
328 void VMGlue::FinishMainIsolate() { 344 void VMGlue::FinishMainIsolate() {
329 LOGI("Finish main isolate"); 345 LOGI("Finish main isolate");
330 Dart_EnterIsolate(isolate_); 346 Dart_EnterIsolate(isolate_);
331 // Shutdown the isolate. 347 // Shutdown the isolate.
332 Dart_ShutdownIsolate(); 348 Dart_ShutdownIsolate();
333 isolate_ = NULL; 349 isolate_ = NULL;
334 initialized_script_ = false; 350 initialized_script_ = false;
335 } 351 }
336 352
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698