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
qsyntheticvideoscene_p.h
Go to the documentation of this file.
1
// Copyright (C) 2026 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4
#
ifndef
QSYNTHETICVIDEOSCENE_P_H
5
#
define
QSYNTHETICVIDEOSCENE_P_H
6
7
//
8
// W A R N I N G
9
// -------------
10
//
11
// This file is not part of the Qt API. It exists purely as an
12
// implementation detail. This header file may change from version to
13
// version without notice, or even be removed.
14
//
15
// We mean it.
16
//
17
18
#
include
<
QtGui
/
qcolor
.
h
>
19
#
include
<
QtGui
/
qimage
.
h
>
20
#
include
<
QtCore
/
qrect
.
h
>
21
#
include
<
QtCore
/
qsize
.
h
>
22
#
include
<
QtCore
/
qvariantmap
.
h
>
23
24
QT_BEGIN_NAMESPACE
25
26
class
QPainter;
27
28
/*!
29
\internal
30
31
Describes the content of a synthetic video frame -- a virtual "screen" for
32
screen-capture tests, or a virtual camera image.
33
34
The same description drives both the real widget shown on screen and the
35
synthetic PipeWire source used by QFakeXdgPortalFixture, so that a test can
36
make identical pixel assertions whichever of the two produced the frame.
37
Keeping one paint routine (paintSyntheticVideoScene()) is the point: it makes
38
"the fake source shows the same thing as the widget" structural rather than
39
a duplicated implementation that can drift.
40
*/
41
struct
SyntheticVideoScene
42
{
43
// Whole virtual screen, in device pixels.
44
QSize
frameSize
{ 1920, 1080 };
45
// Where the pattern sits on that screen, in device pixels.
46
QRect
patternRect
{ 200, 100, 430, 351 };
47
QColor
backgroundColor
{
Qt
::
black
};
48
QColor
firstColor
{ 0xFF, 0, 0 };
49
QColor
secondColor
{ 0, 0, 0xFF };
50
// When set, firstColor/secondColor swap on odd ticks, so consecutive frames
51
// differ. Some capture backends stop emitting frames on static content.
52
bool
animated
=
false
;
53
/*
54
Scales the inset's margins. The margins below are expressed in
55
device-independent pixels, because that is the space a widget paints in
56
(QPainter applies the device pixel ratio for it). When the scene is
57
rendered straight into a device-pixel framebuffer instead, as the
58
synthetic PipeWire source does, they have to be scaled explicitly.
59
*/
60
qreal
scale
= 1.0;
61
62
// The inset filled with secondColor. Matches QTestWidget::paintEvent().
63
[[nodiscard]]
QRect
insetRect
()
const
64
{
65
return
patternRect.adjusted(qRound(40 * scale), qRound(50 * scale), qRound(-60 * scale),
66
qRound(-70 * scale));
67
}
68
69
[[nodiscard]]
QVariantMap
toVariantMap
()
const
;
70
[[nodiscard]]
static
SyntheticVideoScene
fromVariantMap
(
const
QVariantMap &map);
71
};
72
73
/*!
74
\internal
75
Paints \a scene with \a painter. \a tick only matters when scene.animated is set.
76
*/
77
void
paintSyntheticVideoScene
(
QPainter
&painter,
const
SyntheticVideoScene
&scene,
78
unsigned
tick = 0);
79
80
/*!
81
\internal
82
Renders \a scene into a QImage::Format_RGB32 image of scene.frameSize.
83
84
Format_RGB32 is deliberate: its in-memory byte order is B,G,R,x on
85
little-endian, identical to SPA_VIDEO_FORMAT_BGRx, so the PipeWire producer
86
can memcpy rows without any conversion.
87
*/
88
[[nodiscard]]
QImage
renderSyntheticVideoScene
(
const
SyntheticVideoScene
&scene,
unsigned
tick = 0);
89
90
QT_END_NAMESPACE
91
92
#
endif
// QSYNTHETICVIDEOSCENE_P_H
QPaintEngine::QPainter
friend class QPainter
Definition
qpaintengine.h:220
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
paintSyntheticVideoScene
void paintSyntheticVideoScene(QPainter &painter, const SyntheticVideoScene &scene, unsigned tick)
Definition
qsyntheticvideoscene.cpp:63
renderSyntheticVideoScene
QImage renderSyntheticVideoScene(const SyntheticVideoScene &scene, unsigned tick)
Definition
qsyntheticvideoscene.cpp:75
SyntheticVideoScene
Definition
qsyntheticvideoscene_p.h:42
SyntheticVideoScene::firstColor
QColor firstColor
Definition
qsyntheticvideoscene_p.h:48
SyntheticVideoScene::frameSize
QSize frameSize
Definition
qsyntheticvideoscene_p.h:44
SyntheticVideoScene::patternRect
QRect patternRect
Definition
qsyntheticvideoscene_p.h:46
SyntheticVideoScene::fromVariantMap
static SyntheticVideoScene fromVariantMap(const QVariantMap &map)
Definition
qsyntheticvideoscene.cpp:32
SyntheticVideoScene::insetRect
QRect insetRect() const
Definition
qsyntheticvideoscene_p.h:63
SyntheticVideoScene::animated
bool animated
Definition
qsyntheticvideoscene_p.h:52
SyntheticVideoScene::scale
qreal scale
Definition
qsyntheticvideoscene_p.h:60
SyntheticVideoScene::backgroundColor
QColor backgroundColor
Definition
qsyntheticvideoscene_p.h:47
SyntheticVideoScene::toVariantMap
QVariantMap toVariantMap() const
Definition
qsyntheticvideoscene.cpp:15
SyntheticVideoScene::secondColor
QColor secondColor
Definition
qsyntheticvideoscene_p.h:49
qtmultimedia
src
multimediatestlib
qsyntheticvideoscene_p.h
Generated on
for Qt by
1.16.1