mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Optimize ttl media overlay a bit.
This commit is contained in:
parent
93a734eecf
commit
06775b5623
2 changed files with 28 additions and 39 deletions
|
@ -113,10 +113,7 @@ private:
|
||||||
rpl::variable<QRect> _elementInner;
|
rpl::variable<QRect> _elementInner;
|
||||||
rpl::lifetime _elementLifetime;
|
rpl::lifetime _elementLifetime;
|
||||||
|
|
||||||
struct {
|
QImage _lastFrameCache;
|
||||||
QImage frame;
|
|
||||||
bool use = false;
|
|
||||||
} _last;
|
|
||||||
|
|
||||||
rpl::event_stream<> _closeRequests;
|
rpl::event_stream<> _closeRequests;
|
||||||
|
|
||||||
|
@ -138,6 +135,14 @@ PreviewWrap::PreviewWrap(
|
||||||
std::move(chatWideValue),
|
std::move(chatWideValue),
|
||||||
[=] { update(_elementGeometry); }))
|
[=] { update(_elementGeometry); }))
|
||||||
, _globalViewport(std::move(viewportValue)) {
|
, _globalViewport(std::move(viewportValue)) {
|
||||||
|
const auto closeCallback = [=] { _closeRequests.fire({}); };
|
||||||
|
HistoryView::TTLVoiceStops(
|
||||||
|
item->fullId()
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
_lastFrameCache = Ui::GrabWidgetToImage(this, _elementGeometry);
|
||||||
|
closeCallback();
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
const auto isRound = _item
|
const auto isRound = _item
|
||||||
&& _item->media()
|
&& _item->media()
|
||||||
&& _item->media()->document()
|
&& _item->media()->document()
|
||||||
|
@ -158,8 +163,6 @@ PreviewWrap::PreviewWrap(
|
||||||
}
|
}
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
const auto closeCallback = [=] { _closeRequests.fire({}); };
|
|
||||||
|
|
||||||
{
|
{
|
||||||
const auto close = Ui::CreateChild<Ui::RoundButton>(
|
const auto close = Ui::CreateChild<Ui::RoundButton>(
|
||||||
this,
|
this,
|
||||||
|
@ -252,13 +255,6 @@ PreviewWrap::PreviewWrap(
|
||||||
});
|
});
|
||||||
}, tooltip->lifetime());
|
}, tooltip->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
HistoryView::TTLVoiceStops(
|
|
||||||
item->fullId()
|
|
||||||
) | rpl::start_with_next([=] {
|
|
||||||
_last.use = true;
|
|
||||||
closeCallback();
|
|
||||||
}, lifetime());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<> PreviewWrap::closeRequests() const {
|
rpl::producer<> PreviewWrap::closeRequests() const {
|
||||||
|
@ -275,31 +271,19 @@ void PreviewWrap::paintEvent(QPaintEvent *e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto p = QPainter(this);
|
auto p = Painter(this);
|
||||||
//p.fillRect(_viewport, QColor(255, 0, 0, 64));
|
|
||||||
//p.fillRect(_elementGeometry, QColor(0, 255, 0, 64));
|
|
||||||
//p.fillRect(_elementInner.current(), QColor(0, 0, 255, 64));
|
|
||||||
if (!_last.use) {
|
|
||||||
const auto size = _element->currentSize();
|
|
||||||
auto result = QImage(
|
|
||||||
size * style::DevicePixelRatio(),
|
|
||||||
QImage::Format_ARGB32_Premultiplied);
|
|
||||||
result.fill(Qt::transparent);
|
|
||||||
result.setDevicePixelRatio(style::DevicePixelRatio());
|
|
||||||
{
|
|
||||||
auto q = Painter(&result);
|
|
||||||
auto context = _theme->preparePaintContext(
|
|
||||||
_style.get(),
|
|
||||||
Rect(size),
|
|
||||||
Rect(size),
|
|
||||||
!window()->isActiveWindow());
|
|
||||||
context.outbg = _element->hasOutLayout();
|
|
||||||
_element->draw(q, context);
|
|
||||||
}
|
|
||||||
_last.frame = std::move(result);
|
|
||||||
}
|
|
||||||
p.translate(_elementGeometry.topLeft());
|
p.translate(_elementGeometry.topLeft());
|
||||||
p.drawImage(0, 0, _last.frame);
|
if (!_lastFrameCache.isNull()) {
|
||||||
|
p.drawImage(0, 0, _lastFrameCache);
|
||||||
|
} else {
|
||||||
|
auto context = _theme->preparePaintContext(
|
||||||
|
_style.get(),
|
||||||
|
Rect(_element->currentSize()),
|
||||||
|
Rect(_element->currentSize()),
|
||||||
|
!window()->isActiveWindow());
|
||||||
|
context.outbg = _element->hasOutLayout();
|
||||||
|
_element->draw(p, context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<QRect> GlobalViewportForWindow(
|
rpl::producer<QRect> GlobalViewportForWindow(
|
||||||
|
|
|
@ -71,8 +71,13 @@ constexpr auto kAudioVoiceMsgUpdateView = crl::time(100);
|
||||||
st::historyFileInPause.width(),
|
st::historyFileInPause.width(),
|
||||||
st::historyFileInPause.height()));
|
st::historyFileInPause.height()));
|
||||||
const auto state = lifetime->make_state<State>();
|
const auto state = lifetime->make_state<State>();
|
||||||
state->start = Lottie::MakeIcon({
|
//state->start = Lottie::MakeIcon({
|
||||||
.name = u"voice_ttl_start"_q,
|
// .name = u"voice_ttl_start"_q,
|
||||||
|
// .color = &st::historyFileInIconFg,
|
||||||
|
// .sizeOverride = iconSize,
|
||||||
|
//});
|
||||||
|
state->idle = Lottie::MakeIcon({
|
||||||
|
.name = u"voice_ttl_idle"_q,
|
||||||
.color = &st::historyFileInIconFg,
|
.color = &st::historyFileInIconFg,
|
||||||
.sizeOverride = iconSize,
|
.sizeOverride = iconSize,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue