Skip to content
Permalink
Browse files

[temporal] Optimize canvas rendering by avoiding needless cache clearing

  • Loading branch information
nirvn committed May 8, 2020
1 parent da23cb6 commit 9be36fdbf3743666f48c166248d9d194b7d1c75a
@@ -49,6 +49,7 @@ Constructor for QgsMeshLayerTemporalProperties
%End

public:

virtual QDomElement writeXml( QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context );

virtual bool readXml( const QDomElement &element, const QgsReadWriteContext &context );
@@ -24,6 +24,13 @@ Base class for temporal property.
#include "qgstemporalproperty.h"
%End
public:
enum Flag
{
NoFlags,
FlagDontInvalidateCachedRendersWhenRangeChanges
};
typedef QFlags<QgsTemporalProperty::Flag> Flags;


QgsTemporalProperty( QObject *parent /TransferThis/ = 0, bool enabled = false );
%Docstring
@@ -44,6 +51,11 @@ Sets whether the temporal property is ``active``.
Returns ``True`` if the temporal property is active.

.. seealso:: :py:func:`setIsActive`
%End

virtual const QgsTemporalProperty::Flags flags() const;
%Docstring
Returns flags associated to the temporal property.
%End

signals:
@@ -54,6 +54,12 @@ Returns the temporal properties mode.
Sets the temporal properties ``mode``.

.. seealso:: :py:func:`mode`
%End

virtual const QgsTemporalProperty::Flags flags() const;

%Docstring
Returns flags associated to the temporal property.
%End

void setFixedTemporalRange( const QgsDateTimeRange &range );
@@ -51,6 +51,12 @@ Returns the temporal properties mode.
Sets the temporal properties ``mode``.

.. seealso:: :py:func:`mode`
%End

virtual const QgsTemporalProperty::Flags flags() const;

%Docstring
Returns flags associated to the temporal property.
%End

QgsRasterDataProviderTemporalCapabilities::IntervalHandlingMethod intervalHandlingMethod() const;
@@ -61,6 +61,7 @@ class CORE_EXPORT QgsMeshLayerTemporalProperties : public QgsMapLayerTemporalPro
QgsMeshLayerTemporalProperties( QObject *parent SIP_TRANSFERTHIS = nullptr, bool enabled = true );

public:

QDomElement writeXml( QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context ) override;
bool readXml( const QDomElement &element, const QgsReadWriteContext &context ) override;
void setDefaultsFromDataProviderTemporalCapabilities( const QgsDataProviderTemporalCapabilities *capabilities ) override;
@@ -37,6 +37,12 @@ class CORE_EXPORT QgsTemporalProperty : public QObject
Q_OBJECT

public:
enum Flag
{
NoFlags = 0,
FlagDontInvalidateCachedRendersWhenRangeChanges = 1 //!< Any cached rendering will not be invalidated when temporal range context is modified
};
Q_DECLARE_FLAGS( Flags, Flag )

/**
* Constructor for QgsTemporalProperty, with the specified \a parent object.
@@ -59,6 +65,11 @@ class CORE_EXPORT QgsTemporalProperty : public QObject
*/
bool isActive() const;

/**
* Returns flags associated to the temporal property.
*/
virtual const QgsTemporalProperty::Flags flags() const { return QgsTemporalProperty::NoFlags; }

signals:

/**
@@ -108,6 +108,11 @@ void QgsVectorLayerTemporalProperties::setMode( QgsVectorLayerTemporalProperties
mMode = mode;
}

const QgsTemporalProperty::Flags QgsVectorLayerTemporalProperties::flags() const
{
return mode() == ModeFixedTemporalRange ? QgsTemporalProperty::FlagDontInvalidateCachedRendersWhenRangeChanges : QgsTemporalProperty::NoFlags;
}

void QgsVectorLayerTemporalProperties::setFixedTemporalRange( const QgsDateTimeRange &range )
{
mFixedRange = range;
@@ -75,6 +75,11 @@ class CORE_EXPORT QgsVectorLayerTemporalProperties : public QgsMapLayerTemporalP
**/
void setMode( TemporalMode mode );

/**
* Returns flags associated to the temporal property.
*/
const QgsTemporalProperty::Flags flags() const override;

/**
* Sets a temporal \a range to apply to the whole layer. All features from
* the layer will be rendered whenever the current datetime range of
@@ -70,6 +70,11 @@ void QgsRasterLayerTemporalProperties::setMode( QgsRasterLayerTemporalProperties
mMode = mode;
}

const QgsTemporalProperty::Flags QgsRasterLayerTemporalProperties::flags() const
{
return mode() == ModeFixedTemporalRange ? QgsTemporalProperty::FlagDontInvalidateCachedRendersWhenRangeChanges : QgsTemporalProperty::NoFlags;
}

QgsRasterDataProviderTemporalCapabilities::IntervalHandlingMethod QgsRasterLayerTemporalProperties::intervalHandlingMethod() const
{
return mIntervalHandlingMethod;
@@ -71,6 +71,11 @@ class CORE_EXPORT QgsRasterLayerTemporalProperties : public QgsMapLayerTemporalP
**/
void setMode( TemporalMode mode );

/**
* Returns flags associated to the temporal property.
*/
const QgsTemporalProperty::Flags flags() const override;

/**
* Returns the desired method to use when resolving a temporal interval to matching
* layers or bands in the data provider.
@@ -76,6 +76,8 @@ email : sherman at mrcc.com
#include "qgsreferencedgeometry.h"
#include "qgsprojectviewsettings.h"
#include "qgsmaplayertemporalproperties.h"
#include "qgsrasterlayertemporalproperties.h"
#include "qgsvectorlayertemporalproperties.h"
#include "qgstemporalcontroller.h"

/**
@@ -780,7 +782,12 @@ void QgsMapCanvas::clearTemporalCache()
for ( QgsMapLayer *layer : layerList )
{
if ( layer->temporalProperties() && layer->temporalProperties()->isActive() )
{
if ( layer->temporalProperties()->flags() & QgsTemporalProperty::FlagDontInvalidateCachedRendersWhenRangeChanges )
continue;

mCache->invalidateCacheForLayer( layer );
}
}
}
}

0 comments on commit 9be36fd

Please sign in to comment.
You can’t perform that action at this time.