summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-08-10 22:42:39 +0200
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-08-10 23:00:45 +0200
commit5af2c260488f04696f01adcf26c24036820f96ff (patch)
treee53ed17543a99bccd4cf71bc7861582f9cae0f7a /android
parentb58777c8b2b2075a071a25bf9fed0ce7fc0c4401 (diff)
LOAndroid3: correctly calculate the tile view rect
Because the tile view rect wasn't correctly calculated, some tiles were deleted and in the same call immediately created again. With this fix the performance increases. Additionally inflate tile view rect by one tile to minimize the undrawn tiles when scrolling. Change-Id: I4b5b2bb31dd4f55babf87503dd37e396f6a5e200
Diffstat (limited to 'android')
-rw-r--r--android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java33
1 files changed, 28 insertions, 5 deletions
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
index a195da097028..d56f45156b70 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
@@ -21,6 +21,7 @@ public class LOKitThread extends Thread {
private TileProvider mTileProvider;
private ViewportMetrics mViewportMetrics;
private String mInputFile;
+ private Rect mOldRect;
LOKitThread(String inputFile) {
mInputFile = inputFile;
@@ -40,7 +41,22 @@ public class LOKitThread extends Thread {
return new Rect(minX, minY, maxX, maxY);
}
+ Rect inflate(Rect rect, int inflateSize) {
+ Rect newRect = new Rect(rect);
+ newRect.left -= inflateSize;
+ newRect.left = newRect.left < 0 ? 0 : newRect.left;
+
+ newRect.top -= inflateSize;
+ newRect.top = newRect.top < 0 ? 0 : newRect.top;
+
+ newRect.right += inflateSize;
+ newRect.bottom += inflateSize;
+
+ return newRect;
+ }
+
private boolean draw() throws InterruptedException {
+ Log.i(LOGTAG, "tilerender draw");
int pageWidth = mTileProvider.getPageWidth();
int pageHeight = mTileProvider.getPageHeight();
@@ -56,18 +72,25 @@ public class LOKitThread extends Thread {
ViewportMetrics metrics = mApplication.getLayerController().getViewportMetrics();
RectF viewport = normlizeRect(metrics);
- Rect rect = roundToTileSize(viewport, TILE_SIZE);
+ Rect rect = inflate(roundToTileSize(viewport, TILE_SIZE), TILE_SIZE);
+
+ mOldRect = rect;
+
+ Log.i(LOGTAG, "tilerender rect: " + rect);
ArrayList<SubTile> removeTiles = new ArrayList<SubTile>();
for (SubTile tile : layerClient.getTiles()) {
- if (!rect.intersects(tile.x, tile.y, tile.x + TILE_SIZE, tile.y + TILE_SIZE)) {
+ Rect tileRect = new Rect(tile.x, tile.y, tile.x + TILE_SIZE, tile.y + TILE_SIZE);
+ if (!Rect.intersects(rect, tileRect)) {
+ Log.i(LOGTAG, "tilerender delete " + tileRect);
removeTiles.add(tile);
}
}
+
layerClient.getTiles().removeAll(removeTiles);
- for (int y = rect.top; y <= rect.bottom; y += TILE_SIZE) {
- for (int x = rect.left; x <= rect.right; x += TILE_SIZE) {
+ for (int y = rect.top; y < rect.bottom; y += TILE_SIZE) {
+ for (int x = rect.left; x < rect.right; x += TILE_SIZE) {
if (x > pageWidth) {
continue;
}
@@ -88,7 +111,7 @@ public class LOKitThread extends Thread {
}
layerClient.endDrawing();
-
+ Log.i(LOGTAG, "tilerender end draw");
return true;
}