@@ -0,0 +1,69 @@
1+/*
2+ * Copyright (C) 2016 - Canonical Ltd.
3+ *
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
7+ * of the License.
8+ *
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.
14+ *
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/>
17+ */
18+
19+#include "DebuggingController.h"
20+
21+#include <QGuiApplication>
22+#include <QWindow>
23+#include <private/qquickwindow_p.h>
24+#include <private/qabstractanimationjob_p.h>
25+#include <private/qquickitem_p.h>
26+#include <private/qsgrenderer_p.h>
27+
28+DebuggingController::DebuggingController(QObject *parent):
29+ UnityDBusObject(QStringLiteral("/com/canonical/Unity8/Debugging"), QStringLiteral("com.canonical.Unity8"), true, parent)
30+{
31+}
32+
33+void DebuggingController::SetSceneGraphVisualizer(const QString &visualizer)
34+{
35+ Q_FOREACH (QWindow *window, QGuiApplication::allWindows()) {
36+ QQuickWindow* qquickWindow = qobject_cast<QQuickWindow*>(window);
37+ if (qquickWindow) {
38+ QQuickWindowPrivate *winPriv = QQuickWindowPrivate::get(qquickWindow);
39+ winPriv->customRenderMode = visualizer.toLatin1();
40+ qquickWindow->update();
41+
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.
47+
48+ QQuickItemPrivate *contentPriv = QQuickItemPrivate::get(qquickWindow->contentItem());
49+ QSGNode *rootNode = contentPriv->itemNode();
50+ while (rootNode->parent())
51+ rootNode = rootNode->parent();
52+
53+ delete winPriv->renderer;
54+ winPriv->renderer = winPriv->context->createRenderer();
55+ winPriv->renderer->setRootNode(static_cast<QSGRootNode *>(rootNode));
56+#endif
57+ }
58+ }
59+}
60+
61+void DebuggingController::SetSlowAnimations(bool slowAnimations)
62+{
63+ QUnifiedTimer::instance()->setSlowModeEnabled(slowAnimations);
64+}
65+
66+void DebuggingController::SetLoggingFilterRules(const QString &filterRules)
67+{
68+ QLoggingCategory::setFilterRules(filterRules);
69+}