@@ -0,0 +1,69 @@
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>
28+DebuggingController::DebuggingController(QObject *parent):
29+ UnityDBusObject(QStringLiteral("/com/canonical/Unity8/Debugging"), QStringLiteral("com.canonical.Unity8"), true, parent)
33+void DebuggingController::SetSceneGraphVisualizer(const QString &visualizer)
35+ Q_FOREACH (QWindow *window, QGuiApplication::allWindows()) {
36+ QQuickWindow* qquickWindow = qobject_cast<QQuickWindow*>(window);
38+ QQuickWindowPrivate *winPriv = QQuickWindowPrivate::get(qquickWindow);
39+ winPriv->customRenderMode = visualizer.toLatin1();
40+ qquickWindow->update();
42+#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
43+ // Qt does some performance optimizations that break custom render modes.
44+ // Thus the optimizations are only applied if there is no custom render mode set.
45+ // So we need to make the scenegraph recheck whether a custom render mode is set.
46+ // We do this by simply recreating the renderer.
48+ QQuickItemPrivate *contentPriv = QQuickItemPrivate::get(qquickWindow->contentItem());
49+ QSGNode *rootNode = contentPriv->itemNode();
50+ while (rootNode->parent())
51+ rootNode = rootNode->parent();
53+ delete winPriv->renderer;
54+ winPriv->renderer = winPriv->context->createRenderer();
55+ winPriv->renderer->setRootNode(static_cast<QSGRootNode *>(rootNode));
61+void DebuggingController::SetSlowAnimations(bool slowAnimations)
63+ QUnifiedTimer::instance()->setSlowModeEnabled(slowAnimations);
66+void DebuggingController::SetLoggingFilterRules(const QString &filterRules)
68+ QLoggingCategory::setFilterRules(filterRules);