Kaydet (Commit) 848ff96d authored tarafından Tor Lillqvist's avatar Tor Lillqvist

With tiled rendering for iOS there is no need for a "frame buffer"

The resulting dropping of the basebmp code reduces app size by 0.7 MB.

Change-Id: Id263873ed5c4bb2435d929a1319fedeedb6daa14
üst aba9d4ba
...@@ -32,6 +32,8 @@ using namespace basegfx; ...@@ -32,6 +32,8 @@ using namespace basegfx;
SvpSalFrame* SvpSalFrame::s_pFocusFrame = NULL; SvpSalFrame* SvpSalFrame::s_pFocusFrame = NULL;
#ifndef IOS
namespace { namespace {
/// Decouple SalFrame lifetime from damagetracker lifetime /// Decouple SalFrame lifetime from damagetracker lifetime
struct DamageTracker : public basebmp::IBitmapDeviceDamageTracker struct DamageTracker : public basebmp::IBitmapDeviceDamageTracker
...@@ -61,6 +63,8 @@ void SvpSalFrame::enableDamageTracker( bool bOn ) ...@@ -61,6 +63,8 @@ void SvpSalFrame::enableDamageTracker( bool bOn )
m_bDamageTracking = bOn; m_bDamageTracking = bOn;
} }
#endif
SvpSalFrame::SvpSalFrame( SvpSalInstance* pInstance, SvpSalFrame::SvpSalFrame( SvpSalInstance* pInstance,
SalFrame* pParent, SalFrame* pParent,
sal_uLong nSalFrameStyle, sal_uLong nSalFrameStyle,
...@@ -71,8 +75,10 @@ SvpSalFrame::SvpSalFrame( SvpSalInstance* pInstance, ...@@ -71,8 +75,10 @@ SvpSalFrame::SvpSalFrame( SvpSalInstance* pInstance,
m_pParent( static_cast<SvpSalFrame*>(pParent) ), m_pParent( static_cast<SvpSalFrame*>(pParent) ),
m_nStyle( nSalFrameStyle ), m_nStyle( nSalFrameStyle ),
m_bVisible( false ), m_bVisible( false ),
m_bDamageTracking( false ),
m_bTopDown( bTopDown ), m_bTopDown( bTopDown ),
#ifndef IOS
m_bDamageTracking( false ),
#endif
m_nScanlineFormat( nScanlineFormat ), m_nScanlineFormat( nScanlineFormat ),
m_nMinWidth( 0 ), m_nMinWidth( 0 ),
m_nMinHeight( 0 ), m_nMinHeight( 0 ),
...@@ -281,6 +287,7 @@ void SvpSalFrame::SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_u ...@@ -281,6 +287,7 @@ void SvpSalFrame::SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_u
if( m_nMinHeight > 0 && maGeometry.nHeight < (unsigned int)m_nMinHeight ) if( m_nMinHeight > 0 && maGeometry.nHeight < (unsigned int)m_nMinHeight )
maGeometry.nHeight = m_nMinHeight; maGeometry.nHeight = m_nMinHeight;
} }
#ifndef IOS
B2IVector aFrameSize( maGeometry.nWidth, maGeometry.nHeight ); B2IVector aFrameSize( maGeometry.nWidth, maGeometry.nHeight );
if( ! m_aFrame.get() || m_aFrame->getSize() != aFrameSize ) if( ! m_aFrame.get() || m_aFrame->getSize() != aFrameSize )
{ {
...@@ -296,13 +303,12 @@ void SvpSalFrame::SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_u ...@@ -296,13 +303,12 @@ void SvpSalFrame::SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_u
for( std::list< SvpSalGraphics* >::iterator it = m_aGraphics.begin(); for( std::list< SvpSalGraphics* >::iterator it = m_aGraphics.begin();
it != m_aGraphics.end(); ++it ) it != m_aGraphics.end(); ++it )
{ {
#ifndef IOS
(*it)->setDevice( m_aFrame ); (*it)->setDevice( m_aFrame );
#endif
} }
} }
if( m_bVisible ) if( m_bVisible )
m_pInstance->PostEvent( this, NULL, SALEVENT_RESIZE ); m_pInstance->PostEvent( this, NULL, SALEVENT_RESIZE );
#endif
} }
void SvpSalFrame::GetClientSize( long& rWidth, long& rHeight ) void SvpSalFrame::GetClientSize( long& rWidth, long& rHeight )
......
...@@ -43,8 +43,11 @@ class SvpSalFrame : public SalFrame ...@@ -43,8 +43,11 @@ class SvpSalFrame : public SalFrame
std::list< SvpSalFrame* > m_aChildren; // List of child frames std::list< SvpSalFrame* > m_aChildren; // List of child frames
sal_uLong m_nStyle; sal_uLong m_nStyle;
bool m_bVisible; bool m_bVisible;
bool m_bDamageTracking;
bool m_bTopDown; bool m_bTopDown;
#ifndef IOS
basebmp::BitmapDeviceSharedPtr m_aFrame;
bool m_bDamageTracking;
#endif
basebmp::Format m_nScanlineFormat; basebmp::Format m_nScanlineFormat;
long m_nMinWidth; long m_nMinWidth;
long m_nMinHeight; long m_nMinHeight;
...@@ -53,7 +56,6 @@ class SvpSalFrame : public SalFrame ...@@ -53,7 +56,6 @@ class SvpSalFrame : public SalFrame
SystemEnvData m_aSystemChildData; SystemEnvData m_aSystemChildData;
basebmp::BitmapDeviceSharedPtr m_aFrame;
std::list< SvpSalGraphics* > m_aGraphics; std::list< SvpSalGraphics* > m_aGraphics;
static SvpSalFrame* s_pFocusFrame; static SvpSalFrame* s_pFocusFrame;
...@@ -71,7 +73,7 @@ public: ...@@ -71,7 +73,7 @@ public:
void PostPaint(bool bImmediate) const; void PostPaint(bool bImmediate) const;
void AllocateFrame(); void AllocateFrame();
#if defined IOS || defined ANDROID #if defined ANDROID
const basebmp::BitmapDeviceSharedPtr& getDevice() const { return m_aFrame; } const basebmp::BitmapDeviceSharedPtr& getDevice() const { return m_aFrame; }
#endif #endif
...@@ -125,9 +127,11 @@ public: ...@@ -125,9 +127,11 @@ public:
virtual void UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) SAL_OVERRIDE; virtual void UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) SAL_OVERRIDE;
virtual void EndSetClipRegion() SAL_OVERRIDE; virtual void EndSetClipRegion() SAL_OVERRIDE;
#ifndef IOS
// If enabled we can get damage notifications for regions immediately rendered to ... // If enabled we can get damage notifications for regions immediately rendered to ...
virtual void enableDamageTracker( bool bOn = true ); virtual void enableDamageTracker( bool bOn = true );
virtual void damaged( const basegfx::B2IBox& /* rDamageRect */) {} virtual void damaged( const basegfx::B2IBox& /* rDamageRect */) {}
#endif
/*TODO: functional implementation */ /*TODO: functional implementation */
virtual void SetScreenNumber( unsigned int nScreen ) SAL_OVERRIDE { (void)nScreen; } virtual void SetScreenNumber( unsigned int nScreen ) SAL_OVERRIDE { (void)nScreen; }
......
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
#ifndef INCLUDED_VCL_INC_IOS_IOSINST_HXX #ifndef INCLUDED_VCL_INC_IOS_IOSINST_HXX
#define INCLUDED_VCL_INC_IOS_IOSINST_HXX #define INCLUDED_VCL_INC_IOS_IOSINST_HXX
#include <pthread.h>
#include <premac.h> #include <premac.h>
#include <CoreGraphics/CoreGraphics.h> #include <CoreGraphics/CoreGraphics.h>
#include <postmac.h> #include <postmac.h>
...@@ -47,17 +45,7 @@ public: ...@@ -47,17 +45,7 @@ public:
SalFrame *getFocusFrame() const; SalFrame *getFocusFrame() const;
void damaged( IosSalFrame *frame,
const basegfx::B2IBox& rDamageRect);
// Functions scheduled to be run as "user events" in the LO thread // Functions scheduled to be run as "user events" in the LO thread
typedef struct {
bool done;
CGContextRef context;
CGRect rect;
} RenderWindowsArg;
DECL_LINK( RenderWindows, RenderWindowsArg* );
DECL_LINK( DisplayConfigurationChanged, void* ); DECL_LINK( DisplayConfigurationChanged, void* );
typedef struct { typedef struct {
...@@ -71,9 +59,6 @@ public: ...@@ -71,9 +59,6 @@ public:
int x, y; int x, y;
} SelectionEndMoveArg; } SelectionEndMoveArg;
DECL_LINK( SelectionEndMove, SelectionEndMoveArg* ); DECL_LINK( SelectionEndMove, SelectionEndMoveArg* );
pthread_mutex_t m_aRenderMutex;
pthread_cond_t m_aRenderCond;
}; };
#endif // INCLUDED_VCL_INC_IOS_IOSINST_HXX #endif // INCLUDED_VCL_INC_IOS_IOSINST_HXX
......
...@@ -43,12 +43,6 @@ public: ...@@ -43,12 +43,6 @@ public:
virtual bool ErrorTrapPop( bool ) { return false; } virtual bool ErrorTrapPop( bool ) { return false; }
}; };
void IosSalInstance::damaged( IosSalFrame */* frame */,
const basegfx::B2IBox& rDamageRect )
{
touch_ui_damaged( rDamageRect.getMinX(), rDamageRect.getMinY(), rDamageRect.getWidth(), rDamageRect.getHeight() );
}
void IosSalInstance::GetWorkArea( Rectangle& rRect ) void IosSalInstance::GetWorkArea( Rectangle& rRect )
{ {
rRect = Rectangle( Point( 0, 0 ), rRect = Rectangle( Point( 0, 0 ),
...@@ -90,32 +84,10 @@ IosSalInstance *IosSalInstance::getInstance() ...@@ -90,32 +84,10 @@ IosSalInstance *IosSalInstance::getInstance()
IosSalInstance::IosSalInstance( SalYieldMutex *pMutex ) IosSalInstance::IosSalInstance( SalYieldMutex *pMutex )
: SvpSalInstance( pMutex ) : SvpSalInstance( pMutex )
{ {
int rc;
rc = pthread_cond_init( &m_aRenderCond, NULL );
SAL_WARN_IF( rc != 0, "vcl.ios", "pthread_cond_init failed: " << strerror( rc ) );
#if OSL_DEBUG_LEVEL > 0
pthread_mutexattr_t mutexattr;
rc = pthread_mutexattr_init( &mutexattr );
SAL_WARN_IF( rc != 0, "vcl.ios", "pthread_mutexattr_init failed: " << strerror( rc ) );
rc = pthread_mutexattr_settype( &mutexattr, PTHREAD_MUTEX_ERRORCHECK );
SAL_WARN_IF( rc != 0, "vcl.ios", "pthread_mutexattr_settype failed: " << strerror( rc ) );
rc = pthread_mutex_init( &m_aRenderMutex, &mutexattr );
SAL_WARN_IF( rc != 0, "vcl.ios", "pthread_mutex_init failed: " << strerror( rc ) );
#else
rc = pthread_mutex_init( &m_aRenderMutex, NULL );
SAL_WARN_IF( rc != 0, "vcl.ios", "pthread_mutex_init failed: " << strerror( rc ) );
#endif
} }
IosSalInstance::~IosSalInstance() IosSalInstance::~IosSalInstance()
{ {
pthread_cond_destroy( &m_aRenderCond );
pthread_mutex_destroy( &m_aRenderMutex );
} }
#if 0 #if 0
...@@ -149,9 +121,6 @@ SalSystem *IosSalInstance::CreateSalSystem() ...@@ -149,9 +121,6 @@ SalSystem *IosSalInstance::CreateSalSystem()
class IosSalFrame : public SvpSalFrame class IosSalFrame : public SvpSalFrame
{ {
private:
basegfx::B2IBox m_DamagedRect;
public: public:
IosSalFrame( IosSalInstance *pInstance, IosSalFrame( IosSalInstance *pInstance,
SalFrame *pParent, SalFrame *pParent,
...@@ -161,31 +130,22 @@ public: ...@@ -161,31 +130,22 @@ public:
true, basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA, true, basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA,
pSysParent ) pSysParent )
{ {
enableDamageTracker();
if (pParent == NULL && viewWidth > 1 && viewHeight > 1) if (pParent == NULL && viewWidth > 1 && viewHeight > 1)
SetPosSize(0, 0, viewWidth, viewHeight, SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT); SetPosSize(0, 0, viewWidth, viewHeight, SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT);
} }
virtual void GetWorkArea( Rectangle& rRect ) virtual void GetWorkArea( Rectangle& rRect ) SAL_OVERRIDE
{ {
IosSalInstance::getInstance()->GetWorkArea( rRect ); IosSalInstance::getInstance()->GetWorkArea( rRect );
} }
void ShowFullScreen( bool, sal_Int32 ) virtual void ShowFullScreen( bool, sal_Int32 ) SAL_OVERRIDE
{ {
SetPosSize( 0, 0, viewWidth, viewHeight, SetPosSize( 0, 0, viewWidth, viewHeight,
SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT ); SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT );
} }
virtual void damaged( const basegfx::B2IBox& rDamageRect ) virtual void UpdateSettings( AllSettings &rSettings ) SAL_OVERRIDE
{
if (rDamageRect.isEmpty())
return;
m_DamagedRect.expand(rDamageRect);
}
virtual void UpdateSettings( AllSettings &rSettings )
{ {
// Clobber the UI fonts // Clobber the UI fonts
Font aFont( OUString( "Helvetica" ), Size( 0, 14 ) ); Font aFont( OUString( "Helvetica" ), Size( 0, 14 ) );
...@@ -205,16 +165,6 @@ public: ...@@ -205,16 +165,6 @@ public:
rSettings.SetStyleSettings( aStyleSet ); rSettings.SetStyleSettings( aStyleSet );
} }
virtual void Flush()
{
IosSalInstance::getInstance()->damaged( this, m_DamagedRect );
}
void resetDamaged()
{
m_DamagedRect.reset();
}
}; };
SalFrame *IosSalInstance::CreateChildFrame( SystemParentData* pParent, sal_uLong nStyle ) SalFrame *IosSalInstance::CreateChildFrame( SystemParentData* pParent, sal_uLong nStyle )
...@@ -308,7 +258,6 @@ IMPL_LINK( IosSalInstance, DisplayConfigurationChanged, void*, ) ...@@ -308,7 +258,6 @@ IMPL_LINK( IosSalInstance, DisplayConfigurationChanged, void*, )
(*it)->Show( true, false ); (*it)->Show( true, false );
} }
touch_ui_damaged( 0, 0, viewWidth, viewHeight );
return 0; return 0;
} }
...@@ -332,69 +281,6 @@ void touch_lo_set_view_size(int width, int height) ...@@ -332,69 +281,6 @@ void touch_lo_set_view_size(int width, int height)
} }
} }
IMPL_LINK( IosSalInstance, RenderWindows, RenderWindowsArg*, arg )
{
int rc;
rc = pthread_mutex_lock( &m_aRenderMutex );
SAL_WARN_IF( rc != 0, "vcl.ios", "pthread_mutex_lock failed: " << strerror( rc ) );
CGRect invalidRect = arg->rect;
for( std::list< SalFrame* >::const_reverse_iterator it = getFrames().rbegin();
it != getFrames().rend();
++it ) {
IosSalFrame *pFrame = static_cast<IosSalFrame *>(*it);
SalFrameGeometry aGeom = pFrame->GetGeometry();
CGRect bbox = CGRectMake( 0, 0, aGeom.nWidth, aGeom.nHeight );
if ( pFrame->IsVisible() &&
CGRectIntersectsRect( invalidRect, bbox ) ) {
const basebmp::BitmapDeviceSharedPtr aDevice = pFrame->getDevice();
touch_lo_copy_buffer(aDevice->getBuffer().get(),
aDevice->getSize().getX(),
aDevice->getSize().getY(),
aDevice->getScanlineStride(),
arg->context,
aGeom.nWidth,
aGeom.nHeight);
/*CGDataProviderRef provider =
CGDataProviderCreateWithData( NULL,
aDevice->getBuffer().get(),
aDevice->getSize().getY() * aDevice->getScanlineStride(),
NULL );
CGImage *image =
CGImageCreate( aDevice->getSize().getX(), aDevice->getSize().getY(),
8, 32, aDevice->getScanlineStride(),
CGColorSpaceCreateDeviceRGB(),
kCGImageAlphaNoneSkipLast,
provider,
NULL,
false,
kCGRenderingIntentDefault );
CGContextDrawImage( arg->context, bbox, image );
*/
// if current frame covers the whole invalidRect then break
if (CGRectEqualToRect(CGRectIntersection(invalidRect, bbox), invalidRect))
{
break;
}
pFrame->resetDamaged();
}
}
arg->done = true;
rc = pthread_cond_signal( &m_aRenderCond );
SAL_WARN_IF( rc != 0, "vcl.ios", "pthread_cond_signal failed:" << strerror( rc ) );
rc = pthread_mutex_unlock( &m_aRenderMutex );
SAL_WARN_IF( rc != 0, "vcl.ios", "pthread_mutex_unlock failed: " << strerror( rc ) );
return 0;
}
extern "C" extern "C"
void void
touch_lo_copy_buffer(const void * source, size_t sourceWidth, size_t sourceHeight, size_t sourceBytesPerRow, void * target, size_t targetWidth, size_t targetHeight){ touch_lo_copy_buffer(const void * source, size_t sourceWidth, size_t sourceHeight, size_t sourceBytesPerRow, void * target, size_t targetWidth, size_t targetHeight){
...@@ -421,35 +307,6 @@ touch_lo_copy_buffer(const void * source, size_t sourceWidth, size_t sourceHeigh ...@@ -421,35 +307,6 @@ touch_lo_copy_buffer(const void * source, size_t sourceWidth, size_t sourceHeigh
CGDataProviderRelease(provider); CGDataProviderRelease(provider);
} }
extern "C"
void touch_lo_render_windows(void *context, int minX, int minY, int width, int height)
{
CGContextRef cgContext = (CGContextRef) context;
int rc;
IosSalInstance *pInstance = IosSalInstance::getInstance();
if ( pInstance == NULL )
return;
rc = pthread_mutex_lock( &pInstance->m_aRenderMutex );
if (rc != 0) {
SAL_WARN( "vcl.ios", "pthread_mutex_lock failed: " << strerror( rc ) );
return;
}
CGRect rect = CGRectMake(minX, minY, width, height);
IosSalInstance::RenderWindowsArg arg = { false, cgContext, rect };
Application::PostUserEvent( LINK( pInstance, IosSalInstance, RenderWindows), &arg );
while (!arg.done) {
rc = pthread_cond_wait( &pInstance->m_aRenderCond, &pInstance->m_aRenderMutex );
SAL_WARN_IF( rc != 0, "vcl.ios", "pthread_cond_wait failed: " << strerror( rc ) );
}
rc = pthread_mutex_unlock( &pInstance->m_aRenderMutex );
SAL_WARN_IF( rc != 0, "vcl.ios", "pthread_mutex_unlock failed: " << strerror( rc ) );
}
extern "C" extern "C"
void touch_lo_tap(int x, int y) void touch_lo_tap(int x, int y)
{ {
......
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