Commit b1b8f0fd authored by Dennis Nienhüser's avatar Dennis Nienhüser
Browse files

Minor low level optimizations.

parent fd19557c
......@@ -365,8 +365,7 @@ QVector<VisiblePlacemark *> PlacemarkLayout::generateLayout( const ViewportParam
for ( int i = 0; i < selectedIndexes.count(); ++i ) {
const QModelIndex index = selectedIndexes.at( i );
const GeoDataPlacemark *placemark = dynamic_cast<GeoDataPlacemark*>(qvariant_cast<GeoDataObject*>(index.data( MarblePlacemarkModel::ObjectPointerRole ) ));
Q_ASSERT(placemark);
const GeoDataPlacemark *placemark = static_cast<GeoDataPlacemark*>(qvariant_cast<GeoDataObject*>(index.data( MarblePlacemarkModel::ObjectPointerRole ) ));
const GeoDataCoordinates coordinates = placemarkIconCoordinates( placemark );
if ( !coordinates.isValid() ) {
......
......@@ -67,7 +67,8 @@ bool PlacemarkLayer::render( GeoPainter *geoPainter, ViewportParams *viewport,
QVector<VisiblePlacemark*>::const_iterator itEnd = visiblePlacemarks.constBegin();
QPainter *const painter = geoPainter;
bool const repeatableX = viewport->currentProjection()->repeatableX();
int const radius4 = 4 * viewport->radius();
while ( visit != itEnd ) {
--visit;
......@@ -78,23 +79,21 @@ bool PlacemarkLayer::render( GeoPainter *geoPainter, ViewportParams *viewport,
// when the map is such zoomed out that a given place
// appears many times, we draw one placemark at each
if (viewport->currentProjection()->repeatableX() ) {
if (repeatableX) {
const int symbolX = mark->symbolPosition().x();
const int textX = mark->labelRect().x();
for ( int i = symbolX % (4 * viewport->radius());
i <= viewport->width();
i += 4 * viewport->radius() )
{
labelRect.moveLeft(i - symbolX + textX );
symbolPos.setX( i );
for (int i = symbolX % radius4, width = viewport->width(); i <= width; i += radius4) {
labelRect.moveLeft(i - symbolX + textX);
symbolPos.setX(i);
painter->drawPixmap( symbolPos, mark->symbolPixmap() );
painter->drawPixmap( labelRect, mark->labelPixmap() );
}
} else { // simple case, one draw per placemark
painter->drawPixmap( symbolPos, mark->symbolPixmap() );
painter->drawPixmap( labelRect, mark->labelPixmap() );
} else {
// simple case, one draw per placemark
painter->drawPixmap(symbolPos, mark->symbolPixmap());
painter->drawPixmap(labelRect, mark->labelPixmap());
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment