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

Method createCache

Telegram/SourceFiles/calls/calls_userpic.cpp:171–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169}
170
171void Userpic::createCache(Image *image) {
172 const auto size = this->size();
173 const auto real = size * style::DevicePixelRatio();
174 //_useTransparency
175 // ? (Images::Option::RoundLarge
176 // | Images::Option::RoundSkipBottomLeft
177 // | Images::Option::RoundSkipBottomRight)
178 // : Images::Option::None;
179 if (image) {
180 auto width = image->width();
181 auto height = image->height();
182 if (width > height) {
183 width = qMax((width * real) / height, 1);
184 height = real;
185 } else {
186 height = qMax((height * real) / width, 1);
187 width = real;
188 }
189 _userPhoto = image->pixNoCache(
190 { width, height },
191 {
192 .options = Images::Option::RoundCircle,
193 .outer = { size, size },
194 });
195 _userPhoto.setDevicePixelRatio(style::DevicePixelRatio());
196 } else {
197 auto filled = QImage(
198 QSize(real, real),
199 QImage::Format_ARGB32_Premultiplied);
200 filled.setDevicePixelRatio(style::DevicePixelRatio());
201 filled.fill(Qt::transparent);
202 {
203 auto p = QPainter(&filled);
204 Ui::EmptyUserpic(
205 Ui::EmptyUserpic::UserpicColor(_peer->colorIndex()),
206 _peer->name()
207 ).paintCircle(p, 0, 0, size, size);
208 }
209 //_userPhoto = Images::PixmapFast(Images::Round(
210 // std::move(filled),
211 // ImageRoundRadius::Large,
212 // RectPart::TopLeft | RectPart::TopRight));
213 _userPhoto = Images::PixmapFast(std::move(filled));
214 }
215
216 _content.update();
217}
218
219bool Userpic::isGoodPhoto(PhotoData *photo) const {
220 if (!photo || photo->isNull()) {

Callers

nothing calls this directly

Calls 12

sizeMethod · 0.95
pixNoCacheMethod · 0.80
paintCircleMethod · 0.80
QImageClass · 0.50
QPainterClass · 0.50
EmptyUserpicClass · 0.50
widthMethod · 0.45
heightMethod · 0.45
fillMethod · 0.45
colorIndexMethod · 0.45
nameMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected