Kaydet (Commit) 74eae678 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

android: Fold LayerController into GeckoLayerClient

Change-Id: I6a6e702e243b389f1c487b6b5390f28a4292cc74
üst daa20c9a
......@@ -6,8 +6,7 @@ import android.util.DisplayMetrics;
import android.util.Log;
import org.mozilla.gecko.gfx.GeckoLayerClient;
import org.mozilla.gecko.gfx.ImmutableViewportMetrics;
import org.mozilla.gecko.gfx.LayerController;
import org.mozilla.gecko.gfx.ImmutableViewportMetrics;;
import java.util.concurrent.LinkedBlockingQueue;
......@@ -19,7 +18,6 @@ public class LOKitThread extends Thread {
private TileProvider mTileProvider;
private ImmutableViewportMetrics mViewportMetrics;
private GeckoLayerClient mLayerClient;
private LayerController mController;
public LOKitThread() {
TileProviderFactory.initialize();
......@@ -47,7 +45,7 @@ public class LOKitThread extends Thread {
/** Handle the geometry change + draw. */
private void redraw() {
if (mController == null || mTileProvider == null) {
if (mLayerClient == null || mTileProvider == null) {
// called too early...
return;
}
......@@ -55,16 +53,16 @@ public class LOKitThread extends Thread {
draw();
RectF rect = new RectF(0, 0, mTileProvider.getPageWidth(), mTileProvider.getPageHeight());
mController.setPageRect(rect, rect);
mController.setViewportMetrics(mController.getViewportMetrics());
mController.setForceRedraw();
mLayerClient.setPageRect(rect, rect);
mLayerClient.setViewportMetrics(mLayerClient.getViewportMetrics());
mLayerClient.setForceRedraw();
}
/** Invalidate everything + handle the geometry change + draw. */
private void refresh() {
Bitmap bitmap = mTileProvider.thumbnail(1000);
if (bitmap != null) {
mApplication.getLayerController().getView().changeCheckerboardBitmap(bitmap, mTileProvider.getPageWidth(), mTileProvider.getPageHeight());
mApplication.getLayerClient().getView().changeCheckerboardBitmap(bitmap, mTileProvider.getPageWidth(), mTileProvider.getPageHeight());
}
mLayerClient.clearAndResetlayers();
......@@ -83,10 +81,9 @@ public class LOKitThread extends Thread {
mApplication = LibreOfficeMainActivity.mAppContext;
}
mController = mApplication.getLayerController();
mLayerClient = mApplication.getLayerClient();
mTileProvider = TileProviderFactory.create(mController, filename);
mTileProvider = TileProviderFactory.create(mLayerClient, filename);
boolean isReady = mTileProvider.isReady();
if (isReady) {
mLayerClient.setTileProvider(mTileProvider);
......
......@@ -8,8 +8,8 @@ import org.libreoffice.kit.LibreOfficeKit;
import org.libreoffice.kit.Office;
import org.mozilla.gecko.gfx.BufferedCairoImage;
import org.mozilla.gecko.gfx.CairoImage;
import org.mozilla.gecko.gfx.GeckoLayerClient;
import org.mozilla.gecko.gfx.IntSize;
import org.mozilla.gecko.gfx.LayerController;
import java.nio.ByteBuffer;
......@@ -18,7 +18,7 @@ public class LOKitTileProvider implements TileProvider {
private static int TILE_SIZE = 256;
private Office mOffice;
private Document mDocument;
private final LayerController mLayerController;
private final GeckoLayerClient mLayerClient;
private final float mTileWidth;
private final float mTileHeight;
private final String mInputFile;
......@@ -30,8 +30,8 @@ public class LOKitTileProvider implements TileProvider {
private long objectCreationTime = System.currentTimeMillis();
public LOKitTileProvider(LayerController layerController, String input) {
mLayerController = layerController;
public LOKitTileProvider(GeckoLayerClient layerClient, String input) {
mLayerClient = layerClient;
mDPI = (float) LOKitShell.getDpi();
mTileWidth = pixelToTwip(TILE_SIZE, mDPI);
mTileHeight = pixelToTwip(TILE_SIZE, mDPI);
......
......@@ -3,8 +3,6 @@ package org.libreoffice;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.widget.DrawerLayout;
......@@ -15,14 +13,12 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import org.mozilla.gecko.ZoomConstraints;
import org.mozilla.gecko.gfx.GeckoLayerClient;
import org.mozilla.gecko.gfx.LayerController;
import org.mozilla.gecko.gfx.LayerView;
import java.util.ArrayList;
......@@ -35,7 +31,6 @@ public class LibreOfficeMainActivity extends Activity {
public static LibreOfficeMainActivity mAppContext;
private static LayerController mLayerController;
private static GeckoLayerClient mLayerClient;
private static LOKitThread sLOKitThread;
......@@ -52,10 +47,6 @@ public class LibreOfficeMainActivity extends Activity {
return mLayerClient;
}
public static LayerController getLayerController() {
return mLayerController;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
......@@ -130,12 +121,11 @@ public class LibreOfficeMainActivity extends Activity {
sLOKitThread.clearQueue();
}
mLayerController = new LayerController(this);
mLayerController.setZoomConstraints(new ZoomConstraints(true));
mLayerClient = new GeckoLayerClient(this);
mLayerClient.setZoomConstraints(new ZoomConstraints(true));
LayerView layerView = (LayerView) findViewById(R.id.layer_view);
mLayerController.setView(layerView);
mLayerController.setLayerClient(mLayerClient);
mLayerClient.setView(layerView);
mLayerClient.notifyReady();
}
@Override
......@@ -167,6 +157,7 @@ public class LibreOfficeMainActivity extends Activity {
@Override
protected void onDestroy() {
Log.i(LOGTAG, "onDestroy..");
mLayerClient.destroy();
super.onDestroy();
}
......
......@@ -4,17 +4,17 @@ import android.graphics.Bitmap;
import org.mozilla.gecko.gfx.BufferedCairoImage;
import org.mozilla.gecko.gfx.CairoImage;
import org.mozilla.gecko.gfx.GeckoLayerClient;
import org.mozilla.gecko.gfx.IntSize;
import org.mozilla.gecko.gfx.LayerController;
public class MockTileProvider implements TileProvider {
private static final int TILE_SIZE = 256;
private final LayerController layerController;
private final GeckoLayerClient mLayerClient;
private final String inputFile;
public MockTileProvider(LayerController layerController, String inputFile) {
this.layerController = layerController;
this.inputFile = inputFile;
public MockTileProvider(GeckoLayerClient layerClient, String input) {
mLayerClient = layerClient;
this.inputFile = input;
for (int i = 0; i < 5; i++) {
String partName = "Part " + i;
......@@ -52,7 +52,7 @@ public class MockTileProvider implements TileProvider {
tileNumber += 1; // 0 to 1 based numbering
String imageName = "d" + tileNumber;
Bitmap bitmap = layerController.getView().getDrawable(imageName);
Bitmap bitmap = mLayerClient.getView().getDrawable(imageName);
CairoImage image = new BufferedCairoImage(bitmap);
......@@ -61,7 +61,7 @@ public class MockTileProvider implements TileProvider {
@Override
public Bitmap thumbnail(int size) {
return layerController.getView().getDrawable("dummy_page");
return mLayerClient.getView().getDrawable("dummy_page");
}
@Override
......
......@@ -2,7 +2,7 @@ package org.libreoffice;
import org.libreoffice.kit.LibreOfficeKit;
import org.mozilla.gecko.gfx.LayerController;
import org.mozilla.gecko.gfx.GeckoLayerClient;
public class TileProviderFactory {
private static TileProviderID currentTileProvider = TileProviderID.LOKIT;
......@@ -17,11 +17,11 @@ public class TileProviderFactory {
}
}
public static TileProvider create(LayerController layerController, String filename) {
public static TileProvider create(GeckoLayerClient layerClient, String filename) {
if (currentTileProvider == TileProviderID.LOKIT) {
return new LOKitTileProvider(layerController, filename);
return new LOKitTileProvider(layerClient, filename);
} else {
return new MockTileProvider(layerController, filename);
return new MockTileProvider(layerClient, filename);
}
}
......
......@@ -158,8 +158,6 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
public LayerRenderer(LayerView view) {
mView = view;
LayerController controller = view.getController();
CairoImage backgroundImage = new BufferedCairoImage(view.getBackgroundPattern());
mBackgroundLayer = new SingleTileLayer(true, backgroundImage);
......@@ -283,8 +281,8 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
* Called whenever a new frame is about to be drawn.
*/
public void onDrawFrame(GL10 gl) {
Frame frame = createFrame(mView.getController().getViewportMetrics());
synchronized (mView.getController()) {
Frame frame = createFrame(mView.getLayerClient().getViewportMetrics());
synchronized (mView.getLayerClient()) {
frame.beginDrawing();
frame.drawBackground();
frame.drawRootLayer();
......@@ -498,7 +496,7 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
mUpdated = true;
Layer rootLayer = mView.getController().getRoot();
Layer rootLayer = mView.getLayerClient().getRoot();
if (!mPageContext.fuzzyEquals(mLastPageContext)) {
// the viewport or page changed, so show the scrollbars again
......@@ -571,7 +569,7 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
/* Update background color. */
mBackgroundColor = mView.getController().getCheckerboardColor();
mBackgroundColor = mView.getLayerClient().getCheckerboardColor();
/* Clear to the page background colour. The bits set here need to
* match up with those used in gfx/layers/opengl/LayerManagerOGL.cpp.
......@@ -596,9 +594,9 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
/* Draw the 'checkerboard'. We use gfx.show_checkerboard_pattern to
* determine whether to draw the screenshot layer.
*/
if (mView.getController().checkerboardShouldShowChecks()) {
if (mView.getLayerClient().checkerboardShouldShowChecks()) {
/* Find the area the root layer will render into, to mask the checkerboard layer */
Rect rootMask = getMaskForLayer(mView.getController().getRoot());
Rect rootMask = getMaskForLayer(mView.getLayerClient().getRoot());
mScreenshotLayer.setMask(rootMask);
/* Scissor around the page-rect, in case the page has shrunk
......@@ -611,7 +609,7 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
// Draws the layer the client added to us.
void drawRootLayer() {
Layer rootLayer = mView.getController().getRoot();
Layer rootLayer = mView.getLayerClient().getRoot();
if (rootLayer == null) {
return;
}
......@@ -643,7 +641,7 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
mHorizScrollLayer.draw(mPageContext);
/* Measure how much of the screen is checkerboarding */
Layer rootLayer = mView.getController().getRoot();
Layer rootLayer = mView.getLayerClient().getRoot();
if ((rootLayer != null) &&
(mProfileRender || PanningPerfAPI.isRecordingCheckerboard())) {
// Find out how much of the viewport area is valid
......
......@@ -42,7 +42,7 @@ import java.nio.IntBuffer;
public class LayerView extends FrameLayout {
private static String LOGTAG = "GeckoLayerView";
private LayerController mController;
private GeckoLayerClient mLayerClient;
private TouchEventHandler mTouchEventHandler;
private GLController mGLController;
private InputConnectionHandler mInputConnectionHandler;
......@@ -100,9 +100,9 @@ public class LayerView extends FrameLayout {
mGLController = new GLController(this);
}
void connect(LayerController controller) {
mController = controller;
mTouchEventHandler = new TouchEventHandler(getContext(), this, mController);
void connect(GeckoLayerClient layerClient) {
mLayerClient = layerClient;
mTouchEventHandler = new TouchEventHandler(getContext(), this, layerClient);
mRenderer = new LayerRenderer(this);
mInputConnectionHandler = null;
......@@ -124,12 +124,12 @@ public class LayerView extends FrameLayout {
return mTouchEventHandler.handleEvent(event);
}
public LayerController getController() { return mController; }
public GeckoLayerClient getLayerClient() { return mLayerClient; }
public TouchEventHandler getTouchEventHandler() { return mTouchEventHandler; }
/** The LayerRenderer calls this to indicate that the window has changed size. */
public void setViewportSize(IntSize size) {
mController.setViewportSize(new FloatSize(size));
mLayerClient.setViewportSize(new FloatSize(size));
}
@Override
......@@ -307,7 +307,7 @@ public class LayerView extends FrameLayout {
/** This function is invoked by Gecko (compositor thread) via JNI; be careful when modifying signature. */
public static GLController registerCxxCompositor() {
try {
LayerView layerView = LibreOfficeMainActivity.mAppContext.getLayerController().getView();
LayerView layerView = LibreOfficeMainActivity.mAppContext.getLayerClient().getView();
layerView.mListener.compositorCreated();
return layerView.getGLController();
} catch (Exception e) {
......
......@@ -123,17 +123,17 @@ public final class TouchEventHandler {
// processed. (n is the absolute value of the balance.)
private int mProcessingBalance;
TouchEventHandler(Context context, LayerView view, LayerController controller) {
TouchEventHandler(Context context, LayerView view, GeckoLayerClient layerClient) {
mView = view;
mEventQueue = new LinkedList<MotionEvent>();
mGestureDetector = new GestureDetector(context, controller.getGestureListener());
mScaleGestureDetector = new SimpleScaleGestureDetector(controller.getScaleGestureListener());
mPanZoomController = controller.getPanZoomController();
mGestureDetector = new GestureDetector(context, layerClient.getGestureListener());
mScaleGestureDetector = new SimpleScaleGestureDetector(layerClient.getScaleGestureListener());
mPanZoomController = layerClient.getPanZoomController();
mListenerTimeoutProcessor = new ListenerTimeoutProcessor();
mDispatchEvents = true;
mGestureDetector.setOnDoubleTapListener(controller.getDoubleTapListener());
mGestureDetector.setOnDoubleTapListener(layerClient.getDoubleTapListener());
}
/* This function MUST be called on the UI thread */
......
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