mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 06:26:18 +00:00
Make complex gradients animate on outgoing messages.
This commit is contained in:
@@ -55,7 +55,42 @@ class SectionMemento;
|
||||
class Controller;
|
||||
class FiltersMenu;
|
||||
|
||||
struct CacheBackgroundRequest {
|
||||
QImage prepared;
|
||||
QImage preparedForTiled;
|
||||
QSize area;
|
||||
int gradientRotation = 0;
|
||||
bool tile = false;
|
||||
bool recreateGradient = false;
|
||||
QImage gradient;
|
||||
std::vector<QColor> gradientColors;
|
||||
float64 gradientProgress = 1.;
|
||||
float64 patternOpacity = 1.;
|
||||
|
||||
explicit operator bool() const {
|
||||
return !prepared.isNull() || !gradient.isNull();
|
||||
}
|
||||
};
|
||||
|
||||
bool operator==(
|
||||
const CacheBackgroundRequest &a,
|
||||
const CacheBackgroundRequest &b);
|
||||
bool operator!=(
|
||||
const CacheBackgroundRequest &a,
|
||||
const CacheBackgroundRequest &b);
|
||||
|
||||
struct CacheBackgroundResult {
|
||||
QImage image;
|
||||
QImage gradient;
|
||||
QSize area;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
};
|
||||
|
||||
struct CachedBackground {
|
||||
CachedBackground() = default;
|
||||
CachedBackground(CacheBackgroundResult &&result);
|
||||
|
||||
QPixmap pixmap;
|
||||
QSize area;
|
||||
int x = 0;
|
||||
@@ -406,6 +441,7 @@ public:
|
||||
|
||||
[[nodiscard]] const BackgroundState &backgroundState(QSize area);
|
||||
[[nodiscard]] rpl::producer<> repaintBackgroundRequests() const;
|
||||
void rotateComplexGradientBackground();
|
||||
|
||||
rpl::lifetime &lifetime() {
|
||||
return _lifetime;
|
||||
@@ -437,8 +473,17 @@ private:
|
||||
void checkInvitePeek();
|
||||
|
||||
void cacheBackground();
|
||||
void cacheBackgroundNow();
|
||||
void cacheBackgroundAsync(
|
||||
const CacheBackgroundRequest &request,
|
||||
Fn<void(CacheBackgroundResult&&)> done = nullptr);
|
||||
void clearCachedBackground();
|
||||
void setCachedBackground(CachedBackground &&cached);
|
||||
void setCachedBackground(CacheBackgroundResult &&cached);
|
||||
[[nodiscard]] CacheBackgroundRequest currentCacheRequest(
|
||||
QSize area,
|
||||
int addRotation = 0) const;
|
||||
[[nodiscard]] bool readyForBackgroundRotation() const;
|
||||
void generateNextBackgroundRotation();
|
||||
|
||||
const not_null<Controller*> _window;
|
||||
|
||||
@@ -469,6 +514,9 @@ private:
|
||||
|
||||
BackgroundState _backgroundState;
|
||||
Ui::Animations::Simple _backgroundFade;
|
||||
CacheBackgroundRequest _backgroundCachingRequest;
|
||||
CacheBackgroundResult _backgroundNext;
|
||||
int _backgroundAddRotation = 0;
|
||||
QSize _willCacheForArea;
|
||||
crl::time _lastAreaChangeTime = 0;
|
||||
base::Timer _cacheBackgroundTimer;
|
||||
|
Reference in New Issue
Block a user