Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/scenegraph/adaptations/software/qsgsoftwarepainternode.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | - | |||||||
2 | - | |||||||
3 | - | |||||||
4 | QSGSoftwarePainterNode::QSGSoftwarePainterNode(QQuickPaintedItem *item) | - | ||||||
5 | : QSGPainterNode() | - | ||||||
6 | , m_preferredRenderTarget(QQuickPaintedItem::Image) | - | ||||||
7 | , m_item(item) | - | ||||||
8 | , m_texture(nullptr) | - | ||||||
9 | , m_dirtyContents(false) | - | ||||||
10 | , m_opaquePainting(false) | - | ||||||
11 | , m_linear_filtering(false) | - | ||||||
12 | , m_mipmapping(false) | - | ||||||
13 | , m_smoothPainting(false) | - | ||||||
14 | , m_fastFBOResizing(false) | - | ||||||
15 | , m_fillColor(Qt::transparent) | - | ||||||
16 | , m_contentsScale(1.0) | - | ||||||
17 | , m_dirtyGeometry(false) | - | ||||||
18 | { | - | ||||||
19 | setMaterial((QSGMaterial*)1); | - | ||||||
20 | setGeometry((QSGGeometry*)1); | - | ||||||
21 | } never executed: end of block | 0 | ||||||
22 | - | |||||||
23 | QSGSoftwarePainterNode::~QSGSoftwarePainterNode() | - | ||||||
24 | { | - | ||||||
25 | delete m_texture; | - | ||||||
26 | } never executed: end of block | 0 | ||||||
27 | - | |||||||
28 | void QSGSoftwarePainterNode::setPreferredRenderTarget(QQuickPaintedItem::RenderTarget target) | - | ||||||
29 | { | - | ||||||
30 | if (m_preferredRenderTarget == target
| 0 | ||||||
31 | return; never executed: return; | 0 | ||||||
32 | - | |||||||
33 | m_preferredRenderTarget = target; | - | ||||||
34 | } never executed: end of block | 0 | ||||||
35 | - | |||||||
36 | void QSGSoftwarePainterNode::setSize(const QSize &size) | - | ||||||
37 | { | - | ||||||
38 | if (size == m_size
| 0 | ||||||
39 | return; never executed: return; | 0 | ||||||
40 | - | |||||||
41 | m_size = size; | - | ||||||
42 | - | |||||||
43 | m_dirtyGeometry = true; | - | ||||||
44 | } never executed: end of block | 0 | ||||||
45 | - | |||||||
46 | void QSGSoftwarePainterNode::setDirty(const QRect &dirtyRect) | - | ||||||
47 | { | - | ||||||
48 | m_dirtyContents = true; | - | ||||||
49 | m_dirtyRect = dirtyRect; | - | ||||||
50 | markDirty(DirtyMaterial); | - | ||||||
51 | } never executed: end of block | 0 | ||||||
52 | - | |||||||
53 | void QSGSoftwarePainterNode::setOpaquePainting(bool opaque) | - | ||||||
54 | { | - | ||||||
55 | if (opaque == m_opaquePainting
| 0 | ||||||
56 | return; never executed: return; | 0 | ||||||
57 | - | |||||||
58 | m_opaquePainting = opaque; | - | ||||||
59 | } never executed: end of block | 0 | ||||||
60 | - | |||||||
61 | void QSGSoftwarePainterNode::setLinearFiltering(bool linearFiltering) | - | ||||||
62 | { | - | ||||||
63 | if (linearFiltering == m_linear_filtering
| 0 | ||||||
64 | return; never executed: return; | 0 | ||||||
65 | - | |||||||
66 | m_linear_filtering = linearFiltering; | - | ||||||
67 | } never executed: end of block | 0 | ||||||
68 | - | |||||||
69 | void QSGSoftwarePainterNode::setMipmapping(bool mipmapping) | - | ||||||
70 | { | - | ||||||
71 | if (mipmapping == m_mipmapping
| 0 | ||||||
72 | return; never executed: return; | 0 | ||||||
73 | - | |||||||
74 | m_mipmapping = mipmapping; | - | ||||||
75 | } never executed: end of block | 0 | ||||||
76 | - | |||||||
77 | void QSGSoftwarePainterNode::setSmoothPainting(bool s) | - | ||||||
78 | { | - | ||||||
79 | if (s == m_smoothPainting
| 0 | ||||||
80 | return; never executed: return; | 0 | ||||||
81 | - | |||||||
82 | m_smoothPainting = s; | - | ||||||
83 | } never executed: end of block | 0 | ||||||
84 | - | |||||||
85 | void QSGSoftwarePainterNode::setFillColor(const QColor &c) | - | ||||||
86 | { | - | ||||||
87 | if (c == m_fillColor
| 0 | ||||||
88 | return; never executed: return; | 0 | ||||||
89 | - | |||||||
90 | m_fillColor = c; | - | ||||||
91 | markDirty(DirtyMaterial); | - | ||||||
92 | } never executed: end of block | 0 | ||||||
93 | - | |||||||
94 | void QSGSoftwarePainterNode::setContentsScale(qreal s) | - | ||||||
95 | { | - | ||||||
96 | if (s == m_contentsScale
| 0 | ||||||
97 | return; never executed: return; | 0 | ||||||
98 | - | |||||||
99 | m_contentsScale = s; | - | ||||||
100 | markDirty(DirtyMaterial); | - | ||||||
101 | } never executed: end of block | 0 | ||||||
102 | - | |||||||
103 | void QSGSoftwarePainterNode::setFastFBOResizing(bool dynamic) | - | ||||||
104 | { | - | ||||||
105 | m_fastFBOResizing = dynamic; | - | ||||||
106 | } never executed: end of block | 0 | ||||||
107 | - | |||||||
108 | QImage QSGSoftwarePainterNode::toImage() const | - | ||||||
109 | { | - | ||||||
110 | return never executed: m_pixmap.toImage();return m_pixmap.toImage(); never executed: return m_pixmap.toImage(); | 0 | ||||||
111 | } | - | ||||||
112 | - | |||||||
113 | void QSGSoftwarePainterNode::update() | - | ||||||
114 | { | - | ||||||
115 | if (m_dirtyGeometry
| 0 | ||||||
116 | m_pixmap = QPixmap(m_textureSize); | - | ||||||
117 | if (!m_opaquePainting
| 0 | ||||||
118 | m_pixmap.fill(Qt::transparent); never executed: m_pixmap.fill(Qt::transparent); | 0 | ||||||
119 | - | |||||||
120 | if (m_texture
| 0 | ||||||
121 | delete m_texture; never executed: delete m_texture; | 0 | ||||||
122 | m_texture = new QSGSoftwarePixmapTexture(m_pixmap); | - | ||||||
123 | } never executed: end of block | 0 | ||||||
124 | - | |||||||
125 | if (m_dirtyContents
| 0 | ||||||
126 | paint(); never executed: paint(); | 0 | ||||||
127 | - | |||||||
128 | m_dirtyGeometry = false; | - | ||||||
129 | m_dirtyContents = false; | - | ||||||
130 | } never executed: end of block | 0 | ||||||
131 | - | |||||||
132 | void QSGSoftwarePainterNode::paint(QPainter *painter) | - | ||||||
133 | { | - | ||||||
134 | painter->drawPixmap(0, 0, m_size.width(), m_size.height(), m_pixmap); | - | ||||||
135 | } never executed: end of block | 0 | ||||||
136 | - | |||||||
137 | void QSGSoftwarePainterNode::paint() | - | ||||||
138 | { | - | ||||||
139 | QRect dirtyRect = m_dirtyRect.isNull()
| 0 | ||||||
140 | - | |||||||
141 | QPainter painter; | - | ||||||
142 | - | |||||||
143 | painter.begin(&m_pixmap); | - | ||||||
144 | if (m_smoothPainting
| 0 | ||||||
145 | painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform); | - | ||||||
146 | } never executed: end of block | 0 | ||||||
147 | - | |||||||
148 | QRect clipRect; | - | ||||||
149 | - | |||||||
150 | if (m_contentsScale == 1
| 0 | ||||||
151 | qreal scaleX = m_textureSize.width() / (qreal) m_size.width(); | - | ||||||
152 | qreal scaleY = m_textureSize.height() / (qreal) m_size.height(); | - | ||||||
153 | painter.scale(scaleX, scaleY); | - | ||||||
154 | clipRect = dirtyRect; | - | ||||||
155 | } never executed: else {end of block | 0 | ||||||
156 | painter.scale(m_contentsScale, m_contentsScale); | - | ||||||
157 | - | |||||||
158 | QRect sclip(qFloor(dirtyRect.x()/m_contentsScale), | - | ||||||
159 | qFloor(dirtyRect.y()/m_contentsScale), | - | ||||||
160 | qCeil(dirtyRect.width()/m_contentsScale+dirtyRect.x()/m_contentsScale-qFloor(dirtyRect.x()/m_contentsScale)), | - | ||||||
161 | qCeil(dirtyRect.height()/m_contentsScale+dirtyRect.y()/m_contentsScale-qFloor(dirtyRect.y()/m_contentsScale))); | - | ||||||
162 | - | |||||||
163 | clipRect = sclip; | - | ||||||
164 | } never executed: end of block | 0 | ||||||
165 | - | |||||||
166 | if (!m_dirtyRect.isNull()
| 0 | ||||||
167 | painter.setClipRect(clipRect); never executed: painter.setClipRect(clipRect); | 0 | ||||||
168 | - | |||||||
169 | painter.setCompositionMode(QPainter::CompositionMode_Source); | - | ||||||
170 | painter.fillRect(clipRect, m_fillColor); | - | ||||||
171 | painter.setCompositionMode(QPainter::CompositionMode_SourceOver); | - | ||||||
172 | - | |||||||
173 | m_item->paint(&painter); | - | ||||||
174 | painter.end(); | - | ||||||
175 | - | |||||||
176 | m_dirtyRect = QRect(); | - | ||||||
177 | } never executed: end of block | 0 | ||||||
178 | - | |||||||
179 | - | |||||||
180 | void QSGSoftwarePainterNode::setTextureSize(const QSize &size) | - | ||||||
181 | { | - | ||||||
182 | if (size == m_textureSize
| 0 | ||||||
183 | return; never executed: return; | 0 | ||||||
184 | - | |||||||
185 | m_textureSize = size; | - | ||||||
186 | m_dirtyGeometry = true; | - | ||||||
187 | } never executed: end of block | 0 | ||||||
188 | - | |||||||
189 | - | |||||||
Switch to Source code | Preprocessed file |