Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsgopenvgtexture.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
6
8
9QSGOpenVGTexture::QSGOpenVGTexture(const QImage &image, uint flags)
10{
11 Q_UNUSED(flags);
12
13 VGImageFormat format = QSGOpenVGHelpers::qImageFormatToVGImageFormat(image.format());
14 m_image = vgCreateImage(format, image.width(), image.height(), VG_IMAGE_QUALITY_BETTER);
15
16 // Do Texture Upload
17 vgImageSubData(m_image, image.constBits(), image.bytesPerLine(), format, 0, 0, image.width(), image.height());
18}
19
21{
22 vgDestroyImage(m_image);
23}
24
26{
27 return qint64(static_cast<int>(m_image));
28}
29
31{
32 VGint imageWidth = vgGetParameteri(m_image, VG_IMAGE_WIDTH);
33 VGint imageHeight = vgGetParameteri(m_image, VG_IMAGE_HEIGHT);
34 return QSize(imageWidth, imageHeight);
35}
36
38{
39 VGImageFormat format = static_cast<VGImageFormat>(vgGetParameteri(m_image, VG_IMAGE_FORMAT));
40
41 switch (format) {
42 case VG_sRGBA_8888:
43 case VG_sRGBA_8888_PRE:
44 case VG_sRGBA_5551:
45 case VG_sRGBA_4444:
46 case VG_lRGBA_8888:
47 case VG_lRGBA_8888_PRE:
48 case VG_A_8:
49 case VG_A_1:
50 case VG_A_4:
51 case VG_sARGB_8888:
52 case VG_sARGB_8888_PRE:
53 case VG_sARGB_1555:
54 case VG_sARGB_4444:
55 case VG_lARGB_8888:
56 case VG_lARGB_8888_PRE:
57 case VG_sBGRA_8888:
58 case VG_sBGRA_8888_PRE:
59 case VG_sBGRA_5551:
60 case VG_sBGRA_4444:
61 case VG_lBGRA_8888:
62 case VG_lBGRA_8888_PRE:
63 case VG_sABGR_8888:
64 case VG_sABGR_8888_PRE:
65 case VG_sABGR_1555:
66 case VG_sABGR_4444:
67 case VG_lABGR_8888:
68 case VG_lABGR_8888_PRE:
69 return true;
70 break;
71 default:
72 break;
73 }
74 return false;
75}
76
78{
79 return false;
80}
81
82QT_END_NAMESPACE
QSize textureSize() const override
Returns the size of the texture in pixels.
bool hasMipmaps() const override
Returns true if the texture data contains mipmap levels.
bool hasAlphaChannel() const override
Returns true if the texture data contains an alpha channel.
qint64 comparisonKey() const override
Returns a key suitable for comparing textures.