diff options
author | Paolo Angelelli <paolo.angelelli@qt.io> | 2017-02-02 19:11:48 +0100 |
---|---|---|
committer | Paolo Angelelli <paolo.angelelli@qt.io> | 2017-02-13 11:27:20 +0000 |
commit | 2ace49b0db995a75694218113fd5743d05d97dcb (patch) | |
tree | 3862fe79eada4962abc1d393fc8c7dadad8e1415 /src/location/maps/qgeotiledmapscene.cpp | |
parent | 5de8061470c9bc89b1add1f681a732404e04c53e (diff) | |
download | qtlocation-2ace49b0db995a75694218113fd5743d05d97dcb.tar.gz |
Use OpenGL anisotropic texture filtering if available
Enabling 16x anisotropic texture filtering by default if available and
running on OpenGL.
This has almost no performance impact, while at the same time greatly
improving the map quality when tilting the map.
OpenGL is also supposed to be smart enough not to use it when no
anisotropy is present.
Change-Id: Ic0303b13625a28d36b258d617a9dd64f5b1a9700
Reviewed-by: Gunnar Sletta <gunnar@crimson.no>
Diffstat (limited to 'src/location/maps/qgeotiledmapscene.cpp')
-rw-r--r-- | src/location/maps/qgeotiledmapscene.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/location/maps/qgeotiledmapscene.cpp b/src/location/maps/qgeotiledmapscene.cpp index fbd05645..7a38153e 100644 --- a/src/location/maps/qgeotiledmapscene.cpp +++ b/src/location/maps/qgeotiledmapscene.cpp @@ -43,6 +43,7 @@ #include <QtCore/private/qobject_p.h> #include <QtQuick/QSGImageNode> #include <QtQuick/QQuickWindow> +#include <QtQuick/private/qsgdefaultimagenode_p.h> #include <QtGui/QVector3D> #include <cmath> #include <QtPositioning/private/qlocationutils_p.h> @@ -487,7 +488,8 @@ public: void updateTiles(QGeoTiledMapTileContainerNode *root, QGeoTiledMapScenePrivate *d, double camAdjust, - QQuickWindow *window); + QQuickWindow *window, + bool ogl); bool isTextureLinear; @@ -535,7 +537,8 @@ static bool qgeotiledmapscene_isTileInViewport(const QRectF &tileRect, const QMa void QGeoTiledMapRootNode::updateTiles(QGeoTiledMapTileContainerNode *root, QGeoTiledMapScenePrivate *d, double camAdjust, - QQuickWindow *window) + QQuickWindow *window, + bool ogl) { // Set up the matrix... QDoubleVector3D eye = d->m_cameraEye; @@ -573,6 +576,8 @@ void QGeoTiledMapRootNode::updateTiles(QGeoTiledMapTileContainerNode *root, } else { node->setFiltering(d->m_linearScaling ? QSGTexture::Linear : QSGTexture::Nearest); } + if (ogl) + static_cast<QSGDefaultImageNode *>(node)->setAnisotropyLevel(QSGTexture::Anisotropy16x); dirtyBits |= QSGNode::DirtyMaterial; } if (dirtyBits != 0) @@ -596,6 +601,8 @@ void QGeoTiledMapRootNode::updateTiles(QGeoTiledMapTileContainerNode *root, } else { tileNode->setFiltering(d->m_linearScaling ? QSGTexture::Linear : QSGTexture::Nearest); } + if (ogl) + static_cast<QSGDefaultImageNode *>(tileNode)->setAnisotropyLevel(QSGTexture::Anisotropy16x); root->addChild(s, tileNode); } else { delete tileNode; @@ -613,6 +620,7 @@ QSGNode *QGeoTiledMapScene::updateSceneGraph(QSGNode *oldNode, QQuickWindow *win return 0; } + bool isOpenGL = (window->rendererInterface()->graphicsApi() == QSGRendererInterface::OpenGL); QGeoTiledMapRootNode *mapRoot = static_cast<QGeoTiledMapRootNode *>(oldNode); if (!mapRoot) mapRoot = new QGeoTiledMapRootNode(); @@ -652,9 +660,9 @@ QSGNode *QGeoTiledMapScene::updateSceneGraph(QSGNode *oldNode, QQuickWindow *win } double sideLength = d->m_scaleFactor * d->m_tileSize * d->m_sideLength; - mapRoot->updateTiles(mapRoot->tiles, d, 0, window); - mapRoot->updateTiles(mapRoot->wrapLeft, d, +sideLength, window); - mapRoot->updateTiles(mapRoot->wrapRight, d, -sideLength, window); + mapRoot->updateTiles(mapRoot->tiles, d, 0, window, isOpenGL); + mapRoot->updateTiles(mapRoot->wrapLeft, d, +sideLength, window, isOpenGL); + mapRoot->updateTiles(mapRoot->wrapRight, d, -sideLength, window, isOpenGL); mapRoot->isTextureLinear = d->m_linearScaling; |