Kaydet (Commit) 96c4aeed authored tarafından Tor Lillqvist's avatar Tor Lillqvist

Implement XToolkit2::createScreenCompatibleDeviceUsingBuffer for Android

Change-Id: I8dd16850a35cd2de7260dcbe9a8aa7afae2294be
üst 56595dab
......@@ -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
......
......@@ -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,
......@@ -561,6 +566,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() );
......@@ -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;
......
......@@ -56,6 +56,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 )
......@@ -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
......
......@@ -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 );
};
......
......@@ -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;
......
......@@ -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 ); }
......
......@@ -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 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment