OpenCoverage

qsgsoftwarerenderer.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderer.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtQuick module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qsgsoftwarerenderer_p.h"-
41-
42#include "qsgsoftwarerenderablenodeupdater_p.h"-
43#include "qsgsoftwarerenderlistbuilder_p.h"-
44#include "qsgsoftwarecontext_p.h"-
45#include "qsgsoftwarerenderablenode_p.h"-
46-
47#include <QtGui/QPaintDevice>-
48#include <QtGui/QBackingStore>-
49#include <QElapsedTimer>-
50-
51Q_LOGGING_CATEGORY(lcRenderer, "qt.scenegraph.softwarecontext.renderer")
executed 24 times by 1 test: return category;
Executed by:
  • tst_qquickshape
24
52-
53QT_BEGIN_NAMESPACE-
54-
55QSGSoftwareRenderer::QSGSoftwareRenderer(QSGRenderContext *context)-
56 : QSGAbstractSoftwareRenderer(context)-
57 , m_paintDevice(nullptr)-
58 , m_backingStore(nullptr)-
59{-
60}
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickshape
8
61-
62QSGSoftwareRenderer::~QSGSoftwareRenderer()-
63{-
64}-
65-
66void QSGSoftwareRenderer::setCurrentPaintDevice(QPaintDevice *device)-
67{-
68 m_paintDevice = device;-
69 m_backingStore = nullptr;-
70}
never executed: end of block
0
71-
72QPaintDevice *QSGSoftwareRenderer::currentPaintDevice() const-
73{-
74 return m_paintDevice;
never executed: return m_paintDevice;
0
75}-
76-
77void QSGSoftwareRenderer::setBackingStore(QBackingStore *backingStore)-
78{-
79 m_backingStore = backingStore;-
80 m_paintDevice = nullptr;-
81}
executed 24 times by 1 test: end of block
Executed by:
  • tst_qquickshape
24
82-
83QRegion QSGSoftwareRenderer::flushRegion() const-
84{-
85 return m_flushRegion;
never executed: return m_flushRegion;
0
86}-
87-
88void QSGSoftwareRenderer::renderScene(uint)-
89{-
90 class B : public QSGBindable-
91 {-
92 public:-
93 void bind() const override { }-
94 } bindable;-
95 QSGRenderer::renderScene(bindable);-
96}
executed 24 times by 1 test: end of block
Executed by:
  • tst_qquickshape
24
97-
98void QSGSoftwareRenderer::render()-
99{-
100 if (!m_paintDevice && !m_backingStore)
!m_paintDeviceDescription
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
!m_backingStoreDescription
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_qquickshape
0-24
101 return;
never executed: return;
0
102-
103 // If there is a backingstore, set the current paint device-
104 if (m_backingStore) {
m_backingStoreDescription
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
0-24
105 // For HiDPI QBackingStores, the paint device is not valid-
106 // until begin() has been called. See: QTBUG-55875-
107 m_backingStore->beginPaint(QRegion());-
108 m_paintDevice = m_backingStore->paintDevice();-
109 m_backingStore->endPaint();-
110 }
executed 24 times by 1 test: end of block
Executed by:
  • tst_qquickshape
24
111-
112 QElapsedTimer renderTimer;-
113-
114 setBackgroundColor(clearColor());-
115 setBackgroundRect(QRect(0, 0,-
116 m_paintDevice->width() / m_paintDevice->devicePixelRatio(),-
117 m_paintDevice->height() / m_paintDevice->devicePixelRatio()));-
118-
119 // Build Renderlist-
120 // The renderlist is created by visiting each node in the tree and when a-
121 // renderable node is reach, we find the coorosponding RenderableNode object-
122 // and append it to the renderlist. At this point the RenderableNode object-
123 // should not need any further updating so it is just a matter of appending-
124 // RenderableNodes-
125 renderTimer.start();-
126 buildRenderList();-
127 qint64 buildRenderListTime = renderTimer.restart();-
128-
129 // Optimize Renderlist-
130 // This is a pass through the renderlist to determine what actually needs to-
131 // be painted. Without this pass the renderlist will simply render each item-
132 // from back to front, with a high potential for overdraw. It would also lead-
133 // to the entire window being flushed every frame. The objective of the-
134 // optimization pass is to only paint dirty nodes that are not occuluded. A-
135 // side effect of this is that additional nodes may need to be marked dirty to-
136 // force a repaint. It is also important that any item that needs to be-
137 // repainted only paints what is needed, via the use of clip regions.-
138 const QRegion updateRegion = optimizeRenderList();-
139 qint64 optimizeRenderListTime = renderTimer.restart();-
140-
141 // If Rendering to a backingstore, prepare it to be updated-
142 if (m_backingStore != nullptr) {
m_backingStore != nullptrDescription
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
0-24
143 m_backingStore->beginPaint(updateRegion);-
144 // It is possible that a QBackingStore's paintDevice() will change-
145 // when begin() is called.-
146 m_paintDevice = m_backingStore->paintDevice();-
147 }
executed 24 times by 1 test: end of block
Executed by:
  • tst_qquickshape
24
148-
149 QPainter painter(m_paintDevice);-
150 painter.setRenderHint(QPainter::Antialiasing);-
151 auto rc = static_cast<QSGSoftwareRenderContext *>(context());-
152 QPainter *prevPainter = rc->m_activePainter;-
153 rc->m_activePainter = &painter;-
154-
155 // Render the contents Renderlist-
156 m_flushRegion = renderNodes(&painter);-
157 qint64 renderTime = renderTimer.elapsed();-
158-
159 painter.end();-
160 if (m_backingStore != nullptr)
m_backingStore != nullptrDescription
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
0-24
161 m_backingStore->endPaint();
executed 24 times by 1 test: m_backingStore->endPaint();
Executed by:
  • tst_qquickshape
24
162-
163 rc->m_activePainter = prevPainter;-
164 qCDebug(lcRenderer) << "render" << m_flushRegion << buildRenderListTime << optimizeRenderListTime << renderTime;
never executed: QMessageLogger(__FILE__, 164, __PRETTY_FUNCTION__, lcRenderer().categoryName()).debug() << "render" << m_flushRegion << buildRenderListTime << optimizeRenderListTime << renderTime;
qt_category_enabledDescription
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_qquickshape
0-24
165}
executed 24 times by 1 test: end of block
Executed by:
  • tst_qquickshape
24
166-
167QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0