mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-02-17 16:20:48 +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()
|
||||
{
|
||||
QImage img(_rect.width() * _ratio, _rect.height() * _ratio,
|
||||
QImage::Format_ARGB32_Premultiplied);
|
||||
QList<MapData::Line> lines;
|
||||
QList<MapData::Poly> polygons;
|
||||
QList<MapData::Point> points;
|
||||
QList<TextItem*> textItems, lights;
|
||||
|
||||
_pixmap.setDevicePixelRatio(_ratio);
|
||||
_pixmap.fill(Qt::transparent);
|
||||
img.setDevicePixelRatio(_ratio);
|
||||
img.fill(Qt::transparent);
|
||||
|
||||
fetchData(polygons, lines, points);
|
||||
|
||||
@ -379,7 +381,7 @@ void RasterTile::render()
|
||||
processPoints(points, textItems, lights);
|
||||
processLines(lines, textItems);
|
||||
|
||||
QPainter painter(&_pixmap);
|
||||
QPainter painter(&img);
|
||||
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.translate(-_rect.x(), -_rect.y());
|
||||
@ -399,23 +401,5 @@ void RasterTile::render()
|
||||
//painter.setRenderHint(QPainter::Antialiasing, false);
|
||||
//painter.drawRect(QRect(_rect.topLeft(), _pixmap.size()));
|
||||
|
||||
_valid = true;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
_pixmap.convertFromImage(img);
|
||||
}
|
||||
|
@ -18,15 +18,18 @@ class RasterTile
|
||||
public:
|
||||
RasterTile(const Projection &proj, const Transform &transform,
|
||||
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,
|
||||
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;}
|
||||
QPoint xy() const {return _rect.topLeft();}
|
||||
const QPixmap &pixmap() const {return _pixmap;}
|
||||
bool isValid() const {return _valid;}
|
||||
|
||||
void render();
|
||||
|
||||
@ -65,7 +68,6 @@ private:
|
||||
QRect _rect;
|
||||
qreal _ratio;
|
||||
QPixmap _pixmap;
|
||||
bool _valid;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -511,5 +511,5 @@ void RasterTile::render()
|
||||
//painter.setRenderHint(QPainter::Antialiasing, false);
|
||||
//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++) {
|
||||
const ENC::RasterTile &mt = tiles.at(i);
|
||||
if (mt.isValid())
|
||||
if (!mt.pixmap().isNull())
|
||||
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++) {
|
||||
const ENC::RasterTile &mt = tiles.at(i);
|
||||
if (mt.isValid())
|
||||
if (!mt.pixmap().isNull())
|
||||
QPixmapCache::insert(key(mt.zoom(), mt.xy()), mt.pixmap());
|
||||
}
|
||||
|
||||
|
@ -529,5 +529,5 @@ void RasterTile::render()
|
||||
|
||||
qDeleteAll(textItems);
|
||||
|
||||
_pixmap = QPixmap::fromImage(img);
|
||||
_pixmap.convertFromImage(img);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user