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

QTBUG47714 Workaround #113

Merged
merged 1 commit into from
Sep 6, 2015
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/qml/timeline/Clip.qml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ Rectangle {

Canvas {
id: transitionCanvas
Component.onCompleted: view.applyQTBUG47714Workaround(transitionCanvas);
visible: isTransition
anchors.fill: parent
onPaint: {
Expand All @@ -162,6 +163,7 @@ Rectangle {

Canvas {
id: waveform
Component.onCompleted: view.applyQTBUG47714Workaround(waveform);
visible: !isBlank && settings.timelineShowWaveforms
height: isAudio? parent.height : parent.height / 2
anchors.left: parent.left
Expand Down Expand Up @@ -302,6 +304,7 @@ Rectangle {

Canvas {
id: fadeInCanvas
Component.onCompleted: view.applyQTBUG47714Workaround(fadeInCanvas);
visible: !isBlank && !isTransition
width: parent.fadeIn * timeScale
height: parent.height - parent.border.width * 2
Expand Down Expand Up @@ -398,6 +401,7 @@ Rectangle {

Canvas {
id: fadeOutCanvas
Component.onCompleted: view.applyQTBUG47714Workaround(fadeOutCanvas);
visible: !isBlank && !isTransition
width: parent.fadeOut * timeScale
height: parent.height - parent.border.width * 2
Expand Down
1 change: 1 addition & 0 deletions src/qml/timeline/timeline.qml
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ Rectangle {
}
Canvas {
id: playhead
Component.onCompleted: view.applyQTBUG47714Workaround(playhead);
visible: timeline.position > -1
x: timeline.position * multitrack.scaleFactor - scrollView.flickableItem.contentX - 5
y: 0
Expand Down
78 changes: 78 additions & 0 deletions src/qmltypes/qmlview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
#include "qmlview.h"
#include <QQuickView>
#include <QDebug>
#include <QSGMaterial>
#include <QSGSimpleTextureNode>

#include <QTimer>

#include <private/qquickitem_p.h>
#include <private/qsgrenderer_p.h>
#include <private/qquickcanvasitem_p.h>

QmlView::QmlView(QQuickView* qview)
: QObject(qview)
Expand All @@ -30,3 +38,73 @@ QPoint QmlView::pos()
{
return m_qview->mapToGlobal(QPoint(0,0));
}

class QTBUG47714WorkaroundRenderListener : public QObject
{
public:
QTBUG47714WorkaroundRenderListener(QQuickItem * item)
: item(item)
, oldTexture(0)
{
startTimer(0);
}

void timerEvent(QTimerEvent * event)
{
if (item) {
QQuickWindow * window = item->window();
connect(window, &QQuickWindow::beforeSynchronizing,
this, &QTBUG47714WorkaroundRenderListener::beforeSync);
connect(window, &QQuickWindow::afterSynchronizing,
this, &QTBUG47714WorkaroundRenderListener::afterSync);
}
killTimer(event->timerId());
}

QSGSimpleTextureNode * nodeFromItem()
{
if (item.isNull())
{
deleteLater();
return 0;
}
QQuickItemPrivate * priv = QQuickItemPrivate::get(item);
QSGTransformNode * tnode = priv->itemNode();
QSGGeometryNode * geom = 0;
if (tnode->firstChild()->type() == QSGNode::GeometryNodeType)
geom = static_cast<QSGGeometryNode*>(tnode->firstChild());
else if (tnode->firstChild()->type() == QSGNode::OpacityNodeType
&& tnode->firstChild()->firstChild()
&& tnode->firstChild()->firstChild()->type() == QSGNode::GeometryNodeType)
geom = static_cast<QSGGeometryNode*>(tnode->firstChild()->firstChild());

return dynamic_cast<QSGSimpleTextureNode*>(geom);
}


void beforeSync()
{
QSGSimpleTextureNode * texNode = nodeFromItem();
if (texNode)
texNode->setOwnsTexture(false);
}

void afterSync()
{
QSGSimpleTextureNode * texNode = nodeFromItem();
if (texNode) {
oldTexture = texNode->texture();
} else {
delete oldTexture;
oldTexture = 0;
}
}

QPointer<QQuickItem> item;
QSGTexture * oldTexture;
};

void QmlView::applyQTBUG47714Workaround(QObject * item)
{
new QTBUG47714WorkaroundRenderListener(static_cast<QQuickItem*>(item));
}
1 change: 1 addition & 0 deletions src/qmltypes/qmlview.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class QmlView : public QObject
public:
explicit QmlView(QQuickView* qview);
QPoint pos();
Q_INVOKABLE void applyQTBUG47714Workaround(QObject * item);

private:
QQuickView* m_qview;
Expand Down
1 change: 1 addition & 0 deletions src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ CONFIG += link_prl

QT += widgets opengl xml network printsupport qml quick sql webkitwidgets
QT += multimedia
QT += qml-private core-private quick-private gui-private

TARGET = shotcut
TEMPLATE = app
Expand Down