[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - 3 commits - include/vcl vcl/inc vcl/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Mon Dec 21 04:13:25 UTC 2020
include/vcl/pdfread.hxx | 7 ++++++-
vcl/inc/impgraph.hxx | 5 +++++
vcl/source/filter/ipdf/pdfread.cxx | 17 +++++++++++++----
vcl/source/gdi/impgraph.cxx | 20 ++++++++++++++------
vcl/source/gdi/vectorgraphicdata.cxx | 8 ++++----
5 files changed, 42 insertions(+), 15 deletions(-)
New commits:
commit 52bf1fcbc4b108e774dd579328def2b6019b8a0f
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Mon Dec 21 13:04:18 2020 +0900
Commit: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Mon Dec 21 13:07:38 2020 +0900
ImplGraphic: set PrefSize, PrefMapMode without forcing a swap-in
This adds methods to set the PrefSize, PrefMapMode directly with
no forced swap-in.
Change-Id: I52b424ffc920c5a760891672c1ef961c1b1c1b64
diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx
index 6a312a76d58e..86fa80606b8f 100644
--- a/vcl/inc/impgraph.hxx
+++ b/vcl/inc/impgraph.hxx
@@ -213,6 +213,11 @@ private:
sal_Int32 getPageNumber() const;
+ // Set the pref size, but don't force swap-in
+ void setValuesForPrefSize(const Size& rPrefSize);
+ // Set the pref map mode, but don't force swap-in
+ void setValuesForPrefMapMod(const MapMode& rPrefMapMode);
+
public:
void resetChecksum() { mnChecksum = 0; }
bool swapIn();
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index fec7c9654f4c..1ad21ab7c750 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -801,10 +801,8 @@ Size ImpGraphic::ImplGetPrefSize() const
return aSize;
}
-void ImpGraphic::ImplSetPrefSize(const Size& rPrefSize)
+void ImpGraphic::setValuesForPrefSize(const Size& rPrefSize)
{
- ensureAvailable();
-
switch (meType)
{
case GraphicType::Bitmap:
@@ -843,6 +841,12 @@ void ImpGraphic::ImplSetPrefSize(const Size& rPrefSize)
}
}
+void ImpGraphic::ImplSetPrefSize(const Size& rPrefSize)
+{
+ ensureAvailable();
+ setValuesForPrefSize(rPrefSize);
+}
+
MapMode ImpGraphic::ImplGetPrefMapMode() const
{
MapMode aMapMode;
@@ -887,10 +891,8 @@ MapMode ImpGraphic::ImplGetPrefMapMode() const
return aMapMode;
}
-void ImpGraphic::ImplSetPrefMapMode(const MapMode& rPrefMapMode)
+void ImpGraphic::setValuesForPrefMapMod(const MapMode& rPrefMapMode)
{
- ensureAvailable();
-
switch (meType)
{
case GraphicType::Bitmap:
@@ -926,6 +928,12 @@ void ImpGraphic::ImplSetPrefMapMode(const MapMode& rPrefMapMode)
}
}
+void ImpGraphic::ImplSetPrefMapMode(const MapMode& rPrefMapMode)
+{
+ ensureAvailable();
+ setValuesForPrefMapMod(rPrefMapMode);
+}
+
sal_uLong ImpGraphic::ImplGetSizeBytes() const
{
if (mnSizeBytes > 0)
commit e48fe07d7572790944689551169c7538e1ee0275
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Tue Dec 15 17:01:01 2020 +0900
Commit: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Mon Dec 21 12:59:55 2020 +0900
vcl: reverse the if statement in VectorGraphicData::getSizeBytes
It makes more sense to fallback to an State::UNPARSED unless the
condition is satisfied and not the other way around.
Change-Id: I97c2792c8ddd293d99c6418ac0221b7331ee6b5c
diff --git a/vcl/source/gdi/vectorgraphicdata.cxx b/vcl/source/gdi/vectorgraphicdata.cxx
index 92d49e07de3e..a8134a60c852 100644
--- a/vcl/source/gdi/vectorgraphicdata.cxx
+++ b/vcl/source/gdi/vectorgraphicdata.cxx
@@ -278,15 +278,15 @@ void VectorGraphicData::ensureSequenceAndRange()
mbSequenceCreated = true;
}
-auto VectorGraphicData::getSizeBytes() const -> std::pair<State, size_t>
+std::pair<VectorGraphicData::State, size_t> VectorGraphicData::getSizeBytes() const
{
- if (maSequence.empty() && maVectorGraphicDataArray.hasElements())
+ if (!maSequence.empty() && maVectorGraphicDataArray.hasElements())
{
- return std::make_pair(State::UNPARSED, maVectorGraphicDataArray.getLength());
+ return std::make_pair(State::PARSED, maVectorGraphicDataArray.getLength() + mNestedBitmapSize);
}
else
{
- return std::make_pair(State::PARSED, maVectorGraphicDataArray.getLength() + mNestedBitmapSize);
+ return std::make_pair(State::UNPARSED, maVectorGraphicDataArray.getLength());
}
}
commit 6273e8b9774649d5c19a8d7f9da9c56bbb7ded23
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Tue Dec 15 16:54:46 2020 +0900
Commit: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Mon Dec 21 12:59:49 2020 +0900
pdf: add a public function to load PDF as a VectorGraphicData
This adds a public function that loads a PDF as a VectorGraphicData
which essentially spilts the ImportPDF to general import as a
VectorGraphicData and then creation of a new Graphic. This is
needed so we can just load the VectorGraphicData independent to
a Graphic itself, so we don't needlessly create a new Graphic
instance in some cases.
Change-Id: Ib5f570242da69a1537bfdf1054f8eb40ecead31b
diff --git a/include/vcl/pdfread.hxx b/include/vcl/pdfread.hxx
index b693c432302b..084bd3f913b5 100644
--- a/include/vcl/pdfread.hxx
+++ b/include/vcl/pdfread.hxx
@@ -34,7 +34,12 @@ VCL_DLLPUBLIC size_t RenderPDFBitmaps(const void* pBuffer, int nSize,
std::vector<BitmapEx>& rBitmaps, size_t nFirstPage = 0,
int nPages = 1, const basegfx::B2DTuple* pSizeHint = nullptr);
-/// Imports a PDF stream into rGraphic as VectorGraphicData.
+/// Imports a PDF stream as a VectorGraphicData.
+VCL_DLLPUBLIC bool
+importPdfVectorGraphicData(SvStream& rStream,
+ std::shared_ptr<VectorGraphicData>& rVectorGraphicData);
+
+/// Imports a PDF stream into rGraphic.
VCL_DLLPUBLIC bool ImportPDF(SvStream& rStream, Graphic& rGraphic);
struct PDFGraphicAnnotation
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index ef5d799fe4ee..dbfa5ceeaf68 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -230,7 +230,8 @@ size_t RenderPDFBitmaps(const void* pBuffer, int nSize, std::vector<BitmapEx>& r
#endif // HAVE_FEATURE_PDFIUM
}
-bool ImportPDF(SvStream& rStream, Graphic& rGraphic)
+bool importPdfVectorGraphicData(SvStream& rStream,
+ std::shared_ptr<VectorGraphicData>& rVectorGraphicData)
{
VectorGraphicDataArray aPdfDataArray = createVectorGraphicDataArray(rStream);
if (!aPdfDataArray.hasElements())
@@ -239,10 +240,18 @@ bool ImportPDF(SvStream& rStream, Graphic& rGraphic)
return false;
}
- auto aVectorGraphicDataPtr = std::make_shared<VectorGraphicData>(aPdfDataArray, OUString(),
- VectorGraphicDataType::Pdf);
+ rVectorGraphicData = std::make_shared<VectorGraphicData>(aPdfDataArray, OUString(),
+ VectorGraphicDataType::Pdf);
+
+ return true;
+}
- rGraphic = Graphic(aVectorGraphicDataPtr);
+bool ImportPDF(SvStream& rStream, Graphic& rGraphic)
+{
+ std::shared_ptr<VectorGraphicData> pVectorGraphicData;
+ if (!importPdfVectorGraphicData(rStream, pVectorGraphicData))
+ return false;
+ rGraphic = Graphic(pVectorGraphicData);
return true;
}
More information about the Libreoffice-commits
mailing list