mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1063224 - Give AsyncPanZoomController a mechanism for converting between local and global screen coordinates. r=kats
--HG-- extra : source : 9e2fe73a1837854b8a024f82d2b6a38eba18ff5e
This commit is contained in:
parent
e35b939581
commit
98845853b8
@ -1692,6 +1692,35 @@ nsEventStatus AsyncPanZoomController::OnCancelTap(const TapGestureInput& aEvent)
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
|
||||
// Helper function for To[Global|Local]ScreenCoordinates().
|
||||
// TODO(botond): Generalize this into a template function in UnitTransforms.h.
|
||||
static void TransformVector(const Matrix4x4& aTransform,
|
||||
ScreenPoint* aVector,
|
||||
const ScreenPoint& aAnchor) {
|
||||
ScreenPoint start = aAnchor;
|
||||
ScreenPoint end = aAnchor + *aVector;
|
||||
start = TransformTo<ScreenPixel>(aTransform, start);
|
||||
end = TransformTo<ScreenPixel>(aTransform, end);
|
||||
*aVector = end - start;
|
||||
}
|
||||
|
||||
void AsyncPanZoomController::ToGlobalScreenCoordinates(ScreenPoint* aVector,
|
||||
const ScreenPoint& aAnchor) const {
|
||||
if (APZCTreeManager* treeManagerLocal = mTreeManager) {
|
||||
Matrix4x4 transform = treeManagerLocal->GetScreenToApzcTransform(this);
|
||||
transform.Invert();
|
||||
TransformVector(transform, aVector, aAnchor);
|
||||
}
|
||||
}
|
||||
|
||||
void AsyncPanZoomController::ToLocalScreenCoordinates(ScreenPoint* aVector,
|
||||
const ScreenPoint& aAnchor) const {
|
||||
if (APZCTreeManager* treeManagerLocal = mTreeManager) {
|
||||
Matrix4x4 transform = treeManagerLocal->GetScreenToApzcTransform(this);
|
||||
TransformVector(transform, aVector, aAnchor);
|
||||
}
|
||||
}
|
||||
|
||||
float AsyncPanZoomController::PanDistance() const {
|
||||
ReentrantMonitorAutoEnter lock(mMonitor);
|
||||
return NS_hypot(mX.PanDistance(), mY.PanDistance());
|
||||
|
@ -326,6 +326,28 @@ public:
|
||||
*/
|
||||
int32_t GetLastTouchIdentifier() const;
|
||||
|
||||
/**
|
||||
* Convert the vector |aVector|, rooted at the point |aAnchor|, from
|
||||
* this APZC's local screen coordinates into global screen coordinates.
|
||||
* The anchor is necessary because with 3D tranforms, the location of the
|
||||
* vector can affect the result of the transform.
|
||||
* To respect the lock ordering, mMonitor must NOT be held when calling
|
||||
* this function (since this function acquires the tree lock).
|
||||
*/
|
||||
void ToGlobalScreenCoordinates(ScreenPoint* aVector,
|
||||
const ScreenPoint& aAnchor) const;
|
||||
|
||||
/**
|
||||
* Convert the vector |aVector|, rooted at the point |aAnchor|, from
|
||||
* global screen coordinates into this APZC's local screen coordinates .
|
||||
* The anchor is necessary because with 3D tranforms, the location of the
|
||||
* vector can affect the result of the transform.
|
||||
* To respect the lock ordering, mMonitor must NOT be held when calling
|
||||
* this function (since this function acquires the tree lock).
|
||||
*/
|
||||
void ToLocalScreenCoordinates(ScreenPoint* aVector,
|
||||
const ScreenPoint& aAnchor) const;
|
||||
|
||||
protected:
|
||||
enum PanZoomState {
|
||||
NOTHING, /* no touch-start events received */
|
||||
|
Loading…
Reference in New Issue
Block a user