[Libreoffice-commits] core.git: Branch 'feature/droid_calcimpress2' - 3 commits - android/experimental

Tomaž Vajngerl tomaz.vajngerl at collabora.com
Mon Sep 29 05:23:53 PDT 2014


 android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java      |   20 +----
 android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java     |   36 +++-------
 android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/Layer.java     |   33 +++++++++
 android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java |    1 
 android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/TileLayer.java |    5 +
 5 files changed, 56 insertions(+), 39 deletions(-)

New commits:
commit 082b3b68c61433605836a0ff5404e1dc1774a08b
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date:   Mon Sep 29 14:20:11 2014 +0200

    android: refresh screenshot correctly, fix rendering at load
    
    Change-Id: I38345399c96764ecc454cc3e6e8f87b5cc5e8fbe

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
index ba7102e..5c03c2b 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
@@ -1,7 +1,6 @@
 package org.libreoffice;
 
 import android.graphics.Bitmap;
-import android.graphics.Rect;
 import android.graphics.RectF;
 import android.util.DisplayMetrics;
 import android.util.Log;
@@ -15,11 +14,10 @@ import java.util.concurrent.LinkedBlockingQueue;
 public class LOKitThread extends Thread {
     private static final String LOGTAG = LOKitThread.class.getSimpleName();
 
-    public LinkedBlockingQueue<LOEvent> mEventQueue = new LinkedBlockingQueue<LOEvent>();
+    private LinkedBlockingQueue<LOEvent> mEventQueue = new LinkedBlockingQueue<LOEvent>();
     private LibreOfficeMainActivity mApplication;
     private TileProvider mTileProvider;
     private ImmutableViewportMetrics mViewportMetrics;
-    private boolean mCheckboardImageSet = false;
     private GeckoLayerClient mLayerClient;
     private LayerController mController;
 
@@ -36,19 +34,26 @@ public class LOKitThread extends Thread {
         GeckoLayerClient layerClient = mApplication.getLayerClient();
 
         layerClient.beginDrawing();
-
         layerClient.reevaluateTiles();
-
         layerClient.endDrawing(mViewportMetrics);
 
         return true;
     }
 
+    private void refresh() {
+        Bitmap bitmap = mTileProvider.thumbnail();
+        if (bitmap != null) {
+            mApplication.getLayerController().getView().changeCheckerboardBitmap(bitmap, mTileProvider.getPageWidth(), mTileProvider.getPageHeight());
+        }
+
+        RectF rect = new RectF(0, 0, mTileProvider.getPageWidth(), mTileProvider.getPageHeight());
+        mController.setPageRect(rect, rect);
+        mController.setForceRedraw();
+    }
+
     private void changePart(int partIndex) throws InterruptedException {
         mTileProvider.changePart(partIndex);
-        GeckoLayerClient layerClient = mApplication.getLayerClient();
-        updateCheckbardImage();
-        LOKitShell.sendEvent(LOEvent.draw(new Rect()));
+        refresh();
     }
 
     private boolean load(String filename) {
@@ -68,24 +73,11 @@ public class LOKitThread extends Thread {
 
         boolean isReady = mTileProvider.isReady();
         if (isReady) {
-            updateCheckbardImage();
-            RectF rect = new RectF(0, 0, mTileProvider.getPageWidth(), mTileProvider.getPageHeight());
-            mController.setPageRect(rect, rect);
-            mController.setForceRedraw();
+            refresh();
         }
         return isReady;
     }
 
-    private void updateCheckbardImage() {
-        if (!mCheckboardImageSet) {
-            Bitmap bitmap = mTileProvider.thumbnail();
-            if (bitmap != null) {
-                mApplication.getLayerController().getView().changeCheckerboardBitmap(bitmap, mTileProvider.getPageWidth(), mTileProvider.getPageHeight());
-                mCheckboardImageSet = true;
-            }
-        }
-    }
-
     public void run() {
         try {
             while (true) {
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java
index 18f6328..38a09d8 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java
@@ -322,7 +322,6 @@ public class LayerView extends SurfaceView implements SurfaceHolder.Callback {
     }
 
     public void changeCheckerboardBitmap(Bitmap bitmap, float pageWidth, float pageHeight) {
-        mRenderer.resetCheckerboard();
         mRenderer.setCheckerboardBitmap(bitmap, pageWidth, pageHeight);
     }
 }
commit 4b1af3d5c2b8939f904525694ad8f6145d5ba40d
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date:   Mon Sep 29 14:17:59 2014 +0200

    android: use linear scaler for better quality tiles
    
    Change-Id: I60874ad0c849d3f4bc9ff05a7c96daa0bfd3946d

diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/Layer.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/Layer.java
index 3eab452..b7fee29 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/Layer.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/Layer.java
@@ -154,6 +154,39 @@ public abstract class Layer {
         }
     }
 
+    /**
+     * This function fills in the provided <tt>dest</tt> array with values to render a texture.
+     * The array is filled with 4 sets of {x, y, z, texture_x, texture_y} values (so 20 values
+     * in total) corresponding to the corners of the rect.
+     */
+    protected final void fillRectCoordBuffer(float[] dest, RectF rect, float viewWidth, float viewHeight,
+                                             Rect cropRect, float texWidth, float texHeight) {
+        //x, y, z, texture_x, texture_y
+        dest[0] = rect.left / viewWidth;
+        dest[1] = rect.bottom / viewHeight;
+        dest[2] = 0;
+        dest[3] = cropRect.left / texWidth;
+        dest[4] = cropRect.top / texHeight;
+
+        dest[5] = rect.left / viewWidth;
+        dest[6] = rect.top / viewHeight;
+        dest[7] = 0;
+        dest[8] = cropRect.left / texWidth;
+        dest[9] = cropRect.bottom / texHeight;
+
+        dest[10] = rect.right / viewWidth;
+        dest[11] = rect.bottom / viewHeight;
+        dest[12] = 0;
+        dest[13] = cropRect.right / texWidth;
+        dest[14] = cropRect.top / texHeight;
+
+        dest[15] = rect.right / viewWidth;
+        dest[16] = rect.top / viewHeight;
+        dest[17] = 0;
+        dest[18] = cropRect.right / texWidth;
+        dest[19] = cropRect.bottom / texHeight;
+    }
+
     public static class RenderContext {
         public final RectF viewport;
         public final RectF pageRect;
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/TileLayer.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/TileLayer.java
index b7ba36a..1ee1f1a 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/TileLayer.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/TileLayer.java
@@ -151,14 +151,17 @@ public abstract class TileLayer extends Layer {
         // XXX TexSubImage2D is too broken to rely on on Adreno, and very slow
         //     on other chipsets, so we always upload the entire buffer.
         IntSize bufferSize = mImage.getSize();
+
         GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, glInfo.internalFormat, mSize.width,
                             mSize.height, 0, glInfo.format, glInfo.type, imageBuffer);
+
     }
 
     private void bindAndSetGLParameters() {
+        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
         GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureIDs[0]);
         GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER,
-                               GLES20.GL_NEAREST);
+                               GLES20.GL_LINEAR);
         GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER,
                                GLES20.GL_LINEAR);
 
