mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1169880 - Recompute image visibility on a timer if layout or style flushes have occurred. r=tn
This commit is contained in:
parent
4881006619
commit
865f2c6620
@ -78,6 +78,7 @@ static PRLogModuleInfo *gLog = nullptr;
|
||||
|
||||
#define DEFAULT_FRAME_RATE 60
|
||||
#define DEFAULT_THROTTLED_FRAME_RATE 1
|
||||
#define DEFAULT_RECOMPUTE_VISIBILITY_INTERVAL_MS 1000
|
||||
// after 10 minutes, stop firing off inactive timers
|
||||
#define DEFAULT_INACTIVE_TIMER_DISABLE_SECONDS 600
|
||||
|
||||
@ -970,6 +971,17 @@ nsRefreshDriver::GetThrottledTimerInterval()
|
||||
return 1000.0 / rate;
|
||||
}
|
||||
|
||||
/* static */ mozilla::TimeDuration
|
||||
nsRefreshDriver::GetMinRecomputeVisibilityInterval()
|
||||
{
|
||||
int32_t interval =
|
||||
Preferences::GetInt("layout.visibility.min-recompute-interval-ms", -1);
|
||||
if (interval <= 0) {
|
||||
interval = DEFAULT_RECOMPUTE_VISIBILITY_INTERVAL_MS;
|
||||
}
|
||||
return TimeDuration::FromMilliseconds(interval);
|
||||
}
|
||||
|
||||
double
|
||||
nsRefreshDriver::GetRefreshTimerInterval() const
|
||||
{
|
||||
@ -1016,7 +1028,9 @@ nsRefreshDriver::nsRefreshDriver(nsPresContext* aPresContext)
|
||||
mFreezeCount(0),
|
||||
mThrottledFrameRequestInterval(TimeDuration::FromMilliseconds(
|
||||
GetThrottledTimerInterval())),
|
||||
mMinRecomputeVisibilityInterval(GetMinRecomputeVisibilityInterval()),
|
||||
mThrottled(false),
|
||||
mNeedToRecomputeVisibility(false),
|
||||
mTestControllingRefreshes(false),
|
||||
mViewManagerFlushIsPending(false),
|
||||
mRequestedHighPrecision(false),
|
||||
@ -1028,6 +1042,7 @@ nsRefreshDriver::nsRefreshDriver(nsPresContext* aPresContext)
|
||||
mMostRecentRefresh = TimeStamp::Now();
|
||||
mMostRecentTick = mMostRecentRefresh;
|
||||
mNextThrottledFrameRequestTick = mMostRecentTick;
|
||||
mNextRecomputeVisibilityTick = mMostRecentTick;
|
||||
}
|
||||
|
||||
nsRefreshDriver::~nsRefreshDriver()
|
||||
@ -1676,6 +1691,8 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
|
||||
NS_RELEASE(shell);
|
||||
}
|
||||
|
||||
mNeedToRecomputeVisibility = true;
|
||||
|
||||
if (tracingStyleFlush) {
|
||||
profiler_tracing("Paint", "Styles", TRACING_INTERVAL_END);
|
||||
}
|
||||
@ -1721,6 +1738,8 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
|
||||
NS_RELEASE(shell);
|
||||
}
|
||||
|
||||
mNeedToRecomputeVisibility = true;
|
||||
|
||||
if (tracingLayoutFlush) {
|
||||
profiler_tracing("Paint", "Reflow", TRACING_INTERVAL_END);
|
||||
}
|
||||
@ -1728,6 +1747,17 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
|
||||
}
|
||||
}
|
||||
|
||||
// Recompute image visibility if it's necessary and enough time has passed
|
||||
// since the last time we did it.
|
||||
if (mNeedToRecomputeVisibility && !mThrottled &&
|
||||
aNowTime >= mNextRecomputeVisibilityTick &&
|
||||
!presShell->IsPaintingSuppressed()) {
|
||||
mNextRecomputeVisibilityTick = aNowTime + mMinRecomputeVisibilityInterval;
|
||||
mNeedToRecomputeVisibility = false;
|
||||
|
||||
presShell->ScheduleImageVisibilityUpdate();
|
||||
}
|
||||
|
||||
/*
|
||||
* Perform notification to imgIRequests subscribed to listen
|
||||
* for refresh events.
|
||||
|
@ -339,6 +339,8 @@ private:
|
||||
double GetRegularTimerInterval(bool *outIsDefault = nullptr) const;
|
||||
static double GetThrottledTimerInterval();
|
||||
|
||||
static mozilla::TimeDuration GetMinRecomputeVisibilityInterval();
|
||||
|
||||
bool HaveFrameRequestCallbacks() const {
|
||||
return mFrameRequestCallbackDocs.Length() != 0;
|
||||
}
|
||||
@ -367,7 +369,14 @@ private:
|
||||
// non-visible) documents registered with a non-throttled refresh driver.
|
||||
const mozilla::TimeDuration mThrottledFrameRequestInterval;
|
||||
|
||||
// How long we wait, at a minimum, before recomputing image visibility
|
||||
// information. This is a minimum because, regardless of this interval, we
|
||||
// only recompute visibility when we've seen a layout or style flush since the
|
||||
// last time we did it.
|
||||
const mozilla::TimeDuration mMinRecomputeVisibilityInterval;
|
||||
|
||||
bool mThrottled;
|
||||
bool mNeedToRecomputeVisibility;
|
||||
bool mTestControllingRefreshes;
|
||||
bool mViewManagerFlushIsPending;
|
||||
bool mRequestedHighPrecision;
|
||||
@ -386,6 +395,7 @@ private:
|
||||
mozilla::TimeStamp mMostRecentTick;
|
||||
mozilla::TimeStamp mTickStart;
|
||||
mozilla::TimeStamp mNextThrottledFrameRequestTick;
|
||||
mozilla::TimeStamp mNextRecomputeVisibilityTick;
|
||||
|
||||
// separate arrays for each flush type we support
|
||||
ObserverArray mObservers[3];
|
||||
|
Loading…
Reference in New Issue
Block a user