[Libreoffice-commits] core.git: sd/source vcl/source
Jan Holesovsky (via logerrit)
logerrit at kemper.freedesktop.org
Sun Aug 25 11:35:28 UTC 2019
sd/source/filter/pdf/sdpdffilter.cxx | 10 ++++++++--
vcl/source/filter/ipdf/pdfread.cxx | 11 ++++++++---
vcl/source/gdi/impgraph.cxx | 10 ++++++++++
3 files changed, 26 insertions(+), 5 deletions(-)
New commits:
commit 81f73f1c1706d790c010e8fc0abcb2a0e9e86ace
Author: Jan Holesovsky <kendy at collabora.com>
AuthorDate: Fri Jun 22 12:58:12 2018 +0200
Commit: Ashod Nakashian <ashnakash at gmail.com>
CommitDate: Sun Aug 25 13:34:17 2019 +0200
pdfium: Delay the swap out.
If we swap out too early, the constructor of GraphicObject forces a swap
in, so we'd render everything during the load anyway.
Change-Id: I0ea1a755242fd57ef28d082ce4bf534a32199f87
Reviewed-on: https://gerrit.libreoffice.org/56286
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
(cherry picked from commit 242c7663e275a712430a8c4ac8eeacbb8b3bd440)
Reviewed-on: https://gerrit.libreoffice.org/77690
Tested-by: Jenkins
diff --git a/sd/source/filter/pdf/sdpdffilter.cxx b/sd/source/filter/pdf/sdpdffilter.cxx
index cbd83075338d..88986fe0e477 100644
--- a/sd/source/filter/pdf/sdpdffilter.cxx
+++ b/sd/source/filter/pdf/sdpdffilter.cxx
@@ -86,8 +86,14 @@ bool SdPdfFilter::Import()
pPage->SetSize(aGrfSize);
Point aPos(0, 0);
- pPage->InsertObject(new SdrGrafObj(pPage->getSdrModelFromSdrPage(), rGraphic,
- tools::Rectangle(aPos, aGrfSize)));
+ SdrGrafObj* pSdrGrafObj = new SdrGrafObj(pPage->getSdrModelFromSdrPage(), rGraphic,
+ tools::Rectangle(aPos, aGrfSize));
+ pPage->InsertObject(pSdrGrafObj);
+
+ // we know that the initial bitmap we provided was just a placeholder,
+ // we need to swap it out, so that on the next swap in, we render the
+ // correct one
+ // const_cast<GraphicObject&>(pSdrGrafObj->GetGraphicObject()).SwapOut();
}
return true;
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index 3687f301b2e9..b7b43c1d0d4d 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -312,6 +312,9 @@ size_t ImportPDFUnloaded(const OUString& rURL, std::vector<std::pair<Graphic, Si
if (nPageCount <= 0)
return 0;
+ // dummy Bitmap
+ Bitmap aBitmap(Size(1, 1), 24);
+
for (size_t nPageIndex = 0; nPageIndex < static_cast<size_t>(nPageCount); ++nPageIndex)
{
double fPageWidth = 0;
@@ -323,9 +326,11 @@ size_t ImportPDFUnloaded(const OUString& rURL, std::vector<std::pair<Graphic, Si
const size_t nPageWidth = pointToPixel(fPageWidth, fResolutionDPI);
const size_t nPageHeight = pointToPixel(fPageHeight, fResolutionDPI);
- // Create the Graphic and link the original PDF stream.
- Graphic aGraphic;
- aGraphic.setPdfData(pPdfData); // TODO: Skip if unchanged.
+ // Create the Graphic with a dummy Bitmap and link the original PDF stream.
+ // We swap out this Graphic as soon as possible, and a later swap in
+ // actually renders the correct Bitmap on demand.
+ Graphic aGraphic(aBitmap);
+ aGraphic.setPdfData(pPdfData);
aGraphic.setPageNumber(nPageIndex);
aGraphic.SetGfxLink(pGfxLink);
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 8b283081b966..7547853eba2a 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -123,6 +123,16 @@ GraphicID::GraphicID(ImpGraphic const & rGraphic)
mnID3 = basegfx::fround(rRange.getHeight());
mnID4 = vcl_get_checksum(0, rVectorGraphicDataPtr->getVectorGraphicDataArray().getConstArray(), rVectorGraphicDataPtr->getVectorGraphicDataArrayLength());
}
+ else if (rGraphic.hasPdfData())
+ {
+ std::shared_ptr<css::uno::Sequence<sal_Int8>> pPdfData = rGraphic.getPdfData();
+ const BitmapEx& rBmpEx = rGraphic.ImplGetBitmapExRef();
+
+ mnID1 |= (rGraphic.mnPageNumber & 0x0fffffff);
+ mnID2 = rBmpEx.GetSizePixel().Width();
+ mnID3 = rBmpEx.GetSizePixel().Height();
+ mnID4 = vcl_get_checksum(0, pPdfData->getConstArray(), pPdfData->getLength());
+ }
else if (rGraphic.ImplIsAnimated())
{
const Animation aAnimation(rGraphic.ImplGetAnimation());
More information about the Libreoffice-commits
mailing list