mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 487515 - PRMJ_Now needs better granularity for panning in fennec r=crowder, robarnold
This commit is contained in:
parent
bed8a86165
commit
073360a19a
@ -165,10 +165,25 @@ static const JSInt64 win2un = JSLL_INIT(0x19DB1DE, 0xD53E8000);
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_GETSYSTEMTIMEASFILETIME
|
#if defined(HAVE_GETSYSTEMTIMEASFILETIME) || defined(HAVE_SYSTEMTIMETOFILETIME)
|
||||||
|
|
||||||
typedef struct CalibrationData
|
#if defined(HAVE_GETSYSTEMTIMEASFILETIME)
|
||||||
|
inline void
|
||||||
|
LowResTime(LPFILETIME lpft)
|
||||||
{
|
{
|
||||||
|
GetSystemTimeAsFileTime(lpft);
|
||||||
|
}
|
||||||
|
#elif defined(HAVE_SYSTEMTIMETOFILETIME)
|
||||||
|
inline void
|
||||||
|
LowResTime(LPFILETIME lpft)
|
||||||
|
{
|
||||||
|
GetCurrentFT(lpft);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#error "No implementation of PRMJ_Now was selected."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct CalibrationData {
|
||||||
long double freq; /* The performance counter frequency */
|
long double freq; /* The performance counter frequency */
|
||||||
long double offset; /* The low res 'epoch' */
|
long double offset; /* The low res 'epoch' */
|
||||||
long double timer_offset; /* The high res 'epoch' */
|
long double timer_offset; /* The high res 'epoch' */
|
||||||
@ -182,6 +197,9 @@ typedef struct CalibrationData
|
|||||||
CRITICAL_SECTION data_lock;
|
CRITICAL_SECTION data_lock;
|
||||||
CRITICAL_SECTION calibration_lock;
|
CRITICAL_SECTION calibration_lock;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef WINCE
|
||||||
|
JSInt64 granularity;
|
||||||
|
#endif
|
||||||
} CalibrationData;
|
} CalibrationData;
|
||||||
|
|
||||||
static CalibrationData calibration = { 0 };
|
static CalibrationData calibration = { 0 };
|
||||||
@ -206,12 +224,16 @@ NowCalibrate()
|
|||||||
/* By wrapping a timeBegin/EndPeriod pair of calls around this loop,
|
/* By wrapping a timeBegin/EndPeriod pair of calls around this loop,
|
||||||
the loop seems to take much less time (1 ms vs 15ms) on Vista. */
|
the loop seems to take much less time (1 ms vs 15ms) on Vista. */
|
||||||
timeBeginPeriod(1);
|
timeBeginPeriod(1);
|
||||||
GetSystemTimeAsFileTime(&ftStart);
|
LowResTime(&ftStart);
|
||||||
do {
|
do {
|
||||||
GetSystemTimeAsFileTime(&ft);
|
LowResTime(&ft);
|
||||||
} while (memcmp(&ftStart,&ft, sizeof(ft)) == 0);
|
} while (memcmp(&ftStart,&ft, sizeof(ft)) == 0);
|
||||||
timeEndPeriod(1);
|
timeEndPeriod(1);
|
||||||
|
|
||||||
|
#ifdef WINCE
|
||||||
|
calibration.granularity = (FILETIME2INT64(ft) -
|
||||||
|
FILETIME2INT64(ftStart))/10;
|
||||||
|
#endif
|
||||||
/*
|
/*
|
||||||
calibrationDelta = (FILETIME2INT64(ft) - FILETIME2INT64(ftStart))/10;
|
calibrationDelta = (FILETIME2INT64(ft) - FILETIME2INT64(ftStart))/10;
|
||||||
fprintf(stderr, "Calibration delta was %I64d us\n", calibrationDelta);
|
fprintf(stderr, "Calibration delta was %I64d us\n", calibrationDelta);
|
||||||
@ -243,8 +265,13 @@ NowInit(void)
|
|||||||
{
|
{
|
||||||
memset(&calibration, 0, sizeof(calibration));
|
memset(&calibration, 0, sizeof(calibration));
|
||||||
NowCalibrate();
|
NowCalibrate();
|
||||||
|
#ifdef WINCE
|
||||||
|
InitializeCriticalSection(&calibration.calibration_lock);
|
||||||
|
InitializeCriticalSection(&calibration.data_lock);
|
||||||
|
#else
|
||||||
InitializeCriticalSectionAndSpinCount(&calibration.calibration_lock, CALIBRATIONLOCK_SPINCOUNT);
|
InitializeCriticalSectionAndSpinCount(&calibration.calibration_lock, CALIBRATIONLOCK_SPINCOUNT);
|
||||||
InitializeCriticalSectionAndSpinCount(&calibration.data_lock, DATALOCK_SPINCOUNT);
|
InitializeCriticalSectionAndSpinCount(&calibration.data_lock, DATALOCK_SPINCOUNT);
|
||||||
|
#endif
|
||||||
return PR_SUCCESS;
|
return PR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,7 +285,11 @@ PRMJ_NowShutdown()
|
|||||||
#define MUTEX_LOCK(m) EnterCriticalSection(m)
|
#define MUTEX_LOCK(m) EnterCriticalSection(m)
|
||||||
#define MUTEX_TRYLOCK(m) TryEnterCriticalSection(m)
|
#define MUTEX_TRYLOCK(m) TryEnterCriticalSection(m)
|
||||||
#define MUTEX_UNLOCK(m) LeaveCriticalSection(m)
|
#define MUTEX_UNLOCK(m) LeaveCriticalSection(m)
|
||||||
|
#ifdef WINCE
|
||||||
|
#define MUTEX_SETSPINCOUNT(m, c)
|
||||||
|
#else
|
||||||
#define MUTEX_SETSPINCOUNT(m, c) SetCriticalSectionSpinCount((m),(c))
|
#define MUTEX_SETSPINCOUNT(m, c) SetCriticalSectionSpinCount((m),(c))
|
||||||
|
#endif
|
||||||
|
|
||||||
static PRCallOnceType calibrationOnce = { 0 };
|
static PRCallOnceType calibrationOnce = { 0 };
|
||||||
|
|
||||||
@ -312,7 +343,7 @@ PRMJ_Now(void)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(HAVE_GETSYSTEMTIMEASFILETIME)
|
#else
|
||||||
/*
|
/*
|
||||||
|
|
||||||
Win32 python-esque pseudo code
|
Win32 python-esque pseudo code
|
||||||
@ -395,7 +426,7 @@ PRMJ_Now(void)
|
|||||||
int thiscall = JS_ATOMIC_INCREMENT(&nCalls);
|
int thiscall = JS_ATOMIC_INCREMENT(&nCalls);
|
||||||
/* 10 seems to be the number of calls to load with a blank homepage */
|
/* 10 seems to be the number of calls to load with a blank homepage */
|
||||||
if (thiscall <= 10) {
|
if (thiscall <= 10) {
|
||||||
GetSystemTimeAsFileTime(&ft);
|
LowResTime(&ft);
|
||||||
return (FILETIME2INT64(ft)-win2un)/10L;
|
return (FILETIME2INT64(ft)-win2un)/10L;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,7 +458,7 @@ PRMJ_Now(void)
|
|||||||
|
|
||||||
|
|
||||||
/* Calculate a low resolution time */
|
/* Calculate a low resolution time */
|
||||||
GetSystemTimeAsFileTime(&ft);
|
LowResTime(&ft);
|
||||||
lowresTime = 0.1*(long double)(FILETIME2INT64(ft) - win2un);
|
lowresTime = 0.1*(long double)(FILETIME2INT64(ft) - win2un);
|
||||||
|
|
||||||
if (calibration.freq > 0.0) {
|
if (calibration.freq > 0.0) {
|
||||||
@ -453,6 +484,10 @@ PRMJ_Now(void)
|
|||||||
returnedTime = calibration.last;
|
returnedTime = calibration.last;
|
||||||
MUTEX_UNLOCK(&calibration.data_lock);
|
MUTEX_UNLOCK(&calibration.data_lock);
|
||||||
|
|
||||||
|
#ifdef WINCE
|
||||||
|
/* Get an estimate of clock ticks per second from our own test */
|
||||||
|
skewThreshold = calibration.granularity;
|
||||||
|
#else
|
||||||
/* Rather than assume the NT kernel ticks every 15.6ms, ask it */
|
/* Rather than assume the NT kernel ticks every 15.6ms, ask it */
|
||||||
if (GetSystemTimeAdjustment(&timeAdjustment,
|
if (GetSystemTimeAdjustment(&timeAdjustment,
|
||||||
&timeIncrement,
|
&timeIncrement,
|
||||||
@ -465,7 +500,7 @@ PRMJ_Now(void)
|
|||||||
skewThreshold = timeIncrement/10.0;
|
skewThreshold = timeIncrement/10.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/* Check for clock skew */
|
/* Check for clock skew */
|
||||||
diff = lowresTime - highresTime;
|
diff = lowresTime - highresTime;
|
||||||
|
|
||||||
@ -514,20 +549,6 @@ PRMJ_Now(void)
|
|||||||
|
|
||||||
return returnedTime;
|
return returnedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined (HAVE_SYSTEMTIMETOFILETIME)
|
|
||||||
JSInt64
|
|
||||||
PRMJ_Now(void)
|
|
||||||
{
|
|
||||||
FILETIME ft;
|
|
||||||
SYSTEMTIME st;
|
|
||||||
GetSystemTime(&st);
|
|
||||||
SystemTimeToFileTime(&st,&ft);
|
|
||||||
return (FILETIME2INT64(ft)-win2un)/10L;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
#error "No implementation of PRMJ_Now was selected."
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Get the DST timezone offset for the time passed in */
|
/* Get the DST timezone offset for the time passed in */
|
||||||
|
@ -78,7 +78,7 @@ extern JSInt64
|
|||||||
PRMJ_Now(void);
|
PRMJ_Now(void);
|
||||||
|
|
||||||
/* Release the resources associated with PRMJ_Now; don't call PRMJ_Now again */
|
/* Release the resources associated with PRMJ_Now; don't call PRMJ_Now again */
|
||||||
#if defined(JS_THREADSAFE) && defined(HAVE_GETSYSTEMTIMEASFILETIME)
|
#if defined(JS_THREADSAFE) && (defined(HAVE_GETSYSTEMTIMEASFILETIME) || defined(HAVE_SYSTEMTIMETOFILETIME))
|
||||||
extern void
|
extern void
|
||||||
PRMJ_NowShutdown(void);
|
PRMJ_NowShutdown(void);
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user