sw/source/core/doc/notxtfrm.cxx | 56 +++++++++++++++++++++---------------- sw/source/core/inc/frmtool.hxx | 7 ++++ sw/source/core/layout/paintfrm.cxx | 11 ++++++- 3 files changed, 49 insertions(+), 25 deletions(-)
New commits: commit 478e481e36add5c34788b718ef7a4b9dc4744424 Author: Michael Stahl <mst...@redhat.com> Date: Fri Feb 14 22:18:27 2014 +0100 fdo#68927: sw: fix painting of SVG page background There was a fix for a wrong constant resulting in too large image size in a1a0830d1ac3ffabbe35bd8a0264b64f1f7a9d67, and it turns out that painting of SVG backgrounds was relying on the wasteful rasterization: the SVG is rasterized only once (at the initial zoom level) and then cached, and now the correct image size for 100% is simply scaled up when zooming in. Fix that by painting SVGs with the drawing layer primitives instead, which appears to give better results. Change-Id: I4be16856fd080290526d4963d8c512beefa85363 (cherry picked from commit c9cdc1252374a04f866c0715cb582cc08935d92d) Reviewed-on: https://gerrit.libreoffice.org/8060 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Miklos Vajna <vmik...@collabora.co.uk> (cherry picked from commit 884aa71132efe05aed456a5ca0cfd69ca148939f) Reviewed-on: https://gerrit.libreoffice.org/8082 Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx index fb4abbf..c148fbc 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -733,6 +733,36 @@ bool paintUsingPrimitivesHelper( return false; } + +void paintGraphicUsingPrimitivesHelper(OutputDevice & rOutputDevice, + Graphic const& rGraphic, GraphicAttr const& rGraphicAttr, + SwRect const& rAlignedGrfArea) +{ + // unify using GraphicPrimitive2D + // -> the primitive handles all crop and mirror stuff + // -> the primitive renderer will create the needed pdf export data + // -> if bitmap content, it will be cached system-dependent + const basegfx::B2DRange aTargetRange( + rAlignedGrfArea.Left(), rAlignedGrfArea.Top(), + rAlignedGrfArea.Right(), rAlignedGrfArea.Bottom()); + const basegfx::B2DHomMatrix aTargetTransform( + basegfx::tools::createScaleTranslateB2DHomMatrix( + aTargetRange.getRange(), + aTargetRange.getMinimum())); + drawinglayer::primitive2d::Primitive2DSequence aContent(1); + + aContent[0] = new drawinglayer::primitive2d::GraphicPrimitive2D( + aTargetTransform, + rGraphic, + rGraphicAttr); + + paintUsingPrimitivesHelper( + rOutputDevice, + aContent, + aTargetRange, + aTargetRange); +} + /** Paint the graphic. We require either a QuickDraw-Bitmap or a graphic here. If we do not have @@ -855,30 +885,8 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons } else { - // unify using GraphicPrimitive2D - // -> the primitive handles all crop and mirror stuff - // -> the primitive renderer will create the needed pdf export data - // -> if bitmap conent, it will be cached system-dependent - const basegfx::B2DRange aTargetRange( - aAlignedGrfArea.Left(), aAlignedGrfArea.Top(), - aAlignedGrfArea.Right(), aAlignedGrfArea.Bottom()); - const basegfx::B2DHomMatrix aTargetTransform( - basegfx::tools::createScaleTranslateB2DHomMatrix( - aTargetRange.getRange(), - aTargetRange.getMinimum())); - drawinglayer::primitive2d::Primitive2DSequence aContent; - - aContent.realloc(1); - aContent[0] = new drawinglayer::primitive2d::GraphicPrimitive2D( - aTargetTransform, - rGrfObj.GetGraphic(), - aGrfAttr); - - paintUsingPrimitivesHelper( - *pOut, - aContent, - aTargetRange, - aTargetRange); + paintGraphicUsingPrimitivesHelper(*pOut, + rGrfObj.GetGraphic(), aGrfAttr, aAlignedGrfArea); } } else diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx index 3304351..02569bf 100644 --- a/sw/source/core/inc/frmtool.hxx +++ b/sw/source/core/inc/frmtool.hxx @@ -42,6 +42,8 @@ class XFillGradientItem; class SdrMarkList; class SwNodeIndex; class OutputDevice; +class Graphic; +class GraphicAttr; class SwPageDesc; #define FAR_AWAY LONG_MAX - 20000 // initial position of a Fly @@ -57,6 +59,11 @@ void DrawGraphic( const SvxBrushItem *, const XFillStyleItem*, const XFillGradie const SwRect &rOrg, const SwRect &rOut, const sal_uInt8 nGrfNum = GRFNUM_NO, const sal_Bool bConsiderBackgroundTransparency = sal_False ); +void paintGraphicUsingPrimitivesHelper( + OutputDevice & rOutputDevice, + Graphic const& rGraphic, GraphicAttr const& rGraphicAttr, + SwRect const& rAlignedGrfArea); + // method to align rectangle. // Created declaration here to avoid <extern> declarations void SwAlignRect( SwRect &rRect, const SwViewShell *pSh ); diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index a57df40..ba57797 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -1799,7 +1799,16 @@ static void lcl_DrawGraphic( const SvxBrushItem& rBrush, OutputDevice *pOut, /// Because for drawing a graphic left-top-corner and size coordinations are /// used, these coordinations have to be determined on pixel level. ::SwAlignGrfRect( &aAlignedGrfRect, *pOut ); - pGrf->DrawWithPDFHandling( *pOut, aAlignedGrfRect.Pos(), aAlignedGrfRect.SSize() ); + + if (pGrf->GetGraphic().getSvgData().get()) + { // fdo#68927 - SVGs are rasterized badly by DrawWithPDFHandling + paintGraphicUsingPrimitivesHelper(*pOut, + pGrf->GetGraphic(), pGrf->GetAttr(), aAlignedGrfRect); + } + else + { + pGrf->DrawWithPDFHandling( *pOut, aAlignedGrfRect.Pos(), aAlignedGrfRect.SSize() ); + } if ( bNotInside ) pOut->Pop();
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits