Bug 877728 - Convert the scroll offset out-param to SyncViewportInfo from nsIntPoint to ScreenPoint. r=BenWa

Also deletes a bunch of dead code, and makes some variables local
variables instead of member variables since they are only used in
a single function and don't need to be persisted.
This commit is contained in:
Kartikaya Gupta 2013-06-03 09:53:32 -04:00
parent 83f51d55ac
commit d45ced53de
9 changed files with 25 additions and 41 deletions

View File

@ -26,15 +26,6 @@ using namespace mozilla::dom;
namespace mozilla {
namespace layers {
void
AsyncCompositionManager::SetTransformation(float aScale,
const nsIntPoint& aScrollOffset)
{
mXScale = aScale;
mYScale = aScale;
mScrollOffset = aScrollOffset;
}
enum Op { Resolve, Detach };
static bool
@ -454,8 +445,11 @@ AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer, const gfx3DMatr
gfx::Margin fixedLayerMargins(0, 0, 0, 0);
gfx::Point offset(0, 0);
ScreenPoint scrollOffset(0, 0);
float scaleX = 1.0,
scaleY = 1.0;
SyncViewportInfo(displayPortDevPixels, 1/rootScaleX, mLayersUpdated,
mScrollOffset, mXScale, mYScale, fixedLayerMargins,
scrollOffset, scaleX, scaleY, fixedLayerMargins,
offset);
mLayersUpdated = false;
@ -468,8 +462,8 @@ AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer, const gfx3DMatr
// primary scrollable layer. We compare this to the desired zoom and scroll
// offset in the view transform we obtained from Java in order to compute the
// transformation we need to apply.
float tempScaleDiffX = rootScaleX * mXScale;
float tempScaleDiffY = rootScaleY * mYScale;
float tempScaleDiffX = rootScaleX * scaleX;
float tempScaleDiffY = rootScaleY * scaleY;
nsIntPoint metricsScrollOffset(0, 0);
if (metrics.IsScrollable()) {
@ -477,13 +471,13 @@ AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer, const gfx3DMatr
}
nsIntPoint scrollCompensation(
(mScrollOffset.x / tempScaleDiffX - metricsScrollOffset.x) * mXScale,
(mScrollOffset.y / tempScaleDiffY - metricsScrollOffset.y) * mYScale);
(scrollOffset.x / tempScaleDiffX - metricsScrollOffset.x) * scaleX,
(scrollOffset.y / tempScaleDiffY - metricsScrollOffset.y) * scaleY);
treeTransform = gfx3DMatrix(ViewTransform(-scrollCompensation,
gfxSize(mXScale, mYScale)));
gfxSize(scaleX, scaleY)));
// Translate fixed position layers so that they stay in the correct position
// when mScrollOffset and metricsScrollOffset differ.
// when scrollOffset and metricsScrollOffset differ.
gfxPoint fixedOffset;
gfxSize scaleDiff;
@ -494,7 +488,7 @@ AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer, const gfx3DMatr
fixedOffset.x = -metricsScrollOffset.x;
scaleDiff.width = std::min(1.0f, metrics.mCompositionBounds.width / (float)mContentRect.width);
} else {
fixedOffset.x = clamped(mScrollOffset.x / tempScaleDiffX, (float)mContentRect.x,
fixedOffset.x = clamped(scrollOffset.x / tempScaleDiffX, (float)mContentRect.x,
mContentRect.XMost() - metrics.mCompositionBounds.width / tempScaleDiffX) -
metricsScrollOffset.x;
scaleDiff.width = tempScaleDiffX;
@ -504,7 +498,7 @@ AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer, const gfx3DMatr
fixedOffset.y = -metricsScrollOffset.y;
scaleDiff.height = std::min(1.0f, metrics.mCompositionBounds.height / (float)mContentRect.height);
} else {
fixedOffset.y = clamped(mScrollOffset.y / tempScaleDiffY, (float)mContentRect.y,
fixedOffset.y = clamped(scrollOffset.y / tempScaleDiffY, (float)mContentRect.y,
mContentRect.YMost() - metrics.mCompositionBounds.height / tempScaleDiffY) -
metricsScrollOffset.y;
scaleDiff.height = tempScaleDiffY;
@ -589,7 +583,7 @@ void
AsyncCompositionManager::SyncViewportInfo(const nsIntRect& aDisplayPort,
float aDisplayResolution,
bool aLayersUpdated,
nsIntPoint& aScrollOffset,
ScreenPoint& aScrollOffset,
float& aScaleX, float& aScaleY,
gfx::Margin& aFixedLayerMargins,
gfx::Point& aOffset)

View File

@ -57,9 +57,7 @@ class AsyncCompositionManager MOZ_FINAL : public RefCounted<AsyncCompositionMana
friend class AutoResolveRefLayers;
public:
AsyncCompositionManager(LayerManagerComposite* aManager)
: mXScale(1.0)
, mYScale(1.0)
, mLayerManager(aManager)
: mLayerManager(aManager)
, mIsFirstPaint(false)
, mLayersUpdated(false)
, mReadyForCompose(true)
@ -108,8 +106,6 @@ public:
// particular document.
bool IsFirstPaint() { return mIsFirstPaint; }
void SetTransformation(float aScale, const nsIntPoint& aScrollOffset);
private:
void TransformScrollableLayer(Layer* aLayer, const gfx3DMatrix& aRootTransform);
// Return true if an AsyncPanZoomController content transform was
@ -126,7 +122,7 @@ private:
void SyncViewportInfo(const nsIntRect& aDisplayPort,
float aDisplayResolution,
bool aLayersUpdated,
nsIntPoint& aScrollOffset,
ScreenPoint& aScrollOffset,
float& aScaleX, float& aScaleY,
gfx::Margin& aFixedLayerMargins,
gfx::Point& aOffset);
@ -167,9 +163,6 @@ private:
void DetachRefLayers();
TargetConfig mTargetConfig;
float mXScale;
float mYScale;
nsIntPoint mScrollOffset;
nsIntRect mContentRect;
nsRefPtr<LayerManagerComposite> mLayerManager;

View File

@ -423,12 +423,6 @@ CompositorParent::ScheduleComposition()
}
}
void
CompositorParent::SetTransformation(float aScale, nsIntPoint aScrollOffset)
{
mCompositionManager->SetTransformation(aScale, aScrollOffset);
}
void
CompositorParent::Composite()
{

View File

@ -73,8 +73,6 @@ public:
LayerManagerComposite* GetLayerManager() { return mLayerManager; }
void SetTransformation(float aScale, nsIntPoint aScrollOffset);
void AsyncRender();
// Can be called from any thread

View File

@ -58,6 +58,11 @@ struct LayerPixel {
typedef gfx::RectTyped<LayerPixel> LayerRect;
typedef gfx::IntRectTyped<LayerPixel> LayerIntRect;
struct ScreenPixel {
};
typedef gfx::PointTyped<ScreenPixel> ScreenPoint;
};
#endif

View File

@ -2133,7 +2133,7 @@ AndroidBridge::SetPageRect(const CSSRect& aCssPageRect)
void
AndroidBridge::SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated,
nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY,
ScreenPoint& aScrollOffset, float& aScaleX, float& aScaleY,
gfx::Margin& aFixedLayerMargins, gfx::Point& aOffset)
{
AndroidGeckoLayerClient *client = mLayerClient;

View File

@ -374,7 +374,7 @@ public:
void SetFirstPaintViewport(const nsIntPoint& aOffset, float aZoom, const nsIntRect& aPageRect, const CSSRect& aCssPageRect);
void SetPageRect(const CSSRect& aCssPageRect);
void SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated,
nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY,
ScreenPoint& aScrollOffset, float& aScaleX, float& aScaleY,
gfx::Margin& aFixedLayerMargins, gfx::Point& aOffset);
void SyncFrameMetrics(const gfx::Point& aScrollOffset, float aZoom, const CSSRect& aCssPageRect,
bool aLayersUpdated, const gfx::Rect& aDisplayPort, float aDisplayResolution,

View File

@ -891,7 +891,7 @@ AndroidGeckoLayerClient::SetPageRect(const CSSRect& aCssPageRect)
void
AndroidGeckoLayerClient::SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated,
nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY,
ScreenPoint& aScrollOffset, float& aScaleX, float& aScaleY,
gfx::Margin& aFixedLayerMargins, gfx::Point& aOffset)
{
NS_ASSERTION(!isNull(), "SyncViewportInfo called on null layer client!");
@ -913,7 +913,7 @@ AndroidGeckoLayerClient::SyncViewportInfo(const nsIntRect& aDisplayPort, float a
AndroidViewTransform viewTransform;
viewTransform.Init(viewTransformJObj);
aScrollOffset = nsIntPoint(viewTransform.GetX(env), viewTransform.GetY(env));
aScrollOffset = ScreenPoint(viewTransform.GetX(env), viewTransform.GetY(env));
aScaleX = aScaleY = viewTransform.GetScale(env);
viewTransform.GetFixedLayerMargins(env, aFixedLayerMargins);

View File

@ -272,7 +272,7 @@ public:
void SetFirstPaintViewport(const nsIntPoint& aOffset, float aZoom, const nsIntRect& aPageRect, const CSSRect& aCssPageRect);
void SetPageRect(const CSSRect& aCssPageRect);
void SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated,
nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY,
ScreenPoint& aScrollOffset, float& aScaleX, float& aScaleY,
gfx::Margin& aFixedLayerMargins, gfx::Point& aOffset);
void SyncFrameMetrics(const gfx::Point& aScrollOffset, float aZoom, const CSSRect& aCssPageRect,
bool aLayersUpdated, const gfx::Rect& aDisplayPort, float aDisplayResolution,