Qt
6.x
The Qt SDK
Loading...
Searching...
No Matches
qwindowsdirect2ddevicecontext.h
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
#ifndef QWINDOWSDIRECT2DDEVICECONTEXT_H
5
#define QWINDOWSDIRECT2DDEVICECONTEXT_H
6
7
#include <QtCore/qscopedpointer.h>
8
9
QT_BEGIN_NAMESPACE
10
11
/*
12
* Convenience class for handling device contexts. We have to call BeginDraw
13
* before anything can happen, and EndDraw once we're done, for every frame and
14
* pretty much any kind of operation.
15
*
16
* Unfortunately, these calls cannot be interleaved, and there is no way to check
17
* what state a device context is in.
18
*
19
* The end result is that the following throws an error if we don't track it:
20
* QPixmap pmap;
21
* QPainter painter(&pmap);
22
* pmap.clear();
23
*
24
* Here BeginDraw would first be called through the paint device, then when we clear
25
* the pixmap we would have to call it again. There is no way to know what state
26
* the device context is in when performing the clear, and activating the dc is an
27
* error. Bummer.
28
*
29
* Hence we keep a reference count here and only activate/deactivate the device
30
* if the refcount is zero.
31
*
32
* In a nutshell: Do not call BeginDraw/EndDraw yourself on the device pointer, do
33
* so through the begin/end members below.
34
*/
35
36
class
QWindowsDirect2DDeviceContextPrivate
;
37
class
QWindowsDirect2DDeviceContext
38
{
39
Q_DECLARE_PRIVATE(
QWindowsDirect2DDeviceContext
)
40
friend class
QWindowsDirect2DDeviceContextSuspender
;
41
public:
42
QWindowsDirect2DDeviceContext
(ID2D1DeviceContext *dc);
43
~
QWindowsDirect2DDeviceContext
();
44
45
ID2D1DeviceContext *
get
() const;
46
47
void
begin
();
48
bool
end
();
49
50
private
:
51
void
suspend();
52
void
resume();
53
54
QScopedPointer
<
QWindowsDirect2DDeviceContextPrivate
> d_ptr;
55
};
56
57
class
QWindowsDirect2DDeviceContextSuspender
{
58
Q_DISABLE_COPY_MOVE(
QWindowsDirect2DDeviceContextSuspender
)
59
60
QWindowsDirect2DDeviceContext
*m_dc;
61
public
:
62
QWindowsDirect2DDeviceContextSuspender
(
QWindowsDirect2DDeviceContext
*dc);
63
~QWindowsDirect2DDeviceContextSuspender
();
64
65
void
resume
();
66
};
67
68
QT_END_NAMESPACE
69
70
#endif
// QWINDOWSDIRECT2DDEVICECONTEXT_H
QScopedPointer
\inmodule QtCore
Definition
qscopedpointer.h:71
QWindowsDirect2DDeviceContextPrivate
Definition
qwindowsdirect2ddevicecontext.cpp:14
QWindowsDirect2DDeviceContextSuspender
Definition
qwindowsdirect2ddevicecontext.h:57
QWindowsDirect2DDeviceContext
Definition
qwindowsdirect2ddevicecontext.h:38
QWindowsDirect2DDeviceContext::begin
void begin()
Definition
qwindowsdirect2ddevicecontext.cpp:86
QWindowsDirect2DDeviceContext::QWindowsDirect2DDeviceContextSuspender
friend class QWindowsDirect2DDeviceContextSuspender
Definition
qwindowsdirect2ddevicecontext.h:40
QWindowsDirect2DDeviceContext::get
ID2D1DeviceContext * get() const
Definition
qwindowsdirect2ddevicecontext.cpp:78
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qstandardpaths_haiku.cpp:21
QT_END_NAMESPACE
Definition
qsharedpointer.cpp:1545
end
GLuint GLuint end
Definition
qopengles2ext.h:354
resume
future resume()
private
#define private
Definition
vsp2hardwarelayerintegration.cpp:7
qtbase
src
plugins
platforms
direct2d
qwindowsdirect2ddevicecontext.h
Generated by
1.9.7