[Libreoffice-commits] core.git: chart2/source include/svx svx/source

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Thu Dec 21 13:48:53 UTC 2017


 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(-)

New commits:
commit b2c3233e5f267b5d244d722a94424a3b224b3314
Author: Tomaž Vajngerl <tomaz.vajngerl at 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.
    
    Change-Id: Ie4dec644102140edf282a2f5f6eb7fc9b81dbe48
    Reviewed-on: https://gerrit.libreoffice.org/46901
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

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
                             {
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 )


More information about the Libreoffice-commits mailing list