Fix controls fading in raster stories backend.

This commit is contained in:
John Preston 2023-06-09 18:48:32 +04:00
parent 0a54325db9
commit 43af9fd87e
3 changed files with 48 additions and 36 deletions

View File

@ -749,8 +749,8 @@ void OverlayWidget::RendererGL::invalidateControls() {
} }
void OverlayWidget::RendererGL::validateControlsFade() { void OverlayWidget::RendererGL::validateControlsFade() {
const auto flip = !_owner->topShadowOnTheRight();
const auto forStories = (_owner->_stories != nullptr); const auto forStories = (_owner->_stories != nullptr);
const auto flip = !forStories && !_owner->topShadowOnTheRight();
if (!_controlsFadeImage.image().isNull() if (!_controlsFadeImage.image().isNull()
&& _shadowTopFlip == flip && _shadowTopFlip == flip
&& _shadowsForStories == forStories) { && _shadowsForStories == forStories) {

View File

@ -76,7 +76,7 @@ void OverlayWidget::RendererSW::paintTransformedVideoFrame(
return; return;
} }
paintTransformedImage(_owner->videoFrame(), rect, rotation); paintTransformedImage(_owner->videoFrame(), rect, rotation);
paintControlsFade(rect, geometry.controlsOpacity, geometry.fade); paintControlsFade(rect, geometry);
} }
void OverlayWidget::RendererSW::paintTransformedStaticContent( void OverlayWidget::RendererSW::paintTransformedStaticContent(
@ -97,56 +97,71 @@ void OverlayWidget::RendererSW::paintTransformedStaticContent(
if (!image.isNull()) { if (!image.isNull()) {
paintTransformedImage(image, rect, rotation); paintTransformedImage(image, rect, rotation);
} }
paintControlsFade(rect, geometry.controlsOpacity, geometry.fade); paintControlsFade(rect, geometry);
} }
void OverlayWidget::RendererSW::paintControlsFade( void OverlayWidget::RendererSW::paintControlsFade(
QRect geometry, QRect content,
float64 opacity, const ContentGeometry &geometry) {
float64 fullFade) { auto opacity = geometry.controlsOpacity;
if (fullFade > 0.) { if (geometry.fade > 0.) {
_p->setOpacity(fullFade); _p->setOpacity(geometry.fade);
_p->fillRect(geometry, Qt::black); _p->fillRect(content, Qt::black);
opacity *= 1. - fullFade; opacity *= 1. - geometry.fade;
} }
_p->setOpacity(opacity); _p->setOpacity(opacity);
_p->setClipRect(geometry); _p->setClipRect(content);
const auto width = _owner->width(); const auto width = _owner->width();
const auto flip = !_owner->topShadowOnTheRight();
const auto stories = (_owner->_stories != nullptr); const auto stories = (_owner->_stories != nullptr);
const auto &top = stories if (!stories || geometry.topShadowShown) {
? st::storiesShadowTop const auto flip = !stories && !_owner->topShadowOnTheRight();
: st::mediaviewShadowTop; const auto &top = stories
const auto topShadow = stories ? st::storiesShadowTop
? QRect(geometry.topLeft(), QSize(geometry.width(), top.height())) : st::mediaviewShadowTop;
: QRect( const auto topShadow = stories
QPoint(flip ? 0 : (width - top.width()), 0), ? QRect(
top.size()); content.topLeft(),
if (topShadow.intersected(geometry).intersects(_clipOuter)) { QSize(content.width(), top.height()))
if (flip) { : QRect(
if (_topShadowCache.isNull() QPoint(flip ? 0 : (width - top.width()), 0),
|| _topShadowColor != st::windowShadowFg->c) { top.size());
_topShadowColor = st::windowShadowFg->c; if (topShadow.intersected(content).intersects(_clipOuter)) {
_topShadowCache = top.instance( if (stories) {
_topShadowColor).mirrored(true, false); top.fill(*_p, topShadow);
} else if (flip) {
if (_topShadowCache.isNull()
|| _topShadowColor != st::windowShadowFg->c) {
_topShadowColor = st::windowShadowFg->c;
_topShadowCache = top.instance(
_topShadowColor).mirrored(true, false);
}
_p->drawImage(0, 0, _topShadowCache);
} else {
top.paint(*_p, topShadow.topLeft(), width);
} }
_p->drawImage(0, 0, _topShadowCache);
} else {
top.paint(*_p, topShadow.topLeft(), width);
} }
} }
const auto &bottom = stories const auto &bottom = stories
? st::storiesShadowBottom ? st::storiesShadowBottom
: st::mediaviewShadowBottom; : st::mediaviewShadowBottom;
const auto bottomStart = _owner->height() - geometry.bottomShadowSkip;
const auto bottomShadow = QRect( const auto bottomShadow = QRect(
QPoint(0, _owner->height() - bottom.height()), QPoint(0, bottomStart - bottom.height()),
QSize(width, bottom.height())); QSize(width, bottom.height()));
if (bottomShadow.intersected(geometry).intersects(_clipOuter)) { if (bottomShadow.intersected(content).intersects(_clipOuter)) {
bottom.fill(*_p, bottomShadow); bottom.fill(*_p, bottomShadow);
} }
_p->setClipping(false); _p->setClipping(false);
_p->setOpacity(1.); _p->setOpacity(1.);
if (bottomStart < content.y() + content.height()) {
_p->fillRect(
content.x(),
bottomStart,
content.width(),
content.y() + content.height() - bottomStart,
QColor(0, 0, 0, 88));
}
} }
void OverlayWidget::RendererSW::paintTransformedImage( void OverlayWidget::RendererSW::paintTransformedImage(

View File

@ -33,10 +33,7 @@ private:
const QImage &image, const QImage &image,
QRect rect, QRect rect,
int rotation); int rotation);
void paintControlsFade( void paintControlsFade(QRect content, const ContentGeometry &geometry);
QRect geometry,
float64 opacity,
float64 fullFade);
void paintRadialLoading( void paintRadialLoading(
QRect inner, QRect inner,
bool radial, bool radial,