[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - filter/source include/svx svx/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Wed Feb 26 08:59:43 UTC 2020
filter/source/svg/svgwriter.cxx | 45 ++++++++++++++++++++++++++++++----------
include/svx/svdograf.hxx | 9 --------
svx/source/svdraw/svdograf.cxx | 22 -------------------
3 files changed, 34 insertions(+), 42 deletions(-)
New commits:
commit 5aae00b8a9400dad43004081db69996c24157641
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Feb 25 11:28:44 2020 +0100
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Wed Feb 26 09:59:13 2020 +0100
SVG export: try to reuse original bitmap data for JPG and PNG bitmaps
This has a number of benefits:
1) For a sample JPG photo, the SVG output is now 4,9MB, not 20MB.
2) Even the first export to SVG is fast, see commit
570be56b37e4ff105649e604ff4c8a6c368e2e79 (svx: cache PNG export of
graphic shapes, 2020-02-25) for exact numbers.
3) Allow using less memory as the SdrGrafObj doesn't have to store a PNG
result till the document is closed.
We still require matching checksums, so in case anything problematic
happens with the bitmap (grayscale filter applied, etc), then the
optimization is meant to not help, but still produces correct output.
(cherry picked from commit c7af36a6504a192f72fcd3a30712ca8c14e12fa5)
Conflicts:
include/svx/svdograf.hxx
Change-Id: Id3bc359a8dcc4c4d12d3b66ffb512cfa71939a26
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89465
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx
index 956651e41d01..d9f7dc48bf08 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -2716,29 +2716,52 @@ void SVGActionWriter::ImplWriteBmp( const BitmapEx& rBmpEx,
bool bCached = false;
SdrGrafObj* pGrafObj = nullptr;
+ bool bPNG = false;
+ bool bJPG = false;
if (pShape)
{
pGrafObj = GetSdrGrafObjFromXShape(pShape);
- if (pGrafObj && pGrafObj->GetPNGPreviewChecksum() == rBmpEx.GetChecksum())
+ if (pGrafObj)
{
- const std::vector<sal_Int8>& rPreviewData = pGrafObj->GetPNGPreviewData();
- aOStm.WriteBytes(rPreviewData.data(), rPreviewData.size());
- bCached = true;
+ const Graphic& rGraphic = pGrafObj->GetGraphic();
+ if (rGraphic.GetType() == GraphicType::Bitmap)
+ {
+ const BitmapEx& rGraphicBitmap = rGraphic.GetBitmapExRef();
+ if (rGraphicBitmap.GetChecksum() == rBmpEx.GetChecksum())
+ {
+ GfxLink aGfxLink = rGraphic.GetGfxLink();
+ if (aGfxLink.GetType() == GfxLinkType::NativePng)
+ {
+ bPNG = true;
+ }
+ else if (aGfxLink.GetType() == GfxLinkType::NativeJpg)
+ {
+ bJPG = true;
+ }
+ if (bPNG || bJPG)
+ {
+ aOStm.WriteBytes(aGfxLink.GetData(), aGfxLink.GetDataSize());
+ bCached = true;
+ }
+ }
+ }
}
}
if( bCached || GraphicConverter::Export( aOStm, rBmpEx, ConvertDataFormat::PNG ) == ERRCODE_NONE )
{
- if (!bCached && pGrafObj)
- {
- pGrafObj->SetPNGPreviewChecksum(rBmpEx.GetChecksum());
- pGrafObj->SetPNGPreviewData(aOStm);
- }
-
Point aPt;
Size aSz;
Sequence< sal_Int8 > aSeq( static_cast<sal_Int8 const *>(aOStm.GetData()), aOStm.Tell() );
- OUStringBuffer aBuffer( "data:image/png;base64," );
+ OUStringBuffer aBuffer;
+ if (bJPG)
+ {
+ aBuffer.append("data:image/jpeg;base64,");
+ }
+ else
+ {
+ aBuffer.append("data:image/png;base64,");
+ }
::comphelper::Base64::encode( aBuffer, aSeq );
ImplMap( rPt, aPt );
diff --git a/include/svx/svdograf.hxx b/include/svx/svdograf.hxx
index 966cb3893b9b..c3e2ae0c1874 100644
--- a/include/svx/svdograf.hxx
+++ b/include/svx/svdograf.hxx
@@ -28,7 +28,6 @@
#include <vcl/GraphicObject.hxx>
#include <svx/svxdllapi.h>
#include <o3tl/typed_flags_set.hxx>
-#include <tools/stream.hxx>
namespace sdr
{
@@ -122,9 +121,6 @@ private:
void onGraphicChanged();
GDIMetaFile GetMetaFile(GraphicType &rGraphicType) const;
- BitmapChecksum mnPNGPreviewChecksum = 0;
- std::vector<sal_Int8> maPNGPreviewData;
-
protected:
// protected destructor
virtual ~SdrGrafObj() override;
@@ -287,11 +283,6 @@ public:
};
bool isSignatureLineSigned() const { return mbSignatureLineIsSigned; };
void setSignatureLineIsSigned(bool bIsSigned) { mbSignatureLineIsSigned = bIsSigned; }
-
- void SetPNGPreviewChecksum(BitmapChecksum nPNGPreviewChecksum);
- BitmapChecksum GetPNGPreviewChecksum() const;
- void SetPNGPreviewData(SvMemoryStream& rPNGPreviewData);
- const std::vector<sal_Int8>& GetPNGPreviewData() const;
};
#endif // INCLUDED_SVX_SVDOGRAF_HXX
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index b68aec25b2a3..0e4413b3764f 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -1265,26 +1265,4 @@ void SdrGrafObj::addCropHandles(SdrHdlList& rTarget) const
rTarget.AddHdl(o3tl::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::LowerRight, fShearX, fRotate));
}
-void SdrGrafObj::SetPNGPreviewChecksum(BitmapChecksum nPNGPreviewChecksum)
-{
- mnPNGPreviewChecksum = nPNGPreviewChecksum;
-}
-
-BitmapChecksum SdrGrafObj::GetPNGPreviewChecksum() const
-{
- return mnPNGPreviewChecksum;
-}
-
-void SdrGrafObj::SetPNGPreviewData(SvMemoryStream& rPNGPreviewData)
-{
- rPNGPreviewData.Seek(0);
- maPNGPreviewData.resize(rPNGPreviewData.remainingSize());
- rPNGPreviewData.ReadBytes(maPNGPreviewData.data(), maPNGPreviewData.size());
-}
-
-const std::vector<sal_Int8>& SdrGrafObj::GetPNGPreviewData() const
-{
- return maPNGPreviewData;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list