Skip to content

Commit 440ede9

Browse files
committed
Feature #8725: Fast rendering of geom (v-OGR)
Implements fast rendering of LineStrings and Polygons pre-applying a view threshold filter to the geometries to render in qgis. Also disable 'Antialiasing' when it is possible. View Table of test results in 'http://hub.qgis.org/issues/8725' (This version of branch implements the improvement in vector-providers)
1 parent b192f64 commit 440ede9

23 files changed

+746
-44
lines changed

python/core/symbology-ng/qgssymbollayerv2.sip

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,5 +202,5 @@ class QgsFillSymbolLayerV2 : QgsSymbolLayerV2
202202
protected:
203203
QgsFillSymbolLayerV2( bool locked = false );
204204
/**Default method to render polygon*/
205-
void _renderPolygon( QPainter* p, const QPolygonF& points, const QList<QPolygonF>* rings );
205+
void _renderPolygon( QPainter* p, const QPolygonF& points, const QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context );
206206
};

src/core/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ SET(QGIS_CORE_SRCS
8181
qgslabelattributes.cpp
8282
qgslabelsearchtree.cpp
8383
qgslogger.cpp
84+
qgsmaprequest.cpp
8485
qgsmaplayer.cpp
8586
qgsmaplayerregistry.cpp
8687
qgsmaprenderer.cpp

src/core/qgsclipper.cpp

+8-16
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ const unsigned char* QgsClipper::clippedLineWKB( const unsigned char* wkb, const
4545

4646
bool hasZValue = ( wkbType == QGis::WKBLineString25D );
4747

48+
int sizeOfDoubleX = sizeof(double);
49+
int sizeOfDoubleY = hasZValue ? 2*sizeof(double) : sizeof(double);
50+
4851
double p0x, p0y, p1x = 0.0, p1y = 0.0; //original coordinates
4952
double p1x_c, p1y_c; //clipped end coordinates
5053
double lastClipX = 0.0, lastClipY = 0.0; //last successfully clipped coords
@@ -56,29 +59,18 @@ const unsigned char* QgsClipper::clippedLineWKB( const unsigned char* wkb, const
5659
{
5760
if ( i == 0 )
5861
{
59-
memcpy( &p1x, wkb, sizeof( double ) );
60-
wkb += sizeof( double );
61-
memcpy( &p1y, wkb, sizeof( double ) );
62-
wkb += sizeof( double );
63-
if ( hasZValue ) // ignore Z value
64-
{
65-
wkb += sizeof( double );
66-
}
62+
memcpy( &p1x, wkb, sizeof( double ) ); wkb += sizeOfDoubleX;
63+
memcpy( &p1y, wkb, sizeof( double ) ); wkb += sizeOfDoubleY;
64+
6765
continue;
6866
}
6967
else
7068
{
7169
p0x = p1x;
7270
p0y = p1y;
7371

74-
memcpy( &p1x, wkb, sizeof( double ) );
75-
wkb += sizeof( double );
76-
memcpy( &p1y, wkb, sizeof( double ) );
77-
wkb += sizeof( double );
78-
if ( hasZValue ) // ignore Z value
79-
{
80-
wkb += sizeof( double );
81-
}
72+
memcpy( &p1x, wkb, sizeof( double ) ); wkb += sizeOfDoubleX;
73+
memcpy( &p1y, wkb, sizeof( double ) ); wkb += sizeOfDoubleY;
8274

8375
p1x_c = p1x; p1y_c = p1y;
8476
if ( clipLineSegment( clipExtent.xMinimum(), clipExtent.xMaximum(), clipExtent.yMinimum(), clipExtent.yMaximum(),

src/core/qgsfeaturerequest.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ QgsFeatureRequest::QgsFeatureRequest( const QgsFeatureRequest &rh )
5656

5757
QgsFeatureRequest& QgsFeatureRequest::operator=( const QgsFeatureRequest & rh )
5858
{
59+
QgsMapRequest::operator=( rh );
60+
5961
mFlags = rh.mFlags;
6062
mFilter = rh.mFilter;
6163
mFilterRect = rh.mFilterRect;

src/core/qgsfeaturerequest.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include <QFlags>
1919

20+
#include "qgsmaprequest.h"
2021
#include "qgsfeature.h"
2122
#include "qgsrectangle.h"
2223
#include "qgsexpression.h"
@@ -53,15 +54,16 @@ typedef QList<int> QgsAttributeList;
5354
* QgsFeatureRequest().setFilterFid(45)
5455
*
5556
*/
56-
class CORE_EXPORT QgsFeatureRequest
57+
class CORE_EXPORT QgsFeatureRequest : public QgsMapRequest
5758
{
5859
public:
5960
enum Flag
6061
{
6162
NoFlags = 0,
6263
NoGeometry = 1, //!< Geometry is not required. It may still be returned if e.g. required for a filter condition.
6364
SubsetOfAttributes = 2, //!< Fetch only a subset of attributes (setSubsetOfAttributes sets this flag)
64-
ExactIntersect = 4 //!< Use exact geometry intersection (slower) instead of bounding boxes
65+
ExactIntersect = 4, //!< Use exact geometry intersection (slower) instead of bounding boxes
66+
SimplifyGeometries = 8 //!< Simplify the geometry using the current map2pixel context
6567
};
6668
Q_DECLARE_FLAGS( Flags, Flag )
6769

src/core/qgsmaprenderer.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,10 @@ void QgsMapRenderer::render( QPainter* painter, double* forceWidthScale )
278278
//so must be false at every new render operation
279279
mRenderContext.setRenderingStopped( false );
280280

281+
// Gets the configured Tolerance for simplify transformations between map coordinates and device coordinates
282+
QSettings mySettings2;
283+
mRenderContext.setMapToPixelTol( mySettings2.value( "Map/map2pixelTol", 1.0f ).toFloat() );
284+
281285
// set selection color
282286
QgsProject* prj = QgsProject::instance();
283287
int myRed = prj->readNumEntry( "Gui", "/SelectionColorRedPart", 255 );

0 commit comments

Comments
 (0)