diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2014-10-01 13:43:29 +0200 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2014-10-04 17:49:17 +0200 |
commit | 91507e8e4896c57de367838f5a2ede7301ccd819 (patch) | |
tree | cdc69ab2f0034c0f6278712305fc26e6b658061d /android | |
parent | 594e72904ad0c9862d1379c8d2c48f7af276e5db (diff) |
android: add tileSize parameter to TileProvider
Change-Id: I607dbaa897b17f5b650f10293956c8154da6f43d
Diffstat (limited to 'android')
4 files changed, 15 insertions, 16 deletions
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java index 8050863cccbd..073876e221e3 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java @@ -8,6 +8,7 @@ import org.libreoffice.kit.LibreOfficeKit; import org.libreoffice.kit.Office; import org.mozilla.gecko.gfx.BufferedCairoImage; import org.mozilla.gecko.gfx.CairoImage; +import org.mozilla.gecko.gfx.FloatSize; import org.mozilla.gecko.gfx.LayerController; import java.nio.ByteBuffer; @@ -131,7 +132,7 @@ public class LOKitTileProvider implements TileProvider { } @Override - public CairoImage createTile(float x, float y, float zoom) { + public CairoImage createTile(float x, float y, FloatSize tileSize, float zoom) { ByteBuffer buffer = ByteBuffer.allocateDirect(TILE_SIZE * TILE_SIZE * 4); Bitmap bitmap = Bitmap.createBitmap(TILE_SIZE, TILE_SIZE, Bitmap.Config.ARGB_8888); diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java index 2d81d3e0d1a0..672973c05b7a 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java @@ -4,6 +4,7 @@ import android.graphics.Bitmap; import org.mozilla.gecko.gfx.BufferedCairoImage; import org.mozilla.gecko.gfx.CairoImage; +import org.mozilla.gecko.gfx.FloatSize; import org.mozilla.gecko.gfx.LayerController; public class MockTileProvider implements TileProvider { @@ -35,7 +36,7 @@ public class MockTileProvider implements TileProvider { @Override public int getPageHeight() { - return 630*5; + return 630 * 5; } @Override @@ -44,7 +45,7 @@ public class MockTileProvider implements TileProvider { } @Override - public CairoImage createTile(float x, float y, float zoom) { + public CairoImage createTile(float x, float y, FloatSize tileSize, float zoom) { int tiles = (int) (getPageWidth() / TILE_SIZE) + 1; int tileNumber = (int) ((y / TILE_SIZE) * tiles + (x / TILE_SIZE)); tileNumber %= 9; diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java index 8373ad8f4dfd..ada23608b154 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java @@ -4,6 +4,7 @@ package org.libreoffice; import android.graphics.Bitmap; import org.mozilla.gecko.gfx.CairoImage; +import org.mozilla.gecko.gfx.FloatSize; public interface TileProvider { int getPageWidth(); @@ -12,7 +13,7 @@ public interface TileProvider { boolean isReady(); - CairoImage createTile(float x, float y, float zoom); + CairoImage createTile(float x, float y, FloatSize tileSize, float zoom); void changePart(int partIndex); diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/MultiTileLayer.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/MultiTileLayer.java index eb1ab5ca4482..7d1306e76416 100644 --- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/MultiTileLayer.java +++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/MultiTileLayer.java @@ -56,11 +56,7 @@ public class MultiTileLayer extends Layer { private static int TILE_SIZE = 256; private final List<SubTile> mTiles = new CopyOnWriteArrayList<SubTile>(); private TileProvider tileProvider; - private RectF tileViewPort = new RectF(); - - public MultiTileLayer() { - super(); - } + private RectF currentViewPort = new RectF(); public void invalidate() { for (SubTile layer : mTiles) { @@ -211,10 +207,10 @@ public class MultiTileLayer extends Layer { } public void reevaluateTiles(ImmutableViewportMetrics viewportMetrics) { - RectF newTileViewPort = inflate(roundToTileSize(viewportMetrics.getViewport(), TILE_SIZE), TILE_SIZE); + RectF newCurrentViewPort = inflate(roundToTileSize(viewportMetrics.getViewport(), TILE_SIZE), TILE_SIZE); - if (tileViewPort != newTileViewPort) { - tileViewPort = newTileViewPort; + if (currentViewPort != newCurrentViewPort) { + currentViewPort = newCurrentViewPort; clearMarkedTiles(); addNewTiles(viewportMetrics); markTiles(viewportMetrics); @@ -233,11 +229,11 @@ public class MultiTileLayer extends Layer { } private void addNewTiles(ImmutableViewportMetrics viewportMetrics) { - for (float y = tileViewPort.top; y < tileViewPort.bottom; y += TILE_SIZE) { + for (float y = currentViewPort.top; y < currentViewPort.bottom; y += TILE_SIZE) { if (y > viewportMetrics.getPageHeight()) { continue; } - for (float x = tileViewPort.left; x < tileViewPort.right; x += TILE_SIZE) { + for (float x = currentViewPort.left; x < currentViewPort.right; x += TILE_SIZE) { if (x > viewportMetrics.getPageWidth()) { continue; } @@ -248,7 +244,7 @@ public class MultiTileLayer extends Layer { } } if (!contains) { - CairoImage image = tileProvider.createTile(x, y, viewportMetrics.zoomFactor); + CairoImage image = tileProvider.createTile(x, y, new FloatSize(TILE_SIZE, TILE_SIZE), viewportMetrics.zoomFactor); SubTile tile = new SubTile(image, (int)x, (int)y, viewportMetrics.zoomFactor); tile.beginTransaction(); mTiles.add(tile); @@ -261,7 +257,7 @@ public class MultiTileLayer extends Layer { for (SubTile tile : mTiles) { if (FloatUtils.fuzzyEquals(tile.zoom, viewportMetrics.zoomFactor)) { RectF tileRect = new RectF(tile.x, tile.y, tile.x + TILE_SIZE, tile.y + TILE_SIZE); - if (!RectF.intersects(tileViewPort, tileRect)) { + if (!RectF.intersects(currentViewPort, tileRect)) { tile.markForRemoval(); } } else { |