16 #ifndef QGSMAPRENDERERJOB_H
17 #define QGSMAPRENDERERJOB_H
19 #include "qgis_core.h"
21 #include <QFutureWatcher>
26 #include <QElapsedTimer>
54 LayerRenderJob() =
default;
57 LayerRenderJob(
const LayerRenderJob & ) =
delete;
60 LayerRenderJob &operator=(
const LayerRenderJob & ) =
delete;
62 LayerRenderJob( LayerRenderJob && );
63 LayerRenderJob &operator=( LayerRenderJob && );
71 void setContext( std::unique_ptr< QgsRenderContext > context ) { mContext = std::move( context ); }
85 QImage *img =
nullptr;
88 bool imageInitialized =
false;
90 bool imageCanBeComposed()
const;
94 QPainter::CompositionMode blendMode = QPainter::CompositionMode_SourceOver;
109 bool completed =
false;
112 int renderingTime = -1;
123 int estimatedRenderingTime = 0;
152 std::unique_ptr<QPainter> maskPainter;
157 std::unique_ptr<QPaintDevice> maskPaintDevice;
163 bool maskRequiresLayerRasterization =
false;
169 LayerRenderJob *firstPassJob =
nullptr;
174 std::unique_ptr<QPicture> picture;
182 QList<QPair<LayerRenderJob *, int>> maskJobs;
185 std::unique_ptr< QgsRenderContext > mContext;
193 struct LabelRenderJob
201 QImage *img =
nullptr;
204 std::unique_ptr<QPicture> picture;
207 std::vector< std::unique_ptr<QPainter> > maskPainters;
219 std::vector< std::unique_ptr<QPaintDevice> > maskPaintDevices;
230 bool canUseCache =
false;
232 bool complete =
false;
234 int renderingTime = -1;
236 QList< QPointer< QgsMapLayer > > participatingLayers;
288 virtual void cancel() = 0;
295 virtual void cancelWithoutBlocking() = 0;
298 virtual void waitForFinished() = 0;
301 virtual bool isActive()
const = 0;
310 virtual bool usedCachedLabels()
const = 0;
320 QStringList layersRedrawnFromCache()
const;
356 Error(
const QString &lid,
const QString &msg )
365 typedef QList<QgsMapRendererJob::Error>
Errors;
407 int renderingTime()
const {
return mRenderingTime; }
414 QHash< QgsMapLayer *, int > perLayerRenderingTime() const
SIP_SKIP;
428 void setLayerRenderingTimeHints( const QHash< QString,
int > &hints )
SIP_SKIP;
448 static const QString LABEL_PREVIEW_CACHE_ID
SIP_SKIP;
464 void renderingLayersFinished();
474 void layerRenderingStarted(
const QString &layerId );
483 void layerRendered(
const QString &layerId );
496 int mRenderingTime = 0;
511 bool mRecordRenderingTime =
true;
524 bool prepareLabelCache() const
SIP_SKIP;
537 std::vector< LayerRenderJob > prepareJobs( QPainter *painter,
QgsLabelingEngine *labelingEngine2,
bool deferredPainterSet = false )
SIP_SKIP;
544 LabelRenderJob prepareLabelingJob( QPainter *painter,
QgsLabelingEngine *labelingEngine2,
bool canUseLabelCache = true )
SIP_SKIP;
554 std::vector< LayerRenderJob > prepareSecondPassJobs( std::vector< LayerRenderJob > &firstPassJobs, LabelRenderJob &labelJob )
SIP_SKIP;
560 void initSecondPassJobs( std::vector< LayerRenderJob > &secondPassJobs, LabelRenderJob &labelJob ) const
SIP_SKIP;
564 const std::vector< LayerRenderJob > &jobs,
565 const LabelRenderJob &labelJob,
577 static
void composeSecondPass( std::vector< LayerRenderJob > &secondPassJobs, LabelRenderJob &labelJob,
bool forceVector = false )
SIP_SKIP;
580 void logRenderingTime( const std::vector< LayerRenderJob > &jobs, const std::vector< LayerRenderJob > &secondPassJobs, const LabelRenderJob &labelJob )
SIP_SKIP;
583 void cleanupJobs( std::vector< LayerRenderJob > &jobs )
SIP_SKIP;
586 void cleanupSecondPassJobs( std::vector< LayerRenderJob > &jobs )
SIP_SKIP;
594 void cleanupLabelJob( LabelRenderJob &job )
SIP_SKIP;
623 QImage *allocateImage( QString layerId );
626 QPainter *allocateImageAndPainter( QString layerId, QImage *&image, const
QgsRenderContext *context );
633 virtual
void startPrivate() = 0;
638 typedef std::pair<std::
unique_ptr<QPicture>, QPainter * > PictureAndPainter;
641 PictureAndPainter allocatePictureAndPainter( const
QgsRenderContext *context );
661 virtual QImage renderedImage() = 0;
666 #endif // QGSMAPRENDERERJOB_H