[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - 2 commits - include/vcl vcl/source
Michael Meeks
michael.meeks at collabora.com
Wed Feb 24 13:42:29 UTC 2016
include/vcl/pdfextoutdevdata.hxx | 2 +
vcl/source/app/scheduler.cxx | 14 -----------
vcl/source/app/svapp.cxx | 18 +++++++++++++-
vcl/source/gdi/pdfextoutdevdata.cxx | 27 ++++++++++++++++++----
vcl/source/gdi/pdfwriter_impl.hxx | 2 -
vcl/source/gdi/pdfwriter_impl2.cxx | 44 ++++++++++++++++++++++++++----------
6 files changed, 74 insertions(+), 33 deletions(-)
New commits:
commit c5292a52b20466f0259f638332452c4a87e038a8
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Thu Feb 18 21:18:28 2016 +0000
Ensure processEventsToIdle process events (including from the OS) until idle.
Change-Id: I9578849b0e78af15ddeb1e6495a48ccfb3f1c44a
Reviewed-on: https://gerrit.libreoffice.org/22651
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
(cherry picked from commit b952aaacb1a6ef628226ef2699fac9fab936f20b)
Reviewed-on: https://gerrit.libreoffice.org/22652
Reviewed-by: Andras Timar <andras.timar at collabora.com>
diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx
index 9450393..879ca42 100644
--- a/vcl/source/app/scheduler.cxx
+++ b/vcl/source/app/scheduler.cxx
@@ -174,20 +174,6 @@ bool Scheduler::ProcessTaskScheduling( bool bTimerOnly )
return false;
}
-void Scheduler::ProcessEventsToIdle()
-{
- // FIXME: really we should process incoming OS events too ...
- int nSanity = 1000;
- while (Scheduler::ProcessTaskScheduling(false))
- {
- if (nSanity-- < 0)
- {
- SAL_WARN("vcl.schedule", "Unexpected volume of events to process");
- break;
- }
- }
-}
-
sal_uInt64 Scheduler::CalculateMinimumTimeout( bool &bHasActiveIdles )
{
// process all pending Tasks
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 0270b8c..a75a6db 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -473,7 +473,7 @@ void Application::Execute()
pSVData->maAppData.mbInAppExecute = false;
}
-inline void ImplYield(bool i_bWait, bool i_bAllEvents, sal_uLong const nReleased)
+inline bool ImplYield(bool i_bWait, bool i_bAllEvents, sal_uLong const nReleased)
{
ImplSVData* pSVData = ImplGetSVData();
@@ -523,6 +523,8 @@ inline void ImplYield(bool i_bWait, bool i_bAllEvents, sal_uLong const nReleased
vcl::LazyDelete::flush();
SAL_INFO("vcl.schedule", "Leave ImplYield");
+
+ return bHasActiveIdles || eResult == SalYieldResult::EVENT;
}
void Application::Reschedule( bool i_bAllEvents )
@@ -530,6 +532,20 @@ void Application::Reschedule( bool i_bAllEvents )
ImplYield(false, i_bAllEvents, 0);
}
+void Scheduler::ProcessEventsToIdle()
+{
+ int nSanity = 1000;
+ while(Scheduler::ProcessTaskScheduling(false) ||
+ ImplYield(false, false, 0))
+ {
+ if (nSanity-- < 0)
+ {
+ SAL_WARN("vcl.schedule", "Unexpected volume of events to process");
+ break;
+ }
+ }
+}
+
void Application::Yield()
{
ImplYield(true, false, 0);
commit 2ee228e179d98630bc69cef8b13a55c0edbe9e1b
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date: Fri Feb 19 13:42:24 2016 +0100
tdf#97662 - Try to preserve original compressed JPEGs harder.
Avoiding de-compressing and re-compressing them saves lots of
time too. Avoid PNG compressing de-compressed JPEGs, and avoid
JPEG compressing de-compressed PNGs.
Change-Id: Iafa5d4b347da46dedb9431b6870f34b2b6fcad99
Reviewed-on: https://gerrit.libreoffice.org/22656
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
diff --git a/include/vcl/pdfextoutdevdata.hxx b/include/vcl/pdfextoutdevdata.hxx
index 477f668..1140180 100644
--- a/include/vcl/pdfextoutdevdata.hxx
+++ b/include/vcl/pdfextoutdevdata.hxx
@@ -146,6 +146,8 @@ public:
std::vector< PDFExtOutDevBookmarkEntry >& GetBookmarks() { return maBookmarks;}
+ Graphic GetCurrentGraphic() const;
+
/** Start a new group of render output
Use this method to group render output.
diff --git a/vcl/source/gdi/pdfextoutdevdata.cxx b/vcl/source/gdi/pdfextoutdevdata.cxx
index 8212f85..0466cfb 100644
--- a/vcl/source/gdi/pdfextoutdevdata.cxx
+++ b/vcl/source/gdi/pdfextoutdevdata.cxx
@@ -294,13 +294,17 @@ struct PageSyncData
std::deque< PDFWriter::StructAttribute > mParaStructAttributes;
std::deque< PDFWriter::StructAttributeValue > mParaStructAttributeValues;
std::deque< Graphic > mGraphics;
+ Graphic mCurrentGraphic;
std::deque< std::shared_ptr< PDFWriter::AnyWidget > >
mControls;
GlobalSyncData* mpGlobalData;
bool mbGroupIgnoreGDIMtfActions;
- explicit PageSyncData( GlobalSyncData* pGlobal ) : mbGroupIgnoreGDIMtfActions ( false ) { mpGlobalData = pGlobal; }
+
+ explicit PageSyncData( GlobalSyncData* pGlobal )
+ : mbGroupIgnoreGDIMtfActions ( false )
+ { mpGlobalData = pGlobal; }
void PushAction( const OutputDevice& rOutDev, const PDFExtOutDevDataSync::Action eAct );
bool PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAction, const PDFExtOutDevData& rOutDevData );
@@ -403,12 +407,19 @@ bool PageSyncData::PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAc
}
else if ( aBeg->eAct == PDFExtOutDevDataSync::EndGroupGfxLink )
{
- if ( rOutDevData.GetIsLosslessCompression() && !rOutDevData.GetIsReduceImageResolution() )
+ Graphic& rGraphic = mGraphics.front();
+ if ( rGraphic.IsLink() )
{
- Graphic& rGraphic = mGraphics.front();
- if ( rGraphic.IsLink() && rGraphic.GetLink().GetType() == GFX_LINK_TYPE_NATIVE_JPG )
+ GfxLinkType eType = rGraphic.GetLink().GetType();
+ if ( eType == GFX_LINK_TYPE_NATIVE_JPG )
+ {
+ mbGroupIgnoreGDIMtfActions = rOutDevData.GetIsLosslessCompression() && !rOutDevData.GetIsReduceImageResolution();
+ if ( !mbGroupIgnoreGDIMtfActions )
+ mCurrentGraphic = rGraphic;
+ }
+ else if ( eType == GFX_LINK_TYPE_NATIVE_PNG )
{
- mbGroupIgnoreGDIMtfActions = true;
+ mCurrentGraphic = rGraphic;
}
}
break;
@@ -464,6 +475,7 @@ bool PageSyncData::PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAc
}
mbGroupIgnoreGDIMtfActions = false;
}
+ mCurrentGraphic.Clear();
}
break;
case PDFExtOutDevDataSync::CreateNamedDest:
@@ -516,6 +528,11 @@ PDFExtOutDevData::~PDFExtOutDevData()
delete mpGlobalSyncData;
}
+Graphic PDFExtOutDevData::GetCurrentGraphic() const
+{
+ return mpPageSyncData->mCurrentGraphic;
+}
+
void PDFExtOutDevData::SetDocumentLocale( const css::lang::Locale& rLoc )
{
maDocLocale = rLoc;
diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx
index 77b0d47..306bb15 100644
--- a/vcl/source/gdi/pdfwriter_impl.hxx
+++ b/vcl/source/gdi/pdfwriter_impl.hxx
@@ -1011,7 +1011,7 @@ i12626
// helper for playMetafile
void implWriteGradient( const tools::PolyPolygon& rPolyPoly, const Gradient& rGradient,
VirtualDevice* pDummyVDev, const vcl::PDFWriter::PlayMetafileContext& );
- void implWriteBitmapEx( const Point& rPoint, const Size& rSize, const BitmapEx& rBitmapEx,
+ void implWriteBitmapEx( const Point& rPoint, const Size& rSize, const BitmapEx& rBitmapEx, Graphic i_pGraphic,
VirtualDevice* pDummyVDev, const vcl::PDFWriter::PlayMetafileContext& );
// helpers for CCITT 1bit bitmap stream
diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx
index 8e47b84..0d14428 100644
--- a/vcl/source/gdi/pdfwriter_impl2.cxx
+++ b/vcl/source/gdi/pdfwriter_impl2.cxx
@@ -65,7 +65,7 @@ void PDFWriterImpl::implWriteGradient( const tools::PolyPolygon& i_rPolyPoly, co
m_rOuterFace.Pop();
}
-void PDFWriterImpl::implWriteBitmapEx( const Point& i_rPoint, const Size& i_rSize, const BitmapEx& i_rBitmapEx,
+void PDFWriterImpl::implWriteBitmapEx( const Point& i_rPoint, const Size& i_rSize, const BitmapEx& i_rBitmapEx, Graphic i_Graphic,
VirtualDevice* i_pDummyVDev, const vcl::PDFWriter::PlayMetafileContext& i_rContext )
{
if ( !i_rBitmapEx.IsEmpty() && i_rSize.Width() && i_rSize.Height() )
@@ -95,6 +95,15 @@ void PDFWriterImpl::implWriteBitmapEx( const Point& i_rPoint, const Size& i_rSiz
{
aBitmapEx.Mirror( nMirrorFlags );
}
+
+ bool bIsJpeg = false, bIsPng = false;
+ if( i_Graphic.GetType() != GRAPHIC_NONE && i_Graphic.GetBitmapEx() == aBitmapEx )
+ {
+ GfxLinkType eType = i_Graphic.GetLink().GetType();
+ bIsJpeg = (eType == GFX_LINK_TYPE_NATIVE_JPG);
+ bIsPng = (eType == GFX_LINK_TYPE_NATIVE_PNG);
+ }
+
if( i_rContext.m_nMaxImageResolution > 50 )
{
// do downsampling if necessary
@@ -151,7 +160,7 @@ void PDFWriterImpl::implWriteBitmapEx( const Point& i_rPoint, const Size& i_rSiz
aBitmapEx.Convert( eConv );
}
bool bUseJPGCompression = !i_rContext.m_bOnlyLosslessCompression;
- if ( ( aSizePixel.Width() < 32 ) || ( aSizePixel.Height() < 32 ) )
+ if ( bIsPng || ( aSizePixel.Width() < 32 ) || ( aSizePixel.Height() < 32 ) )
bUseJPGCompression = false;
SvMemoryStream aStrm;
@@ -160,8 +169,10 @@ void PDFWriterImpl::implWriteBitmapEx( const Point& i_rPoint, const Size& i_rSiz
bool bTrueColorJPG = true;
if ( bUseJPGCompression )
{
- sal_uInt32 nZippedFileSize; // sj: we will calculate the filesize of a zipped bitmap
- { // to determine if jpeg compression is useful
+
+ sal_uInt32 nZippedFileSize = 0; // sj: we will calculate the filesize of a zipped bitmap
+ if ( !bIsJpeg ) // to determine if jpeg compression is useful
+ {
SvMemoryStream aTemp;
aTemp.SetCompressMode( aTemp.GetCompressMode() | SvStreamCompressFlags::ZBITMAP );
aTemp.SetVersion( SOFFICE_FILEFORMAT_40 ); // sj: up from version 40 our bitmap stream operator
@@ -203,7 +214,7 @@ void PDFWriterImpl::implWriteBitmapEx( const Point& i_rPoint, const Size& i_rSiz
aOutMediaProperties[2].Value <<= aFilterData;
xGraphicProvider->storeGraphic( xGraphic, aOutMediaProperties );
xOut->flush();
- if ( xSeekable->getLength() > nZippedFileSize )
+ if ( !bIsJpeg && xSeekable->getLength() > nZippedFileSize )
{
bUseJPGCompression = false;
}
@@ -482,7 +493,9 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa
xVDev->EnableMapMode( false );
xVDev->DrawMask( aPoint, aDstSizePixel, aMask, Color( COL_WHITE ) );
aAlpha = xVDev->GetBitmap( aPoint, aDstSizePixel );
- implWriteBitmapEx( rPos, rSize, BitmapEx( aPaint, aAlpha ), pDummyVDev, i_rContext );
+
+ Graphic aGraphic = i_pOutDevData ? i_pOutDevData->GetCurrentGraphic() : Graphic();
+ implWriteBitmapEx( rPos, rSize, BitmapEx( aPaint, aAlpha ), aGraphic, pDummyVDev, i_rContext );
}
}
}
@@ -781,14 +794,17 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa
aBitmapEx.GetPrefMapMode(), pDummyVDev->GetMapMode() ) );
if( ! ( aSize.Width() && aSize.Height() ) )
aSize = pDummyVDev->PixelToLogic( aBitmapEx.GetSizePixel() );
- implWriteBitmapEx( pA->GetPoint(), aSize, aBitmapEx, pDummyVDev, i_rContext );
+
+ Graphic aGraphic = i_pOutDevData ? i_pOutDevData->GetCurrentGraphic() : Graphic();
+ implWriteBitmapEx( pA->GetPoint(), aSize, aBitmapEx, aGraphic, pDummyVDev, i_rContext );
}
break;
case( MetaActionType::BMPSCALE ):
{
const MetaBmpScaleAction* pA = static_cast<const MetaBmpScaleAction*>(pAction);
- implWriteBitmapEx( pA->GetPoint(), pA->GetSize(), BitmapEx( pA->GetBitmap() ), pDummyVDev, i_rContext );
+ Graphic aGraphic = i_pOutDevData ? i_pOutDevData->GetCurrentGraphic() : Graphic();
+ implWriteBitmapEx( pA->GetPoint(), pA->GetSize(), BitmapEx( pA->GetBitmap() ), aGraphic, pDummyVDev, i_rContext );
}
break;
@@ -797,7 +813,8 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa
const MetaBmpScalePartAction* pA = static_cast<const MetaBmpScalePartAction*>(pAction);
BitmapEx aBitmapEx( pA->GetBitmap() );
aBitmapEx.Crop( Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) );
- implWriteBitmapEx( pA->GetDestPoint(), pA->GetDestSize(), aBitmapEx, pDummyVDev, i_rContext );
+ Graphic aGraphic = i_pOutDevData ? i_pOutDevData->GetCurrentGraphic() : Graphic();
+ implWriteBitmapEx( pA->GetDestPoint(), pA->GetDestSize(), aBitmapEx, aGraphic, pDummyVDev, i_rContext );
}
break;
@@ -807,14 +824,16 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa
BitmapEx aBitmapEx( pA->GetBitmapEx() );
Size aSize( OutputDevice::LogicToLogic( aBitmapEx.GetPrefSize(),
aBitmapEx.GetPrefMapMode(), pDummyVDev->GetMapMode() ) );
- implWriteBitmapEx( pA->GetPoint(), aSize, aBitmapEx, pDummyVDev, i_rContext );
+ Graphic aGraphic = i_pOutDevData ? i_pOutDevData->GetCurrentGraphic() : Graphic();
+ implWriteBitmapEx( pA->GetPoint(), aSize, aBitmapEx, aGraphic, pDummyVDev, i_rContext );
}
break;
case( MetaActionType::BMPEXSCALE ):
{
const MetaBmpExScaleAction* pA = static_cast<const MetaBmpExScaleAction*>(pAction);
- implWriteBitmapEx( pA->GetPoint(), pA->GetSize(), pA->GetBitmapEx(), pDummyVDev, i_rContext );
+ Graphic aGraphic = i_pOutDevData ? i_pOutDevData->GetCurrentGraphic() : Graphic();
+ implWriteBitmapEx( pA->GetPoint(), pA->GetSize(), pA->GetBitmapEx(), aGraphic, pDummyVDev, i_rContext );
}
break;
@@ -823,7 +842,8 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa
const MetaBmpExScalePartAction* pA = static_cast<const MetaBmpExScalePartAction*>(pAction);
BitmapEx aBitmapEx( pA->GetBitmapEx() );
aBitmapEx.Crop( Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) );
- implWriteBitmapEx( pA->GetDestPoint(), pA->GetDestSize(), aBitmapEx, pDummyVDev, i_rContext );
+ Graphic aGraphic = i_pOutDevData ? i_pOutDevData->GetCurrentGraphic() : Graphic();
+ implWriteBitmapEx( pA->GetDestPoint(), pA->GetDestSize(), aBitmapEx, aGraphic, pDummyVDev, i_rContext );
}
break;
More information about the Libreoffice-commits
mailing list