[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - 6 commits - android/experimental
Tomaž Vajngerl
tomaz.vajngerl at collabora.co.uk
Mon Feb 16 04:27:49 PST 2015
android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java | 13 -
android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java | 27 ++
android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java | 98 +++-------
android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java | 27 --
android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/RenderControllerThread.java | 37 +--
5 files changed, 87 insertions(+), 115 deletions(-)
New commits:
commit ba66d0463f661474fd5fd982dfd3a454c65adc20
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Mon Feb 16 19:29:58 2015 +0900
android: Clean-up LayerClient - add @Override, rearrange, comments
Change-Id: I75f32f2a99430ff65345e203ac49189fec011e2e
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 ea729a5..e975bf9 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
@@ -24,12 +24,10 @@ public class GeckoLayerClient implements PanZoomTarget {
private static final String LOGTAG = GeckoLayerClient.class.getSimpleName();
private LayerRenderer mLayerRenderer;
- private boolean mLayerRendererInitialized;
private Context mContext;
private IntSize mScreenSize;
private DisplayPortMetrics mDisplayPort;
- private DisplayPortMetrics mReturnDisplayPort;
private ComposedTileLayer mLowResLayer;
private ComposedTileLayer mRootLayer;
@@ -89,6 +87,26 @@ public class GeckoLayerClient implements PanZoomTarget {
sendResizeEventIfNecessary();
}
+ public void destroy() {
+ mPanZoomController.destroy();
+ }
+
+ public Context getContext() {
+ return mContext;
+ }
+
+ Layer getRoot() {
+ return mIsReady ? mRootLayer : null;
+ }
+
+ Layer getLowResLayer() {
+ return mIsReady ? mLowResLayer : null;
+ }
+
+ public LayerView getView() {
+ return mView;
+ }
+
/**
* Returns true if this controller is fine with performing a redraw operation or false if it
* would prefer that the action didn't take place.
@@ -105,18 +123,6 @@ public class GeckoLayerClient implements PanZoomTarget {
return DisplayPortCalculator.aboutToCheckerboard(mViewportMetrics, mPanZoomController.getVelocityVector(), getDisplayPort());
}
- Layer getRoot() {
- return mIsReady ? mRootLayer : null;
- }
-
- Layer getLowResLayer() {
- return mIsReady ? mLowResLayer : null;
- }
-
- public LayerView getView() {
- return mView;
- }
-
/**
* The view calls this function to indicate that the viewport changed size. It must hold the
* monitor while calling it.
@@ -243,16 +249,19 @@ public class GeckoLayerClient implements PanZoomTarget {
}
/** Implementation of PanZoomTarget */
+ @Override
public ImmutableViewportMetrics getViewportMetrics() {
return mViewportMetrics;
}
/** Implementation of PanZoomTarget */
+ @Override
public ZoomConstraints getZoomConstraints() {
return mZoomConstraints;
}
/** Implementation of PanZoomTarget */
+ @Override
public void setAnimationTarget(ImmutableViewportMetrics viewport) {
if (mIsReady) {
// We know what the final viewport of the animation is going to be, so
@@ -267,6 +276,7 @@ public class GeckoLayerClient implements PanZoomTarget {
/** Implementation of PanZoomTarget
* You must hold the monitor while calling this.
*/
+ @Override
public void setViewportMetrics(ImmutableViewportMetrics viewport) {
mViewportMetrics = viewport;
mView.requestRender();
@@ -276,6 +286,7 @@ public class GeckoLayerClient implements PanZoomTarget {
}
/** Implementation of PanZoomTarget */
+ @Override
public void forceRedraw() {
mForceRedraw = true;
if (mIsReady) {
@@ -284,11 +295,13 @@ public class GeckoLayerClient implements PanZoomTarget {
}
/** Implementation of PanZoomTarget */
+ @Override
public boolean post(Runnable action) {
return mView.post(action);
}
/** Implementation of PanZoomTarget */
+ @Override
public Object getLock() {
return this;
}
@@ -305,19 +318,12 @@ public class GeckoLayerClient implements PanZoomTarget {
return layerPoint;
}
+ /** Implementation of PanZoomTarget */
@Override
public boolean isFullScreen() {
return false;
}
- public void destroy() {
- mPanZoomController.destroy();
- }
-
- public Context getContext() {
- return mContext;
- }
-
public void zoomTo(RectF rect) {
if (mPanZoomController instanceof JavaPanZoomController) {
((JavaPanZoomController) mPanZoomController).animatedZoomTo(rect);
commit a631fd36fc2b4f5a8691c907379ec1d49d940088
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Sun Feb 15 17:29:23 2015 +0900
android: hide soft keyboard
Change-Id: Id23c330953efeb65960878413dd9dd0ad00eef40
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
index 0b87a59..43f2e6a 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -198,6 +198,7 @@ public class LibreOfficeMainActivity extends LOAbout {
@Override
protected void onStop() {
Log.i(LOGTAG, "onStop..");
+ hideSoftKeyboardDirect();
LOKitShell.sendCloseEvent();
super.onStop();
}
@@ -242,8 +243,6 @@ public class LibreOfficeMainActivity extends LOAbout {
* Force the request on main thread.
*/
public void showSoftKeyboard() {
- Log.i(LOGTAG, "SoftKeyboard show request..");
-
LOKitShell.getMainHandler().post(new Runnable() {
@Override
public void run() {
@@ -257,6 +256,30 @@ public class LibreOfficeMainActivity extends LOAbout {
});
}
+ /**
+ * Hides software keyboard on UI thread.
+ */
+ public void hideSoftKeyboard() {
+ LOKitShell.getMainHandler().post(new Runnable() {
+ @Override
+ public void run() {
+ hideSoftKeyboardDirect();
+ }
+ });
+ }
+
+ /**
+ * Hides software keyboard.
+ */
+ private void hideSoftKeyboardDirect() {
+ LayerView layerView = (LayerView) findViewById(R.id.layer_view);
+
+ if (getCurrentFocus() != null) {
+ InputMethodManager inputMethodManager = (InputMethodManager) getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE);
+ inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
+ }
+ }
+
public void showProgressSpinner() {
findViewById(R.id.loadingPanel).setVisibility(View.VISIBLE);
}
commit 9757b354a2b52610f31fa855fd677855c1034104
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Sun Feb 15 17:02:03 2015 +0900
android: check if mTileProvider is available
Change-Id: Ibf2d491ad8867facab6181bec3d26d99a3ffbcf8
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
index a98b6cc..0ea2829 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
@@ -144,6 +144,7 @@ public class LOKitThread extends Thread implements TileProvider.TileInvalidation
}
}
+ @Override
public void run() {
try {
while (true) {
@@ -193,6 +194,9 @@ public class LOKitThread extends Thread implements TileProvider.TileInvalidation
if (!LOKitShell.isEditingEnabled()) {
return;
}
+ if (mTileProvider == null) {
+ return;
+ }
if (keyEventType == "KeyPress") {
mTileProvider.keyPress(keyEvent);
} else if (keyEventType.equals("KeyRelease")) {
@@ -207,6 +211,9 @@ public class LOKitThread extends Thread implements TileProvider.TileInvalidation
if (!LOKitShell.isEditingEnabled()) {
return;
}
+ if (mTileProvider == null) {
+ return;
+ }
LibreOfficeMainActivity.mAppContext.showSoftKeyboard();
mTileProvider.mouseButtonDown(mDocumentTouchCoordinate);
}
commit c7eec063f15f1d377ae252d039bc89c40266d45e
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Sun Feb 15 15:14:44 2015 +0900
android: cleanup more in LayerClient
Change-Id: I2ea316c9f63343290da59df7f07433e38db974c3
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 6fdfc8b..ea729a5 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
@@ -34,12 +34,6 @@ public class GeckoLayerClient implements PanZoomTarget {
private ComposedTileLayer mLowResLayer;
private ComposedTileLayer mRootLayer;
- /*
- * The viewport metrics being used to draw the current frame. This is only
- * accessed by the compositor thread, and so needs no synchronisation.
- */
- private ImmutableViewportMetrics mFrameMetrics;
-
private boolean mForceRedraw;
/* The current viewport metrics.
@@ -58,10 +52,7 @@ public class GeckoLayerClient implements PanZoomTarget {
private ZoomConstraints mZoomConstraints;
- private boolean mIsReady ;
-
- /* The new color for the checkerboard. */
- private int mCheckerboardColor;
+ private boolean mIsReady;
private PanZoomController mPanZoomController;
private LayerView mView;
@@ -94,6 +85,7 @@ public class GeckoLayerClient implements PanZoomTarget {
mLayerRenderer = new LayerRenderer(mView);
mView.setLayerRenderer(mLayerRenderer);
+
sendResizeEventIfNecessary();
}
@@ -110,7 +102,6 @@ public class GeckoLayerClient implements PanZoomTarget {
if (!mPanZoomController.getRedrawHint()) {
return false;
}
-
return DisplayPortCalculator.aboutToCheckerboard(mViewportMetrics, mPanZoomController.getVelocityVector(), getDisplayPort());
}
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java
index b401fd4..3f0fb78 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java
@@ -182,7 +182,6 @@ public class LayerView extends FrameLayout {
public GeckoLayerClient getLayerClient() { return mLayerClient; }
public PanZoomController getPanZoomController() { return mPanZoomController; }
- /** The LayerRenderer calls this to indicate that the window has changed size. */
public void setViewportSize(IntSize size) {
mLayerClient.setViewportSize(new FloatSize(size));
}
commit 4266845aca7566af82bbe797eed2f77f186d08eb
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Sun Feb 15 15:10:22 2015 +0900
android: fix "invalidate()..." exception
Fix "invalidate() is only valid inside a transaction" exception.
Change-Id: I550811a0324bece298ac1a583e4198ae280586f6
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
index 44cb7e3..a98b6cc 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
@@ -55,16 +55,14 @@ public class LOKitThread extends Thread implements TileProvider.TileInvalidation
return;
}
+ mLayerClient.beginDrawing();
+
List<SubTile> tiles = new ArrayList<SubTile>();
mLayerClient.invalidateTiles(tiles, rect);
for (SubTile tile : tiles) {
CairoImage image = mTileProvider.createTile(tile.id.x, tile.id.y, tile.id.size, tile.id.zoom);
tile.setImage(image);
- }
-
- mLayerClient.beginDrawing();
- for (SubTile tile : tiles) {
tile.invalidate();
}
mLayerClient.endDrawing();
commit f97c76f6c6c837c582f86e00a3fa9c4e89109dc1
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Sun Feb 15 14:13:56 2015 +0900
android: use mListener in LayerView for RenderControllerThread
Change-Id: I15b65f6eda04fce83831d8bee03b3840a1c15095
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 4c3f87a..6fdfc8b 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
@@ -20,7 +20,7 @@ import org.mozilla.gecko.util.FloatUtils;
import java.util.List;
-public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
+public class GeckoLayerClient implements PanZoomTarget {
private static final String LOGTAG = GeckoLayerClient.class.getSimpleName();
private LayerRenderer mLayerRenderer;
@@ -93,7 +93,6 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
mLayerRenderer = new LayerRenderer(mView);
- mView.setListener(this);
mView.setLayerRenderer(mLayerRenderer);
sendResizeEventIfNecessary();
}
@@ -252,38 +251,6 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
}
}
- /** Implementation of LayerView.Listener */
- @Override
- public void renderRequested() {
- }
-
- /** Implementation of LayerView.Listener */
- @Override
- public void compositionPauseRequested() {
- }
-
- /** Implementation of LayerView.Listener */
- @Override
- public void compositionResumeRequested(int width, int height) {
- }
-
- /** Implementation of LayerView.Listener */
- @Override
- public void surfaceChanged(int width, int height) {
- setViewportSize(new FloatSize(width, height));
-
- // We need to make this call even when the compositor isn't currently
- // paused (e.g. during an orientation change), to make the compositor
- // aware of the changed surface.
- compositionResumeRequested(width, height);
- renderRequested();
- }
-
- /** Implementation of LayerView.Listener */
- @Override
- public void compositorCreated() {
- }
-
/** Implementation of PanZoomTarget */
public ImmutableViewportMetrics getViewportMetrics() {
return mViewportMetrics;
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java
index 1b94fc4..b401fd4 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java
@@ -12,7 +12,6 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.PixelFormat;
import android.graphics.SurfaceTexture;
-import android.os.Build;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
@@ -24,16 +23,12 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
-import android.view.inputmethod.InputMethodManager;
import android.widget.FrameLayout;
import org.libreoffice.LibreOfficeMainActivity;
import org.libreoffice.R;
import org.mozilla.gecko.OnInterceptTouchListener;
-import java.lang.reflect.Method;
-import java.nio.IntBuffer;
-
/**
* A view rendered by the layer compositor.
*
@@ -246,9 +241,6 @@ public class LayerView extends FrameLayout {
}
public void requestRender() {
- if (mRenderControllerThread != null) {
- mRenderControllerThread.renderFrame();
- }
if (mListener != null) {
mListener.renderRequested();
}
@@ -324,9 +316,7 @@ public class LayerView extends FrameLayout {
private void onSizeChanged(int width, int height) {
mGLController.surfaceChanged(width, height);
- if (mRenderControllerThread != null) {
- mRenderControllerThread.surfaceChanged(width, height);
- }
+ mLayerClient.setViewportSize(new FloatSize(width, height));
if (mListener != null) {
mListener.surfaceChanged(width, height);
@@ -336,10 +326,6 @@ public class LayerView extends FrameLayout {
private void onDestroyed() {
mGLController.surfaceDestroyed();
- if (mRenderControllerThread != null) {
- mRenderControllerThread.surfaceDestroyed();
- }
-
if (mListener != null) {
mListener.compositionPauseRequested();
}
@@ -430,6 +416,7 @@ public class LayerView extends FrameLayout {
Log.e(LOGTAG, "### Creating GL thread!");
mRenderControllerThread = new RenderControllerThread(mGLController);
mRenderControllerThread.start();
+ setListener(mRenderControllerThread);
notifyAll();
}
@@ -447,18 +434,11 @@ public class LayerView extends FrameLayout {
Log.e(LOGTAG, "### Destroying GL thread!");
Thread thread = mRenderControllerThread;
mRenderControllerThread.shutdown();
+ setListener(null);
mRenderControllerThread = null;
return thread;
}
- public synchronized void recreateSurface() {
- if (mRenderControllerThread == null) {
- throw new LayerViewException("recreateSurface() called with no GL thread active!");
- }
-
- mRenderControllerThread.recreateSurface();
- }
-
public static class LayerViewException extends RuntimeException {
public static final long serialVersionUID = 1L;
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/RenderControllerThread.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/RenderControllerThread.java
index df710bf..dc211c4 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/RenderControllerThread.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/RenderControllerThread.java
@@ -6,7 +6,7 @@ import java.util.concurrent.LinkedBlockingQueue;
import javax.microedition.khronos.opengles.GL10;
-public class RenderControllerThread extends Thread {
+public class RenderControllerThread extends Thread implements LayerView.Listener {
private LinkedBlockingQueue<RenderCommand> queue = new LinkedBlockingQueue<RenderCommand>();
private GLController controller;
private boolean renderQueued = false;
@@ -38,9 +38,6 @@ public class RenderControllerThread extends Thread {
case SHUTDOWN:
doShutdown();
break;
- case RECREATE_SURFACE:
- doRecreateSurface();
- break;
case RENDER_FRAME:
doRenderFrame();
break;
@@ -56,11 +53,17 @@ public class RenderControllerThread extends Thread {
}
}
- public void recreateSurface() {
- queue.add(RenderCommand.RECREATE_SURFACE);
+ public void shutdown() {
+ queue.add(RenderCommand.SHUTDOWN);
+ }
+
+ @Override
+ public void compositorCreated() {
+
}
- public void renderFrame() {
+ @Override
+ public void renderRequested() {
synchronized (this) {
if (!renderQueued) {
queue.add(RenderCommand.RENDER_FRAME);
@@ -69,10 +72,17 @@ public class RenderControllerThread extends Thread {
}
}
- public void shutdown() {
- queue.add(RenderCommand.SHUTDOWN);
+ @Override
+ public void compositionPauseRequested() {
+ queue.add(RenderCommand.SURFACE_DESTROYED);
}
+ @Override
+ public void compositionResumeRequested(int width, int height) {
+
+ }
+
+ @Override
public void surfaceChanged(int width, int height) {
this.width = width;
this.height = height;
@@ -83,15 +93,6 @@ public class RenderControllerThread extends Thread {
queue.add(RenderCommand.SURFACE_CREATED);
}
- public void surfaceDestroyed() {
- queue.add(RenderCommand.SURFACE_DESTROYED);
- }
-
- private void doRecreateSurface() {
- controller.disposeGLContext();
- controller.initGLContext();
- }
-
private GLSurfaceView.Renderer getRenderer() {
return controller.getView().getRenderer();
}
More information about the Libreoffice-commits
mailing list