summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-02-17 19:14:12 +0900
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-02-23 10:10:24 +0100
commitb8a2e465ff2e1893aab0a78cad180b7db3a1df04 (patch)
treea83d0b834497f7b9ba66249f71010619622fb3aa /android
parent538135e6447d01a99b50faf63d6f65a8b8543514 (diff)
android: cleanup ComposedTileLayer
Change-Id: I976384ac5515295a56bc1339791ab63a62dc4bea
Diffstat (limited to 'android')
-rw-r--r--android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java73
1 files changed, 35 insertions, 38 deletions
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
index 92996566d468..62eae49c9469 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
@@ -24,18 +24,50 @@ public abstract class ComposedTileLayer extends Layer implements ComponentCallba
protected final List<SubTile> tiles = new ArrayList<SubTile>();
protected final IntSize tileSize;
- protected RectF currentViewport = new RectF();
- protected float currentZoom;
-
private final ReadWriteLock tilesReadWriteLock = new ReentrantReadWriteLock();
private final Lock tilesReadLock = tilesReadWriteLock.readLock();
private final Lock tilesWriteLock = tilesReadWriteLock.writeLock();
+ protected RectF currentViewport = new RectF();
+ protected float currentZoom;
+
public ComposedTileLayer(Context context) {
context.registerComponentCallbacks(this);
this.tileSize = new IntSize(256, 256);
}
+ protected static 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;
+ float maxY = ((int) (input.bottom / tileSize.height) + 1) * tileSize.height;
+ return new RectF(minX, minY, maxX, maxY);
+ }
+
+ protected static 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;
+
+ newRect.top -= inflateSize.height;
+ newRect.top = newRect.top < 0.0f ? 0.0f : newRect.top;
+
+ newRect.right += inflateSize.width;
+ newRect.bottom += inflateSize.height;
+
+ return newRect;
+ }
+
+ protected static RectF normalizeRect(RectF rect, float sourceFactor, float targetFactor) {
+ RectF normalizedRect = new RectF(
+ (rect.left / sourceFactor) * targetFactor,
+ (rect.top / sourceFactor) * targetFactor,
+ (rect.right / sourceFactor) * targetFactor,
+ (rect.bottom / sourceFactor) * targetFactor);
+
+ return normalizedRect;
+ }
+
public void invalidate() {
tilesReadLock.lock();
for (SubTile tile : tiles) {
@@ -110,38 +142,6 @@ public abstract class ComposedTileLayer extends Layer implements ComponentCallba
tilesReadLock.unlock();
}
- protected 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;
- float maxY = ((int) (input.bottom / tileSize.height) + 1) * tileSize.height;
- return new RectF(minX, minY, maxX, maxY);
- }
-
- protected 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;
-
- newRect.top -= inflateSize.height;
- newRect.top = newRect.top < 0.0f ? 0.0f : newRect.top;
-
- newRect.right += inflateSize.width;
- newRect.bottom += inflateSize.height;
-
- return newRect;
- }
-
- protected RectF normalizeRect(RectF rect, float sourceFactor, float targetFactor) {
- RectF normalizedRect = new RectF(
- (rect.left / sourceFactor) * targetFactor,
- (rect.top / sourceFactor) * targetFactor,
- (rect.right / sourceFactor) * targetFactor,
- (rect.bottom / sourceFactor) * targetFactor);
-
- return normalizedRect;
- }
-
public void reevaluateTiles(ImmutableViewportMetrics viewportMetrics, DisplayPortMetrics mDisplayPort) {
RectF newViewPort = getViewPort(viewportMetrics);
float newZoom = getZoom(viewportMetrics);
@@ -276,7 +276,4 @@ public abstract class ComposedTileLayer extends Layer implements ComponentCallba
Log.i(LOGTAG, "Trimming memory - TRIM_MEMORY_RUNNING_LOW");
}
}
-
- public void cleanupInvalidTile(TileIdentifier tileId) {
- }
}