[Libreoffice-commits] core.git: include/vcl vcl/inc vcl/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jan 22 06:49:59 UTC 2021
include/vcl/graph.hxx | 1 +
vcl/inc/graphic/Manager.hxx | 3 +++
vcl/inc/impgraph.hxx | 1 +
vcl/source/filter/ipdf/pdfread.cxx | 6 +-----
vcl/source/gdi/graph.cxx | 5 +++++
vcl/source/gdi/impgraph.cxx | 17 +++++++++++++++++
vcl/source/graphic/Manager.cxx | 8 ++++++++
7 files changed, 36 insertions(+), 5 deletions(-)
New commits:
commit 3adff41ab14ab27ca07cffef0f38471ac5321ee2
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sat Jan 2 00:12:25 2021 +0900
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Fri Jan 22 07:49:17 2021 +0100
vcl: support creating a Graphic with only GfxLink as swapped-out
This adds support to create a Graphic with only a GfxLink and the
Graphic is in a swapped-out state. This is similar to the prepared
state, but the prepared state is a special state of the Graphic.
In the future, all loading will probably be done in this way and
prepared state will go away, but for now this is only supported
for PDF and is used in PDFium import only.
The main reason is to avoid that a multi-page PDF is immediately
swapped out after loading, which just does unneeded work and
freezes the application for a while.
Change-Id: I409741d27a4ad309264cdf27b2ba03f2cf37ead9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109600
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/include/vcl/graph.hxx b/include/vcl/graph.hxx
index 86d885a326ac..79083bb5a224 100644
--- a/include/vcl/graph.hxx
+++ b/include/vcl/graph.hxx
@@ -89,6 +89,7 @@ public:
SAL_DLLPRIVATE ImpGraphic* ImplGetImpGraphic() const { return mxImpGraphic.get(); }
Graphic();
+ Graphic(std::shared_ptr<GfxLink> const & rGfxLink, sal_Int32 nPageIndex = 0);
Graphic( const GraphicExternalLink& rGraphicLink );
Graphic( const Graphic& rGraphic );
Graphic( Graphic&& rGraphic ) noexcept;
diff --git a/vcl/inc/graphic/Manager.hxx b/vcl/inc/graphic/Manager.hxx
index 098c8644ac61..4319620e21c4 100644
--- a/vcl/inc/graphic/Manager.hxx
+++ b/vcl/inc/graphic/Manager.hxx
@@ -17,6 +17,7 @@
#include <vcl/vectorgraphicdata.hxx>
#include <vcl/timer.hxx>
#include <vcl/GraphicExternalLink.hxx>
+#include <vcl/gfxlink.hxx>
#include <memory>
#include <mutex>
@@ -60,6 +61,8 @@ public:
std::shared_ptr<ImpGraphic> copy(std::shared_ptr<ImpGraphic> const& pImpGraphic);
std::shared_ptr<ImpGraphic> newInstance();
std::shared_ptr<ImpGraphic> newInstance(const BitmapEx& rBitmapEx);
+ std::shared_ptr<ImpGraphic> newInstance(std::shared_ptr<GfxLink> const& rLink,
+ sal_Int32 nPageIndex = 0);
std::shared_ptr<ImpGraphic>
newInstance(const std::shared_ptr<VectorGraphicData>& rVectorGraphicDataPtr);
std::shared_ptr<ImpGraphic> newInstance(const Animation& rAnimation);
diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx
index 2ee0e9ef61ec..6287be0df1b1 100644
--- a/vcl/inc/impgraph.hxx
+++ b/vcl/inc/impgraph.hxx
@@ -90,6 +90,7 @@ public:
ImpGraphic( const ImpGraphic& rImpGraphic );
ImpGraphic( ImpGraphic&& rImpGraphic ) noexcept;
ImpGraphic( const GraphicExternalLink& rExternalLink);
+ ImpGraphic(std::shared_ptr<GfxLink> const& rGfxLink, sal_Int32 nPageIndex = 0);
ImpGraphic( const BitmapEx& rBmpEx );
ImpGraphic(const std::shared_ptr<VectorGraphicData>& rVectorGraphicDataPtr);
ImpGraphic( const Animation& rAnimation );
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index 7a7d1c75aa38..f2730dbfe811 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -474,14 +474,10 @@ size_t ImportPDFUnloaded(const OUString& rURL, std::vector<PDFGraphicResult>& rG
tools::Long nPageWidth = convertTwipToMm100(aPageSize.getX() * pointToTwipconversionRatio);
tools::Long nPageHeight = convertTwipToMm100(aPageSize.getY() * pointToTwipconversionRatio);
- auto aVectorGraphicDataPtr = std::make_shared<VectorGraphicData>(
- aDataContainer, VectorGraphicDataType::Pdf, nPageIndex);
-
// Create the Graphic with the VectorGraphicDataPtr 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(aVectorGraphicDataPtr);
- aGraphic.SetGfxLink(pGfxLink);
+ Graphic aGraphic(pGfxLink, nPageIndex);
auto pPage = pPdfDocument->openPage(nPageIndex);
diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx
index 033e5576ce20..74a61e871e78 100644
--- a/vcl/source/gdi/graph.cxx
+++ b/vcl/source/gdi/graph.cxx
@@ -177,6 +177,11 @@ Graphic::Graphic(Graphic&& rGraphic) noexcept
{
}
+Graphic::Graphic(std::shared_ptr<GfxLink> const & rGfxLink, sal_Int32 nPageIndex)
+ : mxImpGraphic(vcl::graphic::Manager::get().newInstance(rGfxLink, nPageIndex))
+{
+}
+
Graphic::Graphic(GraphicExternalLink const & rGraphicExternalLink)
: mxImpGraphic(vcl::graphic::Manager::get().newInstance(rGraphicExternalLink))
{
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 5e53a900a60f..99fe4d8ca63a 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -131,6 +131,23 @@ ImpGraphic::ImpGraphic(ImpGraphic&& rImpGraphic) noexcept
rImpGraphic.mbDummyContext = false;
}
+ImpGraphic::ImpGraphic(std::shared_ptr<GfxLink> const & rGfxLink, sal_Int32 nPageIndex)
+ : mpGfxLink(rGfxLink)
+ , meType(GraphicType::Bitmap)
+ , mnSizeBytes(0)
+ , mbSwapOut(true)
+ , mbDummyContext(false)
+ , maLastUsed (std::chrono::high_resolution_clock::now())
+ , mbPrepared (false)
+{
+ maSwapInfo.mbIsTransparent = true;
+ maSwapInfo.mbIsAlpha = true;
+ maSwapInfo.mbIsEPS = false;
+ maSwapInfo.mbIsAnimated = false;
+ maSwapInfo.mnAnimationLoopCount = 0;
+ maSwapInfo.mnPageIndex = nPageIndex;
+}
+
ImpGraphic::ImpGraphic(GraphicExternalLink const & rGraphicExternalLink) :
meType ( GraphicType::Default ),
mnSizeBytes ( 0 ),
diff --git a/vcl/source/graphic/Manager.cxx b/vcl/source/graphic/Manager.cxx
index fafca90b5ad8..054a615ef812 100644
--- a/vcl/source/graphic/Manager.cxx
+++ b/vcl/source/graphic/Manager.cxx
@@ -203,6 +203,14 @@ std::shared_ptr<ImpGraphic> Manager::newInstance()
return pReturn;
}
+std::shared_ptr<ImpGraphic> Manager::newInstance(std::shared_ptr<GfxLink> const& rGfxLink,
+ sal_Int32 nPageIndex)
+{
+ auto pReturn = std::make_shared<ImpGraphic>(rGfxLink, nPageIndex);
+ registerGraphic(pReturn);
+ return pReturn;
+}
+
std::shared_ptr<ImpGraphic> Manager::newInstance(const BitmapEx& rBitmapEx)
{
auto pReturn = std::make_shared<ImpGraphic>(rBitmapEx);
More information about the Libreoffice-commits
mailing list