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
qwindowsdirect2dpaintdevice.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// Qt-Security score:significant reason:default
4
11
12#include "qwindowswindow.h"
13
14QT_BEGIN_NAMESPACE
15
16class QWindowsDirect2DPaintDevicePrivate
17{
18public:
19 QWindowsDirect2DPaintDevicePrivate(QWindowsDirect2DBitmap *bitmap, QInternal::PaintDeviceFlags f,
20 QWindowsDirect2DPaintEngine::Flags paintFlags)
21 : engine(new QWindowsDirect2DPaintEngine(bitmap, paintFlags))
22 , bitmap(bitmap)
23 , flags(f)
24 {}
25
26 QScopedPointer<QWindowsDirect2DPaintEngine> engine;
27 QWindowsDirect2DBitmap *bitmap;
28 QInternal::PaintDeviceFlags flags;
29};
30
31QWindowsDirect2DPaintDevice::QWindowsDirect2DPaintDevice(QWindowsDirect2DBitmap *bitmap, QInternal::PaintDeviceFlags flags,
32 QWindowsDirect2DPaintEngine::Flags paintFlags)
33 : d_ptr(new QWindowsDirect2DPaintDevicePrivate(bitmap, flags, paintFlags))
34{
35}
36
40
42{
43 Q_D(const QWindowsDirect2DPaintDevice);
44
45 return d->engine.data();
46}
47
49{
50 Q_D(const QWindowsDirect2DPaintDevice);
51
52 return d->flags;
53}
54
55int QWindowsDirect2DPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const
56{
57 Q_D(const QWindowsDirect2DPaintDevice);
58
59 switch (metric) {
60 case QPaintDevice::PdmWidth:
61 return int(d->bitmap->bitmap()->GetPixelSize().width);
62 case QPaintDevice::PdmHeight:
63 return int(d->bitmap->bitmap()->GetPixelSize().height);
64 case QPaintDevice::PdmNumColors:
65 return INT_MAX;
66 case QPaintDevice::PdmDepth:
67 return 32;
68 case QPaintDevice::PdmDpiX:
69 case QPaintDevice::PdmPhysicalDpiX:
70 {
71QT_WARNING_PUSH
72QT_WARNING_DISABLE_DEPRECATED // See QTBUG-94043
73 FLOAT x, y;
75 return qRound(x);
76 }
77 case QPaintDevice::PdmDpiY:
78 case QPaintDevice::PdmPhysicalDpiY:
79 {
80 FLOAT x, y;
82 return qRound(y);
83QT_WARNING_POP
84 }
85 case QPaintDevice::PdmDevicePixelRatio:
86 return 1;
87 case QPaintDevice::PdmDevicePixelRatioScaled:
88 return int(devicePixelRatioFScale());
89 case QPaintDevice::PdmWidthMM:
90 case QPaintDevice::PdmHeightMM:
91 break;
92 default:
93 break;
94 }
95
96 return -1;
97}
98
99QT_END_NAMESPACE
ID2D1Factory1 * d2dFactory() const
static QWindowsDirect2DContext * instance()
QPaintEngine * paintEngine() const override
int metric(PaintDeviceMetric metric) const override