summaryrefslogtreecommitdiff
path: root/android/experimental
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-07-07 21:15:41 +0200
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-07-10 11:17:54 +0200
commitd4ab22323a34c286b411044a598f5041e189d159 (patch)
treed8c74ee5d87a495f94aa54304fb51e1709107509 /android/experimental
parent2375959cdbdce2b2ac9e908f91f26abf9ed2f95b (diff)
LOAndroid3: remove GeckoEventListener dependency & bufferSize
Change-Id: I2e7bf8eb463fa9d9480f247732bde0af2055bd76
Diffstat (limited to 'android/experimental')
-rw-r--r--android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java33
-rw-r--r--android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoSoftwareLayerClient.java11
-rw-r--r--android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerController.java7
-rw-r--r--android/experimental/LOAndroid3/src/java/org/mozilla/gecko/ui/PanZoomController.java44
4 files changed, 7 insertions, 88 deletions
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
index 66ac7e985c71..3ed110440db4 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
@@ -40,30 +40,27 @@ package org.mozilla.gecko.gfx;
import android.content.Context;
import android.graphics.PointF;
-import android.graphics.Rect;
import android.os.SystemClock;
import android.util.DisplayMetrics;
import android.util.Log;
-import org.json.JSONObject;
import org.libreoffice.LOEvent;
import org.libreoffice.LOKitShell;
import org.libreoffice.LibreOfficeMainActivity;
-import org.mozilla.gecko.GeckoEventListener;
import org.mozilla.gecko.util.FloatUtils;
-import java.util.regex.Pattern;
-
-public abstract class GeckoLayerClient implements GeckoEventListener {
+public abstract class GeckoLayerClient {
private static final String LOGTAG = "GeckoLayerClient";
private static final long MIN_VIEWPORT_CHANGE_DELAY = 25L;
- private static Pattern sColorPattern;
protected IntSize mScreenSize;
protected Layer mTileLayer;
+
/* The viewport that Gecko is currently displaying. */
protected ViewportMetrics mGeckoViewport;
+
/* The viewport that Gecko will display when drawing is finished */
protected ViewportMetrics mNewGeckoViewport;
+
protected LayerController mLayerController;
private long mLastViewportChangeTime;
private boolean mPendingViewportAdjust;
@@ -84,8 +81,6 @@ public abstract class GeckoLayerClient implements GeckoEventListener {
protected abstract void updateLayerAfterDraw();
- protected abstract IntSize getBufferSize();
-
protected abstract IntSize getTileSize();
/**
@@ -171,12 +166,11 @@ public abstract class GeckoLayerClient implements GeckoEventListener {
}
mScreenSize = new IntSize(metrics.widthPixels, metrics.heightPixels);
- IntSize bufferSize = getBufferSize();
IntSize tileSize = getTileSize();
Log.e(LOGTAG, "### Screen-size changed to " + mScreenSize);
- LOEvent event = LOEvent.sizeChanged(bufferSize.width, bufferSize.height,
+ LOEvent event = LOEvent.sizeChanged(
metrics.widthPixels, metrics.heightPixels,
tileSize.width, tileSize.height);
LOKitShell.sendEvent(event);
@@ -217,8 +211,6 @@ public abstract class GeckoLayerClient implements GeckoEventListener {
private void adjustViewport() {
ViewportMetrics viewportMetrics = new ViewportMetrics(mLayerController.getViewportMetrics());
- PointF viewportOffset = viewportMetrics.getOptimumViewportOffset(getBufferSize());
- viewportMetrics.setViewportOffset(viewportOffset);
viewportMetrics.setViewport(viewportMetrics.getClampedViewport());
LOKitShell.sendEvent(LOEvent.viewport(viewportMetrics));
@@ -230,21 +222,6 @@ public abstract class GeckoLayerClient implements GeckoEventListener {
mLastViewportChangeTime = System.currentTimeMillis();
}
- public void handleMessage(String event, JSONObject message) {
- if ("Viewport:UpdateAndDraw".equals(event)) {
- Log.e(LOGTAG, "### Java side Viewport:UpdateAndDraw()!");
- mUpdateViewportOnEndDraw = true;
-
- // Redraw everything.
- IntSize bufferSize = getBufferSize();
- Rect rect = new Rect(0, 0, bufferSize.width, bufferSize.height);
- LOKitShell.sendEvent(LOEvent.draw(rect));
- } else if ("Viewport:UpdateLater".equals(event)) {
- Log.e(LOGTAG, "### Java side Viewport:UpdateLater()!");
- mUpdateViewportOnEndDraw = true;
- }
- }
-
public void geometryChanged() {
sendResizeEventIfNecessary();
render();
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoSoftwareLayerClient.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoSoftwareLayerClient.java
index 66adaf2922cc..8efe82d62c44 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoSoftwareLayerClient.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoSoftwareLayerClient.java
@@ -53,15 +53,10 @@ import java.util.List;
public class GeckoSoftwareLayerClient extends GeckoLayerClient {
private static final String LOGTAG = "GeckoSoftwareLayerClient";
- private int mFormat;
- private IntSize mViewportSize;
- private IntSize mBufferSize;
private static final IntSize TILE_SIZE = new IntSize(256, 256);
public GeckoSoftwareLayerClient(Context context) {
super(context);
- mBufferSize = new IntSize(0,0);
- mFormat = CairoImage.FORMAT_ARGB32;
}
public void setLayerController(LayerController layerController) {
@@ -98,12 +93,6 @@ public class GeckoSoftwareLayerClient extends GeckoLayerClient {
}
}
- @Override
- protected IntSize getBufferSize() {
- return new IntSize(
- ((mScreenSize.width + LayerController.MIN_BUFFER.width - 1) / TILE_SIZE.width + 1) * TILE_SIZE.width,
- ((mScreenSize.height + LayerController.MIN_BUFFER.height - 1) / TILE_SIZE.height + 1) * TILE_SIZE.height);
- }
@Override
protected IntSize getTileSize() {
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerController.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerController.java
index 0ddd7aa2916e..38de9c45a4a5 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerController.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerController.java
@@ -68,7 +68,6 @@ public class LayerController {
* smooth, asynchronous scrolling. Depending on a device's support for NPOT
* textures, this may be rounded up to the nearest power of two.
*/
- public static final IntSize MIN_BUFFER = new IntSize(512, 1024);
private static final String LOGTAG = "GeckoLayerController";
/* If the visible rect is within the danger zone (measured in pixels from each edge of a tile),
* we start aggressively redrawing to minimize checkerboarding. */
@@ -79,10 +78,7 @@ public class LayerController {
private static final int PREVENT_DEFAULT_TIMEOUT = 200;
private Layer mRootLayer; /* The root layer. */
private LayerView mView; /* The main rendering view. */
- /*
- * The panning and zooming controller, which interprets pan and zoom gestures for us and
- * updates our visible rect appropriately.
- */
+
private Context mContext; /* The current context. */
private ViewportMetrics mViewportMetrics; /* The current viewport metrics. */
private boolean mWaitForTouchListeners;
@@ -100,7 +96,6 @@ public class LayerController {
public LayerController(Context context) {
mContext = context;
-
mForceRedraw = true;
mViewportMetrics = new ViewportMetrics();
mPanZoomController = new PanZoomController(this);
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/ui/PanZoomController.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/ui/PanZoomController.java
index 066f4cea2630..7d15bdb09728 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/ui/PanZoomController.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/ui/PanZoomController.java
@@ -45,13 +45,10 @@ import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
-import org.json.JSONObject;
import org.libreoffice.LOKitShell;
import org.libreoffice.LibreOfficeMainActivity;
-import org.mozilla.gecko.GeckoEventListener;
import org.mozilla.gecko.gfx.FloatSize;
import org.mozilla.gecko.gfx.LayerController;
-import org.mozilla.gecko.gfx.PointUtils;
import org.mozilla.gecko.gfx.ViewportMetrics;
import org.mozilla.gecko.util.FloatUtils;
@@ -64,9 +61,7 @@ import java.util.TimerTask;
* Many ideas are from Joe Hewitt's Scrollability:
* https://github.com/joehewitt/scrollability/
*/
-public class PanZoomController
- extends GestureDetector.SimpleOnGestureListener
- implements SimpleScaleGestureDetector.SimpleScaleGestureListener, GeckoEventListener {
+public class PanZoomController extends GestureDetector.SimpleOnGestureListener implements SimpleScaleGestureDetector.SimpleScaleGestureListener {
// The distance the user has to pan before we recognize it as such (e.g. to avoid 1-pixel pans
// between the touch-down and touch-up of a click). In units of density-independent pixels.
public static final float PAN_THRESHOLD = 1 / 16f * LOKitShell.getDpi();
@@ -127,43 +122,6 @@ public class PanZoomController
mState = PanZoomState.NOTHING;
}
- public void handleMessage(String event, JSONObject message) {
- Log.i(LOGTAG, "Got message: " + event);
- try {
- if (MESSAGE_ZOOM_RECT.equals(event)) {
- float x = (float) message.getDouble("x");
- float y = (float) message.getDouble("y");
- final RectF zoomRect = new RectF(x, y,
- x + (float) message.getDouble("w"),
- y + (float) message.getDouble("h"));
- mController.post(new Runnable() {
- public void run() {
- animatedZoomTo(zoomRect);
- }
- });
- } else if (MESSAGE_ZOOM_PAGE.equals(event)) {
- FloatSize pageSize = mController.getPageSize();
-
- RectF viewableRect = mController.getViewport();
- float y = viewableRect.top;
- // attempt to keep zoom keep focused on the center of the viewport
- float newHeight = viewableRect.height() * pageSize.width / viewableRect.width();
- float dh = viewableRect.height() - newHeight; // increase in the height
- final RectF r = new RectF(0.0f,
- y + dh / 2,
- pageSize.width,
- y + dh / 2 + newHeight);
- mController.post(new Runnable() {
- public void run() {
- animatedZoomTo(r);
- }
- });
- }
- } catch (Exception e) {
- Log.e(LOGTAG, "Exception handling message \"" + event + "\":", e);
- }
- }
-
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN: