[Libreoffice-commits] .: Branch 'feature/androidapp' - 2 commits - android/Bootstrap android/qa desktop/source vcl/android vcl/inc vcl/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Dec 17 04:02:42 PST 2012


 android/Bootstrap/Makefile.shared                                      |    6 
 android/qa/desktop/native-code.cxx                                     |    3 
 android/qa/desktop/src/org/libreoffice/android/examples/LODesktop.java |   31 +++
 desktop/source/app/app.cxx                                             |    2 
 desktop/source/app/sofficemain.cxx                                     |    7 
 vcl/android/androidinst.cxx                                            |   96 ++++++++--
 vcl/inc/android/androidinst.hxx                                        |    2 
 vcl/source/app/svmain.cxx                                              |    7 
 8 files changed, 138 insertions(+), 16 deletions(-)

New commits:
commit 5076ece1c759278d409057be22912bee4f4d46a1
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Mon Dec 17 12:02:55 2012 +0000

    get blue foo onto the screen ...

diff --git a/android/qa/desktop/src/org/libreoffice/android/examples/LODesktop.java b/android/qa/desktop/src/org/libreoffice/android/examples/LODesktop.java
index 9b5f103..f0956b4 100644
--- a/android/qa/desktop/src/org/libreoffice/android/examples/LODesktop.java
+++ b/android/qa/desktop/src/org/libreoffice/android/examples/LODesktop.java
@@ -58,6 +58,7 @@ package org.libreoffice.android.examples;
 
 import android.app.Activity;
 import android.app.AlertDialog;
+import android.content.Context;
 import android.content.DialogInterface;
 import android.graphics.Bitmap;
 import android.graphics.Canvas;
@@ -125,7 +126,7 @@ public class LODesktop
     private static native void spawnMain();
 
     /* implementend by vcl */
-    private static native void renderVCL(Bitmap bitmap);
+    public static native void renderVCL(Bitmap bitmap);
 
     /**
      * This class contains the state that is initialized once and never changes
@@ -258,26 +259,6 @@ public class LODesktop
         }
     }
 
-    class BitmapView extends View {
-        LODesktop mDesktop;
-        private Bitmap mBitmap;
-        private long mStartTime;
-
-        public BitmapView(LODesktop desktop)
-        {
-            mDesktop = desktop;
-            mBitmap = Bitmap.createBitmap(1000, 600, Bitmap.Config.ARGB_8888);
-        }
-
-        @Override protected void onDraw(Canvas canvas) {
-            renderVCL(mBitmap);
-            canvas.drawBitmap(mBitmap, 0, 0, null);
-
-            // force a redraw / re-call of ourselves, with a different time-based pattern.
-            invalidate();
-        }
-    }
-
     @Override
     public void onCreate(Bundle savedInstanceState)
     {
@@ -310,8 +291,32 @@ public class LODesktop
             finish();
         }
 
-        setContentView(new BitmapView(this));
+        Log.i(TAG, "onCreate - set content view\n");
+        setContentView(new BitmapView(this, this));
     }
 }
 
+    class BitmapView extends android.view.View
+    {
+        LODesktop mDesktop;
+        Bitmap mBitmap;
+
+        public BitmapView(Context context, LODesktop desktop)
+        {
+            super(context);
+            mDesktop = desktop;
+            mBitmap = Bitmap.createBitmap(1000, 600, Bitmap.Config.ARGB_8888);
+        }
+
+        @Override protected void onDraw(Canvas canvas) {
+            canvas.drawColor(0xFF1ABCDD);
+
+            mDesktop.renderVCL(mBitmap);
+            canvas.drawBitmap(mBitmap, 0, 0, null);
+
+            // re-call ourselves a bit later ...
+            invalidate();
+        }
+    }
+
 // vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/vcl/android/androidinst.cxx b/vcl/android/androidinst.cxx
index 144c51f..44be265 100644
--- a/vcl/android/androidinst.cxx
+++ b/vcl/android/androidinst.cxx
@@ -263,30 +263,33 @@ void AndroidSalInstance::BlitFrameToWindow(ANativeWindow_Buffer *pOutBuffer,
 
 void AndroidSalInstance::RedrawWindows(ANativeWindow *pWindow, ANativeWindow_Buffer *pBuffer)
 {
-    if (!pWindow)
-        return;
-
     ANativeWindow_Buffer aOutBuffer;
     memset ((void *)&aOutBuffer, 0, sizeof (aOutBuffer));
 
+    fprintf (stderr, "RedrawWindows\n");
+
     int32_t nRet = 0;
     if (pBuffer != NULL)
         aOutBuffer = *pBuffer;
     else
     {
+        if (!pWindow)
+            return;
+
         //    ARect aRect;
         fprintf (stderr, "pre lock #3\n");
         nRet = ANativeWindow_lock(pWindow, &aOutBuffer, NULL);
     }
-    fprintf (stderr, "locked window %d returned " // rect:  %d,%d->%d,%d "
+    fprintf (stderr, "Frame count: %d locked window %d returned " // rect:  %d,%d->%d,%d "
              "buffer: %dx%d stride %d, format %d, bits %p\n",
+             (int)getFrames().size(),
              nRet, // aRect.left, aRect.top, aRect.right, aRect.bottom,
              aOutBuffer.width, aOutBuffer.height, aOutBuffer.stride,
              aOutBuffer.format, aOutBuffer.bits);
     if (aOutBuffer.bits != NULL)
     {
 
-#if 0   // pre-'clean' the buffer with cruft:
+#if 1   // pre-'clean' the buffer with cruft:
         // hard-code / guess at a format ...
         int32_t *p = (int32_t *)aOutBuffer.bits;
         for (int32_t y = 0; y < aOutBuffer.height; y++)
@@ -336,7 +339,7 @@ void AndroidSalInstance::RedrawWindows(ANativeWindow *pWindow, ANativeWindow_Buf
     else
         fprintf (stderr, "no buffer for locked window\n");
 
-    if (pBuffer != NULL)
+    if (pBuffer && pWindow)
         ANativeWindow_unlockAndPost(pWindow);
 
     fprintf (stderr, "done render!\n");
@@ -895,10 +898,12 @@ Java_org_libreoffice_android_examples_LODesktop_renderVCL(JNIEnv *env,
         return;
     }
 
+#if 0
     if (info.format != ANDROID_BITMAP_FORMAT_RGB_565) {
         fprintf(stderr, "Bitmap format is not RGB_565 !");
         return;
     }
+#endif
 
     if ((ret = AndroidBitmap_lockPixels(env, bitmap, &pixels)) < 0) {
         fprintf(stderr, "AndroidBitmap_lockPixels() failed ! error=%d", ret);
@@ -933,7 +938,7 @@ typedef struct ANativeWindow_Buffer {
     dummyOut.stride = info.stride;
     dummyOut.format = info.format;
     dummyOut.bits = pixels;
-    AndroidSalInstance::getInstance()->RedrawWindows (lo_get_app()->window, &dummyOut);
+    AndroidSalInstance::getInstance()->RedrawWindows (NULL, &dummyOut);
 
     AndroidBitmap_unlockPixels(env, bitmap);
 }
commit 5ddd72f7422483fd07b3e8741072e87821849e73
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Mon Dec 17 11:15:07 2012 +0000

    first attempt at constantly rendering the vcl window stack ...

diff --git a/android/Bootstrap/Makefile.shared b/android/Bootstrap/Makefile.shared
index 31029a1..6a02b11 100644
--- a/android/Bootstrap/Makefile.shared
+++ b/android/Bootstrap/Makefile.shared
@@ -88,11 +88,13 @@ WHOLELIBS = \
 
 $(OBJLOCAL)/liblo-native-code.so : $(wildcard $(OUTDIR)/lib/lib*.a) native-code.cxx
 	mkdir -p $(OBJLOCAL)
-	$(CXX) -Wl,-Map,liblo-native-code.map -Wl,--gc-sections -Wl,--version-script=../../Bootstrap/version.map -Wl,--no-keep-files-mapped -Wl,--no-undefined -DANDROID -DDISABLE_DYNLOADING -shared -o $(OBJLOCAL)/liblo-native-code.so -I$(OUTDIR)/inc native-code.cxx -L$(OUTDIR)/lib $(WHOLELIBS) $(LIBS) -lgnustl_static -landroid -llog -lz
+	$(CXX) -Wl,-Map,liblo-native-code.map -Wl,--gc-sections -Wl,--version-script=../../Bootstrap/version.map -Wl,--no-keep-files-mapped -Wl,--no-undefined -DANDROID -DDISABLE_DYNLOADING -shared -o $(OBJLOCAL)/liblo-native-code.so -I$(OUTDIR)/inc native-code.cxx -L$(OUTDIR)/lib $(WHOLELIBS) $(LIBS) -lgnustl_static -landroid -ljnigraphics -llog -lz
 
 $(SODEST)/liblo-native-code.so : $(OBJLOCAL)/liblo-native-code.so
 	mkdir -p $(SODEST)
-	$(STRIP) -o $(SODEST)/liblo-native-code.so $(OBJLOCAL)/liblo-native-code.so
+	cp -a $(OBJLOCAL)/liblo-native-code.so $(SODEST)/liblo-native-code.so
+
+# shrinkme $(STRIP) -o $(SODEST)/liblo-native-code.so $(OBJLOCAL)/liblo-native-code.so
 
 link-so: $(SODEST)/liblo-native-code.so
 
diff --git a/android/qa/desktop/native-code.cxx b/android/qa/desktop/native-code.cxx
index 06caf06..e9298e0 100644
--- a/android/qa/desktop/native-code.cxx
+++ b/android/qa/desktop/native-code.cxx
@@ -104,6 +104,9 @@ lo_get_libmap(void)
     extern void Java_org_libreoffice_android_examples_LODesktop_spawnMain();
     volatile void *p = (void *) Java_org_libreoffice_android_examples_LODesktop_spawnMain;
 
+    extern void Java_org_libreoffice_android_examples_LODesktop_renderVCL();
+    volatile void *q = (void *) Java_org_libreoffice_android_examples_LODesktop_renderVCL;
+
     return map;
 }
 
diff --git a/android/qa/desktop/src/org/libreoffice/android/examples/LODesktop.java b/android/qa/desktop/src/org/libreoffice/android/examples/LODesktop.java
index e1564b0..9b5f103 100644
--- a/android/qa/desktop/src/org/libreoffice/android/examples/LODesktop.java
+++ b/android/qa/desktop/src/org/libreoffice/android/examples/LODesktop.java
@@ -124,6 +124,9 @@ public class LODesktop
     /* implementend by desktop */
     private static native void spawnMain();
 
