Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_opengl_canvas_debugger.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2015 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
8
9#include <QGlobalStatic>
10
11#include <QElapsedTimer>
12#include <QDebug>
13
14#include "kis_config.h"
15#include <kis_config_notifier.h>
16
18{
19
21 : fpsCounter(0),
22 fpsSum(0),
25 isEnabled(true) {}
26
27 QElapsedTimer time;
28
30 int fpsSum;
31
34
36};
37
39
41 : m_d(new Private)
42{
43 connect(KisConfigNotifier::instance(), SIGNAL(configChanged()), SLOT(slotConfigChanged()));
44 slotConfigChanged();
45}
46
50
53{
54 return s_instance;
55}
56
58{
59 return m_d->isEnabled;
60}
61
63{
64 qreal value = 0;
65
66 if (m_d->fpsSum > 0) {
67 value = qreal(m_d->fpsCounter) / m_d->fpsSum * 1000.0;
68 }
69
70 return value;
71}
72
74{
75 KisConfig cfg(true);
76 m_d->isEnabled = cfg.enableOpenGLFramerateLogging();
77
78 if (m_d->isEnabled) {
79 m_d->time.start();
80 }
81}
82
84{
85 if (!m_d->isEnabled) return;
86
87 m_d->fpsSum += m_d->time.restart();
88 m_d->fpsCounter++;
89
90 if (m_d->fpsCounter > 100 && m_d->fpsSum > 0) {
91 qDebug() << "Requested FPS:" << qreal(m_d->fpsCounter) / m_d->fpsSum * 1000.0;
92 m_d->fpsSum = 0;
93 m_d->fpsCounter = 0;
94 }
95}
96
98{
99 if (!m_d->isEnabled) return;
100
101 m_d->syncFlaggedSum += isBusy;
102 m_d->syncFlaggedCounter++;
103
104 if (m_d->syncFlaggedCounter > 500 && m_d->syncFlaggedSum > 0) {
105 qDebug() << "glSync effectiveness:" << qreal(m_d->syncFlaggedSum) / m_d->syncFlaggedCounter;
106 m_d->syncFlaggedSum = 0;
107 m_d->syncFlaggedCounter = 0;
108 }
109}
float value(const T *src, size_t ch)
Q_GLOBAL_STATIC(KisStoragePluginRegistry, s_instance)
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
static KisConfigNotifier * instance()
bool enableOpenGLFramerateLogging(bool defaultValue=false) const
static KisOpenglCanvasDebugger * instance()
const QScopedPointer< Private > m_d