2012-12-11 22:15:32 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2009-10-08 03:22:42 +00:00
|
|
|
/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-10-08 03:22:42 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Code to notify things that animate before a refresh, at an appropriate
|
|
|
|
* refresh rate. (Perhaps temporary, until replaced by compositor.)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsRefreshDriver_h_
|
|
|
|
#define nsRefreshDriver_h_
|
|
|
|
|
|
|
|
#include "mozilla/TimeStamp.h"
|
|
|
|
#include "mozFlushType.h"
|
|
|
|
#include "nsTObserverArray.h"
|
2010-08-11 21:05:27 +00:00
|
|
|
#include "nsTArray.h"
|
2011-11-09 21:39:16 +00:00
|
|
|
#include "nsTHashtable.h"
|
2013-05-17 20:57:26 +00:00
|
|
|
#include "nsClassHashtable.h"
|
2011-11-09 21:39:16 +00:00
|
|
|
#include "nsHashKeys.h"
|
2012-06-19 03:26:34 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-08-27 22:10:28 +00:00
|
|
|
#include "mozilla/Maybe.h"
|
2014-04-22 18:13:00 +00:00
|
|
|
#include "GeckoProfiler.h"
|
2014-05-28 21:42:17 +00:00
|
|
|
#include "mozilla/layers/TransactionIdAllocator.h"
|
2009-10-08 03:22:42 +00:00
|
|
|
|
2009-12-21 21:46:24 +00:00
|
|
|
class nsPresContext;
|
2010-08-11 21:05:27 +00:00
|
|
|
class nsIPresShell;
|
2010-08-11 21:05:28 +00:00
|
|
|
class nsIDocument;
|
2011-11-09 21:39:16 +00:00
|
|
|
class imgIRequest;
|
2013-08-19 13:08:44 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
class RefreshDriverTimer;
|
2015-01-13 23:38:00 +00:00
|
|
|
namespace layout {
|
|
|
|
class VsyncChild;
|
|
|
|
}
|
2013-08-19 13:08:44 +00:00
|
|
|
}
|
2009-12-21 21:46:24 +00:00
|
|
|
|
2009-10-08 03:22:42 +00:00
|
|
|
/**
|
|
|
|
* An abstract base class to be implemented by callers wanting to be
|
|
|
|
* notified at refresh times. When nothing needs to be painted, callers
|
|
|
|
* may not be notified.
|
|
|
|
*/
|
|
|
|
class nsARefreshObserver {
|
|
|
|
public:
|
2009-12-21 21:46:25 +00:00
|
|
|
// AddRef and Release signatures that match nsISupports. Implementors
|
|
|
|
// must implement reference counting, and those that do implement
|
|
|
|
// nsISupports will already have methods with the correct signature.
|
|
|
|
//
|
|
|
|
// The refresh driver does NOT hold references to refresh observers
|
2010-06-27 02:43:13 +00:00
|
|
|
// except while it is notifying them.
|
2014-03-27 20:38:33 +00:00
|
|
|
NS_IMETHOD_(MozExternalRefCountType) AddRef(void) = 0;
|
|
|
|
NS_IMETHOD_(MozExternalRefCountType) Release(void) = 0;
|
2009-12-21 21:46:25 +00:00
|
|
|
|
2009-10-08 03:22:42 +00:00
|
|
|
virtual void WillRefresh(mozilla::TimeStamp aTime) = 0;
|
|
|
|
};
|
|
|
|
|
2013-08-19 13:08:44 +00:00
|
|
|
/**
|
|
|
|
* An abstract base class to be implemented by callers wanting to be notified
|
|
|
|
* that a refresh has occurred. Callers must ensure an observer is removed
|
|
|
|
* before it is destroyed.
|
|
|
|
*/
|
|
|
|
class nsAPostRefreshObserver {
|
|
|
|
public:
|
|
|
|
virtual void DidRefresh() = 0;
|
|
|
|
};
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class nsRefreshDriver final : public mozilla::layers::TransactionIdAllocator,
|
2015-03-27 18:52:19 +00:00
|
|
|
public nsARefreshObserver
|
|
|
|
{
|
2009-10-08 03:22:42 +00:00
|
|
|
public:
|
2014-08-07 23:48:38 +00:00
|
|
|
explicit nsRefreshDriver(nsPresContext *aPresContext);
|
2009-10-08 03:22:42 +00:00
|
|
|
~nsRefreshDriver();
|
|
|
|
|
2011-03-07 16:58:48 +00:00
|
|
|
static void InitializeStatics();
|
2012-12-11 22:15:32 +00:00
|
|
|
static void Shutdown();
|
2011-03-07 16:58:48 +00:00
|
|
|
|
2011-04-12 06:18:43 +00:00
|
|
|
/**
|
|
|
|
* Methods for testing, exposed via nsIDOMWindowUtils. See
|
|
|
|
* nsIDOMWindowUtils.advanceTimeAndRefresh for description.
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
void AdvanceTimeAndRefresh(int64_t aMilliseconds);
|
2011-04-12 06:18:43 +00:00
|
|
|
void RestoreNormalRefresh();
|
2012-12-11 22:15:32 +00:00
|
|
|
void DoTick();
|
|
|
|
bool IsTestControllingRefreshesEnabled() const
|
|
|
|
{
|
|
|
|
return mTestControllingRefreshes;
|
|
|
|
}
|
2011-04-12 06:18:43 +00:00
|
|
|
|
2009-10-08 03:22:42 +00:00
|
|
|
/**
|
|
|
|
* Return the time of the most recent refresh. This is intended to be
|
|
|
|
* used by callers who want to start an animation now and want to know
|
|
|
|
* what time to consider the start of the animation. (This helps
|
|
|
|
* ensure that multiple animations started during the same event off
|
|
|
|
* the main event loop have the same start time.)
|
|
|
|
*/
|
|
|
|
mozilla::TimeStamp MostRecentRefresh() const;
|
2010-08-11 21:05:28 +00:00
|
|
|
/**
|
|
|
|
* Same thing, but in microseconds since the epoch.
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
int64_t MostRecentRefreshEpochTime() const;
|
2009-10-08 03:22:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add / remove refresh observers. Returns whether the operation
|
|
|
|
* succeeded.
|
|
|
|
*
|
|
|
|
* The flush type affects:
|
|
|
|
* + the order in which the observers are notified (lowest flush
|
|
|
|
* type to highest, in order registered)
|
|
|
|
* + (in the future) which observers are suppressed when the display
|
|
|
|
* doesn't require current position data or isn't currently
|
|
|
|
* painting, and, correspondingly, which get notified when there
|
|
|
|
* is a flush during such suppression
|
|
|
|
* and it must be either Flush_Style, Flush_Layout, or Flush_Display.
|
2009-12-21 21:46:25 +00:00
|
|
|
*
|
|
|
|
* The refresh driver does NOT own a reference to these observers;
|
|
|
|
* they must remove themselves before they are destroyed.
|
2013-08-19 13:08:44 +00:00
|
|
|
*
|
|
|
|
* The observer will be called even if there is no other activity.
|
2009-10-08 03:22:42 +00:00
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
bool AddRefreshObserver(nsARefreshObserver *aObserver,
|
2013-08-19 13:08:44 +00:00
|
|
|
mozFlushType aFlushType);
|
2011-09-29 06:19:26 +00:00
|
|
|
bool RemoveRefreshObserver(nsARefreshObserver *aObserver,
|
2013-08-19 13:08:44 +00:00
|
|
|
mozFlushType aFlushType);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add an observer that will be called after each refresh. The caller
|
|
|
|
* must remove the observer before it is deleted. This does not trigger
|
|
|
|
* refresh driver ticks.
|
|
|
|
*/
|
|
|
|
void AddPostRefreshObserver(nsAPostRefreshObserver *aObserver);
|
|
|
|
void RemovePostRefreshObserver(nsAPostRefreshObserver *aObserver);
|
2009-10-08 03:22:42 +00:00
|
|
|
|
2011-11-09 21:39:16 +00:00
|
|
|
/**
|
|
|
|
* Add/Remove imgIRequest versions of observers.
|
|
|
|
*
|
|
|
|
* These are used for hooking into the refresh driver for
|
|
|
|
* controlling animated images.
|
|
|
|
*
|
|
|
|
* @note The refresh driver owns a reference to these listeners.
|
|
|
|
*
|
|
|
|
* @note Technically, imgIRequest objects are not nsARefreshObservers, but
|
|
|
|
* for controlling animated image repaint events, we subscribe the
|
|
|
|
* imgIRequests to the nsRefreshDriver for notification of paint events.
|
|
|
|
*
|
|
|
|
* @returns whether the operation succeeded, or void in the case of removal.
|
|
|
|
*/
|
|
|
|
bool AddImageRequest(imgIRequest* aRequest);
|
|
|
|
void RemoveImageRequest(imgIRequest* aRequest);
|
|
|
|
|
2010-08-11 21:05:27 +00:00
|
|
|
/**
|
|
|
|
* Add / remove presshells that we should flush style and layout on
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
bool AddStyleFlushObserver(nsIPresShell* aShell) {
|
2010-08-11 21:05:27 +00:00
|
|
|
NS_ASSERTION(!mStyleFlushObservers.Contains(aShell),
|
|
|
|
"Double-adding style flush observer");
|
2014-04-22 18:13:00 +00:00
|
|
|
// We only get the cause for the first observer each frame because capturing
|
|
|
|
// a stack is expensive. This is still useful if (1) you're trying to remove
|
|
|
|
// all flushes for a particial frame or (2) the costly flush is triggered
|
|
|
|
// near the call site where the first observer is triggered.
|
|
|
|
if (!mStyleCause) {
|
|
|
|
mStyleCause = profiler_get_backtrace();
|
|
|
|
}
|
2012-07-30 14:20:58 +00:00
|
|
|
bool appended = mStyleFlushObservers.AppendElement(aShell) != nullptr;
|
2015-01-06 01:56:02 +00:00
|
|
|
EnsureTimerStarted();
|
2014-04-22 18:13:00 +00:00
|
|
|
|
2010-08-11 21:05:27 +00:00
|
|
|
return appended;
|
|
|
|
}
|
|
|
|
void RemoveStyleFlushObserver(nsIPresShell* aShell) {
|
|
|
|
mStyleFlushObservers.RemoveElement(aShell);
|
|
|
|
}
|
2011-09-29 06:19:26 +00:00
|
|
|
bool AddLayoutFlushObserver(nsIPresShell* aShell) {
|
2010-08-11 21:05:27 +00:00
|
|
|
NS_ASSERTION(!IsLayoutFlushObserver(aShell),
|
|
|
|
"Double-adding layout flush observer");
|
2014-04-22 18:13:00 +00:00
|
|
|
// We only get the cause for the first observer each frame because capturing
|
|
|
|
// a stack is expensive. This is still useful if (1) you're trying to remove
|
|
|
|
// all flushes for a particial frame or (2) the costly flush is triggered
|
|
|
|
// near the call site where the first observer is triggered.
|
|
|
|
if (!mReflowCause) {
|
|
|
|
mReflowCause = profiler_get_backtrace();
|
|
|
|
}
|
2012-07-30 14:20:58 +00:00
|
|
|
bool appended = mLayoutFlushObservers.AppendElement(aShell) != nullptr;
|
2015-01-06 01:56:02 +00:00
|
|
|
EnsureTimerStarted();
|
2010-08-11 21:05:27 +00:00
|
|
|
return appended;
|
|
|
|
}
|
|
|
|
void RemoveLayoutFlushObserver(nsIPresShell* aShell) {
|
|
|
|
mLayoutFlushObservers.RemoveElement(aShell);
|
|
|
|
}
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsLayoutFlushObserver(nsIPresShell* aShell) {
|
2010-08-11 21:05:27 +00:00
|
|
|
return mLayoutFlushObservers.Contains(aShell);
|
|
|
|
}
|
2012-08-29 05:48:44 +00:00
|
|
|
bool AddPresShellToInvalidateIfHidden(nsIPresShell* aShell) {
|
|
|
|
NS_ASSERTION(!mPresShellsToInvalidateIfHidden.Contains(aShell),
|
|
|
|
"Double-adding style flush observer");
|
|
|
|
bool appended = mPresShellsToInvalidateIfHidden.AppendElement(aShell) != nullptr;
|
2015-01-06 01:56:02 +00:00
|
|
|
EnsureTimerStarted();
|
2012-08-29 05:48:44 +00:00
|
|
|
return appended;
|
|
|
|
}
|
|
|
|
void RemovePresShellToInvalidateIfHidden(nsIPresShell* aShell) {
|
|
|
|
mPresShellsToInvalidateIfHidden.RemoveElement(aShell);
|
|
|
|
}
|
2010-08-11 21:05:27 +00:00
|
|
|
|
2011-12-24 03:52:22 +00:00
|
|
|
/**
|
|
|
|
* Remember whether our presshell's view manager needs a flush
|
|
|
|
*/
|
2012-09-17 05:06:12 +00:00
|
|
|
void ScheduleViewManagerFlush();
|
2011-12-24 03:52:22 +00:00
|
|
|
void RevokeViewManagerFlush() {
|
|
|
|
mViewManagerFlushIsPending = false;
|
|
|
|
}
|
2012-08-29 05:47:18 +00:00
|
|
|
bool ViewManagerFlushIsPending() {
|
|
|
|
return mViewManagerFlushIsPending;
|
|
|
|
}
|
2011-12-24 03:52:22 +00:00
|
|
|
|
2010-09-09 05:38:04 +00:00
|
|
|
/**
|
2011-11-28 12:48:30 +00:00
|
|
|
* Add a document for which we have nsIFrameRequestCallbacks
|
2010-09-09 05:38:04 +00:00
|
|
|
*/
|
2011-11-28 12:48:30 +00:00
|
|
|
void ScheduleFrameRequestCallbacks(nsIDocument* aDocument);
|
2010-09-09 05:38:04 +00:00
|
|
|
|
|
|
|
/**
|
2011-11-28 12:48:30 +00:00
|
|
|
* Remove a document for which we have nsIFrameRequestCallbacks
|
2010-09-09 05:38:04 +00:00
|
|
|
*/
|
2011-11-28 12:48:30 +00:00
|
|
|
void RevokeFrameRequestCallbacks(nsIDocument* aDocument);
|
2010-09-09 05:38:04 +00:00
|
|
|
|
2009-12-21 21:46:24 +00:00
|
|
|
/**
|
|
|
|
* Tell the refresh driver that it is done driving refreshes and
|
|
|
|
* should stop its timer and forget about its pres context. This may
|
|
|
|
* be called from within a refresh.
|
|
|
|
*/
|
|
|
|
void Disconnect() {
|
|
|
|
StopTimer();
|
2012-07-30 14:20:58 +00:00
|
|
|
mPresContext = nullptr;
|
2009-12-21 21:46:24 +00:00
|
|
|
}
|
2009-10-08 03:22:42 +00:00
|
|
|
|
2013-12-19 21:38:35 +00:00
|
|
|
bool IsFrozen() { return mFreezeCount > 0; }
|
|
|
|
|
2010-02-03 21:17:55 +00:00
|
|
|
/**
|
|
|
|
* Freeze the refresh driver. It should stop delivering future
|
2013-12-19 21:38:35 +00:00
|
|
|
* refreshes until thawed. Note that the number of calls to Freeze() must
|
|
|
|
* match the number of calls to Thaw() in order for the refresh driver to
|
|
|
|
* be un-frozen.
|
2010-02-03 21:17:55 +00:00
|
|
|
*/
|
|
|
|
void Freeze();
|
|
|
|
|
|
|
|
/**
|
2013-12-19 21:38:35 +00:00
|
|
|
* Thaw the refresh driver. If the number of calls to Freeze() matches the
|
|
|
|
* number of calls to this function, the refresh driver should start
|
|
|
|
* delivering refreshes again.
|
2010-02-03 21:17:55 +00:00
|
|
|
*/
|
|
|
|
void Thaw();
|
|
|
|
|
2010-08-27 04:26:23 +00:00
|
|
|
/**
|
|
|
|
* Throttle or unthrottle the refresh driver. This is done if the
|
|
|
|
* corresponding presshell is hidden or shown.
|
|
|
|
*/
|
|
|
|
void SetThrottled(bool aThrottled);
|
|
|
|
|
2010-08-11 21:05:27 +00:00
|
|
|
/**
|
|
|
|
* Return the prescontext we were initialized with
|
|
|
|
*/
|
|
|
|
nsPresContext* PresContext() const { return mPresContext; }
|
|
|
|
|
2015-01-13 23:38:00 +00:00
|
|
|
/**
|
|
|
|
* PBackgroundChild actor is created asynchronously in content process.
|
|
|
|
* We can't create vsync-based timers during PBackground startup. This
|
|
|
|
* function will be called when PBackgroundChild actor is created. Then we can
|
|
|
|
* do the pending vsync-based timer creation.
|
|
|
|
*/
|
|
|
|
static void PVsyncActorCreated(mozilla::layout::VsyncChild* aVsyncChild);
|
|
|
|
|
2010-02-19 17:11:40 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/**
|
|
|
|
* Check whether the given observer is an observer for the given flush type
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsRefreshObserver(nsARefreshObserver *aObserver,
|
2010-02-19 17:11:40 +00:00
|
|
|
mozFlushType aFlushType);
|
|
|
|
#endif
|
|
|
|
|
2011-12-24 03:52:26 +00:00
|
|
|
/**
|
|
|
|
* Default interval the refresh driver uses, in ms.
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
static int32_t DefaultInterval();
|
2011-12-24 03:52:26 +00:00
|
|
|
|
2013-09-04 11:47:21 +00:00
|
|
|
bool IsInRefresh() { return mInRefresh; }
|
|
|
|
|
2014-05-28 21:42:17 +00:00
|
|
|
// mozilla::layers::TransactionIdAllocator
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual uint64_t GetTransactionId() override;
|
|
|
|
void NotifyTransactionCompleted(uint64_t aTransactionId) override;
|
|
|
|
void RevokeTransactionId(uint64_t aTransactionId) override;
|
|
|
|
mozilla::TimeStamp GetTransactionStart() override;
|
2014-05-28 21:42:17 +00:00
|
|
|
|
2014-08-15 02:24:50 +00:00
|
|
|
bool IsWaitingForPaint(mozilla::TimeStamp aTime);
|
2014-05-28 21:43:41 +00:00
|
|
|
|
|
|
|
// nsARefreshObserver
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD_(MozExternalRefCountType) AddRef(void) override { return TransactionIdAllocator::AddRef(); }
|
|
|
|
NS_IMETHOD_(MozExternalRefCountType) Release(void) override { return TransactionIdAllocator::Release(); }
|
|
|
|
virtual void WillRefresh(mozilla::TimeStamp aTime) override;
|
2009-12-21 21:46:24 +00:00
|
|
|
private:
|
2009-10-08 03:22:42 +00:00
|
|
|
typedef nsTObserverArray<nsARefreshObserver*> ObserverArray;
|
2011-11-09 21:39:16 +00:00
|
|
|
typedef nsTHashtable<nsISupportsHashKey> RequestTable;
|
2013-05-17 20:57:26 +00:00
|
|
|
struct ImageStartData {
|
|
|
|
ImageStartData()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::Maybe<mozilla::TimeStamp> mStartTime;
|
|
|
|
RequestTable mEntries;
|
|
|
|
};
|
|
|
|
typedef nsClassHashtable<nsUint32HashKey, ImageStartData> ImageStartTable;
|
2009-10-08 03:22:42 +00:00
|
|
|
|
2015-04-21 16:44:40 +00:00
|
|
|
void RunFrameRequestCallbacks(int64_t aNowEpoch, mozilla::TimeStamp aNowTime);
|
|
|
|
|
2012-12-11 22:15:32 +00:00
|
|
|
void Tick(int64_t aNowEpoch, mozilla::TimeStamp aNowTime);
|
|
|
|
|
2015-01-06 01:56:02 +00:00
|
|
|
enum EnsureTimerStartedFlags {
|
|
|
|
eNone = 0,
|
|
|
|
eAdjustingTimer = 1 << 0,
|
|
|
|
eAllowTimeToGoBackwards = 1 << 1
|
|
|
|
};
|
|
|
|
void EnsureTimerStarted(EnsureTimerStartedFlags aFlags = eNone);
|
2009-10-08 03:22:42 +00:00
|
|
|
void StopTimer();
|
2011-11-09 21:39:16 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t ObserverCount() const;
|
|
|
|
uint32_t ImageRequestCount() const;
|
2011-11-09 21:39:16 +00:00
|
|
|
static PLDHashOperator ImageRequestEnumerator(nsISupportsHashKey* aEntry,
|
2013-05-17 20:57:26 +00:00
|
|
|
void* aUserArg);
|
|
|
|
static PLDHashOperator StartTableRequestCounter(const uint32_t& aKey,
|
|
|
|
ImageStartData* aEntry,
|
|
|
|
void* aUserArg);
|
|
|
|
static PLDHashOperator StartTableRefresh(const uint32_t& aKey,
|
|
|
|
ImageStartData* aEntry,
|
|
|
|
void* aUserArg);
|
|
|
|
static PLDHashOperator BeginRefreshingImages(nsISupportsHashKey* aEntry,
|
|
|
|
void* aUserArg);
|
2009-10-08 03:22:42 +00:00
|
|
|
ObserverArray& ArrayFor(mozFlushType aFlushType);
|
2010-02-03 21:17:55 +00:00
|
|
|
// Trigger a refresh immediately, if haven't been disconnected or frozen.
|
|
|
|
void DoRefresh();
|
2009-10-08 03:22:42 +00:00
|
|
|
|
2012-12-11 22:15:32 +00:00
|
|
|
double GetRefreshTimerInterval() const;
|
2013-05-29 10:31:16 +00:00
|
|
|
double GetRegularTimerInterval(bool *outIsDefault = nullptr) const;
|
2015-04-21 16:44:40 +00:00
|
|
|
static double GetThrottledTimerInterval();
|
2011-03-04 15:27:02 +00:00
|
|
|
|
2011-11-28 12:48:30 +00:00
|
|
|
bool HaveFrameRequestCallbacks() const {
|
|
|
|
return mFrameRequestCallbackDocs.Length() != 0;
|
2011-03-07 16:58:48 +00:00
|
|
|
}
|
|
|
|
|
2014-05-28 21:42:17 +00:00
|
|
|
void FinishedWaitingForTransaction();
|
|
|
|
|
2012-12-11 22:15:32 +00:00
|
|
|
mozilla::RefreshDriverTimer* ChooseTimer() const;
|
2015-01-13 23:38:00 +00:00
|
|
|
mozilla::RefreshDriverTimer* mActiveTimer;
|
2009-10-08 03:22:42 +00:00
|
|
|
|
2014-04-22 18:13:00 +00:00
|
|
|
ProfilerBacktrace* mReflowCause;
|
|
|
|
ProfilerBacktrace* mStyleCause;
|
|
|
|
|
2009-12-21 21:46:24 +00:00
|
|
|
nsPresContext *mPresContext; // weak; pres context passed in constructor
|
|
|
|
// and unset in Disconnect
|
|
|
|
|
2014-05-28 21:43:41 +00:00
|
|
|
nsRefPtr<nsRefreshDriver> mRootRefresh;
|
|
|
|
|
2014-05-28 21:42:17 +00:00
|
|
|
// The most recently allocated transaction id.
|
|
|
|
uint64_t mPendingTransaction;
|
|
|
|
// The most recently completed transaction id.
|
|
|
|
uint64_t mCompletedTransaction;
|
|
|
|
|
2013-12-19 21:38:35 +00:00
|
|
|
uint32_t mFreezeCount;
|
2015-04-21 16:44:40 +00:00
|
|
|
|
|
|
|
// How long we wait between ticks for throttled (which generally means
|
|
|
|
// non-visible) documents registered with a non-throttled refresh driver.
|
|
|
|
const mozilla::TimeDuration mThrottledFrameRequestInterval;
|
|
|
|
|
2010-08-27 04:26:23 +00:00
|
|
|
bool mThrottled;
|
2011-04-12 06:18:43 +00:00
|
|
|
bool mTestControllingRefreshes;
|
2011-12-24 03:52:22 +00:00
|
|
|
bool mViewManagerFlushIsPending;
|
2012-12-11 22:15:32 +00:00
|
|
|
bool mRequestedHighPrecision;
|
2013-09-04 11:47:21 +00:00
|
|
|
bool mInRefresh;
|
2012-12-11 22:15:32 +00:00
|
|
|
|
2014-05-28 21:42:17 +00:00
|
|
|
// True if the refresh driver is suspended waiting for transaction
|
|
|
|
// id's to be returned and shouldn't do any work during Tick().
|
|
|
|
bool mWaitingForTransaction;
|
|
|
|
// True if Tick() was skipped because of mWaitingForTransaction and
|
|
|
|
// we should schedule a new Tick immediately when resumed instead
|
|
|
|
// of waiting until the next interval.
|
2014-08-15 02:24:50 +00:00
|
|
|
bool mSkippedPaints;
|
2014-05-28 21:42:17 +00:00
|
|
|
|
2012-12-11 22:15:32 +00:00
|
|
|
int64_t mMostRecentRefreshEpochTime;
|
|
|
|
mozilla::TimeStamp mMostRecentRefresh;
|
2014-08-15 02:24:50 +00:00
|
|
|
mozilla::TimeStamp mMostRecentTick;
|
2014-08-28 19:24:26 +00:00
|
|
|
mozilla::TimeStamp mTickStart;
|
2015-04-21 16:44:40 +00:00
|
|
|
mozilla::TimeStamp mNextThrottledFrameRequestTick;
|
2010-02-03 21:17:55 +00:00
|
|
|
|
2009-10-08 03:22:42 +00:00
|
|
|
// separate arrays for each flush type we support
|
|
|
|
ObserverArray mObservers[3];
|
2011-11-09 21:39:16 +00:00
|
|
|
RequestTable mRequests;
|
2013-05-17 20:57:26 +00:00
|
|
|
ImageStartTable mStartTable;
|
2011-11-09 21:39:16 +00:00
|
|
|
|
2010-08-11 21:05:27 +00:00
|
|
|
nsAutoTArray<nsIPresShell*, 16> mStyleFlushObservers;
|
|
|
|
nsAutoTArray<nsIPresShell*, 16> mLayoutFlushObservers;
|
2012-08-29 05:48:44 +00:00
|
|
|
nsAutoTArray<nsIPresShell*, 16> mPresShellsToInvalidateIfHidden;
|
2010-08-11 21:05:28 +00:00
|
|
|
// nsTArray on purpose, because we want to be able to swap.
|
2011-11-28 12:48:30 +00:00
|
|
|
nsTArray<nsIDocument*> mFrameRequestCallbackDocs;
|
2015-04-21 16:44:40 +00:00
|
|
|
nsTArray<nsIDocument*> mThrottledFrameRequestCallbackDocs;
|
2013-08-19 13:08:44 +00:00
|
|
|
nsTArray<nsAPostRefreshObserver*> mPostRefreshObservers;
|
2011-03-04 15:27:02 +00:00
|
|
|
|
2011-11-09 21:39:16 +00:00
|
|
|
// Helper struct for processing image requests
|
|
|
|
struct ImageRequestParameters {
|
2013-05-17 20:57:26 +00:00
|
|
|
mozilla::TimeStamp mCurrent;
|
|
|
|
mozilla::TimeStamp mPrevious;
|
|
|
|
RequestTable* mRequests;
|
|
|
|
mozilla::TimeStamp mDesired;
|
2011-11-09 21:39:16 +00:00
|
|
|
};
|
2012-12-11 22:15:32 +00:00
|
|
|
|
|
|
|
friend class mozilla::RefreshDriverTimer;
|
|
|
|
|
|
|
|
// turn on or turn off high precision based on various factors
|
|
|
|
void ConfigureHighPrecision();
|
|
|
|
void SetHighPrecisionTimersEnabled(bool aEnable);
|
2009-10-08 03:22:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* !defined(nsRefreshDriver_h_) */
|