Bug 907243 - Move SetDPI to APZCTreeManager. r=kats

This commit is contained in:
Jim Mathies 2013-08-22 19:28:02 -05:00
parent fcd4bed6e9
commit e6ba4d9285
7 changed files with 22 additions and 30 deletions

View File

@ -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.

View File

@ -25,6 +25,8 @@
namespace mozilla {
namespace layers {
float APZCTreeManager::sDPI = 72.0;
APZCTreeManager::APZCTreeManager()
: mTreeLock("APZCTreeLock")
{

View File

@ -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<AsyncPanZoomController> mApzcForInputBlock;
static float sDPI;
};
}

View File

@ -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();

View File

@ -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;

View File

@ -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);
}

View File

@ -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<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1", &rv);