Bug 923512 - Introduce strongly-typed coordinate classes (Part2: Changes to rest of codebase, and switching Axis to use the strongly-typed coordinates). r=kats

This commit is contained in:
Botond Ballo 2014-07-29 17:24:12 -04:00
Родитель 320a557f2c
Коммит 4dcd36c48e
13 изменённых файлов: 139 добавлений и 104 удалений

Просмотреть файл

@ -728,7 +728,7 @@ public:
int32_t ScrollTop() int32_t ScrollTop()
{ {
nsIScrollableFrame* sf = GetScrollFrame(); nsIScrollableFrame* sf = GetScrollFrame();
return sf ? sf->GetScrollPositionCSSPixels().y : 0; return sf ? sf->GetScrollPositionCSSPixels().y.value : 0;
} }
void SetScrollTop(int32_t aScrollTop) void SetScrollTop(int32_t aScrollTop)
{ {
@ -741,7 +741,7 @@ public:
int32_t ScrollLeft() int32_t ScrollLeft()
{ {
nsIScrollableFrame* sf = GetScrollFrame(); nsIScrollableFrame* sf = GetScrollFrame();
return sf ? sf->GetScrollPositionCSSPixels().x : 0; return sf ? sf->GetScrollPositionCSSPixels().x.value : 0;
} }
void SetScrollLeft(int32_t aScrollLeft) void SetScrollLeft(int32_t aScrollLeft)
{ {

Просмотреть файл

@ -1987,7 +1987,7 @@ CanvasRenderingContext2D::ArcTo(double x1, double y1, double x2,
} }
// Check for colinearity // Check for colinearity
dir = (p2.x - p1.x) * (p0.y - p1.y) + (p2.y - p1.y) * (p1.x - p0.x); dir = (p2.x - p1.x).value * (p0.y - p1.y).value + (p2.y - p1.y).value * (p1.x - p0.x).value;
if (dir == 0) { if (dir == 0) {
LineTo(p1.x, p1.y); LineTo(p1.x, p1.y);
return; return;
@ -4505,7 +4505,7 @@ CanvasPath::ArcTo(double x1, double y1, double x2, double y2, double radius,
} }
// Check for colinearity // Check for colinearity
dir = (p2.x - p1.x) * (p0.y - p1.y) + (p2.y - p1.y) * (p1.x - p0.x); dir = (p2.x - p1.x).value * (p0.y - p1.y).value + (p2.y - p1.y).value * (p1.x - p0.x).value;
if (dir == 0) { if (dir == 0) {
LineTo(p1.x, p1.y); LineTo(p1.x, p1.y);
return; return;

Просмотреть файл

@ -791,7 +791,7 @@ protected:
// The spec says we should not draw shadows if the operator is OVER. // The spec says we should not draw shadows if the operator is OVER.
// If it's over and the alpha value is zero, nothing needs to be drawn. // If it's over and the alpha value is zero, nothing needs to be drawn.
return NS_GET_A(state.shadowColor) != 0 && return NS_GET_A(state.shadowColor) != 0 &&
(state.shadowBlur != 0 || state.shadowOffset.x != 0 || state.shadowOffset.y != 0); (state.shadowBlur != 0.f || state.shadowOffset.x != 0.f || state.shadowOffset.y != 0.f);
} }
mozilla::gfx::CompositionOp UsedOperation() mozilla::gfx::CompositionOp UsedOperation()

Просмотреть файл

@ -1595,8 +1595,9 @@ EventStateManager::GenerateDragGesture(nsPresContext* aPresContext,
// fire drag gesture if mouse has moved enough // fire drag gesture if mouse has moved enough
LayoutDeviceIntPoint pt = aEvent->refPoint + LayoutDeviceIntPoint pt = aEvent->refPoint +
LayoutDeviceIntPoint::FromUntyped(aEvent->widget->WidgetToScreenOffset()); LayoutDeviceIntPoint::FromUntyped(aEvent->widget->WidgetToScreenOffset());
if (DeprecatedAbs(pt.x - mGestureDownPoint.x) > pixelThresholdX || LayoutDeviceIntPoint distance = pt - mGestureDownPoint;
DeprecatedAbs(pt.y - mGestureDownPoint.y) > pixelThresholdY) { if (Abs(distance.x.value) > SafeCast<uint32_t>(pixelThresholdX) ||
Abs(distance.y.value) > SafeCast<uint32_t>(pixelThresholdY)) {
if (Prefs::ClickHoldContextMenu()) { if (Prefs::ClickHoldContextMenu()) {
// stop the click-hold before we fire off the drag gesture, in case // stop the click-hold before we fire off the drag gesture, in case
// it takes a long time // it takes a long time

Просмотреть файл

@ -507,6 +507,38 @@ struct ParamTraits<nsIntSize>
} }
}; };
template<class T>
struct ParamTraits< mozilla::gfx::CoordTyped<T> >
{
typedef mozilla::gfx::CoordTyped<T> paramType;
static void Write(Message* msg, const paramType& param)
{
WriteParam(msg, param.value);
}
static bool Read(const Message* msg, void** iter, paramType* result)
{
return (ReadParam(msg, iter, &result->value));
}
};
template<class T>
struct ParamTraits< mozilla::gfx::IntCoordTyped<T> >
{
typedef mozilla::gfx::IntCoordTyped<T> paramType;
static void Write(Message* msg, const paramType& param)
{
WriteParam(msg, param.value);
}
static bool Read(const Message* msg, void** iter, paramType* result)
{
return (ReadParam(msg, iter, &result->value));
}
};
template<class T, class U> template<class T, class U>
struct ParamTraits< mozilla::gfx::ScaleFactor<T, U> > struct ParamTraits< mozilla::gfx::ScaleFactor<T, U> >
{ {

Просмотреть файл

@ -384,16 +384,14 @@ APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor,
ApplyTransform(gfx::PointTyped<T>* aPoint, const Matrix4x4& aMatrix) ApplyTransform(gfx::PointTyped<T>* aPoint, const Matrix4x4& aMatrix)
{ {
Point result = aMatrix * aPoint->ToUnknownPoint(); Point result = aMatrix * aPoint->ToUnknownPoint();
aPoint->x = result.x; *aPoint = ViewAs<T>(result);
aPoint->y = result.y;
} }
/*static*/ template<class T> void /*static*/ template<class T> void
ApplyTransform(gfx::IntPointTyped<T>* aPoint, const Matrix4x4& aMatrix) ApplyTransform(gfx::IntPointTyped<T>* aPoint, const Matrix4x4& aMatrix)
{ {
Point result = aMatrix * aPoint->ToUnknownPoint(); Point result = aMatrix * aPoint->ToUnknownPoint();
aPoint->x = result.x; *aPoint = TruncatedToInt(ViewAs<T>(result));
aPoint->y = result.y;
} }
/*static*/ void /*static*/ void
@ -651,9 +649,7 @@ APZCTreeManager::TransformCoordinateToGecko(const ScreenIntPoint& aPoint,
Matrix4x4 transformToGecko; Matrix4x4 transformToGecko;
GetInputTransforms(apzc, transformToApzc, transformToGecko); GetInputTransforms(apzc, transformToApzc, transformToGecko);
Matrix4x4 outTransform = transformToApzc * transformToGecko; Matrix4x4 outTransform = transformToApzc * transformToGecko;
aOutTransformedPoint->x = aPoint.x; *aOutTransformedPoint = TransformTo<LayoutDevicePixel>(outTransform, aPoint);
aOutTransformedPoint->y = aPoint.y;
ApplyTransform(aOutTransformedPoint, outTransform);
} }
} }

Просмотреть файл

@ -378,8 +378,8 @@ static bool IsCloseToVertical(float aAngle, float aThreshold)
template <typename Units> template <typename Units>
static bool IsZero(const gfx::PointTyped<Units>& aPoint) static bool IsZero(const gfx::PointTyped<Units>& aPoint)
{ {
return FuzzyEqualsMultiplicative(aPoint.x, 0.0f) return FuzzyEqualsMultiplicative(aPoint.x.value, 0.0f)
&& FuzzyEqualsMultiplicative(aPoint.y, 0.0f); && FuzzyEqualsMultiplicative(aPoint.y.value, 0.0f);
} }
static inline void LogRendertraceRect(const ScrollableLayerGuid& aGuid, const char* aDesc, const char* aColor, const CSSRect& aRect) static inline void LogRendertraceRect(const ScrollableLayerGuid& aGuid, const char* aDesc, const char* aColor, const CSSRect& aRect)
@ -529,9 +529,9 @@ public:
// We may have reached the end of the scroll range along one axis but // We may have reached the end of the scroll range along one axis but
// not the other. In such a case we only want to hand off the relevant // not the other. In such a case we only want to hand off the relevant
// component of the fling. // component of the fling.
if (FuzzyEqualsAdditive(overscroll.x, 0.0f, COORDINATE_EPSILON)) { if (FuzzyEqualsAdditive(overscroll.x.value, 0.0f, COORDINATE_EPSILON)) {
velocity.x = 0; velocity.x = 0;
} else if (FuzzyEqualsAdditive(overscroll.y, 0.0f, COORDINATE_EPSILON)) { } else if (FuzzyEqualsAdditive(overscroll.y.value, 0.0f, COORDINATE_EPSILON)) {
velocity.y = 0; velocity.y = 0;
} }
@ -599,7 +599,7 @@ public:
// Sample the zoom at the current time point. The sampled zoom // Sample the zoom at the current time point. The sampled zoom
// will affect the final computed resolution. // will affect the final computed resolution.
double sampledPosition = gComputedTimingFunction->GetValue(animPosition); float sampledPosition = gComputedTimingFunction->GetValue(animPosition);
// We scale the scrollOffset linearly with sampledPosition, so the zoom // We scale the scrollOffset linearly with sampledPosition, so the zoom
// needs to scale inversely to match. // needs to scale inversely to match.
@ -1357,8 +1357,8 @@ AsyncPanZoomController::ConvertToGecko(const ScreenPoint& aPoint, CSSPoint* aOut
nsEventStatus AsyncPanZoomController::OnPanMayBegin(const PanGestureInput& aEvent) { nsEventStatus AsyncPanZoomController::OnPanMayBegin(const PanGestureInput& aEvent) {
APZC_LOG("%p got a pan-maybegin in state %d\n", this, mState); APZC_LOG("%p got a pan-maybegin in state %d\n", this, mState);
mX.StartTouch(aEvent.mPanStartPoint.x, aEvent.mTime); mX.StartTouch(aEvent.mPanStartPoint.x.Truncated(), aEvent.mTime);
mY.StartTouch(aEvent.mPanStartPoint.y, aEvent.mTime); mY.StartTouch(aEvent.mPanStartPoint.y.Truncated(), aEvent.mTime);
CancelAnimationForHandoffChain(); CancelAnimationForHandoffChain();
return nsEventStatus_eConsumeNoDefault; return nsEventStatus_eConsumeNoDefault;
@ -1377,8 +1377,8 @@ nsEventStatus AsyncPanZoomController::OnPanCancelled(const PanGestureInput& aEve
nsEventStatus AsyncPanZoomController::OnPanBegin(const PanGestureInput& aEvent) { nsEventStatus AsyncPanZoomController::OnPanBegin(const PanGestureInput& aEvent) {
APZC_LOG("%p got a pan-begin in state %d\n", this, mState); APZC_LOG("%p got a pan-begin in state %d\n", this, mState);
mX.StartTouch(aEvent.mPanStartPoint.x, aEvent.mTime); mX.StartTouch(aEvent.mPanStartPoint.x.Truncated(), aEvent.mTime);
mY.StartTouch(aEvent.mPanStartPoint.y, aEvent.mTime); mY.StartTouch(aEvent.mPanStartPoint.y.Truncated(), aEvent.mTime);
if (GetAxisLockMode() == FREE) { if (GetAxisLockMode() == FREE) {
SetState(PANNING); SetState(PANNING);
@ -1401,8 +1401,8 @@ nsEventStatus AsyncPanZoomController::OnPan(const PanGestureInput& aEvent, bool
// size and position. We need to do so even if this is a momentum pan (i.e. // size and position. We need to do so even if this is a momentum pan (i.e.
// aFingersOnTouchpad == false); in that case the "with touch" part is not // aFingersOnTouchpad == false); in that case the "with touch" part is not
// really appropriate, so we may want to rethink this at some point. // really appropriate, so we may want to rethink this at some point.
mX.UpdateWithTouchAtDevicePoint(aEvent.mPanStartPoint.x, aEvent.mTime); mX.UpdateWithTouchAtDevicePoint(aEvent.mPanStartPoint.x.Truncated(), aEvent.mTime);
mY.UpdateWithTouchAtDevicePoint(aEvent.mPanStartPoint.y, aEvent.mTime); mY.UpdateWithTouchAtDevicePoint(aEvent.mPanStartPoint.y.Truncated(), aEvent.mTime);
HandlePanningUpdate(aEvent.mPanDisplacement.x, aEvent.mPanDisplacement.y); HandlePanningUpdate(aEvent.mPanDisplacement.x, aEvent.mPanDisplacement.y);

Просмотреть файл

@ -33,7 +33,7 @@ Axis::Axis(AsyncPanZoomController* aAsyncPanZoomController)
{ {
} }
void Axis::UpdateWithTouchAtDevicePoint(int32_t aPos, uint32_t aTimestampMs) { void Axis::UpdateWithTouchAtDevicePoint(ScreenIntCoord aPos, uint32_t aTimestampMs) {
// mVelocityQueue is controller-thread only // mVelocityQueue is controller-thread only
AsyncPanZoomController::AssertOnControllerThread(); AsyncPanZoomController::AssertOnControllerThread();
@ -62,16 +62,16 @@ void Axis::UpdateWithTouchAtDevicePoint(int32_t aPos, uint32_t aTimestampMs) {
} }
} }
void Axis::StartTouch(int32_t aPos, uint32_t aTimestampMs) { void Axis::StartTouch(ScreenIntCoord aPos, uint32_t aTimestampMs) {
mStartPos = aPos; mStartPos = aPos;
mPos = aPos; mPos = aPos;
mPosTimeMs = aTimestampMs; mPosTimeMs = aTimestampMs;
mAxisLocked = false; mAxisLocked = false;
} }
bool Axis::AdjustDisplacement(float aDisplacement, bool Axis::AdjustDisplacement(CSSCoord aDisplacement,
float& aDisplacementOut, CSSCoord& aDisplacementOut,
float& aOverscrollAmountOut) CSSCoord& aOverscrollAmountOut)
{ {
if (mAxisLocked) { if (mAxisLocked) {
aOverscrollAmountOut = 0; aOverscrollAmountOut = 0;
@ -79,14 +79,14 @@ bool Axis::AdjustDisplacement(float aDisplacement,
return false; return false;
} }
float displacement = aDisplacement; CSSCoord displacement = aDisplacement;
// First consume any overscroll in the opposite direction along this axis. // First consume any overscroll in the opposite direction along this axis.
float consumedOverscroll = 0; CSSCoord consumedOverscroll = 0;
if (mOverscroll > 0 && aDisplacement < 0) { if (mOverscroll > 0 && aDisplacement < 0) {
consumedOverscroll = std::min(mOverscroll, -aDisplacement); consumedOverscroll = std::min(mOverscroll, -aDisplacement);
} else if (mOverscroll < 0 && aDisplacement > 0) { } else if (mOverscroll < 0 && aDisplacement > 0) {
consumedOverscroll = 0 - std::min(-mOverscroll, aDisplacement); consumedOverscroll = 0.f - std::min(-mOverscroll, aDisplacement);
} }
mOverscroll -= consumedOverscroll; mOverscroll -= consumedOverscroll;
displacement += consumedOverscroll; displacement += consumedOverscroll;
@ -104,7 +104,7 @@ bool Axis::AdjustDisplacement(float aDisplacement,
return fabsf(consumedOverscroll) > EPSILON; return fabsf(consumedOverscroll) > EPSILON;
} }
float Axis::ApplyResistance(float aRequestedOverscroll) const { CSSCoord Axis::ApplyResistance(CSSCoord aRequestedOverscroll) const {
// 'resistanceFactor' is a value between 0 and 1, which: // 'resistanceFactor' is a value between 0 and 1, which:
// - tends to 1 as the existing overscroll tends to 0 // - tends to 1 as the existing overscroll tends to 0
// - tends to 0 as the existing overscroll tends to the composition length // - tends to 0 as the existing overscroll tends to the composition length
@ -112,23 +112,23 @@ float Axis::ApplyResistance(float aRequestedOverscroll) const {
// factor; this should prevent overscrolling by more than the composition // factor; this should prevent overscrolling by more than the composition
// length. // length.
float resistanceFactor = 1 - fabsf(mOverscroll) / GetCompositionLength(); float resistanceFactor = 1 - fabsf(mOverscroll) / GetCompositionLength();
return resistanceFactor < 0 ? 0 : aRequestedOverscroll * resistanceFactor; return resistanceFactor < 0 ? CSSCoord(0) : aRequestedOverscroll * resistanceFactor;
} }
void Axis::OverscrollBy(float aOverscroll) { void Axis::OverscrollBy(CSSCoord aOverscroll) {
MOZ_ASSERT(CanScroll()); MOZ_ASSERT(CanScroll());
aOverscroll = ApplyResistance(aOverscroll); aOverscroll = ApplyResistance(aOverscroll);
if (aOverscroll > 0) { if (aOverscroll > 0) {
MOZ_ASSERT(FuzzyEqualsAdditive(GetCompositionEnd(), GetPageEnd(), COORDINATE_EPSILON)); MOZ_ASSERT(FuzzyEqualsAdditive(GetCompositionEnd().value, GetPageEnd().value, COORDINATE_EPSILON));
MOZ_ASSERT(mOverscroll >= 0); MOZ_ASSERT(mOverscroll >= 0);
} else if (aOverscroll < 0) { } else if (aOverscroll < 0) {
MOZ_ASSERT(FuzzyEqualsAdditive(GetOrigin(), GetPageStart(), COORDINATE_EPSILON)); MOZ_ASSERT(FuzzyEqualsAdditive(GetOrigin().value, GetPageStart().value, COORDINATE_EPSILON));
MOZ_ASSERT(mOverscroll <= 0); MOZ_ASSERT(mOverscroll <= 0);
} }
mOverscroll += aOverscroll; mOverscroll += aOverscroll;
} }
float Axis::GetOverscroll() const { CSSCoord Axis::GetOverscroll() const {
return mOverscroll; return mOverscroll;
} }
@ -162,7 +162,7 @@ bool Axis::SampleSnapBack(const TimeDuration& aDelta) {
} }
mOverscroll = std::max(mOverscroll + cssDisplacement, 0.0f); mOverscroll = std::max(mOverscroll + cssDisplacement, 0.0f);
// Overscroll relieved, do not continue animation. // Overscroll relieved, do not continue animation.
if (mOverscroll == 0) { if (mOverscroll == 0.f) {
mVelocity = 0; mVelocity = 0;
return false; return false;
} }
@ -174,7 +174,7 @@ bool Axis::SampleSnapBack(const TimeDuration& aDelta) {
} }
mOverscroll = std::min(mOverscroll + cssDisplacement, 0.0f); mOverscroll = std::min(mOverscroll + cssDisplacement, 0.0f);
// Overscroll relieved, do not continue animation. // Overscroll relieved, do not continue animation.
if (mOverscroll == 0) { if (mOverscroll == 0.f) {
mVelocity = 0; mVelocity = 0;
return false; return false;
} }
@ -185,7 +185,7 @@ bool Axis::SampleSnapBack(const TimeDuration& aDelta) {
} }
bool Axis::IsOverscrolled() const { bool Axis::IsOverscrolled() const {
return mOverscroll != 0; return mOverscroll != 0.f;
} }
void Axis::ClearOverscroll() { void Axis::ClearOverscroll() {
@ -193,11 +193,11 @@ void Axis::ClearOverscroll() {
} }
float Axis::PanDistance() { float Axis::PanDistance() {
return fabsf(mPos - mStartPos); return fabsf((mPos - mStartPos).value);
} }
float Axis::PanDistance(float aPos) { float Axis::PanDistance(ScreenIntCoord aPos) {
return fabsf(aPos - mStartPos); return fabsf((aPos - mStartPos).value);
} }
void Axis::EndTouch(uint32_t aTimestampMs) { void Axis::EndTouch(uint32_t aTimestampMs) {
@ -252,7 +252,7 @@ bool Axis::FlingApplyFrictionOrCancel(const TimeDuration& aDelta,
return true; return true;
} }
Axis::Overscroll Axis::DisplacementWillOverscroll(float aDisplacement) { Axis::Overscroll Axis::DisplacementWillOverscroll(CSSCoord aDisplacement) {
// If the current pan plus a displacement takes the window to the left of or // If the current pan plus a displacement takes the window to the left of or
// above the current page rect. // above the current page rect.
bool minus = GetOrigin() + aDisplacement < GetPageStart(); bool minus = GetOrigin() + aDisplacement < GetPageStart();
@ -271,7 +271,7 @@ Axis::Overscroll Axis::DisplacementWillOverscroll(float aDisplacement) {
return OVERSCROLL_NONE; return OVERSCROLL_NONE;
} }
float Axis::DisplacementWillOverscrollAmount(float aDisplacement) { CSSCoord Axis::DisplacementWillOverscrollAmount(CSSCoord aDisplacement) {
switch (DisplacementWillOverscroll(aDisplacement)) { switch (DisplacementWillOverscroll(aDisplacement)) {
case OVERSCROLL_MINUS: return (GetOrigin() + aDisplacement) - GetPageStart(); case OVERSCROLL_MINUS: return (GetOrigin() + aDisplacement) - GetPageStart();
case OVERSCROLL_PLUS: return (GetCompositionEnd() + aDisplacement) - GetPageEnd(); case OVERSCROLL_PLUS: return (GetCompositionEnd() + aDisplacement) - GetPageEnd();
@ -281,8 +281,8 @@ float Axis::DisplacementWillOverscrollAmount(float aDisplacement) {
} }
} }
float Axis::ScaleWillOverscrollAmount(float aScale, float aFocus) { CSSCoord Axis::ScaleWillOverscrollAmount(float aScale, CSSCoord aFocus) {
float originAfterScale = (GetOrigin() + aFocus) - (aFocus / aScale); CSSCoord originAfterScale = (GetOrigin() + aFocus) - (aFocus / aScale);
bool both = ScaleWillOverscrollBothSides(aScale); bool both = ScaleWillOverscrollBothSides(aScale);
bool minus = GetPageStart() - originAfterScale > COORDINATE_EPSILON; bool minus = GetPageStart() - originAfterScale > COORDINATE_EPSILON;
@ -310,29 +310,29 @@ void Axis::SetVelocity(float aVelocity) {
mVelocity = aVelocity; mVelocity = aVelocity;
} }
float Axis::GetCompositionEnd() const { CSSCoord Axis::GetCompositionEnd() const {
return GetOrigin() + GetCompositionLength(); return GetOrigin() + GetCompositionLength();
} }
float Axis::GetPageEnd() const { CSSCoord Axis::GetPageEnd() const {
return GetPageStart() + GetPageLength(); return GetPageStart() + GetPageLength();
} }
float Axis::GetOrigin() const { CSSCoord Axis::GetOrigin() const {
CSSPoint origin = GetFrameMetrics().GetScrollOffset(); CSSPoint origin = GetFrameMetrics().GetScrollOffset();
return GetPointOffset(origin); return GetPointOffset(origin);
} }
float Axis::GetCompositionLength() const { CSSCoord Axis::GetCompositionLength() const {
return GetRectLength(GetFrameMetrics().CalculateCompositedRectInCssPixels()); return GetRectLength(GetFrameMetrics().CalculateCompositedRectInCssPixels());
} }
float Axis::GetPageStart() const { CSSCoord Axis::GetPageStart() const {
CSSRect pageRect = GetFrameMetrics().GetExpandedScrollableRect(); CSSRect pageRect = GetFrameMetrics().GetExpandedScrollableRect();
return GetRectOffset(pageRect); return GetRectOffset(pageRect);
} }
float Axis::GetPageLength() const { CSSCoord Axis::GetPageLength() const {
CSSRect pageRect = GetFrameMetrics().GetExpandedScrollableRect(); CSSRect pageRect = GetFrameMetrics().GetExpandedScrollableRect();
return GetRectLength(pageRect); return GetRectLength(pageRect);
} }
@ -357,17 +357,17 @@ AxisX::AxisX(AsyncPanZoomController* aAsyncPanZoomController)
} }
float AxisX::GetPointOffset(const CSSPoint& aPoint) const CSSCoord AxisX::GetPointOffset(const CSSPoint& aPoint) const
{ {
return aPoint.x; return aPoint.x;
} }
float AxisX::GetRectLength(const CSSRect& aRect) const CSSCoord AxisX::GetRectLength(const CSSRect& aRect) const
{ {
return aRect.width; return aRect.width;
} }
float AxisX::GetRectOffset(const CSSRect& aRect) const CSSCoord AxisX::GetRectOffset(const CSSRect& aRect) const
{ {
return aRect.x; return aRect.x;
} }
@ -378,17 +378,17 @@ AxisY::AxisY(AsyncPanZoomController* aAsyncPanZoomController)
} }
float AxisY::GetPointOffset(const CSSPoint& aPoint) const CSSCoord AxisY::GetPointOffset(const CSSPoint& aPoint) const
{ {
return aPoint.y; return aPoint.y;
} }
float AxisY::GetRectLength(const CSSRect& aRect) const CSSCoord AxisY::GetRectLength(const CSSRect& aRect) const
{ {
return aRect.height; return aRect.height;
} }
float AxisY::GetRectOffset(const CSSRect& aRect) const CSSCoord AxisY::GetRectOffset(const CSSRect& aRect) const
{ {
return aRect.y; return aRect.y;
} }

Просмотреть файл

@ -55,13 +55,13 @@ public:
* Notify this Axis that a new touch has been received, including a timestamp * Notify this Axis that a new touch has been received, including a timestamp
* for when the touch was received. This triggers a recalculation of velocity. * for when the touch was received. This triggers a recalculation of velocity.
*/ */
void UpdateWithTouchAtDevicePoint(int32_t aPos, uint32_t aTimestampMs); void UpdateWithTouchAtDevicePoint(ScreenIntCoord aPos, uint32_t aTimestampMs);
/** /**
* Notify this Axis that a touch has begun, i.e. the user has put their finger * Notify this Axis that a touch has begun, i.e. the user has put their finger
* on the screen but has not yet tried to pan. * on the screen but has not yet tried to pan.
*/ */
void StartTouch(int32_t aPos, uint32_t aTimestampMs); void StartTouch(ScreenIntCoord aPos, uint32_t aTimestampMs);
/** /**
* Notify this Axis that a touch has ended gracefully. This may perform * Notify this Axis that a touch has ended gracefully. This may perform
@ -87,20 +87,20 @@ public:
* displacement, and the function returns true iff internal overscroll amounts * displacement, and the function returns true iff internal overscroll amounts
* were changed. * were changed.
*/ */
bool AdjustDisplacement(float aDisplacement, bool AdjustDisplacement(CSSCoord aDisplacement,
float& aDisplacementOut, CSSCoord& aDisplacementOut,
float& aOverscrollAmountOut); CSSCoord& aOverscrollAmountOut);
/** /**
* Overscrolls this axis by the requested amount in the requested direction. * Overscrolls this axis by the requested amount in the requested direction.
* The axis must be at the end of its scroll range in this direction. * The axis must be at the end of its scroll range in this direction.
*/ */
void OverscrollBy(float aOverscroll); void OverscrollBy(CSSCoord aOverscroll);
/** /**
* Return the amount of overscroll on this axis, in CSS pixels. * Return the amount of overscroll on this axis, in CSS pixels.
*/ */
float GetOverscroll() const; CSSCoord GetOverscroll() const;
/** /**
* Sample the snap-back animation to relieve overscroll. * Sample the snap-back animation to relieve overscroll.
@ -129,7 +129,7 @@ public:
* Gets the distance between the starting position of the touch supplied in * Gets the distance between the starting position of the touch supplied in
* startTouch() and the supplied position. * startTouch() and the supplied position.
*/ */
float PanDistance(float aPos); float PanDistance(ScreenIntCoord aPos);
/** /**
* Applies friction during a fling, or cancels the fling if the velocity is * Applies friction during a fling, or cancels the fling if the velocity is
@ -177,13 +177,13 @@ public:
* That is to say, if the given displacement is applied, this will tell you * That is to say, if the given displacement is applied, this will tell you
* whether or not it will overscroll, and in what direction. * whether or not it will overscroll, and in what direction.
*/ */
Overscroll DisplacementWillOverscroll(float aDisplacement); Overscroll DisplacementWillOverscroll(CSSCoord aDisplacement);
/** /**
* If a displacement will overscroll the axis, this returns the amount and in * If a displacement will overscroll the axis, this returns the amount and in
* what direction. Similar to GetExcess() but takes a displacement to apply. * what direction. Similar to GetExcess() but takes a displacement to apply.
*/ */
float DisplacementWillOverscrollAmount(float aDisplacement); CSSCoord DisplacementWillOverscrollAmount(CSSCoord aDisplacement);
/** /**
* If a scale will overscroll the axis, this returns the amount and in what * If a scale will overscroll the axis, this returns the amount and in what
@ -193,7 +193,7 @@ public:
* scroll offset in such a way that it remains in the same place on the page * scroll offset in such a way that it remains in the same place on the page
* relative. * relative.
*/ */
float ScaleWillOverscrollAmount(float aScale, float aFocus); CSSCoord ScaleWillOverscrollAmount(float aScale, CSSCoord aFocus);
/** /**
* Checks if an axis will overscroll in both directions by computing the * Checks if an axis will overscroll in both directions by computing the
@ -204,23 +204,23 @@ public:
*/ */
bool ScaleWillOverscrollBothSides(float aScale); bool ScaleWillOverscrollBothSides(float aScale);
float GetOrigin() const; CSSCoord GetOrigin() const;
float GetCompositionLength() const; CSSCoord GetCompositionLength() const;
float GetPageStart() const; CSSCoord GetPageStart() const;
float GetPageLength() const; CSSCoord GetPageLength() const;
float GetCompositionEnd() const; CSSCoord GetCompositionEnd() const;
float GetPageEnd() const; CSSCoord GetPageEnd() const;
int32_t GetPos() const { return mPos; } ScreenIntCoord GetPos() const { return mPos; }
virtual float GetPointOffset(const CSSPoint& aPoint) const = 0; virtual CSSCoord GetPointOffset(const CSSPoint& aPoint) const = 0;
virtual float GetRectLength(const CSSRect& aRect) const = 0; virtual CSSCoord GetRectLength(const CSSRect& aRect) const = 0;
virtual float GetRectOffset(const CSSRect& aRect) const = 0; virtual CSSCoord GetRectOffset(const CSSRect& aRect) const = 0;
protected: protected:
int32_t mPos; ScreenIntCoord mPos;
uint32_t mPosTimeMs; uint32_t mPosTimeMs;
int32_t mStartPos; ScreenIntCoord mStartPos;
float mVelocity; float mVelocity;
bool mAxisLocked; // Whether movement on this axis is locked. bool mAxisLocked; // Whether movement on this axis is locked.
AsyncPanZoomController* mAsyncPanZoomController; AsyncPanZoomController* mAsyncPanZoomController;
@ -230,7 +230,7 @@ protected:
// extreme allowed value in the relevant direction (that is, it must be at // extreme allowed value in the relevant direction (that is, it must be at
// its maximum value if mOverscroll is positive, and at its minimum value // its maximum value if mOverscroll is positive, and at its minimum value
// if mOverscroll is negative). // if mOverscroll is negative).
float mOverscroll; CSSCoord mOverscroll;
// A queue of (timestamp, velocity) pairs; these are the historical // A queue of (timestamp, velocity) pairs; these are the historical
// velocities at the given timestamps. Timestamps are in milliseconds, // velocities at the given timestamps. Timestamps are in milliseconds,
// velocities are in screen pixels per ms. This member can only be // velocities are in screen pixels per ms. This member can only be
@ -241,23 +241,23 @@ protected:
// Adjust a requested overscroll amount for resistance, yielding a smaller // Adjust a requested overscroll amount for resistance, yielding a smaller
// actual overscroll amount. // actual overscroll amount.
float ApplyResistance(float aOverscroll) const; CSSCoord ApplyResistance(CSSCoord aOverscroll) const;
}; };
class AxisX : public Axis { class AxisX : public Axis {
public: public:
AxisX(AsyncPanZoomController* mAsyncPanZoomController); AxisX(AsyncPanZoomController* mAsyncPanZoomController);
virtual float GetPointOffset(const CSSPoint& aPoint) const; virtual CSSCoord GetPointOffset(const CSSPoint& aPoint) const;
virtual float GetRectLength(const CSSRect& aRect) const; virtual CSSCoord GetRectLength(const CSSRect& aRect) const;
virtual float GetRectOffset(const CSSRect& aRect) const; virtual CSSCoord GetRectOffset(const CSSRect& aRect) const;
}; };
class AxisY : public Axis { class AxisY : public Axis {
public: public:
AxisY(AsyncPanZoomController* mAsyncPanZoomController); AxisY(AsyncPanZoomController* mAsyncPanZoomController);
virtual float GetPointOffset(const CSSPoint& aPoint) const; virtual CSSCoord GetPointOffset(const CSSPoint& aPoint) const;
virtual float GetRectLength(const CSSRect& aRect) const; virtual CSSCoord GetRectLength(const CSSRect& aRect) const;
virtual float GetRectOffset(const CSSRect& aRect) const; virtual CSSCoord GetRectOffset(const CSSRect& aRect) const;
}; };
} }

Просмотреть файл

@ -222,8 +222,8 @@ static void DrawVelGraph(const nsIntRect& aClipRect,
for (int32_t i = (int32_t)velocityData->mData.size() - 2; i >= 0; i--) { for (int32_t i = (int32_t)velocityData->mData.size() - 2; i >= 0; i--) {
const gfx::Point& p1 = velocityData->mData[i+1].mPoint; const gfx::Point& p1 = velocityData->mData[i+1].mPoint;
const gfx::Point& p2 = velocityData->mData[i].mPoint; const gfx::Point& p2 = velocityData->mData[i].mPoint;
int vel = sqrt((p1.x - p2.x) * (p1.x - p2.x) + int vel = sqrt((p1.x - p2.x).value * (p1.x - p2.x).value +
(p1.y - p2.y) * (p1.y - p2.y)); (p1.y - p2.y).value * (p1.y - p2.y).value);
Point next = Point(graphRect.width / circularBufferSize * i, Point next = Point(graphRect.width / circularBufferSize * i,
graphRect.height - vel/yScaleFactor); graphRect.height - vel/yScaleFactor);
if (first) { if (first) {
@ -266,11 +266,9 @@ static void PrintUniformityInfo(Layer* aLayer)
} }
FrameMetrics frameMetrics = aLayer->AsContainerLayer()->GetFrameMetrics(); FrameMetrics frameMetrics = aLayer->AsContainerLayer()->GetFrameMetrics();
LayerIntPoint scrollOffset = RoundedToInt(frameMetrics.GetScrollOffsetInLayerPixels()); const LayerPoint scrollOffset = frameMetrics.GetScrollOffsetInLayerPixels();
const gfx::Point layerTransform = GetScrollData(aLayer); const gfx::Point layerTransform = GetScrollData(aLayer);
gfx::Point layerScroll; const gfx::Point layerScroll = scrollOffset.ToUnknownPoint() - layerTransform;
layerScroll.x = scrollOffset.x - layerTransform.x;
layerScroll.y = scrollOffset.y - layerTransform.y;
printf_stderr("UniformityInfo Layer_Move %llu %p %f, %f\n", printf_stderr("UniformityInfo Layer_Move %llu %p %f, %f\n",
TimeStamp::Now(), aLayer, layerScroll.x, layerScroll.y); TimeStamp::Now(), aLayer, layerScroll.x, layerScroll.y);

Просмотреть файл

@ -474,8 +474,8 @@ DecomposeIntoNoRepeatRects(const Rect& aRect,
// If we are dealing with wrapping br.x and br.y are greater than 1.0 so // If we are dealing with wrapping br.x and br.y are greater than 1.0 so
// wrap them here as well. // wrap them here as well.
br = Point(xwrap ? WrapTexCoord(br.x) : br.x, br = Point(xwrap ? WrapTexCoord(br.x) : br.x.value,
ywrap ? WrapTexCoord(br.y) : br.y); ywrap ? WrapTexCoord(br.y) : br.y.value);
// If we wrap around along the x axis, we will draw first from // If we wrap around along the x axis, we will draw first from
// tl.x .. 1.0 and then from 0.0 .. br.x (which we just wrapped above). // tl.x .. 1.0 and then from 0.0 .. br.x (which we just wrapped above).
@ -759,8 +759,7 @@ CompositorOGL::BeginFrame(const nsIntRegion& aInvalidRegion,
// UI for its dynamic toolbar. // UI for its dynamic toolbar.
IntPoint origin; IntPoint origin;
if (!mTarget) { if (!mTarget) {
origin.x = -mRenderOffset.x; origin = -TruncatedToInt(mRenderOffset.ToUnknownPoint());
origin.y = -mRenderOffset.y;
} }
mCurrentRenderTarget = mCurrentRenderTarget =

Просмотреть файл

@ -7,6 +7,7 @@
#ifndef MOZ_UNITS_H_ #ifndef MOZ_UNITS_H_
#define MOZ_UNITS_H_ #define MOZ_UNITS_H_
#include "mozilla/gfx/Coord.h"
#include "mozilla/gfx/Point.h" #include "mozilla/gfx/Point.h"
#include "mozilla/gfx/Rect.h" #include "mozilla/gfx/Rect.h"
#include "mozilla/gfx/ScaleFactor.h" #include "mozilla/gfx/ScaleFactor.h"
@ -30,6 +31,8 @@ template<> struct IsPixel<LayoutDevicePixel> : TrueType {};
template<> struct IsPixel<LayerPixel> : TrueType {}; template<> struct IsPixel<LayerPixel> : TrueType {};
template<> struct IsPixel<ScreenPixel> : TrueType {}; template<> struct IsPixel<ScreenPixel> : TrueType {};
typedef gfx::CoordTyped<CSSPixel> CSSCoord;
typedef gfx::IntCoordTyped<CSSPixel> CSSIntCoord;
typedef gfx::PointTyped<CSSPixel> CSSPoint; typedef gfx::PointTyped<CSSPixel> CSSPoint;
typedef gfx::IntPointTyped<CSSPixel> CSSIntPoint; typedef gfx::IntPointTyped<CSSPixel> CSSIntPoint;
typedef gfx::SizeTyped<CSSPixel> CSSSize; typedef gfx::SizeTyped<CSSPixel> CSSSize;
@ -39,6 +42,8 @@ typedef gfx::IntRectTyped<CSSPixel> CSSIntRect;
typedef gfx::MarginTyped<CSSPixel> CSSMargin; typedef gfx::MarginTyped<CSSPixel> CSSMargin;
typedef gfx::IntMarginTyped<CSSPixel> CSSIntMargin; typedef gfx::IntMarginTyped<CSSPixel> CSSIntMargin;
typedef gfx::CoordTyped<LayoutDevicePixel> LayoutDeviceCoord;
typedef gfx::IntCoordTyped<LayoutDevicePixel> LayoutDeviceIntCoord;
typedef gfx::PointTyped<LayoutDevicePixel> LayoutDevicePoint; typedef gfx::PointTyped<LayoutDevicePixel> LayoutDevicePoint;
typedef gfx::IntPointTyped<LayoutDevicePixel> LayoutDeviceIntPoint; typedef gfx::IntPointTyped<LayoutDevicePixel> LayoutDeviceIntPoint;
typedef gfx::SizeTyped<LayoutDevicePixel> LayoutDeviceSize; typedef gfx::SizeTyped<LayoutDevicePixel> LayoutDeviceSize;
@ -48,6 +53,8 @@ typedef gfx::IntRectTyped<LayoutDevicePixel> LayoutDeviceIntRect;
typedef gfx::MarginTyped<LayoutDevicePixel> LayoutDeviceMargin; typedef gfx::MarginTyped<LayoutDevicePixel> LayoutDeviceMargin;
typedef gfx::IntMarginTyped<LayoutDevicePixel> LayoutDeviceIntMargin; typedef gfx::IntMarginTyped<LayoutDevicePixel> LayoutDeviceIntMargin;
typedef gfx::CoordTyped<LayerPixel> LayerCoord;
typedef gfx::IntCoordTyped<LayerPixel> LayerIntCoord;
typedef gfx::PointTyped<LayerPixel> LayerPoint; typedef gfx::PointTyped<LayerPixel> LayerPoint;
typedef gfx::IntPointTyped<LayerPixel> LayerIntPoint; typedef gfx::IntPointTyped<LayerPixel> LayerIntPoint;
typedef gfx::SizeTyped<LayerPixel> LayerSize; typedef gfx::SizeTyped<LayerPixel> LayerSize;
@ -57,6 +64,8 @@ typedef gfx::IntRectTyped<LayerPixel> LayerIntRect;
typedef gfx::MarginTyped<LayerPixel> LayerMargin; typedef gfx::MarginTyped<LayerPixel> LayerMargin;
typedef gfx::IntMarginTyped<LayerPixel> LayerIntMargin; typedef gfx::IntMarginTyped<LayerPixel> LayerIntMargin;
typedef gfx::CoordTyped<ScreenPixel> ScreenCoord;
typedef gfx::IntCoordTyped<ScreenPixel> ScreenIntCoord;
typedef gfx::PointTyped<ScreenPixel> ScreenPoint; typedef gfx::PointTyped<ScreenPixel> ScreenPoint;
typedef gfx::IntPointTyped<ScreenPixel> ScreenIntPoint; typedef gfx::IntPointTyped<ScreenPixel> ScreenIntPoint;
typedef gfx::SizeTyped<ScreenPixel> ScreenSize; typedef gfx::SizeTyped<ScreenPixel> ScreenSize;

Просмотреть файл

@ -1805,8 +1805,8 @@ nsBaseWidget::debug_DumpEvent(FILE * aFileOut,
(void *) aWidget, (void *) aWidget,
aWidgetName.get(), aWidgetName.get(),
aWindowID, aWindowID,
aGuiEvent->refPoint.x, aGuiEvent->refPoint.x.value,
aGuiEvent->refPoint.y); aGuiEvent->refPoint.y.value);
} }
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////
/* static */ void /* static */ void