Backed out changeset e6430ac52054 (bug 864447) for OS X make check crashes

This commit is contained in:
Ed Morley 2013-07-09 08:41:49 +01:00
Родитель 6bd7de027d
Коммит 258bb235ff
5 изменённых файлов: 54 добавлений и 90 удалений

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

@ -171,6 +171,7 @@ AsyncPanZoomController::AsyncPanZoomController(GeckoContentController* aGeckoCon
mMonitor("AsyncPanZoomController"),
mLastSampleTime(GetFrameTime()),
mState(NOTHING),
mPreviousPaintStartTime(GetFrameTime()),
mLastAsyncScrollTime(GetFrameTime()),
mLastAsyncScrollOffset(0, 0),
mCurrentAsyncScrollOffset(0, 0),
@ -178,6 +179,7 @@ AsyncPanZoomController::AsyncPanZoomController(GeckoContentController* aGeckoCon
mAsyncScrollThrottleTime(100),
mAsyncScrollTimeout(300),
mDPI(72),
mWaitingForContentToPaint(false),
mDisableNextTouchBatch(false),
mHandlingTouchQueue(false),
mDelayPanning(false)
@ -777,7 +779,7 @@ void AsyncPanZoomController::TrackTouch(const MultiTouchInput& aEvent) {
ScrollBy(CSSPoint::FromUnknownPoint(displacement));
ScheduleComposite();
TimeDuration timePaintDelta = mPaintThrottler.TimeSinceLastRequest();
TimeDuration timePaintDelta = GetFrameTime() - mPreviousPaintStartTime;
if (timePaintDelta.ToMilliseconds() > gPanRepaintInterval) {
RequestContentRepaint();
}
@ -814,7 +816,7 @@ bool AsyncPanZoomController::DoFling(const TimeDuration& aDelta) {
mX.GetDisplacementForDuration(inverseResolution.scale, aDelta),
mY.GetDisplacementForDuration(inverseResolution.scale, aDelta)
)));
TimeDuration timePaintDelta = mPaintThrottler.TimeSinceLastRequest();
TimeDuration timePaintDelta = GetFrameTime() - mPreviousPaintStartTime;
if (timePaintDelta.ToMilliseconds() > gFlingRepaintInterval) {
RequestContentRepaint();
}
@ -984,11 +986,23 @@ void AsyncPanZoomController::ScheduleComposite() {
}
void AsyncPanZoomController::RequestContentRepaint() {
mPreviousPaintStartTime = GetFrameTime();
double estimatedPaintSum = 0.0;
for (uint32_t i = 0; i < mPreviousPaintDurations.Length(); i++) {
estimatedPaintSum += mPreviousPaintDurations[i].ToSeconds();
}
double estimatedPaintDuration = 0.0;
if (estimatedPaintSum > EPSILON) {
estimatedPaintDuration = estimatedPaintSum / mPreviousPaintDurations.Length();
}
mFrameMetrics.mDisplayPort =
CalculatePendingDisplayPort(mFrameMetrics,
GetVelocityVector(),
GetAccelerationVector(),
mPaintThrottler.AverageDuration().ToSeconds());
estimatedPaintDuration);
// If we're trying to paint what we already think is painted, discard this
// request since it's a pointless paint.
@ -1028,10 +1042,10 @@ void AsyncPanZoomController::RequestContentRepaint() {
FROM_HERE,
NewRunnableMethod(mGeckoContentController.get(),
&GeckoContentController::RequestContentRepaint,
mFrameMetrics),
GetFrameTime());
mFrameMetrics));
mFrameMetrics.mPresShellId = mLastContentPaintMetrics.mPresShellId;
mLastPaintRequestMetrics = mFrameMetrics;
mWaitingForContentToPaint = true;
// Set the zoom back to what it was for the purpose of logic control.
mFrameMetrics.mZoom = actualZoom;
@ -1165,7 +1179,16 @@ void AsyncPanZoomController::NotifyLayersUpdated(const FrameMetrics& aViewportFr
mLastContentPaintMetrics = aViewportFrame;
mFrameMetrics.mMayHaveTouchListeners = aViewportFrame.mMayHaveTouchListeners;
if (!mPaintThrottler.IsOutstanding()) {
if (mWaitingForContentToPaint) {
// Remove the oldest sample we have if adding a new sample takes us over our
// desired number of samples.
if (mPreviousPaintDurations.Length() >= gNumPaintDurationSamples) {
mPreviousPaintDurations.RemoveElementAt(0);
}
mPreviousPaintDurations.AppendElement(
GetFrameTime() - mPreviousPaintStartTime);
} else {
// No paint was requested, but we got one anyways. One possible cause of this
// is that content could have fired a scrollTo(). In this case, we should take
// the new scroll offset. Document/viewport changes are handled elsewhere.
@ -1185,7 +1208,7 @@ void AsyncPanZoomController::NotifyLayersUpdated(const FrameMetrics& aViewportFr
}
}
mPaintThrottler.TaskComplete(GetFrameTime());
mWaitingForContentToPaint = mPaintThrottler.TaskComplete();
bool needContentRepaint = false;
if (aViewportFrame.mCompositionBounds.width == mFrameMetrics.mCompositionBounds.width &&
aViewportFrame.mCompositionBounds.height == mFrameMetrics.mCompositionBounds.height) {
@ -1198,8 +1221,7 @@ void AsyncPanZoomController::NotifyLayersUpdated(const FrameMetrics& aViewportFr
}
if (aIsFirstPaint || mFrameMetrics.IsDefault()) {
mPaintThrottler.ClearHistory();
mPaintThrottler.SetMaxDurations(gNumPaintDurationSamples);
mPreviousPaintDurations.Clear();
mX.CancelTouch();
mY.CancelTouch();

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

@ -11,6 +11,7 @@
#include "mozilla/Attributes.h"
#include "mozilla/Monitor.h"
#include "mozilla/RefPtr.h"
#include "mozilla/TimeStamp.h"
#include "InputData.h"
#include "Axis.h"
#include "TaskThrottler.h"
@ -553,6 +554,13 @@ private:
// |mMonitor|; that is, it should be held whenever this is updated.
PanZoomState mState;
// How long it took in the past to paint after a series of previous requests.
nsTArray<TimeDuration> mPreviousPaintDurations;
// When the last paint request started. Used to determine the duration of
// previous paints.
TimeStamp mPreviousPaintStartTime;
// The last time and offset we fire the mozbrowserasyncscroll event when
// compositor has sampled the content transform for this frame.
TimeStamp mLastAsyncScrollTime;
@ -576,6 +584,12 @@ private:
int mDPI;
// Stores the current paint status of the frame that we're managing. Repaints
// may be triggered by other things (like content doing things), in which case
// this status will not be updated. It is only changed when this class
// requests a repaint.
bool mWaitingForContentToPaint;
// Flag used to determine whether or not we should disable handling of the
// next batch of touch events. This is used for sync scrolling of subframes.
bool mDisableNextTouchBatch;

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

@ -18,7 +18,7 @@ TaskThrottler::TaskThrottler()
void
TaskThrottler::PostTask(const tracked_objects::Location& aLocation,
CancelableTask* aTask, const TimeStamp& aTimeStamp)
CancelableTask* aTask)
{
aTask->SetBirthPlace(aLocation);
@ -28,53 +28,22 @@ TaskThrottler::PostTask(const tracked_objects::Location& aLocation,
}
mQueuedTask = aTask;
} else {
mStartTime = aTimeStamp;
aTask->Run();
delete aTask;
mOutstanding = true;
}
}
void
TaskThrottler::TaskComplete(const TimeStamp& aTimeStamp)
bool
TaskThrottler::TaskComplete()
{
if (!mOutstanding) {
return;
}
// Remove the oldest sample we have if adding a new sample takes us over our
// desired number of samples.
if (mDurations.Length() >= mMaxDurations) {
mDurations.RemoveElementAt(0);
}
if (mMaxDurations) {
mDurations.AppendElement(aTimeStamp - mStartTime);
}
if (mQueuedTask) {
mStartTime = aTimeStamp;
mQueuedTask->Run();
mQueuedTask = nullptr;
} else {
mOutstanding = false;
return true;
}
}
TimeDuration
TaskThrottler::AverageDuration()
{
TimeDuration durationSum;
for (uint32_t i = 0; i < mDurations.Length(); i++) {
durationSum += mDurations[i];
}
return durationSum / mDurations.Length();
}
TimeDuration
TaskThrottler::TimeSinceLastRequest(const TimeStamp& aTimeStamp)
{
return aTimeStamp - mStartTime;
mOutstanding = false;
return false;
}
}

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

@ -8,8 +8,6 @@
#define mozilla_dom_TaskThrottler_h
#include "nsAutoPtr.h"
#include "nsTArray.h"
#include "mozilla/TimeStamp.h"
class CancelableTask;
namespace tracked_objects {
@ -44,51 +42,15 @@ public:
* obsolete or the TaskThrottler is destructed.
*/
void PostTask(const tracked_objects::Location& aLocation,
CancelableTask* aTask, const TimeStamp& aTimeStamp);
CancelableTask* aTask);
/**
* Mark the task as complete and process the next queued task.
* return true if Throttler had outstanding task
*/
void TaskComplete(const TimeStamp& aTimeStamp);
/**
* Calculate the average time between processing the posted task and getting
* the TaskComplete() call back.
*/
TimeDuration AverageDuration();
/**
* return true if Throttler has an outstanding task
*/
bool IsOutstanding() { return mOutstanding; }
/**
* Return the time elapsed since the last request was processed
*/
TimeDuration TimeSinceLastRequest(const TimeStamp& aTimeStamp =
TimeStamp::Now());
/**
* Clear average history.
*/
void ClearHistory() { mDurations.Clear(); }
/**
* @param aMaxDurations The maximum number of durations to measure.
*/
void SetMaxDurations(uint32_t aMaxDurations)
{
mMaxDurations = aMaxDurations;
}
bool TaskComplete();
private:
bool mOutstanding;
nsAutoPtr<CancelableTask> mQueuedTask;
TimeStamp mStartTime;
// How long it took in the past to paint after a series of previous requests.
nsTArray<TimeDuration> mDurations;
uint32_t mMaxDurations;
};
}

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

@ -111,9 +111,6 @@ public:
TimeDuration operator*(const int64_t aMultiplier) const {
return TimeDuration::FromTicks(mValue * int64_t(aMultiplier));
}
TimeDuration operator/(const int64_t aDivisor) const {
return TimeDuration::FromTicks(mValue / aDivisor);
}
double operator/(const TimeDuration& aOther) {
return static_cast<double>(mValue) / aOther.mValue;
}