Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | - | |||||||||||||
7 | static QElapsedTimer qsg_renderer_timer; | - | ||||||||||||
8 | - | |||||||||||||
9 | namespace QSGCompressedAtlasTexture | - | ||||||||||||
10 | { | - | ||||||||||||
11 | - | |||||||||||||
12 | Atlas::Atlas(const QSize &size, uint format) | - | ||||||||||||
13 | : QSGAtlasTexture::AtlasBase(size) | - | ||||||||||||
14 | , m_format(format) | - | ||||||||||||
15 | { | - | ||||||||||||
16 | } never executed: end of block | 0 | ||||||||||||
17 | - | |||||||||||||
18 | Atlas::~Atlas() | - | ||||||||||||
19 | { | - | ||||||||||||
20 | } | - | ||||||||||||
21 | - | |||||||||||||
22 | Texture *Atlas::create(const QByteArray &data, int dataLength, int dataOffset, const QSize &size, const QSize &paddedSize) | - | ||||||||||||
23 | { | - | ||||||||||||
24 | - | |||||||||||||
25 | QRect rect = m_allocator.allocate(paddedSize); | - | ||||||||||||
26 | if (rect.width() > 0
| 0 | ||||||||||||
27 | Texture *t = new Texture(this, rect, data, dataLength, dataOffset, size); | - | ||||||||||||
28 | m_pending_uploads << t; | - | ||||||||||||
29 | return never executed: t;return t; never executed: return t; | 0 | ||||||||||||
30 | } | - | ||||||||||||
31 | return never executed: nullptr;return nullptr; never executed: return nullptr; | 0 | ||||||||||||
32 | } | - | ||||||||||||
33 | - | |||||||||||||
34 | void Atlas::generateTexture() | - | ||||||||||||
35 | { | - | ||||||||||||
36 | QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); | - | ||||||||||||
37 | funcs->glCompressedTexImage2D( | - | ||||||||||||
38 | 0x0DE1 | - | ||||||||||||
39 | , 0, m_format, | - | ||||||||||||
40 | m_size.width(), m_size.height(), 0, | - | ||||||||||||
41 | (m_size.width() * m_size.height()) / 2, | - | ||||||||||||
42 | nullptr); | - | ||||||||||||
43 | } never executed: end of block | 0 | ||||||||||||
44 | - | |||||||||||||
45 | void Atlas::uploadPendingTexture(int i) | - | ||||||||||||
46 | { | - | ||||||||||||
47 | Texture *texture = static_cast<Texture*>(m_pending_uploads.at(i)); | - | ||||||||||||
48 | - | |||||||||||||
49 | const QRect &r = texture->atlasSubRect(); | - | ||||||||||||
50 | - | |||||||||||||
51 | QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); | - | ||||||||||||
52 | funcs->glCompressedTexSubImage2D( | - | ||||||||||||
53 | 0x0DE1 | - | ||||||||||||
54 | , 0, | - | ||||||||||||
55 | r.x(), r.y(), r.width(), r.height(), m_format, | - | ||||||||||||
56 | texture->sizeInBytes(), | - | ||||||||||||
57 | texture->data().constData() + texture->dataOffset()); | - | ||||||||||||
58 | - | |||||||||||||
59 | for (bool qt_category_enabled = QSG_LOG_TIME_TEXTURE().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 111, __PRETTY_FUNCTION__, QSG_LOG_TIME_TEXTURE().categoryName()).debug().nospace() << "compressed atlastexture uploaded in: " << qsg_renderer_timer.elapsed() << "ms (" << texture->textureSize().width() << "x" << texture->textureSize().height() << ")"; | 0 | ||||||||||||
60 | << "ms (" << texture->textureSize().width() << "x" never executed: QMessageLogger(__FILE__, 111, __PRETTY_FUNCTION__, QSG_LOG_TIME_TEXTURE().categoryName()).debug().nospace() << "compressed atlastexture uploaded in: " << qsg_renderer_timer.elapsed() << "ms (" << texture->textureSize().width() << "x" << texture->textureSize().height() << ")"; | 0 | ||||||||||||
61 | << texture->textureSize().height() << ")"; never executed: QMessageLogger(__FILE__, 111, __PRETTY_FUNCTION__, QSG_LOG_TIME_TEXTURE().categoryName()).debug().nospace() << "compressed atlastexture uploaded in: " << qsg_renderer_timer.elapsed() << "ms (" << texture->textureSize().width() << "x" << texture->textureSize().height() << ")"; | 0 | ||||||||||||
62 | - | |||||||||||||
63 | - | |||||||||||||
64 | - | |||||||||||||
65 | - | |||||||||||||
66 | } never executed: end of block | 0 | ||||||||||||
67 | - | |||||||||||||
68 | Texture::Texture(Atlas *atlas, const QRect &textureRect, const QByteArray &data, int dataLength, int dataOffset, const QSize &size) | - | ||||||||||||
69 | : QSGAtlasTexture::TextureBase(atlas, textureRect) | - | ||||||||||||
70 | , m_nonatlas_texture(nullptr) | - | ||||||||||||
71 | , m_data(data) | - | ||||||||||||
72 | , m_size(size) | - | ||||||||||||
73 | , m_dataLength(dataLength) | - | ||||||||||||
74 | , m_dataOffset(dataOffset) | - | ||||||||||||
75 | { | - | ||||||||||||
76 | float w = atlas->size().width(); | - | ||||||||||||
77 | float h = atlas->size().height(); | - | ||||||||||||
78 | QRect nopad = atlasSubRect(); | - | ||||||||||||
79 | - | |||||||||||||
80 | m_texture_coords_rect = QRectF((nopad.x() + .5) / w, | - | ||||||||||||
81 | (nopad.y() + .5) / h, | - | ||||||||||||
82 | (nopad.width() - 1.) / w, | - | ||||||||||||
83 | (nopad.height() - 1.) / h); | - | ||||||||||||
84 | } never executed: end of block | 0 | ||||||||||||
85 | - | |||||||||||||
86 | Texture::~Texture() | - | ||||||||||||
87 | { | - | ||||||||||||
88 | delete m_nonatlas_texture; | - | ||||||||||||
89 | } never executed: end of block | 0 | ||||||||||||
90 | - | |||||||||||||
91 | bool Texture::hasAlphaChannel() const | - | ||||||||||||
92 | { | - | ||||||||||||
93 | return never executed: QSGCompressedTexture::formatIsOpaque(static_cast<Atlas*>(m_atlas)->format());return QSGCompressedTexture::formatIsOpaque(static_cast<Atlas*>(m_atlas)->format()); never executed: return QSGCompressedTexture::formatIsOpaque(static_cast<Atlas*>(m_atlas)->format()); | 0 | ||||||||||||
94 | } | - | ||||||||||||
95 | - | |||||||||||||
96 | QSGTexture *Texture::removedFromAtlas() const | - | ||||||||||||
97 | { | - | ||||||||||||
98 | if (m_nonatlas_texture
| 0 | ||||||||||||
99 | m_nonatlas_texture->setMipmapFiltering(mipmapFiltering()); | - | ||||||||||||
100 | m_nonatlas_texture->setFiltering(filtering()); | - | ||||||||||||
101 | return never executed: m_nonatlas_texture;return m_nonatlas_texture; never executed: return m_nonatlas_texture; | 0 | ||||||||||||
102 | } | - | ||||||||||||
103 | - | |||||||||||||
104 | if (!m_data.isEmpty()
| 0 | ||||||||||||
105 | QSGCompressedTexture::DataPtr texData(QSGCompressedTexture::DataPtr::create()); | - | ||||||||||||
106 | texData->data = m_data; | - | ||||||||||||
107 | texData->size = m_size; | - | ||||||||||||
108 | texData->format = static_cast<Atlas*>(m_atlas)->format(); | - | ||||||||||||
109 | texData->hasAlpha = hasAlphaChannel(); | - | ||||||||||||
110 | texData->dataLength = m_dataLength; | - | ||||||||||||
111 | texData->dataOffset = m_dataOffset; | - | ||||||||||||
112 | m_nonatlas_texture = new QSGCompressedTexture(texData); | - | ||||||||||||
113 | m_nonatlas_texture->setMipmapFiltering(mipmapFiltering()); | - | ||||||||||||
114 | m_nonatlas_texture->setFiltering(filtering()); | - | ||||||||||||
115 | } never executed: end of block | 0 | ||||||||||||
116 | - | |||||||||||||
117 | return never executed: m_nonatlas_texture;return m_nonatlas_texture; never executed: return m_nonatlas_texture; | 0 | ||||||||||||
118 | } | - | ||||||||||||
119 | - | |||||||||||||
120 | } | - | ||||||||||||
121 | - | |||||||||||||
122 | - | |||||||||||||
Switch to Source code | Preprocessed file |