[Libreoffice-commits] core.git: Branch 'feature/droid_calcimpress3' - 9 commits - android/experimental
Tomaž Vajngerl
tomaz.vajngerl at collabora.com
Sat Oct 4 07:17:05 PDT 2014
android/experimental/LOAndroid3/res/layout/activity_main.xml | 14
android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java | 4
android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java | 41 +-
android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java | 44 ++
android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java | 8
android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java | 4
android/experimental/LOAndroid3/src/java/org/libreoffice/ViewFactory.java | 32 ++
android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/DynamicTileLayer.java | 24 -
android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GLController.java | 28 -
android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java | 19 -
android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerController.java | 20 -
android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerRenderer.java | 4
android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java | 155 +++++++---
android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/SubTile.java | 61 ++-
14 files changed, 318 insertions(+), 140 deletions(-)
New commits:
commit af162f96745caca0355ba3d1c853a8dd693bdfa3
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Sat Oct 4 16:17:58 2014 +0200
android: Better detection of HW accel. (needed by TextureView)
Change-Id: I32b091d13d9236cee654819e701c583041f869bb
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 0a993a7..ad5ad66 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
@@ -20,6 +20,7 @@ import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.TextureView;
+import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
@@ -27,6 +28,7 @@ import android.widget.FrameLayout;
import org.libreoffice.LibreOfficeMainActivity;
+import java.lang.reflect.Method;
import java.nio.IntBuffer;
/**
@@ -61,21 +63,38 @@ public class LayerView extends FrameLayout {
public static final int PAINT_BEFORE_FIRST = 1;
public static final int PAINT_AFTER_FIRST = 2;
+ boolean shouldUseTextureView() {
+ // we can only use TextureView on ICS or higher
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+ Log.i(LOGTAG, "Not using TextureView: not on ICS+");
+ return false;
+ }
+
+ try {
+ // and then we can only use it if we have a hardware accelerated window
+ Method m = View.class.getMethod("isHardwareAccelerated", new Class[0]);
+ return (Boolean) m.invoke(this);
+ } catch (Exception e) {
+ Log.i(LOGTAG, "Not using TextureView: caught exception checking for hw accel: " + e.toString());
+ return false;
+ }
+ }
+
public LayerView(Context context, AttributeSet attrs) {
super(context, attrs);
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+ if (shouldUseTextureView()) {
+ mTextureView = new TextureView(context);
+ mTextureView.setSurfaceTextureListener(new SurfaceTextureListener());
+
+ addView(mTextureView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
+ } else {
mSurfaceView = new SurfaceView(context);
addView(mSurfaceView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
SurfaceHolder holder = mSurfaceView.getHolder();
holder.addCallback(new SurfaceListener());
holder.setFormat(PixelFormat.RGB_565);
- } else {
- mTextureView = new TextureView(context);
- mTextureView.setSurfaceTextureListener(new SurfaceTextureListener());
-
- addView(mTextureView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
}
mGLController = new GLController(this);
@@ -279,7 +298,7 @@ public class LayerView extends FrameLayout {
}
public Object getNativeWindow() {
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH)
+ if (mSurfaceView != null)
return mSurfaceView.getHolder();
return mTextureView.getSurfaceTexture();
commit 124ce0feabced374ad48233341fb3e9cb30734dc
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Sat Oct 4 16:09:26 2014 +0200
android: move getDrawable to LayerView (Fennec import)
Change-Id: Idd15003939574963f836bfab1e0c5385957ab18b
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
index 583773b..eba732f 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
@@ -52,7 +52,7 @@ public class MockTileProvider implements TileProvider {
tileNumber += 1; // 0 to 1 based numbering
String imageName = "d" + tileNumber;
- Bitmap bitmap = layerController.getDrawable(imageName);
+ Bitmap bitmap = layerController.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.getDrawable("dummy_page");
+ return layerController.getView().getDrawable("dummy_page");
}
@Override
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 f35ee9d..c641c75 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
@@ -6,9 +6,6 @@
package org.mozilla.gecko.gfx;
import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.PointF;
import android.graphics.RectF;
@@ -104,9 +101,6 @@ public class LayerController implements PanZoomTarget {
return mViewportMetrics.getSize();
}
- public Bitmap getBackgroundPattern() { return getDrawable("background"); }
- public Bitmap getShadowPattern() { return getDrawable("shadow"); }
-
public PanZoomController getPanZoomController() { return mPanZoomController; }
public GestureDetector.OnGestureListener getGestureListener() { return mPanZoomController; }
public SimpleScaleGestureDetector.SimpleScaleGestureListener getScaleGestureListener() {
@@ -114,14 +108,6 @@ public class LayerController implements PanZoomTarget {
}
public GestureDetector.OnDoubleTapListener getDoubleTapListener() { return mPanZoomController; }
- public Bitmap getDrawable(String name) {
- Resources resources = mContext.getResources();
- int resourceID = resources.getIdentifier(name, "drawable", mContext.getPackageName());
- BitmapFactory.Options options = new BitmapFactory.Options();
- options.inScaled = false;
- return BitmapFactory.decodeResource(mContext.getResources(), resourceID, options);
- }
-
/**
* The view calls this function to indicate that the viewport changed size. It must hold the
* monitor while calling it.
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerRenderer.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerRenderer.java
index dcedaae..b4975da 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerRenderer.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerRenderer.java
@@ -160,12 +160,12 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
LayerController controller = view.getController();
- CairoImage backgroundImage = new BufferedCairoImage(controller.getBackgroundPattern());
+ CairoImage backgroundImage = new BufferedCairoImage(view.getBackgroundPattern());
mBackgroundLayer = new SingleTileLayer(true, backgroundImage);
mScreenshotLayer = ScreenshotLayer.create();
- CairoImage shadowImage = new BufferedCairoImage(controller.getShadowPattern());
+ CairoImage shadowImage = new BufferedCairoImage(view.getShadowPattern());
mShadowLayer = new NinePatchTileLayer(shadowImage);
mHorizScrollLayer = ScrollbarLayer.create(this, false);
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 505f933..0a993a7 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
@@ -7,7 +7,9 @@ package org.mozilla.gecko.gfx;
import android.content.Context;
+import android.content.res.Resources;
import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
import android.graphics.PixelFormat;
import android.graphics.SurfaceTexture;
import android.os.Build;
@@ -235,6 +237,23 @@ public class LayerView extends FrameLayout {
return mGLController;
}
+ public Bitmap getDrawable(String name) {
+ Context context = getContext();
+ Resources resources = context.getResources();
+ int resourceID = resources.getIdentifier(name, "drawable", context.getPackageName());
+ BitmapFactory.Options options = new BitmapFactory.Options();
+ options.inScaled = false;
+ return BitmapFactory.decodeResource(context.getResources(), resourceID, options);
+ }
+
+ Bitmap getBackgroundPattern() {
+ return getDrawable("background");
+ }
+
+ Bitmap getShadowPattern() {
+ return getDrawable("shadow");
+ }
+
private void onSizeChanged(int width, int height) {
mGLController.surfaceChanged(width, height);
commit e7c9250a5aba60919116de07614c480116b399cd
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Sat Oct 4 15:53:44 2014 +0200
android: use TextureView instead of SurfaceView for ICS+ devices
Change-Id: I4c5585d5eac4faf46ad9bed2d3992fe87b3d9a03
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GLController.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GLController.java
index 9bd7d2f..e296f47 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GLController.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GLController.java
@@ -5,8 +5,6 @@
package org.mozilla.gecko.gfx;
-import android.view.SurfaceHolder;
-
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGL11;
import javax.microedition.khronos.egl.EGLConfig;
@@ -119,8 +117,15 @@ public class GLController {
return true;
}
+ // This function is invoked by JNI
+ public synchronized void resumeCompositorIfValid() {
+ if (mSurfaceValid) {
+ mView.getListener().compositionResumeRequested(mWidth, mHeight);
+ }
+ }
+
// Wait until we are allowed to use EGL functions on the Surface backing
- // this window.
+ // this window. This function is invoked by JNI
public synchronized void waitForValidSurface() {
while (!mSurfaceValid) {
try {
@@ -139,19 +144,16 @@ public class GLController {
return mHeight;
}
- synchronized void surfaceCreated() {
- mSurfaceValid = true;
- notifyAll();
- }
-
synchronized void surfaceDestroyed() {
mSurfaceValid = false;
notifyAll();
}
- synchronized void sizeChanged(int newWidth, int newHeight) {
+ synchronized void surfaceChanged(int newWidth, int newHeight) {
mWidth = newWidth;
mHeight = newHeight;
+ mSurfaceValid = true;
+ notifyAll();
}
private void initEGL() {
@@ -218,8 +220,8 @@ public class GLController {
}
private void createEGLSurface() {
- SurfaceHolder surfaceHolder = mView.getHolder();
- mEGLSurface = mEGL.eglCreateWindowSurface(mEGLDisplay, mEGLConfig, surfaceHolder, null);
+ Object window = mView.getNativeWindow();
+ mEGLSurface = mEGL.eglCreateWindowSurface(mEGLDisplay, mEGLConfig, window, null);
if (mEGLSurface == null || mEGLSurface == EGL10.EGL_NO_SURFACE) {
throw new GLControllerException("EGL window surface could not be created! " +
getEGLError());
@@ -248,8 +250,8 @@ public class GLController {
initEGL();
}
- SurfaceHolder surfaceHolder = mView.getHolder();
- EGLSurface surface = mEGL.eglCreateWindowSurface(mEGLDisplay, mEGLConfig, surfaceHolder, null);
+ Object window = mView.getNativeWindow();
+ EGLSurface surface = mEGL.eglCreateWindowSurface(mEGLDisplay, mEGLConfig, window, null);
if (surface == null || surface == EGL10.EGL_NO_SURFACE) {
throw new GLControllerException("EGL window surface could not be created! " +
getEGLError());
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 cf4ba34..9b7dd39 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
@@ -227,23 +227,23 @@ public class GeckoLayerClient implements LayerView.Listener {
}
@Override
- public void renderRequested() {
+ public void compositorCreated() {
+ }
+ @Override
+ public void renderRequested() {
}
@Override
public void compositionPauseRequested() {
-
}
@Override
public void compositionResumeRequested(int width, int height) {
-
}
@Override
public void surfaceChanged(int width, int height) {
- compositionResumeRequested(width, height);
renderRequested();
}
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 874d10a..505f933 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
@@ -9,14 +9,19 @@ package org.mozilla.gecko.gfx;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.PixelFormat;
+import android.graphics.SurfaceTexture;
+import android.os.Build;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
+import android.view.TextureView;
+import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
+import android.widget.FrameLayout;
import org.libreoffice.LibreOfficeMainActivity;
@@ -30,7 +35,7 @@ import java.nio.IntBuffer;
*
* Note that LayerView is accessed by Robocop via reflection.
*/
-public class LayerView extends SurfaceView implements SurfaceHolder.Callback {
+public class LayerView extends FrameLayout {
private static String LOGTAG = "GeckoLayerView";
private LayerController mController;
@@ -43,6 +48,9 @@ public class LayerView extends SurfaceView implements SurfaceHolder.Callback {
/* Must be a PAINT_xxx constant */
private int mPaintState = PAINT_NONE;
+ private SurfaceView mSurfaceView;
+ private TextureView mTextureView;
+
private Listener mListener;
/* Flags used to determine when to show the painted surface. The integer
@@ -54,9 +62,19 @@ public class LayerView extends SurfaceView implements SurfaceHolder.Callback {
public LayerView(Context context, AttributeSet attrs) {
super(context, attrs);
- SurfaceHolder holder = getHolder();
- holder.addCallback(this);
- holder.setFormat(PixelFormat.RGB_565);
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+ mSurfaceView = new SurfaceView(context);
+ addView(mSurfaceView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
+
+ SurfaceHolder holder = mSurfaceView.getHolder();
+ holder.addCallback(new SurfaceListener());
+ holder.setFormat(PixelFormat.RGB_565);
+ } else {
+ mTextureView = new TextureView(context);
+ mTextureView.setSurfaceTextureListener(new SurfaceTextureListener());
+
+ addView(mTextureView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
+ }
mGLController = new GLController(this);
}
@@ -217,10 +235,8 @@ public class LayerView extends SurfaceView implements SurfaceHolder.Callback {
return mGLController;
}
- /** Implementation of SurfaceHolder.Callback */
- public synchronized void surfaceChanged(SurfaceHolder holder, int format, int width,
- int height) {
- mGLController.sizeChanged(width, height);
+ private void onSizeChanged(int width, int height) {
+ mGLController.surfaceChanged(width, height);
if (mGLThread != null) {
mGLThread.surfaceChanged(width, height);
@@ -231,16 +247,7 @@ public class LayerView extends SurfaceView implements SurfaceHolder.Callback {
}
}
- /** Implementation of SurfaceHolder.Callback */
- public synchronized void surfaceCreated(SurfaceHolder holder) {
- mGLController.surfaceCreated();
- if (mGLThread != null) {
- mGLThread.surfaceCreated();
- }
- }
-
- /** Implementation of SurfaceHolder.Callback */
- public synchronized void surfaceDestroyed(SurfaceHolder holder) {
+ private void onDestroyed() {
mGLController.surfaceDestroyed();
if (mGLThread != null) {
@@ -252,24 +259,73 @@ public class LayerView extends SurfaceView implements SurfaceHolder.Callback {
}
}
+ public Object getNativeWindow() {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH)
+ return mSurfaceView.getHolder();
+
+ return mTextureView.getSurfaceTexture();
+ }
+
/** 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.mListener.compositorCreated();
return layerView.getGLController();
} catch (Exception e) {
- Log.e(LOGTAG, "### Exception! " + e);
+ Log.e(LOGTAG, "Error registering compositor!", e);
return null;
}
}
public interface Listener {
+ void compositorCreated();
void renderRequested();
void compositionPauseRequested();
void compositionResumeRequested(int width, int height);
void surfaceChanged(int width, int height);
}
+ private class SurfaceListener implements SurfaceHolder.Callback {
+ public void surfaceChanged(SurfaceHolder holder, int format, int width,
+ int height) {
+ onSizeChanged(width, height);
+ }
+
+ public void surfaceCreated(SurfaceHolder holder) {
+ if (mGLThread != null) {
+ mGLThread.surfaceCreated();
+ }
+ }
+
+ public void surfaceDestroyed(SurfaceHolder holder) {
+ onDestroyed();
+ }
+ }
+
+ private class SurfaceTextureListener implements TextureView.SurfaceTextureListener {
+ public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
+ // We don't do this for surfaceCreated above because it is always followed by a surfaceChanged,
+ // but that is not the case here.
+ if (mGLThread != null) {
+ mGLThread.surfaceCreated();
+ }
+ onSizeChanged(width, height);
+ }
+
+ public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
+ onDestroyed();
+ return true; // allow Android to call release() on the SurfaceTexture, we are done drawing to it
+ }
+
+ public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
+ onSizeChanged(width, height);
+ }
+
+ public void onSurfaceTextureUpdated(SurfaceTexture surface) {
+ }
+ }
+
private GLThread mGLThread; // Protected by this class's monitor.
public synchronized void createGLThread() {
commit 84a44f1272338bc54bfa668ccf7168f733687930
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Sat Oct 4 15:51:02 2014 +0200
android: assure document close, introduce message box for errors
Change-Id: I4d5607d5568ebf73a61067975c21e740020cc8f7
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
index c904942..bd1b27b 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
@@ -8,7 +8,6 @@ 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.FloatSize;
import org.mozilla.gecko.gfx.IntSize;
import org.mozilla.gecko.gfx.LayerController;
@@ -16,13 +15,14 @@ import java.nio.ByteBuffer;
public class LOKitTileProvider implements TileProvider {
private static final String LOGTAG = LOKitTileProvider.class.getSimpleName();
- public static int TILE_SIZE = 256;
- public final Office mOffice;
- public final Document mDocument;
+ private static int TILE_SIZE = 256;
+ private final Office mOffice;
+ private Document mDocument;
private final LayerController mLayerController;
private final float mTileWidth;
private final float mTileHeight;
private final String mInputFile;
+ private boolean mIsReady = false;
private float mDPI;
private float mWidthTwip;
@@ -70,6 +70,8 @@ public class LOKitTileProvider implements TileProvider {
LibreOfficeMainActivity.mAppContext.getDocumentPartViewListAdpater().notifyDataSetChanged();
}
});
+
+ mIsReady = true;
}
}
@@ -108,8 +110,15 @@ public class LOKitTileProvider implements TileProvider {
mWidthTwip = mDocument.getDocumentWidth();
mHeightTwip = mDocument.getDocumentHeight();
- if (mWidthTwip == 0 && mHeightTwip == 0) {
+ if (mWidthTwip == 0 || mHeightTwip == 0) {
Log.e(LOGTAG, "Document size zero - last error: " + mOffice.getError());
+ LOKitShell.getMainHandler().post(new Runnable() {
+ @Override
+ public void run() {
+ LibreOfficeMainActivity.mAppContext.showAlertDialog("Document has no size!");
+ }
+ });
+ return false;
} else {
Log.i(LOGTAG, "Document size: " + mDocument.getDocumentWidth() + " x " + mDocument.getDocumentHeight());
}
@@ -129,7 +138,7 @@ public class LOKitTileProvider implements TileProvider {
@Override
public boolean isReady() {
- return mDocument != null;
+ return mIsReady;
}
@Override
@@ -143,7 +152,7 @@ public class LOKitTileProvider implements TileProvider {
float twipWidth = mTileWidth / zoom;
float twipHeight = mTileHeight / zoom;
long start = System.currentTimeMillis();
- Log.i(LOGTAG, "paintTile TOP @ " + start + "(" + tileSize.width + " " + tileSize.height + " " + (int)twipX + " " + (int)twipY + " " + (int) twipWidth + " " + (int) twipHeight + ")");
+ Log.i(LOGTAG, "paintTile TOP @ " + start + "(" + tileSize.width + " " + tileSize.height + " " + (int) twipX + " " + (int) twipY + " " + (int) twipWidth + " " + (int) twipHeight + ")");
mDocument.paintTile(buffer, tileSize.width, tileSize.height, (int) twipX, (int) twipY, (int) twipWidth, (int) twipHeight);
long stop = System.currentTimeMillis();
Log.i(LOGTAG, "paintTile TAIL @ " + stop + " - elapsed: " + (stop - start) + " ");
@@ -173,6 +182,8 @@ public class LOKitTileProvider implements TileProvider {
widthPixel = (int) (heightPixel * ratio);
}
+ Log.w(LOGTAG, "Thumbnail size: " + getPageWidth() + " " + getPageHeight() + " " + widthPixel + " " + heightPixel);
+
ByteBuffer buffer = ByteBuffer.allocateDirect(widthPixel * heightPixel * 4);
mDocument.paintTile(buffer, widthPixel, heightPixel, 0, 0, (int) mWidthTwip, (int) mHeightTwip);
@@ -189,10 +200,17 @@ public class LOKitTileProvider implements TileProvider {
Log.i(LOGTAG, "Document destroyed: " + mInputFile);
if (mDocument != null) {
mDocument.destroy();
+ mDocument = null;
}
}
@Override
+ protected void finalize() throws Throwable {
+ close();
+ super.finalize();
+ }
+
+ @Override
public void changePart(int partIndex) {
mDocument.setPart(partIndex);
}
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
index aa4f70c..c5ecccb 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -2,6 +2,7 @@ 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;
@@ -132,7 +133,7 @@ public class LibreOfficeMainActivity extends Activity {
mLayerController = new LayerController(this);
mLayerController.setZoomConstraints(new ZoomConstraints(true));
mLayerClient = new GeckoLayerClient(this);
- LayerView layerView = (LayerView)findViewById(R.id.layer_view);
+ LayerView layerView = (LayerView) findViewById(R.id.layer_view);
mLayerController.setView(layerView);
mLayerController.setLayerClient(mLayerClient);
@@ -147,10 +148,28 @@ public class LibreOfficeMainActivity extends Activity {
@Override
protected void onPause() {
- Log.i(LOGTAG, "Pause..");
+ Log.i(LOGTAG, "onPause..");
super.onPause();
}
+ @Override
+ protected void onStart() {
+ Log.i(LOGTAG, "onStart..");
+ super.onStop();
+ }
+
+ @Override
+ protected void onStop() {
+ Log.i(LOGTAG, "onStop..");
+ super.onStop();
+ }
+
+ @Override
+ protected void onDestroy() {
+ Log.i(LOGTAG, "onDestroy..");
+ super.onDestroy();
+ }
+
public LOKitThread getLOKitThread() {
return sLOKitThread;
}
@@ -212,6 +231,22 @@ public class LibreOfficeMainActivity extends Activity {
findViewById(R.id.loadingPanel).setVisibility(View.GONE);
}
+ public void showAlertDialog(String s) {
+
+ AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(LibreOfficeMainActivity.this);
+
+ alertDialogBuilder.setTitle("Error");
+ alertDialogBuilder.setMessage(s);
+ alertDialogBuilder.setNeutralButton("OK", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ finish();
+ }
+ });
+
+ AlertDialog alertDialog = alertDialogBuilder.create();
+ alertDialog.show();
+ }
+
private class DocumentPartClickListener implements android.widget.AdapterView.OnItemClickListener {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
index 5de6a82..583773b 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
@@ -4,7 +4,6 @@ import android.graphics.Bitmap;
import org.mozilla.gecko.gfx.BufferedCairoImage;
import org.mozilla.gecko.gfx.CairoImage;
-import org.mozilla.gecko.gfx.FloatSize;
import org.mozilla.gecko.gfx.IntSize;
import org.mozilla.gecko.gfx.LayerController;
commit ce530cbab0831f8362d1ddc5bd221d72e9351fea
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Sat Oct 4 15:47:44 2014 +0200
androdi: set TileProvider only when document is ready
Change-Id: Iada0e4513cc00248f45c97bfecbc91590e80a437
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
index 398389b..528f419 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
@@ -74,10 +74,10 @@ public class LOKitThread extends Thread {
}
mTileProvider = TileProviderFactory.create(mController, filename);
- mLayerClient.setTileProvider(mTileProvider);
-
boolean isReady = mTileProvider.isReady();
if (isReady) {
+ mLayerClient.setTileProvider(mTileProvider);
+
LOKitShell.showProgressSpinner();
refresh();
LOKitShell.hideProgressSpinner();
commit cbe7d42df1c33b5e61a717a9228dccd340c800d2
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Thu Oct 2 16:16:33 2014 +0200
android: TileIdentifier - contains tile position and zoom
Change-Id: Ia82dc1f99eff5117fe16df2b61c1a7230b52e07a
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 407cdc1..01ab8be 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 27f11fc..7e60af1 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;
+ }
}
}
commit cfd2146a419f91861e19e624f6f3aeddff64431d
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Thu Oct 2 15:56:00 2014 +0200
android: construct LayerView in xml GUI definition (activity_main)
Change-Id: I6cd3c8dff2ca36f3d64559b218d005d5a6da9066
diff --git a/android/experimental/LOAndroid3/res/layout/activity_main.xml b/android/experimental/LOAndroid3/res/layout/activity_main.xml
index fd7d63b..1b1bb07 100644
--- a/android/experimental/LOAndroid3/res/layout/activity_main.xml
+++ b/android/experimental/LOAndroid3/res/layout/activity_main.xml
@@ -16,19 +16,25 @@
android:id="@+id/gecko_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
- android:layout_weight="1"/>
+ android:layout_weight="1">
+
+ <org.mozilla.gecko.gfx.LayerView
+ android:id="@+id/layer_view"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"/>
+ </RelativeLayout>
<RelativeLayout
android:id="@+id/loadingPanel"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:gravity="center"
- android:background="#9333">
+ android:background="#9333"
+ android:gravity="center">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:indeterminate="true" />
+ android:indeterminate="true"/>
</RelativeLayout>
<View
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
index 8607ebf..aa4f70c 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -9,6 +9,7 @@ import android.os.Handler;
import android.support.v4.widget.DrawerLayout;
import android.util.DisplayMetrics;
import android.util.Log;
+import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@@ -21,6 +22,7 @@ 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;
import java.util.List;
@@ -96,6 +98,8 @@ public class LibreOfficeMainActivity extends Activity {
mMainHandler = new Handler();
+ LayoutInflater.from(this).setFactory(ViewFactory.getInstance());
+
if (getIntent().getData() != null) {
mInputFile = getIntent().getData().getEncodedPath();
} else {
@@ -128,8 +132,9 @@ public class LibreOfficeMainActivity extends Activity {
mLayerController = new LayerController(this);
mLayerController.setZoomConstraints(new ZoomConstraints(true));
mLayerClient = new GeckoLayerClient(this);
+ LayerView layerView = (LayerView)findViewById(R.id.layer_view);
+ mLayerController.setView(layerView);
mLayerController.setLayerClient(mLayerClient);
- mGeckoLayout.addView(mLayerController.getView(), 0);
LOKitShell.sendEvent(LOEventFactory.load(mInputFile));
}
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/ViewFactory.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/ViewFactory.java
new file mode 100644
index 0000000..c26ad22
--- /dev/null
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ViewFactory.java
@@ -0,0 +1,32 @@
+package org.libreoffice;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+
+import org.mozilla.gecko.gfx.LayerView;
+
+public class ViewFactory implements LayoutInflater.Factory {
+ private static final String LOGTAG = ViewFactory.class.getSimpleName();
+ private static final String LAYER_VIEW_ID = "org.mozilla.gecko.gfx.LayerView";
+ private static final ViewFactory INSTANCE = new ViewFactory();
+
+ private ViewFactory() {
+ }
+
+ public static LayoutInflater.Factory getInstance() {
+ return INSTANCE;
+ }
+
+ @Override
+ public View onCreateView(String name, Context context, AttributeSet attrs) {
+ if (name.equals(LAYER_VIEW_ID)) {
+ Log.i(LOGTAG, "Creating custom Gecko view: " + name);
+ return new LayerView(context, attrs);
+ }
+
+ return null;
+ }
+}
\ No newline at end of file
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 2e6a4a0..f35ee9d 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
@@ -69,11 +69,15 @@ public class LayerController implements PanZoomTarget {
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
mViewportMetrics = new ImmutableViewportMetrics(displayMetrics);
mPanZoomController = new PanZoomController(this);
- mView = new LayerView(context, this);
mCheckerboardShouldShowChecks = true;
mZoomConstraints = new ZoomConstraints(false);
}
+ public void setView(LayerView v) {
+ mView = v;
+ mView.connect(this);
+ }
+
public void setRoot(Layer layer) { mRootLayer = layer; }
public void setLayerClient(GeckoLayerClient layerClient) {
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 38a09d8..874d10a 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
@@ -9,6 +9,7 @@ package org.mozilla.gecko.gfx;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.PixelFormat;
+import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -32,7 +33,6 @@ import java.nio.IntBuffer;
public class LayerView extends SurfaceView implements SurfaceHolder.Callback {
private static String LOGTAG = "GeckoLayerView";
- private Context mContext;
private LayerController mController;
private TouchEventHandler mTouchEventHandler;
private GLController mGLController;
@@ -51,18 +51,19 @@ public class LayerView extends SurfaceView implements SurfaceHolder.Callback {
public static final int PAINT_BEFORE_FIRST = 1;
public static final int PAINT_AFTER_FIRST = 2;
-
- public LayerView(Context context, LayerController controller) {
- super(context);
+ public LayerView(Context context, AttributeSet attrs) {
+ super(context, attrs);
SurfaceHolder holder = getHolder();
holder.addCallback(this);
holder.setFormat(PixelFormat.RGB_565);
mGLController = new GLController(this);
- mContext = context;
+ }
+
+ void connect(LayerController controller) {
mController = controller;
- mTouchEventHandler = new TouchEventHandler(context, this, mController);
+ mTouchEventHandler = new TouchEventHandler(getContext(), this, mController);
mRenderer = new LayerRenderer(this);
mInputConnectionHandler = null;
@@ -208,6 +209,10 @@ public class LayerView extends SurfaceView implements SurfaceHolder.Callback {
mListener = listener;
}
+ Listener getListener() {
+ return mListener;
+ }
+
public GLController getGLController() {
return mGLController;
}
@@ -267,10 +272,6 @@ public class LayerView extends SurfaceView implements SurfaceHolder.Callback {
private GLThread mGLThread; // Protected by this class's monitor.
- /**
- * Creates a Java GL thread. After this is called, the FlexibleGLSurfaceView may be used just
- * like a GLSurfaceView. It is illegal to access the controller after this has been called.
- */
public synchronized void createGLThread() {
if (mGLThread != null) {
throw new LayerViewException ("createGLThread() called with a GL thread already in place!");
@@ -282,10 +283,6 @@ public class LayerView extends SurfaceView implements SurfaceHolder.Callback {
notifyAll();
}
- /**
- * Destroys the Java GL thread. Returns a Thread that completes when the Java GL thread is
- * fully shut down.
- */
public synchronized Thread destroyGLThread() {
// Wait for the GL thread to be started.
Log.e(LOGTAG, "### Waiting for GL thread to be created...");
commit e4c4a41c292e93619d31313065cc85186a6c9f0c
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Thu Oct 2 15:50:53 2014 +0200
android: use tile size and change the type to IntSize
Change-Id: Id19c3517fc6fb59307c81a0c1c8868e0d0c777b4
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
index 4fdf84f..c904942 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
@@ -9,6 +9,7 @@ import org.libreoffice.kit.Office;
import org.mozilla.gecko.gfx.BufferedCairoImage;
import org.mozilla.gecko.gfx.CairoImage;
import org.mozilla.gecko.gfx.FloatSize;
+import org.mozilla.gecko.gfx.IntSize;
import org.mozilla.gecko.gfx.LayerController;
import java.nio.ByteBuffer;
@@ -132,9 +133,9 @@ public class LOKitTileProvider implements TileProvider {
}
@Override
- public CairoImage createTile(float x, float y, FloatSize tileSize, float zoom) {
- ByteBuffer buffer = ByteBuffer.allocateDirect(TILE_SIZE * TILE_SIZE * 4);
- Bitmap bitmap = Bitmap.createBitmap(TILE_SIZE, TILE_SIZE, Bitmap.Config.ARGB_8888);
+ public CairoImage createTile(float x, float y, IntSize tileSize, float zoom) {
+ ByteBuffer buffer = ByteBuffer.allocateDirect(tileSize.width * tileSize.height * 4);
+ Bitmap bitmap = Bitmap.createBitmap(tileSize.width, tileSize.height, Bitmap.Config.ARGB_8888);
if (mDocument != null) {
float twipX = pixelToTwip(x, mDPI) / zoom;
@@ -142,8 +143,8 @@ public class LOKitTileProvider implements TileProvider {
float twipWidth = mTileWidth / zoom;
float twipHeight = mTileHeight / zoom;
long start = System.currentTimeMillis();
- Log.i(LOGTAG, "paintTile TOP @ " + start + "(" + TILE_SIZE + " " + TILE_SIZE + " " + (int)twipX + " " + (int)twipY + " " + (int) twipWidth + " " + (int) twipHeight + ")");
- mDocument.paintTile(buffer, TILE_SIZE, TILE_SIZE, (int) twipX, (int) twipY, (int) twipWidth, (int) twipHeight);
+ Log.i(LOGTAG, "paintTile TOP @ " + start + "(" + tileSize.width + " " + tileSize.height + " " + (int)twipX + " " + (int)twipY + " " + (int) twipWidth + " " + (int) twipHeight + ")");
+ mDocument.paintTile(buffer, tileSize.width, tileSize.height, (int) twipX, (int) twipY, (int) twipWidth, (int) twipHeight);
long stop = System.currentTimeMillis();
Log.i(LOGTAG, "paintTile TAIL @ " + stop + " - elapsed: " + (stop - start) + " ");
} else {
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
index 672973c..5de6a82 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
@@ -5,6 +5,7 @@ import android.graphics.Bitmap;
import org.mozilla.gecko.gfx.BufferedCairoImage;
import org.mozilla.gecko.gfx.CairoImage;
import org.mozilla.gecko.gfx.FloatSize;
+import org.mozilla.gecko.gfx.IntSize;
import org.mozilla.gecko.gfx.LayerController;
public class MockTileProvider implements TileProvider {
@@ -45,7 +46,7 @@ public class MockTileProvider implements TileProvider {
}
@Override
- public CairoImage createTile(float x, float y, FloatSize tileSize, float zoom) {
+ public CairoImage createTile(float x, float y, IntSize tileSize, float zoom) {
int tiles = (int) (getPageWidth() / TILE_SIZE) + 1;
int tileNumber = (int) ((y / TILE_SIZE) * tiles + (x / TILE_SIZE));
tileNumber %= 9;
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java
index ada2360..12a47f6 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java
@@ -4,7 +4,7 @@ package org.libreoffice;
import android.graphics.Bitmap;
import org.mozilla.gecko.gfx.CairoImage;
-import org.mozilla.gecko.gfx.FloatSize;
+import org.mozilla.gecko.gfx.IntSize;
public interface TileProvider {
int getPageWidth();
@@ -13,7 +13,7 @@ public interface TileProvider {
boolean isReady();
- CairoImage createTile(float x, float y, FloatSize tileSize, float zoom);
+ CairoImage createTile(float x, float y, IntSize tileSize, float zoom);
void changePart(int partIndex);
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 1ad8d38..407cdc1 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
@@ -17,14 +17,14 @@ public class DynamicTileLayer extends Layer {
private final List<SubTile> tiles = new CopyOnWriteArrayList<SubTile>();
private TileProvider tileProvider;
- private final FloatSize tileSize;
+ private final IntSize tileSize;
private RectF currentViewport = new RectF();
public DynamicTileLayer() {
- this.tileSize = new FloatSize(256, 256);
+ this.tileSize = new IntSize(256, 256);
}
- public DynamicTileLayer(FloatSize tileSize) {
+ public DynamicTileLayer(IntSize tileSize) {
this.tileSize = tileSize;
}
@@ -108,7 +108,7 @@ public class DynamicTileLayer extends Layer {
}
}
- private RectF roundToTileSize(RectF input, FloatSize tileSize) {
+ private 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;
@@ -116,7 +116,7 @@ public class DynamicTileLayer extends Layer {
return new RectF(minX, minY, maxX, maxY);
}
- private RectF inflate(RectF rect, FloatSize inflateSize) {
+ private 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;
commit e61fe5a8a43830b93acc411ad94b776580030540
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Thu Oct 2 15:24:41 2014 +0200
android: remove unused windowSizeChanged tracking
Change-Id: I0d451d9fea83d70e69d07059e55a5e6067c45711
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 23095ef..cf4ba34 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
@@ -42,7 +42,6 @@ import android.content.Context;
import android.graphics.RectF;
import android.util.DisplayMetrics;
import android.util.Log;
-import android.view.View;
import org.libreoffice.LOEvent;
import org.libreoffice.LOEventFactory;
@@ -148,32 +147,24 @@ public class GeckoLayerClient implements LayerView.Listener {
private void sendResizeEventIfNecessary(boolean force) {
DisplayMetrics metrics = new DisplayMetrics();
LibreOfficeMainActivity.mAppContext.getWindowManager().getDefaultDisplay().getMetrics(metrics);
- View view = mLayerController.getView();
IntSize newScreenSize = new IntSize(metrics.widthPixels, metrics.heightPixels);
- IntSize newWindowSize = new IntSize(view.getWidth(), view.getHeight());
// Return immediately if the screen size hasn't changed or the viewport
// size is zero (which indicates that the rendering surface hasn't been
// allocated yet).
boolean screenSizeChanged = !mScreenSize.equals(newScreenSize);
- boolean windowSizeChanged = !mWindowSize.equals(newWindowSize);
- if (!force && !screenSizeChanged && !windowSizeChanged) {
+ if (!force && !screenSizeChanged) {
return;
}
mScreenSize = newScreenSize;
- mWindowSize = newWindowSize;
if (screenSizeChanged) {
Log.d(LOGTAG, "Screen-size changed to " + mScreenSize);
}
- if (windowSizeChanged) {
- Log.d(LOGTAG, "Window-size changed to " + mWindowSize);
- }
-
LOEvent event = LOEventFactory.sizeChanged(metrics.widthPixels, metrics.heightPixels);
LOKitShell.sendEvent(event);
}
More information about the Libreoffice-commits
mailing list