Bug 840693 - Change to using gfx:: types in AsyncPanZoomController; r=cjones

This commit is contained in:
Anthony Jones 2013-03-04 13:25:26 +13:00
parent a867d6ab73
commit fffa15107b
17 changed files with 210 additions and 196 deletions

View File

@ -82,6 +82,7 @@
#include "StructuredCloneUtils.h" #include "StructuredCloneUtils.h"
#include "xpcpublic.h" #include "xpcpublic.h"
#include "nsViewportInfo.h" #include "nsViewportInfo.h"
#include "gfx2DGlue.h"
#define BROWSER_ELEMENT_CHILD_SCRIPT \ #define BROWSER_ELEMENT_CHILD_SCRIPT \
NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js") 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 // Calculate a really simple resolution that we probably won't
// be keeping, as well as putting the scroll offset back to // be keeping, as well as putting the scroll offset back to
// the top-left of the page. // the top-left of the page.
mLastMetrics.mZoom = gfxSize(1.0, 1.0); mLastMetrics.mZoom = gfx::ZoomScale(1.0, 1.0);
mLastMetrics.mViewport = mLastMetrics.mViewport =
gfx::Rect(0, 0, gfx::Rect(0, 0,
kDefaultViewportSize.width, kDefaultViewportSize.height); kDefaultViewportSize.width, kDefaultViewportSize.height);
mLastMetrics.mCompositionBounds = nsIntRect(nsIntPoint(0, 0), mLastMetrics.mCompositionBounds = gfx::IntRect(gfx::IntPoint(0, 0),
mInnerSize); mInnerSize);
mLastMetrics.mResolution = mLastMetrics.mResolution =
AsyncPanZoomController::CalculateResolution(mLastMetrics); AsyncPanZoomController::CalculateResolution(mLastMetrics);
mLastMetrics.mScrollOffset = gfx::Point(0, 0); mLastMetrics.mScrollOffset = gfx::Point(0, 0);
@ -590,7 +591,7 @@ TabChild::HandlePossibleViewportChange()
FrameMetrics metrics(mLastMetrics); FrameMetrics metrics(mLastMetrics);
metrics.mViewport = gfx::Rect(0.0f, 0.0f, viewportW, viewportH); metrics.mViewport = gfx::Rect(0.0f, 0.0f, viewportW, viewportH);
metrics.mScrollableRect = gfx::Rect(0.0f, 0.0f, pageWidth, pageHeight); 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 // Changing the zoom when we're not doing a first paint will get ignored
// by AsyncPanZoomController and causes a blurry flash. // by AsyncPanZoomController and causes a blurry flash.
@ -598,7 +599,7 @@ TabChild::HandlePossibleViewportChange()
nsresult rv = utils->GetIsFirstPaint(&isFirstPaint); nsresult rv = utils->GetIsFirstPaint(&isFirstPaint);
MOZ_ASSERT(NS_SUCCEEDED(rv)); MOZ_ASSERT(NS_SUCCEEDED(rv));
if (NS_FAILED(rv) || isFirstPaint) { if (NS_FAILED(rv) || isFirstPaint) {
gfxSize intrinsicScale = gfx::ZoomScale intrinsicScale =
AsyncPanZoomController::CalculateIntrinsicScale(metrics); AsyncPanZoomController::CalculateIntrinsicScale(metrics);
// FIXME/bug 799585(?): GetViewportInfo() returns a defaultZoom of // FIXME/bug 799585(?): GetViewportInfo() returns a defaultZoom of
// 0.0 to mean "did not calculate a zoom". In that case, we default // 0.0 to mean "did not calculate a zoom". In that case, we default
@ -612,8 +613,8 @@ TabChild::HandlePossibleViewportChange()
defaultZoom <= viewportInfo.GetMaxZoom()); defaultZoom <= viewportInfo.GetMaxZoom());
// GetViewportInfo() returns a resolution-dependent scale factor. // GetViewportInfo() returns a resolution-dependent scale factor.
// Convert that to a resolution-indepedent zoom. // Convert that to a resolution-indepedent zoom.
metrics.mZoom = gfxSize(defaultZoom / intrinsicScale.width, metrics.mZoom = gfx::ZoomScale(defaultZoom / intrinsicScale.width,
defaultZoom / intrinsicScale.height); defaultZoom / intrinsicScale.height);
} }
metrics.mDisplayPort = AsyncPanZoomController::CalculatePendingDisplayPort( metrics.mDisplayPort = AsyncPanZoomController::CalculatePendingDisplayPort(
@ -621,7 +622,7 @@ TabChild::HandlePossibleViewportChange()
// new CSS viewport, so we know that there's no velocity, acceleration, and // new CSS viewport, so we know that there's no velocity, acceleration, and
// we have no idea how long painting will take. // we have no idea how long painting will take.
metrics, gfx::Point(0.0f, 0.0f), gfx::Point(0.0f, 0.0f), 0.0); 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 // XXX is this actually hysteresis? This calculation is not well
// understood. It's taken from the previous JS implementation. // understood. It's taken from the previous JS implementation.
gfxFloat hysteresis/*?*/ = gfxFloat hysteresis/*?*/ =
@ -1371,7 +1372,9 @@ TabChild::RecvShow(const nsIntSize& size)
} }
bool 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) { if (!mRemoteFrame) {
return true; return true;
@ -1383,7 +1386,7 @@ TabChild::RecvUpdateDimensions(const nsRect& rect, const nsIntSize& size, const
mOuterRect.height = rect.height; mOuterRect.height = rect.height;
mOrientation = orientation; mOrientation = orientation;
mInnerSize = size; mInnerSize = gfx::ToIntSize(size);
mWidget->Resize(0, 0, size.width, size.height, mWidget->Resize(0, 0, size.width, size.height,
true); true);
@ -1483,7 +1486,7 @@ TabChild::RecvUpdateFrame(const FrameMetrics& aFrameMetrics)
utils->SetScrollPositionClampingScrollPortSize( utils->SetScrollPositionClampingScrollPortSize(
cssCompositedRect.width, cssCompositedRect.height); cssCompositedRect.width, cssCompositedRect.height);
ScrollWindowTo(window, aFrameMetrics.mScrollOffset); ScrollWindowTo(window, aFrameMetrics.mScrollOffset);
gfxSize resolution = AsyncPanZoomController::CalculateResolution( gfx::ZoomScale resolution = AsyncPanZoomController::CalculateResolution(
aFrameMetrics); aFrameMetrics);
utils->SetResolution(resolution.width, resolution.height); utils->SetResolution(resolution.width, resolution.height);

View File

@ -201,7 +201,9 @@ public:
const FileDescriptor& aFileDescriptor) const FileDescriptor& aFileDescriptor)
MOZ_OVERRIDE; MOZ_OVERRIDE;
virtual bool RecvShow(const nsIntSize& size); 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 RecvUpdateFrame(const mozilla::layers::FrameMetrics& aFrameMetrics);
virtual bool RecvHandleDoubleTap(const nsIntPoint& aPoint); virtual bool RecvHandleDoubleTap(const nsIntPoint& aPoint);
virtual bool RecvHandleSingleTap(const nsIntPoint& aPoint); virtual bool RecvHandleSingleTap(const nsIntPoint& aPoint);
@ -293,7 +295,7 @@ public:
/** Return the DPI of the widget this TabChild draws to. */ /** Return the DPI of the widget this TabChild draws to. */
void GetDPI(float* aDPI); void GetDPI(float* aDPI);
gfxSize GetZoom() { return mLastMetrics.mZoom; } const gfx::ZoomScale& GetZoom() { return mLastMetrics.mZoom; }
ScreenOrientation GetOrientation() { return mOrientation; } ScreenOrientation GetOrientation() { return mOrientation; }
@ -435,8 +437,8 @@ private:
RenderFrameChild* mRemoteFrame; RenderFrameChild* mRemoteFrame;
nsRefPtr<TabChildGlobal> mTabChildGlobal; nsRefPtr<TabChildGlobal> mTabChildGlobal;
uint32_t mChromeFlags; uint32_t mChromeFlags;
nsIntRect mOuterRect; gfx::IntRect mOuterRect;
nsIntSize mInnerSize; gfx::IntSize mInnerSize;
// When we're tracking a possible tap gesture, this is the "down" // When we're tracking a possible tap gesture, this is the "down"
// point of the touchstart. // point of the touchstart.
nsIntPoint mGestureDownPoint; nsIntPoint mGestureDownPoint;

View File

@ -6,10 +6,12 @@
#ifndef GFX_FRAMEMETRICS_H #ifndef GFX_FRAMEMETRICS_H
#define GFX_FRAMEMETRICS_H #define GFX_FRAMEMETRICS_H
#include "gfxPoint.h" #include "mozilla/gfx/ZoomScale.h"
#include "gfxTypes.h"
#include "nsRect.h"
#include "mozilla/gfx/Rect.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 mozilla {
namespace layers { namespace layers {
@ -80,18 +82,14 @@ public:
return mScrollId != NULL_SCROLL_ID; return mScrollId != NULL_SCROLL_ID;
} }
gfxSize LayersPixelsPerCSSPixel() const gfx::ZoomScale LayersPixelsPerCSSPixel() const
{ {
return mResolution * mDevPixelsPerCSSPixel; return mResolution * mDevPixelsPerCSSPixel;
} }
gfxPoint GetScrollOffsetInLayerPixels() const gfx::Point GetScrollOffsetInLayerPixels() const
{ {
return gfxPoint( return mScrollOffset * LayersPixelsPerCSSPixel();
static_cast<gfx::Float>(
mScrollOffset.x * LayersPixelsPerCSSPixel().width),
static_cast<gfx::Float>(
mScrollOffset.y * LayersPixelsPerCSSPixel().height));
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@ -114,7 +112,7 @@ public:
// //
// This is only valid on the root layer. Nested iframes do not need this // 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. // 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. // |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 // FIXME/bug 785929: Is this really necessary? Can it not be calculated from
// |mScrollableRect| whenever it's needed? // |mScrollableRect| whenever it's needed?
nsIntRect mContentRect; gfx::IntRect mContentRect;
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// The following metrics are all in CSS pixels. They are not in any uniform // 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 // 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 // we walk the layer tree, the resulting transform isn't stored here. Thus the
// resolution of parent layers is opaque to this metric. // resolution of parent layers is opaque to this metric.
gfxSize mResolution; gfx::ZoomScale mResolution;
// The resolution-independent "user zoom". For example, if a page // The resolution-independent "user zoom". For example, if a page
// configures the viewport to a zoom value of 2x, then this member // 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 // When this is not true, we're probably asynchronously sampling a
// zoom animation for content. // zoom animation for content.
gfxSize mZoom; gfx::ZoomScale mZoom;
// The conversion factor between CSS pixels and device pixels for this frame. // 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 // This can vary based on a variety of things, such as reflowing-zoom. The

View File

@ -7,6 +7,7 @@
#include "gfxImageSurface.h" #include "gfxImageSurface.h"
#include "sampler.h" #include "sampler.h"
#include "gfxPlatform.h" #include "gfxPlatform.h"
#include "gfx2DGlue.h"
#include <cstdlib> // for std::abs(int/long) #include <cstdlib> // for std::abs(int/long)
#include <cmath> // for std::abs(float/double) #include <cmath> // for std::abs(float/double)
@ -261,7 +262,7 @@ BasicTiledThebesLayer::FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
static nsIntRect static nsIntRect
RoundedTransformViewportBounds(const gfx::Rect& aViewport, RoundedTransformViewportBounds(const gfx::Rect& aViewport,
const gfx::Point& aScrollOffset, const gfx::Point& aScrollOffset,
const gfxSize& aResolution, const gfx::ZoomScale& aResolution,
float aScaleX, float aScaleX,
float aScaleY, float aScaleY,
const gfx3DMatrix& aTransform) const gfx3DMatrix& aTransform)
@ -287,7 +288,7 @@ BasicTiledThebesLayer::ComputeProgressiveUpdateRegion(BasicTiledLayerBuffer& aTi
const gfx3DMatrix& aTransform, const gfx3DMatrix& aTransform,
const nsIntRect& aCompositionBounds, const nsIntRect& aCompositionBounds,
const gfx::Point& aScrollOffset, const gfx::Point& aScrollOffset,
const gfxSize& aResolution, const gfx::ZoomScale& aResolution,
bool aIsRepeated) bool aIsRepeated)
{ {
aRegionToPaint = aInvalidRegion; aRegionToPaint = aInvalidRegion;
@ -416,7 +417,7 @@ BasicTiledThebesLayer::ProgressiveUpdate(BasicTiledLayerBuffer& aTiledBuffer,
const gfx3DMatrix& aTransform, const gfx3DMatrix& aTransform,
const nsIntRect& aCompositionBounds, const nsIntRect& aCompositionBounds,
const gfx::Point& aScrollOffset, const gfx::Point& aScrollOffset,
const gfxSize& aResolution, const gfx::ZoomScale& aResolution,
LayerManager::DrawThebesLayerCallback aCallback, LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData) void* aCallbackData)
{ {
@ -486,12 +487,11 @@ BasicTiledThebesLayer::BeginPaint()
// Compute the critical display port in layer space. // Compute the critical display port in layer space.
mPaintData.mLayerCriticalDisplayPort.SetEmpty(); mPaintData.mLayerCriticalDisplayPort.SetEmpty();
const gfx::Rect& criticalDisplayPort = GetParent()->GetFrameMetrics().mCriticalDisplayPort; const gfxRect criticalDisplayPort(gfx::ThebesRect(
GetParent()->GetFrameMetrics().mCriticalDisplayPort));
if (!criticalDisplayPort.IsEmpty()) { if (!criticalDisplayPort.IsEmpty()) {
gfxRect transformedCriticalDisplayPort = gfxRect transformedCriticalDisplayPort =
mPaintData.mTransformScreenToLayer.TransformBounds( mPaintData.mTransformScreenToLayer.TransformBounds(criticalDisplayPort);
gfxRect(criticalDisplayPort.x, criticalDisplayPort.y,
criticalDisplayPort.width, criticalDisplayPort.height));
transformedCriticalDisplayPort.RoundOut(); transformedCriticalDisplayPort.RoundOut();
mPaintData.mLayerCriticalDisplayPort = nsIntRect(transformedCriticalDisplayPort.x, mPaintData.mLayerCriticalDisplayPort = nsIntRect(transformedCriticalDisplayPort.x,
transformedCriticalDisplayPort.y, transformedCriticalDisplayPort.y,
@ -500,7 +500,7 @@ BasicTiledThebesLayer::BeginPaint()
} }
// Calculate the frame resolution. // Calculate the frame resolution.
mPaintData.mResolution.SizeTo(1, 1); mPaintData.mResolution = gfx::ZoomScale();
for (ContainerLayer* parent = GetParent(); parent; parent = parent->GetParent()) { for (ContainerLayer* parent = GetParent(); parent; parent = parent->GetParent()) {
const FrameMetrics& metrics = parent->GetFrameMetrics(); const FrameMetrics& metrics = parent->GetFrameMetrics();
mPaintData.mResolution.width *= metrics.mResolution.width; mPaintData.mResolution.width *= metrics.mResolution.width;

View File

@ -73,7 +73,7 @@ struct BasicTiledLayerPaintData {
gfx::Point mScrollOffset; gfx::Point mScrollOffset;
gfx3DMatrix mTransformScreenToLayer; gfx3DMatrix mTransformScreenToLayer;
nsIntRect mLayerCriticalDisplayPort; nsIntRect mLayerCriticalDisplayPort;
gfxSize mResolution; gfx::ZoomScale mResolution;
nsIntRect mCompositionBounds; nsIntRect mCompositionBounds;
uint16_t mLowPrecisionPaintCount; uint16_t mLowPrecisionPaintCount;
bool mPaintFinished : 1; bool mPaintFinished : 1;
@ -121,8 +121,8 @@ public:
} }
} }
const gfxSize& GetFrameResolution() { return mFrameResolution; } const gfx::ZoomScale& GetFrameResolution() { return mFrameResolution; }
void SetFrameResolution(const gfxSize& aResolution) { mFrameResolution = aResolution; } void SetFrameResolution(const gfx::ZoomScale& aResolution) { mFrameResolution = aResolution; }
bool HasFormatChanged(BasicTiledThebesLayer* aThebesLayer) const; bool HasFormatChanged(BasicTiledThebesLayer* aThebesLayer) const;
protected: protected:
@ -147,7 +147,7 @@ private:
BasicTiledThebesLayer* mThebesLayer; BasicTiledThebesLayer* mThebesLayer;
LayerManager::DrawThebesLayerCallback mCallback; LayerManager::DrawThebesLayerCallback mCallback;
void* mCallbackData; void* mCallbackData;
gfxSize mFrameResolution; gfx::ZoomScale mFrameResolution;
bool mLastPaintOpaque; bool mLastPaintOpaque;
// The buffer we use when UseSinglePaintBuffer() above is true. // The buffer we use when UseSinglePaintBuffer() above is true.
@ -247,7 +247,7 @@ private:
const gfx3DMatrix& aTransform, const gfx3DMatrix& aTransform,
const nsIntRect& aCompositionBounds, const nsIntRect& aCompositionBounds,
const gfx::Point& aScrollOffset, const gfx::Point& aScrollOffset,
const gfxSize& aResolution, const gfx::ZoomScale& aResolution,
bool aIsRepeated); bool aIsRepeated);
/** /**
@ -261,7 +261,7 @@ private:
const gfx3DMatrix& aTransform, const gfx3DMatrix& aTransform,
const nsIntRect& aCompositionBounds, const nsIntRect& aCompositionBounds,
const gfx::Point& aScrollOffset, const gfx::Point& aScrollOffset,
const gfxSize& aResolution, const gfx::ZoomScale& aResolution,
LayerManager::DrawThebesLayerCallback aCallback, LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData); void* aCallbackData);

View File

@ -18,6 +18,7 @@
#include "nsThreadUtils.h" #include "nsThreadUtils.h"
#include "Layers.h" #include "Layers.h"
#include "AnimationCommon.h" #include "AnimationCommon.h"
#include "gfx2DGlue.h"
#include <algorithm> #include <algorithm>
using namespace mozilla::css; using namespace mozilla::css;
@ -192,6 +193,10 @@ AsyncPanZoomController::~AsyncPanZoomController() {
} }
inline void AsyncPanZoomController::ScrollBy(const gfx::Point& aOffset) {
mFrameMetrics.mScrollOffset += aOffset;
}
void void
AsyncPanZoomController::Destroy() AsyncPanZoomController::Destroy()
{ {
@ -207,12 +212,12 @@ AsyncPanZoomController::GetTouchStartTolerance()
} }
static gfx::Point static gfx::Point
WidgetSpaceToCompensatedViewportSpace(const gfx::Point& aPoint, WidgetSpaceToCompensatedViewportSpace(const nsIntPoint& aPoint,
gfxFloat aCurrentZoom) gfxFloat aCurrentZoom)
{ {
// Transform the input point from local widget space to the content document // Transform the input point from local widget space to the content document
// space that the user is seeing, from last composite. // space that the user is seeing, from last composite.
gfx::Point pt(aPoint); gfx::Point pt(gfx::ToIntPoint(aPoint));
pt = pt / aCurrentZoom; pt = pt / aCurrentZoom;
// FIXME/bug 775451: this doesn't attempt to compensate for content transforms // FIXME/bug 775451: this doesn't attempt to compensate for content transforms
@ -233,10 +238,8 @@ AsyncPanZoomController::ReceiveInputEvent(const nsInputEvent& aEvent,
{ {
MonitorAutoLock monitor(mMonitor); MonitorAutoLock monitor(mMonitor);
currentResolution = CalculateResolution(mFrameMetrics).width; currentResolution = CalculateResolution(mFrameMetrics).width;
currentScrollOffset = gfx::Point(mFrameMetrics.mScrollOffset.x, currentScrollOffset = mFrameMetrics.mScrollOffset;
mFrameMetrics.mScrollOffset.y); lastScrollOffset = mLastContentPaintMetrics.mScrollOffset;
lastScrollOffset = gfx::Point(mLastContentPaintMetrics.mScrollOffset.x,
mLastContentPaintMetrics.mScrollOffset.y);
} }
nsEventStatus status; nsEventStatus status;
@ -264,8 +267,7 @@ AsyncPanZoomController::ReceiveInputEvent(const nsInputEvent& aEvent,
nsIDOMTouch* touch = touches[i]; nsIDOMTouch* touch = touches[i];
if (touch) { if (touch) {
gfx::Point refPoint = WidgetSpaceToCompensatedViewportSpace( gfx::Point refPoint = WidgetSpaceToCompensatedViewportSpace(
gfx::Point(touch->mRefPoint.x, touch->mRefPoint.y), touch->mRefPoint, currentResolution);
currentResolution);
touch->mRefPoint = nsIntPoint(refPoint.x, refPoint.y); touch->mRefPoint = nsIntPoint(refPoint.x, refPoint.y);
} }
} }
@ -273,8 +275,7 @@ AsyncPanZoomController::ReceiveInputEvent(const nsInputEvent& aEvent,
} }
default: { default: {
gfx::Point refPoint = WidgetSpaceToCompensatedViewportSpace( gfx::Point refPoint = WidgetSpaceToCompensatedViewportSpace(
gfx::Point(aOutEvent->refPoint.x, aOutEvent->refPoint.y), aOutEvent->refPoint, currentResolution);
currentResolution);
aOutEvent->refPoint = nsIntPoint(refPoint.x, refPoint.y); aOutEvent->refPoint = nsIntPoint(refPoint.x, refPoint.y);
break; break;
} }
@ -534,7 +535,7 @@ nsEventStatus AsyncPanZoomController::OnScaleBegin(const PinchGestureInput& aEve
} }
SetState(PINCHING); SetState(PINCHING);
mLastZoomFocus = aEvent.mFocusPoint; mLastZoomFocus = gfx::ToIntPoint(aEvent.mFocusPoint);
return nsEventStatus_eConsumeNoDefault; return nsEventStatus_eConsumeNoDefault;
} }
@ -556,28 +557,23 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) {
MonitorAutoLock monitor(mMonitor); MonitorAutoLock monitor(mMonitor);
gfxFloat resolution = CalculateResolution(mFrameMetrics).width; gfxFloat resolution = CalculateResolution(mFrameMetrics).width;
gfxFloat userZoom = mFrameMetrics.mZoom.width; gfx::IntPoint focusPoint(gfx::ToIntPoint(aEvent.mFocusPoint));
nsIntPoint focusPoint = aEvent.mFocusPoint; gfx::Point focusChange(gfx::Point(mLastZoomFocus - focusPoint) / resolution);
gfxFloat xFocusChange = (mLastZoomFocus.x - focusPoint.x) / resolution;
gfxFloat yFocusChange = (mLastZoomFocus.y - focusPoint.y) / resolution;
// If displacing by the change in focus point will take us off page bounds, // If displacing by the change in focus point will take us off page bounds,
// then reduce the displacement such that it doesn't. // then reduce the displacement such that it doesn't.
if (mX.DisplacementWillOverscroll(xFocusChange) != Axis::OVERSCROLL_NONE) { if (mX.DisplacementWillOverscroll(focusChange.x) != Axis::OVERSCROLL_NONE) {
xFocusChange -= mX.DisplacementWillOverscrollAmount(xFocusChange); focusChange.x -= mX.DisplacementWillOverscrollAmount(focusChange.x);
} }
if (mY.DisplacementWillOverscroll(yFocusChange) != Axis::OVERSCROLL_NONE) { if (mY.DisplacementWillOverscroll(focusChange.y) != Axis::OVERSCROLL_NONE) {
yFocusChange -= mY.DisplacementWillOverscrollAmount(yFocusChange); 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 // 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 // that we actually go over them. These are the needed displacements along
// either axis such that we don't overscroll the boundaries when zooming. // either axis such that we don't overscroll the boundaries when zooming.
gfxFloat neededDisplacementX = 0, neededDisplacementY = 0; gfx::Point neededDisplacement;
gfxFloat userZoom = mFrameMetrics.mZoom.width;
// 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 this zoom will take it over 8x zoom in either direction, but it's not // If this zoom will take it over 8x zoom in either direction, but it's not
// already there, then normalize it. // already there, then normalize it.
@ -587,6 +583,10 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) {
spanRatio = userZoom / mMinZoom; 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) { if (doScale) {
switch (mX.ScaleWillOverscroll(spanRatio, focusPoint.x)) switch (mX.ScaleWillOverscroll(spanRatio, focusPoint.x))
{ {
@ -594,7 +594,7 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) {
break; break;
case Axis::OVERSCROLL_MINUS: case Axis::OVERSCROLL_MINUS:
case Axis::OVERSCROLL_PLUS: case Axis::OVERSCROLL_PLUS:
neededDisplacementX = -mX.ScaleWillOverscrollAmount(spanRatio, focusPoint.x); neededDisplacement.x = -mX.ScaleWillOverscrollAmount(spanRatio, focusPoint.x);
break; break;
case Axis::OVERSCROLL_BOTH: case Axis::OVERSCROLL_BOTH:
// If scaling this way will make us overscroll in both directions, then // If scaling this way will make us overscroll in both directions, then
@ -613,7 +613,7 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) {
break; break;
case Axis::OVERSCROLL_MINUS: case Axis::OVERSCROLL_MINUS:
case Axis::OVERSCROLL_PLUS: case Axis::OVERSCROLL_PLUS:
neededDisplacementY = -mY.ScaleWillOverscrollAmount(spanRatio, focusPoint.y); neededDisplacement.y = -mY.ScaleWillOverscrollAmount(spanRatio, focusPoint.y);
break; break;
case Axis::OVERSCROLL_BOTH: case Axis::OVERSCROLL_BOTH:
doScale = false; doScale = false;
@ -624,9 +624,7 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) {
if (doScale) { if (doScale) {
ScaleWithFocus(userZoom * spanRatio, focusPoint); ScaleWithFocus(userZoom * spanRatio, focusPoint);
if (neededDisplacementX != 0 || neededDisplacementY != 0) { ScrollBy(neededDisplacement);
ScrollBy(gfx::Point(neededDisplacementX, neededDisplacementY));
}
ScheduleComposite(); ScheduleComposite();
// We don't want to redraw on every scale, so don't use // 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; gfxFloat resolution = CalculateResolution(mFrameMetrics).width;
gfx::Point point = WidgetSpaceToCompensatedViewportSpace( gfx::Point point = WidgetSpaceToCompensatedViewportSpace(
gfx::Point(aEvent.mPoint.x, aEvent.mPoint.y), aEvent.mPoint, resolution);
resolution);
mGeckoContentController->HandleLongTap(nsIntPoint(NS_lround(point.x), mGeckoContentController->HandleLongTap(nsIntPoint(NS_lround(point.x),
NS_lround(point.y))); NS_lround(point.y)));
return nsEventStatus_eConsumeNoDefault; return nsEventStatus_eConsumeNoDefault;
@ -677,8 +674,7 @@ nsEventStatus AsyncPanZoomController::OnSingleTapConfirmed(const TapGestureInput
gfxFloat resolution = CalculateResolution(mFrameMetrics).width; gfxFloat resolution = CalculateResolution(mFrameMetrics).width;
gfx::Point point = WidgetSpaceToCompensatedViewportSpace( gfx::Point point = WidgetSpaceToCompensatedViewportSpace(
gfx::Point(aEvent.mPoint.x, aEvent.mPoint.y), aEvent.mPoint, resolution);
resolution);
mGeckoContentController->HandleSingleTap(nsIntPoint(NS_lround(point.x), mGeckoContentController->HandleSingleTap(nsIntPoint(NS_lround(point.x),
NS_lround(point.y))); NS_lround(point.y)));
return nsEventStatus_eConsumeNoDefault; return nsEventStatus_eConsumeNoDefault;
@ -693,8 +689,7 @@ nsEventStatus AsyncPanZoomController::OnDoubleTap(const TapGestureInput& aEvent)
if (mAllowZoom) { if (mAllowZoom) {
gfxFloat resolution = CalculateResolution(mFrameMetrics).width; gfxFloat resolution = CalculateResolution(mFrameMetrics).width;
gfx::Point point = WidgetSpaceToCompensatedViewportSpace( gfx::Point point = WidgetSpaceToCompensatedViewportSpace(
gfx::Point(aEvent.mPoint.x, aEvent.mPoint.y), aEvent.mPoint, resolution);
resolution);
mGeckoContentController->HandleDoubleTap(nsIntPoint(NS_lround(point.x), mGeckoContentController->HandleDoubleTap(nsIntPoint(NS_lround(point.x),
NS_lround(point.y))); NS_lround(point.y)));
} }
@ -764,15 +759,15 @@ void AsyncPanZoomController::TrackTouch(const MultiTouchInput& aEvent) {
// larger swipe should move you a shorter distance. // larger swipe should move you a shorter distance.
gfxFloat inverseResolution = 1 / CalculateResolution(mFrameMetrics).width; gfxFloat inverseResolution = 1 / CalculateResolution(mFrameMetrics).width;
float xDisplacement = mX.GetDisplacementForDuration(inverseResolution, gfx::Point displacement(
timeDelta); mX.GetDisplacementForDuration(inverseResolution, timeDelta),
float yDisplacement = mY.GetDisplacementForDuration(inverseResolution, mY.GetDisplacementForDuration(inverseResolution, timeDelta));
timeDelta);
if (fabs(xDisplacement) <= EPSILON && fabs(yDisplacement) <= EPSILON) { if (fabs(displacement.x) <= EPSILON && fabs(displacement.y) <= EPSILON) {
return; return;
} }
ScrollBy(gfx::Point(xDisplacement, yDisplacement)); ScrollBy(displacement);
ScheduleComposite(); ScheduleComposite();
TimeDuration timePaintDelta = TimeStamp::Now() - mPreviousPaintStartTime; TimeDuration timePaintDelta = TimeStamp::Now() - mPreviousPaintStartTime;
@ -828,14 +823,6 @@ void AsyncPanZoomController::SetCompositorParent(CompositorParent* aCompositorPa
mCompositorParent = aCompositorParent; 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) { void AsyncPanZoomController::SetPageRect(const gfx::Rect& aCSSPageRect) {
FrameMetrics metrics = mFrameMetrics; FrameMetrics metrics = mFrameMetrics;
gfx::Rect pageSize = aCSSPageRect; 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 // Round the page rect so we don't get any truncation, then get the nsIntRect
// from this. // from this.
metrics.mContentRect = nsIntRect(pageSize.x, pageSize.y, metrics.mContentRect = gfx::IntRect(pageSize.x, pageSize.y,
pageSize.width, pageSize.height); pageSize.width, pageSize.height);
metrics.mScrollableRect = aCSSPageRect; metrics.mScrollableRect = aCSSPageRect;
mFrameMetrics = metrics; mFrameMetrics = metrics;
} }
void AsyncPanZoomController::ScaleWithFocus(float aZoom, void AsyncPanZoomController::ScaleWithFocus(float aZoom,
const nsIntPoint& aFocus) { const gfx::IntPoint& aFocus) {
float zoomFactor = aZoom / mFrameMetrics.mZoom.width; float zoomFactor = aZoom / mFrameMetrics.mZoom.width;
gfxFloat resolution = CalculateResolution(mFrameMetrics).width; gfxFloat resolution = CalculateResolution(mFrameMetrics).width;
@ -923,7 +910,7 @@ const gfx::Rect AsyncPanZoomController::CalculatePendingDisplayPort(
aEstimatedPaintDuration > EPSILON ? aEstimatedPaintDuration : 1.0; aEstimatedPaintDuration > EPSILON ? aEstimatedPaintDuration : 1.0;
gfxFloat resolution = CalculateResolution(aFrameMetrics).width; gfxFloat resolution = CalculateResolution(aFrameMetrics).width;
nsIntRect compositionBounds = aFrameMetrics.mCompositionBounds; gfx::IntRect compositionBounds = aFrameMetrics.mCompositionBounds;
compositionBounds.ScaleInverseRoundIn(resolution); compositionBounds.ScaleInverseRoundIn(resolution);
gfx::Rect scrollableRect = aFrameMetrics.mScrollableRect; gfx::Rect scrollableRect = aFrameMetrics.mScrollableRect;
@ -997,31 +984,25 @@ const gfx::Rect AsyncPanZoomController::CalculatePendingDisplayPort(
return displayPort; return displayPort;
} }
/*static*/ gfxSize /*static*/ gfx::ZoomScale
AsyncPanZoomController::CalculateIntrinsicScale(const FrameMetrics& aMetrics) AsyncPanZoomController::CalculateIntrinsicScale(const FrameMetrics& aMetrics)
{ {
gfxFloat intrinsicScale = (gfxFloat(aMetrics.mCompositionBounds.width) / gfx::Float intrinsicScale = gfx::Float(aMetrics.mCompositionBounds.width) /
gfxFloat(aMetrics.mViewport.width)); gfx::Float(aMetrics.mViewport.width);
return gfxSize(intrinsicScale, intrinsicScale); return gfx::ZoomScale(intrinsicScale, intrinsicScale);
} }
/*static*/ gfxSize /*static*/ gfx::ZoomScale
AsyncPanZoomController::CalculateResolution(const FrameMetrics& aMetrics) AsyncPanZoomController::CalculateResolution(const FrameMetrics& aMetrics)
{ {
gfxSize intrinsicScale = CalculateIntrinsicScale(aMetrics); return CalculateIntrinsicScale(aMetrics) * aMetrics.mZoom;
gfxSize userZoom = aMetrics.mZoom;
return gfxSize(intrinsicScale.width * userZoom.width,
intrinsicScale.height * userZoom.height);
} }
/*static*/ gfx::Rect /*static*/ gfx::Rect
AsyncPanZoomController::CalculateCompositedRectInCssPixels(const FrameMetrics& aMetrics) AsyncPanZoomController::CalculateCompositedRectInCssPixels(const FrameMetrics& aMetrics)
{ {
gfxSize resolution = CalculateResolution(aMetrics); gfx::ZoomScale resolution = CalculateResolution(aMetrics);
gfx::Rect rect(aMetrics.mCompositionBounds.x, gfx::Rect rect(aMetrics.mCompositionBounds);
aMetrics.mCompositionBounds.y,
aMetrics.mCompositionBounds.width,
aMetrics.mCompositionBounds.height);
rect.ScaleInverseRoundIn(resolution.width, resolution.height); rect.ScaleInverseRoundIn(resolution.width, resolution.height);
return rect; return rect;
} }
@ -1103,7 +1084,7 @@ void AsyncPanZoomController::RequestContentRepaint() {
mWaitingForContentToPaint = true; mWaitingForContentToPaint = true;
// Set the zoom back to what it was for the purpose of logic control. // 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 void
@ -1129,12 +1110,12 @@ bool AsyncPanZoomController::SampleContentTransformForFrame(const TimeStamp& aSa
const gfx3DMatrix& currentTransform = aLayer->GetTransform(); const gfx3DMatrix& currentTransform = aLayer->GetTransform();
// Scales on the root layer, on what's currently painted. // Scales on the root layer, on what's currently painted.
gfxSize rootScale(currentTransform.GetXScale(), gfx::ZoomScale rootScale(currentTransform.GetXScale(),
currentTransform.GetYScale()); currentTransform.GetYScale());
gfxPoint metricsScrollOffset(0, 0); gfx::Point metricsScrollOffset(0, 0);
gfxPoint scrollOffset; gfx::Point scrollOffset;
gfxSize localScale; gfx::ZoomScale localScale;
const FrameMetrics& frame = aLayer->GetFrameMetrics(); const FrameMetrics& frame = aLayer->GetFrameMetrics();
{ {
MonitorAutoLock mon(mMonitor); MonitorAutoLock mon(mMonitor);
@ -1158,7 +1139,7 @@ bool AsyncPanZoomController::SampleContentTransformForFrame(const TimeStamp& aSa
gfxFloat endZoom = mEndZoomToMetrics.mZoom.width; gfxFloat endZoom = mEndZoomToMetrics.mZoom.width;
gfxFloat sampledZoom = (endZoom * sampledPosition + gfxFloat sampledZoom = (endZoom * sampledPosition +
startZoom * (1 - sampledPosition)); startZoom * (1 - sampledPosition));
mFrameMetrics.mZoom = gfxSize(sampledZoom, sampledZoom); mFrameMetrics.mZoom = gfx::ZoomScale(sampledZoom, sampledZoom);
mFrameMetrics.mScrollOffset = gfx::Point( mFrameMetrics.mScrollOffset = gfx::Point(
mEndZoomToMetrics.mScrollOffset.x * sampledPosition + mEndZoomToMetrics.mScrollOffset.x * sampledPosition +
@ -1193,7 +1174,7 @@ bool AsyncPanZoomController::SampleContentTransformForFrame(const TimeStamp& aSa
metricsScrollOffset = frame.GetScrollOffsetInLayerPixels(); metricsScrollOffset = frame.GetScrollOffsetInLayerPixels();
} }
scrollOffset = gfxPoint(mFrameMetrics.mScrollOffset.x, mFrameMetrics.mScrollOffset.y); scrollOffset = mFrameMetrics.mScrollOffset;
mCurrentAsyncScrollOffset = mFrameMetrics.mScrollOffset; mCurrentAsyncScrollOffset = mFrameMetrics.mScrollOffset;
} }
@ -1224,7 +1205,7 @@ bool AsyncPanZoomController::SampleContentTransformForFrame(const TimeStamp& aSa
mAsyncScrollTimeout); mAsyncScrollTimeout);
} }
gfxPoint scrollCompensation( gfx::Point scrollCompensation(
(scrollOffset / rootScale - metricsScrollOffset) * localScale); (scrollOffset / rootScale - metricsScrollOffset) * localScale);
*aNewTransform = ViewTransform(-scrollCompensation, localScale); *aNewTransform = ViewTransform(-scrollCompensation, localScale);
@ -1274,9 +1255,9 @@ void AsyncPanZoomController::NotifyLayersUpdated(const FrameMetrics& aViewportFr
aViewportFrame.mCompositionBounds.height == mFrameMetrics.mCompositionBounds.height) { aViewportFrame.mCompositionBounds.height == mFrameMetrics.mCompositionBounds.height) {
// Remote content has sync'd up to the composition geometry // Remote content has sync'd up to the composition geometry
// change, so we can accept the viewport it's calculated. // change, so we can accept the viewport it's calculated.
gfxSize previousResolution = CalculateResolution(mFrameMetrics); gfx::ZoomScale previousResolution = CalculateResolution(mFrameMetrics);
mFrameMetrics.mViewport = aViewportFrame.mViewport; mFrameMetrics.mViewport = aViewportFrame.mViewport;
gfxSize newResolution = CalculateResolution(mFrameMetrics); gfx::ZoomScale newResolution = CalculateResolution(mFrameMetrics);
needContentRepaint |= (previousResolution != newResolution); needContentRepaint |= (previousResolution != newResolution);
} }
@ -1306,18 +1287,17 @@ const FrameMetrics& AsyncPanZoomController::GetFrameMetrics() {
return mFrameMetrics; return mFrameMetrics;
} }
void AsyncPanZoomController::UpdateCompositionBounds(const nsIntRect& aCompositionBounds) { void AsyncPanZoomController::UpdateCompositionBounds(const gfx::IntRect& aCompositionBounds) {
MonitorAutoLock mon(mMonitor); MonitorAutoLock mon(mMonitor);
nsIntRect oldCompositionBounds = mFrameMetrics.mCompositionBounds; bool wasEmpty = mFrameMetrics.mCompositionBounds.IsEmpty();
mFrameMetrics.mCompositionBounds = aCompositionBounds; mFrameMetrics.mCompositionBounds = aCompositionBounds;
// If the window had 0 dimensions before, or does now, we don't want to // 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 // 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 // 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. // has gone out of view, the buffer will be cleared elsewhere anyways.
if (aCompositionBounds.width && aCompositionBounds.height && if (!aCompositionBounds.IsEmpty() && !wasEmpty) {
oldCompositionBounds.width && oldCompositionBounds.height) {
SetZoomAndResolution(mFrameMetrics.mZoom.width); SetZoomAndResolution(mFrameMetrics.mZoom.width);
// Repaint on a rotation so that our new resolution gets properly updated. // 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) { 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); SetState(ANIMATING_ZOOM);
{ {
MonitorAutoLock mon(mMonitor); MonitorAutoLock mon(mMonitor);
nsIntRect compositionBounds = mFrameMetrics.mCompositionBounds; gfx::IntRect compositionBounds = mFrameMetrics.mCompositionBounds;
gfx::Rect cssPageRect = mFrameMetrics.mScrollableRect; gfx::Rect cssPageRect = mFrameMetrics.mScrollableRect;
gfx::Point scrollOffset = mFrameMetrics.mScrollOffset; 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 // If the rect is empty, treat it as a request to zoom out to the full page
// size. // size.
if (zoomToRect.IsEmpty()) { if (zoomToRect.IsEmpty()) {
// composition bounds in CSS coordinates // composition bounds in CSS coordinates
nsIntRect cssCompositionBounds = compositionBounds; gfx::IntRect cssCompositionBounds = compositionBounds;
cssCompositionBounds.ScaleInverseRoundIn(resolution.width, cssCompositionBounds.ScaleInverseRoundIn(resolution.width,
resolution.height); resolution.height);
cssCompositionBounds.MoveBy(scrollOffset.x, scrollOffset.y); cssCompositionBounds.MoveBy(scrollOffset.x, scrollOffset.y);
@ -1371,7 +1351,7 @@ void AsyncPanZoomController::ZoomToRect(const gfxRect& aRect) {
gfxFloat targetResolution = gfxFloat targetResolution =
std::min(compositionBounds.width / zoomToRect.width, std::min(compositionBounds.width / zoomToRect.width,
compositionBounds.height / zoomToRect.height); compositionBounds.height / zoomToRect.height);
// Recalculate the zoom to rect using the new dimensions. // Recalculate the zoom to rect using the new dimensions.
zoomToRect.width = compositionBounds.width / targetResolution; zoomToRect.width = compositionBounds.width / targetResolution;
@ -1382,13 +1362,13 @@ void AsyncPanZoomController::ZoomToRect(const gfxRect& aRect) {
// Do one final recalculation to get the resolution. // Do one final recalculation to get the resolution.
targetResolution = std::max(compositionBounds.width / zoomToRect.width, targetResolution = std::max(compositionBounds.width / zoomToRect.width,
compositionBounds.height / zoomToRect.height); compositionBounds.height / zoomToRect.height);
float targetZoom = float(targetResolution / resolution.width) * mFrameMetrics.mZoom.width; float targetZoom = float(targetResolution / resolution.width) * mFrameMetrics.mZoom.width;
// If current zoom is equal to mMaxZoom, // If current zoom is equal to mMaxZoom,
// user still double-tapping it, just zoom-out to the full page size // user still double-tapping it, just zoom-out to the full page size
if (mFrameMetrics.mZoom.width == mMaxZoom && targetZoom >= mMaxZoom) { if (mFrameMetrics.mZoom.width == mMaxZoom && targetZoom >= mMaxZoom) {
nsIntRect cssCompositionBounds = compositionBounds; gfx::IntRect cssCompositionBounds = compositionBounds;
cssCompositionBounds.ScaleInverseRoundIn(resolution.width, cssCompositionBounds.ScaleInverseRoundIn(resolution.width,
resolution.height); resolution.height);
cssCompositionBounds.MoveBy(scrollOffset.x, scrollOffset.y); cssCompositionBounds.MoveBy(scrollOffset.x, scrollOffset.y);
@ -1409,7 +1389,7 @@ void AsyncPanZoomController::ZoomToRect(const gfxRect& aRect) {
} }
gfxFloat targetFinalZoom = clamped(targetZoom, mMinZoom, mMaxZoom); gfxFloat targetFinalZoom = clamped(targetZoom, mMinZoom, mMaxZoom);
mEndZoomToMetrics.mZoom = gfxSize(targetFinalZoom, targetFinalZoom); mEndZoomToMetrics.mZoom = gfx::ZoomScale(targetFinalZoom, targetFinalZoom);
mStartZoomToMetrics = mFrameMetrics; mStartZoomToMetrics = mFrameMetrics;
mEndZoomToMetrics.mScrollOffset = mEndZoomToMetrics.mScrollOffset =
@ -1477,7 +1457,7 @@ void AsyncPanZoomController::TimeoutTouchListeners() {
void AsyncPanZoomController::SetZoomAndResolution(float aZoom) { void AsyncPanZoomController::SetZoomAndResolution(float aZoom) {
mMonitor.AssertCurrentThreadOwns(); mMonitor.AssertCurrentThreadOwns();
mFrameMetrics.mZoom = gfxSize(aZoom, aZoom); mFrameMetrics.mZoom = gfx::ZoomScale(aZoom, aZoom);
mFrameMetrics.mResolution = CalculateResolution(mFrameMetrics); mFrameMetrics.mResolution = CalculateResolution(mFrameMetrics);
} }
@ -1505,8 +1485,7 @@ void AsyncPanZoomController::SendAsyncScrollEvent() {
gfx::Rect contentRect; gfx::Rect contentRect;
gfx::Size scrollableSize; gfx::Size scrollableSize;
{ {
scrollableSize = gfx::Size(mFrameMetrics.mScrollableRect.width, scrollableSize = mFrameMetrics.mScrollableRect.Size();
mFrameMetrics.mScrollableRect.height);
contentRect = contentRect =
AsyncPanZoomController::CalculateCompositedRectInCssPixels(mFrameMetrics); AsyncPanZoomController::CalculateCompositedRectInCssPixels(mFrameMetrics);
contentRect.MoveTo(mCurrentAsyncScrollOffset); contentRect.MoveTo(mCurrentAsyncScrollOffset);

View File

@ -111,7 +111,7 @@ public:
* { x = 0, y = 0, width = surface.width, height = surface.height }, however * { x = 0, y = 0, width = surface.width, height = surface.height }, however
* there is no hard requirement for this. * 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 * 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| * Return the scale factor needed to fit the viewport in |aMetrics|
* into its composition bounds. * 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 * Return the resolution that content should be rendered at given
@ -240,7 +240,7 @@ public:
* factor, etc. (The mResolution member of aFrameMetrics is * factor, etc. (The mResolution member of aFrameMetrics is
* ignored.) * ignored.)
*/ */
static gfxSize CalculateResolution(const FrameMetrics& aMetrics); static gfx::ZoomScale CalculateResolution(const FrameMetrics& aMetrics);
static gfx::Rect CalculateCompositedRectInCssPixels(const FrameMetrics& aMetrics); static gfx::Rect CalculateCompositedRectInCssPixels(const FrameMetrics& aMetrics);
@ -347,7 +347,7 @@ protected:
* *
* XXX: Fix focus point calculations. * 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 * 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 // 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). // 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 // Stores the state of panning and zooming this frame. This is protected by
// |mMonitor|; that is, it should be held whenever this is updated. // |mMonitor|; that is, it should be held whenever this is updated.

View File

@ -324,10 +324,7 @@ bool Axis::ScaleWillOverscrollBothSides(float aScale) {
gfx::Rect cssContentRect = metrics.mScrollableRect; gfx::Rect cssContentRect = metrics.mScrollableRect;
float currentScale = metrics.mZoom.width; float currentScale = metrics.mZoom.width;
nsIntRect compositionBounds = metrics.mCompositionBounds; gfx::Rect scaledCompositionBounds(metrics.mCompositionBounds);
gfx::Rect scaledCompositionBounds =
gfx::Rect(compositionBounds.x, compositionBounds.y,
compositionBounds.width, compositionBounds.height);
scaledCompositionBounds.ScaleInverseRoundIn(currentScale * aScale); scaledCompositionBounds.ScaleInverseRoundIn(currentScale * aScale);
return GetRectLength(cssContentRect) < GetRectLength(scaledCompositionBounds); return GetRectLength(cssContentRect) < GetRectLength(scaledCompositionBounds);

View File

@ -38,6 +38,7 @@
#include "gfxPlatform.h" #include "gfxPlatform.h"
#include "mozilla/dom/ScreenOrientation.h" #include "mozilla/dom/ScreenOrientation.h"
#include "mozilla/AutoRestore.h" #include "mozilla/AutoRestore.h"
#include "gfx2DGlue.h"
using namespace base; using namespace base;
using namespace mozilla; using namespace mozilla;
@ -474,7 +475,7 @@ CompositorParent::ScheduleComposition()
} }
void void
CompositorParent::SetTransformation(float aScale, nsIntPoint aScrollOffset) CompositorParent::SetTransformation(float aScale, gfx::IntPoint aScrollOffset)
{ {
mXScale = aScale; mXScale = aScale;
mYScale = aScale; mYScale = aScale;
@ -871,8 +872,8 @@ CompositorParent::ApplyAsyncContentTransformToTree(TimeStamp aCurrentFrame,
TransformFixedLayers( TransformFixedLayers(
aLayer, aLayer,
-treeTransform.mTranslation / treeTransform.mScale, gfx::ThebesPoint(-treeTransform.mTranslation / treeTransform.mScale),
treeTransform.mScale); gfxSize(treeTransform.mScale.width, treeTransform.mScale.height));
appliedTransform = true; appliedTransform = true;
} }
@ -906,8 +907,8 @@ CompositorParent::TransformScrollableLayer(Layer* aLayer, const gfx3DMatrix& aRo
// as a FrameMetrics helper because it's a deprecated conversion. // as a FrameMetrics helper because it's a deprecated conversion.
float devPixelRatioX = 1 / rootScaleX, devPixelRatioY = 1 / rootScaleY; float devPixelRatioX = 1 / rootScaleX, devPixelRatioY = 1 / rootScaleY;
gfxPoint scrollOffsetLayersPixels(metrics.GetScrollOffsetInLayerPixels()); gfx::Point scrollOffsetLayersPixels(metrics.GetScrollOffsetInLayerPixels());
nsIntPoint scrollOffsetDevPixels( gfx::IntPoint scrollOffsetDevPixels(
NS_lround(scrollOffsetLayersPixels.x * devPixelRatioX), NS_lround(scrollOffsetLayersPixels.x * devPixelRatioX),
NS_lround(scrollOffsetLayersPixels.y * devPixelRatioY)); 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 // Calculate the absolute display port to send to Java
gfx::Rect displayPortLayersPixels(metrics.mCriticalDisplayPort.IsEmpty() ? gfx::Rect displayPortLayersPixels(metrics.mCriticalDisplayPort.IsEmpty() ?
metrics.mDisplayPort : metrics.mCriticalDisplayPort); metrics.mDisplayPort : metrics.mCriticalDisplayPort);
nsIntRect displayPortDevPixels( gfx::IntRect displayPortDevPixels(
NS_lround(displayPortLayersPixels.x * devPixelRatioX), NS_lround(displayPortLayersPixels.x * devPixelRatioX),
NS_lround(displayPortLayersPixels.y * devPixelRatioY), NS_lround(displayPortLayersPixels.y * devPixelRatioY),
NS_lround(displayPortLayersPixels.width * devPixelRatioX), NS_lround(displayPortLayersPixels.width * devPixelRatioX),
@ -950,16 +951,16 @@ CompositorParent::TransformScrollableLayer(Layer* aLayer, const gfx3DMatrix& aRo
float tempScaleDiffX = rootScaleX * mXScale; float tempScaleDiffX = rootScaleX * mXScale;
float tempScaleDiffY = rootScaleY * mYScale; float tempScaleDiffY = rootScaleY * mYScale;
nsIntPoint metricsScrollOffset(0, 0); gfx::IntPoint metricsScrollOffset(0, 0);
if (metrics.IsScrollable()) { if (metrics.IsScrollable()) {
metricsScrollOffset = scrollOffsetDevPixels; metricsScrollOffset = scrollOffsetDevPixels;
} }
nsIntPoint scrollCompensation( gfx::IntPoint scrollCompensation(
(mScrollOffset.x / tempScaleDiffX - metricsScrollOffset.x) * mXScale, (mScrollOffset.x / tempScaleDiffX - metricsScrollOffset.x) * mXScale,
(mScrollOffset.y / tempScaleDiffY - metricsScrollOffset.y) * mYScale); (mScrollOffset.y / tempScaleDiffY - metricsScrollOffset.y) * mYScale);
treeTransform = gfx3DMatrix(ViewTransform(-scrollCompensation, treeTransform = gfx3DMatrix(ViewTransform(gfx::Point(-scrollCompensation),
gfxSize(mXScale, mYScale))); gfx::ZoomScale(mXScale, mYScale)));
// If the contents can fit entirely within the widget area on a particular // 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 // dimenson, we need to translate and scale so that the fixed layers remain
@ -1040,8 +1041,10 @@ CompositorParent::TransformShadowTree(TimeStamp aCurrentFrame)
} }
void void
CompositorParent::SetFirstPaintViewport(const nsIntPoint& aOffset, float aZoom, CompositorParent::SetFirstPaintViewport(const gfx::IntPoint& aOffset,
const nsIntRect& aPageRect, const gfx::Rect& aCssPageRect) float aZoom,
const gfx::IntRect& aPageRect,
const gfx::Rect& aCssPageRect)
{ {
#ifdef MOZ_WIDGET_ANDROID #ifdef MOZ_WIDGET_ANDROID
AndroidBridge::Bridge()->SetFirstPaintViewport(aOffset, aZoom, aPageRect, aCssPageRect); AndroidBridge::Bridge()->SetFirstPaintViewport(aOffset, aZoom, aPageRect, aCssPageRect);
@ -1057,9 +1060,11 @@ CompositorParent::SetPageRect(const gfx::Rect& aCssPageRect)
} }
void void
CompositorParent::SyncViewportInfo(const nsIntRect& aDisplayPort, CompositorParent::SyncViewportInfo(const gfx::IntRect& aDisplayPort,
float aDisplayResolution, bool aLayersUpdated, float aDisplayResolution,
nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY) bool aLayersUpdated,
gfx::IntPoint& aScrollOffset,
float& aScaleX, float& aScaleY)
{ {
#ifdef MOZ_WIDGET_ANDROID #ifdef MOZ_WIDGET_ANDROID
AndroidBridge::Bridge()->SyncViewportInfo(aDisplayPort, aDisplayResolution, aLayersUpdated, AndroidBridge::Bridge()->SyncViewportInfo(aDisplayPort, aDisplayResolution, aLayersUpdated,

View File

@ -36,8 +36,8 @@ class LayerManager;
// Represents (affine) transforms that are calculated from a content view. // Represents (affine) transforms that are calculated from a content view.
struct ViewTransform { struct ViewTransform {
ViewTransform(gfxPoint aTranslation = gfxPoint(), ViewTransform(gfx::Point aTranslation = gfx::Point(),
gfxSize aScale = gfxSize(1, 1)) gfx::ZoomScale aScale = gfx::ZoomScale())
: mTranslation(aTranslation) : mTranslation(aTranslation)
, mScale(aScale) , mScale(aScale)
{} {}
@ -49,8 +49,8 @@ struct ViewTransform {
gfx3DMatrix::Translation(mTranslation.x, mTranslation.y, 0); gfx3DMatrix::Translation(mTranslation.x, mTranslation.y, 0);
} }
gfxPoint mTranslation; gfx::Point mTranslation;
gfxSize mScale; gfx::ZoomScale mScale;
}; };
class CompositorParent : public PCompositorParent, class CompositorParent : public PCompositorParent,
@ -87,7 +87,7 @@ public:
LayerManager* GetLayerManager() { return mLayerManager; } LayerManager* GetLayerManager() { return mLayerManager; }
void SetTransformation(float aScale, nsIntPoint aScrollOffset); void SetTransformation(float aScale, gfx::IntPoint aScrollOffset);
void AsyncRender(); void AsyncRender();
// Can be called from any thread // Can be called from any thread
@ -178,10 +178,15 @@ protected:
virtual void ScheduleTask(CancelableTask*, int); virtual void ScheduleTask(CancelableTask*, int);
virtual void Composite(); virtual void Composite();
virtual void ComposeToTarget(gfxContext* aTarget); 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 SetPageRect(const gfx::Rect& aCssPageRect);
virtual void SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated, virtual void SyncViewportInfo(const gfx::IntRect& aDisplayPort,
nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY); float aDisplayResolution, bool aLayersUpdated,
gfx::IntPoint& aScrollOffset,
float& aScaleX, float& aScaleY);
void SetEGLSurfaceSize(int width, int height); void SetEGLSurfaceSize(int width, int height);
// If SetPanZoomControllerForLayerTree is not set, Compositor will use // If SetPanZoomControllerForLayerTree is not set, Compositor will use
// derived class AsyncPanZoomController transformations. // derived class AsyncPanZoomController transformations.
@ -282,8 +287,8 @@ private:
bool mPaused; bool mPaused;
float mXScale; float mXScale;
float mYScale; float mYScale;
nsIntPoint mScrollOffset; gfx::IntPoint mScrollOffset;
nsIntRect mContentRect; gfx::IntRect mContentRect;
// When this flag is set, the next composition will be the first for a // 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). // particular document (i.e. the document displayed on the screen will change).

View File

@ -5,6 +5,7 @@
#include "ReusableTileStoreOGL.h" #include "ReusableTileStoreOGL.h"
#include "GLContext.h" #include "GLContext.h"
#include "gfx2DGlue.h"
namespace mozilla { namespace mozilla {
namespace layers { namespace layers {
@ -291,7 +292,7 @@ ReusableTileStoreOGL::DrawTiles(TiledThebesLayerOGL* aLayer,
scrollableLayer = parent; scrollableLayer = parent;
if (!parentMetrics.mDisplayPort.IsEmpty() && scrollableLayer) { if (!parentMetrics.mDisplayPort.IsEmpty() && scrollableLayer) {
// Get the composition bounds, so as not to waste rendering time. // 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 // Calculate the scale transform applied to the root layer to determine
// the content resolution. // the content resolution.
@ -302,12 +303,12 @@ ReusableTileStoreOGL::DrawTiles(TiledThebesLayerOGL* aLayer,
// Get the content document bounds, in screen-space. // Get the content document bounds, in screen-space.
const FrameMetrics& metrics = scrollableLayer->GetFrameMetrics(); const FrameMetrics& metrics = scrollableLayer->GetFrameMetrics();
const nsIntSize& contentSize = metrics.mContentRect.Size(); const gfx::IntSize& contentSize = metrics.mContentRect.Size();
gfx::Point scrollOffset = gfx::Point scrollOffset =
gfx::Point((metrics.mScrollOffset.x * metrics.LayersPixelsPerCSSPixel().width) / scaleX, gfx::Point((metrics.mScrollOffset.x * metrics.LayersPixelsPerCSSPixel().width) / scaleX,
(metrics.mScrollOffset.y * metrics.LayersPixelsPerCSSPixel().height) / scaleY); (metrics.mScrollOffset.y * metrics.LayersPixelsPerCSSPixel().height) / scaleY);
const nsIntPoint& contentOrigin = metrics.mContentRect.TopLeft() - const gfx::IntPoint& contentOrigin = metrics.mContentRect.TopLeft() -
nsIntPoint(NS_lround(scrollOffset.x), NS_lround(scrollOffset.y)); gfx::IntPoint(NS_lround(scrollOffset.x), NS_lround(scrollOffset.y));
gfxRect contentRect = gfxRect(contentOrigin.x, contentOrigin.y, gfxRect contentRect = gfxRect(contentOrigin.x, contentOrigin.y,
contentSize.width, contentSize.height); contentSize.width, contentSize.height);
gfxRect contentBounds = scrollableLayer->GetEffectiveTransform(). gfxRect contentBounds = scrollableLayer->GetEffectiveTransform().

View File

@ -50,6 +50,7 @@
#include "ImageLayers.h" #include "ImageLayers.h"
#include "ImageContainer.h" #include "ImageContainer.h"
#include "nsCanvasFrame.h" #include "nsCanvasFrame.h"
#include "gfx2DGlue.h"
#include "mozilla/StandardInteger.h" #include "mozilla/StandardInteger.h"
#include <algorithm> #include <algorithm>
@ -650,8 +651,8 @@ static void RecordFrameMetrics(nsIFrame* aForFrame,
nsPresContext::AppUnitsToFloatCSSPixels(contentBounds.y), nsPresContext::AppUnitsToFloatCSSPixels(contentBounds.y),
nsPresContext::AppUnitsToFloatCSSPixels(contentBounds.width), nsPresContext::AppUnitsToFloatCSSPixels(contentBounds.width),
nsPresContext::AppUnitsToFloatCSSPixels(contentBounds.height)); nsPresContext::AppUnitsToFloatCSSPixels(contentBounds.height));
metrics.mContentRect = contentBounds.ScaleToNearestPixels( metrics.mContentRect = mozilla::gfx::ToIntRect(contentBounds.ScaleToNearestPixels(
aContainerParameters.mXScale, aContainerParameters.mYScale, auPerDevPixel); aContainerParameters.mXScale, aContainerParameters.mYScale, auPerDevPixel));
nsPoint scrollPosition = scrollableFrame->GetScrollPosition(); nsPoint scrollPosition = scrollableFrame->GetScrollPosition();
metrics.mScrollOffset = mozilla::gfx::Point( metrics.mScrollOffset = mozilla::gfx::Point(
NSAppUnitsToDoublePixels(scrollPosition.x, auPerCSSPixel), NSAppUnitsToDoublePixels(scrollPosition.x, auPerCSSPixel),
@ -664,8 +665,8 @@ static void RecordFrameMetrics(nsIFrame* aForFrame,
nsPresContext::AppUnitsToFloatCSSPixels(contentBounds.y), nsPresContext::AppUnitsToFloatCSSPixels(contentBounds.y),
nsPresContext::AppUnitsToFloatCSSPixels(contentBounds.width), nsPresContext::AppUnitsToFloatCSSPixels(contentBounds.width),
nsPresContext::AppUnitsToFloatCSSPixels(contentBounds.height)); nsPresContext::AppUnitsToFloatCSSPixels(contentBounds.height));
metrics.mContentRect = contentBounds.ScaleToNearestPixels( metrics.mContentRect = mozilla::gfx::ToIntRect(contentBounds.ScaleToNearestPixels(
aContainerParameters.mXScale, aContainerParameters.mYScale, auPerDevPixel); aContainerParameters.mXScale, aContainerParameters.mYScale, auPerDevPixel));
} }
metrics.mScrollId = aScrollId; metrics.mScrollId = aScrollId;
@ -674,14 +675,16 @@ static void RecordFrameMetrics(nsIFrame* aForFrame,
if (TabChild *tc = GetTabChildFrom(presShell)) { if (TabChild *tc = GetTabChildFrom(presShell)) {
metrics.mZoom = tc->GetZoom(); 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.mDevPixelsPerCSSPixel = auPerCSSPixel / auPerDevPixel;
metrics.mMayHaveTouchListeners = aMayHaveTouchListeners; metrics.mMayHaveTouchListeners = aMayHaveTouchListeners;
if (nsIWidget* widget = aForFrame->GetNearestWidget()) { if (nsIWidget* widget = aForFrame->GetNearestWidget()) {
widget->GetBounds(metrics.mCompositionBounds); nsIntRect bounds;
widget->GetBounds(bounds);
metrics.mCompositionBounds = mozilla::gfx::ToIntRect(bounds);
} }
aRoot->SetFrameMetrics(metrics); aRoot->SetFrameMetrics(metrics);

View File

@ -166,7 +166,7 @@ ComputeShadowTreeTransform(nsIFrame* aContainerFrame,
nsIntPoint scrollOffset = nsIntPoint scrollOffset =
aConfig.mScrollOffset.ToNearestPixels(auPerDevPixel); aConfig.mScrollOffset.ToNearestPixels(auPerDevPixel);
// metricsScrollOffset is in layer coordinates. // metricsScrollOffset is in layer coordinates.
gfxPoint metricsScrollOffset = aMetrics->GetScrollOffsetInLayerPixels(); gfx::Point metricsScrollOffset = aMetrics->GetScrollOffsetInLayerPixels();
nsIntPoint roundedMetricsScrollOffset = nsIntPoint roundedMetricsScrollOffset =
nsIntPoint(NS_lround(metricsScrollOffset.x), NS_lround(metricsScrollOffset.y)); nsIntPoint(NS_lround(metricsScrollOffset.x), NS_lround(metricsScrollOffset.y));
@ -794,7 +794,7 @@ RenderFrameParent::NotifyDimensionsChanged(int width, int height)
{ {
if (mPanZoomController) { if (mPanZoomController) {
mPanZoomController->UpdateCompositionBounds( mPanZoomController->UpdateCompositionBounds(
nsIntRect(0, 0, width, height)); gfx::IntRect(0, 0, width, height));
} }
} }

View File

@ -2089,7 +2089,10 @@ AndroidBridge::IsTablet()
} }
void 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; AndroidGeckoLayerClient *client = mLayerClient;
if (!client) if (!client)
@ -2109,8 +2112,10 @@ AndroidBridge::SetPageRect(const gfx::Rect& aCssPageRect)
} }
void void
AndroidBridge::SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated, AndroidBridge::SyncViewportInfo(const gfx::IntRect& aDisplayPort,
nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY) float aDisplayResolution, bool aLayersUpdated,
gfx::IntPoint& aScrollOffset,
float& aScaleX, float& aScaleY)
{ {
AndroidGeckoLayerClient *client = mLayerClient; AndroidGeckoLayerClient *client = mLayerClient;
if (!client) if (!client)

View File

@ -329,10 +329,15 @@ public:
void EnableNetworkNotifications(); void EnableNetworkNotifications();
void DisableNetworkNotifications(); 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 SetPageRect(const gfx::Rect& aCssPageRect);
void SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated, void SyncViewportInfo(const gfx::IntRect& aDisplayPort,
nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY); float aDisplayResolution, bool aLayersUpdated,
gfx::IntPoint& aScrollOffset,
float& aScaleX, float& aScaleY);
void AddPluginView(jobject view, const gfxRect& rect, bool isFullScreen); void AddPluginView(jobject view, const gfxRect& rect, bool isFullScreen);
void RemovePluginView(jobject view, bool isFullScreen); void RemovePluginView(jobject view, bool isFullScreen);

View File

@ -711,7 +711,10 @@ AndroidProgressiveUpdateData::Init(jobject jobj)
} }
void 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!"); NS_ASSERTION(!isNull(), "SetFirstPaintViewport called on null layer client!");
JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread
@ -738,8 +741,11 @@ AndroidGeckoLayerClient::SetPageRect(const gfx::Rect& aCssPageRect)
} }
void void
AndroidGeckoLayerClient::SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated, AndroidGeckoLayerClient::SyncViewportInfo(const gfx::IntRect& aDisplayPort,
nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY) float aDisplayResolution,
bool aLayersUpdated,
gfx::IntPoint& aScrollOffset,
float& aScaleX, float& aScaleY)
{ {
NS_ASSERTION(!isNull(), "SyncViewportInfo called on null layer client!"); NS_ASSERTION(!isNull(), "SyncViewportInfo called on null layer client!");
JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread
@ -760,7 +766,7 @@ AndroidGeckoLayerClient::SyncViewportInfo(const nsIntRect& aDisplayPort, float a
AndroidViewTransform viewTransform; AndroidViewTransform viewTransform;
viewTransform.Init(viewTransformJObj); 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); aScaleX = aScaleY = viewTransform.GetScale(env);
} }

View File

@ -254,10 +254,15 @@ public:
AndroidGeckoLayerClient() {} AndroidGeckoLayerClient() {}
AndroidGeckoLayerClient(jobject jobj) { Init(jobj); } 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 SetPageRect(const gfx::Rect& aCssPageRect);
void SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated, void SyncViewportInfo(const gfx::IntRect& aDisplayPort,
nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY); 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 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 CreateFrame(AutoLocalJNIFrame *jniFrame, AndroidLayerRendererFrame& aFrame);
bool ActivateProgram(AutoLocalJNIFrame *jniFrame); bool ActivateProgram(AutoLocalJNIFrame *jniFrame);