android: use tile size and change the type to IntSize
Change-Id: Id19c3517fc6fb59307c81a0c1c8868e0d0c777b4
This commit is contained in:
@@ -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 {
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user