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

Side by Side Diff: src/views/SkEvent.cpp

Issue 1811613004: Change SkTime::GetMSecs to double; ensure values stored in SkMSec do not overflow. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Rebase. Created 4 years, 8 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
« no previous file with comments | « src/pdf/SkPDFMetadata.cpp ('k') | src/views/SkTouchGesture.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
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 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFMetadata.cpp ('k') | src/views/SkTouchGesture.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698