From 84a592998d201e22eafd54d3245f7a52d09401ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sun, 2 Apr 2023 14:36:03 +0200 Subject: [PATCH] Only tile big (> Qt OpenGL cache size / 2) images --- src/map/image.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/map/image.cpp b/src/map/image.cpp index ee013d76..f6a79d8c 100644 --- a/src/map/image.cpp +++ b/src/map/image.cpp @@ -2,6 +2,11 @@ #include "image.h" #define TILE_SIZE 256 +#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) +#define OPENGL_SIZE_LIMIT 536870912 /* 512MB */ +#else +#define OPENGL_SIZE_LIMIT 134217728 /* 128MB */ +#endif void Image::draw(QPainter *painter, const QRectF &rect, Map::Flags flags) { @@ -11,7 +16,7 @@ void Image::draw(QPainter *painter, const QRectF &rect, Map::Flags flags) /* When OpenGL is used, big images are rendered incredibly slow or not at all using the QPainter::drawImage() function with a source rect set. So we have to tile the image ourself before it can be drawn. */ - if (flags & Map::OpenGL) { + if (flags & Map::OpenGL && _img.sizeInBytes() > OPENGL_SIZE_LIMIT) { for (int i = sr.left()/TILE_SIZE; i <= sr.right()/TILE_SIZE; i++) { for (int j = sr.top()/TILE_SIZE; j <= sr.bottom()/TILE_SIZE; j++) { QPoint tl(i * TILE_SIZE, j * TILE_SIZE);