Skip to content

Commit

Permalink
Qt 6: Fixed tile rendering when OpenGL is enabled
Browse files Browse the repository at this point in the history
Work around an issue introduced in Qt 6.4.1 (QTBUG-111416) by not using
QPainter::drawPixmapFragments in OpenGL mode. This makes rendering tiles
a bit less efficient, but at least it works.

Closes mapeditor#3578
  • Loading branch information
bjorn committed Feb 23, 2023
1 parent d9a83f0 commit 86652aa
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* Defold plugin: Allow overriding z value also when exporting to .collection (#3214)
* Qt 6: Fixed invisible tileset tabs when only a single tileset is open
* Qt 6: Fixed behavior of "Class of" selection popup
* Qt 6: Fixed tile rendering when OpenGL is enabled (#3578)
* Fixed positioning of point object name labels (by Logan Higinbotham, #3400)
* Fixed slight drift when zooming the map view in/out
* Fixed compile against Qt 6.4
Expand Down
1 change: 0 additions & 1 deletion src/libtiled/isometricrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "mapobject.h"
#include "tile.h"
#include "tilelayer.h"
#include "tileset.h"
#include "objectgroup.h"

#include <QtMath>
Expand Down
10 changes: 8 additions & 2 deletions src/libtiled/maprenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,13 @@ void CellRenderer::render(const Cell &cell, const QPointF &screenPos, const QSiz
fragment.scaleX *= flippedHorizontally ? -1 : 1;
fragment.scaleY *= flippedVertically ? -1 : 1;

// Avoid using drawPixmapFragments with OpenGL in Qt 6.4.1 and above
// (https://bugreports.qt.io/browse/QTBUG-111416)
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 1)
if (mIsOpenGL || (fragment.scaleX > 0 && fragment.scaleY > 0)) {
#else
if (!mIsOpenGL && fragment.scaleX > 0 && fragment.scaleY > 0) {
#endif
mTile = tile;
mFragments.append(fragment);
return;
Expand Down Expand Up @@ -525,7 +531,7 @@ void CellRenderer::render(const Cell &cell, const QPointF &screenPos, const QSiz
mFragments.append(fragment);
paintTileCollisionShapes();
mTile = nullptr;
mFragments.resize(0);
mFragments.clear();
}
}

Expand All @@ -548,7 +554,7 @@ void CellRenderer::flush()
}

mTile = nullptr;
mFragments.resize(0);
mFragments.clear();
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/libtiled/orthogonalrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "mapobject.h"
#include "tile.h"
#include "tilelayer.h"
#include "tileset.h"
#include "objectgroup.h"

#include <QtCore/qmath.h>
Expand Down
2 changes: 1 addition & 1 deletion src/libtiledquick/tilelayeritem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ QSGNode *TileLayerItem::updatePaintNode(QSGNode *node,
if (tileset != helper.tileset() || tileData.size() == TilesNode::MaxTileCount) {
if (!tileData.isEmpty()) {
node->appendChildNode(new TilesNode(helper.texture(), tileData));
tileData.resize(0);
tileData.clear();
}

helper.setTileset(tileset);
Expand Down

0 comments on commit 86652aa

Please sign in to comment.