Changeset View
Changeset View
Standalone View
Standalone View
perf.h
- This file was moved from platformsupport/scenes/opengl/swap_profiler.h.
1 | /******************************************************************** | 1 | /******************************************************************** | ||
---|---|---|---|---|---|
2 | KWin - the KDE window manager | 2 | KWin - the KDE window manager | ||
3 | This file is part of the KDE project. | 3 | This file is part of the KDE project. | ||
4 | 4 | | |||
5 | Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org> | 5 | Copyright 2019 Roman Gilg <subdiff@gmail.com> | ||
6 | Copyright (C) 2009, 2010, 2011 Martin Gräßlin <mgraesslin@kde.org> | | |||
7 | 6 | | |||
8 | This program is free software; you can redistribute it and/or modify | 7 | This program is free software; you can redistribute it and/or modify | ||
9 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by | ||
10 | the Free Software Foundation; either version 2 of the License, or | 9 | the Free Software Foundation; either version 2 of the License, or | ||
11 | (at your option) any later version. | 10 | (at your option) any later version. | ||
12 | 11 | | |||
13 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, | ||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | GNU General Public License for more details. | 15 | GNU General Public License for more details. | ||
17 | 16 | | |||
18 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
19 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
20 | *********************************************************************/ | 19 | *********************************************************************/ | ||
21 | #ifndef KWIN_SCENE_OPENGL_SWAP_PROFILER_H | 20 | #pragma once | ||
22 | #define KWIN_SCENE_OPENGL_SWAP_PROFILER_H | | |||
23 | 21 | | |||
24 | #include <QElapsedTimer> | | |||
25 | #include <kwin_export.h> | 22 | #include <kwin_export.h> | ||
26 | 23 | | |||
24 | #include <QString> | ||||
25 | #include <QDebug> | ||||
26 | | ||||
27 | namespace KWin | 27 | namespace KWin | ||
28 | { | 28 | { | ||
29 | namespace Perf | ||||
30 | { | ||||
29 | 31 | | |||
30 | /** | 32 | /** | ||
31 | * @short Profiler to detect whether we have triple buffering | 33 | * Internal perf API for consumers | ||
32 | * The strategy is to start setBlocksForRetrace(false) but assume blocking and have the system prove that assumption wrong | | |||
33 | */ | 34 | */ | ||
34 | class KWIN_EXPORT SwapProfiler | 35 | class KWIN_EXPORT PerfInterface | ||
35 | { | 36 | { | ||
37 | | ||||
36 | public: | 38 | public: | ||
37 | SwapProfiler(); | 39 | static void ftrace(const QString &message); | ||
38 | void init(); | 40 | static void ftrace(ulong ctx, const QString &message); | ||
39 | void begin(); | 41 | static void ftrace(const QString &message, ulong ctx); | ||
40 | /** | | |||
41 | * @return char being 'd' for double, 't' for triple (or more - but non-blocking) buffering and | | |||
42 | * 0 (NOT '0') otherwise, so you can act on "if (char result = SwapProfiler::end()) { fooBar(); } | | |||
43 | */ | | |||
44 | char end(); | | |||
45 | private: | | |||
46 | QElapsedTimer m_timer; | | |||
47 | qint64 m_time; | | |||
48 | int m_counter; | | |||
49 | }; | 42 | }; | ||
50 | 43 | | |||
44 | inline | ||||
45 | void ftrace(const QString &message) | ||||
46 | { | ||||
47 | PerfInterface::ftrace(message); | ||||
48 | } | ||||
49 | | ||||
50 | inline | ||||
51 | void ftrace(ulong ctx, const QString &message) | ||||
52 | { | ||||
53 | PerfInterface::ftrace(ctx, message); | ||||
51 | } | 54 | } | ||
52 | 55 | | |||
53 | #endif | 56 | inline | ||
57 | void ftrace(const QString &message, ulong ctx) | ||||
58 | { | ||||
59 | PerfInterface::ftrace(message, ctx); | ||||
60 | } | ||||
61 | | ||||
62 | } | ||||
63 | } |