+    /* implementend by vcl */
+    private static native void renderVCL(Bitmap bitmap);
+
     /**
      * This class contains the state that is initialized once and never changes
      * (not specific to a document or a view).
@@ -255,6 +258,26 @@ public class LODesktop
         }
     }
 
+    class BitmapView extends View {
+        LODesktop mDesktop;
+        private Bitmap mBitmap;
+        private long mStartTime;
+
+        public BitmapView(LODesktop desktop)
+        {
+            mDesktop = desktop;
+            mBitmap = Bitmap.createBitmap(1000, 600, Bitmap.Config.ARGB_8888);
+        }
+
+        @Override protected void onDraw(Canvas canvas) {
+            renderVCL(mBitmap);
+            canvas.drawBitmap(mBitmap, 0, 0, null);
+
+            // force a redraw / re-call of ourselves, with a different time-based pattern.
+            invalidate();
+        }
+    }
+
     @Override
     public void onCreate(Bundle savedInstanceState)
     {
@@ -280,11 +303,14 @@ public class LODesktop
                 initBootstrapContext();
 
             spawnMain();
+
         }
         catch (Exception e) {
             e.printStackTrace(System.err);
             finish();
         }
+
+        setContentView(new BitmapView(this));
     }
 }
 
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 26d79ec..a70030e 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -551,6 +551,8 @@ Desktop::~Desktop()
 
 void Desktop::Init()
 {
+    fprintf (stderr, "Desktop::Init()\n");
+
     RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::Desktop::Init" );
     SetBootstrapStatus(BS_OK);
 
diff --git a/desktop/source/app/sofficemain.cxx b/desktop/source/app/sofficemain.cxx
index 00f956b..69697c9 100644
--- a/desktop/source/app/sofficemain.cxx
+++ b/desktop/source/app/sofficemain.cxx
@@ -77,6 +77,7 @@ extern "C" int DESKTOP_DLLPUBLIC soffice_main()
         return EXIT_SUCCESS;
     }
 #endif
+    fprintf (stderr, "enter svmain()\n");
     return SVMain();
 #if defined ANDROID
     } catch (const ::com::sun::star::uno::Exception &e) {
@@ -94,7 +95,11 @@ public:
     MainThread() : salhelper::Thread("vcl-mainloop") { launch(); }
     virtual void execute()
     {
-        soffice_main();
+        int nRet;
+        do {
+            nRet = soffice_main();
+            fprintf( stderr, "nRet %d\n", nRet );
+        } while (nRet == 81 || nRet == 79); // pretend to re-start.
     }
 };
 
diff --git a/vcl/android/androidinst.cxx b/vcl/android/androidinst.cxx
index 7f57a04..144c51f 100644
--- a/vcl/android/androidinst.cxx
+++ b/vcl/android/androidinst.cxx
@@ -32,6 +32,7 @@
 #include <jni.h>
 #include <android/log.h>
 #include <android/looper.h>
+#include <android/bitmap.h>
 #include <osl/detail/android-bootstrap.h>
 #include <osl/detail/android_native_app_glue.h>
 #include <rtl/strbuf.hxx>
@@ -260,7 +261,7 @@ void AndroidSalInstance::BlitFrameToWindow(ANativeWindow_Buffer *pOutBuffer,
     BlitFrameRegionToWindow(pOutBuffer, aDev, aWhole, 0, 0);
 }
 
-void AndroidSalInstance::RedrawWindows(ANativeWindow *pWindow)
+void AndroidSalInstance::RedrawWindows(ANativeWindow *pWindow, ANativeWindow_Buffer *pBuffer)
 {
     if (!pWindow)
         return;
@@ -268,9 +269,15 @@ void AndroidSalInstance::RedrawWindows(ANativeWindow *pWindow)
     ANativeWindow_Buffer aOutBuffer;
     memset ((void *)&aOutBuffer, 0, sizeof (aOutBuffer));
 
-//    ARect aRect;
-    fprintf (stderr, "pre lock #3\n");
-    int32_t nRet = ANativeWindow_lock(pWindow, &aOutBuffer, NULL);
+    int32_t nRet = 0;
+    if (pBuffer != NULL)
+        aOutBuffer = *pBuffer;
+    else
+    {
+        //    ARect aRect;
+        fprintf (stderr, "pre lock #3\n");
+        nRet = ANativeWindow_lock(pWindow, &aOutBuffer, NULL);
+    }
     fprintf (stderr, "locked window %d returned " // rect:  %d,%d->%d,%d "
              "buffer: %dx%d stride %d, format %d, bits %p\n",
              nRet, // aRect.left, aRect.top, aRect.right, aRect.bottom,
@@ -328,7 +335,9 @@ void AndroidSalInstance::RedrawWindows(ANativeWindow *pWindow)
     }
     else
         fprintf (stderr, "no buffer for locked window\n");
-    ANativeWindow_unlockAndPost(pWindow);
+
+    if (pBuffer != NULL)
+        ANativeWindow_unlockAndPost(pWindow);
 
     fprintf (stderr, "done render!\n");
     maRedrawRegion.SetEmpty();
@@ -826,13 +835,14 @@ SalInstance *CreateSalInstance()
     fprintf (stderr, "Android: CreateSalInstance!\n");
     AndroidSalInstance* pInstance = new AndroidSalInstance( new SalYieldMutex() );
     new AndroidSalData( pInstance );
-    pInstance->AcquireYieldMutex(1);
+// FIXME: we init VCL in a different thread from where we run the mainloop [!] ...
+//    pInstance->AcquireYieldMutex(1);
     return pInstance;
 }
 
 void DestroySalInstance( SalInstance *pInst )
 {
-    pInst->ReleaseYieldMutex();
+//    pInst->ReleaseYieldMutex();
     delete pInst;
 }
 
@@ -870,5 +880,62 @@ int AndroidSalSystem::ShowNativeDialog( const rtl::OUString& rTitle,
     return 0;
 }
 
+// Render everything
+extern "C" SAL_JNI_EXPORT void JNICALL
+Java_org_libreoffice_android_examples_LODesktop_renderVCL(JNIEnv *env,
+                                                          jobject /* dummy */,
+                                                          jobject bitmap)
+{
+    AndroidBitmapInfo  info;
+    void*              pixels;
+    int                ret;
+
+    if ((ret = AndroidBitmap_getInfo(env, bitmap, &info)) < 0) {
+        fprintf(stderr, "AndroidBitmap_getInfo() failed ! error=%d", ret);
+        return;
+    }
+
+    if (info.format != ANDROID_BITMAP_FORMAT_RGB_565) {
+        fprintf(stderr, "Bitmap format is not RGB_565 !");
+        return;
+    }
+
+    if ((ret = AndroidBitmap_lockPixels(env, bitmap, &pixels)) < 0) {
+        fprintf(stderr, "AndroidBitmap_lockPixels() failed ! error=%d", ret);
+    }
+
+/*
+typedef struct ANativeWindow_Buffer {
+    // The number of pixels that are show horizontally.
+    int32_t width;
+
+    // The number of pixels that are shown vertically.
+    int32_t height;
+
+    // The number of *pixels* that a line in the buffer takes in
+    // memory.  This may be >= width.
+    int32_t stride;
+
+    // The format of the buffer.  One of WINDOW_FORMAT_*
+    int32_t format;
+
+    // The actual bits.
+    void* bits;
+
+    // Do not touch.
+    uint32_t reserved[6];
+} ANativeWindow_Buffer;
+*/
+
+    ANativeWindow_Buffer dummyOut; // look like a window for now ...
+    dummyOut.width = info.width;
+    dummyOut.height = info.height;
+    dummyOut.stride = info.stride;
+    dummyOut.format = info.format;
+    dummyOut.bits = pixels;
+    AndroidSalInstance::getInstance()->RedrawWindows (lo_get_app()->window, &dummyOut);
+
+    AndroidBitmap_unlockPixels(env, bitmap);
+}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/android/androidinst.hxx b/vcl/inc/android/androidinst.hxx
index addec80..74acc80 100644
--- a/vcl/inc/android/androidinst.hxx
+++ b/vcl/inc/android/androidinst.hxx
@@ -62,7 +62,7 @@ public:
     // incoming android event handlers:
     void      onAppCmd     (struct android_app* app, int32_t cmd);
     int32_t   onInputEvent (struct android_app* app, AInputEvent* event);
-    void      RedrawWindows(ANativeWindow *pWindow);
+    void RedrawWindows(ANativeWindow *pWindow, ANativeWindow_Buffer *pBuffer = NULL);
     SalFrame *getFocusFrame() const;
 
     void      damaged(AndroidSalFrame *frame, const Rectangle &rRect);
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index f2135b2..57367fb 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -153,12 +153,19 @@ int ImplSVMain()
 
     int nReturn = EXIT_FAILURE;
 
+#if 1 // android
+    sal_Bool bInit = true; // already inited by Bootstrap.
+#else
     sal_Bool bInit = InitVCL();
+#endif
+
+    fprintf (stderr, "init vcl %d\n", bInit);
 
     if( bInit )
     {
         // call application main
         pSVData->maAppData.mbInAppMain = sal_True;
+        fprintf(stderr, "call app  main from vcl!\n");
         nReturn = pSVData->mpApp->Main();
         pSVData->maAppData.mbInAppMain = sal_False;
     }


More information about the Libreoffice-commits mailing list