Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 5671b1d

Browse files
committed
Bug 858969 - Refactor dynamic toolbar so page is offset and not overlapped. r=kats,nrc
Refactor the dynamic toolbar code so that the ownership of various properties is clearer, and the page is offset by the toolbar instead of being overlapped. This fixes problems with the scroll origin of the page not corresponding to the visible origin on the screen.
1 parent 6b2624d commit 5671b1d

30 files changed

Lines changed: 690 additions & 558 deletions

gfx/layers/Compositor.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,12 @@ class Compositor : public RefCounted<Compositor>
252252
*/
253253
virtual void SetDestinationSurfaceSize(const gfx::IntSize& aSize) = 0;
254254

255+
/**
256+
* Declare an offset to use when rendering layers. This will be ignored when
257+
* rendering to a target instead of the screen.
258+
*/
259+
virtual void SetScreenRenderOffset(const gfx::Point& aOffset) = 0;
260+
255261
/**
256262
* Tell the compositor to actually draw a quad. What to do draw and how it is
257263
* drawn is specified by aEffectChain. aRect is the quad to draw, in user space.

gfx/layers/ipc/CompositorParent.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ CompositorParent::TransformScrollableLayer(Layer* aLayer, const gfx3DMatrix& aRo
885885
const FrameMetrics& metrics = container->GetFrameMetrics();
886886
// We must apply the resolution scale before a pan/zoom transform, so we call
887887
// GetTransform here.
888-
const gfx3DMatrix& currentTransform = aLayer->GetTransform();
888+
gfx3DMatrix currentTransform = aLayer->GetTransform();
889889

890890
gfx3DMatrix treeTransform;
891891

@@ -934,10 +934,15 @@ CompositorParent::TransformScrollableLayer(Layer* aLayer, const gfx3DMatrix& aRo
934934
displayPortDevPixels.y += scrollOffsetDevPixels.y;
935935

936936
gfx::Margin fixedLayerMargins(0, 0, 0, 0);
937+
float offsetX = 0, offsetY = 0;
937938
SyncViewportInfo(displayPortDevPixels, 1/rootScaleX, mLayersUpdated,
938-
mScrollOffset, mXScale, mYScale, fixedLayerMargins);
939+
mScrollOffset, mXScale, mYScale, fixedLayerMargins,
940+
offsetX, offsetY);
939941
mLayersUpdated = false;
940942

943+
// Apply the render offset
944+
mLayerManager->GetCompositor()->SetScreenRenderOffset(gfx::Point(offsetX, offsetY));
945+
941946
// Handle transformations for asynchronous panning and zooming. We determine the
942947
// zoom used by Gecko from the transformation set on the root layer, and we
943948
// determine the scroll offset used by Gecko from the frame metrics of the
@@ -1091,11 +1096,13 @@ void
10911096
CompositorParent::SyncViewportInfo(const nsIntRect& aDisplayPort,
10921097
float aDisplayResolution, bool aLayersUpdated,
10931098
nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY,
1094-
gfx::Margin& aFixedLayerMargins)
1099+
gfx::Margin& aFixedLayerMargins, float& aOffsetX,
1100+
float& aOffsetY)
10951101
{
10961102
#ifdef MOZ_WIDGET_ANDROID
10971103
AndroidBridge::Bridge()->SyncViewportInfo(aDisplayPort, aDisplayResolution, aLayersUpdated,
1098-
aScrollOffset, aScaleX, aScaleY, aFixedLayerMargins);
1104+
aScrollOffset, aScaleX, aScaleY, aFixedLayerMargins,
1105+
aOffsetX, aOffsetY);
10991106
#endif
11001107
}
11011108

gfx/layers/ipc/CompositorParent.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class CompositorParent : public PCompositorParent,
180180
virtual void SetPageRect(const gfx::Rect& aCssPageRect);
181181
virtual void SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated,
182182
nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY,
183-
gfx::Margin& aFixedLayerMargins);
183+
gfx::Margin& aFixedLayerMargins, float& aOffsetX, float& aOffsetY);
184184
void SetEGLSurfaceSize(int width, int height);
185185

186186
private:

gfx/layers/opengl/CompositorOGL.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,9 @@ CompositorOGL::PrepareViewport(const gfx::IntSize& aSize,
621621
viewMatrix.Translate(-gfxPoint(1.0, -1.0));
622622
viewMatrix.Scale(2.0f / float(aSize.width), 2.0f / float(aSize.height));
623623
viewMatrix.Scale(1.0f, -1.0f);
624+
if (!mTarget) {
625+
viewMatrix.Translate(gfxPoint(mRenderOffset.x, mRenderOffset.y));
626+
}
624627

625628
viewMatrix = aWorldTransform * viewMatrix;
626629

gfx/layers/opengl/CompositorOGL.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ class CompositorOGL : public Compositor
9090
*/
9191
virtual void SetDestinationSurfaceSize(const gfx::IntSize& aSize) MOZ_OVERRIDE;
9292

93+
virtual void SetScreenRenderOffset(const gfx::Point& aOffset) MOZ_OVERRIDE {
94+
mRenderOffset = aOffset;
95+
}
96+
9397
virtual void MakeCurrent(MakeCurrentFlags aFlags = 0) MOZ_OVERRIDE {
9498
if (mDestroyed) {
9599
NS_WARNING("Call on destroyed layer manager");
@@ -141,6 +145,8 @@ class CompositorOGL : public Compositor
141145
/** The size of the surface we are rendering to */
142146
nsIntSize mSurfaceSize;
143147

148+
gfx::Point mRenderOffset;
149+
144150
/** Helper-class used by Initialize **/
145151
class ReadDrawFPSPref MOZ_FINAL : public nsRunnable {
146152
public:

0 commit comments

Comments
 (0)