commit 654af33364324a72d357c208ad3788dc2b8d1f02
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date:   Mon Sep 29 14:15:59 2014 +0200

    android: cleanup LOKitShell
    
    Change-Id: I3ccc306f6ad54d7dcac1adf5657dea4171a4cfa0

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
index fbf8675..b6f0b99 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
@@ -3,16 +3,15 @@ package org.libreoffice;
 
 import android.os.Handler;
 import android.util.DisplayMetrics;
+import android.util.Log;
+
 
 public class LOKitShell {
     private static final String LOGTAG = LOKitShell.class.getSimpleName();
 
-    public static int getDpi() {
+    public static float getDpi() {
         DisplayMetrics metrics = LibreOfficeMainActivity.mAppContext.getResources().getDisplayMetrics();
-        return (int) metrics.density * 160;
-    }
-
-    public static void bindWidgetTexture() {
+        return  metrics.density * 160;
     }
 
     public static void sendEvent(LOEvent event) {
@@ -22,16 +21,7 @@ public class LOKitShell {
     }
 
     public static void viewSizeChanged() {
-    }
-
-    public static void scheduleComposite() {
-    }
-
-    public static void schedulePauseComposition() {
-    }
-
-    public static void scheduleResumeComposition() {
-
+        Log.i(LOGTAG, "viewSizeChanged");
     }
 
     // Get a Handler for the main java thread


More information about the Libreoffice-commits mailing list