| 454 | } |
| 455 | |
| 456 | QPixmap MediaPreviewWidget::currentImage() const { |
| 457 | const auto blur = Images::PrepareArgs{ .options = Images::Option::Blur }; |
| 458 | if (_document) { |
| 459 | const auto sticker = _document->sticker(); |
| 460 | const auto webm = sticker && sticker->isWebm(); |
| 461 | if (sticker && !webm) { |
| 462 | if (_cacheStatus != CacheLoaded) { |
| 463 | const_cast<MediaPreviewWidget*>(this)->createLottieIfReady( |
| 464 | _document); |
| 465 | if (_lottie && _lottie->ready()) { |
| 466 | return QPixmap(); |
| 467 | } else if (const auto image |
| 468 | = _documentMedia->getStickerLarge()) { |
| 469 | const auto s = currentDimensions(); |
| 470 | _cache = image->pix(s); |
| 471 | _cacheStatus = CacheLoaded; |
| 472 | } else if (_cacheStatus != CacheThumbLoaded |
| 473 | && _document->hasThumbnail() |
| 474 | && _documentMedia->thumbnail()) { |
| 475 | const auto s = currentDimensions(); |
| 476 | _cache = _documentMedia->thumbnail()->pix(s, blur); |
| 477 | if (_document && _document->emojiUsesTextColor()) { |
| 478 | _cache = Ui::PixmapFromImage( |
| 479 | Images::Colored( |
| 480 | _cache.toImage(), |
| 481 | st::windowFg->c)); |
| 482 | } |
| 483 | _cacheStatus = CacheThumbLoaded; |
| 484 | } |
| 485 | } |
| 486 | } else { |
| 487 | const_cast<MediaPreviewWidget*>(this)->validateGifAnimation(); |
| 488 | const auto &gif = (_gif && _gif->started()) |
| 489 | ? _gif |
| 490 | : _gifThumbnail; |
| 491 | if (gif && gif->started()) { |
| 492 | const auto paused = _controller->isGifPausedAtLeastFor( |
| 493 | Window::GifPauseReason::MediaPreview); |
| 494 | return QPixmap::fromImage( |
| 495 | gif->current( |
| 496 | { .frame = currentDimensions(), .keepAlpha = webm }, |
| 497 | paused ? 0 : crl::now()), |
| 498 | Qt::ColorOnly); |
| 499 | } |
| 500 | if (_cacheStatus != CacheThumbLoaded |
| 501 | && _document->hasThumbnail()) { |
| 502 | const auto s = currentDimensions(); |
| 503 | const auto thumbnail = _documentMedia->thumbnail(); |
| 504 | if (thumbnail) { |
| 505 | _cache = thumbnail->pix(s, blur); |
| 506 | _cacheStatus = CacheThumbLoaded; |
| 507 | } else if (const auto blurred |
| 508 | = _documentMedia->thumbnailInline()) { |
| 509 | _cache = blurred->pix(s, blur); |
| 510 | _cacheStatus = CacheThumbLoaded; |
| 511 | } |
| 512 | } |
| 513 | } |
nothing calls this directly
no test coverage detected