OLD | NEW |
| (Empty) |
1 /* libs/graphics/animator/SkTime.cpp | |
2 ** | |
3 ** Copyright 2006, The Android Open Source Project | |
4 ** | |
5 ** Licensed under the Apache License, Version 2.0 (the "License"); | |
6 ** you may not use this file except in compliance with the License. | |
7 ** You may obtain a copy of the License at | |
8 ** | |
9 ** http://www.apache.org/licenses/LICENSE-2.0 | |
10 ** | |
11 ** Unless required by applicable law or agreed to in writing, software | |
12 ** distributed under the License is distributed on an "AS IS" BASIS, | |
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 ** See the License for the specific language governing permissions and | |
15 ** limitations under the License. | |
16 */ | |
17 | |
18 #include "SkTime.h" | |
19 | |
20 #ifdef SK_BUILD_FOR_WIN | |
21 | |
22 #ifdef SK_DEBUG | |
23 SkMSec gForceTickCount = (SkMSec) -1; | |
24 #endif | |
25 | |
26 void SkTime::GetDateTime(DateTime* t) | |
27 { | |
28 if (t) | |
29 { | |
30 SYSTEMTIME syst; | |
31 | |
32 ::GetLocalTime(&syst); | |
33 t->fYear = SkToU16(syst.wYear); | |
34 t->fMonth = SkToU8(syst.wMonth); | |
35 t->fDayOfWeek = SkToU8(syst.wDayOfWeek); | |
36 t->fDay = SkToU8(syst.wDay); | |
37 t->fHour = SkToU8(syst.wHour); | |
38 t->fMinute = SkToU8(syst.wMinute); | |
39 t->fSecond = SkToU8(syst.wSecond); | |
40 } | |
41 } | |
42 | |
43 SkMSec SkTime::GetMSecs() | |
44 { | |
45 #ifdef SK_DEBUG | |
46 if (gForceTickCount != (SkMSec) -1) | |
47 return gForceTickCount; | |
48 #endif | |
49 return ::GetTickCount(); | |
50 } | |
51 | |
52 #elif defined(xSK_BUILD_FOR_MAC) | |
53 | |
54 #include <time.h> | |
55 | |
56 void SkTime::GetDateTime(DateTime* t) | |
57 { | |
58 if (t) | |
59 { | |
60 tm syst; | |
61 time_t tm; | |
62 | |
63 time(&tm); | |
64 localtime_r(&tm, &syst); | |
65 t->fYear = SkToU16(syst.tm_year); | |
66 t->fMonth = SkToU8(syst.tm_mon + 1); | |
67 t->fDayOfWeek = SkToU8(syst.tm_wday); | |
68 t->fDay = SkToU8(syst.tm_mday); | |
69 t->fHour = SkToU8(syst.tm_hour); | |
70 t->fMinute = SkToU8(syst.tm_min); | |
71 t->fSecond = SkToU8(syst.tm_sec); | |
72 } | |
73 } | |
74 | |
75 #include "Sk64.h" | |
76 | |
77 SkMSec SkTime::GetMSecs() | |
78 { | |
79 UnsignedWide wide; | |
80 Sk64 s; | |
81 | |
82 ::Microseconds(&wide); | |
83 s.set(wide.hi, wide.lo); | |
84 s.div(1000, Sk64::kRound_DivOption); | |
85 return s.get32(); | |
86 } | |
87 | |
88 #endif | |
89 | |
OLD | NEW |