Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-Studio-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2021 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 : #include "paintdebugger.h"
23 :
24 : using namespace mu;
25 : using namespace muse;
26 : using namespace muse::draw;
27 : using namespace mu::engraving;
28 : using namespace mu::engraving::rendering::score;
29 :
30 0 : PaintDebugger::PaintDebugger(IPaintProviderPtr real)
31 0 : : m_real(real)
32 : {
33 0 : }
34 :
35 0 : IPaintProviderPtr PaintDebugger::realProvider() const
36 : {
37 0 : return m_real;
38 : }
39 :
40 0 : void PaintDebugger::setDebugPenColor(const Color& c)
41 : {
42 0 : m_debugPenColor = c;
43 0 : const Pen& originalPen = pen();
44 0 : m_originalPenColor = originalPen.color();
45 0 : Pen p = originalPen;
46 0 : p.setColor(c);
47 0 : setPen(p);
48 0 : }
49 :
50 0 : void PaintDebugger::restorePenColor()
51 : {
52 0 : Pen p = pen();
53 0 : p.setColor(m_originalPenColor);
54 0 : setPen(p);
55 0 : m_debugPenColor = Color();
56 0 : }
57 :
58 0 : void PaintDebugger::beginTarget(const std::string& name)
59 : {
60 0 : m_real->beginTarget(name);
61 0 : }
62 :
63 0 : void PaintDebugger::beforeEndTargetHook(Painter* p)
64 : {
65 0 : m_real->beforeEndTargetHook(p);
66 0 : }
67 :
68 0 : bool PaintDebugger::endTarget(bool endDraw)
69 : {
70 0 : return m_real->endTarget(endDraw);
71 : }
72 :
73 0 : bool PaintDebugger::isActive() const
74 : {
75 0 : return m_real->isActive();
76 : }
77 :
78 0 : void PaintDebugger::beginObject(const std::string& name)
79 : {
80 0 : m_real->beginObject(name);
81 0 : }
82 :
83 0 : void PaintDebugger::endObject()
84 : {
85 0 : m_real->endObject();
86 0 : }
87 :
88 0 : void PaintDebugger::setAntialiasing(bool arg)
89 : {
90 0 : m_real->setAntialiasing(arg);
91 0 : }
92 :
93 0 : void PaintDebugger::setCompositionMode(CompositionMode mode)
94 : {
95 0 : m_real->setCompositionMode(mode);
96 0 : }
97 :
98 0 : void PaintDebugger::setWindow(const RectF& window)
99 : {
100 0 : m_real->setWindow(window);
101 0 : }
102 :
103 0 : void PaintDebugger::setViewport(const RectF& viewport)
104 : {
105 0 : m_real->setViewport(viewport);
106 0 : }
107 :
108 0 : void PaintDebugger::setFont(const Font& f)
109 : {
110 0 : m_real->setFont(f);
111 0 : }
112 :
113 0 : const Font& PaintDebugger::font() const
114 : {
115 0 : return m_real->font();
116 : }
117 :
118 0 : void PaintDebugger::setPen(const Pen& pen)
119 : {
120 0 : Pen p = pen;
121 0 : if (m_debugPenColor.isValid()) {
122 0 : p.setColor(m_debugPenColor);
123 : }
124 0 : m_real->setPen(p);
125 0 : }
126 :
127 0 : void PaintDebugger::setNoPen()
128 : {
129 0 : m_real->setNoPen();
130 0 : }
131 :
132 0 : const Pen& PaintDebugger::pen() const
133 : {
134 0 : return m_real->pen();
135 : }
136 :
137 0 : void PaintDebugger::setBrush(const Brush& brush)
138 : {
139 0 : m_real->setBrush(brush);
140 0 : }
141 :
142 0 : const Brush& PaintDebugger::brush() const
143 : {
144 0 : return m_real->brush();
145 : }
146 :
147 0 : void PaintDebugger::save()
148 : {
149 0 : m_real->save();
150 0 : }
151 :
152 0 : void PaintDebugger::restore()
153 : {
154 0 : m_real->restore();
155 0 : }
156 :
157 0 : void PaintDebugger::setTransform(const Transform& transform)
158 : {
159 0 : m_real->setTransform(transform);
160 0 : }
161 :
162 0 : const Transform& PaintDebugger::transform() const
163 : {
164 0 : return m_real->transform();
165 : }
166 :
167 : // drawing functions
168 :
169 0 : void PaintDebugger::drawPath(const PainterPath& path)
170 : {
171 0 : m_real->drawPath(path);
172 0 : }
173 :
174 0 : void PaintDebugger::drawPolygon(const PointF* points, size_t pointCount, PolygonMode mode)
175 : {
176 0 : m_real->drawPolygon(points, pointCount, mode);
177 0 : }
178 :
179 0 : void PaintDebugger::drawText(const PointF& point, const String& text)
180 : {
181 0 : m_real->drawText(point, text);
182 0 : }
183 :
184 0 : void PaintDebugger::drawText(const RectF& rect, Alignment alignment, TextFlags textFlags, const String& text)
185 : {
186 0 : m_real->drawText(rect, alignment, textFlags, text);
187 0 : }
188 :
189 0 : void PaintDebugger::drawSymbol(const PointF& point, char32_t ucs4Code)
190 : {
191 0 : m_real->drawSymbol(point, ucs4Code);
192 0 : }
193 :
194 0 : void PaintDebugger::drawPixmap(const PointF& p, const Pixmap& pm)
195 : {
196 0 : m_real->drawPixmap(p, pm);
197 0 : }
198 :
199 0 : void PaintDebugger::drawTiledPixmap(const RectF& rect, const Pixmap& pm, const PointF& offset)
200 : {
201 0 : m_real->drawTiledPixmap(rect, pm, offset);
202 0 : }
203 :
204 : #ifndef NO_QT_SUPPORT
205 0 : void PaintDebugger::drawPixmap(const PointF& point, const QPixmap& pm)
206 : {
207 0 : m_real->drawPixmap(point, pm);
208 0 : }
209 :
210 0 : void PaintDebugger::drawTiledPixmap(const RectF& rect, const QPixmap& pm, const PointF& offset)
211 : {
212 0 : m_real->drawTiledPixmap(rect, pm, offset);
213 0 : }
214 :
215 : #endif
216 :
217 0 : bool PaintDebugger::hasClipping() const
218 : {
219 0 : return m_real->hasClipping();
220 : }
221 :
222 0 : void PaintDebugger::setClipRect(const RectF& rect)
223 : {
224 0 : m_real->setClipRect(rect);
225 0 : }
226 :
227 0 : void PaintDebugger::setMask(const RectF& background, const std::vector<RectF>& maskRects)
228 : {
229 0 : m_real->setMask(background, maskRects);
230 0 : }
231 :
232 0 : void PaintDebugger::setClipping(bool enable)
233 : {
234 0 : m_real->setClipping(enable);
235 0 : }
236 :
237 0 : double mu::engraving::rendering::score::PaintDebugger::deviceLogicalDpi() const
238 : {
239 0 : return m_real->deviceLogicalDpi();
240 : }
|