diff options
author | Tor Lillqvist <tlillqvist@suse.com> | 2012-06-11 20:02:11 +0300 |
---|---|---|
committer | Tor Lillqvist <tlillqvist@suse.com> | 2012-06-12 13:50:49 +0300 |
commit | 96c4aeedb04bfb1438b69875951fc132142cb0d3 (patch) | |
tree | e78113f60d5c449ea6084c556e653d71b23e7fa6 | |
parent | 56595dab6424db6d69f81bfa551118140c5b66ac (diff) |
Implement XToolkit2::createScreenCompatibleDeviceUsingBuffer for Android
Change-Id: I8dd16850a35cd2de7260dcbe9a8aa7afae2294be
-rw-r--r-- | toolkit/inc/toolkit/awt/vclxtoolkit.hxx | 11 | ||||
-rw-r--r-- | toolkit/source/awt/vclxtoolkit.cxx | 22 | ||||
-rw-r--r-- | vcl/headless/svpvd.cxx | 10 | ||||
-rw-r--r-- | vcl/inc/headless/svpvd.hxx | 3 | ||||
-rw-r--r-- | vcl/inc/salvd.hxx | 8 | ||||
-rw-r--r-- | vcl/inc/vcl/virdev.hxx | 5 | ||||
-rw-r--r-- | vcl/source/gdi/virdev.cxx | 27 |
7 files changed, 70 insertions, 16 deletions
diff --git a/toolkit/inc/toolkit/awt/vclxtoolkit.hxx b/toolkit/inc/toolkit/awt/vclxtoolkit.hxx index e706d9cc4a81..dc085b810536 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 7f775fb3dac2..c799393daac7 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 fb752e6f0f57..a0d6aaf759e0 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 211cf36846f9..d33c8dc5853a 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 77904ac6ccfd..5cca88d2d6ee 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 d22f706b2d42..32a316721dcb 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 cda84e464bcb..6c6281962e91 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 ) |