| 1346 | } |
| 1347 | |
| 1348 | void MapWidget::updateMapCache(bool use_background) |
| 1349 | { |
| 1350 | if (map_cache.isNull()) |
| 1351 | { |
| 1352 | // Lazy allocation of cache image |
| 1353 | map_cache = QImage(size(), QImage::Format_ARGB32_Premultiplied); |
| 1354 | map_cache_dirty_rect = rect(); |
| 1355 | } |
| 1356 | else |
| 1357 | { |
| 1358 | // Make sure not to use a bigger draw rect than necessary |
| 1359 | map_cache_dirty_rect = map_cache_dirty_rect.intersected(rect()); |
| 1360 | } |
| 1361 | |
| 1362 | // Start drawing |
| 1363 | QPainter painter; |
| 1364 | painter.begin(&map_cache); |
| 1365 | painter.setClipRect(map_cache_dirty_rect); |
| 1366 | |
| 1367 | // Fill with background color (TODO: make configurable) |
| 1368 | if (use_background) |
| 1369 | { |
| 1370 | painter.fillRect(map_cache_dirty_rect, Qt::white); |
| 1371 | } |
| 1372 | else |
| 1373 | { |
| 1374 | QPainter::CompositionMode mode = painter.compositionMode(); |
| 1375 | painter.setCompositionMode(QPainter::CompositionMode_Clear); |
| 1376 | painter.fillRect(map_cache_dirty_rect, Qt::transparent); |
| 1377 | painter.setCompositionMode(mode); |
| 1378 | } |
| 1379 | |
| 1380 | RenderConfig::Options options(RenderConfig::Screen | RenderConfig::HelperSymbols); |
| 1381 | bool use_antialiasing = force_antialiasing || Settings::getInstance().getSettingCached(Settings::MapDisplay_Antialiasing).toBool(); |
| 1382 | if (use_antialiasing) |
| 1383 | painter.setRenderHint(QPainter::Antialiasing); |
| 1384 | else |
| 1385 | options |= RenderConfig::DisableAntialiasing | RenderConfig::ForceMinSize; |
| 1386 | |
| 1387 | Map* map = view->getMap(); |
| 1388 | QRectF map_view_rect = view->calculateViewedRect(viewportToView(map_cache_dirty_rect)); |
| 1389 | |
| 1390 | RenderConfig config = { *map, map_view_rect, view->calculateFinalZoomFactor(), options, 1.0 }; |
| 1391 | |
| 1392 | painter.translate(width() / 2.0, height() / 2.0); |
| 1393 | painter.setWorldTransform(view->worldTransform(), true); |
| 1394 | #ifndef Q_OS_ANDROID |
| 1395 | if (view->isOverprintingSimulationEnabled()) |
| 1396 | map->drawOverprintingSimulation(&painter, config); |
| 1397 | else |
| 1398 | #endif |
| 1399 | map->draw(&painter, config); |
| 1400 | |
| 1401 | if (view->isGridVisible()) |
| 1402 | map->drawGrid(&painter, map_view_rect); |
| 1403 | |
| 1404 | // Finish drawing |
| 1405 | painter.end(); |
nothing calls this directly
no test coverage detected