MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / validatePaperThumbnail

Method validatePaperThumbnail

Telegram/SourceFiles/boxes/background_box.cpp:642–684  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

640}
641
642void BackgroundBox::Inner::validatePaperThumbnail(
643 const Paper &paper) const {
644 if (!paper.thumbnail.isNull()) {
645 return;
646 }
647 const auto localThumbnail = paper.data.localThumbnail();
648 if (!localThumbnail) {
649 if (const auto document = paper.data.document()) {
650 if (!paper.dataMedia) {
651 paper.dataMedia = document->createMediaView();
652 paper.dataMedia->thumbnailWanted(paper.data.fileOrigin());
653 }
654 if (!paper.dataMedia->thumbnail()) {
655 return;
656 }
657 } else if (!paper.data.backgroundColors().empty()) {
658 paper.thumbnail = Ui::PixmapFromImage(
659 Ui::GenerateBackgroundImage(
660 st::backgroundSize * style::DevicePixelRatio(),
661 paper.data.backgroundColors(),
662 paper.data.gradientRotation()));
663 paper.thumbnail.setDevicePixelRatio(style::DevicePixelRatio());
664 return;
665 } else {
666 return;
667 }
668 }
669 const auto thumbnail = localThumbnail
670 ? localThumbnail
671 : paper.dataMedia->thumbnail();
672 auto original = thumbnail->original();
673 if (paper.data.isPattern()) {
674 original = Ui::PreparePatternImage(
675 std::move(original),
676 paper.data.backgroundColors(),
677 paper.data.gradientRotation(),
678 paper.data.patternOpacity());
679 }
680 paper.thumbnail = Ui::PixmapFromImage(TakeMiddleSample(
681 original,
682 st::backgroundSize));
683 paper.thumbnail.setDevicePixelRatio(style::DevicePixelRatio());
684}
685
686bool BackgroundBox::Inner::forChannel() const {
687 return _forPeer && _forPeer->isChannel();

Callers

nothing calls this directly

Calls 15

GenerateBackgroundImageFunction · 0.85
PreparePatternImageFunction · 0.85
TakeMiddleSampleFunction · 0.85
localThumbnailMethod · 0.80
thumbnailWantedMethod · 0.80
backgroundColorsMethod · 0.80
gradientRotationMethod · 0.80
originalMethod · 0.80
isPatternMethod · 0.80
patternOpacityMethod · 0.80
isNullMethod · 0.45
documentMethod · 0.45

Tested by

no test coverage detected