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