GCC Code Coverage Report


Directory: ./
File: src/client/blur.cpp
Date: 2024-01-22 17:25:27
Exec Total Coverage
Lines: 59 72 81.9%
Branches: 13 26 50.0%

Line Branch Exec Source
1 /********************************************************************
2 Copyright 2015 Martin Gräßlin <mgraesslin@kde.org>
3 Copyright 2015 Marco Martin <mart@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) version 3, or any
9 later version accepted by the membership of KDE e.V. (or its
10 successor approved by the membership of KDE e.V.), which shall
11 act as a proxy defined in Section 6 of version 3 of the license.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library. If not, see <http://www.gnu.org/licenses/>.
20 *********************************************************************/
21 #include "blur.h"
22 #include "event_queue.h"
23 #include "region.h"
24 #include "surface.h"
25 #include "wayland_pointer_p.h"
26
27 #include <wayland-blur-client-protocol.h>
28
29 namespace Wrapland
30 {
31
32 namespace Client
33 {
34
35 class Q_DECL_HIDDEN BlurManager::Private
36 {
37 public:
38 8 Private() = default;
39
40 WaylandPointer<org_kde_kwin_blur_manager, org_kde_kwin_blur_manager_destroy> manager;
41 4 EventQueue* queue = nullptr;
42 };
43
44 4 BlurManager::BlurManager(QObject* parent)
45 4 : QObject(parent)
46
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 , d(new Private)
47 4 {
48 4 }
49
50 8 BlurManager::~BlurManager()
51 8 {
52
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 release();
53 8 }
54
55 4 void BlurManager::release()
56 {
57 4 d->manager.release();
58 4 }
59
60 3 bool BlurManager::isValid() const
61 {
62 3 return d->manager.isValid();
63 }
64
65 4 void BlurManager::setup(org_kde_kwin_blur_manager* manager)
66 {
67
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 Q_ASSERT(manager);
68
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 Q_ASSERT(!d->manager);
69 4 d->manager.setup(manager);
70 4 }
71
72 4 void BlurManager::setEventQueue(EventQueue* queue)
73 {
74 4 d->queue = queue;
75 4 }
76
77 EventQueue* BlurManager::eventQueue()
78 {
79 return d->queue;
80 }
81
82 3 Blur* BlurManager::createBlur(Surface* surface, QObject* parent)
83 {
84
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 Q_ASSERT(isValid());
85
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 Blur* s = new Blur(parent);
86 3 auto w = org_kde_kwin_blur_manager_create(d->manager, *surface);
87
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if (d->queue) {
88 2 d->queue->addProxy(w);
89 2 }
90 3 s->setup(w);
91 3 return s;
92 }
93
94 void BlurManager::removeBlur(Surface* surface)
95 {
96 Q_ASSERT(isValid());
97 org_kde_kwin_blur_manager_unset(d->manager, *surface);
98 }
99
100 BlurManager::operator org_kde_kwin_blur_manager*()
101 {
102 return d->manager;
103 }
104
105 BlurManager::operator org_kde_kwin_blur_manager*() const
106 {
107 return d->manager;
108 }
109
110 class Blur::Private
111 {
112 public:
113 WaylandPointer<org_kde_kwin_blur, org_kde_kwin_blur_release> blur;
114 };
115
116 3 Blur::Blur(QObject* parent)
117 3 : QObject(parent)
118
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 , d(new Private)
119 3 {
120 3 }
121
122 6 Blur::~Blur()
123 6 {
124
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 release();
125 6 }
126
127 3 void Blur::release()
128 {
129 3 d->blur.release();
130 3 }
131
132 3 void Blur::setup(org_kde_kwin_blur* blur)
133 {
134
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 Q_ASSERT(blur);
135
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 Q_ASSERT(!d->blur);
136 3 d->blur.setup(blur);
137 3 }
138
139 2 bool Blur::isValid() const
140 {
141 2 return d->blur.isValid();
142 }
143
144 2 void Blur::commit()
145 {
146
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 Q_ASSERT(isValid());
147 2 org_kde_kwin_blur_commit(d->blur);
148 2 }
149
150 2 void Blur::setRegion(Region* region)
151 {
152 2 org_kde_kwin_blur_set_region(d->blur, *region);
153 2 }
154
155 Blur::operator org_kde_kwin_blur*()
156 {
157 return d->blur;
158 }
159
160 Blur::operator org_kde_kwin_blur*() const
161 {
162 return d->blur;
163 }
164
165 }
166 }
167