OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkEvent.h" | 10 #include "SkEvent.h" |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 | 291 |
292 /////////////////////////////////////////////////////////////////////////////// | 292 /////////////////////////////////////////////////////////////////////////////// |
293 | 293 |
294 void SkEvent::postDelay(SkMSec delay) { | 294 void SkEvent::postDelay(SkMSec delay) { |
295 if (!fTargetID && !fTargetProc) { | 295 if (!fTargetID && !fTargetProc) { |
296 delete this; | 296 delete this; |
297 return; | 297 return; |
298 } | 298 } |
299 | 299 |
300 if (delay) { | 300 if (delay) { |
301 this->postTime(SkTime::GetMSecs() + delay); | 301 this->postTime(GetMSecsSinceStartup() + delay); |
302 return; | 302 return; |
303 } | 303 } |
304 | 304 |
305 SkEvent_Globals& globals = getGlobals(); | 305 SkEvent_Globals& globals = getGlobals(); |
306 | 306 |
307 globals.fEventMutex.acquire(); | 307 globals.fEventMutex.acquire(); |
308 bool wasEmpty = SkEvent::Enqueue(this); | 308 bool wasEmpty = SkEvent::Enqueue(this); |
309 globals.fEventMutex.release(); | 309 globals.fEventMutex.release(); |
310 | 310 |
311 // call outside of us holding the mutex | 311 // call outside of us holding the mutex |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 } | 397 } |
398 | 398 |
399 evt->fTime = time; | 399 evt->fTime = time; |
400 evt->fNextEvent = curr; | 400 evt->fNextEvent = curr; |
401 if (prev == nullptr) { | 401 if (prev == nullptr) { |
402 globals.fDelayQHead = evt; | 402 globals.fDelayQHead = evt; |
403 } else { | 403 } else { |
404 prev->fNextEvent = evt; | 404 prev->fNextEvent = evt; |
405 } | 405 } |
406 | 406 |
407 SkMSec delay = globals.fDelayQHead->fTime - SkTime::GetMSecs(); | 407 SkMSec delay = globals.fDelayQHead->fTime - GetMSecsSinceStartup(); |
408 if ((int32_t)delay <= 0) { | 408 if ((int32_t)delay <= 0) { |
409 delay = 1; | 409 delay = 1; |
410 } | 410 } |
411 return delay; | 411 return delay; |
412 } | 412 } |
413 | 413 |
414 /////////////////////////////////////////////////////////////////////////////// | 414 /////////////////////////////////////////////////////////////////////////////// |
415 | 415 |
416 #include "SkEventSink.h" | 416 #include "SkEventSink.h" |
417 | 417 |
(...skipping 11 matching lines...) Expand all Loading... |
429 return again; | 429 return again; |
430 } | 430 } |
431 | 431 |
432 void SkEvent::ServiceQueueTimer() | 432 void SkEvent::ServiceQueueTimer() |
433 { | 433 { |
434 SkEvent_Globals& globals = getGlobals(); | 434 SkEvent_Globals& globals = getGlobals(); |
435 | 435 |
436 globals.fEventMutex.acquire(); | 436 globals.fEventMutex.acquire(); |
437 | 437 |
438 bool wasEmpty = false; | 438 bool wasEmpty = false; |
439 SkMSec now = SkTime::GetMSecs(); | 439 SkMSec now = GetMSecsSinceStartup(); |
440 SkEvent* evt = globals.fDelayQHead; | 440 SkEvent* evt = globals.fDelayQHead; |
441 | 441 |
442 while (evt) | 442 while (evt) |
443 { | 443 { |
444 if (SkMSec_LT(now, evt->fTime)) | 444 if (SkMSec_LT(now, evt->fTime)) |
445 break; | 445 break; |
446 | 446 |
447 #ifdef SK_TRACE_EVENTS | 447 #ifdef SK_TRACE_EVENTS |
448 --gDelayDepth; | 448 --gDelayDepth; |
449 SkDebugf("dequeue-delay %s (%d)", evt->getType(), gDelayDepth); | 449 SkDebugf("dequeue-delay %s (%d)", evt->getType(), gDelayDepth); |
(...skipping 28 matching lines...) Expand all Loading... |
478 const SkEvent* evt = globals.fEventQHead; | 478 const SkEvent* evt = globals.fEventQHead; |
479 while (evt) { | 479 while (evt) { |
480 count += 1; | 480 count += 1; |
481 evt = evt->fNextEvent; | 481 evt = evt->fNextEvent; |
482 } | 482 } |
483 globals.fEventMutex.release(); | 483 globals.fEventMutex.release(); |
484 | 484 |
485 return count; | 485 return count; |
486 } | 486 } |
487 | 487 |
| 488 SkMSec SkEvent::GetMSecsSinceStartup() { |
| 489 static const double kEpoch = SkTime::GetMSecs(); |
| 490 return static_cast<SkMSec>(SkTime::GetMSecs() - kEpoch); |
| 491 } |
| 492 |
488 /////////////////////////////////////////////////////////////////////////////// | 493 /////////////////////////////////////////////////////////////////////////////// |
489 | 494 |
490 void SkEvent::Init() {} | 495 void SkEvent::Init() {} |
491 | 496 |
492 void SkEvent::Term() { | 497 void SkEvent::Term() { |
493 SkEvent_Globals& globals = getGlobals(); | 498 SkEvent_Globals& globals = getGlobals(); |
494 | 499 |
495 SkEvent* evt = globals.fEventQHead; | 500 SkEvent* evt = globals.fEventQHead; |
496 while (evt) { | 501 while (evt) { |
497 SkEvent* next = evt->fNextEvent; | 502 SkEvent* next = evt->fNextEvent; |
498 delete evt; | 503 delete evt; |
499 evt = next; | 504 evt = next; |
500 } | 505 } |
501 | 506 |
502 evt = globals.fDelayQHead; | 507 evt = globals.fDelayQHead; |
503 while (evt) { | 508 while (evt) { |
504 SkEvent* next = evt->fNextEvent; | 509 SkEvent* next = evt->fNextEvent; |
505 delete evt; | 510 delete evt; |
506 evt = next; | 511 evt = next; |
507 } | 512 } |
508 } | 513 } |
OLD | NEW |