2 * Copyright (C) 2016 - Canonical Ltd.
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License, as
6 * published by the Free Software Foundation; either version 2.1 or 3.0
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranties of
11 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
12 * PURPOSE. See the applicable version of the GNU Lesser General Public
13 * License for more details.
15 * You should have received a copy of both the GNU Lesser General Public
16 * License along with this program. If not, see <http://www.gnu.org/licenses/>
19#include "DebuggingController.h"
21#include <QGuiApplication>
23#include <private/qquickwindow_p.h>
24#include <private/qabstractanimationjob_p.h>
25#include <private/qquickitem_p.h>
26#include <private/qsgrenderer_p.h>
28DebuggingController::DebuggingController(QObject *parent):
29 UnityDBusObject(QStringLiteral("/com/canonical/Unity8/Debugging"), QStringLiteral("com.canonical.Unity8"), true, parent)
33void DebuggingController::SetSceneGraphVisualizer(const QString &visualizer)
35 Q_FOREACH (QWindow *window, QGuiApplication::allWindows()) {
36 QQuickWindow* qquickWindow = qobject_cast<QQuickWindow*>(window);
39#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
40 // Qt does some performance optimizations that break custom render modes.
41 // Thus the optimizations are only applied if there is no custom render mode set.
42 // So we need to make the scenegraph recheck whether a custom render mode is set.
43 // We do this by simply recreating the renderer.
44 QMutexLocker lock(&m_renderModeMutex);
45 m_pendingRenderMode = visualizer;
46 connect(qquickWindow, &QQuickWindow::beforeSynchronizing, this, &DebuggingController::applyRenderMode, Qt::DirectConnection);
48 QQuickWindowPrivate *winPriv = QQuickWindowPrivate::get(qquickWindow);
49 winPriv->customRenderMode = visualizer.toLatin1();
51 qquickWindow->update();
56void DebuggingController::applyRenderMode() {
57 qDebug() << "applyRenderMode called" << sender();
58 QQuickWindow *qquickWindow = dynamic_cast<QQuickWindow*>(sender());
59 qDebug() << "window is" << qquickWindow << sender() << sender()->metaObject()->className();
61 QMutexLocker lock(&m_renderModeMutex);
62 disconnect(qquickWindow, &QQuickWindow::beforeSynchronizing, this, &DebuggingController::applyRenderMode);
64 qDebug() << "mutex locked";
65#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
66 QQuickWindowPrivate *winPriv = QQuickWindowPrivate::get(qquickWindow);
67 QQuickItemPrivate *contentPriv = QQuickItemPrivate::get(qquickWindow->contentItem());
68 qDebug() << "winPriv is" << winPriv << "contentPriv is" << contentPriv;
69 QSGNode *rootNode = contentPriv->itemNode();
70 while (rootNode->parent())
71 rootNode = rootNode->parent();
73 qDebug() << "rootnode is" << rootNode;
74 winPriv->customRenderMode = m_pendingRenderMode.toLatin1();
75 delete winPriv->renderer;
76 qDebug() << "renderer deleted";
77 winPriv->renderer = winPriv->context->createRenderer();
78 qDebug() << "new renderer created";
79 winPriv->renderer->setRootNode(static_cast<QSGRootNode *>(rootNode));
80 qDebug() << "setting back old rootNode. done";
84void DebuggingController::SetSlowAnimations(bool slowAnimations)
86 QUnifiedTimer::instance()->setSlowModeEnabled(slowAnimations);
89void DebuggingController::SetLoggingFilterRules(const QString &filterRules)
91 QLoggingCategory::setFilterRules(filterRules);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list