summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-02-13 18:16:51 +0900
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-02-16 09:20:50 +0100
commitc2b8fa6d9e69682344c66c62d30dfacf9ad51f82 (patch)
treee1ab5b9298d659879c47f8db2a163a5893c8ede6
parent1eb2de90bee8a0585655573eaebcc901495edd4d (diff)
android: invalidate all intersecting tiles in one LOEvent
Change-Id: Ic21984016d10a8e3da87b9fb032179cd4f6f7b9f
-rw-r--r--android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java26
-rw-r--r--android/experimental/LOAndroid3/src/java/org/libreoffice/LOEventFactory.java7
-rw-r--r--android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java38
-rw-r--r--android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java7
-rw-r--r--android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java9
5 files changed, 51 insertions, 36 deletions
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java
index a9600ea2433f..c51b4452f48f 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java
@@ -1,12 +1,12 @@
package org.libreoffice;
import android.graphics.PointF;
+import android.graphics.RectF;
import android.view.KeyEvent;
import android.view.MotionEvent;
import org.mozilla.gecko.gfx.ComposedTileLayer;
import org.mozilla.gecko.gfx.IntSize;
-import org.mozilla.gecko.gfx.SubTile;
public class LOEvent implements Comparable<LOEvent> {
public static final int SIZE_CHANGED = 1;
@@ -17,7 +17,7 @@ public class LOEvent implements Comparable<LOEvent> {
public static final int REDRAW = 6;
public static final int TILE_REQUEST = 7;
public static final int THUMBNAIL = 8;
- public static final int TILE_RERENDER = 9;
+ public static final int TILE_INVALIDATION = 9;
public static final int TOUCH = 10;
public static final int KEY_EVENT = 11;
@@ -30,13 +30,12 @@ public class LOEvent implements Comparable<LOEvent> {
public String mFilename;
public TileIdentifier mTileId;
public ComposedTileLayer mComposedTileLayer;
- public boolean mForceRedraw;
- public SubTile mTile;
public String mTouchType;
public MotionEvent mMotionEvent;
public PointF mDocumentTouchCoordinate;
public String mKeyEventType;
public KeyEvent mKeyEvent;
+ public RectF mInvalidationRect;
public LOEvent(int type) {
mType = type;
@@ -47,12 +46,11 @@ public class LOEvent implements Comparable<LOEvent> {
mTypeString = "Size Changed: " + widthPixels + " " + heightPixels;
}
- public LOEvent(int type, ComposedTileLayer composedTileLayer, TileIdentifier tileId, boolean forceRedraw) {
+ public LOEvent(int type, ComposedTileLayer composedTileLayer, TileIdentifier tileId) {
mType = type;
mTypeString = "Tile Request";
mComposedTileLayer = composedTileLayer;
mTileId = tileId;
- mForceRedraw = forceRedraw;
}
public LOEvent(int type, String filename) {
@@ -75,13 +73,7 @@ public class LOEvent implements Comparable<LOEvent> {
public LOEvent(int type, ThumbnailCreator.ThumbnailCreationTask task) {
mType = type;
mTask = task;
- }
-
- public LOEvent(int type, ComposedTileLayer composedTileLayer, SubTile tile) {
- mType = type;
- mTypeString = "Tile Rerender";
- mComposedTileLayer = composedTileLayer;
- mTile = tile;
+ mTypeString = "Thumbnail";
}
public LOEvent(int type, String touchType, MotionEvent motionEvent, PointF documentTouchCoordinate) {
@@ -94,11 +86,17 @@ public class LOEvent implements Comparable<LOEvent> {
public LOEvent(int type, String keyEventType, KeyEvent keyEvent) {
mType = type;
- mTypeString = "KeyEvent";
+ mTypeString = "Key Event";
mKeyEventType = keyEventType;
mKeyEvent = keyEvent;
}
+ public LOEvent(int type, RectF rect) {
+ mType = type;
+ mTypeString = "Tile Invalidation";
+ mInvalidationRect = rect;
+ }
+
public String getTypeString() {
if (mTypeString == null) {
return "Event type: " + mType;
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEventFactory.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEventFactory.java
index b866850750ea..71bceb2c8d92 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEventFactory.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEventFactory.java
@@ -2,7 +2,6 @@ package org.libreoffice;
import org.mozilla.gecko.gfx.ComposedTileLayer;
import org.mozilla.gecko.gfx.IntSize;
-import org.mozilla.gecko.gfx.SubTile;
public class LOEventFactory {
@@ -31,14 +30,10 @@ public class LOEventFactory {
}
public static LOEvent tileRequest(ComposedTileLayer composedTileLayer, TileIdentifier tileID, boolean forceRedraw) {
- return new LOEvent(LOEvent.TILE_REQUEST, composedTileLayer, tileID, forceRedraw);
+ return new LOEvent(LOEvent.TILE_REQUEST, composedTileLayer, tileID);
}
public static LOEvent thumbnail(ThumbnailCreator.ThumbnailCreationTask task) {
return new LOEvent(LOEvent.THUMBNAIL, task);
}
-
- public static LOEvent tileRerender(ComposedTileLayer composedTileLayer, SubTile tile) {
- return new LOEvent(LOEvent.TILE_RERENDER, composedTileLayer, tile);
- }
}
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
index 3536256a3e0b..a737d18fe163 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
@@ -13,6 +13,8 @@ import org.mozilla.gecko.gfx.GeckoLayerClient;
import org.mozilla.gecko.gfx.ImmutableViewportMetrics;
import org.mozilla.gecko.gfx.SubTile;
+import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.PriorityBlockingQueue;
public class LOKitThread extends Thread implements TileProvider.TileInvalidationCallback {
@@ -28,7 +30,7 @@ public class LOKitThread extends Thread implements TileProvider.TileInvalidation
TileProviderFactory.initialize();
}
- private void tileRequest(ComposedTileLayer composedTileLayer, TileIdentifier tileId, boolean forceRedraw) {
+ private void tileRequest(ComposedTileLayer composedTileLayer, TileIdentifier tileId) {
if (mTileProvider == null)
return;
@@ -47,8 +49,9 @@ public class LOKitThread extends Thread implements TileProvider.TileInvalidation
}
private void tileRerender(ComposedTileLayer composedTileLayer, SubTile tile) {
- if (mTileProvider == null)
+ if (mTileProvider == null) {
return;
+ }
if (composedTileLayer.isStillValid(tile.id) && !tile.markedForRemoval) {
mLayerClient.beginDrawing();
@@ -59,6 +62,26 @@ public class LOKitThread extends Thread implements TileProvider.TileInvalidation
}
}
+ private void tileInvalidation(RectF rect) {
+ if (mLayerClient == null || mTileProvider == null) {
+ return;
+ }
+
+ List<SubTile> tiles = new ArrayList<SubTile>();
+ mLayerClient.invalidateTiles(tiles, rect);
+
+ for (SubTile tile : tiles) {
+ mTileProvider.rerenderTile(tile.getImage(), tile.id.x, tile.id.y, tile.id.size, tile.id.zoom);
+ }
+
+ mLayerClient.beginDrawing();
+ for (SubTile tile : tiles) {
+ tile.invalidate();
+ }
+ mLayerClient.endDrawing(mViewportMetrics);
+ mLayerClient.forceRender();
+ }
+
/** Handle the geometry change + draw. */
private void redraw() {
if (mLayerClient == null || mTileProvider == null) {
@@ -159,10 +182,10 @@ public class LOKitThread extends Thread implements TileProvider.TileInvalidation
changePart(event.mPartIndex);
break;
case LOEvent.TILE_REQUEST:
- tileRequest(event.mComposedTileLayer, event.mTileId, event.mForceRedraw);
+ tileRequest(event.mComposedTileLayer, event.mTileId);
break;
- case LOEvent.TILE_RERENDER:
- tileRerender(event.mComposedTileLayer, event.mTile);
+ case LOEvent.TILE_INVALIDATION:
+ tileInvalidation(event.mInvalidationRect);
break;
case LOEvent.THUMBNAIL:
createThumbnail(event.mTask);
@@ -216,10 +239,7 @@ public class LOKitThread extends Thread implements TileProvider.TileInvalidation
@Override
public void invalidate(RectF rect) {
- Log.i(LOGTAG, "Invalidate request: " + rect);
-
- mLayerClient = mApplication.getLayerClient();
- mLayerClient.invalidateTiles(rect);
+ queueEvent(new LOEvent(LOEvent.TILE_INVALIDATION, rect));
}
}
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
index ca25438e7c31..02fa4fa12bc5 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
@@ -1,6 +1,5 @@
package org.mozilla.gecko.gfx;
-import android.app.ActivityManager;
import android.content.ComponentCallbacks2;
import android.content.Context;
import android.content.res.Configuration;
@@ -212,12 +211,12 @@ public abstract class ComposedTileLayer extends Layer implements ComponentCallba
/**
* Invalidate tiles which intersect the input rect
*/
- public void invalidateTiles(RectF cssRect) {
+ public void invalidateTiles(List<SubTile> tilesToInvalidate, RectF cssRect) {
RectF zoomedRect = RectUtils.scale(cssRect, currentZoom);
for (SubTile tile : tiles) {
- if (RectF.intersects(zoomedRect, tile.id.getRectF())) {
- LOKitShell.sendEvent(LOEventFactory.tileRerender(this, tile));
+ if (!tile.markedForRemoval && RectF.intersects(zoomedRect, tile.id.getRectF())) {
+ tilesToInvalidate.add(tile);
}
}
}
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
index 644ef46f9f2b..83a13245af70 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
@@ -15,9 +15,12 @@ import android.util.Log;
import org.libreoffice.LOEvent;
import org.libreoffice.LOEventFactory;
import org.libreoffice.LOKitShell;
+import org.libreoffice.LOKitThread;
import org.mozilla.gecko.ZoomConstraints;
import org.mozilla.gecko.util.FloatUtils;
+import java.util.List;
+
public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
private static final String LOGTAG = GeckoLayerClient.class.getSimpleName();
@@ -388,8 +391,8 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
mRootLayer.clearAndReset();
}
- public void invalidateTiles(RectF rect) {
- mLowResLayer.invalidateTiles(rect);
- mRootLayer.invalidateTiles(rect);
+ public void invalidateTiles(List<SubTile> tilesToInvalidate, RectF rect) {
+ mLowResLayer.invalidateTiles(tilesToInvalidate, rect);
+ mRootLayer.invalidateTiles(tilesToInvalidate, rect);
}
} \ No newline at end of file