android/experimental/LOAndroid/.gitignore | 4 android/experimental/LOAndroid/.idea/.name | 1 android/experimental/LOAndroid/.idea/compiler.xml | 23 android/experimental/LOAndroid/.idea/copyright/profiles_settings.xml | 3 android/experimental/LOAndroid/.idea/encodings.xml | 5 android/experimental/LOAndroid/.idea/gradle.xml | 18 android/experimental/LOAndroid/.idea/libraries/appcompat_v7_19_1_0.xml | 10 android/experimental/LOAndroid/.idea/libraries/support_v4_19_1_0.xml | 11 android/experimental/LOAndroid/.idea/misc.xml | 146 android/experimental/LOAndroid/.idea/modules.xml | 10 android/experimental/LOAndroid/.idea/scopes/scope_settings.xml | 5 android/experimental/LOAndroid/.idea/vcs.xml | 7 android/experimental/LOAndroid/LOAndroid.iml | 12 android/experimental/LOAndroid/app/.gitignore | 1 android/experimental/LOAndroid/app/app.iml | 77 android/experimental/LOAndroid/app/build.gradle | 24 android/experimental/LOAndroid/app/proguard-rules.txt | 17 android/experimental/LOAndroid/app/src/main/AndroidManifest.xml | 25 android/experimental/LOAndroid/app/src/main/java/org/libreoffice/LOKitShell.java | 22 android/experimental/LOAndroid/app/src/main/java/org/libreoffice/MainActivity.java | 36 android/experimental/LOAndroid/app/src/main/java/org/libreoffice/MainLayerView.java | 26 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/TouchEventInterceptor.java | 14 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/ZoomConstraints.java | 46 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/Axis.java | 420 -- android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/BitmapUtils.java | 368 -- android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/BufferedCairoImage.java | 69 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/CairoGLInfo.java | 35 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/CairoImage.java | 28 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/CairoUtils.java | 51 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/DisplayPortCalculator.java | 777 ----- android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/DisplayPortMetrics.java | 78 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/DrawTimingQueue.java | 95 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/FloatSize.java | 54 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/GLController.java | 354 -- android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/GeckoLayerClient.java | 1000 ------ android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/ImmutableViewportMetrics.java | 374 -- android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/InputConnectionHandler.java | 22 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/IntSize.java | 91 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/JavaPanZoomController.java | 1461 ---------- android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/Layer.java | 207 - android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/LayerMarginsAnimator.java | 324 -- android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/LayerRenderer.java | 722 ---- android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/LayerView.java | 692 ---- android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/Overscroll.java | 21 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/OverscrollEdgeEffect.java | 130 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/PanZoomController.java | 49 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/PanZoomTarget.java | 33 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/PanningPerfAPI.java | 123 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/PointUtils.java | 51 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/ProgressiveUpdateData.java | 33 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/RectUtils.java | 126 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/RenderTask.java | 80 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/ScrollbarLayer.java | 297 -- android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/SimpleScaleGestureDetector.java | 322 -- android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/SingleTileLayer.java | 153 - android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/SubdocumentScrollHelper.java | 148 - android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/TextLayer.java | 69 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/TextureGenerator.java | 75 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/TextureReaper.java | 51 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/TileLayer.java | 177 - android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/TouchEventHandler.java | 306 -- android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/ViewTransform.java | 34 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/VirtualLayer.java | 36 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/mozglue/DirectBufferAllocator.java | 51 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/util/EventDispatcher.java | 115 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/util/FloatUtils.java | 43 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/util/GeckoBackgroundThread.java | 55 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/util/GeckoEventListener.java | 14 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/util/GeckoEventResponder.java | 16 android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/util/ThreadUtils.java | 169 - android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/util/UiAsyncTask.java | 86 android/experimental/LOAndroid/app/src/main/res/layout/activity_main.xml | 15 android/experimental/LOAndroid/app/src/main/res/menu/main.xml | 9 android/experimental/LOAndroid/app/src/main/res/values-w820dp/dimens.xml | 6 android/experimental/LOAndroid/app/src/main/res/values/colors.xml | 95 android/experimental/LOAndroid/app/src/main/res/values/dimens.xml | 5 android/experimental/LOAndroid/app/src/main/res/values/strings.xml | 8 android/experimental/LOAndroid/app/src/main/res/values/styles.xml | 8 android/experimental/LOAndroid/build.gradle | 16 android/experimental/LOAndroid/gradle.properties | 18 android/experimental/LOAndroid/gradle/wrapper/gradle-wrapper.properties | 6 android/experimental/LOAndroid/gradlew | 164 - android/experimental/LOAndroid/gradlew.bat | 90 android/experimental/LOAndroid/settings.gradle | 1 android/experimental/LOAndroid2/.gitignore | 4 android/experimental/LOAndroid2/.idea/.name | 1 android/experimental/LOAndroid2/.idea/compiler.xml | 23 android/experimental/LOAndroid2/.idea/copyright/profiles_settings.xml | 3 android/experimental/LOAndroid2/.idea/encodings.xml | 5 android/experimental/LOAndroid2/.idea/gradle.xml | 18 android/experimental/LOAndroid2/.idea/misc.xml | 41 android/experimental/LOAndroid2/.idea/modules.xml | 11 android/experimental/LOAndroid2/.idea/scopes/scope_settings.xml | 5 android/experimental/LOAndroid2/.idea/vcs.xml | 7 android/experimental/LOAndroid2/LOAndroid2.iml | 19 android/experimental/LOAndroid2/app/.gitignore | 1 android/experimental/LOAndroid2/app/app.iml | 66 android/experimental/LOAndroid2/app/build.gradle | 23 android/experimental/LOAndroid2/app/proguard-rules.txt | 17 android/experimental/LOAndroid2/app/src/main/AndroidManifest.xml | 24 android/experimental/LOAndroid2/app/src/main/java/org/libreoffice/LOEvent.java | 67 android/experimental/LOAndroid2/app/src/main/java/org/libreoffice/LOKitShell.java | 131 android/experimental/LOAndroid2/app/src/main/java/org/libreoffice/LOKitThread.java | 157 - android/experimental/LOAndroid2/app/src/main/java/org/libreoffice/LibreOfficeMainActivity.java | 102 android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/GeckoEventListener.java | 44 android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/BufferedCairoImage.java | 105 android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/CairoGLInfo.java | 72 android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/CairoImage.java | 58 android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/CairoUtils.java | 85 android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/CheckerboardImage.java | 170 - android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/FlexibleGLSurfaceView.java | 218 - android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/FloatSize.java | 99 android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/GLController.java | 279 - android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/GLThread.java | 181 - android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/GeckoLayerClient.java | 398 -- android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/GeckoSoftwareLayerClient.java | 242 - android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/InputConnectionHandler.java | 15 android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/IntSize.java | 103 android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/Layer.java | 242 - android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/LayerClient.java | 81 android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/LayerController.java | 534 --- android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/LayerRenderer.java | 689 ---- android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/LayerView.java | 230 - android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/MultiTileLayer.java | 250 - android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/NinePatchTileLayer.java | 124 android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/PanningPerfAPI.java | 125 android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/PointUtils.java | 96 android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/RectUtils.java | 139 android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/ScrollbarLayer.java | 425 -- android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/SingleTileLayer.java | 127 android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/SubTile.java | 15 android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/TextLayer.java | 117 android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/TextureGenerator.java | 73 android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/TextureReaper.java | 76 android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/TileLayer.java | 256 - android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/ViewTransform.java | 51 android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/ViewportMetrics.java | 306 -- android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/VirtualLayer.java | 80 android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/gfx/WidgetTileLayer.java | 160 - android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/ui/Axis.java | 271 - android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/ui/PanZoomController.java | 921 ------ android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/ui/SimpleScaleGestureDetector.java | 332 -- android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/ui/SubdocumentScrollHelper.java | 140 android/experimental/LOAndroid2/app/src/main/java/org/mozilla/gecko/util/FloatUtils.java | 43 android/experimental/LOAndroid2/app/src/main/res/layout/activity_main.xml | 15 android/experimental/LOAndroid2/app/src/main/res/menu/main.xml | 8 android/experimental/LOAndroid2/app/src/main/res/values-w820dp/dimens.xml | 6 android/experimental/LOAndroid2/app/src/main/res/values/colors.xml | 95 android/experimental/LOAndroid2/app/src/main/res/values/dimens.xml | 5 android/experimental/LOAndroid2/app/src/main/res/values/strings.xml | 8 android/experimental/LOAndroid2/app/src/main/res/values/styles.xml | 8 android/experimental/LOAndroid2/build.gradle | 16 android/experimental/LOAndroid2/gradle.properties | 18 android/experimental/LOAndroid2/gradle/wrapper/gradle-wrapper.properties | 6 android/experimental/LOAndroid2/gradlew | 164 - android/experimental/LOAndroid2/gradlew.bat | 90 android/experimental/LOAndroid2/settings.gradle | 1 android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java | 8 android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java | 9 android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java | 11 android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/DynamicTileLayer.java | 5 android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/FixedZoomTileLayer.java | 9 dev/null |binary 163 files changed, 28 insertions(+), 20220 deletions(-)
New commits: commit bd219e3cba549694f2c190916626ae9e65f06c81 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> Date: Wed Dec 17 18:53:40 2014 +0900 android: tweak low-res tiles Change-Id: I2806f35ee112b9ea7ccf323e01372f7e2f68ffa2 diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java index cb924e3..e6799b6 100644 --- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java +++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java @@ -135,6 +135,7 @@ public abstract class ComposedTileLayer extends Layer { currentViewport = newCurrentViewPort; currentZoom = newZoom; + clearMarkedTiles(); addNewTiles(viewportMetrics); markTiles(viewportMetrics); } @@ -190,10 +191,8 @@ public abstract class ComposedTileLayer extends Layer { RectF tileRect = tile.id.getRect(); if (!RectF.intersects(currentViewport, tileRect)) { tile.markForRemoval(); - Log.i(LOGTAG, "Mark for remove - " + currentViewport + " " + tileRect); } } else { - Log.i(LOGTAG, "Mark for remove - " + tile.id.zoom + " " + zoom); tile.markForRemoval(); } } @@ -205,7 +204,6 @@ public abstract class ComposedTileLayer extends Layer { } public void addTile(SubTile tile) { - clearMarkedTiles(); tile.beginTransaction(); tiles.add(tile); } diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/FixedZoomTileLayer.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/FixedZoomTileLayer.java index 52a26f6..2db6a1d 100644 --- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/FixedZoomTileLayer.java +++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/FixedZoomTileLayer.java @@ -12,7 +12,7 @@ public class FixedZoomTileLayer extends ComposedTileLayer { @Override protected float getZoom(ImmutableViewportMetrics viewportMetrics) { - return 1.0f / 32.0f; + return 1.0f / 16.0f; } @Override @@ -21,6 +21,6 @@ public class FixedZoomTileLayer extends ComposedTileLayer { } private IntSize getInflateFactor() { - return tileSize.scale(3); + return new IntSize(tileSize.width, tileSize.height*6); } } commit 3df95150c1ab65b5d2dc1ed2bd2e2010e6132d32 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> Date: Wed Dec 17 18:45:57 2014 +0900 android: support to handle events with prioritization Low-res tiles should be handleded before normal tiles so for this add priority to tiles and store in a with priority queue. Change-Id: I8d36c14503d9b684816d99f577198ac34b729d15 diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java index ade57c7..ced5ebd 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java @@ -3,7 +3,7 @@ package org.libreoffice; import org.mozilla.gecko.gfx.ComposedTileLayer; import org.mozilla.gecko.gfx.IntSize; -public class LOEvent { +public class LOEvent implements Comparable<LOEvent> { public static final int SIZE_CHANGED = 1; public static final int TILE_SIZE = 2; @@ -14,6 +14,7 @@ public class LOEvent { public static final int TILE_REQUEST = 7; public final int mType; + public int mPriority = 0; public String mTypeString; public int mPartIndex; @@ -60,4 +61,9 @@ public class LOEvent { } return mTypeString; } + + @Override + public int compareTo(LOEvent another) { + return mPriority - another.mPriority; + } } diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java index 7888095..8bf8239 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java @@ -1,22 +1,17 @@ package org.libreoffice; -import android.graphics.Bitmap; -import android.graphics.RectF; -import android.util.DisplayMetrics; -import android.util.Log; - import org.mozilla.gecko.gfx.CairoImage; import org.mozilla.gecko.gfx.ComposedTileLayer; import org.mozilla.gecko.gfx.GeckoLayerClient; import org.mozilla.gecko.gfx.ImmutableViewportMetrics; import org.mozilla.gecko.gfx.SubTile; -import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.PriorityBlockingQueue; public class LOKitThread extends Thread { private static final String LOGTAG = LOKitThread.class.getSimpleName(); - private LinkedBlockingQueue<LOEvent> mEventQueue = new LinkedBlockingQueue<LOEvent>(); + private PriorityBlockingQueue<LOEvent> mEventQueue = new PriorityBlockingQueue<LOEvent>(); private LibreOfficeMainActivity mApplication; private TileProvider mTileProvider; private ImmutableViewportMetrics mViewportMetrics; diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java index 7c41db1..cb924e3 100644 --- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java +++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java @@ -4,6 +4,7 @@ import android.graphics.RectF; import android.graphics.Region; import android.util.Log; +import org.libreoffice.LOEvent; import org.libreoffice.LOEventFactory; import org.libreoffice.LOKitShell; import org.libreoffice.TileIdentifier; @@ -143,6 +144,8 @@ public abstract class ComposedTileLayer extends Layer { protected abstract float getZoom(ImmutableViewportMetrics viewportMetrics); + protected abstract int getTilePriority(); + private void addNewTiles(ImmutableViewportMetrics viewportMetrics) { float zoom = getZoom(viewportMetrics); @@ -161,7 +164,9 @@ public abstract class ComposedTileLayer extends Layer { } } if (!contains) { - LOKitShell.sendEvent(LOEventFactory.tileRequest(this, new TileIdentifier((int) x, (int) y, zoom, tileSize))); + LOEvent event = LOEventFactory.tileRequest(this, new TileIdentifier((int) x, (int) y, zoom, tileSize)); + event.mPriority = getTilePriority(); + LOKitShell.sendEvent(event); } } } 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 82d9928..12ff723 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 @@ -14,6 +14,11 @@ public class DynamicTileLayer extends ComposedTileLayer { return viewportMetrics.zoomFactor; } + @Override + protected int getTilePriority() { + return 0; + } + protected IntSize getInflateFactor() { return tileSize; } diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/FixedZoomTileLayer.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/FixedZoomTileLayer.java index 7b66916..52a26f6 100644 --- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/FixedZoomTileLayer.java +++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/FixedZoomTileLayer.java @@ -15,6 +15,11 @@ public class FixedZoomTileLayer extends ComposedTileLayer { return 1.0f / 32.0f; } + @Override + protected int getTilePriority() { + return -1; + } + private IntSize getInflateFactor() { return tileSize.scale(3); } commit 33e53de6ca2253ebfc1bc0501ab992cb915e16df Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> Date: Tue Dec 16 22:56:46 2014 +0900 android: remove old and unused LOAndroid and LOAndroid2 Change-Id: Ib25c4bb29081ae51a3b06a6fe2af76749ec8ea46 diff --git a/android/experimental/LOAndroid/.gitignore b/android/experimental/LOAndroid/.gitignore deleted file mode 100644 index d6bfc95..0000000 --- a/android/experimental/LOAndroid/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.gradle -/local.properties -/.idea/workspace.xml -.DS_Store diff --git a/android/experimental/LOAndroid/.idea/.name b/android/experimental/LOAndroid/.idea/.name deleted file mode 100644 index 3300c56..0000000 --- a/android/experimental/LOAndroid/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -LOAndroid \ No newline at end of file diff --git a/android/experimental/LOAndroid/.idea/compiler.xml b/android/experimental/LOAndroid/.idea/compiler.xml deleted file mode 100644 index 217af47..0000000 --- a/android/experimental/LOAndroid/.idea/compiler.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="CompilerConfiguration"> - <option name="DEFAULT_COMPILER" value="Javac" /> - <resourceExtensions /> - <wildcardResourcePatterns> - <entry name="!?*.java" /> - <entry name="!?*.form" /> - <entry name="!?*.class" /> - <entry name="!?*.groovy" /> - <entry name="!?*.scala" /> - <entry name="!?*.flex" /> - <entry name="!?*.kt" /> - <entry name="!?*.clj" /> - </wildcardResourcePatterns> - <annotationProcessing> - <profile default="true" name="Default" enabled="false"> - <processorPath useClasspath="true" /> - </profile> - </annotationProcessing> - </component> -</project> - diff --git a/android/experimental/LOAndroid/.idea/copyright/profiles_settings.xml b/android/experimental/LOAndroid/.idea/copyright/profiles_settings.xml deleted file mode 100644 index e7bedf3..0000000 --- a/android/experimental/LOAndroid/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ -<component name="CopyrightManager"> - <settings default="" /> -</component> \ No newline at end of file diff --git a/android/experimental/LOAndroid/.idea/encodings.xml b/android/experimental/LOAndroid/.idea/encodings.xml deleted file mode 100644 index e206d70..0000000 --- a/android/experimental/LOAndroid/.idea/encodings.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" /> -</project> - diff --git a/android/experimental/LOAndroid/.idea/gradle.xml b/android/experimental/LOAndroid/.idea/gradle.xml deleted file mode 100644 index 736c7b5..0000000 --- a/android/experimental/LOAndroid/.idea/gradle.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="GradleSettings"> - <option name="linkedExternalProjectsSettings"> - <GradleProjectSettings> - <option name="distributionType" value="DEFAULT_WRAPPED" /> - <option name="externalProjectPath" value="$PROJECT_DIR$" /> - <option name="modules"> - <set> - <option value="$PROJECT_DIR$" /> - <option value="$PROJECT_DIR$/app" /> - </set> - </option> - </GradleProjectSettings> - </option> - </component> -</project> - diff --git a/android/experimental/LOAndroid/.idea/libraries/appcompat_v7_19_1_0.xml b/android/experimental/LOAndroid/.idea/libraries/appcompat_v7_19_1_0.xml deleted file mode 100644 index 970e5fa..0000000 --- a/android/experimental/LOAndroid/.idea/libraries/appcompat_v7_19_1_0.xml +++ /dev/null @@ -1,10 +0,0 @@ -<component name="libraryTable"> - <library name="appcompat-v7-19.1.0"> - <CLASSES> - <root url="jar://$PROJECT_DIR$/app/build/exploded-aar/com.android.support/appcompat-v7/19.1.0/classes.jar!/" /> - <root url="file://$PROJECT_DIR$/app/build/exploded-aar/com.android.support/appcompat-v7/19.1.0/res" /> - </CLASSES> - <JAVADOC /> - <SOURCES /> - </library> -</component> \ No newline at end of file diff --git a/android/experimental/LOAndroid/.idea/libraries/support_v4_19_1_0.xml b/android/experimental/LOAndroid/.idea/libraries/support_v4_19_1_0.xml deleted file mode 100644 index 1ca1ac6..0000000 --- a/android/experimental/LOAndroid/.idea/libraries/support_v4_19_1_0.xml +++ /dev/null @@ -1,11 +0,0 @@ -<component name="libraryTable"> - <library name="support-v4-19.1.0"> - <CLASSES> - <root url="jar://$USER_HOME$/Programs/android-sdk-linux/extras/android/m2repository/com/android/support/support-v4/19.1.0/support-v4-19.1.0.jar!/" /> - </CLASSES> - <JAVADOC /> - <SOURCES> - <root url="jar://$USER_HOME$/Programs/android-sdk-linux/extras/android/m2repository/com/android/support/support-v4/19.1.0/support-v4-19.1.0-sources.jar!/" /> - </SOURCES> - </library> -</component> \ No newline at end of file diff --git a/android/experimental/LOAndroid/.idea/misc.xml b/android/experimental/LOAndroid/.idea/misc.xml deleted file mode 100644 index 589a3ed..0000000 --- a/android/experimental/LOAndroid/.idea/misc.xml +++ /dev/null @@ -1,146 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="DaemonCodeAnalyzer"> - <disable_hints /> - </component> - <component name="EntryPointsManager"> - <entry_points version="2.0" /> - </component> - <component name="ProjectInspectionProfilesVisibleTreeState"> - <entry key="Project Default"> - <profile-state> - <expanded-state> - <State> - <id /> - </State> - </expanded-state> - <selected-state> - <State> - <id>Abstraction issues</id> - </State> - </selected-state> - </profile-state> - </entry> - </component> - <component name="ProjectLevelVcsManager" settingsEditedManually="false"> - <OptionsSetting value="true" id="Add" /> - <OptionsSetting value="true" id="Remove" /> - <OptionsSetting value="true" id="Checkout" /> - <OptionsSetting value="true" id="Update" /> - <OptionsSetting value="true" id="Status" /> - <OptionsSetting value="true" id="Edit" /> - <ConfirmationsSetting value="0" id="Add" /> - <ConfirmationsSetting value="0" id="Remove" /> - </component> - <component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK"> - <output url="file://$PROJECT_DIR$/build/classes" /> - </component> - <component name="RunManager"> - <configuration default="true" type="Remote" factoryName="Remote"> - <option name="USE_SOCKET_TRANSPORT" value="true" /> - <option name="SERVER_MODE" value="false" /> - <option name="SHMEM_ADDRESS" value="javadebug" /> - <option name="HOST" value="localhost" /> - <option name="PORT" value="5005" /> - <method /> - </configuration> - <configuration default="true" type="TestNG" factoryName="TestNG"> - <module name="" /> - <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" /> - <option name="ALTERNATIVE_JRE_PATH" /> - <option name="SUITE_NAME" /> - <option name="PACKAGE_NAME" /> - <option name="MAIN_CLASS_NAME" /> - <option name="METHOD_NAME" /> - <option name="GROUP_NAME" /> - <option name="TEST_OBJECT" value="CLASS" /> - <option name="VM_PARAMETERS" value="-ea" /> - <option name="PARAMETERS" /> - <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" /> - <option name="OUTPUT_DIRECTORY" /> - <option name="ANNOTATION_TYPE" /> - <option name="ENV_VARIABLES" /> - <option name="PASS_PARENT_ENVS" value="true" /> - <option name="TEST_SEARCH_SCOPE"> - <value defaultName="moduleWithDependencies" /> - </option> - <option name="USE_DEFAULT_REPORTERS" value="false" /> - <option name="PROPERTIES_FILE" /> - <envs /> - <properties /> - <listeners /> - <method /> - </configuration> - <configuration default="true" type="Applet" factoryName="Applet"> - <module name="" /> - <option name="MAIN_CLASS_NAME" /> - <option name="HTML_FILE_NAME" /> - <option name="HTML_USED" value="false" /> - <option name="WIDTH" value="400" /> - <option name="HEIGHT" value="300" /> - <option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" /> - <option name="VM_PARAMETERS" /> - <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" /> - <option name="ALTERNATIVE_JRE_PATH" /> - <method /> - </configuration> - <configuration default="true" type="Application" factoryName="Application"> - <option name="MAIN_CLASS_NAME" /> - <option name="VM_PARAMETERS" /> - <option name="PROGRAM_PARAMETERS" /> - <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" /> - <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" /> - <option name="ALTERNATIVE_JRE_PATH" /> - <option name="ENABLE_SWING_INSPECTOR" value="false" /> - <option name="ENV_VARIABLES" /> - <option name="PASS_PARENT_ENVS" value="true" /> - <module name="" /> - <envs /> - <method /> - </configuration> - <configuration default="true" type="JUnit" factoryName="JUnit"> - <module name="" /> - <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" /> - <option name="ALTERNATIVE_JRE_PATH" /> - <option name="PACKAGE_NAME" /> - <option name="MAIN_CLASS_NAME" /> - <option name="METHOD_NAME" /> - <option name="TEST_OBJECT" value="class" /> - <option name="VM_PARAMETERS" value="-ea" /> - <option name="PARAMETERS" /> - <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" /> - <option name="ENV_VARIABLES" /> - <option name="PASS_PARENT_ENVS" value="true" /> - <option name="TEST_SEARCH_SCOPE"> - <value defaultName="moduleWithDependencies" /> - </option> - <envs /> - <patterns /> - <method /> - </configuration> - <list size="0" /> - <configuration name="<template>" type="#org.jetbrains.idea.devkit.run.PluginConfigurationType" default="true" selected="false"> - <option name="VM_PARAMETERS" value="-Xmx512m -Xms256m -XX:MaxPermSize=250m -ea" /> - </configuration> - <configuration name="<template>" type="WebApp" default="true" selected="false"> - <Host>localhost</Host> - <Port>5050</Port> - </configuration> - </component> - <component name="masterDetails"> - <states> - <state key="ScopeChooserConfigurable.UI"> - <settings> - <splitter-proportions> - <option name="proportions"> - <list> - <option value="0.2" /> - </list> - </option> - </splitter-proportions> - </settings> - </state> - </states> - </component> -</project> - diff --git a/android/experimental/LOAndroid/.idea/modules.xml b/android/experimental/LOAndroid/.idea/modules.xml deleted file mode 100644 index f08135d..0000000 --- a/android/experimental/LOAndroid/.idea/modules.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="ProjectModuleManager"> - <modules> - <module fileurl="file://$PROJECT_DIR$/LOAndroid.iml" filepath="$PROJECT_DIR$/LOAndroid.iml" /> - <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" /> - </modules> - </component> -</project> - diff --git a/android/experimental/LOAndroid/.idea/scopes/scope_settings.xml b/android/experimental/LOAndroid/.idea/scopes/scope_settings.xml deleted file mode 100644 index 922003b..0000000 --- a/android/experimental/LOAndroid/.idea/scopes/scope_settings.xml +++ /dev/null @@ -1,5 +0,0 @@ -<component name="DependencyValidationManager"> - <state> - <option name="SKIP_IMPORT_STATEMENTS" value="false" /> - </state> -</component> \ No newline at end of file diff --git a/android/experimental/LOAndroid/.idea/vcs.xml b/android/experimental/LOAndroid/.idea/vcs.xml deleted file mode 100644 index def6a6a..0000000 --- a/android/experimental/LOAndroid/.idea/vcs.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="VcsDirectoryMappings"> - <mapping directory="" vcs="" /> - </component> -</project> - diff --git a/android/experimental/LOAndroid/LOAndroid.iml b/android/experimental/LOAndroid/LOAndroid.iml deleted file mode 100644 index edb62a6..0000000 --- a/android/experimental/LOAndroid/LOAndroid.iml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4"> - <component name="NewModuleRootManager" inherit-compiler-output="true"> - <exclude-output /> - <content url="file://$MODULE_DIR$"> - <excludeFolder url="file://$MODULE_DIR$/.gradle" /> - </content> - <orderEntry type="inheritedJdk" /> - <orderEntry type="sourceFolder" forTests="false" /> - </component> -</module> - diff --git a/android/experimental/LOAndroid/app/.gitignore b/android/experimental/LOAndroid/app/.gitignore deleted file mode 100644 index 796b96d..0000000 --- a/android/experimental/LOAndroid/app/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/android/experimental/LOAndroid/app/app.iml b/android/experimental/LOAndroid/app/app.iml deleted file mode 100644 index d3a780b..0000000 --- a/android/experimental/LOAndroid/app/app.iml +++ /dev/null @@ -1,77 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="LOAndroid" external.system.module.version="unspecified" type="JAVA_MODULE" version="4"> - <component name="FacetManager"> - <facet type="android-gradle" name="Android-Gradle"> - <configuration> - <option name="GRADLE_PROJECT_PATH" value=":app" /> - </configuration> - </facet> - <facet type="android" name="Android"> - <configuration> - <option name="SELECTED_BUILD_VARIANT" value="debug" /> - <option name="ASSEMBLE_TASK_NAME" value="assembleDebug" /> - <option name="COMPILE_JAVA_TASK_NAME" value="compileDebugJava" /> - <option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" /> - <option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" /> - <option name="ALLOW_USER_CONFIGURATION" value="false" /> - <option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" /> - <option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" /> - <option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" /> - <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" /> - </configuration> - </facet> - </component> - <component name="NewModuleRootManager" inherit-compiler-output="false"> - <output url="file://$MODULE_DIR$/build/classes/debug" /> - <exclude-output /> - <content url="file://$MODULE_DIR$"> - <sourceFolder url="file://$MODULE_DIR$/build/source/r/debug" isTestSource="false" generated="true" /> - <sourceFolder url="file://$MODULE_DIR$/build/source/aidl/debug" isTestSource="false" generated="true" /> - <sourceFolder url="file://$MODULE_DIR$/build/source/buildConfig/debug" isTestSource="false" generated="true" /> - <sourceFolder url="file://$MODULE_DIR$/build/source/rs/debug" isTestSource="false" generated="true" /> - <sourceFolder url="file://$MODULE_DIR$/build/res/rs/debug" type="java-resource" /> - <sourceFolder url="file://$MODULE_DIR$/build/source/r/test/debug" isTestSource="true" generated="true" /> - <sourceFolder url="file://$MODULE_DIR$/build/source/aidl/test/debug" isTestSource="true" generated="true" /> - <sourceFolder url="file://$MODULE_DIR$/build/source/buildConfig/test/debug" isTestSource="true" generated="true" /> - <sourceFolder url="file://$MODULE_DIR$/build/source/rs/test/debug" isTestSource="true" generated="true" /> - <sourceFolder url="file://$MODULE_DIR$/build/res/rs/test/debug" type="java-test-resource" /> - <sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" /> - <sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" /> - <sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" /> - <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" isTestSource="false" /> - <sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" /> - <sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" /> - <sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" /> - <sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" /> - <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> - <sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" /> - <sourceFolder url="file://$MODULE_DIR$/src/main/assets" isTestSource="false" /> - <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> - <sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" /> - <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" /> - <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" /> - <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" /> - <sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" /> - <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" isTestSource="true" /> - <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" /> - <sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" /> - <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" /> - <excludeFolder url="file://$MODULE_DIR$/build/apk" /> - <excludeFolder url="file://$MODULE_DIR$/build/assets" /> - <excludeFolder url="file://$MODULE_DIR$/build/bundles" /> - <excludeFolder url="file://$MODULE_DIR$/build/classes" /> - <excludeFolder url="file://$MODULE_DIR$/build/dependency-cache" /> - <excludeFolder url="file://$MODULE_DIR$/build/incremental" /> - <excludeFolder url="file://$MODULE_DIR$/build/libs" /> - <excludeFolder url="file://$MODULE_DIR$/build/manifests" /> - <excludeFolder url="file://$MODULE_DIR$/build/res" /> - <excludeFolder url="file://$MODULE_DIR$/build/symbols" /> - <excludeFolder url="file://$MODULE_DIR$/build/tmp" /> - </content> - <orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" /> - <orderEntry type="sourceFolder" forTests="false" /> - <orderEntry type="library" exported="" name="appcompat-v7-19.1.0" level="project" /> - <orderEntry type="library" exported="" name="support-v4-19.1.0" level="project" /> - </component> -</module> - diff --git a/android/experimental/LOAndroid/app/build.gradle b/android/experimental/LOAndroid/app/build.gradle deleted file mode 100644 index 7e98dd4c..0000000 --- a/android/experimental/LOAndroid/app/build.gradle +++ /dev/null @@ -1,24 +0,0 @@ -apply plugin: 'android' - -android { - compileSdkVersion 19 - buildToolsVersion "19.1.0" - - defaultConfig { - minSdkVersion 15 - targetSdkVersion 19 - versionCode 1 - versionName "1.0" - } - buildTypes { - release { - runProguard false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' - } - } -} - -dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:19.+' -} diff --git a/android/experimental/LOAndroid/app/proguard-rules.txt b/android/experimental/LOAndroid/app/proguard-rules.txt deleted file mode 100644 index 0b0be28..0000000 --- a/android/experimental/LOAndroid/app/proguard-rules.txt +++ /dev/null @@ -1,17 +0,0 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in /home/quikee/Programs/android-sdk-linux/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the ProGuard -# include property in project.properties. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} \ No newline at end of file diff --git a/android/experimental/LOAndroid/app/src/main/AndroidManifest.xml b/android/experimental/LOAndroid/app/src/main/AndroidManifest.xml deleted file mode 100644 index 3120a69..0000000 --- a/android/experimental/LOAndroid/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="org.libreoffice" > - - <!-- App requires OpenGL ES 2.0 --> - <uses-feature android:glEsVersion="0x00020000" android:required="true" /> - - <application - android:allowBackup="true" - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" - android:hardwareAccelerated="true" - android:theme="@style/AppTheme" > - <activity - android:name="org.libreoffice.MainActivity" - android:label="@string/app_name" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> diff --git a/android/experimental/LOAndroid/app/src/main/java/org/libreoffice/LOKitShell.java b/android/experimental/LOAndroid/app/src/main/java/org/libreoffice/LOKitShell.java deleted file mode 100644 index cd429d6..0000000 --- a/android/experimental/LOAndroid/app/src/main/java/org/libreoffice/LOKitShell.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.libreoffice; - - -import org.mozilla.gecko.gfx.LayerView; - -public class LOKitShell { - public static int getDpi() { - return 96; - } - - public static int getScreenDepth() { - return 24; - } - - public static LayerView getLayerView() { - return null; - } - - public static float computeRenderIntegrity() { - return 0.0f; - } -} diff --git a/android/experimental/LOAndroid/app/src/main/java/org/libreoffice/MainActivity.java b/android/experimental/LOAndroid/app/src/main/java/org/libreoffice/MainActivity.java deleted file mode 100644 index 1963ad2..0000000 --- a/android/experimental/LOAndroid/app/src/main/java/org/libreoffice/MainActivity.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.libreoffice; - -import android.app.Activity; -import android.os.Bundle; -import android.view.Menu; -import android.view.MenuItem; - - -public class MainActivity extends Activity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - } - - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - // Inflate the menu; this adds items to the action bar if it is present. - getMenuInflater().inflate(R.menu.main, menu); - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - // Handle action bar item clicks here. The action bar will - // automatically handle clicks on the Home/Up button, so long - // as you specify a parent activity in AndroidManifest.xml. - int id = item.getItemId(); - if (id == R.id.action_settings) { - return true; - } - return super.onOptionsItemSelected(item); - } -} diff --git a/android/experimental/LOAndroid/app/src/main/java/org/libreoffice/MainLayerView.java b/android/experimental/LOAndroid/app/src/main/java/org/libreoffice/MainLayerView.java deleted file mode 100644 index 5721df2..0000000 --- a/android/experimental/LOAndroid/app/src/main/java/org/libreoffice/MainLayerView.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.libreoffice; - -import android.content.Context; -import android.os.Handler; -import android.util.AttributeSet; - -import org.mozilla.gecko.gfx.LayerView; -import org.mozilla.gecko.util.ThreadUtils; - -public class MainLayerView extends LayerView { - - public MainLayerView(Context context) { - super(context); - init(context); - } - - public MainLayerView(Context context, AttributeSet attrs) { - super(context, attrs); - init(context); - } - - private void init(Context context) { - ThreadUtils.setUiThread(Thread.currentThread(), new Handler()); - } - -} diff --git a/android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/TouchEventInterceptor.java b/android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/TouchEventInterceptor.java deleted file mode 100644 index 41a71df..0000000 --- a/android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/TouchEventInterceptor.java +++ /dev/null @@ -1,14 +0,0 @@ -/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -package org.mozilla.gecko; - -import android.view.MotionEvent; -import android.view.View; - -public interface TouchEventInterceptor extends View.OnTouchListener { - /** Override this method for a chance to consume events before the view or its children */ - public boolean onInterceptTouchEvent(View view, MotionEvent event); -} diff --git a/android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/ZoomConstraints.java b/android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/ZoomConstraints.java deleted file mode 100644 index 40d1817..0000000 --- a/android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/ZoomConstraints.java +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -package org.mozilla.gecko; - -import org.json.JSONException; -import org.json.JSONObject; - -public final class ZoomConstraints { - private final boolean mAllowZoom; - private final float mDefaultZoom; - private final float mMinZoom; - private final float mMaxZoom; - - public ZoomConstraints(boolean allowZoom) { - mAllowZoom = allowZoom; - mDefaultZoom = 0.0f; - mMinZoom = 0.0f; - mMaxZoom = 0.0f; - } - - ZoomConstraints(JSONObject message) throws JSONException { - mAllowZoom = message.getBoolean("allowZoom"); - mDefaultZoom = (float)message.getDouble("defaultZoom"); - mMinZoom = (float)message.getDouble("minZoom"); - mMaxZoom = (float)message.getDouble("maxZoom"); - } - - public final boolean getAllowZoom() { - return mAllowZoom; - } - - public final float getDefaultZoom() { - return mDefaultZoom; - } - - public final float getMinZoom() { - return mMinZoom; - } - - public final float getMaxZoom() { - return mMaxZoom; - } -} diff --git a/android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/Axis.java b/android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/Axis.java deleted file mode 100644 index 103ee51..0000000 --- a/android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/Axis.java +++ /dev/null @@ -1,420 +0,0 @@ -/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -package org.mozilla.gecko.gfx; - -//import org.mozilla.gecko.GeckoAppShell; -//import org.mozilla.gecko.PrefsHelper; -import org.libreoffice.LOKitShell; -import org.mozilla.gecko.util.FloatUtils; - -import org.json.JSONArray; - -import android.util.Log; -import android.view.View; - -import java.util.HashMap; -import java.util.Map; - -/** - * This class represents the physics for one axis of movement (i.e. either - * horizontal or vertical). It tracks the different properties of movement - * like displacement, velocity, viewport dimensions, etc. pertaining to - * a particular axis. - */ -abstract class Axis { - private static final String LOGTAG = "GeckoAxis"; - - private static final String PREF_SCROLLING_FRICTION_SLOW = "ui.scrolling.friction_slow"; - private static final String PREF_SCROLLING_FRICTION_FAST = "ui.scrolling.friction_fast"; - private static final String PREF_SCROLLING_MAX_EVENT_ACCELERATION = "ui.scrolling.max_event_acceleration"; - private static final String PREF_SCROLLING_OVERSCROLL_DECEL_RATE = "ui.scrolling.overscroll_decel_rate"; - private static final String PREF_SCROLLING_OVERSCROLL_SNAP_LIMIT = "ui.scrolling.overscroll_snap_limit"; - private static final String PREF_SCROLLING_MIN_SCROLLABLE_DISTANCE = "ui.scrolling.min_scrollable_distance"; - - // This fraction of velocity remains after every animation frame when the velocity is low. - private static float FRICTION_SLOW; - // This fraction of velocity remains after every animation frame when the velocity is high. - private static float FRICTION_FAST; - // Below this velocity (in pixels per frame), the friction starts increasing from FRICTION_FAST - // to FRICTION_SLOW. - private static float VELOCITY_THRESHOLD; - // The maximum velocity change factor between events, per ms, in %. - // Direction changes are excluded. - private static float MAX_EVENT_ACCELERATION; - - // The rate of deceleration when the surface has overscrolled. - private static float OVERSCROLL_DECEL_RATE; - // The percentage of the surface which can be overscrolled before it must snap back. - private static float SNAP_LIMIT; - - // The minimum amount of space that must be present for an axis to be considered scrollable, - // in pixels. - private static float MIN_SCROLLABLE_DISTANCE; - - private static float getFloatPref(Map<String, Integer> prefs, String prefName, int defaultValue) { - Integer value = (prefs == null ? null : prefs.get(prefName)); - return (float)(value == null || value < 0 ? defaultValue : value) / 1000f; - } - - private static int getIntPref(Map<String, Integer> prefs, String prefName, int defaultValue) { - Integer value = (prefs == null ? null : prefs.get(prefName)); - return (value == null || value < 0 ? defaultValue : value); - } - - static void initPrefs() { - final String[] prefs = { PREF_SCROLLING_FRICTION_FAST, - PREF_SCROLLING_FRICTION_SLOW, - PREF_SCROLLING_MAX_EVENT_ACCELERATION, - PREF_SCROLLING_OVERSCROLL_DECEL_RATE, - PREF_SCROLLING_OVERSCROLL_SNAP_LIMIT, - PREF_SCROLLING_MIN_SCROLLABLE_DISTANCE }; - - /*PrefsHelper.getPrefs(prefs, new PrefsHelper.PrefHandlerBase() { - Map<String, Integer> mPrefs = new HashMap<String, Integer>(); - - @Override public void prefValue(String name, int value) { - mPrefs.put(name, value); - } - - @Override public void finish() { - setPrefs(mPrefs); - } - });*/ - } - - static final float MS_PER_FRAME = 1000.0f / 60.0f; - static final long NS_PER_FRAME = Math.round(1000000000f / 60f); - private static final float FRAMERATE_MULTIPLIER = (1000f/60f) / MS_PER_FRAME; - private static final int FLING_VELOCITY_POINTS = 8; - - // The values we use for friction are based on a 16.6ms frame, adjust them to currentNsPerFrame: - static float getFrameAdjustedFriction(float baseFriction, long currentNsPerFrame) { - float framerateMultiplier = (float)currentNsPerFrame / NS_PER_FRAME; - return (float)Math.pow(Math.E, (Math.log(baseFriction) / framerateMultiplier)); - } - - static void setPrefs(Map<String, Integer> prefs) { - FRICTION_SLOW = getFloatPref(prefs, PREF_SCROLLING_FRICTION_SLOW, 850); - FRICTION_FAST = getFloatPref(prefs, PREF_SCROLLING_FRICTION_FAST, 970); - VELOCITY_THRESHOLD = 10 / FRAMERATE_MULTIPLIER; - MAX_EVENT_ACCELERATION = getFloatPref(prefs, PREF_SCROLLING_MAX_EVENT_ACCELERATION, /*GeckoAppShell.getDpi()*/ LOKitShell.getDpi() > 300 ? 100 : 40); - OVERSCROLL_DECEL_RATE = getFloatPref(prefs, PREF_SCROLLING_OVERSCROLL_DECEL_RATE, 40); - SNAP_LIMIT = getFloatPref(prefs, PREF_SCROLLING_OVERSCROLL_SNAP_LIMIT, 300); - MIN_SCROLLABLE_DISTANCE = getFloatPref(prefs, PREF_SCROLLING_MIN_SCROLLABLE_DISTANCE, 500); - Log.i(LOGTAG, "Prefs: " + FRICTION_SLOW + "," + FRICTION_FAST + "," + VELOCITY_THRESHOLD + "," - + MAX_EVENT_ACCELERATION + "," + OVERSCROLL_DECEL_RATE + "," + SNAP_LIMIT + "," + MIN_SCROLLABLE_DISTANCE); - } - - static { - // set the scrolling parameters to default values on startup - setPrefs(null); - } - - private enum FlingStates { - STOPPED, - PANNING, - FLINGING, - } - - private enum Overscroll { - NONE, - MINUS, // Overscrolled in the negative direction - PLUS, // Overscrolled in the positive direction - BOTH, // Overscrolled in both directions (page is zoomed to smaller than screen) - } - - private final SubdocumentScrollHelper mSubscroller; - - private int mOverscrollMode; /* Default to only overscrolling if we're allowed to scroll in a direction */ - private float mFirstTouchPos; /* Position of the first touch event on the current drag. */ - private float mTouchPos; /* Position of the most recent touch event on the current drag. */ - private float mLastTouchPos; /* Position of the touch event before touchPos. */ - private float mVelocity; /* Velocity in this direction; pixels per animation frame. */ - private float[] mRecentVelocities; /* Circular buffer of recent velocities since last touch start. */ - private int mRecentVelocityCount; /* Number of values put into mRecentVelocities (unbounded). */ - private boolean mScrollingDisabled; /* Whether movement on this axis is locked. */ - private boolean mDisableSnap; /* Whether overscroll snapping is disabled. */ - private float mDisplacement; - - private FlingStates mFlingState = FlingStates.STOPPED; /* The fling state we're in on this axis. */ - - protected abstract float getOrigin(); - protected abstract float getViewportLength(); - protected abstract float getPageStart(); - protected abstract float getPageLength(); - protected abstract float getMarginStart(); - protected abstract float getMarginEnd(); - protected abstract boolean marginsHidden(); - - Axis(SubdocumentScrollHelper subscroller) { - mSubscroller = subscroller; - mOverscrollMode = View.OVER_SCROLL_IF_CONTENT_SCROLLS; - mRecentVelocities = new float[FLING_VELOCITY_POINTS]; - } - - // Implementors can override these to show effects when the axis overscrolls - protected void overscrollFling(float velocity) { } - protected void overscrollPan(float displacement) { } - - public void setOverScrollMode(int overscrollMode) { - mOverscrollMode = overscrollMode; - } - - public int getOverScrollMode() { - return mOverscrollMode; - } - - private float getViewportEnd() { - return getOrigin() + getViewportLength(); - } - - private float getPageEnd() { - return getPageStart() + getPageLength(); - } - - void startTouch(float pos) { - mVelocity = 0.0f; - mScrollingDisabled = false; - mFirstTouchPos = mTouchPos = mLastTouchPos = pos; - mRecentVelocityCount = 0; - } - - float panDistance(float currentPos) { - return currentPos - mFirstTouchPos; - } - - void setScrollingDisabled(boolean disabled) { - mScrollingDisabled = disabled; - } - - void saveTouchPos() { - mLastTouchPos = mTouchPos; - } - - void updateWithTouchAt(float pos, float timeDelta) { - float newVelocity = (mTouchPos - pos) / timeDelta * MS_PER_FRAME; - - mRecentVelocities[mRecentVelocityCount % FLING_VELOCITY_POINTS] = newVelocity; - mRecentVelocityCount++; - - // If there's a direction change, or current velocity is very low, - // allow setting of the velocity outright. Otherwise, use the current - // velocity and a maximum change factor to set the new velocity. - boolean curVelocityIsLow = Math.abs(mVelocity) < 1.0f / FRAMERATE_MULTIPLIER; - boolean directionChange = (mVelocity > 0) != (newVelocity > 0); - if (curVelocityIsLow || (directionChange && !FloatUtils.fuzzyEquals(newVelocity, 0.0f))) { - mVelocity = newVelocity; - } else { - float maxChange = Math.abs(mVelocity * timeDelta * MAX_EVENT_ACCELERATION); - mVelocity = Math.min(mVelocity + maxChange, Math.max(mVelocity - maxChange, newVelocity)); - } - - mTouchPos = pos; - } - - boolean overscrolled() { - return getOverscroll() != Overscroll.NONE; - } - - private Overscroll getOverscroll() { - boolean minus = (getOrigin() < getPageStart()); - boolean plus = (getViewportEnd() > getPageEnd()); - if (minus && plus) { - return Overscroll.BOTH; - } else if (minus) { - return Overscroll.MINUS; - } else if (plus) { - return Overscroll.PLUS; - } else { - return Overscroll.NONE; - } - } - - // Returns the amount that the page has been overscrolled. If the page hasn't been - // overscrolled on this axis, returns 0. - private float getExcess() { - switch (getOverscroll()) { - case MINUS: return getPageStart() - getOrigin(); - case PLUS: return getViewportEnd() - getPageEnd(); - case BOTH: return (getViewportEnd() - getPageEnd()) + (getPageStart() - getOrigin()); - default: return 0.0f; - } - } - - /* - * Returns true if the page is zoomed in to some degree along this axis such that scrolling is - * possible and this axis has not been scroll locked while panning. Otherwise, returns false. - */ - boolean scrollable() { - // If we're scrolling a subdocument, ignore the viewport length restrictions (since those - // apply to the top-level document) and only take into account axis locking. - if (mSubscroller.scrolling()) { - return !mScrollingDisabled; - } - - // if we are axis locked, return false - if (mScrollingDisabled) { - return false; - } - - // if there are margins on this axis but they are currently hidden, - // we must be able to scroll in order to make them visible, so allow - // scrolling in that case - if (marginsHidden()) { - return true; - } - - // there is scrollable space, and we're not disabled, or the document fits the viewport - // but we always allow overscroll anyway - return getViewportLength() <= getPageLength() - MIN_SCROLLABLE_DISTANCE || - getOverScrollMode() == View.OVER_SCROLL_ALWAYS; - } - - /* - * Returns the resistance, as a multiplier, that should be taken into account when - * tracking or pinching. - */ - float getEdgeResistance(boolean forPinching) { - float excess = getExcess(); - if (excess > 0.0f && (getOverscroll() == Overscroll.BOTH || !forPinching)) { - // excess can be greater than viewport length, but the resistance - // must never drop below 0.0 - return Math.max(0.0f, SNAP_LIMIT - excess / getViewportLength()); - } - return 1.0f; - } - - /* Returns the velocity. If the axis is locked, returns 0. */ - float getRealVelocity() { - return scrollable() ? mVelocity : 0f; - } - - void startPan() { - mFlingState = FlingStates.PANNING; - } - - private float calculateFlingVelocity() { - int usablePoints = Math.min(mRecentVelocityCount, FLING_VELOCITY_POINTS); - if (usablePoints <= 1) { - return mVelocity; - } - float average = 0; - for (int i = 0; i < usablePoints; i++) { - average += mRecentVelocities[i]; - } - return average / usablePoints; - } - - void startFling(boolean stopped) { - mDisableSnap = mSubscroller.scrolling(); - - if (stopped) { - mFlingState = FlingStates.STOPPED; - } else { - mVelocity = calculateFlingVelocity(); - mFlingState = FlingStates.FLINGING; - } - } - - /* Advances a fling animation by one step. */ - boolean advanceFling(long realNsPerFrame) { - if (mFlingState != FlingStates.FLINGING) { - return false; - } - if (mSubscroller.scrolling() && !mSubscroller.lastScrollSucceeded()) { - // if the subdocument stopped scrolling, it's because it reached the end - // of the subdocument. we don't do overscroll on subdocuments, so there's - // no point in continuing this fling. - return false; - } - - float excess = getExcess(); - Overscroll overscroll = getOverscroll(); - boolean decreasingOverscroll = false; - if ((overscroll == Overscroll.MINUS && mVelocity > 0) || - (overscroll == Overscroll.PLUS && mVelocity < 0)) - { - decreasingOverscroll = true; - } - - if (mDisableSnap || FloatUtils.fuzzyEquals(excess, 0.0f) || decreasingOverscroll) { - // If we aren't overscrolled, just apply friction. - if (Math.abs(mVelocity) >= VELOCITY_THRESHOLD) { - mVelocity *= getFrameAdjustedFriction(FRICTION_FAST, realNsPerFrame); - } else { - float t = mVelocity / VELOCITY_THRESHOLD; - mVelocity *= FloatUtils.interpolate(getFrameAdjustedFriction(FRICTION_SLOW, realNsPerFrame), - getFrameAdjustedFriction(FRICTION_FAST, realNsPerFrame), t); - } - } else { - // Otherwise, decrease the velocity linearly. - float elasticity = 1.0f - excess / (getViewportLength() * SNAP_LIMIT); - float overscrollDecelRate = getFrameAdjustedFriction(OVERSCROLL_DECEL_RATE, realNsPerFrame); - if (overscroll == Overscroll.MINUS) { - mVelocity = Math.min((mVelocity + overscrollDecelRate) * elasticity, 0.0f); - } else { // must be Overscroll.PLUS - mVelocity = Math.max((mVelocity - overscrollDecelRate) * elasticity, 0.0f); - } - } - - return true; - } - - void stopFling() { - mVelocity = 0.0f; - mFlingState = FlingStates.STOPPED; - } - - // Performs displacement of the viewport position according to the current velocity. - void displace() { - // if this isn't scrollable just return - if (!scrollable()) - return; - - if (mFlingState == FlingStates.PANNING) - mDisplacement += (mLastTouchPos - mTouchPos) * getEdgeResistance(false); - else - mDisplacement += mVelocity * getEdgeResistance(false); - - // if overscroll is disabled and we're trying to overscroll, reset the displacement - // to remove any excess. Using getExcess alone isn't enough here since it relies on - // getOverscroll which doesn't take into account any new displacment being applied. - // If we using a subscroller, we don't want to alter the scrolling being done - if (getOverScrollMode() == View.OVER_SCROLL_NEVER && !mSubscroller.scrolling()) { - float originalDisplacement = mDisplacement; - - if (mDisplacement + getOrigin() < getPageStart() - getMarginStart()) { - mDisplacement = getPageStart() - getMarginStart() - getOrigin(); - } else if (mDisplacement + getViewportEnd() > getPageEnd() + getMarginEnd()) { - mDisplacement = getPageEnd() - getMarginEnd() - getViewportEnd(); - } - - // Return the amount of overscroll so that the overscroll controller can draw it for us - if (originalDisplacement != mDisplacement) { - if (mFlingState == FlingStates.FLINGING) { - overscrollFling(mVelocity / MS_PER_FRAME * 1000); - stopFling(); - } else if (mFlingState == FlingStates.PANNING) { - overscrollPan(originalDisplacement - mDisplacement); - } - } - } - } - - float resetDisplacement() { - float d = mDisplacement; - mDisplacement = 0.0f; - return d; - } - - void setAutoscrollVelocity(float velocity) { - if (mFlingState != FlingStates.STOPPED) { - Log.e(LOGTAG, "Setting autoscroll velocity while in a fling is not allowed!"); - return; - } - mVelocity = velocity; - } -} diff --git a/android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/BitmapUtils.java b/android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/BitmapUtils.java deleted file mode 100644 index 9dba802..0000000 --- a/android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/BitmapUtils.java +++ /dev/null @@ -1,368 +0,0 @@ -/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -package org.mozilla.gecko.gfx; - -import org.mozilla.gecko.util.ThreadUtils; -import org.mozilla.gecko.util.UiAsyncTask; -//import org.mozilla.gecko.util.GeckoJarReader; -//import org.mozilla.gecko.R; - -import org.libreoffice.R; - -import android.content.Context; -import android.content.res.Resources; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.drawable.Drawable; -import android.graphics.drawable.BitmapDrawable; -import android.net.Uri; -import android.os.AsyncTask; -import android.util.Base64; -import android.util.Log; -import android.text.TextUtils; - -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.Field; -import java.lang.NoSuchFieldException; -import java.net.MalformedURLException; -import java.net.URL; - -public final class BitmapUtils { - private static final String LOGTAG = "GeckoBitmapUtils"; - - private BitmapUtils() {} - - public interface BitmapLoader { - public void onBitmapFound(Drawable d); - } - - public static void getDrawable(final Context context, final String data, final BitmapLoader loader) { - if (TextUtils.isEmpty(data)) { - loader.onBitmapFound(null); - return; - } - - if (data.startsWith("data")) { - BitmapDrawable d = new BitmapDrawable(context.getResources(), getBitmapFromDataURI(data)); - loader.onBitmapFound(d); - return; - } - - if (data.startsWith("jar:") || data.startsWith("file://")) { - (new UiAsyncTask<Void, Void, Drawable>(ThreadUtils.getBackgroundHandler()) { - @Override - public Drawable doInBackground(Void... params) { - try { - //if (data.startsWith("jar:jar")) { - // return GeckoJarReader.getBitmapDrawable(context.getResources(), data); - //} - - // Don't attempt to validate the JAR signature when loading an add-on icon - //if (data.startsWith("jar:file")) { - // return GeckoJarReader.getBitmapDrawable(context.getResources(), Uri.decode(data)); - //} - - URL url = new URL(data); - InputStream is = (InputStream) url.getContent(); - try { - return Drawable.createFromStream(is, "src"); - } finally { - is.close(); - } - } catch (Exception e) { - Log.w(LOGTAG, "Unable to set icon", e); - } - return null; - } - - @Override - public void onPostExecute(Drawable drawable) { - loader.onBitmapFound(drawable); - } - }).execute(); - return; - } - - if(data.startsWith("-moz-icon://")) { - Uri imageUri = Uri.parse(data); - String resource = imageUri.getSchemeSpecificPart(); - resource = resource.substring(resource.lastIndexOf('/') + 1); - - try { - Drawable d = context.getPackageManager().getApplicationIcon(resource); - loader.onBitmapFound(d); - } catch(Exception ex) { } - - return; - } - - if(data.startsWith("drawable://")) { - Uri imageUri = Uri.parse(data); - int id = getResource(imageUri, R.drawable.ic_status_logo); - Drawable d = context.getResources().getDrawable(id); - - loader.onBitmapFound(d); - return; - } - - loader.onBitmapFound(null); - } - - public static Bitmap decodeByteArray(byte[] bytes) { - return decodeByteArray(bytes, null); - } - - public static Bitmap decodeByteArray(byte[] bytes, BitmapFactory.Options options) { - return decodeByteArray(bytes, 0, bytes.length, options); - } - - public static Bitmap decodeByteArray(byte[] bytes, int offset, int length) { - return decodeByteArray(bytes, offset, length, null); - } - - public static Bitmap decodeByteArray(byte[] bytes, int offset, int length, BitmapFactory.Options options) { - if (bytes.length <= 0) { - throw new IllegalArgumentException("bytes.length " + bytes.length - + " must be a positive number"); - } - - Bitmap bitmap = null; - try { - bitmap = BitmapFactory.decodeByteArray(bytes, offset, length, options); - } catch (OutOfMemoryError e) { - Log.e(LOGTAG, "decodeByteArray(bytes.length=" + bytes.length - + ", options= " + options + ") OOM!", e); - return null; - } - - if (bitmap == null) { - Log.w(LOGTAG, "decodeByteArray() returning null because BitmapFactory returned null"); - return null; - } - - if (bitmap.getWidth() <= 0 || bitmap.getHeight() <= 0) { - Log.w(LOGTAG, "decodeByteArray() returning null because BitmapFactory returned " - + "a bitmap with dimensions " + bitmap.getWidth() - + "x" + bitmap.getHeight()); - return null; - } - - return bitmap; - } - - public static Bitmap decodeStream(InputStream inputStream) { - try { - return BitmapFactory.decodeStream(inputStream); - } catch (OutOfMemoryError e) { - Log.e(LOGTAG, "decodeStream() OOM!", e); - return null; - } - } - - public static Bitmap decodeUrl(Uri uri) { - return decodeUrl(uri.toString()); - } - - public static Bitmap decodeUrl(String urlString) { - URL url; - - try { - url = new URL(urlString); - } catch(MalformedURLException e) { - Log.w(LOGTAG, "decodeUrl: malformed URL " + urlString); - return null; - } - - return decodeUrl(url); - } - - public static Bitmap decodeUrl(URL url) { - InputStream stream = null; - - try { - stream = url.openStream(); - } catch(IOException e) { - Log.w(LOGTAG, "decodeUrl: IOException downloading " + url); - return null; - } - - if (stream == null) { - Log.w(LOGTAG, "decodeUrl: stream not found downloading " + url); - return null; - } - - Bitmap bitmap = decodeStream(stream); - - try { - stream.close(); - } catch(IOException e) { - Log.w(LOGTAG, "decodeUrl: IOException closing stream " + url, e); - } - - return bitmap; - } - - public static Bitmap decodeResource(Context context, int id) { - return decodeResource(context, id, null); - } - - public static Bitmap decodeResource(Context context, int id, BitmapFactory.Options options) { - Resources resources = context.getResources(); - try { - return BitmapFactory.decodeResource(resources, id, options); - } catch (OutOfMemoryError e) { - Log.e(LOGTAG, "decodeResource() OOM! Resource id=" + id, e); - return null; - } - } - - public static int getDominantColor(Bitmap source) { - return getDominantColor(source, true); - } - - public static int getDominantColor(Bitmap source, boolean applyThreshold) { - if (source == null) - return Color.argb(255,255,255,255); - - // Keep track of how many times a hue in a given bin appears in the image. - // Hue values range [0 .. 360), so dividing by 10, we get 36 bins. - int[] colorBins = new int[36]; - - // The bin with the most colors. Initialize to -1 to prevent accidentally - // thinking the first bin holds the dominant color. - int maxBin = -1; - - // Keep track of sum hue/saturation/value per hue bin, which we'll use to - // compute an average to for the dominant color. - float[] sumHue = new float[36]; - float[] sumSat = new float[36]; - float[] sumVal = new float[36]; - float[] hsv = new float[3]; - - int height = source.getHeight(); - int width = source.getWidth(); - int[] pixels = new int[width * height]; - source.getPixels(pixels, 0, width, 0, 0, width, height); - for (int row = 0; row < height; row++) { - for (int col = 0; col < width; col++) { - int c = pixels[col + row * width]; - // Ignore pixels with a certain transparency. - if (Color.alpha(c) < 128) - continue; - - Color.colorToHSV(c, hsv); - - // If a threshold is applied, ignore arbitrarily chosen values for "white" and "black". - if (applyThreshold && (hsv[1] <= 0.35f || hsv[2] <= 0.35f)) - continue; - - // We compute the dominant color by putting colors in bins based on their hue. - int bin = (int) Math.floor(hsv[0] / 10.0f); - - // Update the sum hue/saturation/value for this bin. - sumHue[bin] = sumHue[bin] + hsv[0]; - sumSat[bin] = sumSat[bin] + hsv[1]; - sumVal[bin] = sumVal[bin] + hsv[2]; - - // Increment the number of colors in this bin. - colorBins[bin]++; - - // Keep track of the bin that holds the most colors. - if (maxBin < 0 || colorBins[bin] > colorBins[maxBin]) - maxBin = bin; - } - } - - // maxBin may never get updated if the image holds only transparent and/or black/white pixels. - if (maxBin < 0) - return Color.argb(255,255,255,255); - - // Return a color with the average hue/saturation/value of the bin with the most colors. - hsv[0] = sumHue[maxBin]/colorBins[maxBin]; - hsv[1] = sumSat[maxBin]/colorBins[maxBin]; - hsv[2] = sumVal[maxBin]/colorBins[maxBin]; - return Color.HSVToColor(hsv); - } - - /** - * Decodes a bitmap from a Base64 data URI. - * - * @param dataURI a Base64-encoded data URI string - * @return the decoded bitmap, or null if the data URI is invalid - */ - public static Bitmap getBitmapFromDataURI(String dataURI) { - String base64 = dataURI.substring(dataURI.indexOf(',') + 1); - try { - byte[] raw = Base64.decode(base64, Base64.DEFAULT); - return BitmapUtils.decodeByteArray(raw); - } catch (Exception e) { - Log.e(LOGTAG, "exception decoding bitmap from data URI: " + dataURI, e); - } - return null; - } - - public static Bitmap getBitmapFromDrawable(Drawable drawable) { - if (drawable instanceof BitmapDrawable) { - return ((BitmapDrawable) drawable).getBitmap(); - } - - int width = drawable.getIntrinsicWidth(); - width = width > 0 ? width : 1; - int height = drawable.getIntrinsicHeight(); - height = height > 0 ? height : 1; - - Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(bitmap); - drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); - drawable.draw(canvas); - - return bitmap; - } - - public static int getResource(Uri resourceUrl, int defaultIcon) { - int icon = defaultIcon; - - final String scheme = resourceUrl.getScheme(); - if ("drawable".equals(scheme)) { - String resource = resourceUrl.getSchemeSpecificPart(); - resource = resource.substring(resource.lastIndexOf('/') + 1); - - try { - return Integer.parseInt(resource); - } catch(NumberFormatException ex) { - // This isn't a resource id, try looking for a string - } - - try { - final Class<R.drawable> drawableClass = R.drawable.class; - final Field f = drawableClass.getField(resource); - icon = f.getInt(null); - } catch (final NoSuchFieldException e1) { - - // just means the resource doesn't exist for fennec. Check in Android resources - try { - final Class<android.R.drawable> drawableClass = android.R.drawable.class; - final Field f = drawableClass.getField(resource); - icon = f.getInt(null); - } catch (final NoSuchFieldException e2) { - // This drawable doesn't seem to exist... - } catch(Exception e3) { - Log.i(LOGTAG, "Exception getting drawable", e3); - } - - } catch (Exception e4) { - Log.i(LOGTAG, "Exception getting drawable", e4); - } - - resourceUrl = null; - } - return icon; - } -} - diff --git a/android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/BufferedCairoImage.java b/android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/BufferedCairoImage.java deleted file mode 100644 index 307f412..0000000 --- a/android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/BufferedCairoImage.java +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -package org.mozilla.gecko.gfx; - -import org.mozilla.gecko.mozglue.DirectBufferAllocator; - -import android.graphics.Bitmap; -import android.util.Log; - -import java.nio.ByteBuffer; - -/** A Cairo image that simply saves a buffer of pixel data. */ -public class BufferedCairoImage extends CairoImage { - private ByteBuffer mBuffer; - private IntSize mSize; - private int mFormat; - - private static String LOGTAG = "GeckoBufferedCairoImage"; - - /** Creates a buffered Cairo image from a byte buffer. */ - public BufferedCairoImage(ByteBuffer inBuffer, int inWidth, int inHeight, int inFormat) { - setBuffer(inBuffer, inWidth, inHeight, inFormat); - } - - /** Creates a buffered Cairo image from an Android bitmap. */ - public BufferedCairoImage(Bitmap bitmap) { - setBitmap(bitmap); - } - - private synchronized void freeBuffer() { - mBuffer = DirectBufferAllocator.free(mBuffer); - } - - @Override - public void destroy() { - try { - freeBuffer(); - } catch (Exception ex) { - Log.e(LOGTAG, "error clearing buffer: ", ex); - } - } - - @Override - public ByteBuffer getBuffer() { return mBuffer; } - @Override - public IntSize getSize() { return mSize; } - @Override - public int getFormat() { return mFormat; } - - - public void setBuffer(ByteBuffer buffer, int width, int height, int format) { - freeBuffer(); - mBuffer = buffer; - mSize = new IntSize(width, height); - mFormat = format; - } - - public void setBitmap(Bitmap bitmap) { - mFormat = CairoUtils.bitmapConfigToCairoFormat(bitmap.getConfig()); - mSize = new IntSize(bitmap.getWidth(), bitmap.getHeight()); - - int bpp = CairoUtils.bitsPerPixelForCairoFormat(mFormat); - mBuffer = DirectBufferAllocator.allocate(mSize.getArea() * bpp); - bitmap.copyPixelsToBuffer(mBuffer.asIntBuffer()); - } -} diff --git a/android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/CairoGLInfo.java b/android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/CairoGLInfo.java deleted file mode 100644 index 472c1d2..0000000 --- a/android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/CairoGLInfo.java +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -package org.mozilla.gecko.gfx; - -import javax.microedition.khronos.opengles.GL10; - -/** Information needed to render Cairo bitmaps using OpenGL ES. */ -public class CairoGLInfo { - public final int internalFormat; - public final int format; - public final int type; - - public CairoGLInfo(int cairoFormat) { - switch (cairoFormat) { - case CairoImage.FORMAT_ARGB32: - internalFormat = format = GL10.GL_RGBA; type = GL10.GL_UNSIGNED_BYTE; - break; - case CairoImage.FORMAT_RGB24: - internalFormat = format = GL10.GL_RGB; type = GL10.GL_UNSIGNED_BYTE; - break; - case CairoImage.FORMAT_RGB16_565: - internalFormat = format = GL10.GL_RGB; type = GL10.GL_UNSIGNED_SHORT_5_6_5; - break; - case CairoImage.FORMAT_A8: - case CairoImage.FORMAT_A1: - throw new RuntimeException("Cairo FORMAT_A1 and FORMAT_A8 unsupported"); - default: - throw new RuntimeException("Unknown Cairo format"); - } - } -} - diff --git a/android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/CairoImage.java b/android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/CairoImage.java deleted file mode 100644 index 5a18a4b..0000000 --- a/android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/CairoImage.java +++ /dev/null @@ -1,28 +0,0 @@ -/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -package org.mozilla.gecko.gfx; - -import java.nio.ByteBuffer; - -/* - * A bitmap with pixel data in one of the formats that Cairo understands. - */ -public abstract class CairoImage { - public abstract ByteBuffer getBuffer(); - - public abstract void destroy(); - - public abstract IntSize getSize(); - public abstract int getFormat(); - - public static final int FORMAT_INVALID = -1; - public static final int FORMAT_ARGB32 = 0; - public static final int FORMAT_RGB24 = 1; - public static final int FORMAT_A8 = 2; - public static final int FORMAT_A1 = 3; - public static final int FORMAT_RGB16_565 = 4; -} - diff --git a/android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/CairoUtils.java b/android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/CairoUtils.java deleted file mode 100644 index 48c449f..0000000 --- a/android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/CairoUtils.java +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -package org.mozilla.gecko.gfx; - -import android.graphics.Bitmap; - -/** - * Utility methods useful when displaying Cairo bitmaps using OpenGL ES. - */ -public class CairoUtils { - private CairoUtils() { /* Don't call me. */ } - - public static int bitsPerPixelForCairoFormat(int cairoFormat) { - switch (cairoFormat) { - case CairoImage.FORMAT_A1: return 1; - case CairoImage.FORMAT_A8: return 8; - case CairoImage.FORMAT_RGB16_565: return 16; - case CairoImage.FORMAT_RGB24: return 24; - case CairoImage.FORMAT_ARGB32: return 32; - default: - throw new RuntimeException("Unknown Cairo format"); - } - } - - public static int bitmapConfigToCairoFormat(Bitmap.Config config) { - if (config == null) - return CairoImage.FORMAT_ARGB32; /* Droid Pro fix. */ - - switch (config) { - case ALPHA_8: return CairoImage.FORMAT_A8; - case ARGB_4444: throw new RuntimeException("ARGB_444 unsupported"); - case ARGB_8888: return CairoImage.FORMAT_ARGB32; - case RGB_565: return CairoImage.FORMAT_RGB16_565; - default: throw new RuntimeException("Unknown Skia bitmap config"); - } - } - - public static Bitmap.Config cairoFormatTobitmapConfig(int format) { - switch (format) { - case CairoImage.FORMAT_A8: return Bitmap.Config.ALPHA_8; - case CairoImage.FORMAT_ARGB32: return Bitmap.Config.ARGB_8888; - case CairoImage.FORMAT_RGB16_565: return Bitmap.Config.RGB_565; - default: - throw new RuntimeException("Unknown CairoImage format"); - } - } -} - diff --git a/android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/DisplayPortCalculator.java b/android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/DisplayPortCalculator.java deleted file mode 100644 index f101dfb..0000000 --- a/android/experimental/LOAndroid/app/src/main/java/org/mozilla/gecko/gfx/DisplayPortCalculator.java +++ /dev/null @@ -1,777 +0,0 @@ -/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -package org.mozilla.gecko.gfx; - -//import org.mozilla.gecko.GeckoAppShell; -//import org.mozilla.gecko.PrefsHelper; -import org.libreoffice.LOKitShell; -import org.mozilla.gecko.util.FloatUtils; - -import org.json.JSONArray; - -import android.graphics.PointF; -import android.graphics.RectF; -import android.util.FloatMath; -import android.util.Log; - -import java.util.HashMap; -import java.util.Map; - -final class DisplayPortCalculator { - private static final String LOGTAG = "GeckoDisplayPort"; - private static final PointF ZERO_VELOCITY = new PointF(0, 0); - - // Keep this in sync with the TILEDLAYERBUFFER_TILE_SIZE defined in gfx/layers/TiledLayerBuffer.h - private static final int TILE_SIZE = 256; - - private static final String PREF_DISPLAYPORT_STRATEGY = "gfx.displayport.strategy"; - private static final String PREF_DISPLAYPORT_FM_MULTIPLIER = "gfx.displayport.strategy_fm.multiplier"; - private static final String PREF_DISPLAYPORT_FM_DANGER_X = "gfx.displayport.strategy_fm.danger_x"; - private static final String PREF_DISPLAYPORT_FM_DANGER_Y = "gfx.displayport.strategy_fm.danger_y"; - private static final String PREF_DISPLAYPORT_VB_MULTIPLIER = "gfx.displayport.strategy_vb.multiplier"; - private static final String PREF_DISPLAYPORT_VB_VELOCITY_THRESHOLD = "gfx.displayport.strategy_vb.threshold"; - private static final String PREF_DISPLAYPORT_VB_REVERSE_BUFFER = "gfx.displayport.strategy_vb.reverse_buffer"; - private static final String PREF_DISPLAYPORT_VB_DANGER_X_BASE = "gfx.displayport.strategy_vb.danger_x_base"; - private static final String PREF_DISPLAYPORT_VB_DANGER_Y_BASE = "gfx.displayport.strategy_vb.danger_y_base"; - private static final String PREF_DISPLAYPORT_VB_DANGER_X_INCR = "gfx.displayport.strategy_vb.danger_x_incr"; - private static final String PREF_DISPLAYPORT_VB_DANGER_Y_INCR = "gfx.displayport.strategy_vb.danger_y_incr"; - private static final String PREF_DISPLAYPORT_PB_VELOCITY_THRESHOLD = "gfx.displayport.strategy_pb.threshold"; - - private static DisplayPortStrategy sStrategy = new VelocityBiasStrategy(null); - - static DisplayPortMetrics calculate(ImmutableViewportMetrics metrics, PointF velocity) { - return sStrategy.calculate(metrics, (velocity == null ? ZERO_VELOCITY : velocity)); - } - - static boolean aboutToCheckerboard(ImmutableViewportMetrics metrics, PointF velocity, DisplayPortMetrics displayPort) { - if (displayPort == null) { - return true; - } - return sStrategy.aboutToCheckerboard(metrics, (velocity == null ? ZERO_VELOCITY : velocity), displayPort); - } - - static boolean drawTimeUpdate(long millis, int pixels) { - return sStrategy.drawTimeUpdate(millis, pixels); - } - - static void resetPageState() { - sStrategy.resetPageState(); - } - - static void initPrefs() { - final String[] prefs = { PREF_DISPLAYPORT_STRATEGY, - PREF_DISPLAYPORT_FM_MULTIPLIER, - PREF_DISPLAYPORT_FM_DANGER_X, - PREF_DISPLAYPORT_FM_DANGER_Y, - PREF_DISPLAYPORT_VB_MULTIPLIER, - PREF_DISPLAYPORT_VB_VELOCITY_THRESHOLD, - PREF_DISPLAYPORT_VB_REVERSE_BUFFER, - PREF_DISPLAYPORT_VB_DANGER_X_BASE, - PREF_DISPLAYPORT_VB_DANGER_Y_BASE, - PREF_DISPLAYPORT_VB_DANGER_X_INCR, - PREF_DISPLAYPORT_VB_DANGER_Y_INCR, - PREF_DISPLAYPORT_PB_VELOCITY_THRESHOLD }; - - /*PrefsHelper.getPrefs(prefs, new PrefsHelper.PrefHandlerBase() { - private Map<String, Integer> mValues = new HashMap<String, Integer>(); - - @Override public void prefValue(String pref, int value) { - mValues.put(pref, value); - } - - @Override public void finish() { - setStrategy(mValues); - } - });*/ - } - - /** - * Set the active strategy to use. - * See the gfx.displayport.strategy pref in mobile/android/app/mobile.js to see the - * mapping between ints and strategies. - */ - static boolean setStrategy(Map<String, Integer> prefs) { - Integer strategy = prefs.get(PREF_DISPLAYPORT_STRATEGY); - if (strategy == null) { - return false; - } - - switch (strategy) { - case 0: - sStrategy = new FixedMarginStrategy(prefs); - break; - case 1: - sStrategy = new VelocityBiasStrategy(prefs); - break; - case 2: - sStrategy = new DynamicResolutionStrategy(prefs); - break; - case 3: - sStrategy = new NoMarginStrategy(prefs); - break; - case 4: - sStrategy = new PredictionBiasStrategy(prefs); - break; - default: - Log.e(LOGTAG, "Invalid strategy index specified"); - return false; - } - Log.i(LOGTAG, "Set strategy " + sStrategy.toString()); - return true; - } - - private static float getFloatPref(Map<String, Integer> prefs, String prefName, int defaultValue) { - Integer value = (prefs == null ? null : prefs.get(prefName)); - return (float)(value == null || value < 0 ? defaultValue : value) / 1000f; - } - - private static abstract class DisplayPortStrategy { - /** Calculates a displayport given a viewport and panning velocity. */ - public abstract DisplayPortMetrics calculate(ImmutableViewportMetrics metrics, PointF velocity); - /** Returns true if a checkerboard is about to be visible and we should not throttle drawing. */ - public abstract boolean aboutToCheckerboard(ImmutableViewportMetrics metrics, PointF velocity, DisplayPortMetrics displayPort); - /** Notify the strategy of a new recorded draw time. Return false to turn off draw time recording. */ - public boolean drawTimeUpdate(long millis, int pixels) { return false; } - /** Reset any page-specific state stored, as the page being displayed has changed. */ - public void resetPageState() {} - } - - /** - * Return the dimensions for a rect that has area (width*height) that does not exceed the page size in the - * given metrics object. The area in the returned FloatSize may be less than width*height if the page is - * small, but it will never be larger than width*height. - * Note that this process may change the relative aspect ratio of the given dimensions. - */ - private static FloatSize reshapeForPage(float width, float height, ImmutableViewportMetrics metrics) { - // figure out how much of the desired buffer amount we can actually use on the horizontal axis - float usableWidth = Math.min(width, metrics.getPageWidth()); - // if we reduced the buffer amount on the horizontal axis, we should take that saved memory and - // use it on the vertical axis - float extraUsableHeight = (float)Math.floor(((width - usableWidth) * height) / usableWidth); - float usableHeight = Math.min(height + extraUsableHeight, metrics.getPageHeight()); - if (usableHeight < height && usableWidth == width) { - // and the reverse - if we shrunk the buffer on the vertical axis we can add it to the horizontal - float extraUsableWidth = (float)Math.floor(((height - usableHeight) * width) / usableHeight); - usableWidth = Math.min(width + extraUsableWidth, metrics.getPageWidth()); - } - return new FloatSize(usableWidth, usableHeight); - } - - /** - * Expand the given rect in all directions by a "danger zone". The size of the danger zone on an axis - * is the size of the view on that axis multiplied by the given multiplier. The expanded rect is then - * clamped to page bounds and returned. - */ - private static RectF expandByDangerZone(RectF rect, float dangerZoneXMultiplier, float dangerZoneYMultiplier, ImmutableViewportMetrics metrics) { - // calculate the danger zone amounts in pixels - float dangerZoneX = metrics.getWidth() * dangerZoneXMultiplier; - float dangerZoneY = metrics.getHeight() * dangerZoneYMultiplier; - rect = RectUtils.expand(rect, dangerZoneX, dangerZoneY); - // clamp to page bounds - return clampToPageBounds(rect, metrics); - } - - /** - * Expand the given margins such that when they are applied on the viewport, the resulting rect - * does not have any partial tiles, except when it is clipped by the page bounds. This assumes - * the tiles are TILE_SIZE by TILE_SIZE and start at the origin, such that there will always be - * a tile at (0,0)-(TILE_SIZE,TILE_SIZE)). - */ - private static DisplayPortMetrics getTileAlignedDisplayPortMetrics(RectF margins, float zoom, ImmutableViewportMetrics metrics) { - float left = metrics.viewportRectLeft - margins.left; - float top = metrics.viewportRectTop - margins.top; - float right = metrics.viewportRectRight + margins.right; - float bottom = metrics.viewportRectBottom + margins.bottom; - left = Math.max(metrics.pageRectLeft, TILE_SIZE * FloatMath.floor(left / TILE_SIZE)); - top = Math.max(metrics.pageRectTop, TILE_SIZE * FloatMath.floor(top / TILE_SIZE)); - right = Math.min(metrics.pageRectRight, TILE_SIZE * FloatMath.ceil(right / TILE_SIZE)); - bottom = Math.min(metrics.pageRectBottom, TILE_SIZE * FloatMath.ceil(bottom / TILE_SIZE)); - return new DisplayPortMetrics(left, top, right, bottom, zoom); - } - - /** - * Adjust the given margins so if they are applied on the viewport in the metrics, the resulting rect - * does not exceed the page bounds. This code will maintain the total margin amount for a given axis; - * it assumes that margins.left + metrics.getWidth() + margins.right is less than or equal to - * metrics.getPageWidth(); and the same for the y axis. - */ - private static RectF shiftMarginsForPageBounds(RectF margins, ImmutableViewportMetrics metrics) { - // check how much we're overflowing in each direction. note that at most one of leftOverflow - // and rightOverflow can be greater than zero, and at most one of topOverflow and bottomOverflow - // can be greater than zero, because of the assumption described in the method javadoc. - float leftOverflow = metrics.pageRectLeft - (metrics.viewportRectLeft - margins.left); - float rightOverflow = (metrics.viewportRectRight + margins.right) - metrics.pageRectRight; - float topOverflow = metrics.pageRectTop - (metrics.viewportRectTop - margins.top); - float bottomOverflow = (metrics.viewportRectBottom + margins.bottom) - metrics.pageRectBottom; - - // if the margins overflow the page bounds, shift them to other side on the same axis - if (leftOverflow > 0) { - margins.left -= leftOverflow; - margins.right += leftOverflow; - } else if (rightOverflow > 0) { - margins.right -= rightOverflow; - margins.left += rightOverflow; - } - if (topOverflow > 0) { - margins.top -= topOverflow; - margins.bottom += topOverflow; - } else if (bottomOverflow > 0) { - margins.bottom -= bottomOverflow; - margins.top += bottomOverflow; - } - return margins; - } - - /** - * Clamp the given rect to the page bounds and return it. - */ - private static RectF clampToPageBounds(RectF rect, ImmutableViewportMetrics metrics) { - if (rect.top < metrics.pageRectTop) rect.top = metrics.pageRectTop; - if (rect.left < metrics.pageRectLeft) rect.left = metrics.pageRectLeft; - if (rect.right > metrics.pageRectRight) rect.right = metrics.pageRectRight; - if (rect.bottom > metrics.pageRectBottom) rect.bottom = metrics.pageRectBottom; - return rect; - } - - /** - * This class implements the variation where we basically don't bother with a display port. - */ - private static class NoMarginStrategy extends DisplayPortStrategy { - NoMarginStrategy(Map<String, Integer> prefs) { - // no prefs in this strategy - } - - @Override - public DisplayPortMetrics calculate(ImmutableViewportMetrics metrics, PointF velocity) { - return new DisplayPortMetrics(metrics.viewportRectLeft, - metrics.viewportRectTop, - metrics.viewportRectRight, - metrics.viewportRectBottom, - metrics.zoomFactor); - } - - @Override - public boolean aboutToCheckerboard(ImmutableViewportMetrics metrics, PointF velocity, DisplayPortMetrics displayPort) { - return true; - } - - @Override - public String toString() { - return "NoMarginStrategy"; - } - } - - /** - * This class implements the variation where we use a fixed-size margin on the display port. - * The margin is always 300 pixels in all directions, except when we are (a) approaching a page - * boundary, and/or (b) if we are limited by the page size. In these cases we try to maintain - * the area of the display port by (a) shifting the buffer to the other side on the same axis, - * and/or (b) increasing the buffer on the other axis to compensate for the reduced buffer on - * one axis. - */ - private static class FixedMarginStrategy extends DisplayPortStrategy { - // The length of each axis of the display port will be the corresponding view length - // multiplied by this factor. - private final float SIZE_MULTIPLIER; - - // If the visible rect is within the danger zone (measured as a fraction of the view size - // from the edge of the displayport) we start redrawing to minimize checkerboarding. - private final float DANGER_ZONE_X_MULTIPLIER; - private final float DANGER_ZONE_Y_MULTIPLIER; - - FixedMarginStrategy(Map<String, Integer> prefs) { - SIZE_MULTIPLIER = getFloatPref(prefs, PREF_DISPLAYPORT_FM_MULTIPLIER, 2000); - DANGER_ZONE_X_MULTIPLIER = getFloatPref(prefs, PREF_DISPLAYPORT_FM_DANGER_X, 100); - DANGER_ZONE_Y_MULTIPLIER = getFloatPref(prefs, PREF_DISPLAYPORT_FM_DANGER_Y, 200); - } - - @Override - public DisplayPortMetrics calculate(ImmutableViewportMetrics metrics, PointF velocity) { - float displayPortWidth = metrics.getWidth() * SIZE_MULTIPLIER; - float displayPortHeight = metrics.getHeight() * SIZE_MULTIPLIER; - - // we need to avoid having a display port that is larger than the page, or we will end up - // painting things outside the page bounds (bug 729169). we simultaneously need to make - // the display port as large as possible so that we redraw less. reshape the display - // port dimensions to accomplish this. - FloatSize usableSize = reshapeForPage(displayPortWidth, displayPortHeight, metrics); - float horizontalBuffer = usableSize.width - metrics.getWidth(); - float verticalBuffer = usableSize.height - metrics.getHeight(); - - // and now calculate the display port margins based on how much buffer we've decided to use and - // the page bounds, ensuring we use all of the available buffer amounts on one side or the other - // on any given axis. (i.e. if we're scrolled to the top of the page, the vertical buffer is - // entirely below the visible viewport, but if we're halfway down the page, the vertical buffer - // is split). - RectF margins = new RectF(); - margins.left = horizontalBuffer / 2.0f; - margins.right = horizontalBuffer - margins.left; - margins.top = verticalBuffer / 2.0f; - margins.bottom = verticalBuffer - margins.top; - margins = shiftMarginsForPageBounds(margins, metrics); - - return getTileAlignedDisplayPortMetrics(margins, metrics.zoomFactor, metrics); - } - - @Override - public boolean aboutToCheckerboard(ImmutableViewportMetrics metrics, PointF velocity, DisplayPortMetrics displayPort) { - // Increase the size of the viewport based on the danger zone multiplier (and clamp to page - // boundaries), and intersect it with the current displayport to determine whether we're - // close to checkerboarding. - RectF adjustedViewport = expandByDangerZone(metrics.getViewport(), DANGER_ZONE_X_MULTIPLIER, DANGER_ZONE_Y_MULTIPLIER, metrics); - return !displayPort.contains(adjustedViewport); - } - - @Override - public String toString() { - return "FixedMarginStrategy mult=" + SIZE_MULTIPLIER + ", dangerX=" + DANGER_ZONE_X_MULTIPLIER + ", dangerY=" + DANGER_ZONE_Y_MULTIPLIER; - } - } - - /** - * This class implements the variation with a small fixed-size margin with velocity bias. - * In this variation, the default margins are pretty small relative to the view size, but - * they are affected by the panning velocity. Specifically, if we are panning on one axis, - * we remove the margins on the other axis because we are likely axis-locked. Also once - * we are panning in one direction above a certain threshold velocity, we shift the buffer - * so that it is almost entirely in the direction of the pan, with a little bit in the - * reverse direction. - */ - private static class VelocityBiasStrategy extends DisplayPortStrategy { - // The length of each axis of the display port will be the corresponding view length - // multiplied by this factor. - private final float SIZE_MULTIPLIER; - // The velocity above which we apply the velocity bias - private final float VELOCITY_THRESHOLD; - // How much of the buffer to keep in the reverse direction of the velocity - private final float REVERSE_BUFFER; - // If the visible rect is within the danger zone we start redrawing to minimize - // checkerboarding. the danger zone amount is a linear function of the form: - // viewportsize * (base + velocity * incr) - // where base and incr are configurable values. - private final float DANGER_ZONE_BASE_X_MULTIPLIER; - private final float DANGER_ZONE_BASE_Y_MULTIPLIER; - private final float DANGER_ZONE_INCR_X_MULTIPLIER; - private final float DANGER_ZONE_INCR_Y_MULTIPLIER; - - VelocityBiasStrategy(Map<String, Integer> prefs) { - SIZE_MULTIPLIER = getFloatPref(prefs, PREF_DISPLAYPORT_VB_MULTIPLIER, 2000); - VELOCITY_THRESHOLD = /*GeckoAppShell.getDpi()*/ LOKitShell.getDpi() * getFloatPref(prefs, PREF_DISPLAYPORT_VB_VELOCITY_THRESHOLD, 32); - REVERSE_BUFFER = getFloatPref(prefs, PREF_DISPLAYPORT_VB_REVERSE_BUFFER, 200); - DANGER_ZONE_BASE_X_MULTIPLIER = getFloatPref(prefs, PREF_DISPLAYPORT_VB_DANGER_X_BASE, 1000); - DANGER_ZONE_BASE_Y_MULTIPLIER = getFloatPref(prefs, PREF_DISPLAYPORT_VB_DANGER_Y_BASE, 1000); - DANGER_ZONE_INCR_X_MULTIPLIER = getFloatPref(prefs, PREF_DISPLAYPORT_VB_DANGER_X_INCR, 0); - DANGER_ZONE_INCR_Y_MULTIPLIER = getFloatPref(prefs, PREF_DISPLAYPORT_VB_DANGER_Y_INCR, 0); - } - - /** - * Split the given amounts into margins based on the VELOCITY_THRESHOLD and REVERSE_BUFFER values. - * If the velocity is above the VELOCITY_THRESHOLD on an axis, split the amount into REVERSE_BUFFER - * and 1.0 - REVERSE_BUFFER fractions. The REVERSE_BUFFER fraction is set as the margin in the - * direction opposite to the velocity, and the remaining fraction is set as the margin in the direction - * of the velocity. If the velocity is lower than VELOCITY_THRESHOLD, split the amount evenly into the - * two margins on that axis. - */ - private RectF velocityBiasedMargins(float xAmount, float yAmount, PointF velocity) { - RectF margins = new RectF(); - - if (velocity.x > VELOCITY_THRESHOLD) { - margins.left = xAmount * REVERSE_BUFFER; - } else if (velocity.x < -VELOCITY_THRESHOLD) { - margins.left = xAmount * (1.0f - REVERSE_BUFFER); - } else { - margins.left = xAmount / 2.0f; - } - margins.right = xAmount - margins.left; - - if (velocity.y > VELOCITY_THRESHOLD) { - margins.top = yAmount * REVERSE_BUFFER; - } else if (velocity.y < -VELOCITY_THRESHOLD) { - margins.top = yAmount * (1.0f - REVERSE_BUFFER); - } else { - margins.top = yAmount / 2.0f; - } - margins.bottom = yAmount - margins.top; - - return margins; - } - - @Override - public DisplayPortMetrics calculate(ImmutableViewportMetrics metrics, PointF velocity) { - float displayPortWidth = metrics.getWidth() * SIZE_MULTIPLIER; - float displayPortHeight = metrics.getHeight() * SIZE_MULTIPLIER; - - // but if we're panning on one axis, set the margins for the other axis to zero since we are likely - // axis locked and won't be displaying that extra area. - if (Math.abs(velocity.x) > VELOCITY_THRESHOLD && FloatUtils.fuzzyEquals(velocity.y, 0)) { - displayPortHeight = metrics.getHeight(); - } else if (Math.abs(velocity.y) > VELOCITY_THRESHOLD && FloatUtils.fuzzyEquals(velocity.x, 0)) { - displayPortWidth = metrics.getWidth(); - } - - // we need to avoid having a display port that is larger than the page, or we will end up - // painting things outside the page bounds (bug 729169). - displayPortWidth = Math.min(displayPortWidth, metrics.getPageWidth()); - displayPortHeight = Math.min(displayPortHeight, metrics.getPageHeight()); - float horizontalBuffer = displayPortWidth - metrics.getWidth(); - float verticalBuffer = displayPortHeight - metrics.getHeight(); - - // split the buffer amounts into margins based on velocity, and shift it to ... etc. - the rest is truncated
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits