OpenCoverage

qquickclipnode.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickclipnode.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-
41#include "qquickclipnode_p.h"-
42-
43#include <QtGui/qvector2d.h>-
44#include <QtCore/qmath.h>-
45-
46QQuickDefaultClipNode::QQuickDefaultClipNode(const QRectF &rect)-
47 : m_rect(rect)-
48 , m_radius(0)-
49 , m_dirty_geometry(true)-
50 , m_geometry(QSGGeometry::defaultAttributes_Point2D(), 0)-
51{-
52 Q_UNUSED(m_reserved);-
53 setGeometry(&m_geometry);-
54 setIsRectangular(true);-
55}
executed 386 times by 9 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquicktableview
  • tst_qquicktextedit
  • tst_qquicktextinput
  • tst_rendernode
  • tst_scenegraph
386
56-
57void QQuickDefaultClipNode::setRect(const QRectF &rect)-
58{-
59 m_rect = rect;-
60 m_dirty_geometry = true;-
61}
executed 330 times by 9 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquicktableview
  • tst_qquicktextedit
  • tst_qquicktextinput
  • tst_rendernode
  • tst_scenegraph
330
62-
63void QQuickDefaultClipNode::setRadius(qreal radius)-
64{-
65 m_radius = radius;-
66 m_dirty_geometry = true;-
67 setIsRectangular(radius == 0);-
68}
never executed: end of block
0
69-
70void QQuickDefaultClipNode::update()-
71{-
72 if (m_dirty_geometry) {
m_dirty_geometryDescription
TRUEevaluated 592 times by 9 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquicktableview
  • tst_qquicktextedit
  • tst_qquicktextinput
  • tst_rendernode
  • tst_scenegraph
FALSEnever evaluated
0-592
73 updateGeometry();-
74 m_dirty_geometry = false;-
75 }
executed 592 times by 9 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquicktableview
  • tst_qquicktextedit
  • tst_qquicktextinput
  • tst_rendernode
  • tst_scenegraph
592
76}
executed 592 times by 9 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquicktableview
  • tst_qquicktextedit
  • tst_qquicktextinput
  • tst_rendernode
  • tst_scenegraph
592
77-
78void QQuickDefaultClipNode::updateGeometry()-
79{-
80 QSGGeometry *g = geometry();-
81-
82 if (qFuzzyIsNull(m_radius)) {
qFuzzyIsNull(m_radius)Description
TRUEevaluated 592 times by 9 tests
Evaluated by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquicktableview
  • tst_qquicktextedit
  • tst_qquicktextinput
  • tst_rendernode
  • tst_scenegraph
FALSEnever evaluated
0-592
83 g->allocate(4);-
84 QSGGeometry::updateRectGeometry(g, m_rect);-
85-
86 } else {
executed 592 times by 9 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquicktableview
  • tst_qquicktextedit
  • tst_qquicktextinput
  • tst_rendernode
  • tst_scenegraph
592
87 int vertexCount = 0;-
88-
89 // Radius should never exceeds half of the width or half of the height-
90 qreal radius = qMin(qMin(m_rect.width() / 2, m_rect.height() / 2), m_radius);-
91 QRectF rect = m_rect;-
92 rect.adjust(radius, radius, -radius, -radius);-
93-
94 int segments = qMin(30, qCeil(radius)); // Number of segments per corner.-
95-
96 g->allocate((segments + 1) * 4);-
97-
98 QVector2D *vertices = (QVector2D *)g->vertexData();-
99-
100 for (int part = 0; part < 2; ++part) {
part < 2Description
TRUEnever evaluated
FALSEnever evaluated
0
101 for (int i = 0; i <= segments; ++i) {
i <= segmentsDescription
TRUEnever evaluated
FALSEnever evaluated
0
102 //### Should change to calculate sin/cos only once.-
103 qreal angle = qreal(0.5 * M_PI) * (part + i / qreal(segments));-
104 qreal s = qFastSin(angle);-
105 qreal c = qFastCos(angle);-
106 qreal y = (part ? rect.bottom() : rect.top()) - radius * c; // current inner y-coordinate.
partDescription
TRUEnever evaluated
FALSEnever evaluated
0
107 qreal lx = rect.left() - radius * s; // current inner left x-coordinate.-
108 qreal rx = rect.right() + radius * s; // current inner right x-coordinate.-
109-
110 vertices[vertexCount++] = QVector2D(rx, y);-
111 vertices[vertexCount++] = QVector2D(lx, y);-
112 }
never executed: end of block
0
113 }
never executed: end of block
0
114-
115 }
never executed: end of block
0
116 setClipRect(m_rect);-
117 markDirty(DirtyGeometry);-
118}
executed 592 times by 9 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquicktableview
  • tst_qquicktextedit
  • tst_qquicktextinput
  • tst_rendernode
  • tst_scenegraph
592
119-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0