diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2017-12-21 20:08:33 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2017-12-21 14:48:32 +0100 |
commit | b2c3233e5f267b5d244d722a94424a3b224b3314 (patch) | |
tree | 68bb18b33ee5068696473c3e7920882f55896882 /chart2/source/view | |
parent | 2c6d6c113177e25b9ae1674c1e8de0b3c8ae1327 (diff) |
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.
Change-Id: Ie4dec644102140edf282a2f5f6eb7fc9b81dbe48
Reviewed-on: https://gerrit.libreoffice.org/46901
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'chart2/source/view')
-rw-r--r-- | chart2/source/view/charttypes/BarChart.cxx | 61 |
1 files changed, 53 insertions, 8 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 <ShapeFactory.hxx> #include <CommonConverters.hxx> #include <ObjectIdentifier.hxx> #include <LabelPositionHelper.hxx> -#include "BarPositionHelper.hxx" #include <AxisIndexDefines.hxx> #include <Clipping.hxx> #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 { @@ -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<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 ) @@ -406,11 +430,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(); @@ -453,6 +477,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 @@ -585,8 +628,13 @@ void BarChart::createShapes() bDrawConnectionLinesInited = true; } - uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes( - getSeriesGroupShape(pSeries, xSeriesTarget) ); + uno::Reference<drawing::XShapes> xSeriesGroupShape_Shapes(getSeriesGroupShape(pSeries, 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 = 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 { |