OpenCoverage

qsgdepthstencilbuffer.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/scenegraph/util/qsgdepthstencilbuffer.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 Qt Quick 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 "qsgdepthstencilbuffer_p.h"-
41-
42QT_BEGIN_NAMESPACE-
43-
44QSGDepthStencilBuffer::QSGDepthStencilBuffer(QOpenGLContext *context, const Format &format)-
45 : m_functions(context)-
46 , m_manager(nullptr)-
47 , m_format(format)-
48 , m_depthBuffer(0)-
49 , m_stencilBuffer(0)-
50{-
51 // 'm_manager' is set by QSGDepthStencilBufferManager::insertBuffer().-
52}
executed 67 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickcustomparticle
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicktext
67
53-
54QSGDepthStencilBuffer::~QSGDepthStencilBuffer()-
55{-
56 if (m_manager)
m_managerDescription
TRUEevaluated 67 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickcustomparticle
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicktext
FALSEnever evaluated
0-67
57 m_manager->m_buffers.remove(m_format);
executed 67 times by 5 tests: m_manager->m_buffers.remove(m_format);
Executed by:
  • tst_examples
  • tst_qquickcustomparticle
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicktext
67
58}
executed 67 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickcustomparticle
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicktext
67
59-
60void QSGDepthStencilBuffer::attach()-
61{-
62 m_functions.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,-
63 GL_RENDERBUFFER, m_depthBuffer);-
64 m_functions.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,-
65 GL_RENDERBUFFER, m_stencilBuffer);-
66}
executed 85 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickcustomparticle
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicktext
85
67-
68void QSGDepthStencilBuffer::detach()-
69{-
70 m_functions.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,-
71 GL_RENDERBUFFER, 0);-
72 m_functions.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,-
73 GL_RENDERBUFFER, 0);-
74}
executed 85 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickcustomparticle
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicktext
85
75-
76#ifndef GL_DEPTH24_STENCIL8_OES-
77#define GL_DEPTH24_STENCIL8_OES 0x88F0-
78#endif-
79-
80#ifndef GL_DEPTH_COMPONENT24_OES-
81#define GL_DEPTH_COMPONENT24_OES 0x81A6-
82#endif-
83-
84QSGDefaultDepthStencilBuffer::QSGDefaultDepthStencilBuffer(QOpenGLContext *context, const Format &format)-
85 : QSGDepthStencilBuffer(context, format)-
86{-
87 const GLsizei width = format.size.width();-
88 const GLsizei height = format.size.height();-
89-
90 if (format.attachments == (DepthAttachment | StencilAttachment)
format.attachm...cilAttachment)Description
TRUEevaluated 67 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickcustomparticle
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicktext
FALSEnever evaluated
0-67
91 && m_functions.hasOpenGLExtension(QOpenGLExtensions::PackedDepthStencil))
m_functions.ha...dDepthStencil)Description
TRUEevaluated 67 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickcustomparticle
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicktext
FALSEnever evaluated
0-67
92 {-
93 m_functions.glGenRenderbuffers(1, &m_depthBuffer);-
94 m_functions.glBindRenderbuffer(GL_RENDERBUFFER, m_depthBuffer);-
95 if (format.samples && m_functions.hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample)) {
format.samplesDescription
TRUEnever evaluated
FALSEevaluated 67 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickcustomparticle
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicktext
m_functions.ha...erMultisample)Description
TRUEnever evaluated
FALSEnever evaluated
0-67
96#if defined(QT_OPENGL_ES_2)-
97 m_functions.glRenderbufferStorageMultisample(GL_RENDERBUFFER, format.samples,-
98 GL_DEPTH24_STENCIL8_OES, width, height);-
99#else-
100 m_functions.glRenderbufferStorageMultisample(GL_RENDERBUFFER, format.samples,-
101 GL_DEPTH24_STENCIL8, width, height);-
102#endif-
103 } else {
never executed: end of block
0
104#if defined(QT_OPENGL_ES_2)-
105 m_functions.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, width, height);-
106#else-
107 m_functions.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height);-
108#endif-
109 }
executed 67 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickcustomparticle
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicktext
67
110 m_stencilBuffer = m_depthBuffer;-
111 }
executed 67 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickcustomparticle
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicktext
67
112 if (!m_depthBuffer && (format.attachments & DepthAttachment)) {
!m_depthBufferDescription
TRUEnever evaluated
FALSEevaluated 67 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickcustomparticle
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicktext
(format.attach...pthAttachment)Description
TRUEnever evaluated
FALSEnever evaluated
0-67
113 m_functions.glGenRenderbuffers(1, &m_depthBuffer);-
114 m_functions.glBindRenderbuffer(GL_RENDERBUFFER, m_depthBuffer);-
115 GLenum internalFormat = GL_DEPTH_COMPONENT;-
116 if (context->isOpenGLES())
context->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
0
117 internalFormat = m_functions.hasOpenGLExtension(QOpenGLExtensions::Depth24)
never executed: internalFormat = m_functions.hasOpenGLExtension(QOpenGLExtensions::Depth24) ? 0x81A6 : 0x81A5;
m_functions.ha...ions::Depth24)Description
TRUEnever evaluated
FALSEnever evaluated
0
118 ? GL_DEPTH_COMPONENT24_OES : GL_DEPTH_COMPONENT16;
never executed: internalFormat = m_functions.hasOpenGLExtension(QOpenGLExtensions::Depth24) ? 0x81A6 : 0x81A5;
0
119 if (format.samples && m_functions.hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample)) {
format.samplesDescription
TRUEnever evaluated
FALSEnever evaluated
m_functions.ha...erMultisample)Description
TRUEnever evaluated
FALSEnever evaluated
0
120 m_functions.glRenderbufferStorageMultisample(GL_RENDERBUFFER, format.samples,-
121 internalFormat, width, height);-
122 } else {
never executed: end of block
0
123 m_functions.glRenderbufferStorage(GL_RENDERBUFFER, internalFormat, width, height);-
124 }
never executed: end of block
0
125 }-
126 if (!m_stencilBuffer && (format.attachments & StencilAttachment)) {
!m_stencilBufferDescription
TRUEnever evaluated
FALSEevaluated 67 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickcustomparticle
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicktext
(format.attach...cilAttachment)Description
TRUEnever evaluated
FALSEnever evaluated
0-67
127 m_functions.glGenRenderbuffers(1, &m_stencilBuffer);-
128 m_functions.glBindRenderbuffer(GL_RENDERBUFFER, m_stencilBuffer);-
129#ifdef QT_OPENGL_ES-
130 const GLenum internalFormat = GL_STENCIL_INDEX8;-
131#else-
132 const GLenum internalFormat = context->isOpenGLES() ? GL_STENCIL_INDEX8 : GL_STENCIL_INDEX;
context->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
0
133#endif-
134 if (format.samples && m_functions.hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample)) {
format.samplesDescription
TRUEnever evaluated
FALSEnever evaluated
m_functions.ha...erMultisample)Description
TRUEnever evaluated
FALSEnever evaluated
0
135 m_functions.glRenderbufferStorageMultisample(GL_RENDERBUFFER, format.samples,-
136 internalFormat, width, height);-
137 } else {
never executed: end of block
0
138 m_functions.glRenderbufferStorage(GL_RENDERBUFFER, internalFormat, width, height);-
139 }
never executed: end of block
0
140 }-
141}
executed 67 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickcustomparticle
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicktext
67
142-
143QSGDefaultDepthStencilBuffer::~QSGDefaultDepthStencilBuffer()-
144{-
145 free();-
146}
executed 67 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickcustomparticle
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicktext
67
147-
148void QSGDefaultDepthStencilBuffer::free()-
149{-
150 if (m_depthBuffer)
m_depthBufferDescription
TRUEevaluated 67 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickcustomparticle
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicktext
FALSEnever evaluated
0-67
151 m_functions.glDeleteRenderbuffers(1, &m_depthBuffer);
executed 67 times by 5 tests: m_functions.glDeleteRenderbuffers(1, &m_depthBuffer);
Executed by:
  • tst_examples
  • tst_qquickcustomparticle
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicktext
67
152 if (m_stencilBuffer && m_stencilBuffer != m_depthBuffer)
m_stencilBufferDescription
TRUEevaluated 67 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickcustomparticle
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicktext
FALSEnever evaluated
m_stencilBuffe... m_depthBufferDescription
TRUEnever evaluated
FALSEevaluated 67 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickcustomparticle
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicktext
0-67
153 m_functions.glDeleteRenderbuffers(1, &m_stencilBuffer);
never executed: m_functions.glDeleteRenderbuffers(1, &m_stencilBuffer);
0
154 m_depthBuffer = m_stencilBuffer = 0;-
155}
executed 67 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickcustomparticle
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicktext
67
156-
157-
158QSGDepthStencilBufferManager::~QSGDepthStencilBufferManager()-
159{-
160 for (Hash::const_iterator it = m_buffers.constBegin(), cend = m_buffers.constEnd(); it != cend; ++it) {
it != cendDescription
TRUEnever evaluated
FALSEevaluated 57 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickcustomparticle
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicktext
0-57
161 QSGDepthStencilBuffer *buffer = it.value().data();-
162 buffer->free();-
163 buffer->m_manager = nullptr;-
164 }
never executed: end of block
0
165}
executed 57 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickcustomparticle
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicktext
57
166-
167QSharedPointer<QSGDepthStencilBuffer> QSGDepthStencilBufferManager::bufferForFormat(const QSGDepthStencilBuffer::Format &fmt)-
168{-
169 Hash::const_iterator it = m_buffers.constFind(fmt);-
170 if (it != m_buffers.constEnd())
it != m_buffers.constEnd()Description
TRUEevaluated 18 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickitemlayer
FALSEevaluated 67 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickcustomparticle
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicktext
18-67
171 return it.value().toStrongRef();
executed 18 times by 2 tests: return it.value().toStrongRef();
Executed by:
  • tst_examples
  • tst_qquickitemlayer
18
172 return QSharedPointer<QSGDepthStencilBuffer>();
executed 67 times by 5 tests: return QSharedPointer<QSGDepthStencilBuffer>();
Executed by:
  • tst_examples
  • tst_qquickcustomparticle
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicktext
67
173}-
174-
175void QSGDepthStencilBufferManager::insertBuffer(const QSharedPointer<QSGDepthStencilBuffer> &buffer)-
176{-
177 Q_ASSERT(buffer->m_manager == nullptr);-
178 Q_ASSERT(!m_buffers.contains(buffer->m_format));-
179 buffer->m_manager = this;-
180 m_buffers.insert(buffer->m_format, buffer.toWeakRef());-
181}
executed 67 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickcustomparticle
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicktext
67
182-
183uint qHash(const QSGDepthStencilBuffer::Format &format)-
184{-
185 return qHash(qMakePair(format.size.width(), format.size.height()))
executed 172 times by 5 tests: return qHash(qMakePair(format.size.width(), format.size.height())) ^ (uint(format.samples) << 12) ^ (uint(format.attachments) << 28);
Executed by:
  • tst_examples
  • tst_qquickcustomparticle
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicktext
172
186 ^ (uint(format.samples) << 12) ^ (uint(format.attachments) << 28);
executed 172 times by 5 tests: return qHash(qMakePair(format.size.width(), format.size.height())) ^ (uint(format.samples) << 12) ^ (uint(format.attachments) << 28);
Executed by:
  • tst_examples
  • tst_qquickcustomparticle
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicktext
172
187}-
188-
189QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0