From ccf4980df548b574034b0cb2e0e4503c9e178ee2 Mon Sep 17 00:00:00 2001 From: Chris Lord Date: Thu, 26 Jan 2012 20:18:47 +0000 Subject: [PATCH] Bug 721100 - After panning, tap area is offset at wrong place. r=pcwalton When rendering with an offset for MultiTileLayer, the tile origin was moved to compensate, but this lead to there being a mismatch between Gecko's displayport origin and the one recorded on the Java side. Instead of altering the origin, allow setting a render offset on MultiTileLayer instead, so the origin remains correct. --- .../base/gfx/GeckoSoftwareLayerClient.java | 5 ++--- mobile/android/base/gfx/MultiTileLayer.java | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/mobile/android/base/gfx/GeckoSoftwareLayerClient.java b/mobile/android/base/gfx/GeckoSoftwareLayerClient.java index 96125dd4a835..81a80a4bbc49 100644 --- a/mobile/android/base/gfx/GeckoSoftwareLayerClient.java +++ b/mobile/android/base/gfx/GeckoSoftwareLayerClient.java @@ -292,9 +292,7 @@ public class GeckoSoftwareLayerClient extends LayerClient implements GeckoEventL LayerController controller = getLayerController(); PointF displayportOrigin = mGeckoViewport.getDisplayportOrigin(); - Point tileOrigin = PointUtils.round(displayportOrigin); - tileOrigin.offset(-mRenderOffset.x, -mRenderOffset.y); - mTileLayer.setOrigin(tileOrigin); + mTileLayer.setOrigin(PointUtils.round(displayportOrigin)); mTileLayer.setResolution(mGeckoViewport.getZoomFactor()); if (onlyUpdatePageSize) { @@ -323,6 +321,7 @@ public class GeckoSoftwareLayerClient extends LayerClient implements GeckoEventL Rect rect = new Rect(x, y, x + width, y + height); rect.offset(mRenderOffset.x, mRenderOffset.y); ((MultiTileLayer)mTileLayer).invalidate(rect); + ((MultiTileLayer)mTileLayer).setRenderOffset(mRenderOffset); } } finally { endTransaction(mTileLayer); diff --git a/mobile/android/base/gfx/MultiTileLayer.java b/mobile/android/base/gfx/MultiTileLayer.java index ef4652f15672..17260e1b66e8 100644 --- a/mobile/android/base/gfx/MultiTileLayer.java +++ b/mobile/android/base/gfx/MultiTileLayer.java @@ -67,6 +67,7 @@ public class MultiTileLayer extends Layer { private IntSize mBufferSize; private Region mDirtyRegion; private Region mValidRegion; + private Point mRenderOffset; private final LinkedList mTiles; private final HashMap mPositionHash; @@ -78,6 +79,7 @@ public class MultiTileLayer extends Layer { mBufferSize = new IntSize(0, 0); mDirtyRegion = new Region(); mValidRegion = new Region(); + mRenderOffset = new Point(); mTiles = new LinkedList(); mPositionHash = new HashMap(); } @@ -160,6 +162,12 @@ public class MultiTileLayer extends Layer { return new Long((((long)point.x) << 32) | point.y); } + private Point getOffsetOrigin() { + Point origin = new Point(getOrigin()); + origin.offset(-mRenderOffset.x, -mRenderOffset.y); + return origin; + } + /** * Performs the necessary functions to update the specified properties of * a sub-tile. @@ -172,7 +180,7 @@ public class MultiTileLayer extends Layer { // buffer. This is done as SingleTileLayer always updates the // entire width, regardless of the dirty-rect's width, and so // can override existing data. - Point origin = getOrigin(); + Point origin = getOffsetOrigin(); Rect validRect = tile.getValidTextureArea(); validRect.offset(tileOrigin.x - origin.x, tileOrigin.y - origin.y); Region validRegion = new Region(validRect); @@ -226,9 +234,9 @@ public class MultiTileLayer extends Layer { } // Check that we're capable of updating from this origin. - Point origin = getOrigin(); + Point origin = getOffsetOrigin(); if ((origin.x % mTileSize.width) != 0 || (origin.y % mTileSize.height) != 0) { - Log.e(LOGTAG, "MultiTileLayer doesn't support non tile-aligned origins! (" + + Log.e(LOGTAG, "MultiTileLayer doesn't support non tile-aligned buffers! (" + origin.x + ", " + origin.y + ")"); return true; } @@ -395,6 +403,10 @@ public class MultiTileLayer extends Layer { } } + public void setRenderOffset(Point offset) { + mRenderOffset.set(offset.x, offset.y); + } + /** * Invalidates all sub-tiles. This should be called if the source backing * this layer has changed. This method is only valid inside a transaction.