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

Side by Side Diff: runtime/embedders/openglui/common/timer.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
« no previous file with comments | « runtime/embedders/openglui/common/timer.h ('k') | runtime/embedders/openglui/common/vm_glue.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/common/timer.h" 5 #include "embedders/openglui/common/timer.h"
6 6
7 #define NANO (+1.0E-9) 7 #define NANO (+1.0E-9)
8 8
9 #ifdef __MACH__ 9 #ifdef __MACH__
10 #include <mach/mach.h> 10 #include <mach/mach.h>
(...skipping 25 matching lines...) Expand all
36 gettimeofday(&now, NULL); 36 gettimeofday(&now, NULL);
37 t->tv_sec = now.tv_sec; 37 t->tv_sec = now.tv_sec;
38 t->tv_nsec = now.tv_usec * 1000; 38 t->tv_nsec = now.tv_usec * 1000;
39 } 39 }
40 } 40 }
41 #endif 41 #endif
42 42
43 Timer::Timer() : elapsed_(0.0f), last_time_(0.0) { 43 Timer::Timer() : elapsed_(0.0f), last_time_(0.0) {
44 } 44 }
45 45
46 void Timer::reset() { 46 void Timer::Reset() {
47 elapsed_ = 0.0f; 47 elapsed_ = 0.0f;
48 last_time_ = now(); 48 last_time_ = Now();
49 } 49 }
50 50
51 void Timer::update() { 51 void Timer::Update() {
52 double current = now(); 52 double current = Now();
53 elapsed_ = (current - last_time_); 53 elapsed_ = (current - last_time_);
54 last_time_ = current; 54 last_time_ = current;
55 } 55 }
56 56
57 double Timer::now() { 57 double Timer::Now() {
58 timespec timeval; 58 timespec timeval;
59 clock_gettime(CLOCK_MONOTONIC, &timeval); 59 clock_gettime(CLOCK_MONOTONIC, &timeval);
60 return timeval.tv_sec + (timeval.tv_nsec * NANO); 60 return timeval.tv_sec + (timeval.tv_nsec * NANO);
61 } 61 }
62 62
63 float Timer::elapsed() { 63 float Timer::Elapsed() {
64 return elapsed_; 64 return elapsed_;
65 } 65 }
66 66
OLDNEW
« no previous file with comments | « runtime/embedders/openglui/common/timer.h ('k') | runtime/embedders/openglui/common/vm_glue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698