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 "qpaintdevice.h" |
5 | |
6 | QT_BEGIN_NAMESPACE |
7 | |
8 | QPaintDevice::QPaintDevice() noexcept |
9 | { |
10 | painters = 0; |
11 | } |
12 | |
13 | QPaintDevice::~QPaintDevice() |
14 | { |
15 | if (paintingActive()) |
16 | qWarning(msg: "QPaintDevice: Cannot destroy paint device that is being " |
17 | "painted"); |
18 | } |
19 | |
20 | |
21 | /*! |
22 | \internal |
23 | */ |
24 | void QPaintDevice::initPainter(QPainter *) const |
25 | { |
26 | } |
27 | |
28 | /*! |
29 | \internal |
30 | */ |
31 | QPaintDevice *QPaintDevice::redirected(QPoint *) const |
32 | { |
33 | return nullptr; |
34 | } |
35 | |
36 | /*! |
37 | \internal |
38 | */ |
39 | QPainter *QPaintDevice::sharedPainter() const |
40 | { |
41 | return nullptr; |
42 | } |
43 | |
44 | Q_GUI_EXPORT int qt_paint_device_metric(const QPaintDevice *device, QPaintDevice::PaintDeviceMetric metric) |
45 | { |
46 | return device->metric(metric); |
47 | } |
48 | |
49 | int QPaintDevice::metric(PaintDeviceMetric m) const |
50 | { |
51 | // Fallback: A subclass has not implemented PdmDevicePixelRatioScaled but might |
52 | // have implemented PdmDevicePixelRatio. |
53 | if (m == PdmDevicePixelRatioScaled) |
54 | return this->metric(m: PdmDevicePixelRatio) * devicePixelRatioFScale(); |
55 | |
56 | qWarning(msg: "QPaintDevice::metrics: Device has no metric information"); |
57 | |
58 | if (m == PdmDpiX) { |
59 | return 72; |
60 | } else if (m == PdmDpiY) { |
61 | return 72; |
62 | } else if (m == PdmNumColors) { |
63 | // FIXME: does this need to be a real value? |
64 | return 256; |
65 | } else if (m == PdmDevicePixelRatio) { |
66 | return 1; |
67 | } else { |
68 | qDebug(msg: "Unrecognised metric %d!",m); |
69 | return 0; |
70 | } |
71 | } |
72 | |
73 | QT_END_NAMESPACE |
74 |