diff --git a/Telegram/SourceFiles/ui/chat/chat_theme.cpp b/Telegram/SourceFiles/ui/chat/chat_theme.cpp index 4b2e29ed4..b3df51177 100644 --- a/Telegram/SourceFiles/ui/chat/chat_theme.cpp +++ b/Telegram/SourceFiles/ui/chat/chat_theme.cpp @@ -124,6 +124,9 @@ constexpr auto kMinAcceptableContrast = 1.14;// 4.5; QImage::Format_ARGB32_Premultiplied), .gradient = gradient, .area = request.area, + .waitingForNegativePattern = (request.background.isPattern + && request.background.prepared.isNull() + && request.background.patternOpacity < 0.) }; } else { const auto rects = ComputeChatBackgroundRects( @@ -206,7 +209,8 @@ CachedBackground::CachedBackground(CacheBackgroundResult &&result) : pixmap(PixmapFromImage(std::move(result.image))) , area(result.area) , x(result.x) -, y(result.y) { +, y(result.y) +, waitingForNegativePattern(result.waitingForNegativePattern) { } ChatTheme::ChatTheme() { diff --git a/Telegram/SourceFiles/ui/chat/chat_theme.h b/Telegram/SourceFiles/ui/chat/chat_theme.h index a6ee89a4f..ca8c1004e 100644 --- a/Telegram/SourceFiles/ui/chat/chat_theme.h +++ b/Telegram/SourceFiles/ui/chat/chat_theme.h @@ -79,6 +79,7 @@ struct CacheBackgroundResult { QSize area; int x = 0; int y = 0; + bool waitingForNegativePattern = false; }; struct CachedBackground { @@ -89,6 +90,7 @@ struct CachedBackground { QSize area; int x = 0; int y = 0; + bool waitingForNegativePattern = false; }; struct BackgroundState { diff --git a/Telegram/SourceFiles/window/section_widget.cpp b/Telegram/SourceFiles/window/section_widget.cpp index 862adb762..1da38491f 100644 --- a/Telegram/SourceFiles/window/section_widget.cpp +++ b/Telegram/SourceFiles/window/section_widget.cpp @@ -191,7 +191,11 @@ void SectionWidget::PaintBackground( const auto to = QRect( QPoint(cache.x, fromy + cache.y), cache.pixmap.size() / cIntRetinaFactor()); - if (cache.area == fill) { + if (cache.waitingForNegativePattern) { + // While we wait for pattern being loaded we paint just gradient. + // But in case of negative patter opacity we just fill-black. + p.fillRect(to, Qt::black); + } else if (cache.area == fill) { p.drawPixmap(to, cache.pixmap); } else { const auto sx = fill.width() / float64(cache.area.width());