[vlc-commits] [Git][videolan/vlc][master] 5 commits: qt: add ViewBlockingRectangle
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Thu Jul 14 04:24:36 UTC 2022
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
73808f53 by Fatih Uzunoglu at 2022-07-14T04:01:17+00:00
qt: add ViewBlockingRectangle
- - - - -
46bfa790 by Fatih Uzunoglu at 2022-07-14T04:01:17+00:00
qt: register ViewBlockingRectangle
- - - - -
414f6e3f by Fatih Uzunoglu at 2022-07-14T04:01:17+00:00
qml: disable layering in AcrylicBackground
- - - - -
1b6c319b by Fatih Uzunoglu at 2022-07-14T04:01:17+00:00
qml: disable layering in PIPPlayer
- - - - -
14392b22 by Fatih Uzunoglu at 2022-07-14T04:01:17+00:00
qt: derive VideoSurface from ViewBlockingRectangle
- - - - -
8 changed files:
- modules/gui/qt/Makefile.am
- modules/gui/qt/maininterface/mainui.cpp
- modules/gui/qt/maininterface/videosurface.cpp
- modules/gui/qt/maininterface/videosurface.hpp
- modules/gui/qt/player/qml/PIPPlayer.qml
- + modules/gui/qt/widgets/native/viewblockingrectangle.cpp
- + modules/gui/qt/widgets/native/viewblockingrectangle.hpp
- modules/gui/qt/widgets/qml/AcrylicBackground.qml
Changes:
=====================================
modules/gui/qt/Makefile.am
=====================================
@@ -295,7 +295,8 @@ libqt_plugin_la_SOURCES = \
gui/qt/widgets/native/qvlcframe.cpp \
gui/qt/widgets/native/qvlcframe.hpp \
gui/qt/widgets/native/roundimage.cpp gui/qt/widgets/native/roundimage.hpp \
- gui/qt/widgets/native/searchlineedit.cpp gui/qt/widgets/native/searchlineedit.hpp
+ gui/qt/widgets/native/searchlineedit.cpp gui/qt/widgets/native/searchlineedit.hpp \
+ gui/qt/widgets/native/viewblockingrectangle.cpp gui/qt/widgets/native/viewblockingrectangle.hpp
if HAVE_WIN32
libqt_plugin_la_SOURCES += \
gui/qt/maininterface/mainctx_win32.cpp \
@@ -464,7 +465,8 @@ nodist_libqt_plugin_la_SOURCES = \
gui/qt/widgets/native/navigation_attached.moc.cpp \
gui/qt/widgets/native/mlfolderseditor.moc.cpp \
gui/qt/widgets/native/roundimage.moc.cpp \
- gui/qt/widgets/native/searchlineedit.moc.cpp
+ gui/qt/widgets/native/searchlineedit.moc.cpp \
+ gui/qt/widgets/native/viewblockingrectangle.moc.cpp
if HAVE_WIN32
nodist_libqt_plugin_la_SOURCES += gui/qt/maininterface/mainctx_win32.moc.cpp \
=====================================
modules/gui/qt/maininterface/mainui.cpp
=====================================
@@ -56,6 +56,7 @@
#include "widgets/native/roundimage.hpp"
#include "widgets/native/navigation_attached.hpp"
+#include "widgets/native/viewblockingrectangle.hpp"
#include "videosurface.hpp"
@@ -293,6 +294,7 @@ void MainUI::registerQMLTypes()
qmlRegisterUncreatableType<NavigationAttached>( uri, versionMajor, versionMinor, "Navigation", "Navigation is only available via attached properties");
+ qmlRegisterType<ViewBlockingRectangle>( uri, versionMajor, versionMinor, "ViewBlockingRectangle" );
qmlProtectModule(uri, versionMajor);
}
=====================================
modules/gui/qt/maininterface/videosurface.cpp
=====================================
@@ -125,7 +125,7 @@ void VideoSurfaceProvider::onSurfaceSizeChanged(QSizeF size)
VideoSurface::VideoSurface(QQuickItem* parent)
- : QQuickItem(parent)
+ : ViewBlockingRectangle(parent)
{
setAcceptHoverEvents(true);
setAcceptedMouseButtons(Qt::AllButtons);
@@ -249,16 +249,9 @@ void VideoSurface::setCursorShape(Qt::CursorShape shape)
setCursor(shape);
}
-QSGNode*VideoSurface::updatePaintNode(QSGNode* oldNode, QQuickItem::UpdatePaintNodeData*)
+QSGNode*VideoSurface::updatePaintNode(QSGNode* oldNode, QQuickItem::UpdatePaintNodeData* data)
{
- QSGRectangleNode* node = static_cast<QSGRectangleNode*>(oldNode);
-
- if (!node)
- {
- node = this->window()->createRectangleNode();
- node->setColor(Qt::transparent);
- }
- node->setRect(this->boundingRect());
+ const auto node = ViewBlockingRectangle::updatePaintNode(oldNode, data);
if (m_provider == nullptr)
{
=====================================
modules/gui/qt/maininterface/videosurface.hpp
=====================================
@@ -18,7 +18,7 @@
#ifndef VIDEOSURFACE_HPP
#define VIDEOSURFACE_HPP
-#include <QtQuick/QQuickItem>
+#include "widgets/native/viewblockingrectangle.hpp"
#include <QMutex>
#include "qt.hpp"
#include "vlc_window.h"
@@ -62,7 +62,7 @@ protected:
};
-class VideoSurface : public QQuickItem
+class VideoSurface : public ViewBlockingRectangle
{
Q_OBJECT
Q_PROPERTY(MainCtx* ctx READ getCtx WRITE setCtx NOTIFY ctxChanged FINAL)
=====================================
modules/gui/qt/player/qml/PIPPlayer.qml
=====================================
@@ -58,13 +58,6 @@ Item {
visible: root.visible
ctx: MainCtx
-
- //punch a transparent hole in the interface
- layer.enabled: true
- layer.effect: ShaderEffect {
- blending: false
- fragmentShader: "void main() { gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); }"
- }
}
MouseArea {
=====================================
modules/gui/qt/widgets/native/viewblockingrectangle.cpp
=====================================
@@ -0,0 +1,67 @@
+/*****************************************************************************
+ * Copyright (C) 2022 VLC authors and VideoLAN
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * ( at your option ) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#include "viewblockingrectangle.hpp"
+
+#include <QSGRectangleNode>
+#include <QQuickWindow>
+#include <QSGMaterial>
+
+ViewBlockingRectangle::ViewBlockingRectangle(QQuickItem *parent)
+ : QQuickItem(parent)
+ , m_color(Qt::transparent)
+{
+ setFlag(QQuickItem::ItemHasContents);
+ connect(this, &ViewBlockingRectangle::colorChanged, this, &QQuickItem::update);
+}
+
+QSGNode *ViewBlockingRectangle::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
+{
+ auto node = static_cast<QSGRectangleNode*>(oldNode);
+
+ const auto rect = boundingRect();
+
+ const auto disableBlending = [&node]() {
+ assert(node->material());
+ // Software backend check: (Qt bug)
+ if (node->material() != reinterpret_cast<QSGMaterial*>(1))
+ node->material()->setFlag(QSGMaterial::Blending, false);
+ };
+
+ if (!node)
+ {
+ assert(window());
+ node = window()->createRectangleNode();
+ assert(node);
+
+ disableBlending();
+ }
+
+ // Geometry:
+ if (node->rect() != rect)
+ node->setRect(rect);
+
+ // Material:
+ if (node->color() != m_color)
+ {
+ node->setColor(m_color);
+ disableBlending();
+ }
+
+ return node;
+}
=====================================
modules/gui/qt/widgets/native/viewblockingrectangle.hpp
=====================================
@@ -0,0 +1,44 @@
+/*****************************************************************************
+ * Copyright (C) 2022 VLC authors and VideoLAN
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * ( at your option ) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifndef VIEWBLOCKINGRECTANGLE_HPP
+#define VIEWBLOCKINGRECTANGLE_HPP
+
+#include <QQuickItem>
+#include <QColor>
+
+class ViewBlockingRectangle : public QQuickItem
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QColor color MEMBER m_color NOTIFY colorChanged FINAL)
+
+public:
+ ViewBlockingRectangle(QQuickItem *parent = nullptr);
+
+protected:
+ QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override;
+
+private:
+ QColor m_color;
+
+signals:
+ void colorChanged();
+};
+
+#endif
=====================================
modules/gui/qt/widgets/qml/AcrylicBackground.qml
=====================================
@@ -24,8 +24,8 @@ import org.videolan.vlc 0.1
import "qrc:///style/"
-// This Component uses layering, avoid adding children to this widget
-Item {
+
+ViewBlockingRectangle {
id: root
readonly property bool usingAcrylic: visible && enabled && AcrylicController.enabled
@@ -36,14 +36,5 @@ Item {
property real _blend: usingAcrylic ? AcrylicController.uiTransluency : 0
- layer.enabled: true
- layer.effect: ShaderEffect {
- property color overlay: VLCStyle.colors.blendColors(root.tintColor, root.alternativeColor, root._blend)
-
- blending: false
- fragmentShader: "
- uniform lowp vec4 overlay;
- void main() { gl_FragColor = overlay; }
- "
- }
+ color: VLCStyle.colors.blendColors(root.tintColor, root.alternativeColor, root._blend)
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5213b04f6a3ef2892ae4b61f1ac7a0b2197a5099...14392b2250a84a80d6def1c450c3a03b20cd993d
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5213b04f6a3ef2892ae4b61f1ac7a0b2197a5099...14392b2250a84a80d6def1c450c3a03b20cd993d
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list