mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-02-20 09:40:49 +01:00
Raster tile APIs unification/cleanup
This commit is contained in:
parent
d42c6831df
commit
6ccfe0eb21
@ -365,13 +365,15 @@ void RasterTile::fetchData(QList<MapData::Poly> &polygons,
|
|||||||
|
|
||||||
void RasterTile::render()
|
void RasterTile::render()
|
||||||
{
|
{
|
||||||
|
QImage img(_rect.width() * _ratio, _rect.height() * _ratio,
|
||||||
|
QImage::Format_ARGB32_Premultiplied);
|
||||||
QList<MapData::Line> lines;
|
QList<MapData::Line> lines;
|
||||||
QList<MapData::Poly> polygons;
|
QList<MapData::Poly> polygons;
|
||||||
QList<MapData::Point> points;
|
QList<MapData::Point> points;
|
||||||
QList<TextItem*> textItems, lights;
|
QList<TextItem*> textItems, lights;
|
||||||
|
|
||||||
_pixmap.setDevicePixelRatio(_ratio);
|
img.setDevicePixelRatio(_ratio);
|
||||||
_pixmap.fill(Qt::transparent);
|
img.fill(Qt::transparent);
|
||||||
|
|
||||||
fetchData(polygons, lines, points);
|
fetchData(polygons, lines, points);
|
||||||
|
|
||||||
@ -379,7 +381,7 @@ void RasterTile::render()
|
|||||||
processPoints(points, textItems, lights);
|
processPoints(points, textItems, lights);
|
||||||
processLines(lines, textItems);
|
processLines(lines, textItems);
|
||||||
|
|
||||||
QPainter painter(&_pixmap);
|
QPainter painter(&img);
|
||||||
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||||
painter.setRenderHint(QPainter::Antialiasing);
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
painter.translate(-_rect.x(), -_rect.y());
|
painter.translate(-_rect.x(), -_rect.y());
|
||||||
@ -399,23 +401,5 @@ void RasterTile::render()
|
|||||||
//painter.setRenderHint(QPainter::Antialiasing, false);
|
//painter.setRenderHint(QPainter::Antialiasing, false);
|
||||||
//painter.drawRect(QRect(_rect.topLeft(), _pixmap.size()));
|
//painter.drawRect(QRect(_rect.topLeft(), _pixmap.size()));
|
||||||
|
|
||||||
_valid = true;
|
_pixmap.convertFromImage(img);
|
||||||
}
|
|
||||||
|
|
||||||
RasterTile::RasterTile(const Projection &proj, const Transform &transform,
|
|
||||||
const Style *style, const MapData *data, int zoom, const Range &zoomRange,
|
|
||||||
const QRect &rect, qreal ratio) :
|
|
||||||
_proj(proj), _transform(transform), _style(style), _map(data), _atlas(0),
|
|
||||||
_zoom(zoom), _zoomRange(zoomRange), _rect(rect), _ratio(ratio),
|
|
||||||
_pixmap(rect.width() * ratio, rect.height() * ratio), _valid(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
RasterTile::RasterTile(const Projection &proj, const Transform &transform,
|
|
||||||
const Style *style, AtlasData *data, int zoom, const Range &zoomRange,
|
|
||||||
const QRect &rect, qreal ratio) :
|
|
||||||
_proj(proj), _transform(transform), _style(style), _map(0), _atlas(data),
|
|
||||||
_zoom(zoom), _zoomRange(zoomRange), _rect(rect), _ratio(ratio),
|
|
||||||
_pixmap(rect.width() * ratio, rect.height() * ratio), _valid(false)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
@ -18,15 +18,18 @@ class RasterTile
|
|||||||
public:
|
public:
|
||||||
RasterTile(const Projection &proj, const Transform &transform,
|
RasterTile(const Projection &proj, const Transform &transform,
|
||||||
const Style *style, const MapData *data, int zoom, const Range &zoomRange,
|
const Style *style, const MapData *data, int zoom, const Range &zoomRange,
|
||||||
const QRect &rect, qreal ratio);
|
const QRect &rect, qreal ratio) :
|
||||||
|
_proj(proj), _transform(transform), _style(style), _map(data), _atlas(0),
|
||||||
|
_zoom(zoom), _zoomRange(zoomRange), _rect(rect), _ratio(ratio) {}
|
||||||
RasterTile(const Projection &proj, const Transform &transform,
|
RasterTile(const Projection &proj, const Transform &transform,
|
||||||
const Style *style, AtlasData *data, int zoom, const Range &zoomRange,
|
const Style *style, AtlasData *data, int zoom, const Range &zoomRange,
|
||||||
const QRect &rect, qreal ratio);
|
const QRect &rect, qreal ratio) :
|
||||||
|
_proj(proj), _transform(transform), _style(style), _map(0), _atlas(data),
|
||||||
|
_zoom(zoom), _zoomRange(zoomRange), _rect(rect), _ratio(ratio) {}
|
||||||
|
|
||||||
int zoom() const {return _zoom;}
|
int zoom() const {return _zoom;}
|
||||||
QPoint xy() const {return _rect.topLeft();}
|
QPoint xy() const {return _rect.topLeft();}
|
||||||
const QPixmap &pixmap() const {return _pixmap;}
|
const QPixmap &pixmap() const {return _pixmap;}
|
||||||
bool isValid() const {return _valid;}
|
|
||||||
|
|
||||||
void render();
|
void render();
|
||||||
|
|
||||||
@ -65,7 +68,6 @@ private:
|
|||||||
QRect _rect;
|
QRect _rect;
|
||||||
qreal _ratio;
|
qreal _ratio;
|
||||||
QPixmap _pixmap;
|
QPixmap _pixmap;
|
||||||
bool _valid;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -511,5 +511,5 @@ void RasterTile::render()
|
|||||||
//painter.setRenderHint(QPainter::Antialiasing, false);
|
//painter.setRenderHint(QPainter::Antialiasing, false);
|
||||||
//painter.drawRect(_rect);
|
//painter.drawRect(_rect);
|
||||||
|
|
||||||
_pixmap = QPixmap::fromImage(img);
|
_pixmap.convertFromImage(img);
|
||||||
}
|
}
|
||||||
|
@ -324,7 +324,7 @@ void ENCAtlas::jobFinished(ENCJob *job)
|
|||||||
|
|
||||||
for (int i = 0; i < tiles.size(); i++) {
|
for (int i = 0; i < tiles.size(); i++) {
|
||||||
const ENC::RasterTile &mt = tiles.at(i);
|
const ENC::RasterTile &mt = tiles.at(i);
|
||||||
if (mt.isValid())
|
if (!mt.pixmap().isNull())
|
||||||
QPixmapCache::insert(key(mt.zoom(), mt.xy()), mt.pixmap());
|
QPixmapCache::insert(key(mt.zoom(), mt.xy()), mt.pixmap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,7 +296,7 @@ void ENCMap::jobFinished(ENCJob *job)
|
|||||||
|
|
||||||
for (int i = 0; i < tiles.size(); i++) {
|
for (int i = 0; i < tiles.size(); i++) {
|
||||||
const ENC::RasterTile &mt = tiles.at(i);
|
const ENC::RasterTile &mt = tiles.at(i);
|
||||||
if (mt.isValid())
|
if (!mt.pixmap().isNull())
|
||||||
QPixmapCache::insert(key(mt.zoom(), mt.xy()), mt.pixmap());
|
QPixmapCache::insert(key(mt.zoom(), mt.xy()), mt.pixmap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,5 +529,5 @@ void RasterTile::render()
|
|||||||
|
|
||||||
qDeleteAll(textItems);
|
qDeleteAll(textItems);
|
||||||
|
|
||||||
_pixmap = QPixmap::fromImage(img);
|
_pixmap.convertFromImage(img);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user