summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMathias Bauer <mba@openoffice.org>2009-12-05 19:29:07 +0100
committerMathias Bauer <mba@openoffice.org>2009-12-05 19:29:07 +0100
commit342e37f151084dfb8f840c0cfaa4674dcf880267 (patch)
tree2dea2ded6ba96ae62da1d9dd7faeb9a80ca7065a /vcl
parent549fb21f357eaa2cda1a53d4fa84cf87896aed6d (diff)
parent2f883652c1af80075dc68b5cb439a13cd1dc4129 (diff)
merge to m67
Diffstat (limited to 'vcl')
-rwxr-xr-xvcl/aqua/source/gdi/salatslayout.cxx30
-rw-r--r--vcl/aqua/source/gdi/salgdi.cxx73
-rwxr-xr-xvcl/aqua/source/window/salframeview.mm21
-rw-r--r--vcl/inc/vcl/svapp.hxx3
-rw-r--r--vcl/inc/vcl/svdata.hxx31
-rw-r--r--vcl/inc/vcl/vclevent.hxx33
-rw-r--r--vcl/prj/d.lst1
-rw-r--r--vcl/source/app/svapp.cxx162
-rw-r--r--vcl/source/app/vclevent.cxx53
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx1
-rw-r--r--vcl/source/gdi/regband.cxx2
-rw-r--r--vcl/unx/headless/svppspgraphics.cxx22
-rw-r--r--vcl/unx/source/gdi/pspgraphics.cxx22
-rw-r--r--vcl/unx/source/gdi/salgdi.cxx422
-rw-r--r--vcl/unx/source/gdi/xrender_peer.cxx4
-rw-r--r--vcl/unx/source/gdi/xrender_peer.hxx14
-rw-r--r--vcl/unx/source/printergfx/common_gfx.cxx66
-rw-r--r--vcl/win/source/gdi/salgdi3.cxx9
18 files changed, 734 insertions, 235 deletions
diff --git a/vcl/aqua/source/gdi/salatslayout.cxx b/vcl/aqua/source/gdi/salatslayout.cxx
index 3021e85fed5c..1387a46c6345 100755
--- a/vcl/aqua/source/gdi/salatslayout.cxx
+++ b/vcl/aqua/source/gdi/salatslayout.cxx
@@ -70,12 +70,13 @@ private:
// to prevent ATS overflowing the Fixed16.16 values
// ATS font requests get size limited by downscaling huge fonts
// in these cases the font scale becomes something bigger than 1.0
- float mfFontScale;
+ float mfFontScale;
private:
bool InitGIA( ImplLayoutArgs* pArgs = NULL ) const;
bool GetIdealX() const;
bool GetDeltaY() const;
+ void InvalidateMeasurements();
int Fixed2Vcl( Fixed ) const; // convert ATSU-Fixed units to VCL units
int AtsuPix2Vcl( int ) const; // convert ATSU-Pixel units to VCL units
@@ -310,7 +311,7 @@ void ATSLayout::AdjustLayout( ImplLayoutArgs& rArgs )
mnTrailingSpaceWidth = rArgs.mpDXArray[ mnCharCount-1 ];
if( i > 0 )
mnTrailingSpaceWidth -= rArgs.mpDXArray[ i-1 ];
- InitGIA(); // ensure valid mpCharWidths[]
+ InitGIA(); // ensure valid mpCharWidths[], TODO: use GetIdealX() instead?
mnTrailingSpaceWidth -= Fixed2Vcl( mpCharWidths[i] );
// ignore trailing space for calculating the available width
nOrigWidth -= mnTrailingSpaceWidth;
@@ -324,11 +325,15 @@ void ATSLayout::AdjustLayout( ImplLayoutArgs& rArgs )
if( !nPixelWidth )
return;
- // HACK: justification requests which change the width by just one pixel are probably
+ // HACK: justification requests which change the width by just one pixel were probably
// #i86038# introduced by lossy conversions between integer based coordinate system
+ // => ignoring such requests has many more benefits than eventual drawbacks
if( (nOrigWidth >= nPixelWidth-1) && (nOrigWidth <= nPixelWidth+1) )
return;
+ // changing the layout will make all previous measurements invalid
+ InvalidateMeasurements();
+
ATSUAttributeTag nTags[3];
ATSUAttributeValuePtr nVals[3];
ByteCount nBytes[3];
@@ -352,7 +357,7 @@ void ATSLayout::AdjustLayout( ImplLayoutArgs& rArgs )
if( eStatus != noErr )
return;
- // check result of the justied layout
+ // update the measurements of the justified layout to match the justification request
if( rArgs.mpDXArray )
InitGIA( &rArgs );
}
@@ -1069,6 +1074,23 @@ bool ATSLayout::GetDeltaY() const
return true;
}
+// -----------------------------------------------------------------------
+
+#define DELETEAZ( X ) { delete[] X; X = NULL; }
+
+void ATSLayout::InvalidateMeasurements()
+{
+ mnGlyphCount = -1;
+ DELETEAZ( mpGlyphIds );
+ DELETEAZ( mpCharWidths );
+ DELETEAZ( mpChars2Glyphs );
+ DELETEAZ( mpGlyphs2Chars );
+ DELETEAZ( mpGlyphRTLFlags );
+ DELETEAZ( mpGlyphAdvances );
+ DELETEAZ( mpGlyphOrigAdvs );
+ DELETEAZ( mpDeltaY );
+}
+
// =======================================================================
#if 0
diff --git a/vcl/aqua/source/gdi/salgdi.cxx b/vcl/aqua/source/gdi/salgdi.cxx
index f389abd19a82..1c9bdda3fbdb 100644
--- a/vcl/aqua/source/gdi/salgdi.cxx
+++ b/vcl/aqua/source/gdi/salgdi.cxx
@@ -404,6 +404,16 @@ void AquaSalGraphics::initResolution( NSWindow* pWin )
DBG_ERROR( "no screen found" );
}
+ // #i107076# maintaining size-WYSIWYG-ness causes many problems for
+ // low-DPI, high-DPI or for mis-reporting devices
+ // => it is better to limit the calculation result then
+ static const int nMinDPI = 72;
+ if( (mnRealDPIX < nMinDPI) || (mnRealDPIY < nMinDPI) )
+ mnRealDPIX = mnRealDPIY = nMinDPI;
+ static const int nMaxDPI = 200;
+ if( (mnRealDPIX > nMaxDPI) || (mnRealDPIY > nMaxDPI) )
+ mnRealDPIX = mnRealDPIY = nMaxDPI;
+
// for OSX any anisotropy reported for the display resolution is best ignored (e.g. TripleHead2Go)
mnRealDPIX = mnRealDPIY = (mnRealDPIX + mnRealDPIY + 1) / 2;
@@ -931,27 +941,29 @@ bool AquaSalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPol
AddPolygonToPath( xPath, rPolygon, true, !getAntiAliasB2DDraw(), IsPenVisible() );
}
- // use the path to prepare the graphics context
- CGContextSaveGState( mrContext );
- CGContextBeginPath( mrContext );
- CGContextAddPath( mrContext, xPath );
const CGRect aRefreshRect = CGPathGetBoundingBox( xPath );
- CGPathRelease( xPath );
-
#ifndef NO_I97317_WORKAROUND
// #i97317# workaround for Quartz having problems with drawing small polygons
- if( (aRefreshRect.size.width <= 0.125) && (aRefreshRect.size.height <= 0.125) )
- return true;
+ if( ! ((aRefreshRect.size.width <= 0.125) && (aRefreshRect.size.height <= 0.125)) )
#endif
+ {
+ // use the path to prepare the graphics context
+ CGContextSaveGState( mrContext );
+ CGContextBeginPath( mrContext );
+ CGContextAddPath( mrContext, xPath );
+
+ // draw path with antialiased polygon
+ CGContextSetShouldAntialias( mrContext, true );
+ CGContextSetAlpha( mrContext, 1.0 - fTransparency );
+ CGContextDrawPath( mrContext, kCGPathEOFillStroke );
+ CGContextRestoreGState( mrContext );
+
+ // mark modified rectangle as updated
+ RefreshRect( aRefreshRect );
+ }
- // draw path with antialiased polygon
- CGContextSetShouldAntialias( mrContext, true );
- CGContextSetAlpha( mrContext, 1.0 - fTransparency );
- CGContextDrawPath( mrContext, kCGPathEOFillStroke );
- CGContextRestoreGState( mrContext );
+ CGPathRelease( xPath );
- // mark modified rectangle as updated
- RefreshRect( aRefreshRect );
return true;
}
@@ -991,27 +1003,28 @@ bool AquaSalGraphics::drawPolyLine( const ::basegfx::B2DPolygon& rPolyLine,
CGMutablePathRef xPath = CGPathCreateMutable();
AddPolygonToPath( xPath, rPolyLine, rPolyLine.isClosed(), !getAntiAliasB2DDraw(), true );
- // use the path to prepare the graphics context
- CGContextSaveGState( mrContext );
- CGContextAddPath( mrContext, xPath );
const CGRect aRefreshRect = CGPathGetBoundingBox( xPath );
- CGPathRelease( xPath );
-
#ifndef NO_I97317_WORKAROUND
// #i97317# workaround for Quartz having problems with drawing small polygons
- if( (aRefreshRect.size.width <= 0.125) && (aRefreshRect.size.height <= 0.125) )
- return true;
+ if( ! ((aRefreshRect.size.width <= 0.125) && (aRefreshRect.size.height <= 0.125)) )
#endif
+ {
+ // use the path to prepare the graphics context
+ CGContextSaveGState( mrContext );
+ CGContextAddPath( mrContext, xPath );
+ // draw path with antialiased line
+ CGContextSetShouldAntialias( mrContext, true );
+ CGContextSetLineJoin( mrContext, aCGLineJoin );
+ CGContextSetLineWidth( mrContext, rLineWidths.getX() );
+ CGContextDrawPath( mrContext, kCGPathStroke );
+ CGContextRestoreGState( mrContext );
+
+ // mark modified rectangle as updated
+ RefreshRect( aRefreshRect );
+ }
- // draw path with antialiased line
- CGContextSetShouldAntialias( mrContext, true );
- CGContextSetLineJoin( mrContext, aCGLineJoin );
- CGContextSetLineWidth( mrContext, rLineWidths.getX() );
- CGContextDrawPath( mrContext, kCGPathStroke );
- CGContextRestoreGState( mrContext );
+ CGPathRelease( xPath );
- // mark modified rectangle as updated
- RefreshRect( aRefreshRect );
return true;
}
diff --git a/vcl/aqua/source/window/salframeview.mm b/vcl/aqua/source/window/salframeview.mm
index 0305b4cadb43..aabc287dc885 100755
--- a/vcl/aqua/source/window/salframeview.mm
+++ b/vcl/aqua/source/window/salframeview.mm
@@ -1332,11 +1332,32 @@ private:
{
mbNeedSpecialKeyHandle = true;
}
+
+ // FIXME:
+ // #i106901#
+ // if we come here outside of mbInKeyInput, this is likely to be because
+ // of the keyboard viewer. For unknown reasons having no marked range
+ // in this case causes a crash. So we say we have a marked range anyway
+ // This is a hack, since it is not understood what a) causes that crash
+ // and b) why we should have a marked range at this point.
+ if( ! mbInKeyInput )
+ bHasMarkedText = YES;
+
return bHasMarkedText;
}
- (NSRange)markedRange
{
+ // FIXME:
+ // #i106901#
+ // if we come here outside of mbInKeyInput, this is likely to be because
+ // of the keyboard viewer. For unknown reasons having no marked range
+ // in this case causes a crash. So we say we have a marked range anyway
+ // This is a hack, since it is not understood what a) causes that crash
+ // and b) why we should have a marked range at this point.
+ if( ! mbInKeyInput )
+ return NSMakeRange( 0, 0 );
+
return [self hasMarkedText] ? mMarkedRange : NSMakeRange( NSNotFound, 0 );
}
diff --git a/vcl/inc/vcl/svapp.hxx b/vcl/inc/vcl/svapp.hxx
index 1e0c5218d1c5..3e9a1cc55019 100644
--- a/vcl/inc/vcl/svapp.hxx
+++ b/vcl/inc/vcl/svapp.hxx
@@ -287,6 +287,9 @@ public:
static vos::OThread::TThreadIdentifier GetMainThreadIdentifier();
static ULONG ReleaseSolarMutex();
static void AcquireSolarMutex( ULONG nCount );
+ static void EnableNoYieldMode( bool i_bNoYield );
+ static void AddPostYieldListener( const Link& i_rListener );
+ static void RemovePostYieldListener( const Link& i_rListener );
static BOOL IsInMain();
static BOOL IsInExecute();
diff --git a/vcl/inc/vcl/svdata.hxx b/vcl/inc/vcl/svdata.hxx
index 12c595350472..d912c172baa5 100644
--- a/vcl/inc/vcl/svdata.hxx
+++ b/vcl/inc/vcl/svdata.hxx
@@ -111,6 +111,7 @@ class ImplWheelWindow;
class SalTimer;
class SalI18NImeStatus;
class DockingManager;
+class VclEventListeners2;
namespace vos { class OMutex; }
namespace vos { class OCondition; }
@@ -137,7 +138,6 @@ struct ImplSVAppData
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
String* mpMSFTempFileName;
- AllSettings* mpSettings; // Application settings
LocaleConfigurationListener* mpCfgListener;
VclEventListeners* mpEventListeners; // listeners for vcl events (eg, extended toolkit)
VclEventListeners* mpKeyListeners; // listeners for key events only (eg, extended toolkit)
@@ -153,19 +153,22 @@ struct ImplSVAppData
ImplWheelWindow* mpWheelWindow; // WheelWindow
ImplHotKey* mpFirstHotKey; // HotKey-Verwaltung
ImplEventHook* mpFirstEventHook; // Event-Hooks
- ULONG mnLastInputTime; // GetLastInputTime()
- USHORT mnDispatchLevel; // DispatchLevel
- USHORT mnModalMode; // ModalMode Count
- USHORT mnModalDialog; // ModalDialog Count
- USHORT mnAccessCount; // AccessHdl Count
- USHORT mnSysWinMode; // Modus, wann SystemWindows erzeugt werden sollen
- USHORT mnLayout; // --- RTL-Flags --- currently not used, only for testing
- short mnDialogScaleX; // Scale X-Positions and sizes in Dialogs
- BOOL mbInAppMain; // is Application::Main() on stack
- BOOL mbInAppExecute; // is Application::Execute() on stack
- BOOL mbAppQuit; // is Application::Quit() called
- BOOL mbSettingsInit; // TRUE: Settings are init
- BOOL mbDialogCancel; // TRUE: Alle Dialog::Execute()-Aufrufe werden mit return FALSE sofort beendet
+ VclEventListeners2* mpPostYieldListeners; // post yield listeners
+ ULONG mnLastInputTime; // GetLastInputTime()
+ USHORT mnDispatchLevel; // DispatchLevel
+ USHORT mnModalMode; // ModalMode Count
+ USHORT mnModalDialog; // ModalDialog Count
+ USHORT mnAccessCount; // AccessHdl Count
+ USHORT mnSysWinMode; // Modus, wann SystemWindows erzeugt werden sollen
+ USHORT mnLayout; // --- RTL-Flags --- currently not used, only for testing
+ short mnDialogScaleX; // Scale X-Positions and sizes in Dialogs
+ BOOL mbInAppMain; // is Application::Main() on stack
+ BOOL mbInAppExecute; // is Application::Execute() on stack
+ BOOL mbAppQuit; // is Application::Quit() called
+ BOOL mbSettingsInit; // TRUE: Settings are initialized
+ BOOL mbDialogCancel; // TRUE: Alle Dialog::Execute()-Aufrufe werden mit return FALSE sofort beendet
+ BOOL mbNoYield; // Application::Yield will not wait for events if the queue is empty
+ // essentially that makes it the same as Application::Reschedule
/** Controls whether showing any IME status window is toggled on or off.
diff --git a/vcl/inc/vcl/vclevent.hxx b/vcl/inc/vcl/vclevent.hxx
index ff0639d70e82..74971f62c5a6 100644
--- a/vcl/inc/vcl/vclevent.hxx
+++ b/vcl/inc/vcl/vclevent.hxx
@@ -31,11 +31,13 @@
#ifndef _VCL_VCLEVENT_HXX
#define _VCL_VCLEVENT_HXX
-#include <tools/link.hxx>
-#include <tools/rtti.hxx>
-#include <vcl/dllapi.h>
+#include "tools/link.hxx"
+#include "tools/rtti.hxx"
+#include "vcl/dllapi.h"
+#include "vcl/impdel.hxx"
#include <list>
+#include <vector>
class Window;
class Menu;
@@ -251,4 +253,29 @@ public:
BOOL Process( VclSimpleEvent* pEvent ) const;
};
+class VCL_DLLPUBLIC VclEventListeners2 : public vcl::DeletionNotifier
+{
+ std::list< Link > m_aListeners;
+
+ struct ListenerIt
+ {
+ std::list< Link >::iterator m_aIt;
+ bool m_bWasInvalidated;
+
+ ListenerIt() : m_bWasInvalidated( false ) {}
+ };
+
+ std::vector< ListenerIt > m_aIterators;
+
+
+public:
+ VclEventListeners2();
+ ~VclEventListeners2();
+
+ void addListener( const Link& );
+ void removeListener( const Link& );
+
+ void callListeners( VclSimpleEvent* );
+};
+
#endif // _VCL_VCLEVENT_HXX
diff --git a/vcl/prj/d.lst b/vcl/prj/d.lst
index 983628184177..54af0d2e289d 100644
--- a/vcl/prj/d.lst
+++ b/vcl/prj/d.lst
@@ -58,6 +58,7 @@ mkdir: %_DEST%\inc%_EXT%\vcl
..\inc\vcl\imagerepository.hxx %_DEST%\inc%_EXT%\vcl\imagerepository.hxx
..\inc\vcl\imgcons.hxx %_DEST%\inc%_EXT%\vcl\imgcons.hxx
..\inc\vcl\imgctrl.hxx %_DEST%\inc%_EXT%\vcl\imgctrl.hxx
+..\inc\vcl\impdel.hxx %_DEST%\inc%_EXT%\vcl\impdel.hxx
..\inc\vcl\inputctx.hxx %_DEST%\inc%_EXT%\vcl\inputctx.hxx
..\inc\vcl\javachild.hxx %_DEST%\inc%_EXT%\vcl\javachild.hxx
..\inc\vcl\jobset.hxx %_DEST%\inc%_EXT%\vcl\jobset.hxx
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index ffb4e94fc775..7f329f2d24d5 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -31,59 +31,49 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_vcl.hxx"
-#ifndef _SV_SVSYS_HXX
-#include <svsys.h>
-#endif
-#include <vcl/salinst.hxx>
-#include <vcl/salframe.hxx>
-#include <vcl/salsys.hxx>
-#ifndef _VOS_PROCESS_HXX
-#include <vos/process.hxx>
-#endif
-#ifndef _VOS_MUTEX_HXX
-#include <vos/mutex.hxx>
-#endif
-#include <tools/tools.h>
-#include <tools/debug.hxx>
-#include <tools/time.hxx>
-#include <vcl/svdata.hxx>
-#include <vcl/settings.hxx>
-#ifndef _ACCMGR_HXX
-#include <vcl/accmgr.hxx>
-#endif
-#ifndef _SV_KEYCOD_HXX
-#include <vcl/keycod.hxx>
-#endif
-#include <vcl/event.hxx>
-#include <vcl/virdev.hxx>
-#include <vcl/windata.hxx>
-#include <vcl/window.h>
-#include <vcl/wrkwin.hxx>
-#include <vcl/idlemgr.hxx>
-#include <vcl/svapp.hxx>
-#include <vcl/cvtgrf.hxx>
-#include <vcl/unowrap.hxx>
-#include <vcl/xconnection.hxx>
-#ifndef _SV_SVIDS_HRC
-#include <vcl/svids.hrc>
-#endif
-#include <vcl/timer.hxx>
-
-#include <vcl/unohelp.hxx>
-
-#include <com/sun/star/uno/Reference.h>
-#include <com/sun/star/awt/XToolkit.hpp>
-#include <com/sun/star/uno/XNamingService.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <comphelper/processfactory.hxx>
-
-#include <osl/module.h>
-#include <osl/file.hxx>
+#include "svsys.h"
+#include "vcl/salinst.hxx"
+#include "vcl/salframe.hxx"
+#include "vcl/salsys.hxx"
+#include "vos/process.hxx"
+#include "vos/mutex.hxx"
+#include "tools/tools.h"
+#include "tools/debug.hxx"
+#include "tools/time.hxx"
+#include "i18npool/mslangid.hxx"
+#include "vcl/svdata.hxx"
+#include "vcl/settings.hxx"
+#include "vcl/accmgr.hxx"
+#include "vcl/keycod.hxx"
+#include "vcl/event.hxx"
+#include "vcl/vclevent.hxx"
+#include "vcl/virdev.hxx"
+#include "vcl/windata.hxx"
+#include "vcl/window.h"
+#include "vcl/wrkwin.hxx"
+#include "vcl/idlemgr.hxx"
+#include "vcl/svapp.hxx"
+#include "vcl/cvtgrf.hxx"
+#include "vcl/unowrap.hxx"
+#include "vcl/xconnection.hxx"
+#include "vcl/svids.hrc"
+#include "vcl/timer.hxx"
+
+#include "vcl/unohelp.hxx"
+
+#include "com/sun/star/uno/Reference.h"
+#include "com/sun/star/awt/XToolkit.hpp"
+#include "com/sun/star/uno/XNamingService.hpp"
+#include "com/sun/star/lang/XMultiServiceFactory.hpp"
+#include "comphelper/processfactory.hxx"
+
+#include "osl/module.h"
+#include "osl/file.hxx"
#include "osl/thread.h"
#include "rtl/tencinfo.h"
-#include <rtl/instance.hxx>
-#include <vcl/salimestatus.hxx>
+#include "rtl/instance.hxx"
+#include "vcl/salimestatus.hxx"
#include <utility>
#include <vcl/lazydelete.hxx>
@@ -467,7 +457,7 @@ void Application::Execute()
// -----------------------------------------------------------------------
-void Application::Reschedule( bool bAllEvents )
+inline void ImplYield( bool i_bWait, bool i_bAllEvents )
{
ImplSVData* pSVData = ImplGetSVData();
@@ -477,34 +467,45 @@ void Application::Reschedule( bool bAllEvents )
Timer::ImplTimerCallbackProc();
pSVData->maAppData.mnDispatchLevel++;
- pSVData->mpDefInst->Yield( false, bAllEvents );
+ // do not wait for events if application was already quit; in that
+ // case only dispatch events already available
+ // do not wait for events either if the app decided that it is too busy for timers
+ // (feature added for the slideshow)
+ pSVData->mpDefInst->Yield( i_bWait && !pSVData->maAppData.mbAppQuit && !pSVData->maAppData.mbNoYield, i_bAllEvents );
pSVData->maAppData.mnDispatchLevel--;
// flush lazy deleted objects
if( pSVData->maAppData.mnDispatchLevel == 0 )
vcl::LazyDelete::flush();
+
+ // the system timer events will not necesseraly come in in non waiting mode
+ // e.g. on aqua; need to trigger timer checks manually
+ if( pSVData->maAppData.mbNoYield && !pSVData->mbNoCallTimer )
+ {
+ do
+ {
+ Timer::ImplTimerCallbackProc();
+ }
+ while( pSVData->mbNotAllTimerCalled );
+ }
+
+ // call post yield listeners
+ if( pSVData->maAppData.mpPostYieldListeners )
+ pSVData->maAppData.mpPostYieldListeners->callListeners( NULL );
}
// -----------------------------------------------------------------------
-void Application::Yield( bool bAllEvents )
+void Application::Reschedule( bool i_bAllEvents )
{
- ImplSVData* pSVData = ImplGetSVData();
-
- // run timers that have timed out
- if ( !pSVData->mbNoCallTimer )
- while ( pSVData->mbNotAllTimerCalled )
- Timer::ImplTimerCallbackProc();
+ ImplYield( false, i_bAllEvents );
+}
- // do not wait for events if application was already quit; in that
- // case only dispatch events already available
- pSVData->maAppData.mnDispatchLevel++;
- pSVData->mpDefInst->Yield( !pSVData->maAppData.mbAppQuit, bAllEvents );
- pSVData->maAppData.mnDispatchLevel--;
+// -----------------------------------------------------------------------
- // flush lazy deleted objects
- if( pSVData->maAppData.mnDispatchLevel == 0 )
- vcl::LazyDelete::flush();
+void Application::Yield( bool i_bAllEvents )
+{
+ ImplYield( true, i_bAllEvents );
}
// -----------------------------------------------------------------------
@@ -1196,6 +1197,33 @@ void Application::RemoveIdleHdl( const Link& rLink )
// -----------------------------------------------------------------------
+void Application::EnableNoYieldMode( bool i_bNoYield )
+{
+ ImplSVData* pSVData = ImplGetSVData();
+ pSVData->maAppData.mbNoYield = i_bNoYield;
+}
+
+// -----------------------------------------------------------------------
+
+void Application::AddPostYieldListener( const Link& i_rListener )
+{
+ ImplSVData* pSVData = ImplGetSVData();
+ if( ! pSVData->maAppData.mpPostYieldListeners )
+ pSVData->maAppData.mpPostYieldListeners = new VclEventListeners2();
+ pSVData->maAppData.mpPostYieldListeners->addListener( i_rListener );
+}
+
+// -----------------------------------------------------------------------
+
+void Application::RemovePostYieldListener( const Link& i_rListener )
+{
+ ImplSVData* pSVData = ImplGetSVData();
+ if( pSVData->maAppData.mpPostYieldListeners )
+ pSVData->maAppData.mpPostYieldListeners->removeListener( i_rListener );
+}
+
+// -----------------------------------------------------------------------
+
WorkWindow* Application::GetAppWindow()
{
return ImplGetSVData()->maWinData.mpAppWin;
diff --git a/vcl/source/app/vclevent.cxx b/vcl/source/app/vclevent.cxx
index 8ebc65c8a3f6..704d68c5bc7f 100644
--- a/vcl/source/app/vclevent.cxx
+++ b/vcl/source/app/vclevent.cxx
@@ -80,3 +80,56 @@ BOOL VclEventListeners::Process( VclSimpleEvent* pEvent ) const
}
return bProcessed;
}
+
+VclEventListeners2::VclEventListeners2()
+{
+}
+
+VclEventListeners2::~VclEventListeners2()
+{
+}
+
+void VclEventListeners2::addListener( const Link& i_rLink )
+{
+ // ensure uniqueness
+ for( std::list< Link >::const_iterator it = m_aListeners.begin(); it != m_aListeners.end(); ++it )
+ {
+ if( *it == i_rLink )
+ return;
+ }
+ m_aListeners.push_back( i_rLink );
+}
+
+void VclEventListeners2::removeListener( const Link& i_rLink )
+{
+ size_t n = m_aIterators.size();
+ for( size_t i = 0; i < n; i++ )
+ {
+ if( m_aIterators[i].m_aIt != m_aListeners.end() && *m_aIterators[i].m_aIt == i_rLink )
+ {
+ m_aIterators[i].m_bWasInvalidated = true;
+ ++m_aIterators[i].m_aIt;
+ }
+ }
+ m_aListeners.remove( i_rLink );
+}
+
+void VclEventListeners2::callListeners( VclSimpleEvent* i_pEvent )
+{
+ vcl::DeletionListener aDel( this );
+
+ m_aIterators.push_back( ListenerIt() );
+ size_t nIndex = m_aIterators.size() - 1;
+ m_aIterators[ nIndex ].m_aIt = m_aListeners.begin();
+ while( ! aDel.isDeleted() && m_aIterators[ nIndex ].m_aIt != m_aListeners.end() )
+ {
+ m_aIterators[ nIndex ].m_aIt->Call( i_pEvent );
+ if( m_aIterators[ nIndex ].m_bWasInvalidated )
+ // check if the current element was removed and the iterator increased in the meantime
+ m_aIterators[ nIndex ].m_bWasInvalidated = false;
+ else
+ ++m_aIterators[ nIndex ].m_aIt;
+ }
+ m_aIterators.pop_back();
+}
+
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index d4fc6fa27117..dd2f4a62c88d 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -3615,6 +3615,7 @@ sal_Int32 PDFWriterImpl::emitFontDescriptor( const ImplFontData* pFont, FontSubs
break;
case FontSubsetInfo::TYPE1_PFA:
case FontSubsetInfo::TYPE1_PFB:
+ case FontSubsetInfo::ANY_TYPE1:
break;
default:
DBG_ERROR( "unknown fonttype in PDF font descriptor" );
diff --git a/vcl/source/gdi/regband.cxx b/vcl/source/gdi/regband.cxx
index 938a30351f9a..09c97ef7cd2b 100644
--- a/vcl/source/gdi/regband.cxx
+++ b/vcl/source/gdi/regband.cxx
@@ -110,7 +110,7 @@ ImplRegionBand::ImplRegionBand(
if ( ! bIgnorePoints)
{
// Copy points.
- ImplRegionBandPoint* pPoint = mpFirstBandPoint;
+ ImplRegionBandPoint* pPoint = rRegionBand.mpFirstBandPoint;
ImplRegionBandPoint* pPrevPointCopy = NULL;
while (pPoint != NULL)
{
diff --git a/vcl/unx/headless/svppspgraphics.cxx b/vcl/unx/headless/svppspgraphics.cxx
index 3e9d67bcbbe9..1311aaed4ee4 100644
--- a/vcl/unx/headless/svppspgraphics.cxx
+++ b/vcl/unx/headless/svppspgraphics.cxx
@@ -986,13 +986,6 @@ const void* PspGraphics::DoGetEmbedFontData( fontID aFont, const sal_Ucs* pUnico
return NULL;
// fill in font info
- switch( aFontInfo.m_eType )
- {
- case psp::fonttype::TrueType: rInfo.m_nFontType = FontSubsetInfo::SFNT_TTF; break;
- case psp::fonttype::Type1: rInfo.m_nFontType = FontSubsetInfo::ANY_TYPE1; break;
- default:
- return NULL;
- }
rInfo.m_nAscent = aFontInfo.m_nAscend;
rInfo.m_nDescent = aFontInfo.m_nDescend;
rInfo.m_aPSName = rMgr.getPSName( aFont );
@@ -1029,9 +1022,22 @@ const void* PspGraphics::DoGetEmbedFontData( fontID aFont, const sal_Ucs* pUnico
rInfo.m_nCapHeight = yMax; // Well ...
for( int i = 0; i < 256; i++ )
-
pWidths[i] = (aMetrics[i].width > 0 ? aMetrics[i].width : 0);
+ switch( aFontInfo.m_eType )
+ {
+ case psp::fonttype::TrueType:
+ rInfo.m_nFontType = FontSubsetInfo::SFNT_TTF;
+ break;
+ case psp::fonttype::Type1: {
+ const bool bPFA = ((*(unsigned char*)pFile) < 0x80);
+ rInfo.m_nFontType = bPFA ? FontSubsetInfo::TYPE1_PFA : FontSubsetInfo::TYPE1_PFB;
+ }
+ break;
+ default:
+ return NULL;
+ }
+
return pFile;
}
diff --git a/vcl/unx/source/gdi/pspgraphics.cxx b/vcl/unx/source/gdi/pspgraphics.cxx
index 009b14c56062..227d6cd7e9b2 100644
--- a/vcl/unx/source/gdi/pspgraphics.cxx
+++ b/vcl/unx/source/gdi/pspgraphics.cxx
@@ -1094,13 +1094,6 @@ const void* PspGraphics::DoGetEmbedFontData( fontID aFont, const sal_Ucs* pUnico
return NULL;
// fill in font info
- switch( aFontInfo.m_eType )
- {
- case psp::fonttype::TrueType: rInfo.m_nFontType = FontSubsetInfo::SFNT_TTF; break;
- case psp::fonttype::Type1: rInfo.m_nFontType = FontSubsetInfo::ANY_TYPE1; break;
- default:
- return NULL;
- }
rInfo.m_nAscent = aFontInfo.m_nAscend;
rInfo.m_nDescent = aFontInfo.m_nDescend;
rInfo.m_aPSName = rMgr.getPSName( aFont );
@@ -1137,9 +1130,22 @@ const void* PspGraphics::DoGetEmbedFontData( fontID aFont, const sal_Ucs* pUnico
rInfo.m_nCapHeight = yMax; // Well ...
for( int i = 0; i < 256; i++ )
-
pWidths[i] = (aMetrics[i].width > 0 ? aMetrics[i].width : 0);
+ switch( aFontInfo.m_eType )
+ {
+ case psp::fonttype::TrueType:
+ rInfo.m_nFontType = FontSubsetInfo::SFNT_TTF;
+ break;
+ case psp::fonttype::Type1: {
+ const bool bPFA = ((*(unsigned char*)pFile) < 0x80);
+ rInfo.m_nFontType = bPFA ? FontSubsetInfo::TYPE1_PFA : FontSubsetInfo::TYPE1_PFB;
+ }
+ break;
+ default:
+ return NULL;
+ }
+
return pFile;
}
diff --git a/vcl/unx/source/gdi/salgdi.cxx b/vcl/unx/source/gdi/salgdi.cxx
index 34f2dfd4b935..c09803dcb269 100644
--- a/vcl/unx/source/gdi/salgdi.cxx
+++ b/vcl/unx/source/gdi/salgdi.cxx
@@ -1028,11 +1028,12 @@ BOOL X11SalGraphics::drawEPS( long,long,long,long,void*,ULONG )
XID X11SalGraphics::GetXRenderPicture()
{
+ XRenderPeer& rRenderPeer = XRenderPeer::GetInstance();
+
if( !m_aRenderPicture )
{
// check xrender support for matching visual
// find a XRenderPictFormat compatible with the Drawable
- XRenderPeer& rRenderPeer = XRenderPeer::GetInstance();
XRenderPictFormat* pVisualFormat = static_cast<XRenderPictFormat*>(GetXRenderFormat());
if( !pVisualFormat )
{
@@ -1053,7 +1054,15 @@ XID X11SalGraphics::GetXRenderPicture()
// TODO: avoid clipping if already set correctly
if( pClipRegion_ && !XEmptyRegion( pClipRegion_ ) )
rRenderPeer.SetPictureClipRegion( aDstPic, pClipRegion_ );
+ else
#endif
+ {
+ // reset clip region
+ // TODO: avoid clip reset if already done
+ XRenderPictureAttributes aAttr;
+ aAttr.clip_mask = None;
+ rRenderPeer.ChangePicture( m_aRenderPicture, CPClipMask, &aAttr );
+ }
return m_aRenderPicture;
}
@@ -1096,6 +1105,7 @@ bool IsLeftOf( const XLineFixed& rA, const XLineFixed& rB )
const XFixed aXDiff = rU.p2.x - rU.p1.x;
const XFixed aYDiff = rU.p2.y - rU.p1.y;
+ // compare upper point of lower segment with line through upper segment
if( (rU.p1.y != rL.p1.y) || (rU.p1.x != rL.p1.x) )
{
const sal_Int64 n1 = (sal_Int64)aXDiff * (rL.p1.y - rU.p1.y);
@@ -1104,6 +1114,7 @@ bool IsLeftOf( const XLineFixed& rA, const XLineFixed& rB )
return ((n1 < n2) == bAbove);
}
+ // compare lower point of lower segment with line through upper segment
if( (rU.p2.y != rL.p2.y) || (rU.p2.x != rL.p2.x) )
{
const sal_Int64 n3 = (sal_Int64)aXDiff * (rL.p2.y - rU.p1.y);
@@ -1122,10 +1133,14 @@ struct HalfTrapezoid
// maLine.p1.y <= mnY < maLine.p2.y
XLineFixed maLine;
XFixed mnY;
+
+ XFixed getXMin() const { return std::min( maLine.p1.x, maLine.p2.x); }
+ XFixed getXMax() const { return std::max( maLine.p1.x, maLine.p2.x); }
};
-struct HalfTrapCompare
+class HalfTrapCompare
{
+public:
bool operator()( const HalfTrapezoid& rA, const HalfTrapezoid& rB ) const
{
bool bIsTopLeft = false;
@@ -1138,14 +1153,15 @@ struct HalfTrapCompare
}
};
-typedef std::priority_queue< HalfTrapezoid, std::vector<HalfTrapezoid>, HalfTrapCompare > HTQueueBase;
+typedef std::vector< HalfTrapezoid > HTVector;
+typedef std::priority_queue< HalfTrapezoid, HTVector, HalfTrapCompare > HTQueueBase;
// we need a priority queue with a reserve() to prevent countless reallocations
class HTQueue
: public HTQueueBase
{
public:
void reserve( size_t n ) { c.reserve( n ); }
- int capacity() { return c.capacity(); }
+ void swapvec( HTVector& v ) { c.swap( v ); }
};
typedef std::vector<XTrapezoid> TrapezoidVector;
@@ -1173,6 +1189,10 @@ public:
};
typedef std::multiset< int, TrapezoidYCompare > VerticalTrapSet;
+
+#ifndef DISABLE_SOLVECROSSOVER_WORKAROUND
+void splitIntersectingSegments( HTVector&);
+#endif // DISABLE_SOLVECROSSOVER_WORKAROUND
} // end of anonymous namespace
// draw a poly-polygon
@@ -1210,7 +1230,7 @@ bool X11SalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rOrigPoly
// don't bother with polygons outside of visible area
const basegfx::B2DRange aViewRange( 0, 0, GetGraphicsWidth(), GetGraphicsHeight() );
const basegfx::B2DRange aPolyRange = basegfx::tools::getRange( rOrigPolyPoly );
- const bool bNeedViewClip = !aPolyRange.isInside( aViewRange );
+ const bool bNeedViewClip = aPolyRange.isInside( aViewRange );
if( !aPolyRange.overlaps( aViewRange ) )
return true;
@@ -1237,6 +1257,15 @@ bool X11SalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rOrigPoly
if( !nClippedPolyCount )
continue;
+#ifndef DISABLE_SOLVECROSSOVER_WORKAROUND
+ for( int nClippedPolyIdx = 0; nClippedPolyIdx < nClippedPolyCount; ++nClippedPolyIdx )
+ {
+ const ::basegfx::B2DPolygon aSolvedPolygon = aClippedPolygon.getB2DPolygon( nClippedPolyIdx );
+ const int nPointCount = aSolvedPolygon.count();
+ aGoodPolyPoly.append( aSolvedPolygon );
+ nHTQueueReserve += aSolvedPolygon.areControlPointsUsed() ? 8 * nPointCount : nPointCount;
+ }
+#else // DISABLE_SOLVECROSSOVER_WORKAROUND
// #i103259# polypoly.solveCrossover() fails to remove self-intersections
// but polygon.solveCrossover() works. Use it to build the intersection-free polypolygon
// TODO: if the self-intersection prevention is too expensive make the trap-algorithm tolerate intersections
@@ -1255,11 +1284,12 @@ bool X11SalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rOrigPoly
nHTQueueReserve += aSolvedPolygon.areControlPointsUsed() ? 8 * nPointCount : nPointCount;
}
}
+#endif // DISABLE_SOLVECROSSOVER_WORKAROUND
}
// #i100922# try to prevent priority-queue reallocations by reservering enough
nHTQueueReserve = ((4*nHTQueueReserve) | 0x1FFF) + 1;
- HTQueue aHTQueue;
- aHTQueue.reserve( nHTQueueReserve );
+ HTVector aHTVector;
+ aHTVector.reserve( nHTQueueReserve );
// first convert the B2DPolyPolygon to HalfTrapezoids
const int nGoodPolyCount = aGoodPolyPoly.count();
@@ -1299,9 +1329,6 @@ bool X11SalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rOrigPoly
// check if enough data is available for a new HalfTrapezoid
if( nPointIdx == 0 )
continue;
- // ignore vertical segments
- if( aNewXPF.y == aOldXPF.y )
- continue;
// construct HalfTrapezoid as topdown segment
HalfTrapezoid aHT;
@@ -1326,14 +1353,33 @@ bool X11SalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rOrigPoly
#endif
// queue up the HalfTrapezoid
- aHTQueue.push( aHT );
+ aHTVector.push_back( aHT );
}
}
}
- if( aHTQueue.empty() )
+ if( aHTVector.empty() )
return TRUE;
+#ifndef DISABLE_SOLVECROSSOVER_WORKAROUND
+ // find intersecting halftraps and split them up
+ // TODO: remove when solveCrossOvers gets fast enough so its use can be enabled above
+ // FAQ: why should segment intersection be handled before adaptiveSubdivide()?
+ // Answer: because it is conceptually much faster
+ // Example: consider two intersecting circles with a diameter of 1000 pixels
+ // before subdivision: eight bezier segments
+ // after subdivision: more than a thousand line segments
+ // since even the best generic intersection finders have a complexity of O((n+k)*log(n+k))
+ // it shows that testing while the segment count is still low is a much better approach.
+ splitIntersectingSegments( aHTVector);
+#endif // DISABLE_SOLVECROSSOVER_WORKAROUND
+
+ // build queue from vector of intersection-free segments
+ // TODO: is replacing the priority-queue by a sorted vector worth it?
+ std::make_heap( aHTVector.begin(), aHTVector.end(), HalfTrapCompare());
+ HTQueue aHTQueue;
+ aHTQueue.swapvec( aHTVector);
+
// then convert the HalfTrapezoids into full Trapezoids
TrapezoidVector aTrapVector;
aTrapVector.reserve( aHTQueue.size() * 2 ); // just a guess
@@ -1349,24 +1395,28 @@ bool X11SalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rOrigPoly
XTrapezoid aTrapezoid;
// convert a HalfTrapezoid pair
+ // get the left side of the trapezoid
const HalfTrapezoid& rLeft = aHTQueue.top();
aTrapezoid.top = rLeft.mnY;
- aTrapezoid.bottom = rLeft.maLine.p2.y;
aTrapezoid.left = rLeft.maLine;
+ aHTQueue.pop();
-#if 0
- // ignore empty trapezoids
- if( aTrapezoid.bottom <= aTrapezoid.top )
+ // ignore left segment that would result in an empty trapezoid
+ if( aTrapezoid.left.p2.y <= aTrapezoid.top )
continue;
-#endif
- aHTQueue.pop();
- if( aHTQueue.empty() ) // TODO: assert
- break;
- const HalfTrapezoid& rRight = aHTQueue.top();
- aTrapezoid.right = rRight.maLine;
- aHTQueue.pop();
+ // get the right side of the trapezoid
+ aTrapezoid.right.p2.y = aTrapezoid.bottom;
+ while( !aHTQueue.empty() ) {
+ const HalfTrapezoid& rRight = aHTQueue.top();
+ aTrapezoid.right = rRight.maLine;
+ aHTQueue.pop();
+ // ignore right segment that would result in an empty trapezoid
+ if( aTrapezoid.right.p2.y > aTrapezoid.top )
+ break;
+ }
+ // the topmost endpoint determines the trapezoid bottom
aTrapezoid.bottom = aTrapezoid.left.p2.y;
if( aTrapezoid.bottom > aTrapezoid.right.p2.y )
aTrapezoid.bottom = aTrapezoid.right.p2.y;
@@ -1374,44 +1424,49 @@ bool X11SalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rOrigPoly
// keep the full Trapezoid candidate
aTrapVector.push_back( aTrapezoid );
- // unless it splits an older trapezoid
+ // unless it splits another trapezoid that is still active
bool bSplit = false;
- for(;;)
+ ActiveTrapSet::iterator aActiveTrapsIt = aActiveTraps.begin();
+ for(; aActiveTrapsIt != aActiveTraps.end(); ++aActiveTrapsIt )
{
- // check if the new trapezoid overlaps with an old trapezoid
- ActiveTrapSet::iterator aActiveTrapsIt
- = aActiveTraps.upper_bound( aTrapVector.size()-1 );
- if( aActiveTrapsIt == aActiveTraps.begin() )
- break;
- --aActiveTrapsIt;
-
XTrapezoid& rLeftTrap = aTrapVector[ *aActiveTrapsIt ];
+ // skip until first overlap candidate
+ // TODO: use stl::*er_bound() instead
+ if( IsLeftOf( aTrapezoid.left, rLeftTrap.left) )
+ continue;
+
// in the ActiveTrapSet there are still trapezoids where
// a vertical overlap with new trapezoids is no longer possible
// they could have been removed in the verticaltraps loop below
- // but this would have been expensive and is not needed as we can
- // simply ignore them now and remove them from the ActiveTrapSet
- // so they won't bother us in the future
+ // but this would be expensive and is not needed as we can
+ // simply ignore them until we stumble upon them here.
if( rLeftTrap.bottom <= aTrapezoid.top )
{
- aActiveTraps.erase( aActiveTrapsIt );
+ ActiveTrapSet::iterator it = aActiveTrapsIt;
+ if( aActiveTrapsIt != aActiveTraps.begin() )
+ --aActiveTrapsIt;
+ aActiveTraps.erase( it );
continue;
}
// check if there is horizontal overlap
// aTrapezoid.left==rLeftTrap.right is allowed though
if( !IsLeftOf( aTrapezoid.left, rLeftTrap.right ) )
- break;
+ continue;
- // split the old trapezoid and keep its upper part
+ // prepare to split the old trapezoid and keep its upper part
// find the old trapezoids entry in the VerticalTrapSet and remove it
typedef std::pair<VerticalTrapSet::iterator, VerticalTrapSet::iterator> VTSPair;
VTSPair aVTSPair = aVerticalTraps.equal_range( *aActiveTrapsIt );
VerticalTrapSet::iterator aVTSit = aVTSPair.first;
- for(; (aVTSit != aVTSPair.second) && (*aVTSit != *aActiveTrapsIt); ++aVTSit ) ;
- if( aVTSit != aVTSPair.second )
+ for(; aVTSit != aVTSPair.second; ++aVTSit )
+ {
+ if( *aVTSit != *aActiveTrapsIt )
+ continue;
aVerticalTraps.erase( aVTSit );
+ break;
+ }
// then update the old trapezoid's bottom
rLeftTrap.bottom = aTrapezoid.top;
// enter the updated old trapzoid in VerticalTrapSet
@@ -1444,24 +1499,26 @@ bool X11SalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rOrigPoly
// mark trapezoids that can no longer be split as inactive
// and recycle their sides which were not fully resolved
static const XFixed nMaxTop = +0x7FFFFFFF;
- XFixed nNewTop = aHTQueue.empty() ? nMaxTop : aHTQueue.top().mnY;
+ const XFixed nNewTop = aHTQueue.empty() ? nMaxTop : aHTQueue.top().mnY;
while( !aVerticalTraps.empty() )
{
+ // check the next trapezoid to be retired
const XTrapezoid& rOldTrap = aTrapVector[ *aVerticalTraps.begin() ];
if( nNewTop < rOldTrap.bottom )
break;
- // the reference Trapezoid can no longer be split
+ // this trapezoid can no longer be split
aVerticalTraps.erase( aVerticalTraps.begin() );
// recycle its sides that were not fully resolved
HalfTrapezoid aHT;
aHT.mnY = rOldTrap.bottom;
- if( rOldTrap.left.p2.y > rOldTrap.bottom )
+
+ if( rOldTrap.left.p2.y > aHT.mnY )
{
aHT.maLine = rOldTrap.left;
aHTQueue.push( aHT );
}
- if( rOldTrap.right.p2.y > rOldTrap.bottom )
+ if( rOldTrap.right.p2.y > aHT.mnY )
{
aHT.maLine = rOldTrap.right;
aHTQueue.push( aHT );
@@ -1527,13 +1584,20 @@ bool X11SalGraphics::drawPolyLine(const ::basegfx::B2DPolygon& rPolygon, const :
aPolygon.transform( aAnisoMatrix );
}
- // AW: reSegment no longer needed; new createAreaGeometry will remove exteme positions
- // and create bezier polygons
- //if( aPolygon.areControlPointsUsed() )
- // aPolygon = basegfx::tools::reSegmentPolygonEdges( aPolygon, 8, true, false );
- //const basegfx::B2DPolyPolygon aAreaPolyPoly = basegfx::tools::createAreaGeometryForSimplePolygon(
- // aPolygon, 0.5*rLineWidth.getX(), eLineJoin );
- const basegfx::B2DPolyPolygon aAreaPolyPoly(basegfx::tools::createAreaGeometry(aPolygon, 0.5*rLineWidth.getX(), eLineJoin));
+ // special handling for hairlines to improve the drawing performance
+ // TODO: revisit after basegfx performance related changes
+ const bool bIsHairline = (rLineWidth.getX() < 1.2) && (rLineWidth.getY() < 1.2);
+ if( bIsHairline )
+ {
+ // for hairlines the linejoin style becomes irrelevant
+ eLineJoin = basegfx::B2DLINEJOIN_NONE;
+ // createAreaGeometry is still too expensive when beziers are involved
+ if( aPolygon.areControlPointsUsed() )
+ aPolygon = ::basegfx::tools::adaptiveSubdivideByDistance( aPolygon, 0.125 );
+ }
+
+ // create the area-polygon for the line
+ const basegfx::B2DPolyPolygon aAreaPolyPoly( basegfx::tools::createAreaGeometry(aPolygon, 0.5*rLineWidth.getX(), eLineJoin) );
if( (rLineWidth.getX() != rLineWidth.getY())
&& !basegfx::fTools::equalZero( rLineWidth.getX() ) )
@@ -1568,3 +1632,259 @@ bool X11SalGraphics::drawPolyLine(const ::basegfx::B2DPolygon& rPolygon, const :
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#ifndef DISABLE_SOLVECROSSOVER_WORKAROUND
+// TODO: move the intersection solver into basegfx
+// and then support bezier-intersection finding too
+
+namespace { // anonymous namespace to prevent export
+
+typedef HalfTrapezoid LineSeg;
+typedef HTVector LSVector;
+
+inline bool operator==( const LineSeg& r1, const LineSeg& r2)
+{
+ if( r1.maLine.p2.y != r2.maLine.p2.y) return false;
+ if( r1.maLine.p2.x != r2.maLine.p2.x) return false;
+ if( r1.maLine.p1.y != r2.maLine.p1.y) return false;
+ if( r1.maLine.p1.x != r2.maLine.p1.x) return false;
+ return true;
+}
+
+struct LSYMinCmp
+{
+ bool operator()( const LineSeg& r1, const LineSeg& r2) const
+ { return r2.maLine.p1.y < r1.maLine.p1.y; }
+};
+
+struct LSYMaxCmp
+{
+ bool operator()( const LineSeg& r1, const LineSeg& r2) const
+ { return r2.maLine.p2.y < r1.maLine.p2.y; }
+};
+
+struct LSXMinCmp
+{
+ bool operator()( const LineSeg& r1, const LineSeg& r2) const
+ { return( r1.getXMin() < r2.getXMin()); }
+};
+
+struct CutPoint
+{
+ XFixed mnSegmentId;
+ float mfCutParam;
+ XPointFixed maPoint;
+};
+
+struct CutPointCmp
+{
+ bool operator()( const CutPoint& r1, const CutPoint& r2) const
+ {
+ if( r1.mnSegmentId != r2.mnSegmentId)
+ return (r1.mnSegmentId < r2.mnSegmentId);
+ return (r1.mfCutParam < r2.mfCutParam);
+ }
+};
+
+bool findIntersection( const LineSeg& rLS1, const LineSeg& rLS2, CutPoint aCutPoints[2])
+{
+ // segments intersect at r1.p1 + s*(r1.p2-r1.p1) == r2.p1 + t*(r2.p2-r2.p1)
+ // when both segment-parameters are ((0 <s<1) && (0<t<1))
+ // (r1.p1 - r2.p1) == s * (r1.p1 - r1.p2) + t * (r2.p2 - r2.p1)
+ // =>
+ // (r1.p1x - r2.p1x) == s * (r1.p1x - r1.p2x) + t * (r2.p2x - r2.p1x)
+ // (r1.p1y - r2.p1y) == s * (r1.p1y - r1.p2y) + t * (r2.p2y - r2.p1y)
+ // check if lines are identical or parallel => not intersecting
+ const XLineFixed& r1 = rLS1.maLine;
+ const XLineFixed& r2 = rLS2.maLine;
+ const double fDet = (double)(r1.p1.x - r1.p2.x) * (r2.p2.y - r2.p1.y)
+ - (double)(r2.p2.x - r2.p1.x) * (r1.p1.y - r1.p2.y);
+ static const double fEps = 1e-8;
+ if( fabs(fDet) < fEps)
+ return false;
+ // check if intersecting with first segment
+ const double fS1 = (double)(r2.p2.y - r2.p1.y) * (r1.p1.x - r2.p1.x);
+ const double fS2 = (double)(r2.p2.x - r2.p1.x) * (r2.p1.y - r1.p1.y);
+ const double fS = (fS1 + fS2) / fDet;
+ if( (fS <= +fEps) || (fS >= 1-fEps))
+ return false;
+ // check if intersecting with second segment
+ const double fT1 = (double)(r1.p2.y - r1.p1.y) * (r1.p1.x - r2.p1.x);
+ const double fT2 = (double)(r1.p2.x - r1.p1.x) * (r2.p1.y - r1.p1.y);
+ const double fT = (fT1 + fT2) / fDet;
+ if( (fT <= +fEps) || (fT >= 1-fEps))
+ return false;
+ // force the intersection point to be exactly identical on both segments
+ aCutPoints[0].maPoint.x = (XFixed)(r1.p1.x + fS * (r1.p2.x - r1.p1.x));
+ aCutPoints[0].maPoint.y = (XFixed)(r1.p1.y + fS * (r1.p2.y - r1.p1.y));
+ aCutPoints[1].maPoint.x = aCutPoints[0].maPoint.x;
+ aCutPoints[1].maPoint.y = aCutPoints[0].maPoint.y;
+ aCutPoints[0].mnSegmentId = rLS1.mnY;
+ aCutPoints[0].mfCutParam = (float)fS;
+ aCutPoints[1].mnSegmentId = rLS2.mnY;
+ aCutPoints[1].mfCutParam = (float)fT;
+ return true;
+}
+
+typedef std::priority_queue< LineSeg, LSVector, LSYMinCmp> LSYMinQueueBase;
+typedef std::priority_queue< LineSeg, LSVector, LSYMaxCmp> LSYMaxQueueBase;
+typedef std::multiset< LineSeg, LSXMinCmp> LSXMinSet;
+typedef std::set< CutPoint, CutPointCmp> CutPointSet;
+
+class LSYMinQueue : public LSYMinQueueBase
+{
+public:
+ void reserve( size_t n) { c.reserve(n);}
+ void swapvec( LSVector& v) { c.swap(v);}
+};
+
+class LSYMaxQueue : public LSYMaxQueueBase
+{
+public:
+ void reserve( size_t n) { c.reserve(n);}
+};
+
+void addAndCutSegment( LSVector& rLSVector, const LineSeg& rLS, CutPointSet& rCutPointSet)
+{
+ // short circuit when no segment was cut
+ if( rCutPointSet.empty()) {
+ rLSVector.push_back( rLS);
+ return;
+ }
+
+ // find the first cut point for this segment
+ LineSeg aCS = rLS;
+ CutPoint aMinCutPoint;
+ aMinCutPoint.mnSegmentId = rLS.mnY;
+ aMinCutPoint.mfCutParam = 0.0;
+ CutPointSet::iterator itFirst = rCutPointSet.lower_bound( aMinCutPoint);
+ CutPointSet::iterator it = itFirst;
+ // iterate through all cut points of this segment
+ for(; it != rCutPointSet.end(); ++it) {
+ const CutPoint rCutPoint = (*it);
+ if( rCutPoint.mnSegmentId != rLS.mnY)
+ break;
+ // cut segment at the cutpoint
+ aCS.maLine.p2 = rCutPoint.maPoint;
+ rLSVector.push_back( aCS);
+ // prepare for next segment cut
+ aCS.maLine.p1 = aCS.maLine.p2;
+ }
+ // remove cutparams that will no longer be needed
+ // TODO: is it worth it or should we just keep the cutparams?
+ rCutPointSet.erase( itFirst, it);
+
+ // add segment part remaining after last cut
+ aCS.maLine.p2 = rLS.maLine.p2;
+ rLSVector.push_back( aCS);
+}
+
+void splitIntersectingSegments( LSVector& rLSVector)
+{
+ // get a unique id for each lineseg, temporarily abuse the mnY member
+ LSVector::iterator aLSit = rLSVector.begin();
+ for( int i = 0; aLSit != rLSVector.end(); ++aLSit) {
+ LineSeg& rLS = *aLSit;
+ rLS.mnY = i++;
+ }
+ // get an y-sorted queue from the input vector
+ LSYMinQueue aYMinQueue;
+ std::make_heap( rLSVector.begin(), rLSVector.end(), LSYMinCmp());
+ aYMinQueue.swapvec( rLSVector);
+
+ // prepare the result vector
+ // try to avoid reallocations by guessing a reasonable result size
+ rLSVector.reserve( aYMinQueue.size() * 1.5);
+
+ // find all intersections
+ CutPointSet aCutPointSet;
+ LSXMinSet aXMinSet;
+ LSYMaxQueue aYMaxQueue;
+ aYMaxQueue.reserve( aYMinQueue.size());
+ // sweep-down and check all segment-pairs that overlap
+ while( !aYMinQueue.empty()) {
+ // get next input-segment
+ const LineSeg& rLS = aYMinQueue.top();
+ // retire obsoleted segments
+ const XFixed fYCur = rLS.maLine.p1.y;
+ while( !aYMaxQueue.empty()) {
+ // check next segment to be retired
+ const LineSeg& rOS = aYMaxQueue.top();
+ if( fYCur < rOS.maLine.p2.y)
+ break;
+ // emit resolved segment into result
+ addAndCutSegment( rLSVector, rOS, aCutPointSet);
+ // find segment to be retired in xmin-compare-set
+ LSXMinSet::iterator itR = aXMinSet.lower_bound( rOS);
+ while( !(*itR == rOS)) ++itR;
+ // retire segment from xmin-compare-set
+ aXMinSet.erase( itR);
+ // this segment is pining for the fjords
+ aYMaxQueue.pop();
+ }
+
+ // iterate over all segments that might overlap
+ // skip over the leftmost segments that cannot overlap
+ const XFixed fXMax = rLS.getXMax();
+ LSXMinSet::const_iterator itC = aXMinSet.begin();
+ for(; itC != aXMinSet.end(); ++itC)
+ if( (*itC).getXMin() <= fXMax)
+ break;
+ // TODO: if the linear search becomes too expensive
+ // then use an XMaxQueue based approach to replace it
+ const XFixed fXMin = rLS.getXMin();
+ for(; itC != aXMinSet.end(); ++itC) {
+ const LineSeg& rOS = *itC;
+ if( fXMin >= rOS.getXMax())
+ continue;
+ if( fXMax < rOS.getXMin())
+ break;
+ CutPoint aCutPoints[2];
+ if( !findIntersection( rLS, rOS, aCutPoints))
+ continue;
+ // remember cut parameters
+ // TODO: std::set seems to use individual allocations
+ // which results in perf-problems for many entries
+ // => pre-allocate nodes by using a non-default allocator
+ aCutPointSet.insert( aCutPoints[0]);
+ aCutPointSet.insert( aCutPoints[1]);
+ }
+ // add segment to xmin-compare-set
+ // TODO: do we have a good insertion hint?
+ aXMinSet.insert( /*itC,*/ rLS);
+ // register segment for retirement
+ aYMaxQueue.push( rLS);
+ aYMinQueue.pop();
+ }
+
+ // retire the remaining segments
+ aXMinSet.clear();
+ while( !aYMaxQueue.empty()) {
+ // emit segments and cut them up if needed
+ const LineSeg& rLS = aYMaxQueue.top();
+ addAndCutSegment( rLSVector, rLS, aCutPointSet);
+ aYMaxQueue.pop();
+ }
+
+ // get the segments ready to be consumed by the drawPolygon() caller
+ aLSit = rLSVector.begin();
+ LSVector::iterator aLSit2 = aLSit;
+ for(; aLSit != rLSVector.end(); ++aLSit) {
+ LineSeg& rLS = *aLSit;
+ // restore the segment top member
+ rLS.mnY = rLS.maLine.p1.y;
+ // remove horizontal segments for now
+ // TODO: until the trapezoid converter is adjusted to handle them
+ if( rLS.maLine.p1.y == rLS.maLine.p2.y )
+ continue;
+ *(aLSit2++) = rLS;
+ }
+ if(aLSit2 != aLSit)
+ rLSVector.resize( aLSit2 - rLSVector.begin() );
+}
+
+} // end anonymous namespace
+
+#endif // DISABLE_SOLVECROSSOVER_WORKAROUND
+
+// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
diff --git a/vcl/unx/source/gdi/xrender_peer.cxx b/vcl/unx/source/gdi/xrender_peer.cxx
index d8f2045c6fde..fc8de818fafd 100644
--- a/vcl/unx/source/gdi/xrender_peer.cxx
+++ b/vcl/unx/source/gdi/xrender_peer.cxx
@@ -142,6 +142,10 @@ void XRenderPeer::InitRenderLib()
mpXRenderCreatePicture = (Picture(*)(Display*,Drawable,const XRenderPictFormat*,
unsigned long,const XRenderPictureAttributes*))pFunc;
+ pFunc = osl_getAsciiFunctionSymbol( mpRenderLib, "XRenderChangePicture" );
+ if( !pFunc ) return;
+ mpXRenderChangePicture = (void(*)(Display*,Picture,unsigned long,const XRenderPictureAttributes*))pFunc;
+
pFunc = osl_getAsciiFunctionSymbol( mpRenderLib, "XRenderSetPictureClipRegion" );
if( !pFunc ) return;
mpXRenderSetPictureClipRegion = (void(*)(Display*,Picture,XLIB_Region))pFunc;
diff --git a/vcl/unx/source/gdi/xrender_peer.hxx b/vcl/unx/source/gdi/xrender_peer.hxx
index f1e2fd77a273..27c8fb3dcaeb 100644
--- a/vcl/unx/source/gdi/xrender_peer.hxx
+++ b/vcl/unx/source/gdi/xrender_peer.hxx
@@ -66,6 +66,8 @@ public:
const XRenderPictFormat& ) const;
Picture CreatePicture( Drawable, const XRenderPictFormat*,
unsigned long nDrawable, const XRenderPictureAttributes* ) const;
+ void ChangePicture( Picture, unsigned long nValueMask,
+ const XRenderPictureAttributes* ) const;
void SetPictureClipRegion( Picture, XLIB_Region ) const;
void CompositePicture( int nOp, Picture aSrc, Picture aMask, Picture aDst,
int nXSrc, int nYSrc, int nXMask, int nYMask,
@@ -103,6 +105,8 @@ private:
Picture (*mpXRenderCreatePicture)(Display*,Drawable, const XRenderPictFormat*,
unsigned long,const XRenderPictureAttributes*);
+ void (*mpXRenderChangePicture)(Display*,Picture,
+ unsigned long,const XRenderPictureAttributes*);
void (*mpXRenderSetPictureClipRegion)(Display*,Picture,XLIB_Region);
void (*mpXRenderFreePicture)(Display*,Picture);
void (*mpXRenderComposite)(Display*,int,Picture,Picture,Picture,
@@ -194,6 +198,16 @@ inline Picture XRenderPeer::CreatePicture( Drawable aDrawable,
#endif
}
+inline void XRenderPeer::ChangePicture( Picture aPicture,
+ unsigned long nValueMask, const XRenderPictureAttributes* pRenderAttr ) const
+{
+#ifdef XRENDER_LINK
+ XRenderChangePicture( mpDisplay, aPicture, nValueMask, pRenderAttr );
+#else
+ (*mpXRenderChangePicture)( mpDisplay, aPicture, nValueMask, pRenderAttr );
+#endif
+}
+
inline void XRenderPeer::SetPictureClipRegion( Picture aPicture,
XLIB_Region aXlibRegion ) const
{
diff --git a/vcl/unx/source/printergfx/common_gfx.cxx b/vcl/unx/source/printergfx/common_gfx.cxx
index 632f0d70aa2f..9b305ff323ba 100644
--- a/vcl/unx/source/printergfx/common_gfx.cxx
+++ b/vcl/unx/source/printergfx/common_gfx.cxx
@@ -7,7 +7,6 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: common_gfx.cxx,v $
- * $Revision: 1.20.18.1 $
*
* This file is part of OpenOffice.org.
*
@@ -535,68 +534,47 @@ PrinterGfx::DrawPolyLineBezier (sal_uInt32 nPoints, const Point* pPath, const BY
const sal_uInt32 nBezString = 1024;
sal_Char pString[nBezString];
- if ( maLineColor.Is() && nPoints && pPath )
+ if ( nPoints > 1 && maLineColor.Is() && pPath )
{
PSSetColor (maLineColor);
PSSetColor ();
PSSetLineWidth ();
- if (pFlgAry[0] != POLY_NORMAL) //There must be a starting point to moveto
- {
- return;
- }
- else
- {
- snprintf(pString, nBezString, "%li %li moveto\n", pPath[0].X(), pPath[0].Y());
- WritePS(mpPageBody, pString);
- }
+ snprintf(pString, nBezString, "%li %li moveto\n", pPath[0].X(), pPath[0].Y());
+ WritePS(mpPageBody, pString);
// Handle the drawing of mixed lines mixed with curves
// - a normal point followed by a normal point is a line
// - a normal point followed by 2 control points and a normal point is a curve
for (unsigned int i=1; i<nPoints;)
{
- if (pFlgAry[i+1] != POLY_CONTROL) //If the next point is a POLY_NORMAL, we're drawing a line
+ if (pFlgAry[i] != POLY_CONTROL) //If the next point is a POLY_NORMAL, we're drawing a line
{
- if (i+1 >= nPoints) return; //Make sure we don't pass the end of the array
snprintf(pString, nBezString, "%li %li lineto\n", pPath[i].X(), pPath[i].Y());
i++;
}
else //Otherwise we're drawing a spline
{
- if (i+3 >= nPoints) return; //Make sure we don't pass the end of the array
- snprintf(pString, nBezString, "%li %li %li %li %li %li curveto\n",
- pPath[i+1].X(), pPath[i+1].Y(),
- pPath[i+2].X(), pPath[i+2].Y(),
- pPath[i+3].X(), pPath[i+3].Y());
+ if (i+2 >= nPoints)
+ return; //Error: wrong sequence of contol/normal points somehow
+ if ((pFlgAry[i] == POLY_CONTROL) && (pFlgAry[i+1] == POLY_CONTROL) &&
+ (pFlgAry[i+2] != POLY_CONTROL))
+ {
+ snprintf(pString, nBezString, "%li %li %li %li %li %li curveto\n",
+ pPath[i].X(), pPath[i].Y(),
+ pPath[i+1].X(), pPath[i+1].Y(),
+ pPath[i+2].X(), pPath[i+2].Y());
+ }
+ else
+ {
+ DBG_ERROR( "PrinterGfx::DrawPolyLineBezier: Strange output" );
+ }
i+=3;
}
WritePS(mpPageBody, pString);
}
- }
-
- // if eofill and stroke, save the current path
- if( maFillColor.Is() && maLineColor.Is())
- PSGSave();
-
- // first draw area
- if( maFillColor.Is() )
- {
- PSSetColor (maFillColor);
- PSSetColor ();
- WritePS (mpPageBody, "eofill\n");
- }
-
- // restore the current path
- if( maFillColor.Is() && maLineColor.Is())
- PSGRestore();
- // now draw outlines
- if( maLineColor.Is() )
- {
- PSSetColor (maLineColor);
- PSSetColor ();
- PSSetLineWidth ();
+ // now draw outlines
WritePS (mpPageBody, "stroke\n");
}
}
@@ -635,7 +613,7 @@ PrinterGfx::DrawPolygonBezier (sal_uInt32 nPoints, const Point* pPath, const BYT
}
else
{
- fprintf(stderr, "Strange output\n");
+ DBG_ERROR( "PrinterGfx::DrawPolygonBezier: Strange output" );
}
i+=3;
}
@@ -699,9 +677,7 @@ PrinterGfx::DrawPolyPolygonBezier (sal_uInt32 nPoly, const sal_uInt32 * pPoints,
}
else
{
-#if OSL_DEBUG_LEVEL > 1
- fprintf(stderr, "Strange output\n");
-#endif
+ DBG_ERROR( "PrinterGfx::DrawPolyPolygonBezier: Strange output" );
}
j+=3;
}
diff --git a/vcl/win/source/gdi/salgdi3.cxx b/vcl/win/source/gdi/salgdi3.cxx
index 73f4d8320acc..d82830a9022f 100644
--- a/vcl/win/source/gdi/salgdi3.cxx
+++ b/vcl/win/source/gdi/salgdi3.cxx
@@ -557,7 +557,7 @@ static ImplDevFontAttributes WinFont2DevFontAttributes( const ENUMLOGFONTEXA& rE
if( 0 != (rMetric.ntmFlags & (NTM_TT_OPENTYPE | NTM_PS_OPENTYPE))
|| 0 != (rMetric.tmPitchAndFamily & TMPF_TRUETYPE))
aDFA.mbSubsettable = true;
- else if( 0 != (rMetric.tmPitchAndFamily & NTM_TYPE1) ) // TODO: implement subsetting for type1 too
+ else if( 0 != (rMetric.ntmFlags & NTM_TYPE1) ) // TODO: implement subsetting for type1 too
aDFA.mbEmbeddable = true;
// heuristics for font quality
@@ -636,7 +636,7 @@ static ImplDevFontAttributes WinFont2DevFontAttributes( const ENUMLOGFONTEXW& rE
if( 0 != (rMetric.ntmFlags & (NTM_TT_OPENTYPE | NTM_PS_OPENTYPE))
|| 0 != (rMetric.tmPitchAndFamily & TMPF_TRUETYPE))
aDFA.mbSubsettable = true;
- else if( 0 != (rMetric.tmPitchAndFamily & NTM_TYPE1) ) // TODO: implement subsetting for type1 too
+ else if( 0 != (rMetric.ntmFlags & NTM_TYPE1) ) // TODO: implement subsetting for type1 too
aDFA.mbEmbeddable = true;
// heuristics for font quality
@@ -2162,7 +2162,7 @@ void WinSalGraphics::GetDevFontList( ImplDevFontList* pFontList )
::rtl::OUString aExecutableFile( aPath );
aPath = aPath.copy( 0, aPath.lastIndexOf('/') );
String aFontDirUrl = aPath.copy( 0, aPath.lastIndexOf('/') );
- aFontDirUrl += String( RTL_CONSTASCII_USTRINGPARAM("/share/fonts/truetype") );
+ aFontDirUrl += String( RTL_CONSTASCII_USTRINGPARAM("/Basis/share/fonts/truetype") );
// collect fonts in font path that could not be registered
osl::Directory aFontDir( aFontDirUrl );
@@ -2723,7 +2723,8 @@ const void* WinSalGraphics::GetEmbedFontData( const ImplFontData* pFont,
TEXTMETRICA aTm;
if( !::GetTextMetricsA( mhDC, &aTm ) )
*pDataLen = 0;
- rInfo.m_nFontType = FontSubsetInfo::ANY_TYPE1;
+ const bool bPFA = (*aRawFontData.get() < 0x80);
+ rInfo.m_nFontType = bPFA ? FontSubsetInfo::TYPE1_PFA : FontSubsetInfo::TYPE1_PFB;
WCHAR aFaceName[64];
int nFNLen = ::GetTextFaceW( mhDC, 64, aFaceName );
// #i59854# strip eventual null byte