Kaydet (Commit) b2c3233e authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Tomaž Vajngerl

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/46901Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst 2c6d6c11
...@@ -18,21 +18,24 @@ ...@@ -18,21 +18,24 @@
*/ */
#include "BarChart.hxx" #include "BarChart.hxx"
#include "BarPositionHelper.hxx"
#include <ShapeFactory.hxx> #include <ShapeFactory.hxx>
#include <CommonConverters.hxx> #include <CommonConverters.hxx>
#include <ObjectIdentifier.hxx> #include <ObjectIdentifier.hxx>
#include <LabelPositionHelper.hxx> #include <LabelPositionHelper.hxx>
#include "BarPositionHelper.hxx"
#include <AxisIndexDefines.hxx> #include <AxisIndexDefines.hxx>
#include <Clipping.hxx> #include <Clipping.hxx>
#include <DateHelper.hxx> #include <DateHelper.hxx>
#include <svx/scene3d.hxx> #include <svx/scene3d.hxx>
#include <svx/unoshape.hxx> #include <svx/unoshape.hxx>
#include <comphelper/scopeguard.hxx>
#include <com/sun/star/chart/DataLabelPlacement.hpp> #include <com/sun/star/chart/DataLabelPlacement.hpp>
#include <com/sun/star/chart2/DataPointGeometry3D.hpp> #include <com/sun/star/chart2/DataPointGeometry3D.hpp>
#include <rtl/math.hxx> #include <rtl/math.hxx>
#include <unordered_set>
namespace chart namespace chart
{ {
...@@ -40,6 +43,27 @@ using namespace ::com::sun::star; ...@@ -40,6 +43,27 @@ using namespace ::com::sun::star;
using namespace ::rtl::math; using namespace ::rtl::math;
using namespace ::com::sun::star::chart2; 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 BarChart::BarChart( const uno::Reference<XChartType>& xChartTypeModel
, sal_Int32 nDimensionCount ) , sal_Int32 nDimensionCount )
: VSeriesPlotter( xChartTypeModel, nDimensionCount ) : VSeriesPlotter( xChartTypeModel, nDimensionCount )
...@@ -406,11 +430,11 @@ void BarChart::adaptOverlapAndGapwidthForGroupBarsPerAxis() ...@@ -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; E3dScene* pScene = nullptr;
SvxShape* pSvxShape = SvxShape::getImplementation(xShapes); SvxShape* pSvxShape = SvxShape::getImplementation(xInterface);
if (pSvxShape) if (pSvxShape)
{ {
SdrObject* pObject = pSvxShape->GetSdrObject(); SdrObject* pObject = pSvxShape->GetSdrObject();
...@@ -453,6 +477,25 @@ void BarChart::createShapes() ...@@ -453,6 +477,25 @@ void BarChart::createShapes()
bool bDrawConnectionLinesInited = false; bool bDrawConnectionLinesInited = false;
bool bOnlyConnectionLinesForThisPoint = 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(); adaptOverlapAndGapwidthForGroupBarsPerAxis();
//better performance for big data //better performance for big data
...@@ -585,8 +628,13 @@ void BarChart::createShapes() ...@@ -585,8 +628,13 @@ void BarChart::createShapes()
bDrawConnectionLinesInited = true; bDrawConnectionLinesInited = true;
} }
uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes( uno::Reference<drawing::XShapes> xSeriesGroupShape_Shapes(getSeriesGroupShape(pSeries, xSeriesTarget));
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 ): //collect data point information (logic coordinates, style ):
double fUnscaledLogicX = pSeries->getXValue( nPointIndex ); double fUnscaledLogicX = pSeries->getXValue( nPointIndex );
...@@ -777,12 +825,9 @@ void BarChart::createShapes() ...@@ -777,12 +825,9 @@ void BarChart::createShapes()
if( fTopHeight < 0 ) if( fTopHeight < 0 )
fTopHeight *= -1.0; fTopHeight *= -1.0;
E3dScene* pScene = lcl_getE3dScene(xSeriesGroupShape_Shapes);
pScene->EnterObjectSetupMode();
xShape = createDataPoint3D_Bar( xShape = createDataPoint3D_Bar(
xSeriesGroupShape_Shapes, aTransformedBottom, aSize, fTopHeight, nRotateZAngleHundredthDegree xSeriesGroupShape_Shapes, aTransformedBottom, aSize, fTopHeight, nRotateZAngleHundredthDegree
, xDataPointProperties, nGeometry3D ); , xDataPointProperties, nGeometry3D );
pScene->ExitObjectSetupMode();
} }
else //m_nDimension!=3 else //m_nDimension!=3
{ {
......
...@@ -164,8 +164,10 @@ public: ...@@ -164,8 +164,10 @@ public:
virtual bool BckCreate(SdrDragStat& rStat) override; virtual bool BckCreate(SdrDragStat& rStat) override;
virtual void BrkCreate(SdrDragStat& rStat) override; virtual void BrkCreate(SdrDragStat& rStat) override;
void EnterObjectSetupMode(); void SuspendReportingDirtyRects();
void ExitObjectSetupMode(); void ResumeReportingDirtyRects();
void SetAllSceneRectsDirty();
}; };
#endif // INCLUDED_SVX_SCENE3D_HXX #endif // INCLUDED_SVX_SCENE3D_HXX
......
...@@ -416,16 +416,21 @@ E3dScene* E3dScene::Clone() const ...@@ -416,16 +416,21 @@ E3dScene* E3dScene::Clone() const
return CloneHelper< E3dScene >(); return CloneHelper< E3dScene >();
} }
void E3dScene::EnterObjectSetupMode() void E3dScene::SuspendReportingDirtyRects()
{ {
GetScene()->mbSkipSettingDirty = true; GetScene()->mbSkipSettingDirty = true;
} }
void E3dScene::ExitObjectSetupMode() void E3dScene::ResumeReportingDirtyRects()
{ {
GetScene()->mbSkipSettingDirty = false; GetScene()->mbSkipSettingDirty = false;
} }
void E3dScene::SetAllSceneRectsDirty()
{
GetScene()->SetRectsDirty();
}
E3dScene& E3dScene::operator=(const E3dScene& rObj) E3dScene& E3dScene::operator=(const E3dScene& rObj)
{ {
if( this == &rObj ) if( this == &rObj )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment