Skip to content
Permalink
Browse files

Have QgsRasterDrawer::draw check for interrupted rendering, reduce ra…

…ster block tile dimensions, to greatly enhance responsiveness when dealing with reprojected raster layers
  • Loading branch information
manisandro authored and nyalldawson committed Mar 2, 2016
1 parent 1e8abb1 commit d984148efe126842e9f588cd361239cbb3bf4361
@@ -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

0 comments on commit d984148

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