bug 627628 - Throttle the dispatching of starved paints so that time is allowed for the processing of input events between each starved paint. r=roc

This helps maintain responsiveness in cases where input events are being generated very rapidly or where painting is extremely expensive.
This commit is contained in:
Kevin Gadd 2012-01-13 19:29:22 -06:00
Родитель e4a937dbdf
Коммит f72449e397
3 изменённых файлов: 14 добавлений и 3 удалений

Просмотреть файл

@ -3757,9 +3757,11 @@ void nsWindow::DispatchPendingEvents()
--recursionBlocker;
}
// Quickly check to see if there are any
// paint events pending.
if (::GetQueueStatus(QS_PAINT)) {
// Quickly check to see if there are any paint events pending,
// but only dispatch them if it has been long enough since the
// last paint completed.
if (::GetQueueStatus(QS_PAINT) &&
((TimeStamp::Now() - mLastPaintEndTime).ToMilliseconds() >= 50)) {
// Find the top level window.
HWND topWnd = WinUtils::GetTopLevelHWND(mWnd);

Просмотреть файл

@ -61,6 +61,8 @@
#include "nsWindowDbg.h"
#include "cairo.h"
#include "nsITimer.h"
#include "mozilla/TimeStamp.h"
#ifdef CAIRO_HAS_D2D_SURFACE
#include "gfxD2DSurface.h"
#endif
@ -94,6 +96,8 @@ class imgIContainer;
class nsWindow : public nsBaseWidget
{
typedef mozilla::TimeStamp TimeStamp;
typedef mozilla::TimeDuration TimeDuration;
typedef mozilla::widget::WindowHook WindowHook;
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_WIN7
typedef mozilla::widget::TaskbarWindowPreview TaskbarWindowPreview;
@ -611,6 +615,10 @@ protected:
bool mHasTaskbarIconBeenCreated;
#endif
// The point in time at which the last paint completed. We use this to avoid
// painting too rapidly in response to frequent input events.
TimeStamp mLastPaintEndTime;
#ifdef ACCESSIBILITY
static BOOL sIsAccessibilityOn;
static HINSTANCE sAccLib;

Просмотреть файл

@ -605,6 +605,7 @@ bool nsWindow::OnPaint(HDC aDC, PRUint32 aNestingLevel)
}
mPaintDC = nsnull;
mLastPaintEndTime = TimeStamp::Now();
#if defined(WIDGET_DEBUG_OUTPUT)
if (debug_WantPaintFlashing())