| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #include "labelitem_p.h" |
| 5 | |
| 6 | QT_BEGIN_NAMESPACE |
| 7 | |
| 8 | LabelItem::LabelItem() |
| 9 | : m_size(QSize(0, 0)), |
| 10 | m_textureId(0) |
| 11 | { |
| 12 | } |
| 13 | |
| 14 | LabelItem::~LabelItem() |
| 15 | { |
| 16 | clear(); |
| 17 | } |
| 18 | |
| 19 | void LabelItem::setSize(const QSize &size) |
| 20 | { |
| 21 | m_size = size; |
| 22 | } |
| 23 | |
| 24 | QSize LabelItem::size() const |
| 25 | { |
| 26 | return m_size; |
| 27 | } |
| 28 | |
| 29 | void LabelItem::setTextureId(GLuint textureId) |
| 30 | { |
| 31 | QOpenGLContext::currentContext()->functions()->glDeleteTextures(n: 1, textures: &m_textureId); |
| 32 | m_textureId = textureId; |
| 33 | } |
| 34 | |
| 35 | GLuint LabelItem::textureId() const |
| 36 | { |
| 37 | return m_textureId; |
| 38 | } |
| 39 | |
| 40 | void LabelItem::clear() |
| 41 | { |
| 42 | if (m_textureId && QOpenGLContext::currentContext()) |
| 43 | QOpenGLContext::currentContext()->functions()->glDeleteTextures(n: 1, textures: &m_textureId); |
| 44 | m_textureId = 0; |
| 45 | m_size = QSize(0, 0); |
| 46 | } |
| 47 | |
| 48 | QT_END_NAMESPACE |
| 49 |
