From 450a4f46d9de0f2b2d7b4232e7fef380dacdfcd0 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Thu, 2 Oct 2014 16:16:33 +0200 Subject: android: TileIdentifier - contains tile position and zoom Change-Id: Ia82dc1f99eff5117fe16df2b61c1a7230b52e07a --- .../org/mozilla/gecko/gfx/DynamicTileLayer.java | 14 ++--- .../src/java/org/mozilla/gecko/gfx/SubTile.java | 61 ++++++++++++---------- 2 files changed, 41 insertions(+), 34 deletions(-) (limited to 'android') 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 407cdc1847ff..01ab8bec9203 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 @@ -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(); } diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/SubTile.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/SubTile.java index 27f11fc1908d..7e60af1f962c 100644 --- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/SubTile.java +++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/SubTile.java @@ -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; + } } } -- cgit