mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Have QgsRasterDrawer::draw check for interrupted rendering, reduce raster block tile dimensions, to greatly enhance responsiveness when dealing with reprojected raster layers
This commit is contained in:
parent
1e8abb1d1d
commit
d984148efe
@ -9,7 +9,13 @@ class QgsRasterDrawer
|
||||
public:
|
||||
QgsRasterDrawer( QgsRasterIterator *iterator );
|
||||
|
||||
void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel );
|
||||
/** Draws raster data.
|
||||
* @param p destination QPainter
|
||||
* @param viewPort viewport to render
|
||||
* @param theQgsMapToPixel map to pixel convertor
|
||||
* @param ctx render context
|
||||
*/
|
||||
void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel, const QgsRenderContext *ctx = nullptr );
|
||||
|
||||
protected:
|
||||
/** Draws raster part
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "qgsrasteriterator.h"
|
||||
#include "qgsrasterviewport.h"
|
||||
#include "qgsmaptopixel.h"
|
||||
#include "qgsrendercontext.h"
|
||||
#include <QImage>
|
||||
#include <QPainter>
|
||||
#include <QPrinter>
|
||||
@ -28,7 +29,7 @@ QgsRasterDrawer::QgsRasterDrawer( QgsRasterIterator* iterator ): mIterator( iter
|
||||
{
|
||||
}
|
||||
|
||||
void QgsRasterDrawer::draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel )
|
||||
void QgsRasterDrawer::draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel, const QgsRenderContext* ctx )
|
||||
{
|
||||
QgsDebugMsgLevel( "Entered", 4 );
|
||||
if ( !p || !mIterator || !viewPort || !theQgsMapToPixel )
|
||||
@ -88,6 +89,8 @@ void QgsRasterDrawer::draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsM
|
||||
drawImage( p, viewPort, img, topLeftCol, topLeftRow, theQgsMapToPixel );
|
||||
|
||||
delete block;
|
||||
if ( ctx && ctx->renderingStopped() )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
class QPainter;
|
||||
class QImage;
|
||||
class QgsMapToPixel;
|
||||
class QgsRenderContext;
|
||||
struct QgsRasterViewPort;
|
||||
class QgsRasterIterator;
|
||||
|
||||
@ -35,7 +36,13 @@ class CORE_EXPORT QgsRasterDrawer
|
||||
public:
|
||||
QgsRasterDrawer( QgsRasterIterator *iterator );
|
||||
|
||||
void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel );
|
||||
/** Draws raster data.
|
||||
* @param p destination QPainter
|
||||
* @param viewPort viewport to render
|
||||
* @param theQgsMapToPixel map to pixel convertor
|
||||
* @param ctx render context
|
||||
*/
|
||||
void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel, const QgsRenderContext *ctx = nullptr );
|
||||
|
||||
protected:
|
||||
/** Draws raster part
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "qgsrasterviewport.h"
|
||||
|
||||
QgsRasterIterator::QgsRasterIterator( QgsRasterInterface* input ): mInput( input ),
|
||||
mMaximumTileWidth( 2000 ), mMaximumTileHeight( 2000 )
|
||||
mMaximumTileWidth( 256 ), mMaximumTileHeight( 256 )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ QgsRasterLayerRenderer::QgsRasterLayerRenderer( QgsRasterLayer* layer, QgsRender
|
||||
: QgsMapLayerRenderer( layer->id() )
|
||||
, mRasterViewPort( nullptr )
|
||||
, mPipe( nullptr )
|
||||
, mContext( rendererContext )
|
||||
{
|
||||
|
||||
mPainter = rendererContext.painter();
|
||||
@ -209,7 +210,7 @@ bool QgsRasterLayerRenderer::render()
|
||||
// Drawer to pipe?
|
||||
QgsRasterIterator iterator( mPipe->last() );
|
||||
QgsRasterDrawer drawer( &iterator );
|
||||
drawer.draw( mPainter, mRasterViewPort, mMapToPixel );
|
||||
drawer.draw( mPainter, mRasterViewPort, mMapToPixel, &mContext );
|
||||
|
||||
QgsDebugMsgLevel( QString( "total raster draw time (ms): %1" ).arg( time.elapsed(), 5 ), 4 );
|
||||
|
||||
|
@ -47,6 +47,7 @@ class QgsRasterLayerRenderer : public QgsMapLayerRenderer
|
||||
QgsRasterViewPort* mRasterViewPort;
|
||||
|
||||
QgsRasterPipe* mPipe;
|
||||
QgsRenderContext& mContext;
|
||||
};
|
||||
|
||||
#endif // QGSRASTERLAYERRENDERER_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user