Rebased ref, commits from common ancestor: commit 23684ff8299ca9d5a026e33c018b8dfed34e0c30 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu Aug 13 08:49:30 2020 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Thu Aug 13 10:19:28 2020 +0200
remove constructor with plain Bitmap from Graphic, use BitmapEx Change-Id: Ie429a10a8f54c6779d437ee4bc75a5ea0c427848 diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 89ba081348c2..cc60076b58a6 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -4309,7 +4309,8 @@ void SbRtl_LoadPicture(StarBASIC *, SbxArray & rPar, bool) { Bitmap aBmp; ReadDIB(aBmp, *pStream, true); - Graphic aGraphic(aBmp); + BitmapEx aBitmapEx(aBmp); + Graphic aGraphic(aBitmapEx); SbxObjectRef xRef = new SbStdPicture; static_cast<SbStdPicture*>(xRef.get())->SetGraphic( aGraphic ); diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx index 535c49184dae..a903bf99aa99 100644 --- a/emfio/source/reader/mtftools.cxx +++ b/emfio/source/reader/mtftools.cxx @@ -1310,7 +1310,7 @@ namespace emfio Color(), Color(), 0, - Graphic (maLatestFillStyle.aBmp) ); + Graphic (BitmapEx(maLatestFillStyle.aBmp))); SvMemoryStream aMemStm; diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index 57f034e38870..ea37cbe45b47 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -6555,7 +6555,7 @@ bool SvxMSDffManager::GetBLIPDirect( SvStream& rBLIPStream, Graphic& rData, tool Bitmap aNew; if( ReadDIB(aNew, *pGrStream, false) ) { - rData = Graphic( aNew ); + rData = Graphic(BitmapEx(aNew)); nRes = ERRCODE_NONE; } } diff --git a/include/vcl/graph.hxx b/include/vcl/graph.hxx index f6a47e43b8ec..1880041b4ba5 100644 --- a/include/vcl/graph.hxx +++ b/include/vcl/graph.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_VCL_GRAPH_HXX -#define INCLUDED_VCL_GRAPH_HXX +#pragma once #include <memory> #include <vcl/dllapi.h> @@ -93,7 +92,6 @@ public: Graphic( const GraphicExternalLink& rGraphicLink ); Graphic( const Graphic& rGraphic ); Graphic( Graphic&& rGraphic ) noexcept; - Graphic( const Bitmap& rBmp ); Graphic( const Image& rImage ); Graphic( const BitmapEx& rBmpEx ); Graphic( const std::shared_ptr<VectorGraphicData>& rVectorGraphicDataPtr ); @@ -213,6 +211,4 @@ struct hash<Graphic> } // end namespace std -#endif // INCLUDED_VCL_GRAPH_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx index 70f30c693bb3..70252f6e6699 100644 --- a/sc/source/filter/excel/xiescher.cxx +++ b/sc/source/filter/excel/xiescher.cxx @@ -752,7 +752,7 @@ void XclImpDrawObjBase::ConvertFillStyle( SdrObject& rSdrObj, const XclObjFillDa aBitmap = aXOBitmap.GetBitmap().GetBitmap(); rSdrObj.SetMergedItem(XFillStyleItem(drawing::FillStyle_BITMAP)); - rSdrObj.SetMergedItem(XFillBitmapItem(EMPTY_OUSTRING, Graphic(aBitmap))); + rSdrObj.SetMergedItem(XFillBitmapItem(EMPTY_OUSTRING, Graphic(BitmapEx(aBitmap)))); } } } @@ -4137,7 +4137,7 @@ void XclImpDrawing::ReadBmp( Graphic& rGraphic, const XclImpRoot& rRoot, XclImpS aMemStrm.Seek( STREAM_SEEK_TO_BEGIN ); Bitmap aBitmap; if( ReadDIB(aBitmap, aMemStrm, false) ) // read DIB without file header - rGraphic = aBitmap; + rGraphic = BitmapEx(aBitmap); } void XclImpDrawing::ReadDffRecord( XclImpStream& rStrm ) diff --git a/sd/source/core/drawdoc4.cxx b/sd/source/core/drawdoc4.cxx index 59687f189450..2f028a15644e 100644 --- a/sd/source/core/drawdoc4.cxx +++ b/sd/source/core/drawdoc4.cxx @@ -167,7 +167,7 @@ void SdDrawDocument::CreateLayoutTemplates() Size aNullSize( 32, 32 ); Bitmap aNullBmp( aNullSize, 8 ); aNullBmp.Erase( COL_WHITE ); - rISet.Put(XFillBitmapItem(Graphic(aNullBmp))); + rISet.Put(XFillBitmapItem(Graphic(BitmapEx(aNullBmp)))); // Shadow attributes (Drawing Engine) rISet.Put(makeSdrShadowItem(false)); diff --git a/sd/source/ui/dlg/vectdlg.cxx b/sd/source/ui/dlg/vectdlg.cxx index 843d593f5e28..dce0e837ac38 100644 --- a/sd/source/ui/dlg/vectdlg.cxx +++ b/sd/source/ui/dlg/vectdlg.cxx @@ -103,7 +103,7 @@ void SdVectorizeDlg::InitPreviewBmp() aPreviewBmp = aBmp; aPreviewBmp.Scale( aRect.GetSize() ); - m_aBmpWin.SetGraphic( aPreviewBmp ); + m_aBmpWin.SetGraphic(BitmapEx(aPreviewBmp)); } Bitmap SdVectorizeDlg::GetPreparedBitmap( Bitmap const & rBmp, Fraction& rScale ) diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx index c4ae7621a60c..1ecd4aa48efe 100644 --- a/sd/source/ui/view/sdview3.cxx +++ b/sd/source/ui/view/sdview3.cxx @@ -194,21 +194,21 @@ bool View::InsertMetaFile( TransferableDataHelper& rDataHelper, const Point& rPo { MetaBmpAction* pBmpAction = dynamic_cast< MetaBmpAction* >( pAction ); if( pBmpAction ) - aGraphic = Graphic( pBmpAction->GetBitmap() ); + aGraphic = Graphic(BitmapEx(pBmpAction->GetBitmap())); } break; case MetaActionType::BMPSCALE: { MetaBmpScaleAction* pBmpScaleAction = dynamic_cast< MetaBmpScaleAction* >( pAction ); if( pBmpScaleAction ) - aGraphic = Graphic( pBmpScaleAction->GetBitmap() ); + aGraphic = Graphic(BitmapEx(pBmpScaleAction->GetBitmap())); } break; case MetaActionType::BMPEX: { MetaBmpExAction* pBmpExAction = dynamic_cast< MetaBmpExAction* >( pAction ); if( pBmpExAction ) - aGraphic = Graphic( pBmpExAction->GetBitmapEx() ); + aGraphic = Graphic(pBmpExAction->GetBitmapEx() ); } break; case MetaActionType::BMPEXSCALE: diff --git a/sfx2/source/appl/linkmgr2.cxx b/sfx2/source/appl/linkmgr2.cxx index 8245f6da66ec..7f760ab26e13 100644 --- a/sfx2/source/appl/linkmgr2.cxx +++ b/sfx2/source/appl/linkmgr2.cxx @@ -559,7 +559,7 @@ bool LinkManager::GetGraphicFromAny(const OUString& rMimeType, { Bitmap aBmp; ReadDIB(aBmp, aMemStm, true); - rGraphic = aBmp; + rGraphic = BitmapEx(aBmp); bRet = true; } break; diff --git a/svtools/qa/unit/GraphicObjectTest.cxx b/svtools/qa/unit/GraphicObjectTest.cxx index bb09612f7d72..849dea550606 100644 --- a/svtools/qa/unit/GraphicObjectTest.cxx +++ b/svtools/qa/unit/GraphicObjectTest.cxx @@ -45,7 +45,7 @@ private: void GraphicObjectTest::testTdf88836() { // Construction with empty bitmap -> type should be GraphicType::NONE - Graphic aGraphic = Bitmap(); + Graphic aGraphic = BitmapEx(Bitmap()); CPPUNIT_ASSERT_EQUAL(int(GraphicType::NONE), int(aGraphic.GetType())); aGraphic = Graphic(BitmapEx()); CPPUNIT_ASSERT_EQUAL(int(GraphicType::NONE), int(aGraphic.GetType())); diff --git a/svx/source/dialog/_bmpmask.cxx b/svx/source/dialog/_bmpmask.cxx index 52cd4f2ae79b..ca3b0d21ef6c 100644 --- a/svx/source/dialog/_bmpmask.cxx +++ b/svx/source/dialog/_bmpmask.cxx @@ -811,7 +811,7 @@ GDIMetaFile SvxBmpMask::ImpMask( const GDIMetaFile& rMtf ) case MetaActionType::BMP: { MetaBmpAction* pAct = static_cast<MetaBmpAction*>(pAction); - const Bitmap aBmp( Mask( pAct->GetBitmap() ).GetBitmapEx().GetBitmap() ); + const Bitmap aBmp( Mask(BitmapEx(pAct->GetBitmap())).GetBitmapEx().GetBitmap() ); pAct = new MetaBmpAction( pAct->GetPoint(), aBmp ); aMtf.AddAction( pAct ); @@ -821,7 +821,7 @@ GDIMetaFile SvxBmpMask::ImpMask( const GDIMetaFile& rMtf ) case MetaActionType::BMPSCALE: { MetaBmpScaleAction* pAct = static_cast<MetaBmpScaleAction*>(pAction); - const Bitmap aBmp( Mask( pAct->GetBitmap() ).GetBitmapEx().GetBitmap() ); + const Bitmap aBmp( Mask(BitmapEx(pAct->GetBitmap())).GetBitmapEx().GetBitmap() ); pAct = new MetaBmpScaleAction( pAct->GetPoint(), pAct->GetSize(), aBmp ); aMtf.AddAction( pAct ); @@ -831,7 +831,7 @@ GDIMetaFile SvxBmpMask::ImpMask( const GDIMetaFile& rMtf ) case MetaActionType::BMPSCALEPART: { MetaBmpScalePartAction* pAct = static_cast<MetaBmpScalePartAction*>(pAction); - const Bitmap aBmp( Mask( pAct->GetBitmap() ).GetBitmapEx().GetBitmap() ); + const Bitmap aBmp( Mask(BitmapEx(pAct->GetBitmap())).GetBitmapEx().GetBitmap() ); pAct = new MetaBmpScalePartAction( pAct->GetDestPoint(), pAct->GetDestSize(), pAct->GetSrcPoint(), pAct->GetSrcSize(), aBmp ); diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx index 1f62442af896..1555951984c1 100644 --- a/svx/source/svdraw/svdfmtf.cxx +++ b/svx/source/svdraw/svdfmtf.cxx @@ -1092,7 +1092,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpAction const & rAct) aRect.AdjustRight( 1 ); aRect.AdjustBottom( 1 ); SdrGrafObj* pGraf = new SdrGrafObj( *mpModel, - Graphic(rAct.GetBitmap()), + Graphic(BitmapEx(rAct.GetBitmap())), aRect); // This action is not creating line and fill, set directly, do not use SetAttributes(..) @@ -1107,7 +1107,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpScaleAction const & rAct) aRect.AdjustRight( 1 ); aRect.AdjustBottom( 1 ); SdrGrafObj* pGraf = new SdrGrafObj( *mpModel, - Graphic(rAct.GetBitmap()), + Graphic(BitmapEx(rAct.GetBitmap())), aRect); // This action is not creating line and fill, set directly, do not use SetAttributes(..) @@ -1319,14 +1319,14 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaTextRectAction const & rAct) void ImpSdrGDIMetaFileImport::DoAction(MetaBmpScalePartAction const & rAct) { tools::Rectangle aRect(rAct.GetDestPoint(), rAct.GetDestSize()); - Bitmap aBitmap(rAct.GetBitmap()); + BitmapEx aBitmapEx(rAct.GetBitmap()); aRect.AdjustRight( 1 ); aRect.AdjustBottom( 1 ); - aBitmap.Crop(tools::Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize())); + aBitmapEx.Crop(tools::Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize())); SdrGrafObj* pGraf = new SdrGrafObj( *mpModel, - aBitmap, + aBitmapEx, aRect); // This action is not creating line and fill, set directly, do not use SetAttributes(..) diff --git a/svx/source/xoutdev/_xoutbmp.cxx b/svx/source/xoutdev/_xoutbmp.cxx index 15123e853484..8680b6fe8189 100644 --- a/svx/source/xoutdev/_xoutbmp.cxx +++ b/svx/source/xoutdev/_xoutbmp.cxx @@ -284,7 +284,7 @@ ErrCode XOutBitmap::WriteGraphic( const Graphic& rGraphic, OUString& rFileName, if( pVDev->SetOutputSizePixel( aSize ) ) { rGraphic.Draw( pVDev.get(), Point(), aSize ); - aGraphic = pVDev->GetBitmap( Point(), aSize ); + aGraphic = BitmapEx(pVDev->GetBitmap(Point(), aSize)); } else aGraphic = rGraphic.GetBitmapEx(); diff --git a/vcl/inc/graphic/Manager.hxx b/vcl/inc/graphic/Manager.hxx index 8b21f1c46105..73a6676e4d7b 100644 --- a/vcl/inc/graphic/Manager.hxx +++ b/vcl/inc/graphic/Manager.hxx @@ -58,7 +58,6 @@ public: std::shared_ptr<ImpGraphic> copy(std::shared_ptr<ImpGraphic> const& pImpGraphic); std::shared_ptr<ImpGraphic> newInstance(); - std::shared_ptr<ImpGraphic> newInstance(const Bitmap& rBitmap); std::shared_ptr<ImpGraphic> newInstance(const BitmapEx& rBitmapEx); std::shared_ptr<ImpGraphic> newInstance(const std::shared_ptr<VectorGraphicData>& rVectorGraphicDataPtr); diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx index 749a5b82a12e..8b3cc14b7f2d 100644 --- a/vcl/inc/impgraph.hxx +++ b/vcl/inc/impgraph.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_VCL_INC_IMPGRAPH_HXX -#define INCLUDED_VCL_INC_IMPGRAPH_HXX +#pragma once #include <vcl/dllapi.h> #include <vcl/GraphicExternalLink.hxx> @@ -83,7 +82,6 @@ public: ImpGraphic( const ImpGraphic& rImpGraphic ); ImpGraphic( ImpGraphic&& rImpGraphic ) noexcept; ImpGraphic( const GraphicExternalLink& rExternalLink); - ImpGraphic( const Bitmap& rBmp ); ImpGraphic( const BitmapEx& rBmpEx ); ImpGraphic(const std::shared_ptr<VectorGraphicData>& rVectorGraphicDataPtr); ImpGraphic( const Animation& rAnimation ); @@ -209,6 +207,4 @@ public: OUString getSwapFileURL(); }; -#endif // INCLUDED_VCL_INC_IMPGRAPH_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qa/cppunit/BackendTest.cxx b/vcl/qa/cppunit/BackendTest.cxx index 68ddebb4380b..7a9cf89fceaf 100644 --- a/vcl/qa/cppunit/BackendTest.cxx +++ b/vcl/qa/cppunit/BackendTest.cxx @@ -41,7 +41,7 @@ class BackendTest : public test::BootstrapFixture Bitmap aBitmap(rBitmap); aBitmap.Scale(Size(128, 128), BmpScaleFlag::Fast); SvFileStream aStream(rsFilename, StreamMode::WRITE | StreamMode::TRUNC); - GraphicFilter::GetGraphicFilter().compressAsPNG(aBitmap, aStream); + GraphicFilter::GetGraphicFilter().compressAsPNG(BitmapEx(aBitmap), aStream); } } diff --git a/vcl/qa/cppunit/BitmapFilterTest.cxx b/vcl/qa/cppunit/BitmapFilterTest.cxx index a519da24ed9b..12b32bc316f7 100644 --- a/vcl/qa/cppunit/BitmapFilterTest.cxx +++ b/vcl/qa/cppunit/BitmapFilterTest.cxx @@ -69,7 +69,7 @@ private: { SvFileStream aStream(sWhere, StreamMode::WRITE | StreamMode::TRUNC); GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter(); - rFilter.compressAsPNG(rBmp, aStream); + rFilter.compressAsPNG(BitmapEx(rBmp), aStream); } }; @@ -201,7 +201,7 @@ void BitmapFilterTest::testPerformance() std::unique_ptr<SvFileStream> pStream( new SvFileStream("~/BlurBigPerformance.png", StreamMode::WRITE | StreamMode::TRUNC)); GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter(); - rFilter.compressAsPNG(aResult, *pStream); + rFilter.compressAsPNG(BitmapEx(aResult), *pStream); pStream.reset(new SvFileStream("~/BlurBigPerformance.txt", StreamMode::WRITE)); pStream->WriteOString("Blur average time: "); diff --git a/vcl/qa/cppunit/BitmapScaleTest.cxx b/vcl/qa/cppunit/BitmapScaleTest.cxx index f73d54f6174d..277e42adbe1b 100644 --- a/vcl/qa/cppunit/BitmapScaleTest.cxx +++ b/vcl/qa/cppunit/BitmapScaleTest.cxx @@ -146,14 +146,14 @@ void BitmapScaleTest::testScale() { SvFileStream aStream("~/scale_before.png", StreamMode::WRITE | StreamMode::TRUNC); GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter(); - rFilter.compressAsPNG(bitmap, aStream); + rFilter.compressAsPNG(BitmapEx(bitmap), aStream); } CPPUNIT_ASSERT(bitmap.Scale(scaleSize.destSize, scaleMethod)); if (bExportBitmap) { SvFileStream aStream("~/scale_after.png", StreamMode::WRITE | StreamMode::TRUNC); GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter(); - rFilter.compressAsPNG(bitmap, aStream); + rFilter.compressAsPNG(BitmapEx(bitmap), aStream); } CPPUNIT_ASSERT_EQUAL(scaleSize.destSize, bitmap.GetSizePixel()); const int lastW = scaleSize.destSize.getWidth() - 1; @@ -215,7 +215,7 @@ void BitmapScaleTest::testScale2() { SvFileStream aStream("scale_before.png", StreamMode::WRITE | StreamMode::TRUNC); GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter(); - rFilter.compressAsPNG(aBitmap24Bit, aStream); + rFilter.compressAsPNG(BitmapEx(aBitmap24Bit), aStream); } // Scale - 65x65 @@ -228,7 +228,7 @@ void BitmapScaleTest::testScale2() { SvFileStream aStream("scale_after_65x65.png", StreamMode::WRITE | StreamMode::TRUNC); GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter(); - rFilter.compressAsPNG(aScaledBitmap, aStream); + rFilter.compressAsPNG(BitmapEx(aScaledBitmap), aStream); } CPPUNIT_ASSERT_EQUAL(static_cast<long>(65), aScaledBitmap.GetSizePixel().Width()); @@ -245,7 +245,7 @@ void BitmapScaleTest::testScale2() { SvFileStream aStream("scale_after_64x64.png", StreamMode::WRITE | StreamMode::TRUNC); GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter(); - rFilter.compressAsPNG(aScaledBitmap, aStream); + rFilter.compressAsPNG(BitmapEx(aScaledBitmap), aStream); } CPPUNIT_ASSERT_EQUAL(static_cast<long>(64), aScaledBitmap.GetSizePixel().Width()); @@ -262,7 +262,7 @@ void BitmapScaleTest::testScale2() { SvFileStream aStream("scale_after_63x63.png", StreamMode::WRITE | StreamMode::TRUNC); GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter(); - rFilter.compressAsPNG(aScaledBitmap, aStream); + rFilter.compressAsPNG(BitmapEx(aScaledBitmap), aStream); } CPPUNIT_ASSERT_EQUAL(static_cast<long>(63), aScaledBitmap.GetSizePixel().Width()); @@ -297,7 +297,7 @@ void BitmapScaleTest::testScaleSymmetry() { SvFileStream aStream("~/scale_before.png", StreamMode::WRITE | StreamMode::TRUNC); GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter(); - rFilter.compressAsPNG(aBitmap24Bit, aStream); + rFilter.compressAsPNG(BitmapEx(aBitmap24Bit), aStream); } aBitmap24Bit.Scale(2, 2, BmpScaleFlag::Fast); @@ -313,7 +313,7 @@ void BitmapScaleTest::testScaleSymmetry() { SvFileStream aStream("~/scale_after.png", StreamMode::WRITE | StreamMode::TRUNC); GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter(); - rFilter.compressAsPNG(aBitmap24Bit, aStream); + rFilter.compressAsPNG(BitmapEx(aBitmap24Bit), aStream); } } diff --git a/vcl/qa/cppunit/graphicfilter/filters-test.cxx b/vcl/qa/cppunit/graphicfilter/filters-test.cxx index 26f743cfa311..bc745fc530f8 100644 --- a/vcl/qa/cppunit/graphicfilter/filters-test.cxx +++ b/vcl/qa/cppunit/graphicfilter/filters-test.cxx @@ -116,7 +116,7 @@ void VclFiltersTest::checkExportImport(const OUString& aFilterShortName) aFilterData[ 2 ].Value <<= sal_Int32(90); sal_uInt16 aFilterType = mpGraphicFilter->GetExportFormatNumberForShortName(aFilterShortName); - mpGraphicFilter->ExportGraphic( aBitmap, OUString(), aStream, aFilterType, &aFilterData ); + mpGraphicFilter->ExportGraphic(BitmapEx(aBitmap), OUString(), aStream, aFilterType, &aFilterData ); CPPUNIT_ASSERT(aStream.Tell() > 0); diff --git a/vcl/source/filter/igif/gifread.cxx b/vcl/source/filter/igif/gifread.cxx index 045a6de0571e..f2ad9bd1132c 100644 --- a/vcl/source/filter/igif/gifread.cxx +++ b/vcl/source/filter/igif/gifread.cxx @@ -712,7 +712,7 @@ Graphic GIFReader::GetIntermediateGraphic() bStatus = bStatus && pAcc1; } else - aImGraphic = aBmp8; + aImGraphic = BitmapEx(aBmp8); pAcc8 = BitmapScopedWriteAccess(aBmp8); bStatus = bStatus && pAcc8; diff --git a/vcl/source/filter/ixpm/xpmread.cxx b/vcl/source/filter/ixpm/xpmread.cxx index fa71bfa3cb75..1e47bfe9d765 100644 --- a/vcl/source/filter/ixpm/xpmread.cxx +++ b/vcl/source/filter/ixpm/xpmread.cxx @@ -254,7 +254,7 @@ ReadState XPMReader::ReadXPM( Graphic& rGraphic ) } else { - rGraphic = maBmp; + rGraphic = BitmapEx(maBmp); } eReadState = XPMREAD_OK; } diff --git a/vcl/source/filter/jpeg/JpegReader.cxx b/vcl/source/filter/jpeg/JpegReader.cxx index cd378f4a855f..0ea4ef493886 100644 --- a/vcl/source/filter/jpeg/JpegReader.cxx +++ b/vcl/source/filter/jpeg/JpegReader.cxx @@ -269,12 +269,12 @@ Graphic JPEGReader::CreateIntermediateGraphic(long nLines) } else { - aGraphic = *mpBitmap; + aGraphic = BitmapEx(*mpBitmap); } } else { - aGraphic = *mpBitmap; + aGraphic = BitmapEx(*mpBitmap); } mnLastLines = nLines; @@ -304,7 +304,7 @@ ReadState JPEGReader::Read( Graphic& rGraphic, GraphicFilterImportFlags nImportF else { if (!bUseExistingBitmap) - rGraphic = *mpBitmap; + rGraphic = BitmapEx(*mpBitmap); } bRet = true; diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx index 05ad9657d8d9..b88aaf0e9f3f 100644 --- a/vcl/source/gdi/graph.cxx +++ b/vcl/source/gdi/graph.cxx @@ -182,11 +182,6 @@ Graphic::Graphic(GraphicExternalLink const & rGraphicExternalLink) { } -Graphic::Graphic(const Bitmap& rBmp) - : mxImpGraphic(vcl::graphic::Manager::get().newInstance(rBmp)) -{ -} - Graphic::Graphic(const BitmapEx& rBmpEx) : mxImpGraphic(vcl::graphic::Manager::get().newInstance(rBmpEx)) { diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 925ec4a34952..c40a344ba1da 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -186,17 +186,6 @@ ImpGraphic::ImpGraphic(GraphicExternalLink const & rGraphicExternalLink) : { } -ImpGraphic::ImpGraphic( const Bitmap& rBitmap ) : - maBitmapEx ( rBitmap ), - meType ( !rBitmap.IsEmpty() ? GraphicType::Bitmap : GraphicType::NONE ), - mnSizeBytes ( 0 ), - mbSwapOut ( false ), - mbDummyContext ( false ), - maLastUsed (std::chrono::high_resolution_clock::now()), - mbPrepared (false) -{ -} - ImpGraphic::ImpGraphic( const BitmapEx& rBitmapEx ) : maBitmapEx ( rBitmapEx ), meType ( !rBitmapEx.IsEmpty() ? GraphicType::Bitmap : GraphicType::NONE ), diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx index c8e5847aaa4d..177a8772c304 100644 --- a/vcl/source/gdi/pdfwriter_impl2.cxx +++ b/vcl/source/gdi/pdfwriter_impl2.cxx @@ -204,7 +204,7 @@ void PDFWriterImpl::implWriteBitmapEx( const Point& i_rPoint, const Size& i_rSiz else aMask = aBitmapEx.GetMask(); } - Graphic aGraphic( aBitmapEx.GetBitmap() ); + Graphic aGraphic(BitmapEx(aBitmapEx.GetBitmap())); Sequence< PropertyValue > aFilterData( 2 ); aFilterData[ 0 ].Name = "Quality"; diff --git a/vcl/source/graphic/GraphicObject2.cxx b/vcl/source/graphic/GraphicObject2.cxx index dc60db55dd3f..d858b47b8f34 100644 --- a/vcl/source/graphic/GraphicObject2.cxx +++ b/vcl/source/graphic/GraphicObject2.cxx @@ -308,9 +308,9 @@ bool GraphicObject::ImplDrawTiled( OutputDevice* pOut, const tools::Rectangle& r GraphicObject aAlphaGraphic; if( GetGraphic().IsAlpha() ) - aAlphaGraphic.SetGraphic( GetGraphic().GetBitmapEx().GetAlpha().GetBitmap() ); + aAlphaGraphic.SetGraphic(BitmapEx(GetGraphic().GetBitmapEx().GetAlpha().GetBitmap())); else - aAlphaGraphic.SetGraphic( GetGraphic().GetBitmapEx().GetMask() ); + aAlphaGraphic.SetGraphic(BitmapEx(GetGraphic().GetBitmapEx().GetMask())); if( aAlphaGraphic.ImplRenderTempTile( *aVDev, nNumTilesInCacheX, nNumTilesInCacheY, rSizePixel, pAttr ) ) diff --git a/vcl/source/graphic/Manager.cxx b/vcl/source/graphic/Manager.cxx index 65e81fc1e605..7a25f8e41b04 100644 --- a/vcl/source/graphic/Manager.cxx +++ b/vcl/source/graphic/Manager.cxx @@ -178,13 +178,6 @@ std::shared_ptr<ImpGraphic> Manager::newInstance() return pReturn; } -std::shared_ptr<ImpGraphic> Manager::newInstance(const Bitmap& rBitmap) -{ - auto pReturn = std::make_shared<ImpGraphic>(rBitmap); - registerGraphic(pReturn, "Bitmap"); - return pReturn; -} - std::shared_ptr<ImpGraphic> Manager::newInstance(const BitmapEx& rBitmapEx) { auto pReturn = std::make_shared<ImpGraphic>(rBitmapEx); commit 2e56fb89cb513063b2677fe32a82dea8a301dd07 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon Jul 20 20:13:26 2020 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Thu Aug 13 10:19:28 2020 +0200 remove polygonprimitive2d.cxx from clang-format blacklist Change-Id: I3122a4058f5447cbf0369b60b368c76e5fe40089 diff --git a/drawinglayer/source/primitive2d/polygonprimitive2d.cxx b/drawinglayer/source/primitive2d/polygonprimitive2d.cxx index 6d2784dee46d..e74be52cf98d 100644 --- a/drawinglayer/source/primitive2d/polygonprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/polygonprimitive2d.cxx @@ -31,569 +31,574 @@ using namespace com::sun::star; using namespace std; - namespace drawinglayer::primitive2d { - PolygonHairlinePrimitive2D::PolygonHairlinePrimitive2D( - const basegfx::B2DPolygon& rPolygon, - const basegfx::BColor& rBColor) - : BasePrimitive2D(), - maPolygon(rPolygon), - maBColor(rBColor) - { - } +PolygonHairlinePrimitive2D::PolygonHairlinePrimitive2D(const basegfx::B2DPolygon& rPolygon, + const basegfx::BColor& rBColor) + : BasePrimitive2D() + , maPolygon(rPolygon) + , maBColor(rBColor) +{ +} - bool PolygonHairlinePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const - { - if(BasePrimitive2D::operator==(rPrimitive)) - { - const PolygonHairlinePrimitive2D& rCompare = static_cast<const PolygonHairlinePrimitive2D&>(rPrimitive); +bool PolygonHairlinePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const +{ + if (BasePrimitive2D::operator==(rPrimitive)) + { + const PolygonHairlinePrimitive2D& rCompare + = static_cast<const PolygonHairlinePrimitive2D&>(rPrimitive); - return (getB2DPolygon() == rCompare.getB2DPolygon() - && getBColor() == rCompare.getBColor()); - } + return (getB2DPolygon() == rCompare.getB2DPolygon() && getBColor() == rCompare.getBColor()); + } - return false; - } + return false; +} - basegfx::B2DRange PolygonHairlinePrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const - { - // this is a hairline, thus the line width is view-dependent. Get range of polygon - // as base size - basegfx::B2DRange aRetval(getB2DPolygon().getB2DRange()); +basegfx::B2DRange +PolygonHairlinePrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const +{ + // this is a hairline, thus the line width is view-dependent. Get range of polygon + // as base size + basegfx::B2DRange aRetval(getB2DPolygon().getB2DRange()); - if(!aRetval.isEmpty()) - { - // Calculate view-dependent hairline width - const basegfx::B2DVector aDiscreteSize(rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 0.0)); - const double fDiscreteHalfLineWidth(aDiscreteSize.getLength() * 0.5); - - if(basegfx::fTools::more(fDiscreteHalfLineWidth, 0.0)) - { - aRetval.grow(fDiscreteHalfLineWidth); - } - } + if (!aRetval.isEmpty()) + { + // Calculate view-dependent hairline width + const basegfx::B2DVector aDiscreteSize( + rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 0.0)); + const double fDiscreteHalfLineWidth(aDiscreteSize.getLength() * 0.5); - // return range - return aRetval; + if (basegfx::fTools::more(fDiscreteHalfLineWidth, 0.0)) + { + aRetval.grow(fDiscreteHalfLineWidth); } + } - // provide unique ID - ImplPrimitive2DIDBlock(PolygonHairlinePrimitive2D, PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D) + // return range + return aRetval; +} +// provide unique ID +ImplPrimitive2DIDBlock(PolygonHairlinePrimitive2D, PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D) - void PolygonMarkerPrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const - { - // calculate logic DashLength - const basegfx::B2DVector aDashVector(rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(getDiscreteDashLength(), 0.0)); - const double fLogicDashLength(aDashVector.getX()); - - if(fLogicDashLength > 0.0 && !getRGBColorA().equal(getRGBColorB())) - { - // apply dashing; get line and gap snippets - std::vector< double > aDash; - basegfx::B2DPolyPolygon aDashedPolyPolyA; - basegfx::B2DPolyPolygon aDashedPolyPolyB; + void PolygonMarkerPrimitive2D::create2DDecomposition( + Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const +{ + // calculate logic DashLength + const basegfx::B2DVector aDashVector(rViewInformation.getInverseObjectToViewTransformation() + * basegfx::B2DVector(getDiscreteDashLength(), 0.0)); + const double fLogicDashLength(aDashVector.getX()); - aDash.push_back(fLogicDashLength); - aDash.push_back(fLogicDashLength); - basegfx::utils::applyLineDashing(getB2DPolygon(), aDash, &aDashedPolyPolyA, &aDashedPolyPolyB, 2.0 * fLogicDashLength); + if (fLogicDashLength > 0.0 && !getRGBColorA().equal(getRGBColorB())) + { + // apply dashing; get line and gap snippets + std::vector<double> aDash; + basegfx::B2DPolyPolygon aDashedPolyPolyA; + basegfx::B2DPolyPolygon aDashedPolyPolyB; + + aDash.push_back(fLogicDashLength); + aDash.push_back(fLogicDashLength); + basegfx::utils::applyLineDashing(getB2DPolygon(), aDash, &aDashedPolyPolyA, + &aDashedPolyPolyB, 2.0 * fLogicDashLength); + + rContainer.push_back(new PolyPolygonHairlinePrimitive2D(aDashedPolyPolyA, getRGBColorA())); + rContainer.push_back(new PolyPolygonHairlinePrimitive2D(aDashedPolyPolyB, getRGBColorB())); + } + else + { + rContainer.push_back(new PolygonHairlinePrimitive2D(getB2DPolygon(), getRGBColorA())); + } +} + +PolygonMarkerPrimitive2D::PolygonMarkerPrimitive2D(const basegfx::B2DPolygon& rPolygon, + const basegfx::BColor& rRGBColorA, + const basegfx::BColor& rRGBColorB, + double fDiscreteDashLength) + : BufferedDecompositionPrimitive2D() + , maPolygon(rPolygon) + , maRGBColorA(rRGBColorA) + , maRGBColorB(rRGBColorB) + , mfDiscreteDashLength(fDiscreteDashLength) + , maLastInverseObjectToViewTransformation() +{ +} - rContainer.push_back(new PolyPolygonHairlinePrimitive2D(aDashedPolyPolyA, getRGBColorA())); - rContainer.push_back(new PolyPolygonHairlinePrimitive2D(aDashedPolyPolyB, getRGBColorB())); - } - else - { - rContainer.push_back(new PolygonHairlinePrimitive2D(getB2DPolygon(), getRGBColorA())); - } - } +bool PolygonMarkerPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const +{ + if (BufferedDecompositionPrimitive2D::operator==(rPrimitive)) + { + const PolygonMarkerPrimitive2D& rCompare + = static_cast<const PolygonMarkerPrimitive2D&>(rPrimitive); - PolygonMarkerPrimitive2D::PolygonMarkerPrimitive2D( - const basegfx::B2DPolygon& rPolygon, - const basegfx::BColor& rRGBColorA, - const basegfx::BColor& rRGBColorB, - double fDiscreteDashLength) - : BufferedDecompositionPrimitive2D(), - maPolygon(rPolygon), - maRGBColorA(rRGBColorA), - maRGBColorB(rRGBColorB), - mfDiscreteDashLength(fDiscreteDashLength), - maLastInverseObjectToViewTransformation() - { - } + return (getB2DPolygon() == rCompare.getB2DPolygon() + && getRGBColorA() == rCompare.getRGBColorA() + && getRGBColorB() == rCompare.getRGBColorB() + && getDiscreteDashLength() == rCompare.getDiscreteDashLength()); + } - bool PolygonMarkerPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const - { - if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) - { - const PolygonMarkerPrimitive2D& rCompare = static_cast<const PolygonMarkerPrimitive2D&>(rPrimitive); + return false; +} - return (getB2DPolygon() == rCompare.getB2DPolygon() - && getRGBColorA() == rCompare.getRGBColorA() - && getRGBColorB() == rCompare.getRGBColorB() - && getDiscreteDashLength() == rCompare.getDiscreteDashLength()); - } +basegfx::B2DRange +PolygonMarkerPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const +{ + // this is a hairline, thus the line width is view-dependent. Get range of polygon + // as base size + basegfx::B2DRange aRetval(getB2DPolygon().getB2DRange()); - return false; - } + if (!aRetval.isEmpty()) + { + // Calculate view-dependent hairline width + const basegfx::B2DVector aDiscreteSize( + rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 0.0)); + const double fDiscreteHalfLineWidth(aDiscreteSize.getLength() * 0.5); - basegfx::B2DRange PolygonMarkerPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const + if (basegfx::fTools::more(fDiscreteHalfLineWidth, 0.0)) { - // this is a hairline, thus the line width is view-dependent. Get range of polygon - // as base size - basegfx::B2DRange aRetval(getB2DPolygon().getB2DRange()); + aRetval.grow(fDiscreteHalfLineWidth); + } + } - if(!aRetval.isEmpty()) - { - // Calculate view-dependent hairline width - const basegfx::B2DVector aDiscreteSize(rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 0.0)); - const double fDiscreteHalfLineWidth(aDiscreteSize.getLength() * 0.5); - - if(basegfx::fTools::more(fDiscreteHalfLineWidth, 0.0)) - { - aRetval.grow(fDiscreteHalfLineWidth); - } - } + // return range + return aRetval; +} - // return range - return aRetval; - } +void PolygonMarkerPrimitive2D::get2DDecomposition( + Primitive2DDecompositionVisitor& rVisitor, + const geometry::ViewInformation2D& rViewInformation) const +{ + ::osl::MutexGuard aGuard(m_aMutex); + bool bNeedNewDecomposition(false); - void PolygonMarkerPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const + if (!getBuffered2DDecomposition().empty()) + { + if (rViewInformation.getInverseObjectToViewTransformation() + != maLastInverseObjectToViewTransformation) { - ::osl::MutexGuard aGuard( m_aMutex ); - bool bNeedNewDecomposition(false); + bNeedNewDecomposition = true; + } + } - if(!getBuffered2DDecomposition().empty()) - { - if(rViewInformation.getInverseObjectToViewTransformation() != maLastInverseObjectToViewTransformation) - { - bNeedNewDecomposition = true; - } - } + if (bNeedNewDecomposition) + { + // conditions of last local decomposition have changed, delete + const_cast<PolygonMarkerPrimitive2D*>(this)->setBuffered2DDecomposition( + Primitive2DContainer()); + } - if(bNeedNewDecomposition) - { - // conditions of last local decomposition have changed, delete - const_cast< PolygonMarkerPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DContainer()); - } + if (getBuffered2DDecomposition().empty()) + { + // remember last used InverseObjectToViewTransformation + PolygonMarkerPrimitive2D* pThat = const_cast<PolygonMarkerPrimitive2D*>(this); + pThat->maLastInverseObjectToViewTransformation + = rViewInformation.getInverseObjectToViewTransformation(); + } - if(getBuffered2DDecomposition().empty()) - { - // remember last used InverseObjectToViewTransformation - PolygonMarkerPrimitive2D* pThat = const_cast< PolygonMarkerPrimitive2D* >(this); - pThat->maLastInverseObjectToViewTransformation = rViewInformation.getInverseObjectToViewTransformation(); - } + // use parent implementation + BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation); +} - // use parent implementation - BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation); - } - - // provide unique ID - ImplPrimitive2DIDBlock(PolygonMarkerPrimitive2D, PRIMITIVE2D_ID_POLYGONMARKERPRIMITIVE2D) +// provide unique ID +ImplPrimitive2DIDBlock(PolygonMarkerPrimitive2D, PRIMITIVE2D_ID_POLYGONMARKERPRIMITIVE2D) } // end of namespace namespace drawinglayer::primitive2d - { - void PolygonStrokePrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& /*rViewInformation*/) const - { - if(!getB2DPolygon().count()) - return; - - // #i102241# try to simplify before usage - const basegfx::B2DPolygon aB2DPolygon(basegfx::utils::simplifyCurveSegments(getB2DPolygon())); - basegfx::B2DPolyPolygon aHairLinePolyPolygon; +{ +void PolygonStrokePrimitive2D::create2DDecomposition( + Primitive2DContainer& rContainer, const geometry::ViewInformation2D& /*rViewInformation*/) const +{ + if (!getB2DPolygon().count()) + return; - if(getStrokeAttribute().isDefault() || 0.0 == getStrokeAttribute().getFullDotDashLen()) - { - // no line dashing, just copy - aHairLinePolyPolygon.append(aB2DPolygon); - } - else - { - // apply LineStyle - basegfx::utils::applyLineDashing( - aB2DPolygon, getStrokeAttribute().getDotDashArray(), - &aHairLinePolyPolygon, nullptr, getStrokeAttribute().getFullDotDashLen()); - } + // #i102241# try to simplify before usage + const basegfx::B2DPolygon aB2DPolygon(basegfx::utils::simplifyCurveSegments(getB2DPolygon())); + basegfx::B2DPolyPolygon aHairLinePolyPolygon; - const sal_uInt32 nCount(aHairLinePolyPolygon.count()); + if (getStrokeAttribute().isDefault() || 0.0 == getStrokeAttribute().getFullDotDashLen()) + { + // no line dashing, just copy + aHairLinePolyPolygon.append(aB2DPolygon); + } + else + { + // apply LineStyle + basegfx::utils::applyLineDashing(aB2DPolygon, getStrokeAttribute().getDotDashArray(), + &aHairLinePolyPolygon, nullptr, + getStrokeAttribute().getFullDotDashLen()); + } - if(!getLineAttribute().isDefault() && getLineAttribute().getWidth()) - { - // create fat line data - const double fHalfLineWidth(getLineAttribute().getWidth() / 2.0); - const basegfx::B2DLineJoin aLineJoin(getLineAttribute().getLineJoin()); - const css::drawing::LineCap aLineCap(getLineAttribute().getLineCap()); - basegfx::B2DPolyPolygon aAreaPolyPolygon; - const double fMiterMinimumAngle(getLineAttribute().getMiterMinimumAngle()); - - for(sal_uInt32 a(0); a < nCount; a++) - { - // New version of createAreaGeometry; now creates bezier polygons - aAreaPolyPolygon.append(basegfx::utils::createAreaGeometry( - aHairLinePolyPolygon.getB2DPolygon(a), - fHalfLineWidth, - aLineJoin, - aLineCap, - basegfx::deg2rad(12.5) /* default fMaxAllowedAngle*/ , - 0.4 /* default fMaxPartOfEdge*/ , - fMiterMinimumAngle)); - } - - // create primitive - for(sal_uInt32 b(0); b < aAreaPolyPolygon.count(); b++) - { - // put into single polyPolygon primitives to make clear that this is NOT meant - // to be painted as a single tools::PolyPolygon (XORed as fill rule). Alternatively, a - // melting process may be used here one day. - const basegfx::B2DPolyPolygon aNewPolyPolygon(aAreaPolyPolygon.getB2DPolygon(b)); - const basegfx::BColor aColor(getLineAttribute().getColor()); - rContainer.push_back(new PolyPolygonColorPrimitive2D(aNewPolyPolygon, aColor)); - } - } - else - { - rContainer.push_back( - new PolyPolygonHairlinePrimitive2D( - aHairLinePolyPolygon, - getLineAttribute().getColor())); - } - } + const sal_uInt32 nCount(aHairLinePolyPolygon.count()); - PolygonStrokePrimitive2D::PolygonStrokePrimitive2D( - const basegfx::B2DPolygon& rPolygon, - const attribute::LineAttribute& rLineAttribute, - const attribute::StrokeAttribute& rStrokeAttribute) - : BufferedDecompositionPrimitive2D(), - maPolygon(rPolygon), - maLineAttribute(rLineAttribute), - maStrokeAttribute(rStrokeAttribute) + if (!getLineAttribute().isDefault() && getLineAttribute().getWidth()) + { + // create fat line data + const double fHalfLineWidth(getLineAttribute().getWidth() / 2.0); + const basegfx::B2DLineJoin aLineJoin(getLineAttribute().getLineJoin()); + const css::drawing::LineCap aLineCap(getLineAttribute().getLineCap()); + basegfx::B2DPolyPolygon aAreaPolyPolygon; + const double fMiterMinimumAngle(getLineAttribute().getMiterMinimumAngle()); + + for (sal_uInt32 a(0); a < nCount; a++) { - // MM01: keep these - these are no curve-decompposers but just checks - // simplify curve segments: moved here to not need to use it - // at VclPixelProcessor2D::tryDrawPolygonStrokePrimitive2DDirect - maPolygon = basegfx::utils::simplifyCurveSegments(maPolygon); + // New version of createAreaGeometry; now creates bezier polygons + aAreaPolyPolygon.append(basegfx::utils::createAreaGeometry( + aHairLinePolyPolygon.getB2DPolygon(a), fHalfLineWidth, aLineJoin, aLineCap, + basegfx::deg2rad(12.5) /* default fMaxAllowedAngle*/, + 0.4 /* default fMaxPartOfEdge*/, fMiterMinimumAngle)); } - PolygonStrokePrimitive2D::PolygonStrokePrimitive2D( - const basegfx::B2DPolygon& rPolygon, - const attribute::LineAttribute& rLineAttribute) - : BufferedDecompositionPrimitive2D(), - maPolygon(rPolygon), - maLineAttribute(rLineAttribute), - maStrokeAttribute() + // create primitive + for (sal_uInt32 b(0); b < aAreaPolyPolygon.count(); b++) { - // MM01: keep these - these are no curve-decompposers but just checks - // simplify curve segments: moved here to not need to use it - // at VclPixelProcessor2D::tryDrawPolygonStrokePrimitive2DDirect - maPolygon = basegfx::utils::simplifyCurveSegments(maPolygon); + // put into single polyPolygon primitives to make clear that this is NOT meant + // to be painted as a single tools::PolyPolygon (XORed as fill rule). Alternatively, a + // melting process may be used here one day. + const basegfx::B2DPolyPolygon aNewPolyPolygon(aAreaPolyPolygon.getB2DPolygon(b)); + const basegfx::BColor aColor(getLineAttribute().getColor()); + rContainer.push_back(new PolyPolygonColorPrimitive2D(aNewPolyPolygon, aColor)); } + } + else + { + rContainer.push_back(new PolyPolygonHairlinePrimitive2D(aHairLinePolyPolygon, + getLineAttribute().getColor())); + } +} + +PolygonStrokePrimitive2D::PolygonStrokePrimitive2D( + const basegfx::B2DPolygon& rPolygon, const attribute::LineAttribute& rLineAttribute, + const attribute::StrokeAttribute& rStrokeAttribute) + : BufferedDecompositionPrimitive2D() + , maPolygon(rPolygon) + , maLineAttribute(rLineAttribute) + , maStrokeAttribute(rStrokeAttribute) +{ + // MM01: keep these - these are no curve-decompposers but just checks + // simplify curve segments: moved here to not need to use it + // at VclPixelProcessor2D::tryDrawPolygonStrokePrimitive2DDirect + maPolygon = basegfx::utils::simplifyCurveSegments(maPolygon); +} + +PolygonStrokePrimitive2D::PolygonStrokePrimitive2D(const basegfx::B2DPolygon& rPolygon, + const attribute::LineAttribute& rLineAttribute) + : BufferedDecompositionPrimitive2D() + , maPolygon(rPolygon) + , maLineAttribute(rLineAttribute) + , maStrokeAttribute() +{ + // MM01: keep these - these are no curve-decompposers but just checks + // simplify curve segments: moved here to not need to use it + // at VclPixelProcessor2D::tryDrawPolygonStrokePrimitive2DDirect + maPolygon = basegfx::utils::simplifyCurveSegments(maPolygon); +} - bool PolygonStrokePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const - { - if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) - { - const PolygonStrokePrimitive2D& rCompare = static_cast<const PolygonStrokePrimitive2D&>(rPrimitive); +bool PolygonStrokePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const +{ + if (BufferedDecompositionPrimitive2D::operator==(rPrimitive)) + { + const PolygonStrokePrimitive2D& rCompare + = static_cast<const PolygonStrokePrimitive2D&>(rPrimitive); - return (getB2DPolygon() == rCompare.getB2DPolygon() - && getLineAttribute() == rCompare.getLineAttribute() - && getStrokeAttribute() == rCompare.getStrokeAttribute()); - } + return (getB2DPolygon() == rCompare.getB2DPolygon() + && getLineAttribute() == rCompare.getLineAttribute() + && getStrokeAttribute() == rCompare.getStrokeAttribute()); + } - return false; - } + return false; +} - basegfx::B2DRange PolygonStrokePrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const - { - basegfx::B2DRange aRetval; +basegfx::B2DRange +PolygonStrokePrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const +{ + basegfx::B2DRange aRetval; - if(getLineAttribute().getWidth()) - { - bool bUseDecomposition(false); - - if(basegfx::B2DLineJoin::Miter == getLineAttribute().getLineJoin()) - { - // if line is mitered, use parent call since mitered line - // geometry may use more space than the geometry grown by half line width - bUseDecomposition = true; - } - - if(!bUseDecomposition && css::drawing::LineCap_SQUARE == getLineAttribute().getLineCap()) - { - // when drawing::LineCap_SQUARE is used the below method to grow the polygon - // range by half line width will not work, so use decomposition. Interestingly, - // the grow method below works perfectly for LineCap_ROUND since the grow is in - // all directions and the rounded cap needs the same grow in all directions independent - // from its orientation. Unfortunately this is not the case for drawing::LineCap_SQUARE - bUseDecomposition = true; - } - - if (bUseDecomposition) - { - // get correct range by using the decomposition fallback, reasons see above cases - - // ofz#947 to optimize calculating the range, turn any slow dashes into a solid line - // when just calculating bounds - attribute::StrokeAttribute aOrigStrokeAttribute = maStrokeAttribute; - const_cast<PolygonStrokePrimitive2D*>(this)->maStrokeAttribute = attribute::StrokeAttribute(); - aRetval = BufferedDecompositionPrimitive2D::getB2DRange(rViewInformation); - const_cast<PolygonStrokePrimitive2D*>(this)->maStrokeAttribute = aOrigStrokeAttribute; - } - else - { - // for all other B2DLINEJOIN_* get the range from the base geometry - // and expand by half the line width - aRetval = getB2DPolygon().getB2DRange(); - aRetval.grow(getLineAttribute().getWidth() * 0.5); - } - } - else - { - // this is a hairline, thus the line width is view-dependent. Get range of polygon - // as base size - aRetval = getB2DPolygon().getB2DRange(); - - if(!aRetval.isEmpty()) - { - // Calculate view-dependent hairline width - const basegfx::B2DVector aDiscreteSize(rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 0.0)); - const double fDiscreteHalfLineWidth(aDiscreteSize.getLength() * 0.5); - - if(basegfx::fTools::more(fDiscreteHalfLineWidth, 0.0)) - { - aRetval.grow(fDiscreteHalfLineWidth); - } - } - } + if (getLineAttribute().getWidth()) + { + bool bUseDecomposition(false); - return aRetval; + if (basegfx::B2DLineJoin::Miter == getLineAttribute().getLineJoin()) + { + // if line is mitered, use parent call since mitered line + // geometry may use more space than the geometry grown by half line width + bUseDecomposition = true; } - // provide unique ID - ImplPrimitive2DIDBlock(PolygonStrokePrimitive2D, PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D) - - - - void PolygonWavePrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& /*rViewInformation*/) const + if (!bUseDecomposition && css::drawing::LineCap_SQUARE == getLineAttribute().getLineCap()) { - if(!getB2DPolygon().count()) - return; - - const bool bHasWidth(!basegfx::fTools::equalZero(getWaveWidth())); - const bool bHasHeight(!basegfx::fTools::equalZero(getWaveHeight())); - - if(bHasWidth && bHasHeight) - { - // create waveline curve - const basegfx::B2DPolygon aWaveline(basegfx::utils::createWaveline(getB2DPolygon(), getWaveWidth(), getWaveHeight())); - rContainer.push_back(new PolygonStrokePrimitive2D(aWaveline, getLineAttribute(), getStrokeAttribute())); - } - else - { - // flat waveline, decompose to simple line primitive - rContainer.push_back(new PolygonStrokePrimitive2D(getB2DPolygon(), getLineAttribute(), getStrokeAttribute())); - } + // when drawing::LineCap_SQUARE is used the below method to grow the polygon + // range by half line width will not work, so use decomposition. Interestingly, + // the grow method below works perfectly for LineCap_ROUND since the grow is in + // all directions and the rounded cap needs the same grow in all directions independent + // from its orientation. Unfortunately this is not the case for drawing::LineCap_SQUARE + bUseDecomposition = true; } - PolygonWavePrimitive2D::PolygonWavePrimitive2D( - const basegfx::B2DPolygon& rPolygon, - const attribute::LineAttribute& rLineAttribute, - const attribute::StrokeAttribute& rStrokeAttribute, - double fWaveWidth, - double fWaveHeight) - : PolygonStrokePrimitive2D(rPolygon, rLineAttribute, rStrokeAttribute), - mfWaveWidth(fWaveWidth), - mfWaveHeight(fWaveHeight) + if (bUseDecomposition) { - if(mfWaveWidth < 0.0) - { - mfWaveWidth = 0.0; - } - - if(mfWaveHeight < 0.0) - { - mfWaveHeight = 0.0; - } + // get correct range by using the decomposition fallback, reasons see above cases + + // ofz#947 to optimize calculating the range, turn any slow dashes into a solid line + // when just calculating bounds + attribute::StrokeAttribute aOrigStrokeAttribute = maStrokeAttribute; + const_cast<PolygonStrokePrimitive2D*>(this)->maStrokeAttribute + = attribute::StrokeAttribute(); + aRetval = BufferedDecompositionPrimitive2D::getB2DRange(rViewInformation); + const_cast<PolygonStrokePrimitive2D*>(this)->maStrokeAttribute = aOrigStrokeAttribute; } + else + { + // for all other B2DLINEJOIN_* get the range from the base geometry + // and expand by half the line width + aRetval = getB2DPolygon().getB2DRange(); + aRetval.grow(getLineAttribute().getWidth() * 0.5); + } + } + else + { + // this is a hairline, thus the line width is view-dependent. Get range of polygon + // as base size + aRetval = getB2DPolygon().getB2DRange(); - PolygonWavePrimitive2D::PolygonWavePrimitive2D( - const basegfx::B2DPolygon& rPolygon, - const attribute::LineAttribute& rLineAttribute, - double fWaveWidth, - double fWaveHeight) - : PolygonStrokePrimitive2D(rPolygon, rLineAttribute), - mfWaveWidth(fWaveWidth), - mfWaveHeight(fWaveHeight) + if (!aRetval.isEmpty()) { - if(mfWaveWidth < 0.0) - { - mfWaveWidth = 0.0; - } + // Calculate view-dependent hairline width + const basegfx::B2DVector aDiscreteSize( + rViewInformation.getInverseObjectToViewTransformation() + * basegfx::B2DVector(1.0, 0.0)); + const double fDiscreteHalfLineWidth(aDiscreteSize.getLength() * 0.5); - if(mfWaveHeight < 0.0) + if (basegfx::fTools::more(fDiscreteHalfLineWidth, 0.0)) { - mfWaveHeight = 0.0; + aRetval.grow(fDiscreteHalfLineWidth); } } + } - bool PolygonWavePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const - { - if(PolygonStrokePrimitive2D::operator==(rPrimitive)) - { - const PolygonWavePrimitive2D& rCompare = static_cast<const PolygonWavePrimitive2D&>(rPrimitive); + return aRetval; +} - return (getWaveWidth() == rCompare.getWaveWidth() - && getWaveHeight() == rCompare.getWaveHeight()); - } +// provide unique ID +ImplPrimitive2DIDBlock(PolygonStrokePrimitive2D, PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D) - return false; - } + void PolygonWavePrimitive2D::create2DDecomposition( + Primitive2DContainer& rContainer, + const geometry::ViewInformation2D& /*rViewInformation*/) const +{ + if (!getB2DPolygon().count()) + return; - basegfx::B2DRange PolygonWavePrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const - { - // get range of parent - basegfx::B2DRange aRetval(PolygonStrokePrimitive2D::getB2DRange(rViewInformation)); + const bool bHasWidth(!basegfx::fTools::equalZero(getWaveWidth())); + const bool bHasHeight(!basegfx::fTools::equalZero(getWaveHeight())); - // if WaveHeight, grow by it - if(basegfx::fTools::more(getWaveHeight(), 0.0)) - { - aRetval.grow(getWaveHeight()); - } + if (bHasWidth && bHasHeight) + { + // create waveline curve + const basegfx::B2DPolygon aWaveline( + basegfx::utils::createWaveline(getB2DPolygon(), getWaveWidth(), getWaveHeight())); + rContainer.push_back( + new PolygonStrokePrimitive2D(aWaveline, getLineAttribute(), getStrokeAttribute())); + } + else + { + // flat waveline, decompose to simple line primitive + rContainer.push_back(new PolygonStrokePrimitive2D(getB2DPolygon(), getLineAttribute(), + getStrokeAttribute())); + } +} + +PolygonWavePrimitive2D::PolygonWavePrimitive2D(const basegfx::B2DPolygon& rPolygon, + const attribute::LineAttribute& rLineAttribute, + const attribute::StrokeAttribute& rStrokeAttribute, + double fWaveWidth, double fWaveHeight) + : PolygonStrokePrimitive2D(rPolygon, rLineAttribute, rStrokeAttribute) + , mfWaveWidth(fWaveWidth) + , mfWaveHeight(fWaveHeight) +{ + if (mfWaveWidth < 0.0) + { + mfWaveWidth = 0.0; + } - // if line width, grow by it - if(basegfx::fTools::more(getLineAttribute().getWidth(), 0.0)) - { - aRetval.grow(getLineAttribute().getWidth() * 0.5); - } + if (mfWaveHeight < 0.0) + { + mfWaveHeight = 0.0; + } +} + +PolygonWavePrimitive2D::PolygonWavePrimitive2D(const basegfx::B2DPolygon& rPolygon, + const attribute::LineAttribute& rLineAttribute, + double fWaveWidth, double fWaveHeight) + : PolygonStrokePrimitive2D(rPolygon, rLineAttribute) + , mfWaveWidth(fWaveWidth) + , mfWaveHeight(fWaveHeight) +{ + if (mfWaveWidth < 0.0) + { + mfWaveWidth = 0.0; + } - return aRetval; - } + if (mfWaveHeight < 0.0) + { + mfWaveHeight = 0.0; + } +} - // provide unique ID - ImplPrimitive2DIDBlock(PolygonWavePrimitive2D, PRIMITIVE2D_ID_POLYGONWAVEPRIMITIVE2D) +bool PolygonWavePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const +{ + if (PolygonStrokePrimitive2D::operator==(rPrimitive)) + { + const PolygonWavePrimitive2D& rCompare + = static_cast<const PolygonWavePrimitive2D&>(rPrimitive); + return (getWaveWidth() == rCompare.getWaveWidth() + && getWaveHeight() == rCompare.getWaveHeight()); + } - void PolygonStrokeArrowPrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& /*rViewInformation*/) const - { - // copy local polygon, it may be changed - basegfx::B2DPolygon aLocalPolygon(getB2DPolygon()); - aLocalPolygon.removeDoublePoints(); - basegfx::B2DPolyPolygon aArrowA; - basegfx::B2DPolyPolygon aArrowB; + return false; +} - if(!aLocalPolygon.isClosed() && aLocalPolygon.count() > 1) - { - // apply arrows - const double fPolyLength(basegfx::utils::getLength(aLocalPolygon)); - double fStart(0.0); - double fEnd(0.0); - double fStartOverlap(0.0); - double fEndOverlap(0.0); - - if(!getStart().isDefault() && getStart().isActive()) - { - // create start arrow primitive and consume - aArrowA = basegfx::utils::createAreaGeometryForLineStartEnd( - aLocalPolygon, getStart().getB2DPolyPolygon(), true, getStart().getWidth(), - fPolyLength, getStart().isCentered() ? 0.5 : 0.0, &fStart); - - // create some overlapping, compromise between straight and peaked markers - // for marker width 0.3cm and marker line width 0.02cm - fStartOverlap = getStart().getWidth() / 15.0; - } - - if(!getEnd().isDefault() && getEnd().isActive()) - { - // create end arrow primitive and consume - aArrowB = basegfx::utils::createAreaGeometryForLineStartEnd( - aLocalPolygon, getEnd().getB2DPolyPolygon(), false, getEnd().getWidth(), - fPolyLength, getEnd().isCentered() ? 0.5 : 0.0, &fEnd); - - // create some overlapping - fEndOverlap = getEnd().getWidth() / 15.0; - } - - if(0.0 != fStart || 0.0 != fEnd) - { - // build new poly, consume something from old poly - aLocalPolygon = basegfx::utils::getSnippetAbsolute(aLocalPolygon, fStart-fStartOverlap, fPolyLength - fEnd + fEndOverlap, fPolyLength); - } - } +basegfx::B2DRange +PolygonWavePrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const +{ + // get range of parent + basegfx::B2DRange aRetval(PolygonStrokePrimitive2D::getB2DRange(rViewInformation)); - // add shaft - rContainer.push_back(new - PolygonStrokePrimitive2D( - aLocalPolygon, getLineAttribute(), getStrokeAttribute())); + // if WaveHeight, grow by it + if (basegfx::fTools::more(getWaveHeight(), 0.0)) + { + aRetval.grow(getWaveHeight()); + } - if(aArrowA.count()) - { - rContainer.push_back( - new PolyPolygonColorPrimitive2D( - aArrowA, getLineAttribute().getColor())); - } + // if line width, grow by it + if (basegfx::fTools::more(getLineAttribute().getWidth(), 0.0)) + { + aRetval.grow(getLineAttribute().getWidth() * 0.5); + } - if(aArrowB.count()) - { - rContainer.push_back( - new PolyPolygonColorPrimitive2D( - aArrowB, getLineAttribute().getColor())); - } - } + return aRetval; +} - PolygonStrokeArrowPrimitive2D::PolygonStrokeArrowPrimitive2D( - const basegfx::B2DPolygon& rPolygon, - const attribute::LineAttribute& rLineAttribute, - const attribute::StrokeAttribute& rStrokeAttribute, - const attribute::LineStartEndAttribute& rStart, - const attribute::LineStartEndAttribute& rEnd) - : PolygonStrokePrimitive2D(rPolygon, rLineAttribute, rStrokeAttribute), - maStart(rStart), - maEnd(rEnd) - { - } +// provide unique ID +ImplPrimitive2DIDBlock(PolygonWavePrimitive2D, PRIMITIVE2D_ID_POLYGONWAVEPRIMITIVE2D) + + void PolygonStrokeArrowPrimitive2D::create2DDecomposition( + Primitive2DContainer& rContainer, + const geometry::ViewInformation2D& /*rViewInformation*/) const +{ + // copy local polygon, it may be changed + basegfx::B2DPolygon aLocalPolygon(getB2DPolygon()); + aLocalPolygon.removeDoublePoints(); + basegfx::B2DPolyPolygon aArrowA; + basegfx::B2DPolyPolygon aArrowB; - PolygonStrokeArrowPrimitive2D::PolygonStrokeArrowPrimitive2D( - const basegfx::B2DPolygon& rPolygon, - const attribute::LineAttribute& rLineAttribute, - const attribute::LineStartEndAttribute& rStart, - const attribute::LineStartEndAttribute& rEnd) - : PolygonStrokePrimitive2D(rPolygon, rLineAttribute), - maStart(rStart), - maEnd(rEnd) + if (!aLocalPolygon.isClosed() && aLocalPolygon.count() > 1) + { + // apply arrows + const double fPolyLength(basegfx::utils::getLength(aLocalPolygon)); + double fStart(0.0); + double fEnd(0.0); + double fStartOverlap(0.0); + double fEndOverlap(0.0); + + if (!getStart().isDefault() && getStart().isActive()) { + // create start arrow primitive and consume + aArrowA = basegfx::utils::createAreaGeometryForLineStartEnd( + aLocalPolygon, getStart().getB2DPolyPolygon(), true, getStart().getWidth(), + fPolyLength, getStart().isCentered() ? 0.5 : 0.0, &fStart); + + // create some overlapping, compromise between straight and peaked markers + // for marker width 0.3cm and marker line width 0.02cm + fStartOverlap = getStart().getWidth() / 15.0; } - bool PolygonStrokeArrowPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + if (!getEnd().isDefault() && getEnd().isActive()) { - if(PolygonStrokePrimitive2D::operator==(rPrimitive)) - { - const PolygonStrokeArrowPrimitive2D& rCompare = static_cast<const PolygonStrokeArrowPrimitive2D&>(rPrimitive); - - return (getStart() == rCompare.getStart() - && getEnd() == rCompare.getEnd()); - } + // create end arrow primitive and consume + aArrowB = basegfx::utils::createAreaGeometryForLineStartEnd( + aLocalPolygon, getEnd().getB2DPolyPolygon(), false, getEnd().getWidth(), + fPolyLength, getEnd().isCentered() ? 0.5 : 0.0, &fEnd); - return false; + // create some overlapping + fEndOverlap = getEnd().getWidth() / 15.0; } - basegfx::B2DRange PolygonStrokeArrowPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const + if (0.0 != fStart || 0.0 != fEnd) { - if(getStart().isActive() || getEnd().isActive()) - { - // use decomposition when line start/end is used - return BufferedDecompositionPrimitive2D::getB2DRange(rViewInformation); - } - else - { - // get range from parent - return PolygonStrokePrimitive2D::getB2DRange(rViewInformation); - } + // build new poly, consume something from old poly + aLocalPolygon + = basegfx::utils::getSnippetAbsolute(aLocalPolygon, fStart - fStartOverlap, + fPolyLength - fEnd + fEndOverlap, fPolyLength); } + } + + // add shaft + rContainer.push_back( + new PolygonStrokePrimitive2D(aLocalPolygon, getLineAttribute(), getStrokeAttribute())); + + if (aArrowA.count()) + { + rContainer.push_back( + new PolyPolygonColorPrimitive2D(aArrowA, getLineAttribute().getColor())); + } + + if (aArrowB.count()) + { + rContainer.push_back( + new PolyPolygonColorPrimitive2D(aArrowB, getLineAttribute().getColor())); + } +} + +PolygonStrokeArrowPrimitive2D::PolygonStrokeArrowPrimitive2D( + const basegfx::B2DPolygon& rPolygon, const attribute::LineAttribute& rLineAttribute, + const attribute::StrokeAttribute& rStrokeAttribute, + const attribute::LineStartEndAttribute& rStart, const attribute::LineStartEndAttribute& rEnd) + : PolygonStrokePrimitive2D(rPolygon, rLineAttribute, rStrokeAttribute) + , maStart(rStart) + , maEnd(rEnd) +{ +} + +PolygonStrokeArrowPrimitive2D::PolygonStrokeArrowPrimitive2D( + const basegfx::B2DPolygon& rPolygon, const attribute::LineAttribute& rLineAttribute, + const attribute::LineStartEndAttribute& rStart, const attribute::LineStartEndAttribute& rEnd) + : PolygonStrokePrimitive2D(rPolygon, rLineAttribute) + , maStart(rStart) + , maEnd(rEnd) +{ +} + +bool PolygonStrokeArrowPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const +{ + if (PolygonStrokePrimitive2D::operator==(rPrimitive)) + { + const PolygonStrokeArrowPrimitive2D& rCompare + = static_cast<const PolygonStrokeArrowPrimitive2D&>(rPrimitive); + + return (getStart() == rCompare.getStart() && getEnd() == rCompare.getEnd()); + } + + return false; +} + +basegfx::B2DRange PolygonStrokeArrowPrimitive2D::getB2DRange( + const geometry::ViewInformation2D& rViewInformation) const +{ + if (getStart().isActive() || getEnd().isActive()) + { + // use decomposition when line start/end is used + return BufferedDecompositionPrimitive2D::getB2DRange(rViewInformation); + } + else + { + // get range from parent + return PolygonStrokePrimitive2D::getB2DRange(rViewInformation); + } +} - // provide unique ID - ImplPrimitive2DIDBlock(PolygonStrokeArrowPrimitive2D, PRIMITIVE2D_ID_POLYGONSTROKEARROWPRIMITIVE2D) +// provide unique ID +ImplPrimitive2DIDBlock(PolygonStrokeArrowPrimitive2D, PRIMITIVE2D_ID_POLYGONSTROKEARROWPRIMITIVE2D) } // end of namespace diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist index 4ec89ee96039..ee8dcf12b344 100644 --- a/solenv/clang-format/excludelist +++ b/solenv/clang-format/excludelist @@ -3684,7 +3684,6 @@ drawinglayer/source/primitive2d/pagehierarchyprimitive2d.cxx drawinglayer/source/primitive2d/pagepreviewprimitive2d.cxx drawinglayer/source/primitive2d/patternfillprimitive2d.cxx drawinglayer/source/primitive2d/pointarrayprimitive2d.cxx -drawinglayer/source/primitive2d/polygonprimitive2d.cxx drawinglayer/source/primitive2d/primitivetools2d.cxx drawinglayer/source/primitive2d/sceneprimitive2d.cxx drawinglayer/source/primitive2d/sdrdecompositiontools2d.cxx commit c92b0d796e7aef7b88bdaa040d4a6a45a1d7a03d Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Fri Jul 17 15:09:49 2020 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Thu Aug 13 10:19:28 2020 +0200 Revert "hack for gradients split into adjacent polygons (tdf#133016)" This reverts commit 777ac5456a1f24fea29931ede983b5b8ad9a063d. diff --git a/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx b/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx index e6906a638084..d3e32e22ea46 100644 --- a/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx @@ -30,7 +30,7 @@ #include <drawinglayer/geometry/viewinformation2d.hxx> #include <sal/log.hxx> #include <cmath> -#include <vcl/skia/SkiaHelper.hxx> + using namespace com::sun::star; @@ -868,12 +868,6 @@ namespace drawinglayer::primitive2d // use color distance and discrete lengths to calculate step count const sal_uInt32 nSteps(calculateStepsForSvgGradient(getColorA(), getColorB(), fDelta, fDiscreteUnit)); - // HACK: Splitting a gradient into adjacent polygons with gradually changing color is silly. - // If antialiasing is used to draw them, the AA-ed adjacent edges won't line up perfectly - // because of the AA (see SkiaSalGraphicsImpl::mergePolyPolygonToPrevious()). - // Make the polygons a bit wider, so they the partial overlap "fixes" this. - const double fixup = SkiaHelper::isVCLSkiaEnabled() ? fDiscreteUnit / 2 : 0; - // tdf#117949 Use a small amount of discrete overlap at the edges. Usually this // should be exactly 0.0 and 1.0, but there were cases when this gets clipped // against the mask polygon which got numerically problematic. @@ -887,7 +881,7 @@ namespace drawinglayer::primitive2d basegfx::B2DRange( getOffsetA() - fDiscreteUnit, -0.0001, // TTTT -> should be 0.0, see comment above - getOffsetA() + (fDelta / nSteps) + fDiscreteUnit + fixup, + getOffsetA() + (fDelta / nSteps) + fDiscreteUnit, 1.0001))); // TTTT -> should be 1.0, see comment above // prepare loop (inside to outside, [0.0 .. 1.0[) commit 69f23e612d5a4a76e942bb4a9fe695cf93d6f0ff Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Tue Jul 14 22:44:13 2020 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Thu Aug 13 10:19:28 2020 +0200 remove texteffectprimitive2d.{cxx,hxx} from clang-format blacklist Change-Id: I57a47358d5e4f1e41fc1c89884b7603d8afdc3bd diff --git a/drawinglayer/inc/primitive2d/texteffectprimitive2d.hxx b/drawinglayer/inc/primitive2d/texteffectprimitive2d.hxx index ac2343220316..9a856c9f6f59 100644 --- a/drawinglayer/inc/primitive2d/texteffectprimitive2d.hxx +++ b/drawinglayer/inc/primitive2d/texteffectprimitive2d.hxx @@ -20,79 +20,79 @@ #pragma once #include <drawinglayer/drawinglayerdllapi.h> - #include <drawinglayer/primitive2d/baseprimitive2d.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> - namespace drawinglayer::primitive2d - { - /** TextEffectStyle2D definition */ - enum class TextEffectStyle2D - { - ReliefEmbossedDefault, - ReliefEngravedDefault, - ReliefEmbossed, - ReliefEngraved, - Outline - }; - - /** TextEffectPrimitive2D class - - This primitive embeds text primitives (normally, as can be seen can - also be used for any other primitives) which have some TextEffect applied - and create the needed geometry and embedding on decomposition. - */ - class TextEffectPrimitive2D final : public BufferedDecompositionPrimitive2D - { - private: - /// the text (or other) content - Primitive2DContainer maTextContent; - - /// the style to apply, the direction and the rotation center - const basegfx::B2DPoint maRotationCenter; - double mfDirection; - TextEffectStyle2D meTextEffectStyle2D; - - /** the last used object to view transformtion used from getDecomposition - for decide buffering - */ - basegfx::B2DHomMatrix maLastObjectToViewTransformation; - - /// create local decomposition - virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; - - public: - /// constructor - TextEffectPrimitive2D( - const Primitive2DContainer& rTextContent, - const basegfx::B2DPoint& rRotationCenter, - double fDirection, - TextEffectStyle2D eTextEffectStyle2D); - - /// data read access - const Primitive2DContainer& getTextContent() const { return maTextContent; } - const basegfx::B2DPoint& getRotationCenter() const { return maRotationCenter; } - double getDirection() const { return mfDirection; } - TextEffectStyle2D getTextEffectStyle2D() const { return meTextEffectStyle2D; } - - /// compare operator - virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; - - /** own get range implementation to solve more effective. Content is by definition displaced - by a fixed discrete unit, thus the contained geometry needs only once be asked for its - own basegfx::B2DRange - */ - virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; - - /// provide unique ID - virtual sal_uInt32 getPrimitive2DID() const override; - - /// Override standard getDecomposition to be view-dependent here - virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override; - }; - -} // end of namespace drawinglayer::primitive2d - +{ +/** TextEffectStyle2D definition */ +enum class TextEffectStyle2D +{ + ReliefEmbossedDefault, + ReliefEngravedDefault, + ReliefEmbossed, + ReliefEngraved, + Outline +}; + +/** TextEffectPrimitive2D class + + This primitive embeds text primitives (normally, as can be seen can + also be used for any other primitives) which have some TextEffect applied + and create the needed geometry and embedding on decomposition. +*/ +class TextEffectPrimitive2D final : public BufferedDecompositionPrimitive2D +{ +private: + /// the text (or other) content + Primitive2DContainer maTextContent; + + /// the style to apply, the direction and the rotation center + const basegfx::B2DPoint maRotationCenter; + double mfDirection; + TextEffectStyle2D meTextEffectStyle2D; + + /** the last used object to view transformtion used from getDecomposition + for decide buffering + */ + basegfx::B2DHomMatrix maLastObjectToViewTransformation; + + /// create local decomposition + virtual void + create2DDecomposition(Primitive2DContainer& rContainer, + const geometry::ViewInformation2D& rViewInformation) const override; + +public: + /// constructor + TextEffectPrimitive2D(const Primitive2DContainer& rTextContent, + const basegfx::B2DPoint& rRotationCenter, double fDirection, + TextEffectStyle2D eTextEffectStyle2D); + + /// data read access + const Primitive2DContainer& getTextContent() const { return maTextContent; } + const basegfx::B2DPoint& getRotationCenter() const { return maRotationCenter; } + double getDirection() const { return mfDirection; } + TextEffectStyle2D getTextEffectStyle2D() const { return meTextEffectStyle2D; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /** own get range implementation to solve more effective. Content is by definition displaced + by a fixed discrete unit, thus the contained geometry needs only once be asked for its + own basegfx::B2DRange + */ + virtual basegfx::B2DRange + getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + + /// Override standard getDecomposition to be view-dependent here + virtual void + get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, + const geometry::ViewInformation2D& rViewInformation) const override; +}; + +} // end of namespace primitive2d::drawinglayer /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/source/primitive2d/texteffectprimitive2d.cxx b/drawinglayer/source/primitive2d/texteffectprimitive2d.cxx index abfe28e3ecca..fbd3dfd14332 100644 --- a/drawinglayer/source/primitive2d/texteffectprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/texteffectprimitive2d.cxx @@ -24,222 +24,213 @@ #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> #include <basegfx/matrix/b2dhommatrixtools.hxx> - namespace drawinglayer::primitive2d { - const double fDiscreteSize(1.1); +const double fDiscreteSize(1.1); - void TextEffectPrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const +void TextEffectPrimitive2D::create2DDecomposition( + Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const +{ + // get the distance of one discrete units from target display. Use between 1.0 and sqrt(2) to + // have good results on rotated objects, too + const basegfx::B2DVector aDistance(rViewInformation.getInverseObjectToViewTransformation() + * basegfx::B2DVector(fDiscreteSize, fDiscreteSize)); + const basegfx::B2DVector aDiagonalDistance(aDistance * (1.0 / 1.44)); + + switch (getTextEffectStyle2D()) + { + case TextEffectStyle2D::ReliefEmbossed: + case TextEffectStyle2D::ReliefEngraved: + case TextEffectStyle2D::ReliefEmbossedDefault: + case TextEffectStyle2D::ReliefEngravedDefault: { - // get the distance of one discrete units from target display. Use between 1.0 and sqrt(2) to - // have good results on rotated objects, too - const basegfx::B2DVector aDistance(rViewInformation.getInverseObjectToViewTransformation() * - basegfx::B2DVector(fDiscreteSize, fDiscreteSize)); - const basegfx::B2DVector aDiagonalDistance(aDistance * (1.0 / 1.44)); - - switch(getTextEffectStyle2D()) + // prepare transform of sub-group back to (0,0) and align to X-Axis + basegfx::B2DHomMatrix aBackTransform(basegfx::utils::createTranslateB2DHomMatrix( + -getRotationCenter().getX(), -getRotationCenter().getY())); + aBackTransform.rotate(-getDirection()); + + // prepare transform of sub-group back to its position and rotation + basegfx::B2DHomMatrix aForwardTransform( + basegfx::utils::createRotateB2DHomMatrix(getDirection())); + aForwardTransform.translate(getRotationCenter().getX(), getRotationCenter().getY()); + + // create transformation for one discrete unit + const bool bEmbossed(TextEffectStyle2D::ReliefEmbossed == getTextEffectStyle2D() + || TextEffectStyle2D::ReliefEmbossedDefault + == getTextEffectStyle2D()); + const bool bDefaultTextColor( + TextEffectStyle2D::ReliefEmbossedDefault == getTextEffectStyle2D() + || TextEffectStyle2D::ReliefEngravedDefault == getTextEffectStyle2D()); + basegfx::B2DHomMatrix aTransform(aBackTransform); + + if (bEmbossed) { - case TextEffectStyle2D::ReliefEmbossed: - case TextEffectStyle2D::ReliefEngraved: - case TextEffectStyle2D::ReliefEmbossedDefault: - case TextEffectStyle2D::ReliefEngravedDefault: - { - // prepare transform of sub-group back to (0,0) and align to X-Axis - basegfx::B2DHomMatrix aBackTransform(basegfx::utils::createTranslateB2DHomMatrix( - -getRotationCenter().getX(), -getRotationCenter().getY())); - aBackTransform.rotate(-getDirection()); - - // prepare transform of sub-group back to its position and rotation - basegfx::B2DHomMatrix aForwardTransform(basegfx::utils::createRotateB2DHomMatrix(getDirection())); - aForwardTransform.translate(getRotationCenter().getX(), getRotationCenter().getY()); - - // create transformation for one discrete unit - const bool bEmbossed( - TextEffectStyle2D::ReliefEmbossed == getTextEffectStyle2D() - || TextEffectStyle2D::ReliefEmbossedDefault == getTextEffectStyle2D()); - const bool bDefaultTextColor( - TextEffectStyle2D::ReliefEmbossedDefault == getTextEffectStyle2D() - || TextEffectStyle2D::ReliefEngravedDefault == getTextEffectStyle2D()); - basegfx::B2DHomMatrix aTransform(aBackTransform); - - if(bEmbossed) - { - // to bottom-right - aTransform.translate(aDiagonalDistance.getX(), aDiagonalDistance.getY()); - } - else - { - // to top-left - aTransform.translate(-aDiagonalDistance.getX(), -aDiagonalDistance.getY()); - } - - aTransform *= aForwardTransform; - - if(bDefaultTextColor) - { - // emboss/engrave in black, original forced to white - const basegfx::BColorModifierSharedPtr aBColorModifierToGray = - std::make_shared<basegfx::BColorModifier_replace>( - basegfx::BColor(0.0)); - const Primitive2DReference xModifiedColor( - new ModifiedColorPrimitive2D( - getTextContent(), - aBColorModifierToGray)); - - rContainer.push_back( - new TransformPrimitive2D( - aTransform, - Primitive2DContainer { xModifiedColor })); - - // add original, too - const basegfx::BColorModifierSharedPtr aBColorModifierToWhite = - std::make_shared<basegfx::BColorModifier_replace>( - basegfx::BColor(1.0)); - - rContainer.push_back( - new ModifiedColorPrimitive2D( - getTextContent(), - aBColorModifierToWhite)); - } - else - { - // emboss/engrave in gray, keep original's color - const basegfx::BColorModifierSharedPtr aBColorModifierToGray = - std::make_shared<basegfx::BColorModifier_replace>( - basegfx::BColor(0.75)); // 192 - const Primitive2DReference xModifiedColor( - new ModifiedColorPrimitive2D( - getTextContent(), - aBColorModifierToGray)); - - rContainer.push_back( - new TransformPrimitive2D( - aTransform, - Primitive2DContainer { xModifiedColor })); - - // add original, too - rContainer.push_back(new GroupPrimitive2D(getTextContent())); - } - - break; - } - case TextEffectStyle2D::Outline: - { - // create transform primitives in all directions - basegfx::B2DHomMatrix aTransform; - - aTransform.set(0, 2, aDistance.getX()); - aTransform.set(1, 2, 0.0); - rContainer.push_back(new TransformPrimitive2D(aTransform, getTextContent())); - - aTransform.set(0, 2, aDiagonalDistance.getX()); - aTransform.set(1, 2, aDiagonalDistance.getY()); - rContainer.push_back(new TransformPrimitive2D(aTransform, getTextContent())); - - aTransform.set(0, 2, 0.0); - aTransform.set(1, 2, aDistance.getY()); - rContainer.push_back(new TransformPrimitive2D(aTransform, getTextContent())); - - aTransform.set(0, 2, -aDiagonalDistance.getX()); - aTransform.set(1, 2, aDiagonalDistance.getY()); - rContainer.push_back(new TransformPrimitive2D(aTransform, getTextContent())); - - aTransform.set(0, 2, -aDistance.getX()); - aTransform.set(1, 2, 0.0); - rContainer.push_back(new TransformPrimitive2D(aTransform, getTextContent())); - - aTransform.set(0, 2, -aDiagonalDistance.getX()); - aTransform.set(1, 2, -aDiagonalDistance.getY()); - rContainer.push_back(new TransformPrimitive2D(aTransform, getTextContent())); - - aTransform.set(0, 2, 0.0); - aTransform.set(1, 2, -aDistance.getY()); - rContainer.push_back(new TransformPrimitive2D(aTransform, getTextContent())); - - aTransform.set(0, 2, aDiagonalDistance.getX()); - aTransform.set(1, 2, -aDiagonalDistance.getY()); - rContainer.push_back(new TransformPrimitive2D(aTransform, getTextContent())); - - // at last, place original over it, but force to white - const basegfx::BColorModifierSharedPtr aBColorModifierToWhite = - std::make_shared<basegfx::BColorModifier_replace>( - basegfx::BColor(1.0, 1.0, 1.0)); - rContainer.push_back( - new ModifiedColorPrimitive2D( - getTextContent(), - aBColorModifierToWhite)); - - break; - } + // to bottom-right + aTransform.translate(aDiagonalDistance.getX(), aDiagonalDistance.getY()); + } + else + { + // to top-left + aTransform.translate(-aDiagonalDistance.getX(), -aDiagonalDistance.getY()); } - } - TextEffectPrimitive2D::TextEffectPrimitive2D( - const Primitive2DContainer& rTextContent, - const basegfx::B2DPoint& rRotationCenter, - double fDirection, - TextEffectStyle2D eTextEffectStyle2D) - : BufferedDecompositionPrimitive2D(), - maTextContent(rTextContent), - maRotationCenter(rRotationCenter), - mfDirection(fDirection), - meTextEffectStyle2D(eTextEffectStyle2D) - { - } + aTransform *= aForwardTransform; - bool TextEffectPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const - { - if(BasePrimitive2D::operator==(rPrimitive)) + if (bDefaultTextColor) { - const TextEffectPrimitive2D& rCompare = static_cast<const TextEffectPrimitive2D&>(rPrimitive); + // emboss/engrave in black, original forced to white + const basegfx::BColorModifierSharedPtr aBColorModifierToGray + = std::make_shared<basegfx::BColorModifier_replace>(basegfx::BColor(0.0)); + const Primitive2DReference xModifiedColor( + new ModifiedColorPrimitive2D(getTextContent(), aBColorModifierToGray)); - return (getTextContent() == rCompare.getTextContent() - && getRotationCenter() == rCompare.getRotationCenter() - && getDirection() == rCompare.getDirection() - && getTextEffectStyle2D() == rCompare.getTextEffectStyle2D()); + rContainer.push_back( + new TransformPrimitive2D(aTransform, Primitive2DContainer{ xModifiedColor })); + + // add original, too + const basegfx::BColorModifierSharedPtr aBColorModifierToWhite + = std::make_shared<basegfx::BColorModifier_replace>(basegfx::BColor(1.0)); + + rContainer.push_back( + new ModifiedColorPrimitive2D(getTextContent(), aBColorModifierToWhite)); + } + else + { + // emboss/engrave in gray, keep original's color + const basegfx::BColorModifierSharedPtr aBColorModifierToGray + = std::make_shared<basegfx::BColorModifier_replace>( + basegfx::BColor(0.75)); // 192 + const Primitive2DReference xModifiedColor( + new ModifiedColorPrimitive2D(getTextContent(), aBColorModifierToGray)); + + rContainer.push_back( + new TransformPrimitive2D(aTransform, Primitive2DContainer{ xModifiedColor })); + + // add original, too + rContainer.push_back(new GroupPrimitive2D(getTextContent())); } - return false; + break; } - - basegfx::B2DRange TextEffectPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const + case TextEffectStyle2D::Outline: { - // get range of content and grow by used fDiscreteSize. That way it is not necessary to ask - // the whole decomposition for its ranges (which may be expensive with outline mode which - // then will ask 9 times at nearly the same content. This may even be refined here using the - // TextEffectStyle information, e.g. for TEXTEFFECTSTYLE2D_RELIEF the grow needs only to - // be in two directions - basegfx::B2DRange aRetval(getTextContent().getB2DRange(rViewInformation)); - aRetval.grow(fDiscreteSize); - - return aRetval; - } + // create transform primitives in all directions + basegfx::B2DHomMatrix aTransform; - void TextEffectPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const - { - ::osl::MutexGuard aGuard( m_aMutex ); + aTransform.set(0, 2, aDistance.getX()); + aTransform.set(1, 2, 0.0); + rContainer.push_back(new TransformPrimitive2D(aTransform, getTextContent())); - if(!getBuffered2DDecomposition().empty()) - { - if(maLastObjectToViewTransformation != rViewInformation.getObjectToViewTransformation()) - { - // conditions of last local decomposition have changed, delete - const_cast< TextEffectPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DContainer()); - } - } + aTransform.set(0, 2, aDiagonalDistance.getX()); + aTransform.set(1, 2, aDiagonalDistance.getY()); + rContainer.push_back(new TransformPrimitive2D(aTransform, getTextContent())); - if(getBuffered2DDecomposition().empty()) - { - // remember ViewRange and ViewTransformation - const_cast< TextEffectPrimitive2D* >(this)->maLastObjectToViewTransformation = rViewInformation.getObjectToViewTransformation(); - } + aTransform.set(0, 2, 0.0); + aTransform.set(1, 2, aDistance.getY()); + rContainer.push_back(new TransformPrimitive2D(aTransform, getTextContent())); + + aTransform.set(0, 2, -aDiagonalDistance.getX()); + aTransform.set(1, 2, aDiagonalDistance.getY()); + rContainer.push_back(new TransformPrimitive2D(aTransform, getTextContent())); + + aTransform.set(0, 2, -aDistance.getX()); + aTransform.set(1, 2, 0.0); + rContainer.push_back(new TransformPrimitive2D(aTransform, getTextContent())); + + aTransform.set(0, 2, -aDiagonalDistance.getX()); + aTransform.set(1, 2, -aDiagonalDistance.getY()); + rContainer.push_back(new TransformPrimitive2D(aTransform, getTextContent())); + + aTransform.set(0, 2, 0.0); + aTransform.set(1, 2, -aDistance.getY()); + rContainer.push_back(new TransformPrimitive2D(aTransform, getTextContent())); + + aTransform.set(0, 2, aDiagonalDistance.getX()); + aTransform.set(1, 2, -aDiagonalDistance.getY()); + rContainer.push_back(new TransformPrimitive2D(aTransform, getTextContent())); + + // at last, place original over it, but force to white + const basegfx::BColorModifierSharedPtr aBColorModifierToWhite + = std::make_shared<basegfx::BColorModifier_replace>(basegfx::BColor(1.0, 1.0, 1.0)); + rContainer.push_back( + new ModifiedColorPrimitive2D(getTextContent(), aBColorModifierToWhite)); + + break; + } + } +} + +TextEffectPrimitive2D::TextEffectPrimitive2D(const Primitive2DContainer& rTextContent, + const basegfx::B2DPoint& rRotationCenter, + double fDirection, + TextEffectStyle2D eTextEffectStyle2D) + : BufferedDecompositionPrimitive2D() + , maTextContent(rTextContent) + , maRotationCenter(rRotationCenter) + , mfDirection(fDirection) + , meTextEffectStyle2D(eTextEffectStyle2D) +{ +} - // use parent implementation - BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation); ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits