diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index f84551448041..9f842d1d6a10 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -82,6 +82,7 @@ #include "StructuredCloneUtils.h" #include "xpcpublic.h" #include "nsViewportInfo.h" +#include "gfx2DGlue.h" #define BROWSER_ELEMENT_CHILD_SCRIPT \ NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js") @@ -345,12 +346,12 @@ TabChild::Observe(nsISupports *aSubject, // Calculate a really simple resolution that we probably won't // be keeping, as well as putting the scroll offset back to // the top-left of the page. - mLastMetrics.mZoom = gfxSize(1.0, 1.0); + mLastMetrics.mZoom = gfx::ZoomScale(1.0, 1.0); mLastMetrics.mViewport = gfx::Rect(0, 0, kDefaultViewportSize.width, kDefaultViewportSize.height); - mLastMetrics.mCompositionBounds = nsIntRect(nsIntPoint(0, 0), - mInnerSize); + mLastMetrics.mCompositionBounds = gfx::IntRect(gfx::IntPoint(0, 0), + mInnerSize); mLastMetrics.mResolution = AsyncPanZoomController::CalculateResolution(mLastMetrics); mLastMetrics.mScrollOffset = gfx::Point(0, 0); @@ -590,7 +591,7 @@ TabChild::HandlePossibleViewportChange() FrameMetrics metrics(mLastMetrics); metrics.mViewport = gfx::Rect(0.0f, 0.0f, viewportW, viewportH); metrics.mScrollableRect = gfx::Rect(0.0f, 0.0f, pageWidth, pageHeight); - metrics.mCompositionBounds = nsIntRect(0, 0, mInnerSize.width, mInnerSize.height); + metrics.mCompositionBounds = gfx::IntRect(0, 0, mInnerSize.width, mInnerSize.height); // Changing the zoom when we're not doing a first paint will get ignored // by AsyncPanZoomController and causes a blurry flash. @@ -598,7 +599,7 @@ TabChild::HandlePossibleViewportChange() nsresult rv = utils->GetIsFirstPaint(&isFirstPaint); MOZ_ASSERT(NS_SUCCEEDED(rv)); if (NS_FAILED(rv) || isFirstPaint) { - gfxSize intrinsicScale = + gfx::ZoomScale intrinsicScale = AsyncPanZoomController::CalculateIntrinsicScale(metrics); // FIXME/bug 799585(?): GetViewportInfo() returns a defaultZoom of // 0.0 to mean "did not calculate a zoom". In that case, we default @@ -612,8 +613,8 @@ TabChild::HandlePossibleViewportChange() defaultZoom <= viewportInfo.GetMaxZoom()); // GetViewportInfo() returns a resolution-dependent scale factor. // Convert that to a resolution-indepedent zoom. - metrics.mZoom = gfxSize(defaultZoom / intrinsicScale.width, - defaultZoom / intrinsicScale.height); + metrics.mZoom = gfx::ZoomScale(defaultZoom / intrinsicScale.width, + defaultZoom / intrinsicScale.height); } metrics.mDisplayPort = AsyncPanZoomController::CalculatePendingDisplayPort( @@ -621,7 +622,7 @@ TabChild::HandlePossibleViewportChange() // new CSS viewport, so we know that there's no velocity, acceleration, and // we have no idea how long painting will take. metrics, gfx::Point(0.0f, 0.0f), gfx::Point(0.0f, 0.0f), 0.0); - gfxSize resolution = AsyncPanZoomController::CalculateResolution(metrics); + gfx::ZoomScale resolution = AsyncPanZoomController::CalculateResolution(metrics); // XXX is this actually hysteresis? This calculation is not well // understood. It's taken from the previous JS implementation. gfxFloat hysteresis/*?*/ = @@ -1371,7 +1372,9 @@ TabChild::RecvShow(const nsIntSize& size) } bool -TabChild::RecvUpdateDimensions(const nsRect& rect, const nsIntSize& size, const ScreenOrientation& orientation) +TabChild::RecvUpdateDimensions(const nsRect& rect, + const nsIntSize& size, + const ScreenOrientation& orientation) { if (!mRemoteFrame) { return true; @@ -1383,7 +1386,7 @@ TabChild::RecvUpdateDimensions(const nsRect& rect, const nsIntSize& size, const mOuterRect.height = rect.height; mOrientation = orientation; - mInnerSize = size; + mInnerSize = gfx::ToIntSize(size); mWidget->Resize(0, 0, size.width, size.height, true); @@ -1483,7 +1486,7 @@ TabChild::RecvUpdateFrame(const FrameMetrics& aFrameMetrics) utils->SetScrollPositionClampingScrollPortSize( cssCompositedRect.width, cssCompositedRect.height); ScrollWindowTo(window, aFrameMetrics.mScrollOffset); - gfxSize resolution = AsyncPanZoomController::CalculateResolution( + gfx::ZoomScale resolution = AsyncPanZoomController::CalculateResolution( aFrameMetrics); utils->SetResolution(resolution.width, resolution.height); diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index cb388f6c3a03..5a00bf50816b 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -201,7 +201,9 @@ public: const FileDescriptor& aFileDescriptor) MOZ_OVERRIDE; virtual bool RecvShow(const nsIntSize& size); - virtual bool RecvUpdateDimensions(const nsRect& rect, const nsIntSize& size, const ScreenOrientation& orientation); + virtual bool RecvUpdateDimensions(const nsRect& rect, + const nsIntSize& size, + const ScreenOrientation& orientation); virtual bool RecvUpdateFrame(const mozilla::layers::FrameMetrics& aFrameMetrics); virtual bool RecvHandleDoubleTap(const nsIntPoint& aPoint); virtual bool RecvHandleSingleTap(const nsIntPoint& aPoint); @@ -293,7 +295,7 @@ public: /** Return the DPI of the widget this TabChild draws to. */ void GetDPI(float* aDPI); - gfxSize GetZoom() { return mLastMetrics.mZoom; } + const gfx::ZoomScale& GetZoom() { return mLastMetrics.mZoom; } ScreenOrientation GetOrientation() { return mOrientation; } @@ -435,8 +437,8 @@ private: RenderFrameChild* mRemoteFrame; nsRefPtr mTabChildGlobal; uint32_t mChromeFlags; - nsIntRect mOuterRect; - nsIntSize mInnerSize; + gfx::IntRect mOuterRect; + gfx::IntSize mInnerSize; // When we're tracking a possible tap gesture, this is the "down" // point of the touchstart. nsIntPoint mGestureDownPoint; diff --git a/gfx/layers/FrameMetrics.h b/gfx/layers/FrameMetrics.h index 9fa44f5e00cf..cfc725678774 100644 --- a/gfx/layers/FrameMetrics.h +++ b/gfx/layers/FrameMetrics.h @@ -6,10 +6,12 @@ #ifndef GFX_FRAMEMETRICS_H #define GFX_FRAMEMETRICS_H -#include "gfxPoint.h" -#include "gfxTypes.h" -#include "nsRect.h" +#include "mozilla/gfx/ZoomScale.h" #include "mozilla/gfx/Rect.h" +#include "mozilla/gfx/Point.h" +#include "mozilla/gfx/Types.h" +#include "nsRect.h" +#include "gfxTypes.h" namespace mozilla { namespace layers { @@ -80,18 +82,14 @@ public: return mScrollId != NULL_SCROLL_ID; } - gfxSize LayersPixelsPerCSSPixel() const + gfx::ZoomScale LayersPixelsPerCSSPixel() const { return mResolution * mDevPixelsPerCSSPixel; } - gfxPoint GetScrollOffsetInLayerPixels() const + gfx::Point GetScrollOffsetInLayerPixels() const { - return gfxPoint( - static_cast( - mScrollOffset.x * LayersPixelsPerCSSPixel().width), - static_cast( - mScrollOffset.y * LayersPixelsPerCSSPixel().height)); + return mScrollOffset * LayersPixelsPerCSSPixel(); } // --------------------------------------------------------------------------- @@ -114,7 +112,7 @@ public: // // This is only valid on the root layer. Nested iframes do not need this // metric as they do not have a displayport set. See bug 775452. - nsIntRect mCompositionBounds; + gfx::IntRect mCompositionBounds; // |mScrollableRect|, stored in device pixels. DECPRECATED, DO NOT USE. // @@ -125,7 +123,7 @@ public: // // FIXME/bug 785929: Is this really necessary? Can it not be calculated from // |mScrollableRect| whenever it's needed? - nsIntRect mContentRect; + gfx::IntRect mContentRect; // --------------------------------------------------------------------------- // The following metrics are all in CSS pixels. They are not in any uniform @@ -216,7 +214,7 @@ public: // post-multiplied into the parent's transform. Since this only happens when // we walk the layer tree, the resulting transform isn't stored here. Thus the // resolution of parent layers is opaque to this metric. - gfxSize mResolution; + gfx::ZoomScale mResolution; // The resolution-independent "user zoom". For example, if a page // configures the viewport to a zoom value of 2x, then this member @@ -231,7 +229,7 @@ public: // // When this is not true, we're probably asynchronously sampling a // zoom animation for content. - gfxSize mZoom; + gfx::ZoomScale mZoom; // The conversion factor between CSS pixels and device pixels for this frame. // This can vary based on a variety of things, such as reflowing-zoom. The diff --git a/gfx/layers/basic/BasicTiledThebesLayer.cpp b/gfx/layers/basic/BasicTiledThebesLayer.cpp index f6b58fe55768..783a73929def 100644 --- a/gfx/layers/basic/BasicTiledThebesLayer.cpp +++ b/gfx/layers/basic/BasicTiledThebesLayer.cpp @@ -7,6 +7,7 @@ #include "gfxImageSurface.h" #include "sampler.h" #include "gfxPlatform.h" +#include "gfx2DGlue.h" #include // for std::abs(int/long) #include // for std::abs(float/double) @@ -261,7 +262,7 @@ BasicTiledThebesLayer::FillSpecificAttributes(SpecificLayerAttributes& aAttrs) static nsIntRect RoundedTransformViewportBounds(const gfx::Rect& aViewport, const gfx::Point& aScrollOffset, - const gfxSize& aResolution, + const gfx::ZoomScale& aResolution, float aScaleX, float aScaleY, const gfx3DMatrix& aTransform) @@ -287,7 +288,7 @@ BasicTiledThebesLayer::ComputeProgressiveUpdateRegion(BasicTiledLayerBuffer& aTi const gfx3DMatrix& aTransform, const nsIntRect& aCompositionBounds, const gfx::Point& aScrollOffset, - const gfxSize& aResolution, + const gfx::ZoomScale& aResolution, bool aIsRepeated) { aRegionToPaint = aInvalidRegion; @@ -416,7 +417,7 @@ BasicTiledThebesLayer::ProgressiveUpdate(BasicTiledLayerBuffer& aTiledBuffer, const gfx3DMatrix& aTransform, const nsIntRect& aCompositionBounds, const gfx::Point& aScrollOffset, - const gfxSize& aResolution, + const gfx::ZoomScale& aResolution, LayerManager::DrawThebesLayerCallback aCallback, void* aCallbackData) { @@ -486,12 +487,11 @@ BasicTiledThebesLayer::BeginPaint() // Compute the critical display port in layer space. mPaintData.mLayerCriticalDisplayPort.SetEmpty(); - const gfx::Rect& criticalDisplayPort = GetParent()->GetFrameMetrics().mCriticalDisplayPort; + const gfxRect criticalDisplayPort(gfx::ThebesRect( + GetParent()->GetFrameMetrics().mCriticalDisplayPort)); if (!criticalDisplayPort.IsEmpty()) { gfxRect transformedCriticalDisplayPort = - mPaintData.mTransformScreenToLayer.TransformBounds( - gfxRect(criticalDisplayPort.x, criticalDisplayPort.y, - criticalDisplayPort.width, criticalDisplayPort.height)); + mPaintData.mTransformScreenToLayer.TransformBounds(criticalDisplayPort); transformedCriticalDisplayPort.RoundOut(); mPaintData.mLayerCriticalDisplayPort = nsIntRect(transformedCriticalDisplayPort.x, transformedCriticalDisplayPort.y, @@ -500,7 +500,7 @@ BasicTiledThebesLayer::BeginPaint() } // Calculate the frame resolution. - mPaintData.mResolution.SizeTo(1, 1); + mPaintData.mResolution = gfx::ZoomScale(); for (ContainerLayer* parent = GetParent(); parent; parent = parent->GetParent()) { const FrameMetrics& metrics = parent->GetFrameMetrics(); mPaintData.mResolution.width *= metrics.mResolution.width; diff --git a/gfx/layers/basic/BasicTiledThebesLayer.h b/gfx/layers/basic/BasicTiledThebesLayer.h index 6aa7cc010486..b5ba57dc0b35 100644 --- a/gfx/layers/basic/BasicTiledThebesLayer.h +++ b/gfx/layers/basic/BasicTiledThebesLayer.h @@ -73,7 +73,7 @@ struct BasicTiledLayerPaintData { gfx::Point mScrollOffset; gfx3DMatrix mTransformScreenToLayer; nsIntRect mLayerCriticalDisplayPort; - gfxSize mResolution; + gfx::ZoomScale mResolution; nsIntRect mCompositionBounds; uint16_t mLowPrecisionPaintCount; bool mPaintFinished : 1; @@ -121,8 +121,8 @@ public: } } - const gfxSize& GetFrameResolution() { return mFrameResolution; } - void SetFrameResolution(const gfxSize& aResolution) { mFrameResolution = aResolution; } + const gfx::ZoomScale& GetFrameResolution() { return mFrameResolution; } + void SetFrameResolution(const gfx::ZoomScale& aResolution) { mFrameResolution = aResolution; } bool HasFormatChanged(BasicTiledThebesLayer* aThebesLayer) const; protected: @@ -147,7 +147,7 @@ private: BasicTiledThebesLayer* mThebesLayer; LayerManager::DrawThebesLayerCallback mCallback; void* mCallbackData; - gfxSize mFrameResolution; + gfx::ZoomScale mFrameResolution; bool mLastPaintOpaque; // The buffer we use when UseSinglePaintBuffer() above is true. @@ -247,7 +247,7 @@ private: const gfx3DMatrix& aTransform, const nsIntRect& aCompositionBounds, const gfx::Point& aScrollOffset, - const gfxSize& aResolution, + const gfx::ZoomScale& aResolution, bool aIsRepeated); /** @@ -261,7 +261,7 @@ private: const gfx3DMatrix& aTransform, const nsIntRect& aCompositionBounds, const gfx::Point& aScrollOffset, - const gfxSize& aResolution, + const gfx::ZoomScale& aResolution, LayerManager::DrawThebesLayerCallback aCallback, void* aCallbackData); diff --git a/gfx/layers/ipc/AsyncPanZoomController.cpp b/gfx/layers/ipc/AsyncPanZoomController.cpp index 133935084522..38f667651eec 100644 --- a/gfx/layers/ipc/AsyncPanZoomController.cpp +++ b/gfx/layers/ipc/AsyncPanZoomController.cpp @@ -18,6 +18,7 @@ #include "nsThreadUtils.h" #include "Layers.h" #include "AnimationCommon.h" +#include "gfx2DGlue.h" #include using namespace mozilla::css; @@ -192,6 +193,10 @@ AsyncPanZoomController::~AsyncPanZoomController() { } +inline void AsyncPanZoomController::ScrollBy(const gfx::Point& aOffset) { + mFrameMetrics.mScrollOffset += aOffset; +} + void AsyncPanZoomController::Destroy() { @@ -207,12 +212,12 @@ AsyncPanZoomController::GetTouchStartTolerance() } static gfx::Point -WidgetSpaceToCompensatedViewportSpace(const gfx::Point& aPoint, +WidgetSpaceToCompensatedViewportSpace(const nsIntPoint& aPoint, gfxFloat aCurrentZoom) { // Transform the input point from local widget space to the content document // space that the user is seeing, from last composite. - gfx::Point pt(aPoint); + gfx::Point pt(gfx::ToIntPoint(aPoint)); pt = pt / aCurrentZoom; // FIXME/bug 775451: this doesn't attempt to compensate for content transforms @@ -233,10 +238,8 @@ AsyncPanZoomController::ReceiveInputEvent(const nsInputEvent& aEvent, { MonitorAutoLock monitor(mMonitor); currentResolution = CalculateResolution(mFrameMetrics).width; - currentScrollOffset = gfx::Point(mFrameMetrics.mScrollOffset.x, - mFrameMetrics.mScrollOffset.y); - lastScrollOffset = gfx::Point(mLastContentPaintMetrics.mScrollOffset.x, - mLastContentPaintMetrics.mScrollOffset.y); + currentScrollOffset = mFrameMetrics.mScrollOffset; + lastScrollOffset = mLastContentPaintMetrics.mScrollOffset; } nsEventStatus status; @@ -264,8 +267,7 @@ AsyncPanZoomController::ReceiveInputEvent(const nsInputEvent& aEvent, nsIDOMTouch* touch = touches[i]; if (touch) { gfx::Point refPoint = WidgetSpaceToCompensatedViewportSpace( - gfx::Point(touch->mRefPoint.x, touch->mRefPoint.y), - currentResolution); + touch->mRefPoint, currentResolution); touch->mRefPoint = nsIntPoint(refPoint.x, refPoint.y); } } @@ -273,8 +275,7 @@ AsyncPanZoomController::ReceiveInputEvent(const nsInputEvent& aEvent, } default: { gfx::Point refPoint = WidgetSpaceToCompensatedViewportSpace( - gfx::Point(aOutEvent->refPoint.x, aOutEvent->refPoint.y), - currentResolution); + aOutEvent->refPoint, currentResolution); aOutEvent->refPoint = nsIntPoint(refPoint.x, refPoint.y); break; } @@ -534,7 +535,7 @@ nsEventStatus AsyncPanZoomController::OnScaleBegin(const PinchGestureInput& aEve } SetState(PINCHING); - mLastZoomFocus = aEvent.mFocusPoint; + mLastZoomFocus = gfx::ToIntPoint(aEvent.mFocusPoint); return nsEventStatus_eConsumeNoDefault; } @@ -556,28 +557,23 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) { MonitorAutoLock monitor(mMonitor); gfxFloat resolution = CalculateResolution(mFrameMetrics).width; - gfxFloat userZoom = mFrameMetrics.mZoom.width; - nsIntPoint focusPoint = aEvent.mFocusPoint; - gfxFloat xFocusChange = (mLastZoomFocus.x - focusPoint.x) / resolution; - gfxFloat yFocusChange = (mLastZoomFocus.y - focusPoint.y) / resolution; + gfx::IntPoint focusPoint(gfx::ToIntPoint(aEvent.mFocusPoint)); + gfx::Point focusChange(gfx::Point(mLastZoomFocus - focusPoint) / resolution); // If displacing by the change in focus point will take us off page bounds, // then reduce the displacement such that it doesn't. - if (mX.DisplacementWillOverscroll(xFocusChange) != Axis::OVERSCROLL_NONE) { - xFocusChange -= mX.DisplacementWillOverscrollAmount(xFocusChange); + if (mX.DisplacementWillOverscroll(focusChange.x) != Axis::OVERSCROLL_NONE) { + focusChange.x -= mX.DisplacementWillOverscrollAmount(focusChange.x); } - if (mY.DisplacementWillOverscroll(yFocusChange) != Axis::OVERSCROLL_NONE) { - yFocusChange -= mY.DisplacementWillOverscrollAmount(yFocusChange); + if (mY.DisplacementWillOverscroll(focusChange.y) != Axis::OVERSCROLL_NONE) { + focusChange.y -= mY.DisplacementWillOverscrollAmount(focusChange.y); } - ScrollBy(gfx::Point(xFocusChange, yFocusChange)); + ScrollBy(focusChange); // When we zoom in with focus, we can zoom too much towards the boundaries // that we actually go over them. These are the needed displacements along // either axis such that we don't overscroll the boundaries when zooming. - gfxFloat neededDisplacementX = 0, neededDisplacementY = 0; - - // Only do the scaling if we won't go over 8x zoom in or out. - bool doScale = (spanRatio > 1.0 && userZoom < mMaxZoom) || - (spanRatio < 1.0 && userZoom > mMinZoom); + gfx::Point neededDisplacement; + gfxFloat userZoom = mFrameMetrics.mZoom.width; // If this zoom will take it over 8x zoom in either direction, but it's not // already there, then normalize it. @@ -587,6 +583,10 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) { spanRatio = userZoom / mMinZoom; } + // Only do the scaling if we won't go over 8x zoom in or out. + bool doScale = (spanRatio > 1.0 && userZoom < mMaxZoom) || + (spanRatio < 1.0 && userZoom > mMinZoom); + if (doScale) { switch (mX.ScaleWillOverscroll(spanRatio, focusPoint.x)) { @@ -594,7 +594,7 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) { break; case Axis::OVERSCROLL_MINUS: case Axis::OVERSCROLL_PLUS: - neededDisplacementX = -mX.ScaleWillOverscrollAmount(spanRatio, focusPoint.x); + neededDisplacement.x = -mX.ScaleWillOverscrollAmount(spanRatio, focusPoint.x); break; case Axis::OVERSCROLL_BOTH: // If scaling this way will make us overscroll in both directions, then @@ -613,7 +613,7 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) { break; case Axis::OVERSCROLL_MINUS: case Axis::OVERSCROLL_PLUS: - neededDisplacementY = -mY.ScaleWillOverscrollAmount(spanRatio, focusPoint.y); + neededDisplacement.y = -mY.ScaleWillOverscrollAmount(spanRatio, focusPoint.y); break; case Axis::OVERSCROLL_BOTH: doScale = false; @@ -624,9 +624,7 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) { if (doScale) { ScaleWithFocus(userZoom * spanRatio, focusPoint); - if (neededDisplacementX != 0 || neededDisplacementY != 0) { - ScrollBy(gfx::Point(neededDisplacementX, neededDisplacementY)); - } + ScrollBy(neededDisplacement); ScheduleComposite(); // We don't want to redraw on every scale, so don't use @@ -658,8 +656,7 @@ nsEventStatus AsyncPanZoomController::OnLongPress(const TapGestureInput& aEvent) gfxFloat resolution = CalculateResolution(mFrameMetrics).width; gfx::Point point = WidgetSpaceToCompensatedViewportSpace( - gfx::Point(aEvent.mPoint.x, aEvent.mPoint.y), - resolution); + aEvent.mPoint, resolution); mGeckoContentController->HandleLongTap(nsIntPoint(NS_lround(point.x), NS_lround(point.y))); return nsEventStatus_eConsumeNoDefault; @@ -677,8 +674,7 @@ nsEventStatus AsyncPanZoomController::OnSingleTapConfirmed(const TapGestureInput gfxFloat resolution = CalculateResolution(mFrameMetrics).width; gfx::Point point = WidgetSpaceToCompensatedViewportSpace( - gfx::Point(aEvent.mPoint.x, aEvent.mPoint.y), - resolution); + aEvent.mPoint, resolution); mGeckoContentController->HandleSingleTap(nsIntPoint(NS_lround(point.x), NS_lround(point.y))); return nsEventStatus_eConsumeNoDefault; @@ -693,8 +689,7 @@ nsEventStatus AsyncPanZoomController::OnDoubleTap(const TapGestureInput& aEvent) if (mAllowZoom) { gfxFloat resolution = CalculateResolution(mFrameMetrics).width; gfx::Point point = WidgetSpaceToCompensatedViewportSpace( - gfx::Point(aEvent.mPoint.x, aEvent.mPoint.y), - resolution); + aEvent.mPoint, resolution); mGeckoContentController->HandleDoubleTap(nsIntPoint(NS_lround(point.x), NS_lround(point.y))); } @@ -764,15 +759,15 @@ void AsyncPanZoomController::TrackTouch(const MultiTouchInput& aEvent) { // larger swipe should move you a shorter distance. gfxFloat inverseResolution = 1 / CalculateResolution(mFrameMetrics).width; - float xDisplacement = mX.GetDisplacementForDuration(inverseResolution, - timeDelta); - float yDisplacement = mY.GetDisplacementForDuration(inverseResolution, - timeDelta); - if (fabs(xDisplacement) <= EPSILON && fabs(yDisplacement) <= EPSILON) { + gfx::Point displacement( + mX.GetDisplacementForDuration(inverseResolution, timeDelta), + mY.GetDisplacementForDuration(inverseResolution, timeDelta)); + + if (fabs(displacement.x) <= EPSILON && fabs(displacement.y) <= EPSILON) { return; } - ScrollBy(gfx::Point(xDisplacement, yDisplacement)); + ScrollBy(displacement); ScheduleComposite(); TimeDuration timePaintDelta = TimeStamp::Now() - mPreviousPaintStartTime; @@ -828,14 +823,6 @@ void AsyncPanZoomController::SetCompositorParent(CompositorParent* aCompositorPa mCompositorParent = aCompositorParent; } -void AsyncPanZoomController::ScrollBy(const gfx::Point& aOffset) { - gfx::Point newOffset(mFrameMetrics.mScrollOffset.x + aOffset.x, - mFrameMetrics.mScrollOffset.y + aOffset.y); - FrameMetrics metrics(mFrameMetrics); - metrics.mScrollOffset = newOffset; - mFrameMetrics = metrics; -} - void AsyncPanZoomController::SetPageRect(const gfx::Rect& aCSSPageRect) { FrameMetrics metrics = mFrameMetrics; gfx::Rect pageSize = aCSSPageRect; @@ -846,15 +833,15 @@ void AsyncPanZoomController::SetPageRect(const gfx::Rect& aCSSPageRect) { // Round the page rect so we don't get any truncation, then get the nsIntRect // from this. - metrics.mContentRect = nsIntRect(pageSize.x, pageSize.y, - pageSize.width, pageSize.height); + metrics.mContentRect = gfx::IntRect(pageSize.x, pageSize.y, + pageSize.width, pageSize.height); metrics.mScrollableRect = aCSSPageRect; mFrameMetrics = metrics; } void AsyncPanZoomController::ScaleWithFocus(float aZoom, - const nsIntPoint& aFocus) { + const gfx::IntPoint& aFocus) { float zoomFactor = aZoom / mFrameMetrics.mZoom.width; gfxFloat resolution = CalculateResolution(mFrameMetrics).width; @@ -923,7 +910,7 @@ const gfx::Rect AsyncPanZoomController::CalculatePendingDisplayPort( aEstimatedPaintDuration > EPSILON ? aEstimatedPaintDuration : 1.0; gfxFloat resolution = CalculateResolution(aFrameMetrics).width; - nsIntRect compositionBounds = aFrameMetrics.mCompositionBounds; + gfx::IntRect compositionBounds = aFrameMetrics.mCompositionBounds; compositionBounds.ScaleInverseRoundIn(resolution); gfx::Rect scrollableRect = aFrameMetrics.mScrollableRect; @@ -997,31 +984,25 @@ const gfx::Rect AsyncPanZoomController::CalculatePendingDisplayPort( return displayPort; } -/*static*/ gfxSize +/*static*/ gfx::ZoomScale AsyncPanZoomController::CalculateIntrinsicScale(const FrameMetrics& aMetrics) { - gfxFloat intrinsicScale = (gfxFloat(aMetrics.mCompositionBounds.width) / - gfxFloat(aMetrics.mViewport.width)); - return gfxSize(intrinsicScale, intrinsicScale); + gfx::Float intrinsicScale = gfx::Float(aMetrics.mCompositionBounds.width) / + gfx::Float(aMetrics.mViewport.width); + return gfx::ZoomScale(intrinsicScale, intrinsicScale); } -/*static*/ gfxSize +/*static*/ gfx::ZoomScale AsyncPanZoomController::CalculateResolution(const FrameMetrics& aMetrics) { - gfxSize intrinsicScale = CalculateIntrinsicScale(aMetrics); - gfxSize userZoom = aMetrics.mZoom; - return gfxSize(intrinsicScale.width * userZoom.width, - intrinsicScale.height * userZoom.height); + return CalculateIntrinsicScale(aMetrics) * aMetrics.mZoom; } /*static*/ gfx::Rect AsyncPanZoomController::CalculateCompositedRectInCssPixels(const FrameMetrics& aMetrics) { - gfxSize resolution = CalculateResolution(aMetrics); - gfx::Rect rect(aMetrics.mCompositionBounds.x, - aMetrics.mCompositionBounds.y, - aMetrics.mCompositionBounds.width, - aMetrics.mCompositionBounds.height); + gfx::ZoomScale resolution = CalculateResolution(aMetrics); + gfx::Rect rect(aMetrics.mCompositionBounds); rect.ScaleInverseRoundIn(resolution.width, resolution.height); return rect; } @@ -1103,7 +1084,7 @@ void AsyncPanZoomController::RequestContentRepaint() { mWaitingForContentToPaint = true; // Set the zoom back to what it was for the purpose of logic control. - mFrameMetrics.mZoom = gfxSize(actualZoom, actualZoom); + mFrameMetrics.mZoom = gfx::ZoomScale(actualZoom, actualZoom); } void @@ -1129,12 +1110,12 @@ bool AsyncPanZoomController::SampleContentTransformForFrame(const TimeStamp& aSa const gfx3DMatrix& currentTransform = aLayer->GetTransform(); // Scales on the root layer, on what's currently painted. - gfxSize rootScale(currentTransform.GetXScale(), - currentTransform.GetYScale()); + gfx::ZoomScale rootScale(currentTransform.GetXScale(), + currentTransform.GetYScale()); - gfxPoint metricsScrollOffset(0, 0); - gfxPoint scrollOffset; - gfxSize localScale; + gfx::Point metricsScrollOffset(0, 0); + gfx::Point scrollOffset; + gfx::ZoomScale localScale; const FrameMetrics& frame = aLayer->GetFrameMetrics(); { MonitorAutoLock mon(mMonitor); @@ -1158,7 +1139,7 @@ bool AsyncPanZoomController::SampleContentTransformForFrame(const TimeStamp& aSa gfxFloat endZoom = mEndZoomToMetrics.mZoom.width; gfxFloat sampledZoom = (endZoom * sampledPosition + startZoom * (1 - sampledPosition)); - mFrameMetrics.mZoom = gfxSize(sampledZoom, sampledZoom); + mFrameMetrics.mZoom = gfx::ZoomScale(sampledZoom, sampledZoom); mFrameMetrics.mScrollOffset = gfx::Point( mEndZoomToMetrics.mScrollOffset.x * sampledPosition + @@ -1193,7 +1174,7 @@ bool AsyncPanZoomController::SampleContentTransformForFrame(const TimeStamp& aSa metricsScrollOffset = frame.GetScrollOffsetInLayerPixels(); } - scrollOffset = gfxPoint(mFrameMetrics.mScrollOffset.x, mFrameMetrics.mScrollOffset.y); + scrollOffset = mFrameMetrics.mScrollOffset; mCurrentAsyncScrollOffset = mFrameMetrics.mScrollOffset; } @@ -1224,7 +1205,7 @@ bool AsyncPanZoomController::SampleContentTransformForFrame(const TimeStamp& aSa mAsyncScrollTimeout); } - gfxPoint scrollCompensation( + gfx::Point scrollCompensation( (scrollOffset / rootScale - metricsScrollOffset) * localScale); *aNewTransform = ViewTransform(-scrollCompensation, localScale); @@ -1274,9 +1255,9 @@ void AsyncPanZoomController::NotifyLayersUpdated(const FrameMetrics& aViewportFr aViewportFrame.mCompositionBounds.height == mFrameMetrics.mCompositionBounds.height) { // Remote content has sync'd up to the composition geometry // change, so we can accept the viewport it's calculated. - gfxSize previousResolution = CalculateResolution(mFrameMetrics); + gfx::ZoomScale previousResolution = CalculateResolution(mFrameMetrics); mFrameMetrics.mViewport = aViewportFrame.mViewport; - gfxSize newResolution = CalculateResolution(mFrameMetrics); + gfx::ZoomScale newResolution = CalculateResolution(mFrameMetrics); needContentRepaint |= (previousResolution != newResolution); } @@ -1306,18 +1287,17 @@ const FrameMetrics& AsyncPanZoomController::GetFrameMetrics() { return mFrameMetrics; } -void AsyncPanZoomController::UpdateCompositionBounds(const nsIntRect& aCompositionBounds) { +void AsyncPanZoomController::UpdateCompositionBounds(const gfx::IntRect& aCompositionBounds) { MonitorAutoLock mon(mMonitor); - nsIntRect oldCompositionBounds = mFrameMetrics.mCompositionBounds; + bool wasEmpty = mFrameMetrics.mCompositionBounds.IsEmpty(); mFrameMetrics.mCompositionBounds = aCompositionBounds; // If the window had 0 dimensions before, or does now, we don't want to // repaint or update the zoom since we'll run into rendering issues and/or // divide-by-zero. This manifests itself as the screen flashing. If the page // has gone out of view, the buffer will be cleared elsewhere anyways. - if (aCompositionBounds.width && aCompositionBounds.height && - oldCompositionBounds.width && oldCompositionBounds.height) { + if (!aCompositionBounds.IsEmpty() && !wasEmpty) { SetZoomAndResolution(mFrameMetrics.mZoom.width); // Repaint on a rotation so that our new resolution gets properly updated. @@ -1337,23 +1317,23 @@ void AsyncPanZoomController::DetectScrollableSubframe() { } void AsyncPanZoomController::ZoomToRect(const gfxRect& aRect) { - gfx::Rect zoomToRect(gfx::Rect(aRect.x, aRect.y, aRect.width, aRect.height)); + gfx::Rect zoomToRect(gfx::ToRect(aRect)); SetState(ANIMATING_ZOOM); { MonitorAutoLock mon(mMonitor); - nsIntRect compositionBounds = mFrameMetrics.mCompositionBounds; + gfx::IntRect compositionBounds = mFrameMetrics.mCompositionBounds; gfx::Rect cssPageRect = mFrameMetrics.mScrollableRect; gfx::Point scrollOffset = mFrameMetrics.mScrollOffset; - gfxSize resolution = CalculateResolution(mFrameMetrics); + gfx::ZoomScale resolution = CalculateResolution(mFrameMetrics); // If the rect is empty, treat it as a request to zoom out to the full page // size. if (zoomToRect.IsEmpty()) { // composition bounds in CSS coordinates - nsIntRect cssCompositionBounds = compositionBounds; + gfx::IntRect cssCompositionBounds = compositionBounds; cssCompositionBounds.ScaleInverseRoundIn(resolution.width, resolution.height); cssCompositionBounds.MoveBy(scrollOffset.x, scrollOffset.y); @@ -1371,7 +1351,7 @@ void AsyncPanZoomController::ZoomToRect(const gfxRect& aRect) { gfxFloat targetResolution = std::min(compositionBounds.width / zoomToRect.width, - compositionBounds.height / zoomToRect.height); + compositionBounds.height / zoomToRect.height); // Recalculate the zoom to rect using the new dimensions. zoomToRect.width = compositionBounds.width / targetResolution; @@ -1382,13 +1362,13 @@ void AsyncPanZoomController::ZoomToRect(const gfxRect& aRect) { // Do one final recalculation to get the resolution. targetResolution = std::max(compositionBounds.width / zoomToRect.width, - compositionBounds.height / zoomToRect.height); + compositionBounds.height / zoomToRect.height); float targetZoom = float(targetResolution / resolution.width) * mFrameMetrics.mZoom.width; // If current zoom is equal to mMaxZoom, // user still double-tapping it, just zoom-out to the full page size if (mFrameMetrics.mZoom.width == mMaxZoom && targetZoom >= mMaxZoom) { - nsIntRect cssCompositionBounds = compositionBounds; + gfx::IntRect cssCompositionBounds = compositionBounds; cssCompositionBounds.ScaleInverseRoundIn(resolution.width, resolution.height); cssCompositionBounds.MoveBy(scrollOffset.x, scrollOffset.y); @@ -1409,7 +1389,7 @@ void AsyncPanZoomController::ZoomToRect(const gfxRect& aRect) { } gfxFloat targetFinalZoom = clamped(targetZoom, mMinZoom, mMaxZoom); - mEndZoomToMetrics.mZoom = gfxSize(targetFinalZoom, targetFinalZoom); + mEndZoomToMetrics.mZoom = gfx::ZoomScale(targetFinalZoom, targetFinalZoom); mStartZoomToMetrics = mFrameMetrics; mEndZoomToMetrics.mScrollOffset = @@ -1477,7 +1457,7 @@ void AsyncPanZoomController::TimeoutTouchListeners() { void AsyncPanZoomController::SetZoomAndResolution(float aZoom) { mMonitor.AssertCurrentThreadOwns(); - mFrameMetrics.mZoom = gfxSize(aZoom, aZoom); + mFrameMetrics.mZoom = gfx::ZoomScale(aZoom, aZoom); mFrameMetrics.mResolution = CalculateResolution(mFrameMetrics); } @@ -1505,8 +1485,7 @@ void AsyncPanZoomController::SendAsyncScrollEvent() { gfx::Rect contentRect; gfx::Size scrollableSize; { - scrollableSize = gfx::Size(mFrameMetrics.mScrollableRect.width, - mFrameMetrics.mScrollableRect.height); + scrollableSize = mFrameMetrics.mScrollableRect.Size(); contentRect = AsyncPanZoomController::CalculateCompositedRectInCssPixels(mFrameMetrics); contentRect.MoveTo(mCurrentAsyncScrollOffset); diff --git a/gfx/layers/ipc/AsyncPanZoomController.h b/gfx/layers/ipc/AsyncPanZoomController.h index 1bc59be283f1..793c9eb3290a 100644 --- a/gfx/layers/ipc/AsyncPanZoomController.h +++ b/gfx/layers/ipc/AsyncPanZoomController.h @@ -111,7 +111,7 @@ public: * { x = 0, y = 0, width = surface.width, height = surface.height }, however * there is no hard requirement for this. */ - void UpdateCompositionBounds(const nsIntRect& aCompositionBounds); + void UpdateCompositionBounds(const gfx::IntRect& aCompositionBounds); /** * We are scrolling a subframe, so disable our machinery until we hit @@ -232,7 +232,7 @@ public: * Return the scale factor needed to fit the viewport in |aMetrics| * into its composition bounds. */ - static gfxSize CalculateIntrinsicScale(const FrameMetrics& aMetrics); + static gfx::ZoomScale CalculateIntrinsicScale(const FrameMetrics& aMetrics); /** * Return the resolution that content should be rendered at given @@ -240,7 +240,7 @@ public: * factor, etc. (The mResolution member of aFrameMetrics is * ignored.) */ - static gfxSize CalculateResolution(const FrameMetrics& aMetrics); + static gfx::ZoomScale CalculateResolution(const FrameMetrics& aMetrics); static gfx::Rect CalculateCompositedRectInCssPixels(const FrameMetrics& aMetrics); @@ -347,7 +347,7 @@ protected: * * XXX: Fix focus point calculations. */ - void ScaleWithFocus(float aScale, const nsIntPoint& aFocus); + void ScaleWithFocus(float aScale, const gfx::IntPoint& aFocus); /** * Schedules a composite on the compositor thread. Wrapper for @@ -551,7 +551,7 @@ private: // Stores the previous focus point if there is a pinch gesture happening. Used // to allow panning by moving multiple fingers (thus moving the focus point). - nsIntPoint mLastZoomFocus; + gfx::IntPoint mLastZoomFocus; // Stores the state of panning and zooming this frame. This is protected by // |mMonitor|; that is, it should be held whenever this is updated. diff --git a/gfx/layers/ipc/Axis.cpp b/gfx/layers/ipc/Axis.cpp index f6013aa85793..e3db67155160 100644 --- a/gfx/layers/ipc/Axis.cpp +++ b/gfx/layers/ipc/Axis.cpp @@ -324,10 +324,7 @@ bool Axis::ScaleWillOverscrollBothSides(float aScale) { gfx::Rect cssContentRect = metrics.mScrollableRect; float currentScale = metrics.mZoom.width; - nsIntRect compositionBounds = metrics.mCompositionBounds; - gfx::Rect scaledCompositionBounds = - gfx::Rect(compositionBounds.x, compositionBounds.y, - compositionBounds.width, compositionBounds.height); + gfx::Rect scaledCompositionBounds(metrics.mCompositionBounds); scaledCompositionBounds.ScaleInverseRoundIn(currentScale * aScale); return GetRectLength(cssContentRect) < GetRectLength(scaledCompositionBounds); diff --git a/gfx/layers/ipc/CompositorParent.cpp b/gfx/layers/ipc/CompositorParent.cpp index 48405f89d43e..081cde00954d 100644 --- a/gfx/layers/ipc/CompositorParent.cpp +++ b/gfx/layers/ipc/CompositorParent.cpp @@ -38,6 +38,7 @@ #include "gfxPlatform.h" #include "mozilla/dom/ScreenOrientation.h" #include "mozilla/AutoRestore.h" +#include "gfx2DGlue.h" using namespace base; using namespace mozilla; @@ -474,7 +475,7 @@ CompositorParent::ScheduleComposition() } void -CompositorParent::SetTransformation(float aScale, nsIntPoint aScrollOffset) +CompositorParent::SetTransformation(float aScale, gfx::IntPoint aScrollOffset) { mXScale = aScale; mYScale = aScale; @@ -871,8 +872,8 @@ CompositorParent::ApplyAsyncContentTransformToTree(TimeStamp aCurrentFrame, TransformFixedLayers( aLayer, - -treeTransform.mTranslation / treeTransform.mScale, - treeTransform.mScale); + gfx::ThebesPoint(-treeTransform.mTranslation / treeTransform.mScale), + gfxSize(treeTransform.mScale.width, treeTransform.mScale.height)); appliedTransform = true; } @@ -906,8 +907,8 @@ CompositorParent::TransformScrollableLayer(Layer* aLayer, const gfx3DMatrix& aRo // as a FrameMetrics helper because it's a deprecated conversion. float devPixelRatioX = 1 / rootScaleX, devPixelRatioY = 1 / rootScaleY; - gfxPoint scrollOffsetLayersPixels(metrics.GetScrollOffsetInLayerPixels()); - nsIntPoint scrollOffsetDevPixels( + gfx::Point scrollOffsetLayersPixels(metrics.GetScrollOffsetInLayerPixels()); + gfx::IntPoint scrollOffsetDevPixels( NS_lround(scrollOffsetLayersPixels.x * devPixelRatioX), NS_lround(scrollOffsetLayersPixels.y * devPixelRatioY)); @@ -928,7 +929,7 @@ CompositorParent::TransformScrollableLayer(Layer* aLayer, const gfx3DMatrix& aRo // Calculate the absolute display port to send to Java gfx::Rect displayPortLayersPixels(metrics.mCriticalDisplayPort.IsEmpty() ? metrics.mDisplayPort : metrics.mCriticalDisplayPort); - nsIntRect displayPortDevPixels( + gfx::IntRect displayPortDevPixels( NS_lround(displayPortLayersPixels.x * devPixelRatioX), NS_lround(displayPortLayersPixels.y * devPixelRatioY), NS_lround(displayPortLayersPixels.width * devPixelRatioX), @@ -950,16 +951,16 @@ CompositorParent::TransformScrollableLayer(Layer* aLayer, const gfx3DMatrix& aRo float tempScaleDiffX = rootScaleX * mXScale; float tempScaleDiffY = rootScaleY * mYScale; - nsIntPoint metricsScrollOffset(0, 0); + gfx::IntPoint metricsScrollOffset(0, 0); if (metrics.IsScrollable()) { metricsScrollOffset = scrollOffsetDevPixels; } - nsIntPoint scrollCompensation( + gfx::IntPoint scrollCompensation( (mScrollOffset.x / tempScaleDiffX - metricsScrollOffset.x) * mXScale, (mScrollOffset.y / tempScaleDiffY - metricsScrollOffset.y) * mYScale); - treeTransform = gfx3DMatrix(ViewTransform(-scrollCompensation, - gfxSize(mXScale, mYScale))); + treeTransform = gfx3DMatrix(ViewTransform(gfx::Point(-scrollCompensation), + gfx::ZoomScale(mXScale, mYScale))); // If the contents can fit entirely within the widget area on a particular // dimenson, we need to translate and scale so that the fixed layers remain @@ -1040,8 +1041,10 @@ CompositorParent::TransformShadowTree(TimeStamp aCurrentFrame) } void -CompositorParent::SetFirstPaintViewport(const nsIntPoint& aOffset, float aZoom, - const nsIntRect& aPageRect, const gfx::Rect& aCssPageRect) +CompositorParent::SetFirstPaintViewport(const gfx::IntPoint& aOffset, + float aZoom, + const gfx::IntRect& aPageRect, + const gfx::Rect& aCssPageRect) { #ifdef MOZ_WIDGET_ANDROID AndroidBridge::Bridge()->SetFirstPaintViewport(aOffset, aZoom, aPageRect, aCssPageRect); @@ -1057,9 +1060,11 @@ CompositorParent::SetPageRect(const gfx::Rect& aCssPageRect) } void -CompositorParent::SyncViewportInfo(const nsIntRect& aDisplayPort, - float aDisplayResolution, bool aLayersUpdated, - nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY) +CompositorParent::SyncViewportInfo(const gfx::IntRect& aDisplayPort, + float aDisplayResolution, + bool aLayersUpdated, + gfx::IntPoint& aScrollOffset, + float& aScaleX, float& aScaleY) { #ifdef MOZ_WIDGET_ANDROID AndroidBridge::Bridge()->SyncViewportInfo(aDisplayPort, aDisplayResolution, aLayersUpdated, diff --git a/gfx/layers/ipc/CompositorParent.h b/gfx/layers/ipc/CompositorParent.h index d77f8eab65fe..7be9763b3b95 100644 --- a/gfx/layers/ipc/CompositorParent.h +++ b/gfx/layers/ipc/CompositorParent.h @@ -36,8 +36,8 @@ class LayerManager; // Represents (affine) transforms that are calculated from a content view. struct ViewTransform { - ViewTransform(gfxPoint aTranslation = gfxPoint(), - gfxSize aScale = gfxSize(1, 1)) + ViewTransform(gfx::Point aTranslation = gfx::Point(), + gfx::ZoomScale aScale = gfx::ZoomScale()) : mTranslation(aTranslation) , mScale(aScale) {} @@ -49,8 +49,8 @@ struct ViewTransform { gfx3DMatrix::Translation(mTranslation.x, mTranslation.y, 0); } - gfxPoint mTranslation; - gfxSize mScale; + gfx::Point mTranslation; + gfx::ZoomScale mScale; }; class CompositorParent : public PCompositorParent, @@ -87,7 +87,7 @@ public: LayerManager* GetLayerManager() { return mLayerManager; } - void SetTransformation(float aScale, nsIntPoint aScrollOffset); + void SetTransformation(float aScale, gfx::IntPoint aScrollOffset); void AsyncRender(); // Can be called from any thread @@ -178,10 +178,15 @@ protected: virtual void ScheduleTask(CancelableTask*, int); virtual void Composite(); virtual void ComposeToTarget(gfxContext* aTarget); - virtual void SetFirstPaintViewport(const nsIntPoint& aOffset, float aZoom, const nsIntRect& aPageRect, const gfx::Rect& aCssPageRect); + virtual void SetFirstPaintViewport(const gfx::IntPoint& aOffset, + float aZoom, + const gfx::IntRect& aPageRect, + const gfx::Rect& aCssPageRect); virtual void SetPageRect(const gfx::Rect& aCssPageRect); - virtual void SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated, - nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY); + virtual void SyncViewportInfo(const gfx::IntRect& aDisplayPort, + float aDisplayResolution, bool aLayersUpdated, + gfx::IntPoint& aScrollOffset, + float& aScaleX, float& aScaleY); void SetEGLSurfaceSize(int width, int height); // If SetPanZoomControllerForLayerTree is not set, Compositor will use // derived class AsyncPanZoomController transformations. @@ -282,8 +287,8 @@ private: bool mPaused; float mXScale; float mYScale; - nsIntPoint mScrollOffset; - nsIntRect mContentRect; + gfx::IntPoint mScrollOffset; + gfx::IntRect mContentRect; // When this flag is set, the next composition will be the first for a // particular document (i.e. the document displayed on the screen will change). diff --git a/gfx/layers/opengl/ReusableTileStoreOGL.cpp b/gfx/layers/opengl/ReusableTileStoreOGL.cpp index 6c52f74c060f..32ead10745e8 100644 --- a/gfx/layers/opengl/ReusableTileStoreOGL.cpp +++ b/gfx/layers/opengl/ReusableTileStoreOGL.cpp @@ -5,6 +5,7 @@ #include "ReusableTileStoreOGL.h" #include "GLContext.h" +#include "gfx2DGlue.h" namespace mozilla { namespace layers { @@ -291,7 +292,7 @@ ReusableTileStoreOGL::DrawTiles(TiledThebesLayerOGL* aLayer, scrollableLayer = parent; if (!parentMetrics.mDisplayPort.IsEmpty() && scrollableLayer) { // Get the composition bounds, so as not to waste rendering time. - compositionBounds = gfxRect(parentMetrics.mCompositionBounds); + compositionBounds = gfx::ThebesRect(parentMetrics.mCompositionBounds); // Calculate the scale transform applied to the root layer to determine // the content resolution. @@ -302,12 +303,12 @@ ReusableTileStoreOGL::DrawTiles(TiledThebesLayerOGL* aLayer, // Get the content document bounds, in screen-space. const FrameMetrics& metrics = scrollableLayer->GetFrameMetrics(); - const nsIntSize& contentSize = metrics.mContentRect.Size(); + const gfx::IntSize& contentSize = metrics.mContentRect.Size(); gfx::Point scrollOffset = gfx::Point((metrics.mScrollOffset.x * metrics.LayersPixelsPerCSSPixel().width) / scaleX, (metrics.mScrollOffset.y * metrics.LayersPixelsPerCSSPixel().height) / scaleY); - const nsIntPoint& contentOrigin = metrics.mContentRect.TopLeft() - - nsIntPoint(NS_lround(scrollOffset.x), NS_lround(scrollOffset.y)); + const gfx::IntPoint& contentOrigin = metrics.mContentRect.TopLeft() - + gfx::IntPoint(NS_lround(scrollOffset.x), NS_lround(scrollOffset.y)); gfxRect contentRect = gfxRect(contentOrigin.x, contentOrigin.y, contentSize.width, contentSize.height); gfxRect contentBounds = scrollableLayer->GetEffectiveTransform(). diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index b0ec58772484..c5a187087378 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -50,6 +50,7 @@ #include "ImageLayers.h" #include "ImageContainer.h" #include "nsCanvasFrame.h" +#include "gfx2DGlue.h" #include "mozilla/StandardInteger.h" #include @@ -650,8 +651,8 @@ static void RecordFrameMetrics(nsIFrame* aForFrame, nsPresContext::AppUnitsToFloatCSSPixels(contentBounds.y), nsPresContext::AppUnitsToFloatCSSPixels(contentBounds.width), nsPresContext::AppUnitsToFloatCSSPixels(contentBounds.height)); - metrics.mContentRect = contentBounds.ScaleToNearestPixels( - aContainerParameters.mXScale, aContainerParameters.mYScale, auPerDevPixel); + metrics.mContentRect = mozilla::gfx::ToIntRect(contentBounds.ScaleToNearestPixels( + aContainerParameters.mXScale, aContainerParameters.mYScale, auPerDevPixel)); nsPoint scrollPosition = scrollableFrame->GetScrollPosition(); metrics.mScrollOffset = mozilla::gfx::Point( NSAppUnitsToDoublePixels(scrollPosition.x, auPerCSSPixel), @@ -664,8 +665,8 @@ static void RecordFrameMetrics(nsIFrame* aForFrame, nsPresContext::AppUnitsToFloatCSSPixels(contentBounds.y), nsPresContext::AppUnitsToFloatCSSPixels(contentBounds.width), nsPresContext::AppUnitsToFloatCSSPixels(contentBounds.height)); - metrics.mContentRect = contentBounds.ScaleToNearestPixels( - aContainerParameters.mXScale, aContainerParameters.mYScale, auPerDevPixel); + metrics.mContentRect = mozilla::gfx::ToIntRect(contentBounds.ScaleToNearestPixels( + aContainerParameters.mXScale, aContainerParameters.mYScale, auPerDevPixel)); } metrics.mScrollId = aScrollId; @@ -674,14 +675,16 @@ static void RecordFrameMetrics(nsIFrame* aForFrame, if (TabChild *tc = GetTabChildFrom(presShell)) { metrics.mZoom = tc->GetZoom(); } - metrics.mResolution = gfxSize(presShell->GetXResolution(), presShell->GetYResolution()); + metrics.mResolution = mozilla::gfx::ZoomScale(presShell->GetXResolution(), presShell->GetYResolution()); metrics.mDevPixelsPerCSSPixel = auPerCSSPixel / auPerDevPixel; metrics.mMayHaveTouchListeners = aMayHaveTouchListeners; if (nsIWidget* widget = aForFrame->GetNearestWidget()) { - widget->GetBounds(metrics.mCompositionBounds); + nsIntRect bounds; + widget->GetBounds(bounds); + metrics.mCompositionBounds = mozilla::gfx::ToIntRect(bounds); } aRoot->SetFrameMetrics(metrics); diff --git a/layout/ipc/RenderFrameParent.cpp b/layout/ipc/RenderFrameParent.cpp index 4f394c48ea65..82a97343cf85 100644 --- a/layout/ipc/RenderFrameParent.cpp +++ b/layout/ipc/RenderFrameParent.cpp @@ -166,7 +166,7 @@ ComputeShadowTreeTransform(nsIFrame* aContainerFrame, nsIntPoint scrollOffset = aConfig.mScrollOffset.ToNearestPixels(auPerDevPixel); // metricsScrollOffset is in layer coordinates. - gfxPoint metricsScrollOffset = aMetrics->GetScrollOffsetInLayerPixels(); + gfx::Point metricsScrollOffset = aMetrics->GetScrollOffsetInLayerPixels(); nsIntPoint roundedMetricsScrollOffset = nsIntPoint(NS_lround(metricsScrollOffset.x), NS_lround(metricsScrollOffset.y)); @@ -794,7 +794,7 @@ RenderFrameParent::NotifyDimensionsChanged(int width, int height) { if (mPanZoomController) { mPanZoomController->UpdateCompositionBounds( - nsIntRect(0, 0, width, height)); + gfx::IntRect(0, 0, width, height)); } } diff --git a/widget/android/AndroidBridge.cpp b/widget/android/AndroidBridge.cpp index b5a8a64bb3e3..25b1ddaacfaa 100644 --- a/widget/android/AndroidBridge.cpp +++ b/widget/android/AndroidBridge.cpp @@ -2089,7 +2089,10 @@ AndroidBridge::IsTablet() } void -AndroidBridge::SetFirstPaintViewport(const nsIntPoint& aOffset, float aZoom, const nsIntRect& aPageRect, const gfx::Rect& aCssPageRect) +AndroidBridge::SetFirstPaintViewport(const gfx::IntPoint& aOffset, + float aZoom, + const gfx::IntRect& aPageRect, + const gfx::Rect& aCssPageRect) { AndroidGeckoLayerClient *client = mLayerClient; if (!client) @@ -2109,8 +2112,10 @@ AndroidBridge::SetPageRect(const gfx::Rect& aCssPageRect) } void -AndroidBridge::SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated, - nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY) +AndroidBridge::SyncViewportInfo(const gfx::IntRect& aDisplayPort, + float aDisplayResolution, bool aLayersUpdated, + gfx::IntPoint& aScrollOffset, + float& aScaleX, float& aScaleY) { AndroidGeckoLayerClient *client = mLayerClient; if (!client) diff --git a/widget/android/AndroidBridge.h b/widget/android/AndroidBridge.h index 5043111b4d44..c8ab77f1d69d 100644 --- a/widget/android/AndroidBridge.h +++ b/widget/android/AndroidBridge.h @@ -329,10 +329,15 @@ public: void EnableNetworkNotifications(); void DisableNetworkNotifications(); - void SetFirstPaintViewport(const nsIntPoint& aOffset, float aZoom, const nsIntRect& aPageRect, const gfx::Rect& aCssPageRect); + void SetFirstPaintViewport(const gfx::IntPoint& aOffset, + float aZoom, + const gfx::IntRect& aPageRect, + const gfx::Rect& aCssPageRect); void SetPageRect(const gfx::Rect& aCssPageRect); - void SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated, - nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY); + void SyncViewportInfo(const gfx::IntRect& aDisplayPort, + float aDisplayResolution, bool aLayersUpdated, + gfx::IntPoint& aScrollOffset, + float& aScaleX, float& aScaleY); void AddPluginView(jobject view, const gfxRect& rect, bool isFullScreen); void RemovePluginView(jobject view, bool isFullScreen); diff --git a/widget/android/AndroidJavaWrappers.cpp b/widget/android/AndroidJavaWrappers.cpp index 889424c7db96..44b2f22a8826 100644 --- a/widget/android/AndroidJavaWrappers.cpp +++ b/widget/android/AndroidJavaWrappers.cpp @@ -711,7 +711,10 @@ AndroidProgressiveUpdateData::Init(jobject jobj) } void -AndroidGeckoLayerClient::SetFirstPaintViewport(const nsIntPoint& aOffset, float aZoom, const nsIntRect& aPageRect, const gfx::Rect& aCssPageRect) +AndroidGeckoLayerClient::SetFirstPaintViewport(const gfx::IntPoint& aOffset, + float aZoom, + const gfx::IntRect& aPageRect, + const gfx::Rect& aCssPageRect) { NS_ASSERTION(!isNull(), "SetFirstPaintViewport called on null layer client!"); JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread @@ -738,8 +741,11 @@ AndroidGeckoLayerClient::SetPageRect(const gfx::Rect& aCssPageRect) } void -AndroidGeckoLayerClient::SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated, - nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY) +AndroidGeckoLayerClient::SyncViewportInfo(const gfx::IntRect& aDisplayPort, + float aDisplayResolution, + bool aLayersUpdated, + gfx::IntPoint& aScrollOffset, + float& aScaleX, float& aScaleY) { NS_ASSERTION(!isNull(), "SyncViewportInfo called on null layer client!"); JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread @@ -760,7 +766,7 @@ AndroidGeckoLayerClient::SyncViewportInfo(const nsIntRect& aDisplayPort, float a AndroidViewTransform viewTransform; viewTransform.Init(viewTransformJObj); - aScrollOffset = nsIntPoint(viewTransform.GetX(env), viewTransform.GetY(env)); + aScrollOffset = gfx::IntPoint(viewTransform.GetX(env), viewTransform.GetY(env)); aScaleX = aScaleY = viewTransform.GetScale(env); } diff --git a/widget/android/AndroidJavaWrappers.h b/widget/android/AndroidJavaWrappers.h index fa8d2a1f945e..f5744b1c0a82 100644 --- a/widget/android/AndroidJavaWrappers.h +++ b/widget/android/AndroidJavaWrappers.h @@ -254,10 +254,15 @@ public: AndroidGeckoLayerClient() {} AndroidGeckoLayerClient(jobject jobj) { Init(jobj); } - void SetFirstPaintViewport(const nsIntPoint& aOffset, float aZoom, const nsIntRect& aPageRect, const gfx::Rect& aCssPageRect); + void SetFirstPaintViewport(const gfx::IntPoint& aOffset, + float aZoom, + const gfx::IntRect& aPageRect, + const gfx::Rect& aCssPageRect); void SetPageRect(const gfx::Rect& aCssPageRect); - void SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated, - nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY); + void SyncViewportInfo(const gfx::IntRect& aDisplayPort, + float aDisplayResolution, bool aLayersUpdated, + gfx::IntPoint& aScrollOffset, + float& aScaleX, float& aScaleY); bool ProgressiveUpdateCallback(bool aHasPendingNewThebesContent, const gfx::Rect& aDisplayPort, float aDisplayResolution, bool aDrawingCritical, gfx::Rect& aViewport, float& aScaleX, float& aScaleY); bool CreateFrame(AutoLocalJNIFrame *jniFrame, AndroidLayerRendererFrame& aFrame); bool ActivateProgram(AutoLocalJNIFrame *jniFrame);