| 347 | } |
| 348 | |
| 349 | void ContinuousPageWidget::deliverScaledImage(int pageIndex, quint64 generation, QImage scaledImage, |
| 350 | qint64 sourceCacheKey, QSize sourceSize, QSize targetSize, |
| 351 | QSize targetPixelSize, qreal devicePixelRatio) |
| 352 | { |
| 353 | ScaleRequestKey deliveredKey; |
| 354 | deliveredKey.sourceCacheKey = sourceCacheKey; |
| 355 | deliveredKey.targetPixelSize = targetPixelSize; |
| 356 | deliveredKey.devicePixelRatio = devicePixelRatio; |
| 357 | deliveredKey.generation = generation; |
| 358 | |
| 359 | // Only consume this result if it still matches the page's pending request. |
| 360 | // A stale task (older source / superseded request) is dropped without |
| 361 | // clearing the newer pending marker. |
| 362 | auto it = pendingScaleRequests.find(pageIndex); |
| 363 | if (it == pendingScaleRequests.end() || !(it.value() == deliveredKey)) { |
| 364 | return; |
| 365 | } |
| 366 | |
| 367 | pendingScaleRequests.erase(it); |
| 368 | |
| 369 | if (generation != cacheGeneration || scaledImage.isNull()) { |
| 370 | return; |
| 371 | } |
| 372 | |
| 373 | ScaledPageCacheEntry entry; |
| 374 | entry.sourceCacheKey = sourceCacheKey; |
| 375 | entry.sourceSize = sourceSize; |
| 376 | entry.targetSize = targetSize; |
| 377 | entry.targetPixelSize = targetPixelSize; |
| 378 | entry.targetDevicePixelRatio = devicePixelRatio; |
| 379 | entry.scaledImage = std::move(scaledImage); |
| 380 | scaledPageCache.pages.insert(pageIndex, std::move(entry)); |
| 381 | |
| 382 | update(pageRectFor(pageIndex)); |
| 383 | } |
| 384 | |
| 385 | void ContinuousPageWidget::resetScaledCache() |
| 386 | { |