Kaydet (Commit) 450a4f46 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

android: TileIdentifier - contains tile position and zoom

Change-Id: Ia82dc1f99eff5117fe16df2b61c1a7230b52e07a
üst e910aa45
......@@ -97,10 +97,10 @@ public class DynamicTileLayer extends Layer {
tile.beginTransaction();
Rect position = tile.getPosition();
float positionX = tile.x / tile.zoom;
float positionY = tile.y / tile.zoom;
float tileSizeWidth = tileSize.width / tile.zoom;
float tileSizeHeight = tileSize.height / tile.zoom;
float positionX = tile.id.x / tile.id.zoom;
float positionY = tile.id.y / tile.id.zoom;
float tileSizeWidth = tileSize.width / tile.id.zoom;
float tileSizeHeight = tileSize.height / tile.id.zoom;
position.set((int) positionX, (int) positionY, (int) (positionX + tileSizeWidth + 1), (int) (positionY + tileSizeHeight + 1));
tile.setPosition(position);
......@@ -157,7 +157,7 @@ public class DynamicTileLayer extends Layer {
}
boolean contains = false;
for (SubTile tile : tiles) {
if (tile.x == x && tile.y == y && tile.zoom == viewportMetrics.zoomFactor) {
if (tile.id.x == x && tile.id.y == y && tile.id.zoom == viewportMetrics.zoomFactor) {
contains = true;
}
}
......@@ -184,8 +184,8 @@ public class DynamicTileLayer extends Layer {
private void markTiles(ImmutableViewportMetrics viewportMetrics) {
for (SubTile tile : tiles) {
if (FloatUtils.fuzzyEquals(tile.zoom, viewportMetrics.zoomFactor)) {
RectF tileRect = new RectF(tile.x, tile.y, tile.x + tileSize.width, tile.y + tileSize.height);
if (FloatUtils.fuzzyEquals(tile.id.zoom, viewportMetrics.zoomFactor)) {
RectF tileRect = new RectF(tile.id.x, tile.id.y, tile.id.x + tileSize.width, tile.id.y + tileSize.height);
if (!RectF.intersects(currentViewport, tileRect)) {
tile.markForRemoval();
}
......
......@@ -6,42 +6,49 @@
package org.mozilla.gecko.gfx;
public class SubTile extends SingleTileLayer {
public int x;
public int y;
public float zoom;
public boolean markedForRemoval = false;
public final TileIdentifier id;
public SubTile(CairoImage mImage, int x, int y, float zoom) {
super(mImage);
this.x = x;
this.y = y;
this.zoom = zoom;
id = new TileIdentifier(x, y, zoom);
}
public void markForRemoval() {
markedForRemoval = true;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SubTile subTile = (SubTile) o;
if (x != subTile.x) return false;
if (y != subTile.y) return false;
if (Float.compare(subTile.zoom, zoom) != 0) return false;
return true;
}
@Override
public int hashCode() {
int result = x;
result = 31 * result + y;
result = 31 * result + (zoom != +0.0f ? Float.floatToIntBits(zoom) : 0);
return result;
public static class TileIdentifier {
public int x;
public int y;
public float zoom;
public TileIdentifier(int x, int y, float zoom) {
this.x = x;
this.y = y;
this.zoom = zoom;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TileIdentifier that = (TileIdentifier) o;
if (x != that.x) return false;
if (y != that.y) return false;
if (Float.compare(that.zoom, zoom) != 0) return false;
return true;
}
@Override
public int hashCode() {
int result = x;
result = 31 * result + y;
result = 31 * result + (zoom != +0.0f ? Float.floatToIntBits(zoom) : 0);
return result;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment