Bug 968112: Remove acceleration code from APZC r=kats

This commit is contained in:
Doug Sherk 2014-02-05 15:15:05 +01:00
parent 96f8629bed
commit df0b993f93
5 changed files with 9 additions and 77 deletions

View File

@ -610,7 +610,7 @@ TabChild::HandlePossibleViewportChange()
// The page must have been refreshed in some way such as a new document or
// new CSS viewport, so we know that there's no velocity, acceleration, and
// we have no idea how long painting will take.
metrics, ScreenPoint(0.0f, 0.0f), gfx::Point(0.0f, 0.0f), 0.0);
metrics, ScreenPoint(0.0f, 0.0f), 0.0);
metrics.mCumulativeResolution = metrics.mZoom / metrics.mDevPixelsPerCSSPixel * ScreenToLayerScale(1);
// This is the root layer, so the cumulative resolution is the same
// as the resolution.

View File

@ -994,10 +994,6 @@ const ScreenPoint AsyncPanZoomController::GetVelocityVector() {
return ScreenPoint(mX.GetVelocity(), mY.GetVelocity());
}
const gfx::Point AsyncPanZoomController::GetAccelerationVector() {
return gfx::Point(mX.GetAccelerationFactor(), mY.GetAccelerationFactor());
}
void AsyncPanZoomController::HandlePanningWithTouchAction(double aAngle, TouchBehaviorFlags aBehavior) {
// Handling of cross sliding will need to be added in this method after touch-action released
// enabled by default.
@ -1309,7 +1305,6 @@ EnlargeDisplayPortAlongAxis(float* aOutOffset, float* aOutLength,
const CSSRect AsyncPanZoomController::CalculatePendingDisplayPort(
const FrameMetrics& aFrameMetrics,
const ScreenPoint& aVelocity,
const gfx::Point& aAcceleration,
double aEstimatedPaintDuration)
{
// convert to milliseconds
@ -1343,10 +1338,9 @@ const CSSRect AsyncPanZoomController::CalculatePendingDisplayPort(
displayPort = displayPort.ForceInside(scrollableRect) - scrollOffset;
APZC_LOG_FM(aFrameMetrics,
"Calculated displayport as (%f %f %f %f) from velocity (%f %f) acceleration (%f %f) paint time %f metrics",
"Calculated displayport as (%f %f %f %f) from velocity (%f %f) paint time %f metrics",
displayPort.x, displayPort.y, displayPort.width, displayPort.height,
aVelocity.x, aVelocity.y, aAcceleration.x, aAcceleration.y,
(float)estimatedPaintDurationMillis);
aVelocity.x, aVelocity.y, (float)estimatedPaintDurationMillis);
return displayPort;
}
@ -1365,7 +1359,6 @@ void AsyncPanZoomController::RequestContentRepaint(FrameMetrics& aFrameMetrics)
aFrameMetrics.mDisplayPort =
CalculatePendingDisplayPort(aFrameMetrics,
GetVelocityVector(),
GetAccelerationVector(),
mPaintThrottler.AverageDuration().ToSeconds());
// If we're trying to paint what we already think is painted, discard this
@ -1720,7 +1713,6 @@ void AsyncPanZoomController::ZoomToRect(CSSRect aRect) {
endZoomToMetrics.mDisplayPort =
CalculatePendingDisplayPort(endZoomToMetrics,
ScreenPoint(0,0),
gfx::Point(0,0),
0);
StartAnimation(new ZoomAnimation(

View File

@ -240,7 +240,6 @@ public:
static const CSSRect CalculatePendingDisplayPort(
const FrameMetrics& aFrameMetrics,
const ScreenPoint& aVelocity,
const gfx::Point& aAcceleration,
double aEstimatedPaintDuration);
/**
@ -438,11 +437,6 @@ protected:
*/
const ScreenPoint GetVelocityVector();
/**
* Gets a vector of the acceleration factors of each axis.
*/
const gfx::Point GetAccelerationVector();
/**
* Gets a reference to the first touch point from a MultiTouchInput. This
* gets only the first one and assumes the rest are either missing or not

View File

@ -33,22 +33,6 @@ static float gMaxEventAcceleration = 999.0f;
*/
static float gFlingFriction = 0.002f;
/**
* Threshold for velocity beneath which we turn off any acceleration we had
* during repeated flings.
*/
static float gVelocityThreshold = 0.14f;
/**
* Amount of acceleration we multiply in each time the user flings in one
* direction. Every time they let go of the screen, we increase the acceleration
* by this amount raised to the power of the amount of times they have let go,
* times two (to make the curve steeper). This stops if the user lets go and we
* slow down enough, or if they put their finger down without moving it for a
* moment (or in the opposite direction).
*/
static float gAccelerationMultiplier = 1.125f;
/**
* When flinging, if the velocity goes below this number, we just stop the
* animation completely. This is to prevent asymptotically approaching 0
@ -67,8 +51,6 @@ static void ReadAxisPrefs()
{
Preferences::AddFloatVarCache(&gMaxEventAcceleration, "apz.max_event_acceleration", gMaxEventAcceleration);
Preferences::AddFloatVarCache(&gFlingFriction, "apz.fling_friction", gFlingFriction);
Preferences::AddFloatVarCache(&gVelocityThreshold, "apz.velocity_threshold", gVelocityThreshold);
Preferences::AddFloatVarCache(&gAccelerationMultiplier, "apz.acceleration_multiplier", gAccelerationMultiplier);
Preferences::AddFloatVarCache(&gFlingStoppedThreshold, "apz.fling_stopped_threshold", gFlingStoppedThreshold);
Preferences::AddUintVarCache(&gMaxVelocityQueueSize, "apz.max_velocity_queue_size", gMaxVelocityQueueSize);
}
@ -100,7 +82,6 @@ static void InitAxisPrefs()
Axis::Axis(AsyncPanZoomController* aAsyncPanZoomController)
: mPos(0),
mVelocity(0.0f),
mAcceleration(0),
mAxisLocked(false),
mAsyncPanZoomController(aAsyncPanZoomController)
{
@ -110,15 +91,6 @@ Axis::Axis(AsyncPanZoomController* aAsyncPanZoomController)
void Axis::UpdateWithTouchAtDevicePoint(int32_t aPos, const TimeDuration& aTimeDelta) {
float newVelocity = mAxisLocked ? 0 : (mPos - aPos) / aTimeDelta.ToMilliseconds();
bool curVelocityBelowThreshold = fabsf(newVelocity) < gVelocityThreshold;
bool directionChange = (mVelocity > 0) != (newVelocity > 0);
// If we've changed directions, or the current velocity threshold, stop any
// acceleration we've accumulated.
if (directionChange || curVelocityBelowThreshold) {
mAcceleration = 0;
}
mVelocity = newVelocity;
mPos = aPos;
@ -145,23 +117,17 @@ float Axis::AdjustDisplacement(float aDisplacement, float& aOverscrollAmountOut,
if (aScrollingDisabled) {
// Scrolling is disabled on this axis, stop scrolling.
aOverscrollAmountOut = aDisplacement;
mAcceleration = 0;
return 0;
}
if (fabsf(mVelocity) < gVelocityThreshold) {
mAcceleration = 0;
}
float displacement = aDisplacement;
float accelerationFactor = GetAccelerationFactor();
float displacement = aDisplacement * accelerationFactor;
// If this displacement will cause an overscroll, throttle it. Can potentially
// bring it to 0 even if the velocity is high.
if (DisplacementWillOverscroll(displacement) != OVERSCROLL_NONE) {
// No need to have a velocity along this axis anymore; it won't take us
// anywhere, so we're just spinning needlessly.
mVelocity = 0.0f;
mAcceleration = 0;
aOverscrollAmountOut = DisplacementWillOverscrollAmount(displacement);
displacement -= aOverscrollAmountOut;
}
@ -177,8 +143,6 @@ float Axis::PanDistance(float aPos) {
}
void Axis::EndTouch() {
mAcceleration++;
// Calculate the mean velocity and empty the queue.
int count = mVelocityQueue.Length();
if (count) {
@ -193,7 +157,6 @@ void Axis::EndTouch() {
void Axis::CancelTouch() {
mVelocity = 0.0f;
mAcceleration = 0;
while (!mVelocityQueue.IsEmpty()) {
mVelocityQueue.RemoveElementAt(0);
}
@ -302,10 +265,6 @@ float Axis::GetVelocity() {
return mAxisLocked ? 0 : mVelocity;
}
float Axis::GetAccelerationFactor() {
return powf(gAccelerationMultiplier, std::max(0, (mAcceleration - 4) * 3));
}
float Axis::GetCompositionEnd() {
return GetOrigin() + GetCompositionLength();
}

View File

@ -70,12 +70,11 @@ public:
void CancelTouch();
/**
* Takes a requested displacement to the position of this axis, and adjusts
* it to account for acceleration (which might increase the displacement),
* overscroll (which might decrease the displacement; this is to prevent the
* viewport from overscrolling the page rect), and axis locking (which might
* prevent any displacement from happening). If overscroll ocurred, its amount
* is written to |aOverscrollAmountOut|.
* Takes a requested displacement to the position of this axis, and adjusts it
* to account for overscroll (which might decrease the displacement; this is
* to prevent the viewport from overscrolling the page rect), and axis locking
* (which might prevent any displacement from happening). If overscroll
* ocurred, its amount is written to |aOverscrollAmountOut|.
* The adjusted displacement is returned.
*
* aScrollingDisabled is used to indicate that no scrolling should happen
@ -128,12 +127,6 @@ public:
*/
float GetExcess();
/**
* Gets the factor of acceleration applied to the velocity, based on the
* amount of flings that have been done successively.
*/
float GetAccelerationFactor();
/**
* Gets the raw velocity of this axis at this moment.
*/
@ -188,12 +181,6 @@ protected:
int32_t mPos;
int32_t mStartPos;
float mVelocity;
// Acceleration is represented by an int, which is the power we raise a
// constant to and then multiply the velocity by whenever it is sampled. We do
// this only when we detect that the user wants to do a fast fling; that is,
// they are flinging multiple times in a row very quickly, probably trying to
// reach one of the extremes of the page.
int32_t mAcceleration;
bool mAxisLocked; // Whether movement on this axis is locked.
AsyncPanZoomController* mAsyncPanZoomController;
nsTArray<float> mVelocityQueue;