Apply rounding to stories.
This commit is contained in:
parent
bab66c4ff6
commit
a0e9e148b0
5 changed files with 34 additions and 16 deletions
|
@ -406,6 +406,7 @@ pipVolumeIcon2Over: icon {{ "player/player_volume_on", mediaviewPipControlsFgOve
|
||||||
speedSliderDividerSize: size(2px, 8px);
|
speedSliderDividerSize: size(2px, 8px);
|
||||||
|
|
||||||
storiesMaxSize: size(405px, 720px);
|
storiesMaxSize: size(405px, 720px);
|
||||||
|
storiesRadius: 8px;
|
||||||
storiesControlSize: 64px;
|
storiesControlSize: 64px;
|
||||||
storiesLeft: icon {{ "mediaview/stories_next-flip_horizontal", mediaviewControlFg }};
|
storiesLeft: icon {{ "mediaview/stories_next-flip_horizontal", mediaviewControlFg }};
|
||||||
storiesRight: icon {{ "mediaview/stories_next", mediaviewControlFg }};
|
storiesRight: icon {{ "mediaview/stories_next", mediaviewControlFg }};
|
||||||
|
|
|
@ -94,7 +94,7 @@ float roundedCorner() {
|
||||||
}
|
}
|
||||||
)",
|
)",
|
||||||
.body = R"(
|
.body = R"(
|
||||||
result = vec4(roundedCorner());
|
result *= roundedCorner();
|
||||||
)",
|
)",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,8 @@ void OverlayWidget::RendererGL::init(
|
||||||
_texturedVertexShader,
|
_texturedVertexShader,
|
||||||
FragmentShader({
|
FragmentShader({
|
||||||
FragmentSampleARGB32Texture(),
|
FragmentSampleARGB32Texture(),
|
||||||
FragmentApplyControlsFade()
|
FragmentApplyControlsFade(),
|
||||||
|
FragmentRoundedCorners()
|
||||||
}));
|
}));
|
||||||
|
|
||||||
_withTransparencyProgram.emplace();
|
_withTransparencyProgram.emplace();
|
||||||
|
@ -179,7 +180,8 @@ void OverlayWidget::RendererGL::init(
|
||||||
_texturedVertexShader,
|
_texturedVertexShader,
|
||||||
FragmentShader({
|
FragmentShader({
|
||||||
FragmentSampleYUV420Texture(),
|
FragmentSampleYUV420Texture(),
|
||||||
FragmentApplyControlsFade()
|
FragmentApplyControlsFade(),
|
||||||
|
FragmentRoundedCorners()
|
||||||
}));
|
}));
|
||||||
|
|
||||||
_nv12Program.emplace();
|
_nv12Program.emplace();
|
||||||
|
@ -188,7 +190,8 @@ void OverlayWidget::RendererGL::init(
|
||||||
_texturedVertexShader,
|
_texturedVertexShader,
|
||||||
FragmentShader({
|
FragmentShader({
|
||||||
FragmentSampleNV12Texture(),
|
FragmentSampleNV12Texture(),
|
||||||
FragmentApplyControlsFade()
|
FragmentApplyControlsFade(),
|
||||||
|
FragmentRoundedCorners()
|
||||||
}));
|
}));
|
||||||
|
|
||||||
_fillProgram.emplace();
|
_fillProgram.emplace();
|
||||||
|
@ -210,7 +213,10 @@ void OverlayWidget::RendererGL::init(
|
||||||
LinkProgram(
|
LinkProgram(
|
||||||
&*_roundedCornersProgram,
|
&*_roundedCornersProgram,
|
||||||
VertexShader({ VertexViewportTransform() }),
|
VertexShader({ VertexViewportTransform() }),
|
||||||
FragmentShader({ FragmentRoundedCorners() }));
|
FragmentShader({
|
||||||
|
{ .body = "result = vec4(1.);" },
|
||||||
|
FragmentRoundedCorners(),
|
||||||
|
}));
|
||||||
|
|
||||||
const auto renderer = reinterpret_cast<const char*>(
|
const auto renderer = reinterpret_cast<const char*>(
|
||||||
f.glGetString(GL_RENDERER));
|
f.glGetString(GL_RENDERER));
|
||||||
|
@ -369,8 +375,8 @@ void OverlayWidget::RendererGL::paintTransformedVideoFrame(
|
||||||
}
|
}
|
||||||
program->setUniformValue("f_texture", GLint(nv12 ? 2 : 3));
|
program->setUniformValue("f_texture", GLint(nv12 ? 2 : 3));
|
||||||
|
|
||||||
toggleBlending(false);
|
toggleBlending(geometry.roundRadius > 0.);
|
||||||
paintTransformedContent(program, geometry);
|
paintTransformedContent(program, geometry, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverlayWidget::RendererGL::paintTransformedStaticContent(
|
void OverlayWidget::RendererGL::paintTransformedStaticContent(
|
||||||
|
@ -440,13 +446,15 @@ void OverlayWidget::RendererGL::paintTransformedStaticContent(
|
||||||
program->setUniformValue("s_texture", GLint(0));
|
program->setUniformValue("s_texture", GLint(0));
|
||||||
program->setUniformValue("f_texture", GLint(1));
|
program->setUniformValue("f_texture", GLint(1));
|
||||||
|
|
||||||
toggleBlending(semiTransparent && !fillTransparentBackground);
|
toggleBlending((geometry.roundRadius > 0.)
|
||||||
paintTransformedContent(&*program, geometry);
|
|| (semiTransparent && !fillTransparentBackground));
|
||||||
|
paintTransformedContent(&*program, geometry, fillTransparentBackground);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverlayWidget::RendererGL::paintTransformedContent(
|
void OverlayWidget::RendererGL::paintTransformedContent(
|
||||||
not_null<QOpenGLShaderProgram*> program,
|
not_null<QOpenGLShaderProgram*> program,
|
||||||
ContentGeometry geometry) {
|
ContentGeometry geometry,
|
||||||
|
bool fillTransparentBackground) {
|
||||||
const auto rect = transformRect(geometry.rect);
|
const auto rect = transformRect(geometry.rect);
|
||||||
const auto centerx = rect.x() + rect.width() / 2;
|
const auto centerx = rect.x() + rect.width() / 2;
|
||||||
const auto centery = rect.y() + rect.height() / 2;
|
const auto centery = rect.y() + rect.height() / 2;
|
||||||
|
@ -493,7 +501,12 @@ void OverlayWidget::RendererGL::paintTransformedContent(
|
||||||
bottom.height() * _factor,
|
bottom.height() * _factor,
|
||||||
geometry.controlsOpacity,
|
geometry.controlsOpacity,
|
||||||
1.f - float(geometry.fade)));
|
1.f - float(geometry.fade)));
|
||||||
|
if (!fillTransparentBackground) {
|
||||||
|
program->setUniformValue("roundRect", Uniform(rect));
|
||||||
|
program->setUniformValue(
|
||||||
|
"roundRadius",
|
||||||
|
GLfloat(geometry.roundRadius * _factor));
|
||||||
|
}
|
||||||
FillTexturedRectangle(*_f, &*program);
|
FillTexturedRectangle(*_f, &*program);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,8 @@ private:
|
||||||
bool fillTransparentBackground) override;
|
bool fillTransparentBackground) override;
|
||||||
void paintTransformedContent(
|
void paintTransformedContent(
|
||||||
not_null<QOpenGLShaderProgram*> program,
|
not_null<QOpenGLShaderProgram*> program,
|
||||||
ContentGeometry geometry);
|
ContentGeometry geometry,
|
||||||
|
bool fillTransparentBackground);
|
||||||
void paintRadialLoading(
|
void paintRadialLoading(
|
||||||
QRect inner,
|
QRect inner,
|
||||||
bool radial,
|
bool radial,
|
||||||
|
|
|
@ -1493,6 +1493,7 @@ QRect OverlayWidget::finalContentRect() const {
|
||||||
|
|
||||||
OverlayWidget::ContentGeometry OverlayWidget::contentGeometry() const {
|
OverlayWidget::ContentGeometry OverlayWidget::contentGeometry() const {
|
||||||
const auto fade = _stories ? _stories->contentFade() : 0.;
|
const auto fade = _stories ? _stories->contentFade() : 0.;
|
||||||
|
const auto radius = _stories ? float64(st::storiesRadius) : 0.;
|
||||||
const auto controlsOpacity = _controlsOpacity.current();
|
const auto controlsOpacity = _controlsOpacity.current();
|
||||||
const auto toRotation = qreal(finalContentRotation());
|
const auto toRotation = qreal(finalContentRotation());
|
||||||
const auto toRectRotated = QRectF(finalContentRect());
|
const auto toRectRotated = QRectF(finalContentRect());
|
||||||
|
@ -1505,7 +1506,7 @@ OverlayWidget::ContentGeometry OverlayWidget::contentGeometry() const {
|
||||||
toRectRotated.width())
|
toRectRotated.width())
|
||||||
: toRectRotated;
|
: toRectRotated;
|
||||||
if (!_geometryAnimation.animating()) {
|
if (!_geometryAnimation.animating()) {
|
||||||
return { toRect, toRotation, controlsOpacity, fade };
|
return { toRect, toRotation, controlsOpacity, fade, radius };
|
||||||
}
|
}
|
||||||
const auto fromRect = _oldGeometry.rect;
|
const auto fromRect = _oldGeometry.rect;
|
||||||
const auto fromRotation = _oldGeometry.rotation;
|
const auto fromRotation = _oldGeometry.rotation;
|
||||||
|
@ -1528,7 +1529,7 @@ OverlayWidget::ContentGeometry OverlayWidget::contentGeometry() const {
|
||||||
fromRect.width() + (toRect.width() - fromRect.width()) * progress,
|
fromRect.width() + (toRect.width() - fromRect.width()) * progress,
|
||||||
fromRect.height() + (toRect.height() - fromRect.height()) * progress
|
fromRect.height() + (toRect.height() - fromRect.height()) * progress
|
||||||
);
|
);
|
||||||
return { useRect, useRotation, controlsOpacity, fade };
|
return { useRect, useRotation, controlsOpacity, fade, radius };
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverlayWidget::updateContentRect() {
|
void OverlayWidget::updateContentRect() {
|
||||||
|
@ -4164,17 +4165,18 @@ void OverlayWidget::paint(not_null<Renderer*> renderer) {
|
||||||
}
|
}
|
||||||
paintRadialLoading(renderer);
|
paintRadialLoading(renderer);
|
||||||
if (_stories) {
|
if (_stories) {
|
||||||
|
const auto radius = float64(st::storiesRadius);
|
||||||
if (const auto left = _stories->siblingLeft()) {
|
if (const auto left = _stories->siblingLeft()) {
|
||||||
renderer->paintTransformedStaticContent(
|
renderer->paintTransformedStaticContent(
|
||||||
left.image,
|
left.image,
|
||||||
{ .rect = left.geometry },
|
{ .rect = left.geometry, .roundRadius = radius },
|
||||||
false, // semi-transparent
|
false, // semi-transparent
|
||||||
false); // fill transparent background
|
false); // fill transparent background
|
||||||
}
|
}
|
||||||
if (const auto right = _stories->siblingRight()) {
|
if (const auto right = _stories->siblingRight()) {
|
||||||
renderer->paintTransformedStaticContent(
|
renderer->paintTransformedStaticContent(
|
||||||
right.image,
|
right.image,
|
||||||
{ .rect = right.geometry },
|
{ .rect = right.geometry, .roundRadius = radius },
|
||||||
false, // semi-transparent
|
false, // semi-transparent
|
||||||
false); // fill transparent background
|
false); // fill transparent background
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,6 +166,7 @@ private:
|
||||||
qreal rotation = 0.;
|
qreal rotation = 0.;
|
||||||
qreal controlsOpacity = 0.;
|
qreal controlsOpacity = 0.;
|
||||||
qreal fade = 0.;
|
qreal fade = 0.;
|
||||||
|
qreal roundRadius = 0.;
|
||||||
};
|
};
|
||||||
struct StartStreaming {
|
struct StartStreaming {
|
||||||
StartStreaming() : continueStreaming(false), startTime(0) {
|
StartStreaming() : continueStreaming(false), startTime(0) {
|
||||||
|
|
Loading…
Reference in a new issue