Backed out changeset cacb9f3ee44d (bug 840693)

This commit is contained in:
Ed Morley 2013-03-04 14:37:43 +00:00
Родитель ab15fcd4c3
Коммит 9096110a31
17 изменённых файлов: 196 добавлений и 210 удалений

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

@ -82,7 +82,6 @@
#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")
@ -346,12 +345,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 = gfx::ZoomScale(1.0, 1.0);
mLastMetrics.mZoom = gfxSize(1.0, 1.0);
mLastMetrics.mViewport =
gfx::Rect(0, 0,
kDefaultViewportSize.width, kDefaultViewportSize.height);
mLastMetrics.mCompositionBounds = gfx::IntRect(gfx::IntPoint(0, 0),
mInnerSize);
mLastMetrics.mCompositionBounds = nsIntRect(nsIntPoint(0, 0),
mInnerSize);
mLastMetrics.mResolution =
AsyncPanZoomController::CalculateResolution(mLastMetrics);
mLastMetrics.mScrollOffset = gfx::Point(0, 0);
@ -591,7 +590,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 = gfx::IntRect(0, 0, mInnerSize.width, mInnerSize.height);
metrics.mCompositionBounds = nsIntRect(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.
@ -599,7 +598,7 @@ TabChild::HandlePossibleViewportChange()
nsresult rv = utils->GetIsFirstPaint(&isFirstPaint);
MOZ_ASSERT(NS_SUCCEEDED(rv));
if (NS_FAILED(rv) || isFirstPaint) {
gfx::ZoomScale intrinsicScale =
gfxSize 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
@ -613,8 +612,8 @@ TabChild::HandlePossibleViewportChange()
defaultZoom <= viewportInfo.GetMaxZoom());
// GetViewportInfo() returns a resolution-dependent scale factor.
// Convert that to a resolution-indepedent zoom.
metrics.mZoom = gfx::ZoomScale(defaultZoom / intrinsicScale.width,
defaultZoom / intrinsicScale.height);
metrics.mZoom = gfxSize(defaultZoom / intrinsicScale.width,
defaultZoom / intrinsicScale.height);
}
metrics.mDisplayPort = AsyncPanZoomController::CalculatePendingDisplayPort(
@ -622,7 +621,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);
gfx::ZoomScale resolution = AsyncPanZoomController::CalculateResolution(metrics);
gfxSize 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/*?*/ =
@ -1372,9 +1371,7 @@ 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;
@ -1386,7 +1383,7 @@ TabChild::RecvUpdateDimensions(const nsRect& rect,
mOuterRect.height = rect.height;
mOrientation = orientation;
mInnerSize = gfx::ToIntSize(size);
mInnerSize = size;
mWidget->Resize(0, 0, size.width, size.height,
true);
@ -1486,7 +1483,7 @@ TabChild::RecvUpdateFrame(const FrameMetrics& aFrameMetrics)
utils->SetScrollPositionClampingScrollPortSize(
cssCompositedRect.width, cssCompositedRect.height);
ScrollWindowTo(window, aFrameMetrics.mScrollOffset);
gfx::ZoomScale resolution = AsyncPanZoomController::CalculateResolution(
gfxSize resolution = AsyncPanZoomController::CalculateResolution(
aFrameMetrics);
utils->SetResolution(resolution.width, resolution.height);

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

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

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

@ -6,12 +6,10 @@
#ifndef GFX_FRAMEMETRICS_H
#define GFX_FRAMEMETRICS_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 "gfxPoint.h"
#include "gfxTypes.h"
#include "nsRect.h"
#include "mozilla/gfx/Rect.h"
namespace mozilla {
namespace layers {
@ -82,14 +80,18 @@ public:
return mScrollId != NULL_SCROLL_ID;
}
gfx::ZoomScale LayersPixelsPerCSSPixel() const
gfxSize LayersPixelsPerCSSPixel() const
{
return mResolution * mDevPixelsPerCSSPixel;
}
gfx::Point GetScrollOffsetInLayerPixels() const
gfxPoint GetScrollOffsetInLayerPixels() const
{
return mScrollOffset * LayersPixelsPerCSSPixel();
return gfxPoint(
static_cast<gfx::Float>(
mScrollOffset.x * LayersPixelsPerCSSPixel().width),
static_cast<gfx::Float>(
mScrollOffset.y * LayersPixelsPerCSSPixel().height));
}
// ---------------------------------------------------------------------------
@ -112,7 +114,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.
gfx::IntRect mCompositionBounds;
nsIntRect mCompositionBounds;
// |mScrollableRect|, stored in device pixels. DECPRECATED, DO NOT USE.
//
@ -123,7 +125,7 @@ public:
//
// FIXME/bug 785929: Is this really necessary? Can it not be calculated from
// |mScrollableRect| whenever it's needed?
gfx::IntRect mContentRect;
nsIntRect mContentRect;
// ---------------------------------------------------------------------------
// The following metrics are all in CSS pixels. They are not in any uniform
@ -214,7 +216,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.
gfx::ZoomScale mResolution;
gfxSize mResolution;
// The resolution-independent "user zoom". For example, if a page
// configures the viewport to a zoom value of 2x, then this member
@ -229,7 +231,7 @@ public:
//
// When this is not true, we're probably asynchronously sampling a
// zoom animation for content.
gfx::ZoomScale mZoom;
gfxSize 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

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

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

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

@ -73,7 +73,7 @@ struct BasicTiledLayerPaintData {
gfx::Point mScrollOffset;
gfx3DMatrix mTransformScreenToLayer;
nsIntRect mLayerCriticalDisplayPort;
gfx::ZoomScale mResolution;
gfxSize mResolution;
nsIntRect mCompositionBounds;
uint16_t mLowPrecisionPaintCount;
bool mPaintFinished : 1;
@ -121,8 +121,8 @@ public:
}
}
const gfx::ZoomScale& GetFrameResolution() { return mFrameResolution; }
void SetFrameResolution(const gfx::ZoomScale& aResolution) { mFrameResolution = aResolution; }
const gfxSize& GetFrameResolution() { return mFrameResolution; }
void SetFrameResolution(const gfxSize& aResolution) { mFrameResolution = aResolution; }
bool HasFormatChanged(BasicTiledThebesLayer* aThebesLayer) const;
protected:
@ -147,7 +147,7 @@ private:
BasicTiledThebesLayer* mThebesLayer;
LayerManager::DrawThebesLayerCallback mCallback;
void* mCallbackData;
gfx::ZoomScale mFrameResolution;
gfxSize 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 gfx::ZoomScale& aResolution,
const gfxSize& aResolution,
bool aIsRepeated);
/**
@ -261,7 +261,7 @@ private:
const gfx3DMatrix& aTransform,
const nsIntRect& aCompositionBounds,
const gfx::Point& aScrollOffset,
const gfx::ZoomScale& aResolution,
const gfxSize& aResolution,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData);

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

@ -18,7 +18,6 @@
#include "nsThreadUtils.h"
#include "Layers.h"
#include "AnimationCommon.h"
#include "gfx2DGlue.h"
#include <algorithm>
using namespace mozilla::css;
@ -193,10 +192,6 @@ AsyncPanZoomController::~AsyncPanZoomController() {
}
inline void AsyncPanZoomController::ScrollBy(const gfx::Point& aOffset) {
mFrameMetrics.mScrollOffset += aOffset;
}
void
AsyncPanZoomController::Destroy()
{
@ -212,12 +207,12 @@ AsyncPanZoomController::GetTouchStartTolerance()
}
static gfx::Point
WidgetSpaceToCompensatedViewportSpace(const nsIntPoint& aPoint,
WidgetSpaceToCompensatedViewportSpace(const gfx::Point& 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(gfx::ToIntPoint(aPoint));
gfx::Point pt(aPoint);
pt = pt / aCurrentZoom;
// FIXME/bug 775451: this doesn't attempt to compensate for content transforms
@ -238,8 +233,10 @@ AsyncPanZoomController::ReceiveInputEvent(const nsInputEvent& aEvent,
{
MonitorAutoLock monitor(mMonitor);
currentResolution = CalculateResolution(mFrameMetrics).width;
currentScrollOffset = mFrameMetrics.mScrollOffset;
lastScrollOffset = mLastContentPaintMetrics.mScrollOffset;
currentScrollOffset = gfx::Point(mFrameMetrics.mScrollOffset.x,
mFrameMetrics.mScrollOffset.y);
lastScrollOffset = gfx::Point(mLastContentPaintMetrics.mScrollOffset.x,
mLastContentPaintMetrics.mScrollOffset.y);
}
nsEventStatus status;
@ -267,7 +264,8 @@ AsyncPanZoomController::ReceiveInputEvent(const nsInputEvent& aEvent,
nsIDOMTouch* touch = touches[i];
if (touch) {
gfx::Point refPoint = WidgetSpaceToCompensatedViewportSpace(
touch->mRefPoint, currentResolution);
gfx::Point(touch->mRefPoint.x, touch->mRefPoint.y),
currentResolution);
touch->mRefPoint = nsIntPoint(refPoint.x, refPoint.y);
}
}
@ -275,7 +273,8 @@ AsyncPanZoomController::ReceiveInputEvent(const nsInputEvent& aEvent,
}
default: {
gfx::Point refPoint = WidgetSpaceToCompensatedViewportSpace(
aOutEvent->refPoint, currentResolution);
gfx::Point(aOutEvent->refPoint.x, aOutEvent->refPoint.y),
currentResolution);
aOutEvent->refPoint = nsIntPoint(refPoint.x, refPoint.y);
break;
}
@ -535,7 +534,7 @@ nsEventStatus AsyncPanZoomController::OnScaleBegin(const PinchGestureInput& aEve
}
SetState(PINCHING);
mLastZoomFocus = gfx::ToIntPoint(aEvent.mFocusPoint);
mLastZoomFocus = aEvent.mFocusPoint;
return nsEventStatus_eConsumeNoDefault;
}
@ -557,23 +556,28 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) {
MonitorAutoLock monitor(mMonitor);
gfxFloat resolution = CalculateResolution(mFrameMetrics).width;
gfx::IntPoint focusPoint(gfx::ToIntPoint(aEvent.mFocusPoint));
gfx::Point focusChange(gfx::Point(mLastZoomFocus - focusPoint) / resolution);
gfxFloat userZoom = mFrameMetrics.mZoom.width;
nsIntPoint focusPoint = aEvent.mFocusPoint;
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,
// then reduce the displacement such that it doesn't.
if (mX.DisplacementWillOverscroll(focusChange.x) != Axis::OVERSCROLL_NONE) {
focusChange.x -= mX.DisplacementWillOverscrollAmount(focusChange.x);
if (mX.DisplacementWillOverscroll(xFocusChange) != Axis::OVERSCROLL_NONE) {
xFocusChange -= mX.DisplacementWillOverscrollAmount(xFocusChange);
}
if (mY.DisplacementWillOverscroll(focusChange.y) != Axis::OVERSCROLL_NONE) {
focusChange.y -= mY.DisplacementWillOverscrollAmount(focusChange.y);
if (mY.DisplacementWillOverscroll(yFocusChange) != Axis::OVERSCROLL_NONE) {
yFocusChange -= mY.DisplacementWillOverscrollAmount(yFocusChange);
}
ScrollBy(focusChange);
ScrollBy(gfx::Point(xFocusChange, yFocusChange));
// 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.
gfx::Point neededDisplacement;
gfxFloat userZoom = mFrameMetrics.mZoom.width;
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);
// If this zoom will take it over 8x zoom in either direction, but it's not
// already there, then normalize it.
@ -583,10 +587,6 @@ 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:
neededDisplacement.x = -mX.ScaleWillOverscrollAmount(spanRatio, focusPoint.x);
neededDisplacementX = -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:
neededDisplacement.y = -mY.ScaleWillOverscrollAmount(spanRatio, focusPoint.y);
neededDisplacementY = -mY.ScaleWillOverscrollAmount(spanRatio, focusPoint.y);
break;
case Axis::OVERSCROLL_BOTH:
doScale = false;
@ -624,7 +624,9 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) {
if (doScale) {
ScaleWithFocus(userZoom * spanRatio, focusPoint);
ScrollBy(neededDisplacement);
if (neededDisplacementX != 0 || neededDisplacementY != 0) {
ScrollBy(gfx::Point(neededDisplacementX, neededDisplacementY));
}
ScheduleComposite();
// We don't want to redraw on every scale, so don't use
@ -656,7 +658,8 @@ nsEventStatus AsyncPanZoomController::OnLongPress(const TapGestureInput& aEvent)
gfxFloat resolution = CalculateResolution(mFrameMetrics).width;
gfx::Point point = WidgetSpaceToCompensatedViewportSpace(
aEvent.mPoint, resolution);
gfx::Point(aEvent.mPoint.x, aEvent.mPoint.y),
resolution);
mGeckoContentController->HandleLongTap(nsIntPoint(NS_lround(point.x),
NS_lround(point.y)));
return nsEventStatus_eConsumeNoDefault;
@ -674,7 +677,8 @@ nsEventStatus AsyncPanZoomController::OnSingleTapConfirmed(const TapGestureInput
gfxFloat resolution = CalculateResolution(mFrameMetrics).width;
gfx::Point point = WidgetSpaceToCompensatedViewportSpace(
aEvent.mPoint, resolution);
gfx::Point(aEvent.mPoint.x, aEvent.mPoint.y),
resolution);
mGeckoContentController->HandleSingleTap(nsIntPoint(NS_lround(point.x),
NS_lround(point.y)));
return nsEventStatus_eConsumeNoDefault;
@ -689,7 +693,8 @@ nsEventStatus AsyncPanZoomController::OnDoubleTap(const TapGestureInput& aEvent)
if (mAllowZoom) {
gfxFloat resolution = CalculateResolution(mFrameMetrics).width;
gfx::Point point = WidgetSpaceToCompensatedViewportSpace(
aEvent.mPoint, resolution);
gfx::Point(aEvent.mPoint.x, aEvent.mPoint.y),
resolution);
mGeckoContentController->HandleDoubleTap(nsIntPoint(NS_lround(point.x),
NS_lround(point.y)));
}
@ -759,15 +764,15 @@ void AsyncPanZoomController::TrackTouch(const MultiTouchInput& aEvent) {
// larger swipe should move you a shorter distance.
gfxFloat inverseResolution = 1 / CalculateResolution(mFrameMetrics).width;
gfx::Point displacement(
mX.GetDisplacementForDuration(inverseResolution, timeDelta),
mY.GetDisplacementForDuration(inverseResolution, timeDelta));
if (fabs(displacement.x) <= EPSILON && fabs(displacement.y) <= EPSILON) {
float xDisplacement = mX.GetDisplacementForDuration(inverseResolution,
timeDelta);
float yDisplacement = mY.GetDisplacementForDuration(inverseResolution,
timeDelta);
if (fabs(xDisplacement) <= EPSILON && fabs(yDisplacement) <= EPSILON) {
return;
}
ScrollBy(displacement);
ScrollBy(gfx::Point(xDisplacement, yDisplacement));
ScheduleComposite();
TimeDuration timePaintDelta = TimeStamp::Now() - mPreviousPaintStartTime;
@ -823,6 +828,14 @@ 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;
@ -833,15 +846,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 = gfx::IntRect(pageSize.x, pageSize.y,
pageSize.width, pageSize.height);
metrics.mContentRect = nsIntRect(pageSize.x, pageSize.y,
pageSize.width, pageSize.height);
metrics.mScrollableRect = aCSSPageRect;
mFrameMetrics = metrics;
}
void AsyncPanZoomController::ScaleWithFocus(float aZoom,
const gfx::IntPoint& aFocus) {
const nsIntPoint& aFocus) {
float zoomFactor = aZoom / mFrameMetrics.mZoom.width;
gfxFloat resolution = CalculateResolution(mFrameMetrics).width;
@ -910,7 +923,7 @@ const gfx::Rect AsyncPanZoomController::CalculatePendingDisplayPort(
aEstimatedPaintDuration > EPSILON ? aEstimatedPaintDuration : 1.0;
gfxFloat resolution = CalculateResolution(aFrameMetrics).width;
gfx::IntRect compositionBounds = aFrameMetrics.mCompositionBounds;
nsIntRect compositionBounds = aFrameMetrics.mCompositionBounds;
compositionBounds.ScaleInverseRoundIn(resolution);
gfx::Rect scrollableRect = aFrameMetrics.mScrollableRect;
@ -984,25 +997,31 @@ const gfx::Rect AsyncPanZoomController::CalculatePendingDisplayPort(
return displayPort;
}
/*static*/ gfx::ZoomScale
/*static*/ gfxSize
AsyncPanZoomController::CalculateIntrinsicScale(const FrameMetrics& aMetrics)
{
gfx::Float intrinsicScale = gfx::Float(aMetrics.mCompositionBounds.width) /
gfx::Float(aMetrics.mViewport.width);
return gfx::ZoomScale(intrinsicScale, intrinsicScale);
gfxFloat intrinsicScale = (gfxFloat(aMetrics.mCompositionBounds.width) /
gfxFloat(aMetrics.mViewport.width));
return gfxSize(intrinsicScale, intrinsicScale);
}
/*static*/ gfx::ZoomScale
/*static*/ gfxSize
AsyncPanZoomController::CalculateResolution(const FrameMetrics& aMetrics)
{
return CalculateIntrinsicScale(aMetrics) * aMetrics.mZoom;
gfxSize intrinsicScale = CalculateIntrinsicScale(aMetrics);
gfxSize userZoom = aMetrics.mZoom;
return gfxSize(intrinsicScale.width * userZoom.width,
intrinsicScale.height * userZoom.height);
}
/*static*/ gfx::Rect
AsyncPanZoomController::CalculateCompositedRectInCssPixels(const FrameMetrics& aMetrics)
{
gfx::ZoomScale resolution = CalculateResolution(aMetrics);
gfx::Rect rect(aMetrics.mCompositionBounds);
gfxSize resolution = CalculateResolution(aMetrics);
gfx::Rect rect(aMetrics.mCompositionBounds.x,
aMetrics.mCompositionBounds.y,
aMetrics.mCompositionBounds.width,
aMetrics.mCompositionBounds.height);
rect.ScaleInverseRoundIn(resolution.width, resolution.height);
return rect;
}
@ -1084,7 +1103,7 @@ void AsyncPanZoomController::RequestContentRepaint() {
mWaitingForContentToPaint = true;
// Set the zoom back to what it was for the purpose of logic control.
mFrameMetrics.mZoom = gfx::ZoomScale(actualZoom, actualZoom);
mFrameMetrics.mZoom = gfxSize(actualZoom, actualZoom);
}
void
@ -1110,12 +1129,12 @@ bool AsyncPanZoomController::SampleContentTransformForFrame(const TimeStamp& aSa
const gfx3DMatrix& currentTransform = aLayer->GetTransform();
// Scales on the root layer, on what's currently painted.
gfx::ZoomScale rootScale(currentTransform.GetXScale(),
currentTransform.GetYScale());
gfxSize rootScale(currentTransform.GetXScale(),
currentTransform.GetYScale());
gfx::Point metricsScrollOffset(0, 0);
gfx::Point scrollOffset;
gfx::ZoomScale localScale;
gfxPoint metricsScrollOffset(0, 0);
gfxPoint scrollOffset;
gfxSize localScale;
const FrameMetrics& frame = aLayer->GetFrameMetrics();
{
MonitorAutoLock mon(mMonitor);
@ -1139,7 +1158,7 @@ bool AsyncPanZoomController::SampleContentTransformForFrame(const TimeStamp& aSa
gfxFloat endZoom = mEndZoomToMetrics.mZoom.width;
gfxFloat sampledZoom = (endZoom * sampledPosition +
startZoom * (1 - sampledPosition));
mFrameMetrics.mZoom = gfx::ZoomScale(sampledZoom, sampledZoom);
mFrameMetrics.mZoom = gfxSize(sampledZoom, sampledZoom);
mFrameMetrics.mScrollOffset = gfx::Point(
mEndZoomToMetrics.mScrollOffset.x * sampledPosition +
@ -1174,7 +1193,7 @@ bool AsyncPanZoomController::SampleContentTransformForFrame(const TimeStamp& aSa
metricsScrollOffset = frame.GetScrollOffsetInLayerPixels();
}
scrollOffset = mFrameMetrics.mScrollOffset;
scrollOffset = gfxPoint(mFrameMetrics.mScrollOffset.x, mFrameMetrics.mScrollOffset.y);
mCurrentAsyncScrollOffset = mFrameMetrics.mScrollOffset;
}
@ -1205,7 +1224,7 @@ bool AsyncPanZoomController::SampleContentTransformForFrame(const TimeStamp& aSa
mAsyncScrollTimeout);
}
gfx::Point scrollCompensation(
gfxPoint scrollCompensation(
(scrollOffset / rootScale - metricsScrollOffset) * localScale);
*aNewTransform = ViewTransform(-scrollCompensation, localScale);
@ -1255,9 +1274,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.
gfx::ZoomScale previousResolution = CalculateResolution(mFrameMetrics);
gfxSize previousResolution = CalculateResolution(mFrameMetrics);
mFrameMetrics.mViewport = aViewportFrame.mViewport;
gfx::ZoomScale newResolution = CalculateResolution(mFrameMetrics);
gfxSize newResolution = CalculateResolution(mFrameMetrics);
needContentRepaint |= (previousResolution != newResolution);
}
@ -1287,17 +1306,18 @@ const FrameMetrics& AsyncPanZoomController::GetFrameMetrics() {
return mFrameMetrics;
}
void AsyncPanZoomController::UpdateCompositionBounds(const gfx::IntRect& aCompositionBounds) {
void AsyncPanZoomController::UpdateCompositionBounds(const nsIntRect& aCompositionBounds) {
MonitorAutoLock mon(mMonitor);
bool wasEmpty = mFrameMetrics.mCompositionBounds.IsEmpty();
nsIntRect oldCompositionBounds = mFrameMetrics.mCompositionBounds;
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.IsEmpty() && !wasEmpty) {
if (aCompositionBounds.width && aCompositionBounds.height &&
oldCompositionBounds.width && oldCompositionBounds.height) {
SetZoomAndResolution(mFrameMetrics.mZoom.width);
// Repaint on a rotation so that our new resolution gets properly updated.
@ -1317,23 +1337,23 @@ void AsyncPanZoomController::DetectScrollableSubframe() {
}
void AsyncPanZoomController::ZoomToRect(const gfxRect& aRect) {
gfx::Rect zoomToRect(gfx::ToRect(aRect));
gfx::Rect zoomToRect(gfx::Rect(aRect.x, aRect.y, aRect.width, aRect.height));
SetState(ANIMATING_ZOOM);
{
MonitorAutoLock mon(mMonitor);
gfx::IntRect compositionBounds = mFrameMetrics.mCompositionBounds;
nsIntRect compositionBounds = mFrameMetrics.mCompositionBounds;
gfx::Rect cssPageRect = mFrameMetrics.mScrollableRect;
gfx::Point scrollOffset = mFrameMetrics.mScrollOffset;
gfx::ZoomScale resolution = CalculateResolution(mFrameMetrics);
gfxSize 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
gfx::IntRect cssCompositionBounds = compositionBounds;
nsIntRect cssCompositionBounds = compositionBounds;
cssCompositionBounds.ScaleInverseRoundIn(resolution.width,
resolution.height);
cssCompositionBounds.MoveBy(scrollOffset.x, scrollOffset.y);
@ -1351,7 +1371,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;
@ -1362,13 +1382,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) {
gfx::IntRect cssCompositionBounds = compositionBounds;
nsIntRect cssCompositionBounds = compositionBounds;
cssCompositionBounds.ScaleInverseRoundIn(resolution.width,
resolution.height);
cssCompositionBounds.MoveBy(scrollOffset.x, scrollOffset.y);
@ -1389,7 +1409,7 @@ void AsyncPanZoomController::ZoomToRect(const gfxRect& aRect) {
}
gfxFloat targetFinalZoom = clamped(targetZoom, mMinZoom, mMaxZoom);
mEndZoomToMetrics.mZoom = gfx::ZoomScale(targetFinalZoom, targetFinalZoom);
mEndZoomToMetrics.mZoom = gfxSize(targetFinalZoom, targetFinalZoom);
mStartZoomToMetrics = mFrameMetrics;
mEndZoomToMetrics.mScrollOffset =
@ -1457,7 +1477,7 @@ void AsyncPanZoomController::TimeoutTouchListeners() {
void AsyncPanZoomController::SetZoomAndResolution(float aZoom) {
mMonitor.AssertCurrentThreadOwns();
mFrameMetrics.mZoom = gfx::ZoomScale(aZoom, aZoom);
mFrameMetrics.mZoom = gfxSize(aZoom, aZoom);
mFrameMetrics.mResolution = CalculateResolution(mFrameMetrics);
}
@ -1485,7 +1505,8 @@ void AsyncPanZoomController::SendAsyncScrollEvent() {
gfx::Rect contentRect;
gfx::Size scrollableSize;
{
scrollableSize = mFrameMetrics.mScrollableRect.Size();
scrollableSize = gfx::Size(mFrameMetrics.mScrollableRect.width,
mFrameMetrics.mScrollableRect.height);
contentRect =
AsyncPanZoomController::CalculateCompositedRectInCssPixels(mFrameMetrics);
contentRect.MoveTo(mCurrentAsyncScrollOffset);

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

@ -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 gfx::IntRect& aCompositionBounds);
void UpdateCompositionBounds(const nsIntRect& 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 gfx::ZoomScale CalculateIntrinsicScale(const FrameMetrics& aMetrics);
static gfxSize 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 gfx::ZoomScale CalculateResolution(const FrameMetrics& aMetrics);
static gfxSize 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 gfx::IntPoint& aFocus);
void ScaleWithFocus(float aScale, const nsIntPoint& 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).
gfx::IntPoint mLastZoomFocus;
nsIntPoint 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.

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

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

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

@ -38,7 +38,6 @@
#include "gfxPlatform.h"
#include "mozilla/dom/ScreenOrientation.h"
#include "mozilla/AutoRestore.h"
#include "gfx2DGlue.h"
using namespace base;
using namespace mozilla;
@ -475,7 +474,7 @@ CompositorParent::ScheduleComposition()
}
void
CompositorParent::SetTransformation(float aScale, gfx::IntPoint aScrollOffset)
CompositorParent::SetTransformation(float aScale, nsIntPoint aScrollOffset)
{
mXScale = aScale;
mYScale = aScale;
@ -872,8 +871,8 @@ CompositorParent::ApplyAsyncContentTransformToTree(TimeStamp aCurrentFrame,
TransformFixedLayers(
aLayer,
gfx::ThebesPoint(-treeTransform.mTranslation / treeTransform.mScale),
gfxSize(treeTransform.mScale.width, treeTransform.mScale.height));
-treeTransform.mTranslation / treeTransform.mScale,
treeTransform.mScale);
appliedTransform = true;
}
@ -907,8 +906,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;
gfx::Point scrollOffsetLayersPixels(metrics.GetScrollOffsetInLayerPixels());
gfx::IntPoint scrollOffsetDevPixels(
gfxPoint scrollOffsetLayersPixels(metrics.GetScrollOffsetInLayerPixels());
nsIntPoint scrollOffsetDevPixels(
NS_lround(scrollOffsetLayersPixels.x * devPixelRatioX),
NS_lround(scrollOffsetLayersPixels.y * devPixelRatioY));
@ -929,7 +928,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);
gfx::IntRect displayPortDevPixels(
nsIntRect displayPortDevPixels(
NS_lround(displayPortLayersPixels.x * devPixelRatioX),
NS_lround(displayPortLayersPixels.y * devPixelRatioY),
NS_lround(displayPortLayersPixels.width * devPixelRatioX),
@ -951,16 +950,16 @@ CompositorParent::TransformScrollableLayer(Layer* aLayer, const gfx3DMatrix& aRo
float tempScaleDiffX = rootScaleX * mXScale;
float tempScaleDiffY = rootScaleY * mYScale;
gfx::IntPoint metricsScrollOffset(0, 0);
nsIntPoint metricsScrollOffset(0, 0);
if (metrics.IsScrollable()) {
metricsScrollOffset = scrollOffsetDevPixels;
}
gfx::IntPoint scrollCompensation(
nsIntPoint scrollCompensation(
(mScrollOffset.x / tempScaleDiffX - metricsScrollOffset.x) * mXScale,
(mScrollOffset.y / tempScaleDiffY - metricsScrollOffset.y) * mYScale);
treeTransform = gfx3DMatrix(ViewTransform(gfx::Point(-scrollCompensation),
gfx::ZoomScale(mXScale, mYScale)));
treeTransform = gfx3DMatrix(ViewTransform(-scrollCompensation,
gfxSize(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
@ -1041,10 +1040,8 @@ CompositorParent::TransformShadowTree(TimeStamp aCurrentFrame)
}
void
CompositorParent::SetFirstPaintViewport(const gfx::IntPoint& aOffset,
float aZoom,
const gfx::IntRect& aPageRect,
const gfx::Rect& aCssPageRect)
CompositorParent::SetFirstPaintViewport(const nsIntPoint& aOffset, float aZoom,
const nsIntRect& aPageRect, const gfx::Rect& aCssPageRect)
{
#ifdef MOZ_WIDGET_ANDROID
AndroidBridge::Bridge()->SetFirstPaintViewport(aOffset, aZoom, aPageRect, aCssPageRect);
@ -1060,11 +1057,9 @@ CompositorParent::SetPageRect(const gfx::Rect& aCssPageRect)
}
void
CompositorParent::SyncViewportInfo(const gfx::IntRect& aDisplayPort,
float aDisplayResolution,
bool aLayersUpdated,
gfx::IntPoint& aScrollOffset,
float& aScaleX, float& aScaleY)
CompositorParent::SyncViewportInfo(const nsIntRect& aDisplayPort,
float aDisplayResolution, bool aLayersUpdated,
nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY)
{
#ifdef MOZ_WIDGET_ANDROID
AndroidBridge::Bridge()->SyncViewportInfo(aDisplayPort, aDisplayResolution, aLayersUpdated,

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

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

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

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

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

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

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

@ -166,7 +166,7 @@ ComputeShadowTreeTransform(nsIFrame* aContainerFrame,
nsIntPoint scrollOffset =
aConfig.mScrollOffset.ToNearestPixels(auPerDevPixel);
// metricsScrollOffset is in layer coordinates.
gfx::Point metricsScrollOffset = aMetrics->GetScrollOffsetInLayerPixels();
gfxPoint 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(
gfx::IntRect(0, 0, width, height));
nsIntRect(0, 0, width, height));
}
}

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

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

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

@ -329,15 +329,10 @@ public:
void EnableNetworkNotifications();
void DisableNetworkNotifications();
void SetFirstPaintViewport(const gfx::IntPoint& aOffset,
float aZoom,
const gfx::IntRect& aPageRect,
const gfx::Rect& aCssPageRect);
void SetFirstPaintViewport(const nsIntPoint& aOffset, float aZoom, const nsIntRect& aPageRect, const gfx::Rect& aCssPageRect);
void SetPageRect(const gfx::Rect& aCssPageRect);
void SyncViewportInfo(const gfx::IntRect& aDisplayPort,
float aDisplayResolution, bool aLayersUpdated,
gfx::IntPoint& aScrollOffset,
float& aScaleX, float& aScaleY);
void SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated,
nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY);
void AddPluginView(jobject view, const gfxRect& rect, bool isFullScreen);
void RemovePluginView(jobject view, bool isFullScreen);

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

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

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

@ -254,15 +254,10 @@ public:
AndroidGeckoLayerClient() {}
AndroidGeckoLayerClient(jobject jobj) { Init(jobj); }
void SetFirstPaintViewport(const gfx::IntPoint& aOffset,
float aZoom,
const gfx::IntRect& aPageRect,
const gfx::Rect& aCssPageRect);
void SetFirstPaintViewport(const nsIntPoint& aOffset, float aZoom, const nsIntRect& aPageRect, const gfx::Rect& aCssPageRect);
void SetPageRect(const gfx::Rect& aCssPageRect);
void SyncViewportInfo(const gfx::IntRect& aDisplayPort,
float aDisplayResolution, bool aLayersUpdated,
gfx::IntPoint& aScrollOffset,
float& aScaleX, float& aScaleY);
void SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated,
nsIntPoint& 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);