| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/scenegraph/util/qsgatlastexture.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||
| 8 | - | |||||||||||||||||||||||||
| 9 | - | |||||||||||||||||||||||||
| 10 | - | |||||||||||||||||||||||||
| 11 | - | |||||||||||||||||||||||||
| 12 | int qt_sg_envInt(const char *name, int defaultValue); | - | ||||||||||||||||||||||||
| 13 | - | |||||||||||||||||||||||||
| 14 | static QElapsedTimer qsg_renderer_timer; | - | ||||||||||||||||||||||||
| 15 | - | |||||||||||||||||||||||||
| 16 | static bool qsgEnableCompressedAtlas() { static enum { Yes, No, Unknown } status = Unknown; if (status == Unknown
never executed: }status = Yes;never executed: }end of blocknever executed: returnend of blocknever executed: status == Yes;return status == Yes;never executed: }return status == Yes; | 0 | ||||||||||||||||||||||||
| 17 | - | |||||||||||||||||||||||||
| 18 | namespace QSGAtlasTexture | - | ||||||||||||||||||||||||
| 19 | { | - | ||||||||||||||||||||||||
| 20 | - | |||||||||||||||||||||||||
| 21 | Manager::Manager() | - | ||||||||||||||||||||||||
| 22 | : m_atlas(nullptr) | - | ||||||||||||||||||||||||
| 23 | { | - | ||||||||||||||||||||||||
| 24 | QOpenGLContext *gl = QOpenGLContext::currentContext(); | - | ||||||||||||||||||||||||
| 25 | ((gl) ? static_cast<void>(0) : qt_assert("gl", __FILE__, 81)); | - | ||||||||||||||||||||||||
| 26 | QSurface *surface = gl->surface(); | - | ||||||||||||||||||||||||
| 27 | QSize surfaceSize = surface->size(); | - | ||||||||||||||||||||||||
| 28 | int max; | - | ||||||||||||||||||||||||
| 29 | gl->functions()->glGetIntegerv( | - | ||||||||||||||||||||||||
| 30 | 0x0D33 | - | ||||||||||||||||||||||||
| 31 | , &max); | - | ||||||||||||||||||||||||
| 32 | - | |||||||||||||||||||||||||
| 33 | int w = qMin(max, qt_sg_envInt("QSG_ATLAS_WIDTH", qMax(512U, qNextPowerOfTwo(surfaceSize.width() - 1)))); | - | ||||||||||||||||||||||||
| 34 | int h = qMin(max, qt_sg_envInt("QSG_ATLAS_HEIGHT", qMax(512U, qNextPowerOfTwo(surfaceSize.height() - 1)))); | - | ||||||||||||||||||||||||
| 35 | - | |||||||||||||||||||||||||
| 36 | if (surface->surfaceClass() == QSurface::Window
| 114-3010 | ||||||||||||||||||||||||
| 37 | QWindow *window = static_cast<QWindow *>(surface); | - | ||||||||||||||||||||||||
| 38 | - | |||||||||||||||||||||||||
| 39 | if ((
| 0-3010 | ||||||||||||||||||||||||
| 40 | w /= 2; | - | ||||||||||||||||||||||||
| 41 | h /= 2; | - | ||||||||||||||||||||||||
| 42 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 43 | } executed 3010 times by 74 tests: end of blockExecuted by:
| 3010 | ||||||||||||||||||||||||
| 44 | - | |||||||||||||||||||||||||
| 45 | m_atlas_size_limit = qt_sg_envInt("QSG_ATLAS_SIZE_LIMIT", qMax(w, h) / 2); | - | ||||||||||||||||||||||||
| 46 | m_atlas_size = QSize(w, h); | - | ||||||||||||||||||||||||
| 47 | - | |||||||||||||||||||||||||
| 48 | for (bool qt_category_enabled = QSG_LOG_INFO().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 102, __PRETTY_FUNCTION__, QSG_LOG_INFO().categoryName()).debug("texture atlas dimensions: %dx%d", w, h); | 0-3124 | ||||||||||||||||||||||||
| 49 | } executed 3124 times by 76 tests: end of blockExecuted by:
| 3124 | ||||||||||||||||||||||||
| 50 | - | |||||||||||||||||||||||||
| 51 | - | |||||||||||||||||||||||||
| 52 | Manager::~Manager() | - | ||||||||||||||||||||||||
| 53 | { | - | ||||||||||||||||||||||||
| 54 | ((m_atlas == nullptr) ? static_cast<void>(0) : qt_assert("m_atlas == nullptr", __FILE__, 108)); | - | ||||||||||||||||||||||||
| 55 | ((m_atlases.isEmpty()) ? static_cast<void>(0) : qt_assert("m_atlases.isEmpty()", __FILE__, 109)); | - | ||||||||||||||||||||||||
| 56 | } executed 3098 times by 70 tests: end of blockExecuted by:
| 3098 | ||||||||||||||||||||||||
| 57 | - | |||||||||||||||||||||||||
| 58 | void Manager::invalidate() | - | ||||||||||||||||||||||||
| 59 | { | - | ||||||||||||||||||||||||
| 60 | if (m_atlas
| 137-2987 | ||||||||||||||||||||||||
| 61 | m_atlas->invalidate(); | - | ||||||||||||||||||||||||
| 62 | m_atlas->deleteLater(); | - | ||||||||||||||||||||||||
| 63 | m_atlas = nullptr; | - | ||||||||||||||||||||||||
| 64 | } executed 137 times by 8 tests: end of blockExecuted by:
| 137 | ||||||||||||||||||||||||
| 65 | - | |||||||||||||||||||||||||
| 66 | QHash<unsigned int, QSGCompressedAtlasTexture::Atlas*>::iterator i = m_atlases.begin(); | - | ||||||||||||||||||||||||
| 67 | while (i != m_atlases.end()
| 0-3124 | ||||||||||||||||||||||||
| 68 | i.value()->invalidate(); | - | ||||||||||||||||||||||||
| 69 | i.value()->deleteLater(); | - | ||||||||||||||||||||||||
| 70 | ++i; | - | ||||||||||||||||||||||||
| 71 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 72 | m_atlases.clear(); | - | ||||||||||||||||||||||||
| 73 | } executed 3124 times by 76 tests: end of blockExecuted by:
| 3124 | ||||||||||||||||||||||||
| 74 | - | |||||||||||||||||||||||||
| 75 | QSGTexture *Manager::create(const QImage &image, bool hasAlphaChannel) | - | ||||||||||||||||||||||||
| 76 | { | - | ||||||||||||||||||||||||
| 77 | Texture *t = nullptr; | - | ||||||||||||||||||||||||
| 78 | if (image.width() < m_atlas_size_limit
| 6-307 | ||||||||||||||||||||||||
| 79 | if (!m_atlas
| 137-164 | ||||||||||||||||||||||||
| 80 | m_atlas = new Atlas(m_atlas_size); executed 137 times by 8 tests: m_atlas = new Atlas(m_atlas_size);Executed by:
| 137 | ||||||||||||||||||||||||
| 81 | - | |||||||||||||||||||||||||
| 82 | t = m_atlas->create(image); | - | ||||||||||||||||||||||||
| 83 | if (t
| 0-289 | ||||||||||||||||||||||||
| 84 | t->setHasAlphaChannel(false); never executed: t->setHasAlphaChannel(false); | 0 | ||||||||||||||||||||||||
| 85 | } executed 301 times by 8 tests: end of blockExecuted by:
| 301 | ||||||||||||||||||||||||
| 86 | return executed 367 times by 8 tests: t;return t;Executed by:
executed 367 times by 8 tests: return t;Executed by:
| 367 | ||||||||||||||||||||||||
| 87 | } | - | ||||||||||||||||||||||||
| 88 | - | |||||||||||||||||||||||||
| 89 | QSGTexture *Manager::create(const QSGCompressedTextureFactory *factory) | - | ||||||||||||||||||||||||
| 90 | { | - | ||||||||||||||||||||||||
| 91 | QSGTexture *t = nullptr; | - | ||||||||||||||||||||||||
| 92 | if (!qsgEnableCompressedAtlas()
| 0 | ||||||||||||||||||||||||
| 93 | return never executed: t;return t;never executed: return t; | 0 | ||||||||||||||||||||||||
| 94 | - | |||||||||||||||||||||||||
| 95 | - | |||||||||||||||||||||||||
| 96 | unsigned int format = factory->m_textureData->format; | - | ||||||||||||||||||||||||
| 97 | switch (format) { | - | ||||||||||||||||||||||||
| 98 | case never executed: QOpenGLTexture::RGB8_ETC1:case QOpenGLTexture::RGB8_ETC1:never executed: case QOpenGLTexture::RGB8_ETC1: | 0 | ||||||||||||||||||||||||
| 99 | case never executed: QOpenGLTexture::RGB8_ETC2:case QOpenGLTexture::RGB8_ETC2:never executed: case QOpenGLTexture::RGB8_ETC2: | 0 | ||||||||||||||||||||||||
| 100 | case never executed: QOpenGLTexture::RGBA8_ETC2_EAC:case QOpenGLTexture::RGBA8_ETC2_EAC:never executed: case QOpenGLTexture::RGBA8_ETC2_EAC: | 0 | ||||||||||||||||||||||||
| 101 | case never executed: QOpenGLTexture::RGB8_PunchThrough_Alpha1_ETC2:case QOpenGLTexture::RGB8_PunchThrough_Alpha1_ETC2:never executed: case QOpenGLTexture::RGB8_PunchThrough_Alpha1_ETC2: | 0 | ||||||||||||||||||||||||
| 102 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 103 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 104 | return never executed: t;return t;never executed: return t; | 0 | ||||||||||||||||||||||||
| 105 | } | - | ||||||||||||||||||||||||
| 106 | - | |||||||||||||||||||||||||
| 107 | QSize size = factory->m_textureData->size; | - | ||||||||||||||||||||||||
| 108 | if (size.width() < m_atlas_size_limit
| 0 | ||||||||||||||||||||||||
| 109 | QHash<unsigned int, QSGCompressedAtlasTexture::Atlas*>::iterator i = m_atlases.find(format); | - | ||||||||||||||||||||||||
| 110 | if (i == m_atlases.end()
| 0 | ||||||||||||||||||||||||
| 111 | i = m_atlases.insert(format, new QSGCompressedAtlasTexture::Atlas(m_atlas_size, format)); never executed: i = m_atlases.insert(format, new QSGCompressedAtlasTexture::Atlas(m_atlas_size, format)); | 0 | ||||||||||||||||||||||||
| 112 | - | |||||||||||||||||||||||||
| 113 | QSize paddedSize(((size.width() + 3) / 4) * 4, ((size.height() + 3) / 4) * 4); | - | ||||||||||||||||||||||||
| 114 | QByteArray data = factory->m_textureData->data; | - | ||||||||||||||||||||||||
| 115 | t = i.value()->create(data, factory->m_textureData->sizeInBytes(), factory->m_textureData->dataOffset, size, paddedSize); | - | ||||||||||||||||||||||||
| 116 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 117 | return never executed: t;return t;never executed: return t; | 0 | ||||||||||||||||||||||||
| 118 | } | - | ||||||||||||||||||||||||
| 119 | - | |||||||||||||||||||||||||
| 120 | AtlasBase::AtlasBase(const QSize &size) | - | ||||||||||||||||||||||||
| 121 | : m_allocator(size) | - | ||||||||||||||||||||||||
| 122 | , m_texture_id(0) | - | ||||||||||||||||||||||||
| 123 | , m_size(size) | - | ||||||||||||||||||||||||
| 124 | , m_allocated(false) | - | ||||||||||||||||||||||||
| 125 | { | - | ||||||||||||||||||||||||
| 126 | } executed 137 times by 8 tests: end of blockExecuted by:
| 137 | ||||||||||||||||||||||||
| 127 | - | |||||||||||||||||||||||||
| 128 | AtlasBase::~AtlasBase() | - | ||||||||||||||||||||||||
| 129 | { | - | ||||||||||||||||||||||||
| 130 | ((!m_texture_id) ? static_cast<void>(0) : qt_assert("!m_texture_id", __FILE__, 184)); | - | ||||||||||||||||||||||||
| 131 | } executed 135 times by 8 tests: end of blockExecuted by:
| 135 | ||||||||||||||||||||||||
| 132 | - | |||||||||||||||||||||||||
| 133 | void AtlasBase::invalidate() | - | ||||||||||||||||||||||||
| 134 | { | - | ||||||||||||||||||||||||
| 135 | if (m_texture_id
| 0-113 | ||||||||||||||||||||||||
| 136 | QOpenGLContext::currentContext()->functions()->glDeleteTextures(1, &m_texture_id); executed 113 times by 8 tests: QOpenGLContext::currentContext()->functions()->glDeleteTextures(1, &m_texture_id);Executed by:
| 113 | ||||||||||||||||||||||||
| 137 | m_texture_id = 0; | - | ||||||||||||||||||||||||
| 138 | } executed 137 times by 8 tests: end of blockExecuted by:
| 137 | ||||||||||||||||||||||||
| 139 | - | |||||||||||||||||||||||||
| 140 | int AtlasBase::textureId() const | - | ||||||||||||||||||||||||
| 141 | { | - | ||||||||||||||||||||||||
| 142 | if (!m_texture_id
| 68-86668 | ||||||||||||||||||||||||
| 143 | ((QOpenGLContext::currentContext()) ? static_cast<void>(0) : qt_assert("QOpenGLContext::currentContext()", __FILE__, 197)); | - | ||||||||||||||||||||||||
| 144 | QOpenGLContext::currentContext()->functions()->glGenTextures(1, &const_cast<AtlasBase *>(this)->m_texture_id); | - | ||||||||||||||||||||||||
| 145 | } executed 68 times by 3 tests: end of blockExecuted by:
| 68 | ||||||||||||||||||||||||
| 146 | - | |||||||||||||||||||||||||
| 147 | return executed 86736 times by 4 tests: m_texture_id;return m_texture_id;Executed by:
executed 86736 times by 4 tests: return m_texture_id;Executed by:
| 86736 | ||||||||||||||||||||||||
| 148 | } | - | ||||||||||||||||||||||||
| 149 | - | |||||||||||||||||||||||||
| 150 | void AtlasBase::bind(QSGTexture::Filtering filtering) | - | ||||||||||||||||||||||||
| 151 | { | - | ||||||||||||||||||||||||
| 152 | QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); | - | ||||||||||||||||||||||||
| 153 | if (!m_allocated
| 113-1324 | ||||||||||||||||||||||||
| 154 | m_allocated = true; | - | ||||||||||||||||||||||||
| 155 | - | |||||||||||||||||||||||||
| 156 | while (funcs->glGetError() !=
| 0-113 | ||||||||||||||||||||||||
| 157 | 0
| 0-113 | ||||||||||||||||||||||||
| 158 | ) ; never executed: ; | 0 | ||||||||||||||||||||||||
| 159 | - | |||||||||||||||||||||||||
| 160 | funcs->glGenTextures(1, &m_texture_id); | - | ||||||||||||||||||||||||
| 161 | funcs->glBindTexture( | - | ||||||||||||||||||||||||
| 162 | 0x0DE1 | - | ||||||||||||||||||||||||
| 163 | , m_texture_id); | - | ||||||||||||||||||||||||
| 164 | funcs->glTexParameteri( | - | ||||||||||||||||||||||||
| 165 | 0x0DE1 | - | ||||||||||||||||||||||||
| 166 | , | - | ||||||||||||||||||||||||
| 167 | 0x2801 | - | ||||||||||||||||||||||||
| 168 | , | - | ||||||||||||||||||||||||
| 169 | 0x2601 | - | ||||||||||||||||||||||||
| 170 | ); | - | ||||||||||||||||||||||||
| 171 | funcs->glTexParameteri( | - | ||||||||||||||||||||||||
| 172 | 0x0DE1 | - | ||||||||||||||||||||||||
| 173 | , | - | ||||||||||||||||||||||||
| 174 | 0x2800 | - | ||||||||||||||||||||||||
| 175 | , | - | ||||||||||||||||||||||||
| 176 | 0x2601 | - | ||||||||||||||||||||||||
| 177 | ); | - | ||||||||||||||||||||||||
| 178 | funcs->glTexParameteri( | - | ||||||||||||||||||||||||
| 179 | 0x0DE1 | - | ||||||||||||||||||||||||
| 180 | , | - | ||||||||||||||||||||||||
| 181 | 0x2802 | - | ||||||||||||||||||||||||
| 182 | , | - | ||||||||||||||||||||||||
| 183 | 0x812F | - | ||||||||||||||||||||||||
| 184 | ); | - | ||||||||||||||||||||||||
| 185 | funcs->glTexParameteri( | - | ||||||||||||||||||||||||
| 186 | 0x0DE1 | - | ||||||||||||||||||||||||
| 187 | , | - | ||||||||||||||||||||||||
| 188 | 0x2803 | - | ||||||||||||||||||||||||
| 189 | , | - | ||||||||||||||||||||||||
| 190 | 0x812F | - | ||||||||||||||||||||||||
| 191 | ); | - | ||||||||||||||||||||||||
| 192 | - | |||||||||||||||||||||||||
| 193 | if (!QOpenGLContext::currentContext()->isOpenGLES()
| 0-113 | ||||||||||||||||||||||||
| 194 | funcs->glTexParameteri( executed 113 times by 8 tests: funcs->glTexParameteri( 0x0DE1 , 0x813D , 0);Executed by:
| 113 | ||||||||||||||||||||||||
| 195 | 0x0DE1 executed 113 times by 8 tests: funcs->glTexParameteri( 0x0DE1 , 0x813D , 0);Executed by:
| 113 | ||||||||||||||||||||||||
| 196 | , executed 113 times by 8 tests: funcs->glTexParameteri( 0x0DE1 , 0x813D , 0);Executed by:
| 113 | ||||||||||||||||||||||||
| 197 | 0x813D executed 113 times by 8 tests: funcs->glTexParameteri( 0x0DE1 , 0x813D , 0);Executed by:
| 113 | ||||||||||||||||||||||||
| 198 | , 0); executed 113 times by 8 tests: funcs->glTexParameteri( 0x0DE1 , 0x813D , 0);Executed by:
| 113 | ||||||||||||||||||||||||
| 199 | - | |||||||||||||||||||||||||
| 200 | generateTexture(); | - | ||||||||||||||||||||||||
| 201 | - | |||||||||||||||||||||||||
| 202 | GLenum errorCode = funcs->glGetError(); | - | ||||||||||||||||||||||||
| 203 | if (errorCode ==
| 0-113 | ||||||||||||||||||||||||
| 204 | 0x0505
| 0-113 | ||||||||||||||||||||||||
| 205 | ) { | - | ||||||||||||||||||||||||
| 206 | QMessageLogger(__FILE__, 226, __PRETTY_FUNCTION__).debug("QSGTextureAtlas: texture atlas allocation failed, out of memory"); | - | ||||||||||||||||||||||||
| 207 | funcs->glDeleteTextures(1, &m_texture_id); | - | ||||||||||||||||||||||||
| 208 | m_texture_id = 0; | - | ||||||||||||||||||||||||
| 209 | } never executed: else if (errorCode != end of block
| 0-113 | ||||||||||||||||||||||||
| 210 | 0
| 0-113 | ||||||||||||||||||||||||
| 211 | ) { | - | ||||||||||||||||||||||||
| 212 | QMessageLogger(__FILE__, 230, __PRETTY_FUNCTION__).debug("QSGTextureAtlas: texture atlas allocation failed, code=%x", errorCode); | - | ||||||||||||||||||||||||
| 213 | funcs->glDeleteTextures(1, &m_texture_id); | - | ||||||||||||||||||||||||
| 214 | m_texture_id = 0; | - | ||||||||||||||||||||||||
| 215 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 216 | } executed 113 times by 8 tests: else {end of blockExecuted by:
| 113 | ||||||||||||||||||||||||
| 217 | funcs->glBindTexture( | - | ||||||||||||||||||||||||
| 218 | 0x0DE1 | - | ||||||||||||||||||||||||
| 219 | , m_texture_id); | - | ||||||||||||||||||||||||
| 220 | } executed 1324 times by 7 tests: end of blockExecuted by:
| 1324 | ||||||||||||||||||||||||
| 221 | - | |||||||||||||||||||||||||
| 222 | if (m_texture_id == 0
| 0-1437 | ||||||||||||||||||||||||
| 223 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 224 | - | |||||||||||||||||||||||||
| 225 | - | |||||||||||||||||||||||||
| 226 | for (int i=0; i<m_pending_uploads.size()
| 263-1437 | ||||||||||||||||||||||||
| 227 | - | |||||||||||||||||||||||||
| 228 | bool profileFrames = QSG_LOG_TIME_TEXTURE().isDebugEnabled(); | - | ||||||||||||||||||||||||
| 229 | if (profileFrames
| 0-263 | ||||||||||||||||||||||||
| 230 | qsg_renderer_timer.start(); never executed: qsg_renderer_timer.start(); | 0 | ||||||||||||||||||||||||
| 231 | - | |||||||||||||||||||||||||
| 232 | if (QQuickProfiler::featuresEnabled & (1 << QQuickProfiler::ProfileSceneGraph)
never executed: else (end of blockexecuted 263 times by 8 tests: void)0;(void)0;Executed by:
executed 263 times by 8 tests: (void)0;Executed by:
| 0-263 | ||||||||||||||||||||||||
| 233 | - | |||||||||||||||||||||||||
| 234 | - | |||||||||||||||||||||||||
| 235 | if (QQuickProfiler::featuresEnabled & (1 << QQuickProfiler::ProfileSceneGraph)
never executed: else (end of blockexecuted 263 times by 8 tests: void)0(void)0 ;Executed by:
executed 263 times by 8 tests: (void)0 ;Executed by:
| 0-263 | ||||||||||||||||||||||||
| 236 | ; executed 263 times by 8 tests: (void)0 ;Executed by:
| 263 | ||||||||||||||||||||||||
| 237 | - | |||||||||||||||||||||||||
| 238 | uploadPendingTexture(i); | - | ||||||||||||||||||||||||
| 239 | - | |||||||||||||||||||||||||
| 240 | if (QQuickProfiler::featuresEnabled & (1 << QQuickProfiler::ProfileSceneGraph)
never executed: else (end of blockexecuted 263 times by 8 tests: void)0(void)0 ;Executed by:
executed 263 times by 8 tests: (void)0 ;Executed by:
| 0-263 | ||||||||||||||||||||||||
| 241 | ; executed 263 times by 8 tests: (void)0 ;Executed by:
| 263 | ||||||||||||||||||||||||
| 242 | - | |||||||||||||||||||||||||
| 243 | - | |||||||||||||||||||||||||
| 244 | if (QQuickProfiler::featuresEnabled & (1 << QQuickProfiler::ProfileSceneGraph)
never executed: else (end of blockexecuted 263 times by 8 tests: void)0(void)0 ;Executed by:
executed 263 times by 8 tests: (void)0 ;Executed by:
| 0-263 | ||||||||||||||||||||||||
| 245 | ; executed 263 times by 8 tests: (void)0 ;Executed by:
| 263 | ||||||||||||||||||||||||
| 246 | if (QQuickProfiler::featuresEnabled & (1 << QQuickProfiler::ProfileSceneGraph)
never executed: else (end of blockexecuted 263 times by 8 tests: void)0(void)0 ;Executed by:
executed 263 times by 8 tests: (void)0 ;Executed by:
| 0-263 | ||||||||||||||||||||||||
| 247 | ; executed 263 times by 8 tests: (void)0 ;Executed by:
| 263 | ||||||||||||||||||||||||
| 248 | } | - | ||||||||||||||||||||||||
| 249 | - | |||||||||||||||||||||||||
| 250 | GLenum f = filtering == QSGTexture::Nearest
| 32-1405 | ||||||||||||||||||||||||
| 251 | 0x2600 | - | ||||||||||||||||||||||||
| 252 | : | - | ||||||||||||||||||||||||
| 253 | 0x2601 | - | ||||||||||||||||||||||||
| 254 | ; | - | ||||||||||||||||||||||||
| 255 | funcs->glTexParameteri( | - | ||||||||||||||||||||||||
| 256 | 0x0DE1 | - | ||||||||||||||||||||||||
| 257 | , | - | ||||||||||||||||||||||||
| 258 | 0x2801 | - | ||||||||||||||||||||||||
| 259 | , f); | - | ||||||||||||||||||||||||
| 260 | funcs->glTexParameteri( | - | ||||||||||||||||||||||||
| 261 | 0x0DE1 | - | ||||||||||||||||||||||||
| 262 | , | - | ||||||||||||||||||||||||
| 263 | 0x2800 | - | ||||||||||||||||||||||||
| 264 | , f); | - | ||||||||||||||||||||||||
| 265 | - | |||||||||||||||||||||||||
| 266 | m_pending_uploads.clear(); | - | ||||||||||||||||||||||||
| 267 | } executed 1437 times by 8 tests: end of blockExecuted by:
| 1437 | ||||||||||||||||||||||||
| 268 | - | |||||||||||||||||||||||||
| 269 | void AtlasBase::remove(TextureBase *t) | - | ||||||||||||||||||||||||
| 270 | { | - | ||||||||||||||||||||||||
| 271 | QRect atlasRect = t->atlasSubRect(); | - | ||||||||||||||||||||||||
| 272 | m_allocator.deallocate(atlasRect); | - | ||||||||||||||||||||||||
| 273 | m_pending_uploads.removeOne(t); | - | ||||||||||||||||||||||||
| 274 | } executed 289 times by 8 tests: end of blockExecuted by:
| 289 | ||||||||||||||||||||||||
| 275 | - | |||||||||||||||||||||||||
| 276 | Atlas::Atlas(const QSize &size) | - | ||||||||||||||||||||||||
| 277 | : AtlasBase(size) | - | ||||||||||||||||||||||||
| 278 | , m_atlas_transient_image_threshold(0) | - | ||||||||||||||||||||||||
| 279 | { | - | ||||||||||||||||||||||||
| 280 | - | |||||||||||||||||||||||||
| 281 | m_internalFormat = | - | ||||||||||||||||||||||||
| 282 | 0x1908 | - | ||||||||||||||||||||||||
| 283 | ; | - | ||||||||||||||||||||||||
| 284 | m_externalFormat = | - | ||||||||||||||||||||||||
| 285 | 0x80E1 | - | ||||||||||||||||||||||||
| 286 | ; | - | ||||||||||||||||||||||||
| 287 | - | |||||||||||||||||||||||||
| 288 | - | |||||||||||||||||||||||||
| 289 | if (QOpenGLContext::currentContext()->isOpenGLES()
| 0-137 | ||||||||||||||||||||||||
| 290 | static bool wrongfullyReportsBgra8888Support = false; | - | ||||||||||||||||||||||||
| 291 | - | |||||||||||||||||||||||||
| 292 | const GLubyte *renderer = QOpenGLContext::currentContext()->functions()->glGetString( | - | ||||||||||||||||||||||||
| 293 | 0x1F01 | - | ||||||||||||||||||||||||
| 294 | ); | - | ||||||||||||||||||||||||
| 295 | if (renderer
| 0 | ||||||||||||||||||||||||
| 296 | wrongfullyReportsBgra8888Support = true; never executed: wrongfullyReportsBgra8888Support = true; | 0 | ||||||||||||||||||||||||
| 297 | - | |||||||||||||||||||||||||
| 298 | - | |||||||||||||||||||||||||
| 299 | if (qEnvironmentVariableIsSet("QSG_ATLAS_NO_BGRA_WORKAROUNDS")
| 0 | ||||||||||||||||||||||||
| 300 | wrongfullyReportsBgra8888Support = false; never executed: wrongfullyReportsBgra8888Support = false; | 0 | ||||||||||||||||||||||||
| 301 | - | |||||||||||||||||||||||||
| 302 | const char *ext = (const char *) QOpenGLContext::currentContext()->functions()->glGetString( | - | ||||||||||||||||||||||||
| 303 | 0x1F03 | - | ||||||||||||||||||||||||
| 304 | ); | - | ||||||||||||||||||||||||
| 305 | if (ext
| 0 | ||||||||||||||||||||||||
| 306 | && (strstr(ext, "GL_EXT_bgra")
| 0 | ||||||||||||||||||||||||
| 307 | || strstr(ext, "GL_EXT_texture_format_BGRA8888")
| 0 | ||||||||||||||||||||||||
| 308 | || strstr(ext, "GL_IMG_texture_format_BGRA8888")
| 0 | ||||||||||||||||||||||||
| 309 | m_internalFormat = m_externalFormat = | - | ||||||||||||||||||||||||
| 310 | 0x80E1 | - | ||||||||||||||||||||||||
| 311 | ; | - | ||||||||||||||||||||||||
| 312 | - | |||||||||||||||||||||||||
| 313 | - | |||||||||||||||||||||||||
| 314 | - | |||||||||||||||||||||||||
| 315 | - | |||||||||||||||||||||||||
| 316 | - | |||||||||||||||||||||||||
| 317 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 318 | m_internalFormat = m_externalFormat = | - | ||||||||||||||||||||||||
| 319 | 0x1908 | - | ||||||||||||||||||||||||
| 320 | ; | - | ||||||||||||||||||||||||
| 321 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 322 | - | |||||||||||||||||||||||||
| 323 | - | |||||||||||||||||||||||||
| 324 | } | - | ||||||||||||||||||||||||
| 325 | - | |||||||||||||||||||||||||
| 326 | - | |||||||||||||||||||||||||
| 327 | m_use_bgra_fallback = qEnvironmentVariableIsSet("QSG_ATLAS_USE_BGRA_FALLBACK"); | - | ||||||||||||||||||||||||
| 328 | m_debug_overlay = qEnvironmentVariableIsSet("QSG_ATLAS_OVERLAY"); | - | ||||||||||||||||||||||||
| 329 | - | |||||||||||||||||||||||||
| 330 | - | |||||||||||||||||||||||||
| 331 | - | |||||||||||||||||||||||||
| 332 | - | |||||||||||||||||||||||||
| 333 | m_atlas_transient_image_threshold = qt_sg_envInt("QSG_ATLAS_TRANSIENT_IMAGE_THRESHOLD", 0); | - | ||||||||||||||||||||||||
| 334 | } executed 137 times by 8 tests: end of blockExecuted by:
| 137 | ||||||||||||||||||||||||
| 335 | - | |||||||||||||||||||||||||
| 336 | Atlas::~Atlas() | - | ||||||||||||||||||||||||
| 337 | { | - | ||||||||||||||||||||||||
| 338 | } | - | ||||||||||||||||||||||||
| 339 | - | |||||||||||||||||||||||||
| 340 | Texture *Atlas::create(const QImage &image) | - | ||||||||||||||||||||||||
| 341 | { | - | ||||||||||||||||||||||||
| 342 | - | |||||||||||||||||||||||||
| 343 | QRect rect = m_allocator.allocate(QSize(image.width() + 2, image.height() + 2)); | - | ||||||||||||||||||||||||
| 344 | if (rect.width() > 0
| 0-289 | ||||||||||||||||||||||||
| 345 | Texture *t = new Texture(this, rect, image); | - | ||||||||||||||||||||||||
| 346 | m_pending_uploads << t; | - | ||||||||||||||||||||||||
| 347 | return executed 289 times by 8 tests: t;return t;Executed by:
executed 289 times by 8 tests: return t;Executed by:
| 289 | ||||||||||||||||||||||||
| 348 | } | - | ||||||||||||||||||||||||
| 349 | return executed 12 times by 1 test: nullptr;return nullptr;Executed by:
executed 12 times by 1 test: return nullptr;Executed by:
| 12 | ||||||||||||||||||||||||
| 350 | } | - | ||||||||||||||||||||||||
| 351 | - | |||||||||||||||||||||||||
| 352 | static void swizzleBGRAToRGBA(QImage *image) | - | ||||||||||||||||||||||||
| 353 | { | - | ||||||||||||||||||||||||
| 354 | const int width = image->width(); | - | ||||||||||||||||||||||||
| 355 | const int height = image->height(); | - | ||||||||||||||||||||||||
| 356 | uint *p = (uint *) image->bits(); | - | ||||||||||||||||||||||||
| 357 | int stride = image->bytesPerLine() / 4; | - | ||||||||||||||||||||||||
| 358 | for (int i = 0; i < height
| 0 | ||||||||||||||||||||||||
| 359 | for (int x = 0; x < width
| 0 | ||||||||||||||||||||||||
| 360 | p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00); never executed: p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00); | 0 | ||||||||||||||||||||||||
| 361 | p += stride; | - | ||||||||||||||||||||||||
| 362 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 363 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 364 | - | |||||||||||||||||||||||||
| 365 | void Atlas::upload(Texture *texture) | - | ||||||||||||||||||||||||
| 366 | { | - | ||||||||||||||||||||||||
| 367 | const QImage &image = texture->image(); | - | ||||||||||||||||||||||||
| 368 | const QRect &r = texture->atlasSubRect(); | - | ||||||||||||||||||||||||
| 369 | - | |||||||||||||||||||||||||
| 370 | QImage tmp(r.width(), r.height(), QImage::Format_ARGB32_Premultiplied); | - | ||||||||||||||||||||||||
| 371 | { | - | ||||||||||||||||||||||||
| 372 | QPainter p(&tmp); | - | ||||||||||||||||||||||||
| 373 | p.setCompositionMode(QPainter::CompositionMode_Source); | - | ||||||||||||||||||||||||
| 374 | - | |||||||||||||||||||||||||
| 375 | int w = r.width(); | - | ||||||||||||||||||||||||
| 376 | int h = r.height(); | - | ||||||||||||||||||||||||
| 377 | int iw = image.width(); | - | ||||||||||||||||||||||||
| 378 | int ih = image.height(); | - | ||||||||||||||||||||||||
| 379 | - | |||||||||||||||||||||||||
| 380 | p.drawImage(1, 1, image); | - | ||||||||||||||||||||||||
| 381 | p.drawImage(1, 0, image, 0, 0, iw, 1); | - | ||||||||||||||||||||||||
| 382 | p.drawImage(1, h - 1, image, 0, ih - 1, iw, 1); | - | ||||||||||||||||||||||||
| 383 | p.drawImage(0, 1, image, 0, 0, 1, ih); | - | ||||||||||||||||||||||||
| 384 | p.drawImage(w - 1, 1, image, iw - 1, 0, 1, ih); | - | ||||||||||||||||||||||||
| 385 | p.drawImage(0, 0, image, 0, 0, 1, 1); | - | ||||||||||||||||||||||||
| 386 | p.drawImage(0, h - 1, image, 0, ih - 1, 1, 1); | - | ||||||||||||||||||||||||
| 387 | p.drawImage(w - 1, 0, image, iw - 1, 0, 1, 1); | - | ||||||||||||||||||||||||
| 388 | p.drawImage(w - 1, h - 1, image, iw - 1, ih - 1, 1, 1); | - | ||||||||||||||||||||||||
| 389 | if (m_debug_overlay
| 0 | ||||||||||||||||||||||||
| 390 | p.setCompositionMode(QPainter::CompositionMode_SourceAtop); | - | ||||||||||||||||||||||||
| 391 | p.fillRect(0, 0, iw, ih, QBrush(QColor::fromRgbF(1, 0, 1, 0.5))); | - | ||||||||||||||||||||||||
| 392 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 393 | } | - | ||||||||||||||||||||||||
| 394 | - | |||||||||||||||||||||||||
| 395 | if (m_externalFormat ==
| 0 | ||||||||||||||||||||||||
| 396 | 0x1908
| 0 | ||||||||||||||||||||||||
| 397 | ) | - | ||||||||||||||||||||||||
| 398 | swizzleBGRAToRGBA(&tmp); never executed: swizzleBGRAToRGBA(&tmp); | 0 | ||||||||||||||||||||||||
| 399 | QOpenGLContext::currentContext()->functions()->glTexSubImage2D( | - | ||||||||||||||||||||||||
| 400 | 0x0DE1 | - | ||||||||||||||||||||||||
| 401 | , 0, | - | ||||||||||||||||||||||||
| 402 | r.x(), r.y(), r.width(), r.height(), | - | ||||||||||||||||||||||||
| 403 | m_externalFormat, | - | ||||||||||||||||||||||||
| 404 | 0x1401 | - | ||||||||||||||||||||||||
| 405 | , tmp.constBits()); | - | ||||||||||||||||||||||||
| 406 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 407 | - | |||||||||||||||||||||||||
| 408 | void Atlas::uploadBgra(Texture *texture) | - | ||||||||||||||||||||||||
| 409 | { | - | ||||||||||||||||||||||||
| 410 | QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); | - | ||||||||||||||||||||||||
| 411 | const QRect &r = texture->atlasSubRect(); | - | ||||||||||||||||||||||||
| 412 | QImage image = texture->image(); | - | ||||||||||||||||||||||||
| 413 | - | |||||||||||||||||||||||||
| 414 | if (image.isNull()
| 0-263 | ||||||||||||||||||||||||
| 415 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 416 | - | |||||||||||||||||||||||||
| 417 | if (image.format() != QImage::Format_ARGB32_Premultiplied
| 72-191 | ||||||||||||||||||||||||
| 418 | && image.format() != QImage::Format_RGB32
| 0-72 | ||||||||||||||||||||||||
| 419 | image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); | - | ||||||||||||||||||||||||
| 420 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 421 | - | |||||||||||||||||||||||||
| 422 | if (m_debug_overlay
| 0-263 | ||||||||||||||||||||||||
| 423 | QPainter p(&image); | - | ||||||||||||||||||||||||
| 424 | p.setCompositionMode(QPainter::CompositionMode_SourceAtop); | - | ||||||||||||||||||||||||
| 425 | p.fillRect(0, 0, image.width(), image.height(), QBrush(QColor::fromRgbF(0, 1, 1, 0.5))); | - | ||||||||||||||||||||||||
| 426 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 427 | - | |||||||||||||||||||||||||
| 428 | QVarLengthArray<quint32, 512> tmpBits(qMax(image.width() + 2, image.height() + 2)); | - | ||||||||||||||||||||||||
| 429 | int iw = image.width(); | - | ||||||||||||||||||||||||
| 430 | int ih = image.height(); | - | ||||||||||||||||||||||||
| 431 | int bpl = image.bytesPerLine() / 4; | - | ||||||||||||||||||||||||
| 432 | const quint32 *src = (const quint32 *) image.constBits(); | - | ||||||||||||||||||||||||
| 433 | quint32 *dst = tmpBits.data(); | - | ||||||||||||||||||||||||
| 434 | - | |||||||||||||||||||||||||
| 435 | - | |||||||||||||||||||||||||
| 436 | dst[0] = src[0]; | - | ||||||||||||||||||||||||
| 437 | memcpy(dst + 1, src, iw * sizeof(quint32)); | - | ||||||||||||||||||||||||
| 438 | dst[1 + iw] = src[iw-1]; | - | ||||||||||||||||||||||||
| 439 | funcs->glTexSubImage2D( | - | ||||||||||||||||||||||||
| 440 | 0x0DE1 | - | ||||||||||||||||||||||||
| 441 | , 0, r.x(), r.y(), iw + 2, 1, m_externalFormat, | - | ||||||||||||||||||||||||
| 442 | 0x1401 | - | ||||||||||||||||||||||||
| 443 | , dst); | - | ||||||||||||||||||||||||
| 444 | - | |||||||||||||||||||||||||
| 445 | - | |||||||||||||||||||||||||
| 446 | const quint32 *lastRow = src + bpl * (ih - 1); | - | ||||||||||||||||||||||||
| 447 | dst[0] = lastRow[0]; | - | ||||||||||||||||||||||||
| 448 | memcpy(dst + 1, lastRow, iw * sizeof(quint32)); | - | ||||||||||||||||||||||||
| 449 | dst[1 + iw] = lastRow[iw-1]; | - | ||||||||||||||||||||||||
| 450 | funcs->glTexSubImage2D( | - | ||||||||||||||||||||||||
| 451 | 0x0DE1 | - | ||||||||||||||||||||||||
| 452 | , 0, r.x(), r.y() + ih + 1, iw + 2, 1, m_externalFormat, | - | ||||||||||||||||||||||||
| 453 | 0x1401 | - | ||||||||||||||||||||||||
| 454 | , dst); | - | ||||||||||||||||||||||||
| 455 | - | |||||||||||||||||||||||||
| 456 | - | |||||||||||||||||||||||||
| 457 | for (int i=0; i<ih
| 263-20294 | ||||||||||||||||||||||||
| 458 | dst[i] = src[i * bpl]; executed 20294 times by 8 tests: dst[i] = src[i * bpl];Executed by:
| 20294 | ||||||||||||||||||||||||
| 459 | funcs->glTexSubImage2D( | - | ||||||||||||||||||||||||
| 460 | 0x0DE1 | - | ||||||||||||||||||||||||
| 461 | , 0, r.x(), r.y() + 1, 1, ih, m_externalFormat, | - | ||||||||||||||||||||||||
| 462 | 0x1401 | - | ||||||||||||||||||||||||
| 463 | , dst); | - | ||||||||||||||||||||||||
| 464 | - | |||||||||||||||||||||||||
| 465 | - | |||||||||||||||||||||||||
| 466 | for (int i=0; i<ih
| 263-20294 | ||||||||||||||||||||||||
| 467 | dst[i] = src[i * bpl + iw - 1]; executed 20294 times by 8 tests: dst[i] = src[i * bpl + iw - 1];Executed by:
| 20294 | ||||||||||||||||||||||||
| 468 | funcs->glTexSubImage2D( | - | ||||||||||||||||||||||||
| 469 | 0x0DE1 | - | ||||||||||||||||||||||||
| 470 | , 0, r.x() + iw + 1, r.y() + 1, 1, ih, m_externalFormat, | - | ||||||||||||||||||||||||
| 471 | 0x1401 | - | ||||||||||||||||||||||||
| 472 | , dst); | - | ||||||||||||||||||||||||
| 473 | - | |||||||||||||||||||||||||
| 474 | - | |||||||||||||||||||||||||
| 475 | if (bpl != iw
| 0-263 | ||||||||||||||||||||||||
| 476 | int sy = r.y() + 1; | - | ||||||||||||||||||||||||
| 477 | int ey = sy + r.height() - 2; | - | ||||||||||||||||||||||||
| 478 | for (int y = sy; y < ey
| 0 | ||||||||||||||||||||||||
| 479 | funcs->glTexSubImage2D( | - | ||||||||||||||||||||||||
| 480 | 0x0DE1 | - | ||||||||||||||||||||||||
| 481 | , 0, r.x() + 1, y, r.width() - 2, 1, m_externalFormat, | - | ||||||||||||||||||||||||
| 482 | 0x1401 | - | ||||||||||||||||||||||||
| 483 | , src); | - | ||||||||||||||||||||||||
| 484 | src += bpl; | - | ||||||||||||||||||||||||
| 485 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 486 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 487 | funcs->glTexSubImage2D( | - | ||||||||||||||||||||||||
| 488 | 0x0DE1 | - | ||||||||||||||||||||||||
| 489 | , 0, r.x() + 1, r.y() + 1, r.width() - 2, r.height() - 2, m_externalFormat, | - | ||||||||||||||||||||||||
| 490 | 0x1401 | - | ||||||||||||||||||||||||
| 491 | , src); | - | ||||||||||||||||||||||||
| 492 | } executed 263 times by 8 tests: end of blockExecuted by:
| 263 | ||||||||||||||||||||||||
| 493 | } | - | ||||||||||||||||||||||||
| 494 | - | |||||||||||||||||||||||||
| 495 | void Atlas::generateTexture() | - | ||||||||||||||||||||||||
| 496 | { | - | ||||||||||||||||||||||||
| 497 | QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); | - | ||||||||||||||||||||||||
| 498 | funcs->glTexImage2D( | - | ||||||||||||||||||||||||
| 499 | 0x0DE1 | - | ||||||||||||||||||||||||
| 500 | , 0, m_internalFormat, m_size.width(), m_size.height(), 0, m_externalFormat, | - | ||||||||||||||||||||||||
| 501 | 0x1401 | - | ||||||||||||||||||||||||
| 502 | , nullptr); | - | ||||||||||||||||||||||||
| 503 | } executed 113 times by 8 tests: end of blockExecuted by:
| 113 | ||||||||||||||||||||||||
| 504 | - | |||||||||||||||||||||||||
| 505 | void Atlas::uploadPendingTexture(int i) | - | ||||||||||||||||||||||||
| 506 | { | - | ||||||||||||||||||||||||
| 507 | Texture *t = static_cast<Texture*>(m_pending_uploads.at(i)); | - | ||||||||||||||||||||||||
| 508 | if (m_externalFormat ==
| 0-263 | ||||||||||||||||||||||||
| 509 | 0x80E1
| 0-263 | ||||||||||||||||||||||||
| 510 | && | - | ||||||||||||||||||||||||
| 511 | !m_use_bgra_fallback
| 0-263 | ||||||||||||||||||||||||
| 512 | uploadBgra(t); | - | ||||||||||||||||||||||||
| 513 | } executed 263 times by 8 tests: else {end of blockExecuted by:
| 263 | ||||||||||||||||||||||||
| 514 | upload(t); | - | ||||||||||||||||||||||||
| 515 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 516 | const QSize textureSize = t->textureSize(); | - | ||||||||||||||||||||||||
| 517 | if (textureSize.width() > m_atlas_transient_image_threshold
| 0-263 | ||||||||||||||||||||||||
| 518 | textureSize.height() > m_atlas_transient_image_threshold
| 0 | ||||||||||||||||||||||||
| 519 | t->releaseImage(); executed 263 times by 8 tests: t->releaseImage();Executed by:
| 263 | ||||||||||||||||||||||||
| 520 | - | |||||||||||||||||||||||||
| 521 | for (bool qt_category_enabled = QSG_LOG_TIME_TEXTURE().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger( __FILE__ , 508 , __PRETTY_FUNCTION__, QSG_LOG_TIME_TEXTURE().categoryName()).debug("atlastexture uploaded in: %lldms (%dx%d)", qsg_renderer_timer.elapsed(), t->textureSize().width(), t->textureSize().height()) ; | 0-263 | ||||||||||||||||||||||||
| 522 | 0 | |||||||||||||||||||||||||
| 523 | 0 | |||||||||||||||||||||||||
| 524 | __FILE__ never executed: QMessageLogger( __FILE__ , 508 , __PRETTY_FUNCTION__, QSG_LOG_TIME_TEXTURE().categoryName()).debug("atlastexture uploaded in: %lldms (%dx%d)", qsg_renderer_timer.elapsed(), t->textureSize().width(), t->textureSize().height()) ; | 0 | ||||||||||||||||||||||||
| 525 | , never executed: QMessageLogger( __FILE__ , 508 , __PRETTY_FUNCTION__, QSG_LOG_TIME_TEXTURE().categoryName()).debug("atlastexture uploaded in: %lldms (%dx%d)", qsg_renderer_timer.elapsed(), t->textureSize().width(), t->textureSize().height()) ; | 0 | ||||||||||||||||||||||||
| 526 | 0 | |||||||||||||||||||||||||
| 527 | 0 | |||||||||||||||||||||||||
| 528 | 508 never executed: QMessageLogger( __FILE__ , 508 , __PRETTY_FUNCTION__, QSG_LOG_TIME_TEXTURE().categoryName()).debug("atlastexture uploaded in: %lldms (%dx%d)", qsg_renderer_timer.elapsed(), t->textureSize().width(), t->textureSize().height()) ; | 0 | ||||||||||||||||||||||||
| 529 | , __PRETTY_FUNCTION__, QSG_LOG_TIME_TEXTURE().categoryName()).debug("atlastexture uploaded in: %lldms (%dx%d)", qsg_renderer_timer.elapsed(), t->textureSize().width(), t->textureSize().height()) never executed: QMessageLogger( __FILE__ , 508 , __PRETTY_FUNCTION__, QSG_LOG_TIME_TEXTURE().categoryName()).debug("atlastexture uploaded in: %lldms (%dx%d)", qsg_renderer_timer.elapsed(), t->textureSize().width(), t->textureSize().height()) ; | 0 | ||||||||||||||||||||||||
| 530 | 0 | |||||||||||||||||||||||||
| 531 | 0 | |||||||||||||||||||||||||
| 532 | ; never executed: QMessageLogger( __FILE__ , 508 , __PRETTY_FUNCTION__, QSG_LOG_TIME_TEXTURE().categoryName()).debug("atlastexture uploaded in: %lldms (%dx%d)", qsg_renderer_timer.elapsed(), t->textureSize().width(), t->textureSize().height()) ; | 0 | ||||||||||||||||||||||||
| 533 | } executed 263 times by 8 tests: end of blockExecuted by:
| 263 | ||||||||||||||||||||||||
| 534 | - | |||||||||||||||||||||||||
| 535 | TextureBase::TextureBase(AtlasBase *atlas, const QRect &textureRect) | - | ||||||||||||||||||||||||
| 536 | : m_allocated_rect(textureRect) | - | ||||||||||||||||||||||||
| 537 | , m_atlas(atlas) | - | ||||||||||||||||||||||||
| 538 | { | - | ||||||||||||||||||||||||
| 539 | } executed 289 times by 8 tests: end of blockExecuted by:
| 289 | ||||||||||||||||||||||||
| 540 | - | |||||||||||||||||||||||||
| 541 | TextureBase::~TextureBase() | - | ||||||||||||||||||||||||
| 542 | { | - | ||||||||||||||||||||||||
| 543 | m_atlas->remove(this); | - | ||||||||||||||||||||||||
| 544 | } executed 289 times by 8 tests: end of blockExecuted by:
| 289 | ||||||||||||||||||||||||
| 545 | - | |||||||||||||||||||||||||
| 546 | void TextureBase::bind() | - | ||||||||||||||||||||||||
| 547 | { | - | ||||||||||||||||||||||||
| 548 | m_atlas->bind(filtering()); | - | ||||||||||||||||||||||||
| 549 | } executed 1437 times by 8 tests: end of blockExecuted by:
| 1437 | ||||||||||||||||||||||||
| 550 | - | |||||||||||||||||||||||||
| 551 | Texture::Texture(Atlas *atlas, const QRect &textureRect, const QImage &image) | - | ||||||||||||||||||||||||
| 552 | : TextureBase(atlas, textureRect) | - | ||||||||||||||||||||||||
| 553 | , m_image(image) | - | ||||||||||||||||||||||||
| 554 | , m_nonatlas_texture(nullptr) | - | ||||||||||||||||||||||||
| 555 | , m_has_alpha(image.hasAlphaChannel()) | - | ||||||||||||||||||||||||
| 556 | { | - | ||||||||||||||||||||||||
| 557 | float w = atlas->size().width(); | - | ||||||||||||||||||||||||
| 558 | float h = atlas->size().height(); | - | ||||||||||||||||||||||||
| 559 | QRect nopad = atlasSubRectWithoutPadding(); | - | ||||||||||||||||||||||||
| 560 | m_texture_coords_rect = QRectF(nopad.x() / w, | - | ||||||||||||||||||||||||
| 561 | nopad.y() / h, | - | ||||||||||||||||||||||||
| 562 | nopad.width() / w, | - | ||||||||||||||||||||||||
| 563 | nopad.height() / h); | - | ||||||||||||||||||||||||
| 564 | } executed 289 times by 8 tests: end of blockExecuted by:
| 289 | ||||||||||||||||||||||||
| 565 | - | |||||||||||||||||||||||||
| 566 | Texture::~Texture() | - | ||||||||||||||||||||||||
| 567 | { | - | ||||||||||||||||||||||||
| 568 | if (m_nonatlas_texture
| 14-275 | ||||||||||||||||||||||||
| 569 | delete m_nonatlas_texture; executed 14 times by 3 tests: delete m_nonatlas_texture;Executed by:
| 14 | ||||||||||||||||||||||||
| 570 | } executed 289 times by 8 tests: end of blockExecuted by:
| 289 | ||||||||||||||||||||||||
| 571 | - | |||||||||||||||||||||||||
| 572 | QSGTexture *Texture::removedFromAtlas() const | - | ||||||||||||||||||||||||
| 573 | { | - | ||||||||||||||||||||||||
| 574 | if (m_nonatlas_texture
| 0-14 | ||||||||||||||||||||||||
| 575 | m_nonatlas_texture->setMipmapFiltering(mipmapFiltering()); | - | ||||||||||||||||||||||||
| 576 | m_nonatlas_texture->setFiltering(filtering()); | - | ||||||||||||||||||||||||
| 577 | return never executed: m_nonatlas_texture;return m_nonatlas_texture;never executed: return m_nonatlas_texture; | 0 | ||||||||||||||||||||||||
| 578 | } | - | ||||||||||||||||||||||||
| 579 | - | |||||||||||||||||||||||||
| 580 | if (!m_image.isNull()
| 2-12 | ||||||||||||||||||||||||
| 581 | m_nonatlas_texture = new QSGPlainTexture(); | - | ||||||||||||||||||||||||
| 582 | m_nonatlas_texture->setImage(m_image); | - | ||||||||||||||||||||||||
| 583 | m_nonatlas_texture->setFiltering(filtering()); | - | ||||||||||||||||||||||||
| 584 | - | |||||||||||||||||||||||||
| 585 | } executed 12 times by 2 tests: else {end of blockExecuted by:
| 12 | ||||||||||||||||||||||||
| 586 | QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); | - | ||||||||||||||||||||||||
| 587 | - | |||||||||||||||||||||||||
| 588 | - | |||||||||||||||||||||||||
| 589 | - | |||||||||||||||||||||||||
| 590 | GLint currentFbo; | - | ||||||||||||||||||||||||
| 591 | f->glGetIntegerv(0x8CA6, ¤tFbo); | - | ||||||||||||||||||||||||
| 592 | - | |||||||||||||||||||||||||
| 593 | - | |||||||||||||||||||||||||
| 594 | GLuint fbo; | - | ||||||||||||||||||||||||
| 595 | f->glGenFramebuffers(1, &fbo); | - | ||||||||||||||||||||||||
| 596 | f->glBindFramebuffer(0x8D40, fbo); | - | ||||||||||||||||||||||||
| 597 | f->glFramebufferTexture2D(0x8D40, 0x8CE0, | - | ||||||||||||||||||||||||
| 598 | 0x0DE1 | - | ||||||||||||||||||||||||
| 599 | , m_atlas->textureId(), 0); | - | ||||||||||||||||||||||||
| 600 | - | |||||||||||||||||||||||||
| 601 | - | |||||||||||||||||||||||||
| 602 | - | |||||||||||||||||||||||||
| 603 | GLuint texture; | - | ||||||||||||||||||||||||
| 604 | f->glGenTextures(1, &texture); | - | ||||||||||||||||||||||||
| 605 | f->glBindTexture( | - | ||||||||||||||||||||||||
| 606 | 0x0DE1 | - | ||||||||||||||||||||||||
| 607 | , texture); | - | ||||||||||||||||||||||||
| 608 | QRect r = atlasSubRectWithoutPadding(); | - | ||||||||||||||||||||||||
| 609 | - | |||||||||||||||||||||||||
| 610 | while (f->glGetError() !=
| 0-2 | ||||||||||||||||||||||||
| 611 | 0
| 0-2 | ||||||||||||||||||||||||
| 612 | ) ; never executed: ; | 0 | ||||||||||||||||||||||||
| 613 | f->glCopyTexImage2D( | - | ||||||||||||||||||||||||
| 614 | 0x0DE1 | - | ||||||||||||||||||||||||
| 615 | , 0, static_cast<Atlas*>(m_atlas)->internalFormat(), r.x(), r.y(), r.width(), r.height(), 0); | - | ||||||||||||||||||||||||
| 616 | - | |||||||||||||||||||||||||
| 617 | if (f->glGetError() !=
| 0-2 | ||||||||||||||||||||||||
| 618 | 0
| 0-2 | ||||||||||||||||||||||||
| 619 | ) | - | ||||||||||||||||||||||||
| 620 | f->glCopyTexImage2D( never executed: f->glCopyTexImage2D( 0x0DE1 , 0, 0x1908 , r.x(), r.y(), r.width(), r.height(), 0); | 0 | ||||||||||||||||||||||||
| 621 | 0x0DE1 never executed: f->glCopyTexImage2D( 0x0DE1 , 0, 0x1908 , r.x(), r.y(), r.width(), r.height(), 0); | 0 | ||||||||||||||||||||||||
| 622 | , 0, never executed: f->glCopyTexImage2D( 0x0DE1 , 0, 0x1908 , r.x(), r.y(), r.width(), r.height(), 0); | 0 | ||||||||||||||||||||||||
| 623 | 0x1908 never executed: f->glCopyTexImage2D( 0x0DE1 , 0, 0x1908 , r.x(), r.y(), r.width(), r.height(), 0); | 0 | ||||||||||||||||||||||||
| 624 | , r.x(), r.y(), r.width(), r.height(), 0); never executed: f->glCopyTexImage2D( 0x0DE1 , 0, 0x1908 , r.x(), r.y(), r.width(), r.height(), 0); | 0 | ||||||||||||||||||||||||
| 625 | - | |||||||||||||||||||||||||
| 626 | m_nonatlas_texture = new QSGPlainTexture(); | - | ||||||||||||||||||||||||
| 627 | m_nonatlas_texture->setTextureId(texture); | - | ||||||||||||||||||||||||
| 628 | m_nonatlas_texture->setOwnsTexture(true); | - | ||||||||||||||||||||||||
| 629 | m_nonatlas_texture->setHasAlphaChannel(m_has_alpha); | - | ||||||||||||||||||||||||
| 630 | m_nonatlas_texture->setTextureSize(r.size()); | - | ||||||||||||||||||||||||
| 631 | - | |||||||||||||||||||||||||
| 632 | - | |||||||||||||||||||||||||
| 633 | f->glFramebufferTexture2D(0x8D40, 0x8CE0, | - | ||||||||||||||||||||||||
| 634 | 0x0DE1 | - | ||||||||||||||||||||||||
| 635 | , 0, 0); | - | ||||||||||||||||||||||||
| 636 | f->glBindFramebuffer(0x8D40, (GLuint) currentFbo); | - | ||||||||||||||||||||||||
| 637 | f->glDeleteFramebuffers(1, &fbo); | - | ||||||||||||||||||||||||
| 638 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||
| 639 | - | |||||||||||||||||||||||||
| 640 | m_nonatlas_texture->setMipmapFiltering(mipmapFiltering()); | - | ||||||||||||||||||||||||
| 641 | m_nonatlas_texture->setFiltering(filtering()); | - | ||||||||||||||||||||||||
| 642 | return executed 14 times by 3 tests: m_nonatlas_texture;return m_nonatlas_texture;Executed by:
executed 14 times by 3 tests: return m_nonatlas_texture;Executed by:
| 14 | ||||||||||||||||||||||||
| 643 | } | - | ||||||||||||||||||||||||
| 644 | - | |||||||||||||||||||||||||
| 645 | } | - | ||||||||||||||||||||||||
| 646 | - | |||||||||||||||||||||||||
| 647 | - | |||||||||||||||||||||||||
| 648 | - | |||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |