diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llcommon/llframetimer.cpp | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llcommon/llframetimer.cpp | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/linden/indra/llcommon/llframetimer.cpp b/linden/indra/llcommon/llframetimer.cpp new file mode 100644 index 0000000..d41f904 --- /dev/null +++ b/linden/indra/llcommon/llframetimer.cpp | |||
@@ -0,0 +1,88 @@ | |||
1 | /** | ||
2 | * @file llframetimer.cpp | ||
3 | * | ||
4 | * Copyright (c) 2002-2007, Linden Research, Inc. | ||
5 | * | ||
6 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
7 | * to you under the terms of the GNU General Public License, version 2.0 | ||
8 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
9 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
10 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
11 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
12 | * | ||
13 | * There are special exceptions to the terms and conditions of the GPL as | ||
14 | * it is applied to this Source Code. View the full text of the exception | ||
15 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
16 | * online at http://secondlife.com/developers/opensource/flossexception | ||
17 | * | ||
18 | * By copying, modifying or distributing this software, you acknowledge | ||
19 | * that you have read and understood your obligations described above, | ||
20 | * and agree to abide by those obligations. | ||
21 | * | ||
22 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
23 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
24 | * COMPLETENESS OR PERFORMANCE. | ||
25 | */ | ||
26 | |||
27 | #include "linden_common.h" | ||
28 | |||
29 | #include "u64.h" | ||
30 | |||
31 | #include "llframetimer.h" | ||
32 | |||
33 | // Static members | ||
34 | //LLTimer LLFrameTimer::sInternalTimer; | ||
35 | U64 LLFrameTimer::sStartTotalTime = totalTime(); | ||
36 | F64 LLFrameTimer::sFrameTime = 0.0; | ||
37 | U64 LLFrameTimer::sTotalTime = 0; | ||
38 | F64 LLFrameTimer::sTotalSeconds = 0.0; | ||
39 | S32 LLFrameTimer::sFrameCount = 0; | ||
40 | U64 LLFrameTimer::sFrameDeltaTime = 0; | ||
41 | const F64 USEC_PER_SECOND = 1000000.0; | ||
42 | const F64 USEC_TO_SEC_F64 = 0.000001; | ||
43 | |||
44 | // static | ||
45 | void LLFrameTimer::updateFrameTime() | ||
46 | { | ||
47 | U64 total_time = totalTime(); | ||
48 | sFrameDeltaTime = total_time - sTotalTime; | ||
49 | sTotalTime = total_time; | ||
50 | sTotalSeconds = U64_to_F64(sTotalTime) * USEC_TO_SEC_F64; | ||
51 | sFrameTime = U64_to_F64(sTotalTime - sStartTotalTime) * USEC_TO_SEC_F64; | ||
52 | sFrameCount++; | ||
53 | } | ||
54 | |||
55 | void LLFrameTimer::setExpiryAt(F64 seconds_since_epoch) | ||
56 | { | ||
57 | mStartTime = sFrameTime; | ||
58 | mExpiry = seconds_since_epoch - (USEC_TO_SEC_F64 * sStartTotalTime); | ||
59 | } | ||
60 | |||
61 | F64 LLFrameTimer::expiresAt() const | ||
62 | { | ||
63 | F64 expires_at = U64_to_F64(sStartTotalTime) * USEC_TO_SEC_F64; | ||
64 | expires_at += mExpiry; | ||
65 | return expires_at; | ||
66 | } | ||
67 | |||
68 | BOOL LLFrameTimer::checkExpirationAndReset(F32 expiration) | ||
69 | { | ||
70 | //llinfos << "LLFrameTimer::checkExpirationAndReset()" << llendl; | ||
71 | //llinfos << " mStartTime:" << mStartTime << llendl; | ||
72 | //llinfos << " sFrameTime:" << sFrameTime << llendl; | ||
73 | //llinfos << " mExpiry: " << mExpiry << llendl; | ||
74 | |||
75 | if(hasExpired()) | ||
76 | { | ||
77 | reset(); | ||
78 | setTimerExpirySec(expiration); | ||
79 | return TRUE; | ||
80 | } | ||
81 | return FALSE; | ||
82 | } | ||
83 | |||
84 | // static | ||
85 | F32 LLFrameTimer::getFrameDeltaTimeF32() | ||
86 | { | ||
87 | return (F32)(U64_to_F64(sFrameDeltaTime) * USEC_TO_SEC_F64); | ||
88 | } | ||