bool GestureEventListener::MoveDistanceIsLarge() { const ParentLayerPoint start = mLastTouchInput.mTouches[0].mLocalScreenPoint; ParentLayerPoint delta = start - mTouchStartPosition; ScreenPoint screenDelta = mAsyncPanZoomController->ToScreenCoordinates(delta, start); return (screenDelta.Length() > AsyncPanZoomController::GetTouchStartTolerance()); }
void Axis::UpdateWithTouchAtDevicePoint(ScreenCoord aPos, uint32_t aTimestampMs) { // mVelocityQueue is controller-thread only AsyncPanZoomController::AssertOnControllerThread(); if (aTimestampMs == mPosTimeMs) { // This could be a duplicate event, or it could be a legitimate event // on some platforms that generate events really fast. As a compromise // update mPos so we don't run into problems like bug 1042734, even though // that means the velocity will be stale. Better than doing a divide-by-zero. mPos = aPos; return; } float newVelocity = mAxisLocked ? 0.0f : (float)(mPos - aPos) / (float)(aTimestampMs - mPosTimeMs); if (gfxPrefs::APZMaxVelocity() > 0.0f) { ScreenPoint maxVelocity = MakePoint(gfxPrefs::APZMaxVelocity() * APZCTreeManager::GetDPI()); mAsyncPanZoomController->ToLocalScreenCoordinates(&maxVelocity, mAsyncPanZoomController->PanStart()); newVelocity = std::min(newVelocity, maxVelocity.Length()); } mVelocity = newVelocity; mPos = aPos; mPosTimeMs = aTimestampMs; // Limit queue size pased on pref mVelocityQueue.AppendElement(std::make_pair(aTimestampMs, mVelocity)); if (mVelocityQueue.Length() > gfxPrefs::APZMaxVelocityQueueSize()) { mVelocityQueue.RemoveElementAt(0); } }