aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@google.com>2015-10-23 06:40:33 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-10-23 06:40:33 -0700
commit3b5b7845428a94402c1984c175ecce83cc963c21 (patch)
tree2076a03c9e01fe3146e64755f54684abd3ea9497 /src/ports
parent38a88e4c0c28a7be981aac7bb4a198ad95a62a63 (diff)
Revert of SkTime::GetNSecs() (patchset #11 id:200001 of https://codereview.chromium.org/1422513003/ )
Reason for revert: Times don't look like they make sense on Windows. Original issue's description: > SkTime::GetNSecs() > > - Move high-precision wall timers from tools/timer to SkTime. > - Implement SkTime::GetMSecs() in terms of SkTime::GetNSecs(). > - Delete unused tools/timer code. > > I have no idea what's going on there in src/animator. > I don't intend to investigate. > > BUG=skia: > > Committed: https://skia.googlesource.com/skia/+/70084cbc16ee8162649f2601377feb6e49de0217 > > CQ_EXTRA_TRYBOTS=client.skia.compile:Build-Ubuntu-GCC-x86_64-Debug-CrOS_Link-Trybot > > Committed: https://skia.googlesource.com/skia/+/a1840d50e29fd95e4df2d1168fe54c34c2a5c30c > > Committed: https://skia.googlesource.com/skia/+/38a88e4c0c28a7be981aac7bb4a198ad95a62a63 TBR=caryclark@google.com,reed@google.com,mtklein@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1422623003
Diffstat (limited to 'src/ports')
-rw-r--r--src/ports/SkTime_Unix.cpp7
-rw-r--r--src/ports/SkTime_win.cpp11
2 files changed, 18 insertions, 0 deletions
diff --git a/src/ports/SkTime_Unix.cpp b/src/ports/SkTime_Unix.cpp
index 1ea3b8fbd0..ec96bb8a90 100644
--- a/src/ports/SkTime_Unix.cpp
+++ b/src/ports/SkTime_Unix.cpp
@@ -34,3 +34,10 @@ void SkTime::GetDateTime(DateTime* dt)
dt->fSecond = SkToU8(tstruct->tm_sec);
}
}
+
+SkMSec SkTime::GetMSecs()
+{
+ struct timeval tv;
+ gettimeofday(&tv, nullptr);
+ return (SkMSec) (tv.tv_sec * 1000 + tv.tv_usec / 1000 ); // microseconds to milliseconds
+}
diff --git a/src/ports/SkTime_win.cpp b/src/ports/SkTime_win.cpp
index 2bd5062c3c..19f4695a86 100644
--- a/src/ports/SkTime_win.cpp
+++ b/src/ports/SkTime_win.cpp
@@ -39,3 +39,14 @@ void SkTime::GetDateTime(DateTime* dt)
dt->fSecond = SkToU8(st.wSecond);
}
}
+
+SkMSec SkTime::GetMSecs()
+{
+ FILETIME ft;
+ LARGE_INTEGER li;
+ GetSystemTimeAsFileTime(&ft);
+ li.LowPart = ft.dwLowDateTime;
+ li.HighPart = ft.dwHighDateTime;
+ __int64 t = li.QuadPart; /* In 100-nanosecond intervals */
+ return (SkMSec)(t / 10000); /* In milliseconds */
+}