mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 11:45:53 +01:00
Optimization
This commit is contained in:
parent
a42709e6a2
commit
071056b9bc
@ -177,9 +177,9 @@ void RasterTile::render()
|
|||||||
processPolygons(textItems);
|
processPolygons(textItems);
|
||||||
processLines(textItems);
|
processLines(textItems);
|
||||||
|
|
||||||
_img.fill(Qt::transparent);
|
_pixmap.fill(Qt::transparent);
|
||||||
|
|
||||||
QPainter painter(&_img);
|
QPainter painter(&_pixmap);
|
||||||
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||||
painter.setRenderHint(QPainter::Antialiasing);
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
painter.translate(-_xy.x(), -_xy.y());
|
painter.translate(-_xy.x(), -_xy.y());
|
||||||
@ -300,7 +300,7 @@ static void removeDuplicitLabel(QList<TextItem *> &labels, const QString &text,
|
|||||||
|
|
||||||
void RasterTile::processPolygons(QList<TextItem*> &textItems)
|
void RasterTile::processPolygons(QList<TextItem*> &textItems)
|
||||||
{
|
{
|
||||||
QRectF tileRect(_xy, _img.size());
|
QRectF tileRect(_xy, _pixmap.size());
|
||||||
QSet<QString> set;
|
QSet<QString> set;
|
||||||
QList<TextItem *> labels;
|
QList<TextItem *> labels;
|
||||||
|
|
||||||
@ -337,7 +337,7 @@ void RasterTile::processPolygons(QList<TextItem*> &textItems)
|
|||||||
|
|
||||||
void RasterTile::processLines(QList<TextItem*> &textItems)
|
void RasterTile::processLines(QList<TextItem*> &textItems)
|
||||||
{
|
{
|
||||||
QRect tileRect(_xy, _img.size());
|
QRect tileRect(_xy, _pixmap.size());
|
||||||
|
|
||||||
std::stable_sort(_lines.begin(), _lines.end());
|
std::stable_sort(_lines.begin(), _lines.end());
|
||||||
|
|
||||||
@ -403,7 +403,7 @@ void RasterTile::processShields(const QRect &tileRect,
|
|||||||
it != shields.constEnd(); ++it) {
|
it != shields.constEnd(); ++it) {
|
||||||
const QPolygonF &p = it.value();
|
const QPolygonF &p = it.value();
|
||||||
QRectF rect(p.boundingRect() & tileRect);
|
QRectF rect(p.boundingRect() & tileRect);
|
||||||
if (AREA(rect) < AREA(QRect(0, 0, _img.width()/4, _img.width()/4)))
|
if (AREA(rect) < AREA(QRect(0, 0, _pixmap.width()/4, _pixmap.width()/4)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QMap<qreal, int> map;
|
QMap<qreal, int> map;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef IMG_RASTERTILE_H
|
#ifndef IMG_RASTERTILE_H
|
||||||
#define IMG_RASTERTILE_H
|
#define IMG_RASTERTILE_H
|
||||||
|
|
||||||
#include <QImage>
|
#include <QPixmap>
|
||||||
#include "mapdata.h"
|
#include "mapdata.h"
|
||||||
|
|
||||||
class QPainter;
|
class QPainter;
|
||||||
@ -19,12 +19,12 @@ public:
|
|||||||
const QString &key, const QList<MapData::Poly> &polygons,
|
const QString &key, const QList<MapData::Poly> &polygons,
|
||||||
const QList<MapData::Poly> &lines, QList<MapData::Point> &points)
|
const QList<MapData::Poly> &lines, QList<MapData::Point> &points)
|
||||||
: _map(map), _style(style), _zoom(zoom), _xy(rect.topLeft()),
|
: _map(map), _style(style), _zoom(zoom), _xy(rect.topLeft()),
|
||||||
_key(key), _img(rect.size(), QImage::Format_ARGB32_Premultiplied),
|
_key(key), _pixmap(rect.size()), _polygons(polygons), _lines(lines),
|
||||||
_polygons(polygons), _lines(lines), _points(points) {}
|
_points(points) {}
|
||||||
|
|
||||||
const QString &key() const {return _key;}
|
const QString &key() const {return _key;}
|
||||||
const QPoint &xy() const {return _xy;}
|
const QPoint &xy() const {return _xy;}
|
||||||
const QImage &img() const {return _img;}
|
const QPixmap &pixmap() const {return _pixmap;}
|
||||||
|
|
||||||
void render();
|
void render();
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ private:
|
|||||||
int _zoom;
|
int _zoom;
|
||||||
QPoint _xy;
|
QPoint _xy;
|
||||||
QString _key;
|
QString _key;
|
||||||
QImage _img;
|
QPixmap _pixmap;
|
||||||
QList<MapData::Poly> _polygons;
|
QList<MapData::Poly> _polygons;
|
||||||
QList<MapData::Poly> _lines;
|
QList<MapData::Poly> _lines;
|
||||||
QList<MapData::Point> _points;
|
QList<MapData::Point> _points;
|
||||||
|
@ -193,13 +193,12 @@ void IMGMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
|
|
||||||
for (int i = 0; i < tiles.size(); i++) {
|
for (int i = 0; i < tiles.size(); i++) {
|
||||||
RasterTile &mt = tiles[i];
|
RasterTile &mt = tiles[i];
|
||||||
QPixmap pm(QPixmap::fromImage(mt.img()));
|
const QPixmap &pm = mt.pixmap();
|
||||||
if (pm.isNull())
|
if (pm.isNull())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QPixmapCache::insert(mt.key(), pm);
|
|
||||||
|
|
||||||
painter->drawPixmap(mt.xy(), pm);
|
painter->drawPixmap(mt.xy(), pm);
|
||||||
|
QPixmapCache::insert(mt.key(), pm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,11 +228,11 @@ void RasterTile::render()
|
|||||||
std::sort(_points.begin(), _points.end());
|
std::sort(_points.begin(), _points.end());
|
||||||
|
|
||||||
QList<TextItem*> textItems;
|
QList<TextItem*> textItems;
|
||||||
QRect tileRect(_xy, _img.size());
|
QRect tileRect(_xy, _pixmap.size());
|
||||||
|
|
||||||
_img.fill(Qt::transparent);
|
_pixmap.fill(Qt::transparent);
|
||||||
|
|
||||||
QPainter painter(&_img);
|
QPainter painter(&_pixmap);
|
||||||
painter.setRenderHint(QPainter::Antialiasing);
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
painter.translate(-_xy.x(), -_xy.y());
|
painter.translate(-_xy.x(), -_xy.y());
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef MAPSFORGE_RASTERTILE_H
|
#ifndef MAPSFORGE_RASTERTILE_H
|
||||||
#define MAPSFORGE_RASTERTILE_H
|
#define MAPSFORGE_RASTERTILE_H
|
||||||
|
|
||||||
#include <QImage>
|
#include <QPixmap>
|
||||||
#include "map/projection.h"
|
#include "map/projection.h"
|
||||||
#include "map/transform.h"
|
#include "map/transform.h"
|
||||||
#include "style.h"
|
#include "style.h"
|
||||||
@ -19,12 +19,11 @@ public:
|
|||||||
const QRect &rect, const QString &key, const QList<MapData::Path> &paths,
|
const QRect &rect, const QString &key, const QList<MapData::Path> &paths,
|
||||||
const QList<MapData::Point> &points)
|
const QList<MapData::Point> &points)
|
||||||
: _proj(proj), _transform(transform), _zoom(zoom), _xy(rect.topLeft()),
|
: _proj(proj), _transform(transform), _zoom(zoom), _xy(rect.topLeft()),
|
||||||
_key(key), _img(rect.size(), QImage::Format_ARGB32_Premultiplied),
|
_key(key), _pixmap(rect.size()), _paths(paths), _points(points) {}
|
||||||
_paths(paths), _points(points) {}
|
|
||||||
|
|
||||||
const QString &key() const {return _key;}
|
const QString &key() const {return _key;}
|
||||||
const QPoint &xy() const {return _xy;}
|
const QPoint &xy() const {return _xy;}
|
||||||
const QImage &img() const {return _img;}
|
const QPixmap &pixmap() const {return _pixmap;}
|
||||||
|
|
||||||
void render();
|
void render();
|
||||||
|
|
||||||
@ -83,7 +82,7 @@ private:
|
|||||||
int _zoom;
|
int _zoom;
|
||||||
QPoint _xy;
|
QPoint _xy;
|
||||||
QString _key;
|
QString _key;
|
||||||
QImage _img;
|
QPixmap _pixmap;
|
||||||
QList<MapData::Path> _paths;
|
QList<MapData::Path> _paths;
|
||||||
QList<MapData::Point> _points;
|
QList<MapData::Point> _points;
|
||||||
};
|
};
|
||||||
|
@ -35,7 +35,7 @@ private slots:
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < _tiles.size(); i++) {
|
for (int i = 0; i < _tiles.size(); i++) {
|
||||||
Mapsforge::RasterTile &mt = _tiles[i];
|
Mapsforge::RasterTile &mt = _tiles[i];
|
||||||
QPixmap pm(QPixmap::fromImage(mt.img()));
|
const QPixmap &pm = mt.pixmap();
|
||||||
if (pm.isNull())
|
if (pm.isNull())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user