[Libreoffice-commits] .: 7 commits - android/Bootstrap android/experimental sal/android sal/inc sal/Package_inc.mk toolkit/inc toolkit/source touch/idl touch/Library_libotouch.mk touch/source vcl/headless vcl/inc vcl/source
Tor Lillqvist
tml at kemper.freedesktop.org
Tue Jun 12 04:03:19 PDT 2012
android/Bootstrap/src/org/libreoffice/android/Bootstrap.java | 10
android/experimental/DocumentLoader/Makefile | 1
android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java | 111 ++--------
sal/Package_inc.mk | 1
sal/android/lo-bootstrap.c | 40 +++
sal/inc/sal/ByteBufferWrapper.hxx | 51 ++++
toolkit/inc/toolkit/awt/vclxtoolkit.hxx | 11
toolkit/source/awt/vclxtoolkit.cxx | 22 +
touch/Library_libotouch.mk | 13 +
touch/idl/org/libreoffice/touch/XDocument.idl | 12 -
touch/source/android/android.cxx | 36 +++
touch/source/uno/Document.cxx | 66 +++--
vcl/headless/svpvd.cxx | 10
vcl/inc/headless/svpvd.hxx | 3
vcl/inc/salvd.hxx | 12 -
vcl/inc/vcl/virdev.hxx | 5
vcl/source/gdi/virdev.cxx | 27 +-
17 files changed, 297 insertions(+), 134 deletions(-)
New commits:
commit cb0450899ddb2ea75d6a6fcf630f41292af64330
Author: Tor Lillqvist <tlillqvist at suse.com>
Date: Tue Jun 12 09:42:11 2012 +0300
Add a default dummy implementation of SalVirtualDevice::SetSizeUsingBuffer()
Change-Id: Ib1d98173f2dd29a59ce49bbe93ff563d5bb913a0
diff --git a/vcl/inc/salvd.hxx b/vcl/inc/salvd.hxx
index 5cca88d..2f48a73 100644
--- a/vcl/inc/salvd.hxx
+++ b/vcl/inc/salvd.hxx
@@ -54,7 +54,11 @@ public: // public for Sal Implementation
virtual sal_Bool SetSize( long nNewDX, long nNewDY ) = 0;
// Set new size using a buffer at the given address
- virtual sal_Bool SetSizeUsingBuffer( long nNewDX, long nNewDY, const basebmp::RawMemorySharedArray &pBuffer ) = 0;
+ virtual sal_Bool SetSizeUsingBuffer( long nNewDX, long nNewDY, const basebmp::RawMemorySharedArray & /* pBuffer */ )
+ {
+ // Only the headless virtual device has an implementation that uses pBuffer.
+ return SetSize( nNewDX, nNewDY );
+ }
/// Get actual VDev size in pixel
virtual void GetSize( long& rWidth, long& rHeight ) = 0;
commit ff719cd8bb07447655c09f9366fe3c4debd31717
Author: Tor Lillqvist <tlillqvist at suse.com>
Date: Mon Jun 11 20:07:58 2012 +0300
More hacking
Note that this Document class is work in progress and the code hasn't
ever been run yet even. Not used by the DocumentLoader test appp
currently.
Change-Id: Ibb285d455f31d9bda43133f3a289fc4564b83d47
diff --git a/touch/source/uno/Document.cxx b/touch/source/uno/Document.cxx
index 7d41698..5163ef4 100644
--- a/touch/source/uno/Document.cxx
+++ b/touch/source/uno/Document.cxx
@@ -11,7 +11,7 @@
#include <com/sun/star/awt/XBitmap.hpp>
#include <com/sun/star/awt/XDevice.hpp>
-#include <com/sun/star/awt/XToolkit.hpp>
+#include <com/sun/star/awt/XToolkit2.hpp>
#include <com/sun/star/beans/NamedValue.hpp>
#include <com/sun/star/beans/PropertyValues.hpp>
#include <com/sun/star/frame/XComponentLoader.hpp>
@@ -40,11 +40,8 @@ private:
OUString m_sURI;
uno::Reference< uno::XComponentContext > m_rContext;
uno::Reference< lang::XComponent > m_xComponent;
+ uno::Reference< awt::XToolkit2 > m_xToolkit;
uno::Reference< frame::XController > m_xController;
- uno::Reference< awt::XDevice > m_xDevice;
- uno::Reference< view::XRenderable > m_xRenderable;
-
- beans::PropertyValues m_aRenderProps;
// XRenderable.getRendererCount() and .render() need an XController in the
// properties, at least in the test Java code it seemed that a totally
@@ -137,6 +134,7 @@ protected:
{
}
+public:
// XInitialization
virtual void SAL_CALL
initialize( const uno::Sequence< uno::Any >& arguments )
@@ -164,21 +162,9 @@ protected:
m_xComponent = componentLoader->loadComponentFromURL( m_sURI, "_blank", 0, loadProps );
- uno::Reference< awt::XToolkit > toolkit( m_rContext->getServiceManager()->createInstanceWithContext( "com.sun.star.awt.Toolkit", m_rContext ), uno::UNO_QUERY_THROW );
-
- m_xDevice = toolkit->createScreenCompatibleDevice( 1024, 1024 );
-
- m_xRenderable = uno::Reference< view::XRenderable >( m_rContext->getServiceManager()->createInstanceWithContext( "com.sun.star.view.Renderable", m_rContext ), uno::UNO_QUERY_THROW );
+ m_xToolkit = uno::Reference< awt::XToolkit2 >( m_rContext->getServiceManager()->createInstanceWithContext( "com.sun.star.awt.Toolkit2", m_rContext ), uno::UNO_QUERY_THROW );
m_xController = new MyXController();
-
- m_aRenderProps.realloc( 3 );
- m_aRenderProps[0].Name = "IsPrinter";
- m_aRenderProps[0].Value <<= sal_Bool(true);
- m_aRenderProps[1].Name = "RenderDevice";
- m_aRenderProps[1].Value <<= m_xDevice;
- m_aRenderProps[2].Name = "View";
- m_aRenderProps[2].Value <<= m_xController;
}
}
@@ -190,12 +176,30 @@ protected:
uno::Any selection;
selection <<= m_xComponent;
- return m_xRenderable->getRendererCount( selection, m_aRenderProps );
+ uno::Reference< awt::XDevice > device;
+ uno::Reference< view::XRenderable > renderable;
+
+ beans::PropertyValues renderProps;
+
+ device = m_xToolkit->createScreenCompatibleDevice( 128, 128 );
+
+ renderable = uno::Reference< view::XRenderable >( m_rContext->getServiceManager()->createInstanceWithContext( "com.sun.star.view.Renderable", m_rContext ), uno::UNO_QUERY_THROW );
+
+ renderProps.realloc( 3 );
+ renderProps[0].Name = "IsPrinter";
+ renderProps[0].Value <<= sal_Bool(true);
+ renderProps[1].Name = "RenderDevice";
+ renderProps[1].Value <<= device;
+ renderProps[2].Name = "View";
+ renderProps[2].Value <<= m_xController;
+
+ return renderable->getRendererCount( selection, renderProps );
}
virtual void SAL_CALL
render( sal_Int64 buffer,
- sal_Int32 bufferSize,
+ sal_Int32 width,
+ sal_Int32 height,
const uno::Reference< XDocumentRenderCallback >& listener,
sal_Int32 pageNo,
sal_Int32 zoomLevel,
@@ -203,20 +207,30 @@ protected:
sal_Int32 y )
throw ( lang::IllegalArgumentException, uno::RuntimeException)
{
- uno::Any selection;
-
- (void) buffer;
- (void) bufferSize;
(void) listener;
(void) zoomLevel;
(void) x;
(void) y;
+ uno::Any selection;
+
selection <<= m_xComponent;
- m_xRenderable->render( pageNo, selection, m_aRenderProps );
+ uno::Reference< awt::XDevice > device( m_xToolkit->createScreenCompatibleDeviceUsingBuffer( width, height, buffer ) );
+
+ beans::PropertyValues renderProps;
+
+ renderProps.realloc( 3 );
+ renderProps[0].Name = "IsPrinter";
+ renderProps[0].Value <<= sal_Bool(true);
+ renderProps[1].Name = "RenderDevice";
+ renderProps[1].Value <<= device;
+ renderProps[2].Name = "View";
+ renderProps[2].Value <<= m_xController;
+
+ uno::Reference< view::XRenderable > renderable( m_rContext->getServiceManager()->createInstanceWithContext( "com.sun.star.view.Renderable", m_rContext ), uno::UNO_QUERY_THROW );
- uno::Reference< awt::XBitmap> bitmap( m_xDevice->createBitmap( 0, 0, 1024, 1024 ) );
+ renderable->render( pageNo, selection, renderProps );
}
};
commit 3ea3c6afa274ea169212101111628d883b7b3f65
Author: Tor Lillqvist <tlillqvist at suse.com>
Date: Mon Jun 11 20:06:39 2012 +0300
Use XToolkit2::createScreenCompatibleDeviceUsingBuffer
Render directly to a direct ByteBuffer allocated on the Java side.
Change-Id: I2d66e4146df77e92260918a78ef22cd9b8c95384
diff --git a/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java b/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java
index 1f0c14e..15b0f35 100644
--- a/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java
+++ b/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java
@@ -116,7 +116,13 @@ public class Bootstrap extends NativeActivity
// documentation sucks.
public static native void twiddle_BGR_to_RGBA(byte[] source, int offset, int width, int height, ByteBuffer destination);
- public static native void force_full_alpha(byte[] source, int offset, int size);
+ public static native void force_full_alpha_array(byte[] array, int offset, int length);
+
+ public static native void force_full_alpha_bb(ByteBuffer buffer, int offset, int length);
+
+ public static native long new_byte_buffer_wrapper(ByteBuffer bbuffer);
+
+ public static native void delete_byte_buffer_wrapper(long bbw);
// This setup() method is called 1) in apps that use *this* class as their activity from onCreate(),
// and 2) should be called from other kinds of LO code using apps.
@@ -282,6 +288,8 @@ public class Bootstrap extends NativeActivity
// time by the package manager.
static {
System.loadLibrary("lo-bootstrap");
+ System.loadLibrary("gnustl_shared");
+ System.loadLibrary("libotouchlo");
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/android/experimental/DocumentLoader/Makefile b/android/experimental/DocumentLoader/Makefile
index 8129948..9423336 100644
--- a/android/experimental/DocumentLoader/Makefile
+++ b/android/experimental/DocumentLoader/Makefile
@@ -80,6 +80,7 @@ copy-stuff:
juhx \
jvmaccessgcc3 \
jvmfwk \
+ libotouchlo \
lo-bootstrap \
localebe1.uno \
localedata_en \
diff --git a/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java b/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java
index 91af731..8e9e499 100644
--- a/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java
+++ b/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java
@@ -39,7 +39,7 @@ import com.polites.android.GestureImageView;
import com.sun.star.awt.XBitmap;
import com.sun.star.awt.XControl;
import com.sun.star.awt.XDevice;
-import com.sun.star.awt.XToolkit;
+import com.sun.star.awt.XToolkit2;
import com.sun.star.beans.PropertyValue;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.frame.XController;
@@ -170,6 +170,26 @@ public class DocumentLoader
}
}
+ static void dumpBytes(String name, ByteBuffer bytes, int offset)
+ {
+ if (bytes == null) {
+ Log.i(TAG, name + " is null");
+ return;
+ }
+ Log.i(TAG, name + ":");
+
+ if (offset != 0)
+ Log.i(TAG, " (offset " + offset + ")");
+
+ for (int i = offset; i < Math.min(bytes.limit(), offset+160); i += 16) {
+ String s = "";
+ for (int j = i; j < Math.min(bytes.limit(), i+16); j++)
+ s = s + String.format(" %02x", bytes.get(j));
+
+ Log.i(TAG, s);
+ }
+ }
+
@Override
public void onCreate(Bundle savedInstanceState)
{
@@ -256,10 +276,12 @@ public class DocumentLoader
dumpUNOObject("toolkit", toolkit);
- XToolkit xToolkit = (XToolkit)
- UnoRuntime.queryInterface(XToolkit.class, toolkit);
+ XToolkit2 xToolkit = (XToolkit2)
+ UnoRuntime.queryInterface(XToolkit2.class, toolkit);
- XDevice device = xToolkit.createScreenCompatibleDevice(1024, 1024);
+ ByteBuffer bb = ByteBuffer.allocateDirect(1024*1024*4);
+ long wrapped_bb = Bootstrap.new_byte_buffer_wrapper(bb);
+ XDevice device = xToolkit.createScreenCompatibleDeviceUsingBuffer(1024, 1024, wrapped_bb);
dumpUNOObject("device", device);
@@ -282,86 +304,17 @@ public class DocumentLoader
renderBabe.render(0, oDoc, renderProps);
- XBitmap bitmap = device.createBitmap(0, 0, 1024, 1024);
-
- byte[] image = bitmap.getDIB();
-
- dumpBytes("image", image, 0);
-
- if (image[0] != 'B' || image[1] != 'M') {
- Log.wtf(TAG, "getDIB() didn't return a BMP file");
- return;
- }
-
- ByteBuffer imagebb = ByteBuffer.wrap(image);
- imagebb.order(ByteOrder.LITTLE_ENDIAN);
-
- if (imagebb.getInt(0x0e) != 40) {
- Log.wtf(TAG, "getDIB() didn't return a DIB with BITMAPINFOHEADER");
- return;
- }
-
- if (imagebb.getShort(0x1c) != 32) {
- Log.wtf(TAG, "getDIB() didn't return a 32 bpp DIB");
- return;
- }
-
- if (imagebb.getInt(0x1e) != 3) {
- Log.wtf(TAG, "getDIB() didn't return a BI_BITFIELDS DIB");
- return;
- }
-
- if (imagebb.getInt(0x36) != 0x000000ff |
- imagebb.getInt(0x3a) != 0x0000ff00 ||
- imagebb.getInt(0x3e) != 0x00ff0000) {
- Log.wtf(TAG, "getDIB() didn't return DIB in RGBX format");
- return;
- }
-
- int offset = imagebb.getInt(0x0a);
- int width = imagebb.getInt(0x12);
- int height = imagebb.getInt(0x16);
-
- Log.i(TAG, String.format("offset: %d (%x), width: %d, height: %d", offset, offset, width, height));
-
- Bootstrap.force_full_alpha(image, offset, width * height * 4);
-
+ Log.i(TAG, "Rendered:");
+ dumpBytes("bb", bb, 0);
+ Bootstrap.force_full_alpha_bb(bb, 0, 1024 * 1024 * 4);
Log.i(TAG, "after force_full_alpha:");
- dumpBytes("image", image, 0);
-
- for (int i = offset; i < offset + width * height * 4; i++) {
- if (image[i] != -1) {
- int o = offset + (((i-offset) - 4) / 4) * 4;
- dumpBytes("First non-ones bytes", image, o);
- o += 160;
- dumpBytes("...", image, o);
- o += 160;
- dumpBytes("...", image, o);
- o += 160;
- dumpBytes("...", image, o);
- break;
- }
- }
+ dumpBytes("bb", bb, 0);
ImageView imageView = new GestureImageView(this);
imageView.setScaleY(-1);
- Bitmap bm = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
- imagebb.position(offset);
-
- // Thanks to Android bug 32588, the above is not enough to get the
- // below copyPixelsFromBuffer() to start copying at offset, it
- // will (as of Android 4.0.3) copy from position zero anyway. So
- // instead have to shift (compact) the bloody buffer.
- imagebb.compact();
-
- // I don't understand what the compact() documentation says about
- // the new position; so explicitly put it at zero, in case
- // runnning on an Android where copyPixelsFromBuffer() *does* take
- // the position into account.
- imagebb.position(0);
-
- bm.copyPixelsFromBuffer(imagebb);
+ Bitmap bm = Bitmap.createBitmap(1024, 1024, Bitmap.Config.ARGB_8888);
+ bm.copyPixelsFromBuffer(bb);
imageView.setImageBitmap(bm);
diff --git a/sal/android/lo-bootstrap.c b/sal/android/lo-bootstrap.c
index b6e29ba..677ff1c 100644
--- a/sal/android/lo-bootstrap.c
+++ b/sal/android/lo-bootstrap.c
@@ -1907,11 +1907,11 @@ Java_org_libreoffice_android_Bootstrap_twiddle_1BGR_1to_1RGBA(JNIEnv* env,
__attribute__ ((visibility("default")))
void
-Java_org_libreoffice_android_Bootstrap_force_1full_1alpha(JNIEnv* env,
- jobject clazz,
- jbyteArray array,
- jint offset,
- jint size)
+Java_org_libreoffice_android_Bootstrap_force_1full_1alpha_1array(JNIEnv* env,
+ jobject clazz,
+ jbyteArray array,
+ jint offset,
+ jint length)
{
void *a = (*env)->GetPrimitiveArrayCritical(env, array, NULL);
jbyte *p = ((jbyte *) a) + offset;
@@ -1920,7 +1920,7 @@ Java_org_libreoffice_android_Bootstrap_force_1full_1alpha(JNIEnv* env,
(void) clazz;
- for (i = 0; i < size; i += 4) {
+ for (i = 0; i < length; i += 4) {
p[3] = 0xFF;
p += 4;
}
@@ -1929,6 +1929,34 @@ Java_org_libreoffice_android_Bootstrap_force_1full_1alpha(JNIEnv* env,
}
__attribute__ ((visibility("default")))
+void
+Java_org_libreoffice_android_Bootstrap_force_1full_1alpha_1bb(JNIEnv* env,
+ jobject clazz,
+ jobject buffer,
+ jint offset,
+ jint length)
+{
+ jbyte *p = (*env)->GetDirectBufferAddress(env, buffer) + offset;
+
+ int i;
+
+ (void) clazz;
+
+ for (i = 0; i < length; i += 4) {
+ p[3] = 0xFF;
+ p += 4;
+ }
+}
+
+__attribute__ ((visibility("default")))
+jlong
+Java_org_libreoffice_android_Bootstrap_address_1of_1direct_1byte_1buffer(JNIEnv *env,
+ jobject bbuffer)
+{
+ return (jlong) (intptr_t) (*env)->GetDirectBufferAddress(env, bbuffer);
+}
+
+__attribute__ ((visibility("default")))
JavaVM *
lo_get_javavm(void)
{
commit 96c4aeedb04bfb1438b69875951fc132142cb0d3
Author: Tor Lillqvist <tlillqvist at suse.com>
Date: Mon Jun 11 20:02:11 2012 +0300
Implement XToolkit2::createScreenCompatibleDeviceUsingBuffer for Android
Change-Id: I8dd16850a35cd2de7260dcbe9a8aa7afae2294be
diff --git a/toolkit/inc/toolkit/awt/vclxtoolkit.hxx b/toolkit/inc/toolkit/awt/vclxtoolkit.hxx
index e706d9c..dc085b8 100644
--- a/toolkit/inc/toolkit/awt/vclxtoolkit.hxx
+++ b/toolkit/inc/toolkit/awt/vclxtoolkit.hxx
@@ -31,7 +31,7 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/awt/XSystemChildFactory.hpp>
-#include <com/sun/star/awt/XToolkit.hpp>
+#include <com/sun/star/awt/XToolkit2.hpp>
#include <com/sun/star/awt/XDataTransferProviderAccess.hpp>
#include <com/sun/star/lang/XTypeProvider.hpp>
#include <com/sun/star/awt/XExtendedToolkit.hpp>
@@ -80,7 +80,7 @@ protected:
class VCLXToolkit : public VCLXToolkit_Impl,
public cppu::WeakComponentImplHelper7<
- ::com::sun::star::awt::XToolkit,
+ ::com::sun::star::awt::XToolkit2,
::com::sun::star::lang::XServiceInfo,
::com::sun::star::awt::XSystemChildFactory,
::com::sun::star::awt::XMessageBoxFactory,
@@ -128,12 +128,17 @@ public:
VCLXToolkit( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & );
~VCLXToolkit();
+ // ::com::sun::star::awt::XToolkit2
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > SAL_CALL createScreenCompatibleDeviceUsingBuffer( sal_Int32 Width, sal_Int32 Height, sal_Int64 addressOfMemoryBufferForSharedArrayWrapper ) throw
+(::com::sun::star::uno::RuntimeException);
+
// ::com::sun::star::awt::XToolkit
::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > SAL_CALL getDesktopWindow( ) throw(::com::sun::star::uno::RuntimeException);
::com::sun::star::awt::Rectangle SAL_CALL getWorkArea( ) throw(::com::sun::star::uno::RuntimeException);
::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > SAL_CALL createWindow( const ::com::sun::star::awt::WindowDescriptor& Descriptor ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > > SAL_CALL createWindows( const ::com::sun::star::uno::Sequence< ::com::sun::star::awt::WindowDescriptor >& Descriptors ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
- ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > SAL_CALL createScreenCompatibleDevice( sal_Int32 Width, sal_Int32 Height ) throw(::com::sun::star::uno::RuntimeException);
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > SAL_CALL createScreenCompatibleDevice( sal_Int32 Width, sal_Int32 Height ) throw
+(::com::sun::star::uno::RuntimeException);
::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion > SAL_CALL createRegion( ) throw(::com::sun::star::uno::RuntimeException);
// ::com::sun::star::awt::XSystemChildFactory
diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx
index 7f775fb..c799393 100644
--- a/toolkit/source/awt/vclxtoolkit.cxx
+++ b/toolkit/source/awt/vclxtoolkit.cxx
@@ -63,6 +63,11 @@
#include "postmac.h"
#endif
+#ifdef ANDROID
+#include <sal/ByteBufferWrapper.hxx>
+using org::libreoffice::touch::ByteBufferWrapper;
+#endif
+
#ifdef IOS
#include "premac.h"
#include <UIKit/UIKit.h>
@@ -468,7 +473,7 @@ static void SAL_CALL ToolkitWorkerFunction( void* pArgs )
// contructor, which might initialize VCL
VCLXToolkit::VCLXToolkit( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr ):
cppu::WeakComponentImplHelper7<
- ::com::sun::star::awt::XToolkit,
+ ::com::sun::star::awt::XToolkit2,
::com::sun::star::lang::XServiceInfo,
::com::sun::star::awt::XSystemChildFactory,
::com::sun::star::awt::XMessageBoxFactory,
@@ -562,6 +567,11 @@ void SAL_CALL VCLXToolkit::disposing()
::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > VCLXToolkit::createScreenCompatibleDevice( sal_Int32 Width, sal_Int32 Height ) throw(::com::sun::star::uno::RuntimeException)
{
+ return createScreenCompatibleDeviceUsingBuffer( Width, Height, 0 );
+}
+
+::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > VCLXToolkit::createScreenCompatibleDeviceUsingBuffer( sal_Int32 Width, sal_Int32 Height, sal_Int64 addressOfMemoryBufferForSharedArrayWrapper ) throw(::com::sun::star::uno::RuntimeException)
+{
::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > xRef;
@@ -570,7 +580,15 @@ void SAL_CALL VCLXToolkit::disposing()
SolarMutexGuard aSolarGuard;
VirtualDevice* pV = new VirtualDevice;
- pV->SetOutputSizePixel( Size( Width, Height ) );
+ if ( addressOfMemoryBufferForSharedArrayWrapper != 0 ) {
+#if defined(ANDROID)
+ ByteBufferWrapper *bbw = (ByteBufferWrapper *) (intptr_t) addressOfMemoryBufferForSharedArrayWrapper;
+ pV->SetOutputSizePixelAndBuffer( Size( Width, Height ), basebmp::RawMemorySharedArray( bbw->pointer(), *bbw ));
+ OSL_FAIL( "rendering to a pre-allocated buffer not done yet for this OS" );
+#endif
+ } else {
+ pV->SetOutputSizePixel( Size( Width, Height ) );
+ }
pVDev->SetVirtualDevice( pV );
xRef = pVDev;
diff --git a/vcl/headless/svpvd.cxx b/vcl/headless/svpvd.cxx
index fb752e6..a0d6aaf 100644
--- a/vcl/headless/svpvd.cxx
+++ b/vcl/headless/svpvd.cxx
@@ -57,6 +57,11 @@ void SvpSalVirtualDevice::ReleaseGraphics( SalGraphics* pGraphics )
sal_Bool SvpSalVirtualDevice::SetSize( long nNewDX, long nNewDY )
{
+ return SetSizeUsingBuffer( nNewDX, nNewDY, basebmp::RawMemorySharedArray() );
+}
+
+sal_Bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY, const basebmp::RawMemorySharedArray &pBuffer )
+{
B2IVector aDevSize( nNewDX, nNewDY );
if( aDevSize.getX() == 0 )
aDevSize.setX( 1 );
@@ -89,7 +94,10 @@ sal_Bool SvpSalVirtualDevice::SetSize( long nNewDX, long nNewDY )
#endif
}
m_aDevice = aDevPal.empty()
- ? createBitmapDevice( aDevSize, false, nFormat )
+ ? ( pBuffer
+ ? createBitmapDevice( aDevSize, false, nFormat, pBuffer, PaletteMemorySharedVector() )
+ : createBitmapDevice( aDevSize, false, nFormat )
+ )
: createBitmapDevice( aDevSize, false, nFormat, PaletteMemorySharedVector( new std::vector< basebmp::Color >(aDevPal) ) );
// update device in existing graphics
diff --git a/vcl/inc/headless/svpvd.hxx b/vcl/inc/headless/svpvd.hxx
index 211cf36..d33c8dc 100644
--- a/vcl/inc/headless/svpvd.hxx
+++ b/vcl/inc/headless/svpvd.hxx
@@ -53,7 +53,8 @@ public:
virtual SalGraphics* GetGraphics();
virtual void ReleaseGraphics( SalGraphics* pGraphics );
- virtual sal_Bool SetSize( long nNewDX, long nNewDY );
+ virtual sal_Bool SetSize( long nNewDX, long nNewDY );
+ virtual sal_Bool SetSizeUsingBuffer( long nNewDX, long nNewDY, const basebmp::RawMemorySharedArray &pBuffer );
virtual void GetSize( long& rWidth, long& rHeight );
};
diff --git a/vcl/inc/salvd.hxx b/vcl/inc/salvd.hxx
index 77904ac..5cca88d 100644
--- a/vcl/inc/salvd.hxx
+++ b/vcl/inc/salvd.hxx
@@ -31,6 +31,7 @@
#include <tools/solar.h>
#include <vcl/dllapi.h>
+#include <basebmp/bitmapdevice.hxx>
class SalGraphics;
@@ -49,8 +50,11 @@ public: // public for Sal Implementation
virtual SalGraphics* GetGraphics() = 0;
virtual void ReleaseGraphics( SalGraphics* pGraphics ) = 0;
- // Set new size, without saving the old contents
- virtual sal_Bool SetSize( long nNewDX, long nNewDY ) = 0;
+ // Set new size, without saving the old contents
+ virtual sal_Bool SetSize( long nNewDX, long nNewDY ) = 0;
+
+ // Set new size using a buffer at the given address
+ virtual sal_Bool SetSizeUsingBuffer( long nNewDX, long nNewDY, const basebmp::RawMemorySharedArray &pBuffer ) = 0;
/// Get actual VDev size in pixel
virtual void GetSize( long& rWidth, long& rHeight ) = 0;
diff --git a/vcl/inc/vcl/virdev.hxx b/vcl/inc/vcl/virdev.hxx
index d22f706..32a3167 100644
--- a/vcl/inc/vcl/virdev.hxx
+++ b/vcl/inc/vcl/virdev.hxx
@@ -32,6 +32,7 @@
#include <tools/solar.h>
#include <vcl/dllapi.h>
#include <vcl/outdev.hxx>
+#include <basebmp/bitmapdevice.hxx>
// -----------------
// - VirtualDevice -
@@ -56,7 +57,8 @@ private:
sal_uInt8 meRefDevMode;
SAL_DLLPRIVATE void ImplInitVirDev( const OutputDevice* pOutDev, long nDX, long nDY, sal_uInt16 nBitCount, const SystemGraphicsData *pData = NULL );
- SAL_DLLPRIVATE sal_Bool ImplSetOutputSizePixel( const Size& rNewSize, sal_Bool bErase );
+ SAL_DLLPRIVATE sal_Bool InnerImplSetOutputSizePixel( const Size& rNewSize, sal_Bool bErase, const basebmp::RawMemorySharedArray &pBuffer );
+ SAL_DLLPRIVATE sal_Bool ImplSetOutputSizePixel( const Size& rNewSize, sal_Bool bErase, const basebmp::RawMemorySharedArray &pBuffer );
// Copy assignment is forbidden and not implemented.
VirtualDevice (const VirtualDevice &);
@@ -104,6 +106,7 @@ public:
virtual ~VirtualDevice();
sal_Bool SetOutputSizePixel( const Size& rNewSize, sal_Bool bErase = sal_True );
+ sal_Bool SetOutputSizePixelAndBuffer( const Size& rNewSize, const basebmp::RawMemorySharedArray &pBuffer );
sal_Bool SetOutputSize( const Size& rNewSize, sal_Bool bErase = sal_True )
{ return SetOutputSizePixel( LogicToPixel( rNewSize ), bErase ); }
diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx
index cda84e4..6c62819 100644
--- a/vcl/source/gdi/virdev.cxx
+++ b/vcl/source/gdi/virdev.cxx
@@ -210,10 +210,10 @@ VirtualDevice::~VirtualDevice()
// -----------------------------------------------------------------------
-sal_Bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, sal_Bool bErase )
+sal_Bool VirtualDevice::InnerImplSetOutputSizePixel( const Size& rNewSize, sal_Bool bErase, const basebmp::RawMemorySharedArray &pBuffer )
{
SAL_INFO( "vcl.gdi",
- "VirtualDevice::ImplSetOutputSizePixel( " << rNewSize.Width() << ", "
+ "VirtualDevice::InnerImplSetOutputSizePixel( " << rNewSize.Width() << ", "
<< rNewSize.Height() << ", " << bErase << " )" );
if ( !mpVirDev )
@@ -222,6 +222,8 @@ sal_Bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, sal_Bool b
{
if ( bErase )
Erase();
+ // Yeah, so trying to re-use a VirtualDevice but this time using a
+ // pre-allocated buffer won't work. Big deal.
return sal_True;
}
@@ -236,7 +238,10 @@ sal_Bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, sal_Bool b
if ( bErase )
{
- bRet = mpVirDev->SetSize( nNewWidth, nNewHeight );
+ if ( pBuffer )
+ bRet = mpVirDev->SetSizeUsingBuffer( nNewWidth, nNewHeight, pBuffer );
+ else
+ bRet = mpVirDev->SetSize( nNewWidth, nNewHeight );
if ( bRet )
{
@@ -323,9 +328,9 @@ void VirtualDevice::ImplFillOpaqueRectangle( const Rectangle& rRect )
// -----------------------------------------------------------------------
-sal_Bool VirtualDevice::SetOutputSizePixel( const Size& rNewSize, sal_Bool bErase )
+sal_Bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, sal_Bool bErase, const basebmp::RawMemorySharedArray &pBuffer )
{
- if( ImplSetOutputSizePixel(rNewSize, bErase) )
+ if( InnerImplSetOutputSizePixel(rNewSize, bErase, pBuffer) )
{
if( mnAlphaDepth != -1 )
{
@@ -339,7 +344,7 @@ sal_Bool VirtualDevice::SetOutputSizePixel( const Size& rNewSize, sal_Bool bEras
if( !mpAlphaVDev )
{
mpAlphaVDev = new VirtualDevice( *this, mnAlphaDepth );
- mpAlphaVDev->ImplSetOutputSizePixel(rNewSize, bErase);
+ mpAlphaVDev->InnerImplSetOutputSizePixel(rNewSize, bErase, basebmp::RawMemorySharedArray() );
}
// TODO: copy full outdev state to new one, here. Also needed in outdev2.cxx:DrawOutDev
@@ -358,6 +363,16 @@ sal_Bool VirtualDevice::SetOutputSizePixel( const Size& rNewSize, sal_Bool bEras
return sal_False;
}
+sal_Bool VirtualDevice::SetOutputSizePixel( const Size& rNewSize, sal_Bool bErase )
+{
+ return ImplSetOutputSizePixel( rNewSize, bErase, basebmp::RawMemorySharedArray() );
+}
+
+sal_Bool VirtualDevice::SetOutputSizePixelAndBuffer( const Size& rNewSize, const basebmp::RawMemorySharedArray &pBuffer )
+{
+ return ImplSetOutputSizePixel( rNewSize, sal_True, pBuffer);
+}
+
// -----------------------------------------------------------------------
void VirtualDevice::SetReferenceDevice( RefDevMode i_eRefDevMode )
commit 56595dab6424db6d69f81bfa551118140c5b66ac
Author: Tor Lillqvist <tlillqvist at suse.com>
Date: Mon Jun 11 18:12:04 2012 +0300
Do use separate width and height
Change-Id: I1bae38bf312ebc0186266be0dad3604e3f940aef
diff --git a/touch/idl/org/libreoffice/touch/XDocument.idl b/touch/idl/org/libreoffice/touch/XDocument.idl
index 254970e..6695de5 100644
--- a/touch/idl/org/libreoffice/touch/XDocument.idl
+++ b/touch/idl/org/libreoffice/touch/XDocument.idl
@@ -37,10 +37,11 @@ interface XDocument: com::sun::star::uno::XInterface
// on Android version and/or hardware? TBD. Will the same format be useful
// also for iOS? TBD.
- // buffer must have an exact number of bytes for a square with each side a
- // power-of-two number of pixels, At this API level buffer is represented
- // as the address of its bytes as a 64-bit integer, i.e. on Android it
- // must be a "direct" ByteBuffer for that to be meaningful.
+ // At this API level buffer is represented as the address of its bytes as
+ // a 64-bit integer, i.e. on Android it must be a "direct" ByteBuffer for
+ // that to be meaningful.
+
+ // width and height must be powers of two
// listener gets a "reasonable" number of callbacks during the rendering
// if it takes "significantly" long, and can inerrupt the rendering.
@@ -56,7 +57,8 @@ interface XDocument: com::sun::star::uno::XInterface
// Or should we just go OpenGL ES and render into a texture?
void render( [in] hyper buffer,
- [in] long bufferSize,
+ [in] long width,
+ [in] long height,
[in] XDocumentRenderCallback listener,
[in] long pageNo,
[in] long zoomLevel,
commit f44530f1a0b775d8da8be2164cf54b7a2a65c614
Author: Tor Lillqvist <tlillqvist at suse.com>
Date: Mon Jun 11 18:08:16 2012 +0300
udkapi and offapi are not "internal"
Change-Id: Id06783a999707ced3fe860fe23a6c48ccc40d9c4
diff --git a/touch/Library_libotouch.mk b/touch/Library_libotouch.mk
index 418c31a..1e06db4 100644
--- a/touch/Library_libotouch.mk
+++ b/touch/Library_libotouch.mk
@@ -13,9 +13,12 @@ $(eval $(call gb_Library_set_include,libotouch,\
$$(INCLUDE) \
))
-$(eval $(call gb_Library_use_internal_comprehensive_api,libotouch,\
+$(eval $(call gb_Library_use_api,libotouch,\
udkapi \
offapi \
+))
+
+$(eval $(call gb_Library_use_internal_comprehensive_api,libotouch,\
touch \
))
commit 4e4dcdae48dcd0437ff3f87a1ffc4fada53f2e3f
Author: Tor Lillqvist <tlillqvist at suse.com>
Date: Mon Jun 11 18:02:56 2012 +0300
Add Android-specific sal/ByteBufferWrapper.hxx header
Used for impedance matching between Java's direct ByteBuffer and the
boost::shared_array used by basebmp. Not sure yet how well this will
actually work. I'm afraid leaks might be possible in exception
throwing cases.
Change-Id: I74fc57aaf46b2dd9f227043bd9045d4815a5ed40
diff --git a/sal/Package_inc.mk b/sal/Package_inc.mk
index 1bce8ec..00dc323 100644
--- a/sal/Package_inc.mk
+++ b/sal/Package_inc.mk
@@ -106,6 +106,7 @@ $(eval $(call gb_Package_add_file,sal_inc,inc/rtl/ustring.h,rtl/ustring.h))
$(eval $(call gb_Package_add_file,sal_inc,inc/rtl/ustring.hxx,rtl/ustring.hxx))
$(eval $(call gb_Package_add_file,sal_inc,inc/rtl/uuid.h,rtl/uuid.h))
$(eval $(call gb_Package_add_file,sal_inc,inc/sal/alloca.h,sal/alloca.h))
+$(eval $(call gb_Package_add_file,sal_inc,inc/sal/ByteBufferWrapper.hxx,sal/ByteBufferWrapper.hxx))
$(eval $(call gb_Package_add_file,sal_inc,inc/sal/config.h,sal/config.h))
$(eval $(call gb_Package_add_file,sal_inc,inc/sal/log-areas.dox,sal/log-areas.dox))
$(eval $(call gb_Package_add_file,sal_inc,inc/sal/log.hxx,sal/log.hxx))
diff --git a/sal/inc/sal/ByteBufferWrapper.hxx b/sal/inc/sal/ByteBufferWrapper.hxx
new file mode 100644
index 0000000..954922d
--- /dev/null
+++ b/sal/inc/sal/ByteBufferWrapper.hxx
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright 2012 LibreOffice contributors.
+ *
+ * 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/.
+ */
+
+#ifndef _SAL_BYTEBUFFERWRAPPER_HXX
+#define _SAL_BYTEBUFFERWRAPPER_HXX
+
+#ifdef ANDROID
+
+#include <jni.h>
+
+#include <sal/types.h>
+
+namespace org { namespace libreoffice { namespace touch {
+
+class ByteBufferWrapper
+{
+private:
+ JNIEnv *env;
+ jobject object;
+
+public:
+ ByteBufferWrapper(JNIEnv *e, jobject o) :
+ env(e)
+ {
+ object = env->NewGlobalRef(o);
+ }
+
+ sal_uInt8* pointer()
+ {
+ return (sal_uInt8 *) env->GetDirectBufferAddress(object);
+ }
+
+ void operator()(sal_uInt8 * /* p */)
+ {
+ env->DeleteGlobalRef(object);
+ }
+};
+
+}; }; };
+
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/touch/Library_libotouch.mk b/touch/Library_libotouch.mk
index be355e3..418c31a 100644
--- a/touch/Library_libotouch.mk
+++ b/touch/Library_libotouch.mk
@@ -28,6 +28,14 @@ $(eval $(call gb_Library_add_exception_objects,libotouch,\
touch/source/generic/libotouch \
))
+ifeq ($(OS),ANDROID)
+
+$(eval $(call gb_Library_add_exception_objects,libotouch,\
+ touch/source/android/android \
+))
+
+endif
+
ifeq ($(OS),IOS)
$(eval $(call gb_Library_add_objcxx_objects,libotouch,\
diff --git a/touch/source/android/android.cxx b/touch/source/android/android.cxx
new file mode 100644
index 0000000..06768c8
--- /dev/null
+++ b/touch/source/android/android.cxx
@@ -0,0 +1,36 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright 2012 LibreOffice contributors.
+ *
+ * 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/.
+ */
+
+#include <jni.h>
+
+#include <sal/ByteBufferWrapper.hxx>
+
+using org::libreoffice::touch::ByteBufferWrapper;
+
+extern "C"
+__attribute__ ((visibility("default")))
+jlong
+Java_org_libreoffice_android_Bootstrap_new_1byte_1buffer_1wrapper(JNIEnv *env,
+ jobject /* clazz */,
+ jobject bytebuffer)
+{
+ return (jlong) (intptr_t) new ByteBufferWrapper(env, bytebuffer);
+}
+
+extern "C"
+__attribute__ ((visibility("default")))
+void
+Java_org_libreoffice_android_Bootstrap_delete_1byte_1buffer_1wrapper(JNIEnv * /* env */,
+ jobject /* clazz */,
+ jlong bbw)
+{
+ delete (ByteBufferWrapper*) (intptr_t) bbw;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list