Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 全屏播放时存在裁剪圆角 #433

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/backends/mediaplayer/qtplayer_glwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,15 +376,20 @@ namespace dmr {

#ifdef _LIBDMR_
if(utils::check_wayland_env()){
m_bDoRoundedClipping = false;
toggleRoundedClip(true);
}else{
m_bDoRoundedClipping = true;
toggleRoundedClip(false);
}
#else
#ifndef USE_DXCB
connect(window()->windowHandle(), &QWindow::windowStateChanged, [=]() {
QWidget* pTopWid = this->topLevelWidget();
bool rounded = !pTopWid->isFullScreen() && !pTopWid->isMaximized();
// 全屏和最大化下不裁剪圆角
m_bDoRoundedClipping = rounded;

if(utils::check_wayland_env()){
toggleRoundedClip(true);
} else {
Expand All @@ -397,7 +402,7 @@ namespace dmr {

void QtPlayerGLWidget::updateMovieFbo()
{
if (!m_bDoRoundedClipping) return;
if (!m_bUseCustomFBO) return;

auto desiredSize = size() * qApp->devicePixelRatio();

Expand All @@ -413,7 +418,7 @@ namespace dmr {

void QtPlayerGLWidget::updateCornerMasks()
{
if (!utils::check_wayland_env() && !m_bDoRoundedClipping) return;
if (!utils::check_wayland_env() && !m_bUseCustomFBO) return;

for (int i = 0; i < 4; i++) {
QSize sz(RADIUS, RADIUS);
Expand Down Expand Up @@ -616,7 +621,7 @@ namespace dmr {
updateMovieFbo();
updateVbo();
updateVboBlend();
if (m_bDoRoundedClipping){
if (m_bUseCustomFBO){
updateVboCorners();
}
qInfo() << "GL resize" << nWidth << nHeight;
Expand All @@ -625,7 +630,9 @@ namespace dmr {

void QtPlayerGLWidget::toggleRoundedClip(bool bFalse)
{
m_bDoRoundedClipping = bFalse;
// 设置圆角时使用自定的FBO,但在全屏和最大化时,通过
// m_bDoRoundedClipping 设置是否实际应用圆角
m_bUseCustomFBO = bFalse;
makeCurrent();
updateMovieFbo();
update();
Expand All @@ -636,7 +643,8 @@ namespace dmr {
m_bPlaying = false;
m_bInMiniMode= false;

m_bDoRoundedClipping=true;
m_bUseCustomFBO = true;
m_bDoRoundedClipping = true;
m_pDarkTex = nullptr;
m_pLightTex = nullptr;
m_pGlProg = nullptr;
Expand Down
3 changes: 2 additions & 1 deletion src/backends/mediaplayer/qtplayer_glwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class QtPlayerGLWidget : public QOpenGLWidget

bool m_bPlaying; //记录播放状态
bool m_bInMiniMode; //是否是最小化
bool m_bDoRoundedClipping; //
bool m_bUseCustomFBO; // 使用自定的 QOpenGLFramebufferObject 进行绘制
bool m_bDoRoundedClipping; // 裁剪圆角

QOpenGLVertexArrayObject m_vao; //顶点数组对象
QOpenGLBuffer m_vbo; //顶点缓冲对象
Expand Down
20 changes: 14 additions & 6 deletions src/backends/mpv/mpv_glwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,15 +463,20 @@ namespace dmr {

#ifdef _LIBDMR_
if(utils::check_wayland_env()){
m_bDoRoundedClipping = true;
toggleRoundedClip(true);
}else{
m_bDoRoundedClipping = false;
toggleRoundedClip(false);
}
#else
#ifndef USE_DXCB
connect(window()->windowHandle(), &QWindow::windowStateChanged, [=]() {
QWidget* pTopWid = this->topLevelWidget();
bool rounded = !pTopWid->isFullScreen() && !pTopWid->isMaximized();
// 全屏和最大化下不裁剪圆角
m_bDoRoundedClipping = rounded;

//wayland
if(utils::check_wayland_env()) {
rounded = true;
Expand Down Expand Up @@ -519,7 +524,7 @@ namespace dmr {

void MpvGLWidget::updateMovieFbo()
{
if (!m_bDoRoundedClipping) return;
if (!m_bUseCustomFBO) return;

auto desiredSize = size() * qApp->devicePixelRatio();

Expand All @@ -535,7 +540,7 @@ namespace dmr {

void MpvGLWidget::updateCornerMasks()
{
if (!utils::check_wayland_env() && !m_bDoRoundedClipping) return;
if (!utils::check_wayland_env() && !m_bUseCustomFBO) return;

for (int i = 0; i < 4; i++) {
QSize sz(RADIUS, RADIUS);
Expand Down Expand Up @@ -717,7 +722,7 @@ namespace dmr {

updateMovieFbo();
updateVbo();
if (m_bDoRoundedClipping){
if (m_bUseCustomFBO){
updateVboCorners();
}
qInfo() << "GL resize" << nWidth << nHeight;
Expand All @@ -726,7 +731,9 @@ namespace dmr {

void MpvGLWidget::toggleRoundedClip(bool bFalse)
{
m_bDoRoundedClipping = bFalse;
// 设置圆角时使用自定的FBO,但在全屏和最大化时,通过
// m_bDoRoundedClipping 设置是否实际应用圆角
m_bUseCustomFBO = bFalse;
makeCurrent();
updateMovieFbo();
update();
Expand All @@ -739,7 +746,8 @@ namespace dmr {
m_bPlaying = false;
m_bInMiniMode= false;

m_bDoRoundedClipping=true;
m_bUseCustomFBO = true;
m_bDoRoundedClipping = true;
m_pDarkTex = nullptr;
m_pLightTex = nullptr;
m_pGlProg = nullptr;
Expand Down Expand Up @@ -776,7 +784,7 @@ namespace dmr {
QSize scaled = size() * dpr;
int nFlip = 1;

if (!m_bDoRoundedClipping) {
if (!m_bUseCustomFBO) {
mpv_opengl_fbo fbo {
static_cast<int>(defaultFramebufferObject()), scaled.width(), scaled.height(), 0
};
Expand Down
3 changes: 2 additions & 1 deletion src/backends/mpv/mpv_glwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ protected slots:

bool m_bPlaying; //记录播放状态
bool m_bInMiniMode; //是否是最小化
bool m_bDoRoundedClipping; //
bool m_bUseCustomFBO; // 使用自定的 QOpenGLFramebufferObject 进行绘制
bool m_bDoRoundedClipping; // 裁剪圆角

QOpenGLVertexArrayObject m_vao; //顶点数组对象
QOpenGLBuffer m_vbo; //顶点缓冲对象
Expand Down
Loading