From b2c3233e5f267b5d244d722a94424a3b224b3314 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Thu, 21 Dec 2017 20:08:33 +0900 Subject: chart2: suspend/resume setting rects dirty for 3D shapes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Change-Id: Ie4dec644102140edf282a2f5f6eb7fc9b81dbe48 Reviewed-on: https://gerrit.libreoffice.org/46901 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- chart2/source/view/charttypes/BarChart.cxx | 61 ++++++++++++++++++++++++++---- include/svx/scene3d.hxx | 6 ++- svx/source/engine3d/scene3d.cxx | 9 ++++- 3 files changed, 64 insertions(+), 12 deletions(-) diff --git a/chart2/source/view/charttypes/BarChart.cxx b/chart2/source/view/charttypes/BarChart.cxx index 34c28deb9057..17407d866a33 100644 --- a/chart2/source/view/charttypes/BarChart.cxx +++ b/chart2/source/view/charttypes/BarChart.cxx @@ -18,21 +18,24 @@ */ #include "BarChart.hxx" +#include "BarPositionHelper.hxx" + #include #include #include #include -#include "BarPositionHelper.hxx" #include #include #include #include #include +#include #include #include #include +#include namespace chart { @@ -40,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 const & lhs, uno::Reference const & rhs) const + { + return lhs.get() < rhs.get(); + } +}; + +struct XShapeHash +{ + bool operator()(uno::Reference const & rXShape) const + { + return rXShape->getShapeType().hashCode(); + } +}; + +} // end anonymous namespace + BarChart::BarChart( const uno::Reference& xChartTypeModel , sal_Int32 nDimensionCount ) : VSeriesPlotter( xChartTypeModel, nDimensionCount ) @@ -406,11 +430,11 @@ void BarChart::adaptOverlapAndGapwidthForGroupBarsPerAxis() } } -E3dScene* lcl_getE3dScene(uno::Reference const & xShapes) +E3dScene* lcl_getE3dScene(uno::Reference const & xInterface) { E3dScene* pScene = nullptr; - SvxShape* pSvxShape = SvxShape::getImplementation(xShapes); + SvxShape* pSvxShape = SvxShape::getImplementation(xInterface); if (pSvxShape) { SdrObject* pObject = pSvxShape->GetSdrObject(); @@ -453,6 +477,25 @@ void BarChart::createShapes() bool bDrawConnectionLinesInited = false; bool bOnlyConnectionLinesForThisPoint = false; + std::unordered_set, XShapeHash, XShapeCompare> aShapeSet; + + const comphelper::ScopeGuard aGuard([aShapeSet]() { + + std::unordered_set aSceneSet; + + for (uno::Reference 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 @@ -585,8 +628,13 @@ void BarChart::createShapes() bDrawConnectionLinesInited = true; } - uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes( - getSeriesGroupShape(pSeries, xSeriesTarget) ); + uno::Reference xSeriesGroupShape_Shapes(getSeriesGroupShape(pSeries, xSeriesTarget)); + uno::Reference 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 = pSeries->getXValue( nPointIndex ); @@ -777,12 +825,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 2f76cec02a13..c0a9a247746b 100644 --- a/include/svx/scene3d.hxx +++ b/include/svx/scene3d.hxx @@ -164,8 +164,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 1da5c1411150..1e3739005fa1 100644 --- a/svx/source/engine3d/scene3d.cxx +++ b/svx/source/engine3d/scene3d.cxx @@ -416,16 +416,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 ) -- cgit