summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-10-02 15:50:53 +0200
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-10-04 17:52:37 +0200
commitfc8e1ac501f021ac6f99f944fd5d38297bc7a00d (patch)
tree8492855f4c580e3d23b9187620bd82a8fb413346 /android
parent1b81aeb2548d3492e0c50dfbfa61b3000cf9b6cb (diff)
android: use tile size and change the type to IntSize
Change-Id: Id19c3517fc6fb59307c81a0c1c8868e0d0c777b4
Diffstat (limited to 'android')
-rw-r--r--android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java11
-rw-r--r--android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java3
-rw-r--r--android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java4
-rw-r--r--android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/DynamicTileLayer.java10
4 files changed, 15 insertions, 13 deletions
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
index 4fdf84fd4030..c904942bbb00 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
@@ -9,6 +9,7 @@ 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.IntSize;
import org.mozilla.gecko.gfx.LayerController;
import java.nio.ByteBuffer;
@@ -132,9 +133,9 @@ public class LOKitTileProvider implements TileProvider {
}
@Override
- 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);
+ public CairoImage createTile(float x, float y, IntSize tileSize, float zoom) {
+ ByteBuffer buffer = ByteBuffer.allocateDirect(tileSize.width * tileSize.height * 4);
+ Bitmap bitmap = Bitmap.createBitmap(tileSize.width, tileSize.height, Bitmap.Config.ARGB_8888);
if (mDocument != null) {
float twipX = pixelToTwip(x, mDPI) / zoom;
@@ -142,8 +143,8 @@ public class LOKitTileProvider implements TileProvider {
float twipWidth = mTileWidth / zoom;
float twipHeight = mTileHeight / zoom;
long start = System.currentTimeMillis();
- Log.i(LOGTAG, "paintTile TOP @ " + start + "(" + TILE_SIZE + " " + TILE_SIZE + " " + (int)twipX + " " + (int)twipY + " " + (int) twipWidth + " " + (int) twipHeight + ")");
- mDocument.paintTile(buffer, TILE_SIZE, TILE_SIZE, (int) twipX, (int) twipY, (int) twipWidth, (int) twipHeight);
+ Log.i(LOGTAG, "paintTile TOP @ " + start + "(" + tileSize.width + " " + tileSize.height + " " + (int)twipX + " " + (int)twipY + " " + (int) twipWidth + " " + (int) twipHeight + ")");
+ mDocument.paintTile(buffer, tileSize.width, tileSize.height, (int) twipX, (int) twipY, (int) twipWidth, (int) twipHeight);
long stop = System.currentTimeMillis();
Log.i(LOGTAG, "paintTile TAIL @ " + stop + " - elapsed: " + (stop - start) + " ");
} else {
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
index 672973c05b7a..5de6a82a0d0e 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
@@ -5,6 +5,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.IntSize;
import org.mozilla.gecko.gfx.LayerController;
public class MockTileProvider implements TileProvider {
@@ -45,7 +46,7 @@ public class MockTileProvider implements TileProvider {
}
@Override
- public CairoImage createTile(float x, float y, FloatSize tileSize, float zoom) {
+ public CairoImage createTile(float x, float y, IntSize 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 ada23608b154..12a47f6c7f39 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java
@@ -4,7 +4,7 @@ package org.libreoffice;
import android.graphics.Bitmap;
import org.mozilla.gecko.gfx.CairoImage;
-import org.mozilla.gecko.gfx.FloatSize;
+import org.mozilla.gecko.gfx.IntSize;
public interface TileProvider {
int getPageWidth();
@@ -13,7 +13,7 @@ public interface TileProvider {
boolean isReady();
- CairoImage createTile(float x, float y, FloatSize tileSize, float zoom);
+ CairoImage createTile(float x, float y, IntSize tileSize, float zoom);
void changePart(int partIndex);
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/DynamicTileLayer.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/DynamicTileLayer.java
index 1ad8d38313b3..407cdc1847ff 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/DynamicTileLayer.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/DynamicTileLayer.java
@@ -17,14 +17,14 @@ public class DynamicTileLayer extends Layer {
private final List<SubTile> tiles = new CopyOnWriteArrayList<SubTile>();
private TileProvider tileProvider;
- private final FloatSize tileSize;
+ private final IntSize tileSize;
private RectF currentViewport = new RectF();
public DynamicTileLayer() {
- this.tileSize = new FloatSize(256, 256);
+ this.tileSize = new IntSize(256, 256);
}
- public DynamicTileLayer(FloatSize tileSize) {
+ public DynamicTileLayer(IntSize tileSize) {
this.tileSize = tileSize;
}
@@ -108,7 +108,7 @@ public class DynamicTileLayer extends Layer {
}
}
- private RectF roundToTileSize(RectF input, FloatSize tileSize) {
+ private RectF roundToTileSize(RectF input, IntSize tileSize) {
float minX = ((int)(input.left / tileSize.width)) * tileSize.width;
float minY = ((int)(input.top / tileSize.height)) * tileSize.height;
float maxX = ((int)(input.right / tileSize.width) + 1) * tileSize.width;
@@ -116,7 +116,7 @@ public class DynamicTileLayer extends Layer {
return new RectF(minX, minY, maxX, maxY);
}
- private RectF inflate(RectF rect, FloatSize inflateSize) {
+ private RectF inflate(RectF rect, IntSize inflateSize) {
RectF newRect = new RectF(rect);
newRect.left -= inflateSize.width;
newRect.left = newRect.left < 0.0f ? 0.0f : newRect.left;