Apply rounding to stories.

This commit is contained in:
John Preston 2023-05-10 23:32:32 +04:00
parent bab66c4ff6
commit a0e9e148b0
5 changed files with 34 additions and 16 deletions

View File

@ -406,6 +406,7 @@ pipVolumeIcon2Over: icon {{ "player/player_volume_on", mediaviewPipControlsFgOve
speedSliderDividerSize: size(2px, 8px);
storiesMaxSize: size(405px, 720px);
storiesRadius: 8px;
storiesControlSize: 64px;
storiesLeft: icon {{ "mediaview/stories_next-flip_horizontal", mediaviewControlFg }};
storiesRight: icon {{ "mediaview/stories_next", mediaviewControlFg }};

View File

@ -94,7 +94,7 @@ float roundedCorner() {
}
)",
.body = R"(
result = vec4(roundedCorner());
result *= roundedCorner();
)",
};
}
@ -160,7 +160,8 @@ void OverlayWidget::RendererGL::init(
_texturedVertexShader,
FragmentShader({
FragmentSampleARGB32Texture(),
FragmentApplyControlsFade()
FragmentApplyControlsFade(),
FragmentRoundedCorners()
}));
_withTransparencyProgram.emplace();
@ -179,7 +180,8 @@ void OverlayWidget::RendererGL::init(
_texturedVertexShader,
FragmentShader({
FragmentSampleYUV420Texture(),
FragmentApplyControlsFade()
FragmentApplyControlsFade(),
FragmentRoundedCorners()
}));
_nv12Program.emplace();
@ -188,7 +190,8 @@ void OverlayWidget::RendererGL::init(
_texturedVertexShader,
FragmentShader({
FragmentSampleNV12Texture(),
FragmentApplyControlsFade()
FragmentApplyControlsFade(),
FragmentRoundedCorners()
}));
_fillProgram.emplace();
@ -210,7 +213,10 @@ void OverlayWidget::RendererGL::init(
LinkProgram(
&*_roundedCornersProgram,
VertexShader({ VertexViewportTransform() }),
FragmentShader({ FragmentRoundedCorners() }));
FragmentShader({
{ .body = "result = vec4(1.);" },
FragmentRoundedCorners(),
}));
const auto renderer = reinterpret_cast<const char*>(
f.glGetString(GL_RENDERER));
@ -369,8 +375,8 @@ void OverlayWidget::RendererGL::paintTransformedVideoFrame(
}
program->setUniformValue("f_texture", GLint(nv12 ? 2 : 3));
toggleBlending(false);
paintTransformedContent(program, geometry);
toggleBlending(geometry.roundRadius > 0.);
paintTransformedContent(program, geometry, false);
}
void OverlayWidget::RendererGL::paintTransformedStaticContent(
@ -440,13 +446,15 @@ void OverlayWidget::RendererGL::paintTransformedStaticContent(
program->setUniformValue("s_texture", GLint(0));
program->setUniformValue("f_texture", GLint(1));
toggleBlending(semiTransparent && !fillTransparentBackground);
paintTransformedContent(&*program, geometry);
toggleBlending((geometry.roundRadius > 0.)
|| (semiTransparent && !fillTransparentBackground));
paintTransformedContent(&*program, geometry, fillTransparentBackground);
}
void OverlayWidget::RendererGL::paintTransformedContent(
not_null<QOpenGLShaderProgram*> program,
ContentGeometry geometry) {
ContentGeometry geometry,
bool fillTransparentBackground) {
const auto rect = transformRect(geometry.rect);
const auto centerx = rect.x() + rect.width() / 2;
const auto centery = rect.y() + rect.height() / 2;
@ -493,7 +501,12 @@ void OverlayWidget::RendererGL::paintTransformedContent(
bottom.height() * _factor,
geometry.controlsOpacity,
1.f - float(geometry.fade)));
if (!fillTransparentBackground) {
program->setUniformValue("roundRect", Uniform(rect));
program->setUniformValue(
"roundRadius",
GLfloat(geometry.roundRadius * _factor));
}
FillTexturedRectangle(*_f, &*program);
}

View File

@ -51,7 +51,8 @@ private:
bool fillTransparentBackground) override;
void paintTransformedContent(
not_null<QOpenGLShaderProgram*> program,
ContentGeometry geometry);
ContentGeometry geometry,
bool fillTransparentBackground);
void paintRadialLoading(
QRect inner,
bool radial,

View File

@ -1493,6 +1493,7 @@ QRect OverlayWidget::finalContentRect() const {
OverlayWidget::ContentGeometry OverlayWidget::contentGeometry() const {
const auto fade = _stories ? _stories->contentFade() : 0.;
const auto radius = _stories ? float64(st::storiesRadius) : 0.;
const auto controlsOpacity = _controlsOpacity.current();
const auto toRotation = qreal(finalContentRotation());
const auto toRectRotated = QRectF(finalContentRect());
@ -1505,7 +1506,7 @@ OverlayWidget::ContentGeometry OverlayWidget::contentGeometry() const {
toRectRotated.width())
: toRectRotated;
if (!_geometryAnimation.animating()) {
return { toRect, toRotation, controlsOpacity, fade };
return { toRect, toRotation, controlsOpacity, fade, radius };
}
const auto fromRect = _oldGeometry.rect;
const auto fromRotation = _oldGeometry.rotation;
@ -1528,7 +1529,7 @@ OverlayWidget::ContentGeometry OverlayWidget::contentGeometry() const {
fromRect.width() + (toRect.width() - fromRect.width()) * progress,
fromRect.height() + (toRect.height() - fromRect.height()) * progress
);
return { useRect, useRotation, controlsOpacity, fade };
return { useRect, useRotation, controlsOpacity, fade, radius };
}
void OverlayWidget::updateContentRect() {
@ -4164,17 +4165,18 @@ void OverlayWidget::paint(not_null<Renderer*> renderer) {
}
paintRadialLoading(renderer);
if (_stories) {
const auto radius = float64(st::storiesRadius);
if (const auto left = _stories->siblingLeft()) {
renderer->paintTransformedStaticContent(
left.image,
{ .rect = left.geometry },
{ .rect = left.geometry, .roundRadius = radius },
false, // semi-transparent
false); // fill transparent background
}
if (const auto right = _stories->siblingRight()) {
renderer->paintTransformedStaticContent(
right.image,
{ .rect = right.geometry },
{ .rect = right.geometry, .roundRadius = radius },
false, // semi-transparent
false); // fill transparent background
}

View File

@ -166,6 +166,7 @@ private:
qreal rotation = 0.;
qreal controlsOpacity = 0.;
qreal fade = 0.;
qreal roundRadius = 0.;
};
struct StartStreaming {
StartStreaming() : continueStreaming(false), startTime(0) {