diff --git a/browser/metro/profile/metro.js b/browser/metro/profile/metro.js index db258325370e..5949bf3a8670 100644 --- a/browser/metro/profile/metro.js +++ b/browser/metro/profile/metro.js @@ -36,6 +36,7 @@ pref("prompts.tab_modal.enabled", true); pref("layers.offmainthreadcomposition.enabled", true); pref("layers.async-pan-zoom.enabled", false); pref("layers.componentalpha.enabled", false); +pref("gfx.azpc.touch_start_tolerance", "0.1"); // dpi * tolerance = pixel threshold pref("gfx.axis.fling_friction", "0.002"); // Enable Microsoft TSF support by default for imes. diff --git a/gfx/layers/composite/APZCTreeManager.cpp b/gfx/layers/composite/APZCTreeManager.cpp index fcdfba5aa08b..35ddbf0f3909 100644 --- a/gfx/layers/composite/APZCTreeManager.cpp +++ b/gfx/layers/composite/APZCTreeManager.cpp @@ -25,6 +25,8 @@ namespace mozilla { namespace layers { +float APZCTreeManager::sDPI = 72.0; + APZCTreeManager::APZCTreeManager() : mTreeLock("APZCTreeLock") { diff --git a/gfx/layers/composite/APZCTreeManager.h b/gfx/layers/composite/APZCTreeManager.h index fd5f5352364e..3d45ebf8ae4a 100644 --- a/gfx/layers/composite/APZCTreeManager.h +++ b/gfx/layers/composite/APZCTreeManager.h @@ -235,6 +235,17 @@ public: */ void ClearTree(); + /** + * Set the dpi value used by all AsyncPanZoomControllers. + * DPI defaults to 72 if not set using SetDPI() at any point. + */ + static void SetDPI(float aDpiValue) { sDPI = aDpiValue; } + + /** + * Returns the current dpi value in use. + */ + static float GetDPI() { return sDPI; } + protected: /** * Debug-build assertion that can be called to ensure code is running on the @@ -292,6 +303,8 @@ private: * input delivery thread, and so does not require locking. */ nsRefPtr mApzcForInputBlock; + + static float sDPI; }; } diff --git a/gfx/layers/ipc/AsyncPanZoomController.cpp b/gfx/layers/ipc/AsyncPanZoomController.cpp index 2ff914cc8387..a2dc0df322c5 100644 --- a/gfx/layers/ipc/AsyncPanZoomController.cpp +++ b/gfx/layers/ipc/AsyncPanZoomController.cpp @@ -212,7 +212,6 @@ AsyncPanZoomController::AsyncPanZoomController(uint64_t aLayersId, mLastAsyncScrollOffset(0, 0), mCurrentAsyncScrollOffset(0, 0), mAsyncScrollTimeoutTask(nullptr), - mDPI(72), mDisableNextTouchBatch(false), mHandlingTouchQueue(false), mDelayPanning(false) @@ -222,8 +221,6 @@ AsyncPanZoomController::AsyncPanZoomController(uint64_t aLayersId, if (aGestures == USE_GESTURE_DETECTOR) { mGestureEventListener = new GestureEventListener(this); } - - SetDPI(mDPI); } AsyncPanZoomController::~AsyncPanZoomController() { @@ -432,7 +429,7 @@ nsEventStatus AsyncPanZoomController::OnTouchMove(const MultiTouchInput& aEvent) return nsEventStatus_eIgnore; case TOUCHING: { - float panThreshold = gTouchStartTolerance * mDPI; + float panThreshold = gTouchStartTolerance * APZCTreeManager::GetDPI(); UpdateWithTouchAtDevicePoint(aEvent); if (PanDistance() < panThreshold) { @@ -950,14 +947,6 @@ const CSSRect AsyncPanZoomController::CalculatePendingDisplayPort( return scrollableRect.ClampRect(shiftedDisplayPort) - scrollOffset; } -void AsyncPanZoomController::SetDPI(int aDPI) { - mDPI = aDPI; -} - -int AsyncPanZoomController::GetDPI() { - return mDPI; -} - void AsyncPanZoomController::ScheduleComposite() { if (mCompositorParent) { mCompositorParent->ScheduleRenderOnCompositorThread(); diff --git a/gfx/layers/ipc/AsyncPanZoomController.h b/gfx/layers/ipc/AsyncPanZoomController.h index bf9bfd1e0df6..30b154163a9f 100644 --- a/gfx/layers/ipc/AsyncPanZoomController.h +++ b/gfx/layers/ipc/AsyncPanZoomController.h @@ -207,19 +207,6 @@ public: */ ViewTransform GetCurrentAsyncTransform(); - /** - * Sets the DPI of the device for use within panning and zooming logic. It is - * a platform responsibility to set this on initialization of this class and - * whenever it changes. - */ - void SetDPI(int aDPI); - - /** - * Gets the DPI of the device for use outside the panning and zooming logic. - * It defaults to 72 if not set using SetDPI() at any point. - */ - int GetDPI(); - /** * Recalculates the displayport. Ideally, this should paint an area bigger * than the composite-to dimensions so that when you scroll down, you don't @@ -590,8 +577,6 @@ private: // ensures the last mozbrowserasyncscroll event is always been fired. CancelableTask* mAsyncScrollTimeoutTask; - int mDPI; - // 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; diff --git a/gfx/layers/ipc/GestureEventListener.cpp b/gfx/layers/ipc/GestureEventListener.cpp index 8783b39bdb57..4d0147ca75cb 100644 --- a/gfx/layers/ipc/GestureEventListener.cpp +++ b/gfx/layers/ipc/GestureEventListener.cpp @@ -108,7 +108,7 @@ nsEventStatus GestureEventListener::HandleInputEvent(const InputData& aEvent) ScreenIntPoint delta = event.mTouches[0].mScreenPoint - mTouchStartPosition; if (mTouches.Length() == 1 && NS_hypot(delta.x, delta.y) > - mAsyncPanZoomController->GetDPI() * mAsyncPanZoomController->GetTouchStartTolerance()) + APZCTreeManager::GetDPI() * mAsyncPanZoomController->GetTouchStartTolerance()) { HandleTapCancel(event); } diff --git a/widget/windows/winrt/MetroWidget.cpp b/widget/windows/winrt/MetroWidget.cpp index 5d49fb94ff56..42f3052a6f8f 100644 --- a/widget/windows/winrt/MetroWidget.cpp +++ b/widget/windows/winrt/MetroWidget.cpp @@ -836,9 +836,11 @@ CompositorParent* MetroWidget::NewCompositorParent(int aSurfaceWidth, int aSurfa CompositorParent *compositor = nsBaseWidget::NewCompositorParent(aSurfaceWidth, aSurfaceHeight); if (ShouldUseAPZC()) { - CompositorParent::SetControllerForLayerTree(compositor->RootLayerTreeId(), this); - MetroWidget::sAPZC = CompositorParent::GetAPZCTreeManager(compositor->RootLayerTreeId()); mRootLayerTreeId = compositor->RootLayerTreeId(); + CompositorParent::SetControllerForLayerTree(mRootLayerTreeId, this); + + MetroWidget::sAPZC = CompositorParent::GetAPZCTreeManager(compositor->RootLayerTreeId()); + MetroWidget::sAPZC->SetDPI(GetDPI()); nsresult rv; nsCOMPtr observerService = do_GetService("@mozilla.org/observer-service;1", &rv);