MCPcopy Create free account
hub / github.com/YACReader/yacreader / deliverScaledImage

Method deliverScaledImage

YACReader/continuous_page_widget.cpp:349–383  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

347}
348
349void 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
385void ContinuousPageWidget::resetScaledCache()
386{

Callers 1

runMethod · 0.80

Calls 1

insertMethod · 0.45

Tested by

no test coverage detected