[Libreoffice-commits] core.git: Branch 'feature/fixes16' - include/vcl vcl/source

Marco Cecchetti marco.cecchetti at collabora.com
Fri Feb 19 13:49:48 UTC 2016


 include/vcl/pdfextoutdevdata.hxx    |    2 ++
 vcl/source/gdi/pdfextoutdevdata.cxx |   17 ++++++++++++++++-
 vcl/source/gdi/pdfwriter_impl.hxx   |    2 +-
 vcl/source/gdi/pdfwriter_impl2.cxx  |   35 ++++++++++++++++++++++++-----------
 4 files changed, 43 insertions(+), 13 deletions(-)

New commits:
commit 4906dfeeb78aa5ff3d2a23f452a8d706c98d1ee7
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Fri Feb 19 13:42:24 2016 +0100

    pdf export - jpeg exporting is too expensive - workaround
    
    Avoid to zip bitmap when the original image is a Jpeg
    
    Conflicts:
    	vcl/source/gdi/pdfextoutdevdata.cxx
    
    Change-Id: I396759ca40ed3730bb29585370b2f8900fcc693c

diff --git a/include/vcl/pdfextoutdevdata.hxx b/include/vcl/pdfextoutdevdata.hxx
index 477f668..7efc561 100644
--- a/include/vcl/pdfextoutdevdata.hxx
+++ b/include/vcl/pdfextoutdevdata.hxx
@@ -146,6 +146,8 @@ public:
 
     std::vector< PDFExtOutDevBookmarkEntry >& GetBookmarks() { return maBookmarks;}
 
+    const 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..8acd537 100644
--- a/vcl/source/gdi/pdfextoutdevdata.cxx
+++ b/vcl/source/gdi/pdfextoutdevdata.cxx
@@ -294,13 +294,18 @@ struct PageSyncData
     std::deque< PDFWriter::StructAttribute >        mParaStructAttributes;
     std::deque< PDFWriter::StructAttributeValue >   mParaStructAttributeValues;
     std::deque< Graphic >                           mGraphics;
+    Graphic*                                        mpCurrentGraphic;
     std::deque< std::shared_ptr< PDFWriter::AnyWidget > >
                                                     mControls;
     GlobalSyncData*                                 mpGlobalData;
 
     bool                                        mbGroupIgnoreGDIMtfActions;
 
-    explicit PageSyncData( GlobalSyncData* pGlobal ) : mbGroupIgnoreGDIMtfActions ( false ) { mpGlobalData = pGlobal; }
+
+    explicit PageSyncData( GlobalSyncData* pGlobal )
+        : mpCurrentGraphic ( nullptr )
+        , mbGroupIgnoreGDIMtfActions ( false )
+    { mpGlobalData = pGlobal; }
 
     void PushAction( const OutputDevice& rOutDev, const PDFExtOutDevDataSync::Action eAct );
     bool PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAction, const PDFExtOutDevData& rOutDevData );
@@ -410,6 +415,7 @@ bool PageSyncData::PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAc
                             {
                                 mbGroupIgnoreGDIMtfActions = true;
                             }
+                            mpCurrentGraphic = mbGroupIgnoreGDIMtfActions ? nullptr : &rGraphic;
                         }
                         break;
                     }
@@ -464,6 +470,10 @@ bool PageSyncData::PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAc
                     }
                     mbGroupIgnoreGDIMtfActions = false;
                 }
+                else
+                {
+                    mpCurrentGraphic = nullptr;
+                }
             }
             break;
             case PDFExtOutDevDataSync::CreateNamedDest:
@@ -516,6 +526,11 @@ PDFExtOutDevData::~PDFExtOutDevData()
     delete mpGlobalSyncData;
 }
 
+const Graphic* PDFExtOutDevData::GetCurrentGraphic() const
+{
+    return mpPageSyncData->mpCurrentGraphic;
+}
+
 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..d4d8f3a 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, const 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..9a45748 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, const Graphic* i_pGraphic,
                                        VirtualDevice* i_pDummyVDev, const vcl::PDFWriter::PlayMetafileContext& i_rContext )
 {
     if ( !i_rBitmapEx.IsEmpty() && i_rSize.Width() && i_rSize.Height() )
@@ -95,6 +95,9 @@ void PDFWriterImpl::implWriteBitmapEx( const Point& i_rPoint, const Size& i_rSiz
         {
             aBitmapEx.Mirror( nMirrorFlags );
         }
+
+        bool bIsJpeg = i_pGraphic && (i_pGraphic->GetBitmapEx() == aBitmapEx);
+
         if( i_rContext.m_nMaxImageResolution > 50 )
         {
             // do downsampling if necessary
@@ -160,8 +163,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 +208,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 +487,8 @@ 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 );
+                                const Graphic* pGraphic = i_pOutDevData->GetCurrentGraphic();
+                                implWriteBitmapEx( rPos, rSize, BitmapEx( aPaint, aAlpha ), pGraphic,pDummyVDev, i_rContext );
                             }
                         }
                     }
@@ -781,14 +787,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 );
+
+                    const Graphic* pGraphic = i_pOutDevData->GetCurrentGraphic();
+                    implWriteBitmapEx( pA->GetPoint(), aSize, aBitmapEx, pGraphic, 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 );
+                    const Graphic* pGraphic = i_pOutDevData->GetCurrentGraphic();
+                    implWriteBitmapEx( pA->GetPoint(), pA->GetSize(), BitmapEx( pA->GetBitmap() ), pGraphic, pDummyVDev, i_rContext );
                 }
                 break;
 
@@ -797,7 +806,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 );
+                    const Graphic* pGraphic = i_pOutDevData->GetCurrentGraphic();
+                    implWriteBitmapEx( pA->GetDestPoint(), pA->GetDestSize(), aBitmapEx, pGraphic, pDummyVDev, i_rContext );
                 }
                 break;
 
@@ -807,14 +817,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 );
+                    const Graphic* pGraphic = i_pOutDevData->GetCurrentGraphic();
+                    implWriteBitmapEx( pA->GetPoint(), aSize, aBitmapEx, pGraphic, 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 );
+                    const Graphic* pGraphic = i_pOutDevData->GetCurrentGraphic();
+                    implWriteBitmapEx( pA->GetPoint(), pA->GetSize(), pA->GetBitmapEx(), pGraphic, pDummyVDev, i_rContext );
                 }
                 break;
 
@@ -823,7 +835,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 );
+                    const Graphic* pGraphic = i_pOutDevData->GetCurrentGraphic();
+                    implWriteBitmapEx( pA->GetDestPoint(), pA->GetDestSize(), aBitmapEx, pGraphic, pDummyVDev, i_rContext );
                 }
                 break;
 


More information about the Libreoffice-commits mailing list