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
qsurface.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
4#include "qsurface.h"
6#include <qpa/qplatformintegration.h>
7#include <QtGui/private/qguiapplication_p.h>
8
10
11QT_IMPL_METATYPE_EXTERN_TAGGED(QSurface*, QSurface_ptr)
12
13/*!
14 \class QSurface
15 \inmodule QtGui
16 \since 5.0
17 \brief The QSurface class is an abstraction of renderable surfaces in Qt.
18
19 The size of the surface is accessible with the size() function. The rendering
20 specific attributes of the surface are accessible through the format() function.
21 */
22
23
24/*!
25 \enum QSurface::SurfaceClass
26
27 The SurfaceClass enum describes the actual subclass of the surface.
28
29 \value Window The surface is an instance of QWindow.
30 \value Offscreen The surface is an instance of QOffscreenSurface.
31 */
32
33/*!
34 \enum QSurface::SurfaceType
35
36 The SurfaceType enum describes what type of surface this is.
37
38 \value RasterSurface The surface is composed of pixels and can be rendered to using
39 a software rasterizer like Qt's raster paint engine.
40 \value OpenGLSurface The surface is an OpenGL compatible surface and can be used
41 in conjunction with QOpenGLContext.
42 \value OpenVGSurface The surface is an OpenVG compatible surface and can be used
43 in conjunction with OpenVG contexts.
44 \value VulkanSurface The surface is a Vulkan compatible surface and can be used
45 in conjunction with the Vulkan graphics API.
46 \value MetalSurface The surface is a Metal compatible surface and can be used
47 in conjunction with Apple's Metal graphics API. This surface type is only supported
48 on \macos and iOS.
49 \value Direct3DSurface The surface is a Direct 3D 11 and 12 compatible
50 surface and can be used in conjunction with the DXGI and Direct3D APIs. This
51 surface type is only supported on Windows.
52
53 \omitvalue RasterGLSurface
54 */
55
56/*!
57 \fn QSurfaceFormat QSurface::format() const
58
59 Returns the format of the surface.
60 */
61
62/*!
63 Returns true if the surface is OpenGL compatible and can be used in
64 conjunction with QOpenGLContext; otherwise returns false.
65
66 \since 5.3
67*/
68
69bool QSurface::supportsOpenGL() const
70{
71 return surfaceType() == OpenGLSurface;
72}
73
74/*!
75 \fn QPlatformSurface *QSurface::surfaceHandle() const
76
77 Returns a handle to the platform-specific implementation of the surface.
78 */
79
80/*!
81 \fn SurfaceType QSurface::surfaceType() const
82
83 Returns the type of the surface.
84 */
85
86/*!
87 \fn QSize QSurface::size() const
88
89 Returns the size of the surface in pixels.
90 */
91
92/*!
93 Creates a surface with the given \a type.
94*/
95QSurface::QSurface(SurfaceClass type)
96 : m_type(type), m_reserved(nullptr)
97{
98}
99
100/*!
101 Destroys the surface.
102*/
103QSurface::~QSurface()
104{
105#ifndef QT_NO_OPENGL
106 QOpenGLContext *context = QOpenGLContext::currentContext();
107 if (context && context->surface() == this)
108 context->doneCurrent();
109#endif
110}
111
112/*!
113 Returns the surface class of this surface.
114 */
115QSurface::SurfaceClass QSurface::surfaceClass() const
116{
117 return m_type;
118}
119
120QT_END_NAMESPACE
121
122#include "moc_qsurface.cpp"