chart2/source/view/charttypes/BarChart.cxx | 55 ++++++++++++++++++++++++++--- include/svx/scene3d.hxx | 6 ++- svx/source/engine3d/scene3d.cxx | 9 +++- 3 files changed, 61 insertions(+), 9 deletions(-)
New commits: commit 394e869234cb27d5526716f7d9a9c1e491735a41 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> Date: Thu Dec 21 20:08:33 2017 +0900 chart2: suspend/resume setting rects dirty for 3D shapes Previously we bypassed setting rects as dirty for a scene just before we are about to create a 3D object. With this change we do it earlier and suspend for the whole time we are creating the scene - so we guarantee to o it for all 3D objects in that code path. Aferwards we resume with setting rects and mark the whole scene as dirty so we don't miss some update. Reviewed-on: https://gerrit.libreoffice.org/46901 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> (cherry picked from commit b2c3233e5f267b5d244d722a94424a3b224b3314) Change-Id: Ie4dec644102140edf282a2f5f6eb7fc9b81dbe48 Reviewed-on: https://gerrit.libreoffice.org/46919 Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> Tested-by: Thorsten Behrens <thorsten.behr...@cib.de> diff --git a/chart2/source/view/charttypes/BarChart.cxx b/chart2/source/view/charttypes/BarChart.cxx index f7206dafb70e..c79cc53c4ee6 100644 --- a/chart2/source/view/charttypes/BarChart.cxx +++ b/chart2/source/view/charttypes/BarChart.cxx @@ -29,11 +29,13 @@ #include "DateHelper.hxx" #include <svx/scene3d.hxx> #include <svx/unoshape.hxx> +#include <comphelper/scopeguard.hxx> #include <com/sun/star/chart/DataLabelPlacement.hpp> #include <com/sun/star/chart2/DataPointGeometry3D.hpp> #include <rtl/math.hxx> +#include <unordered_set> namespace chart { @@ -41,6 +43,27 @@ using namespace ::com::sun::star; using namespace ::rtl::math; using namespace ::com::sun::star::chart2; +namespace +{ + +struct XShapeCompare +{ + bool operator() (uno::Reference<drawing::XShape> const & lhs, uno::Reference<drawing::XShape> const & rhs) const + { + return lhs.get() < rhs.get(); + } +}; + +struct XShapeHash +{ + bool operator()(uno::Reference<drawing::XShape> const & rXShape) const + { + return rXShape->getShapeType().hashCode(); + } +}; + +} // end anonymous namespace + BarChart::BarChart( const uno::Reference<XChartType>& xChartTypeModel , sal_Int32 nDimensionCount ) : VSeriesPlotter( xChartTypeModel, nDimensionCount ) @@ -408,11 +431,11 @@ void BarChart::adaptOverlapAndGapwidthForGroupBarsPerAxis() } } -E3dScene* lcl_getE3dScene(uno::Reference<drawing::XShapes> const & xShapes) +E3dScene* lcl_getE3dScene(uno::Reference<uno::XInterface> const & xInterface) { E3dScene* pScene = nullptr; - SvxShape* pSvxShape = SvxShape::getImplementation(xShapes); + SvxShape* pSvxShape = SvxShape::getImplementation(xInterface); if (pSvxShape) { SdrObject* pObject = pSvxShape->GetSdrObject(); @@ -455,6 +478,25 @@ void BarChart::createShapes() bool bDrawConnectionLinesInited = false; bool bOnlyConnectionLinesForThisPoint = false; + std::unordered_set<uno::Reference<drawing::XShape>, XShapeHash, XShapeCompare> aShapeSet; + + const comphelper::ScopeGuard aGuard([aShapeSet]() { + + std::unordered_set<E3dScene*> aSceneSet; + + for (uno::Reference<drawing::XShape> const & rShape : aShapeSet) + { + E3dScene* pScene = lcl_getE3dScene(rShape); + if (pScene) + aSceneSet.insert(pScene->GetScene()); + } + for (E3dScene* pScene : aSceneSet) + { + pScene->ResumeReportingDirtyRects(); + pScene->SetAllSceneRectsDirty(); + } + }); + adaptOverlapAndGapwidthForGroupBarsPerAxis(); //better performance for big data @@ -604,6 +646,12 @@ void BarChart::createShapes() uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes( getSeriesGroupShape(*aSeriesIter, xSeriesTarget) ); + uno::Reference<drawing::XShape> xSeriesGroupShape(xSeriesGroupShape_Shapes, uno::UNO_QUERY); + // Suspend setting rects dirty for the duration of this call + aShapeSet.insert(xSeriesGroupShape); + E3dScene* pScene = lcl_getE3dScene(xSeriesGroupShape); + if (pScene) + pScene->SuspendReportingDirtyRects(); //collect data point information (logic coordinates, style ): double fUnscaledLogicX = (*aSeriesIter)->getXValue( nPointIndex ); @@ -794,12 +842,9 @@ void BarChart::createShapes() if( fTopHeight < 0 ) fTopHeight *= -1.0; - E3dScene* pScene = lcl_getE3dScene(xSeriesGroupShape_Shapes); - pScene->EnterObjectSetupMode(); xShape = createDataPoint3D_Bar( xSeriesGroupShape_Shapes, aTransformedBottom, aSize, fTopHeight, nRotateZAngleHundredthDegree , xDataPointProperties, nGeometry3D ); - pScene->ExitObjectSetupMode(); } else //m_nDimension!=3 { diff --git a/include/svx/scene3d.hxx b/include/svx/scene3d.hxx index 04343d4dfe88..6dd7c2c54c42 100644 --- a/include/svx/scene3d.hxx +++ b/include/svx/scene3d.hxx @@ -165,8 +165,10 @@ public: virtual bool BckCreate(SdrDragStat& rStat) override; virtual void BrkCreate(SdrDragStat& rStat) override; - void EnterObjectSetupMode(); - void ExitObjectSetupMode(); + void SuspendReportingDirtyRects(); + void ResumeReportingDirtyRects(); + void SetAllSceneRectsDirty(); + }; #endif // INCLUDED_SVX_SCENE3D_HXX diff --git a/svx/source/engine3d/scene3d.cxx b/svx/source/engine3d/scene3d.cxx index 6c75e459bc8d..55b39b62aab5 100644 --- a/svx/source/engine3d/scene3d.cxx +++ b/svx/source/engine3d/scene3d.cxx @@ -438,16 +438,21 @@ E3dScene* E3dScene::Clone() const return CloneHelper< E3dScene >(); } -void E3dScene::EnterObjectSetupMode() +void E3dScene::SuspendReportingDirtyRects() { GetScene()->mbSkipSettingDirty = true; } -void E3dScene::ExitObjectSetupMode() +void E3dScene::ResumeReportingDirtyRects() { GetScene()->mbSkipSettingDirty = false; } +void E3dScene::SetAllSceneRectsDirty() +{ + GetScene()->SetRectsDirty(); +} + E3dScene& E3dScene::operator=(const E3dScene& rObj) { if( this == &rObj )
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits