1 | /* $Id: UIFrameBuffer.h 98841 2023-03-06 15:21:32Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIFrameBuffer class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef FEQT_INCLUDED_SRC_runtime_UIFrameBuffer_h
|
---|
29 | #define FEQT_INCLUDED_SRC_runtime_UIFrameBuffer_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* Qt includes: */
|
---|
35 | #include <QSize>
|
---|
36 |
|
---|
37 | /* GUI includes: */
|
---|
38 | #include "UIExtraDataDefs.h"
|
---|
39 |
|
---|
40 | /* Other VBox includes: */
|
---|
41 | #include <VBox/com/ptr.h>
|
---|
42 |
|
---|
43 | /* Forward declarations: */
|
---|
44 | class UIFrameBufferPrivate;
|
---|
45 | class UIMachineView;
|
---|
46 | class QResizeEvent;
|
---|
47 | class QPaintEvent;
|
---|
48 | class QRegion;
|
---|
49 |
|
---|
50 | /** IFramebuffer implementation used to maintain VM display video memory. */
|
---|
51 | class UIFrameBuffer : public QObject
|
---|
52 | {
|
---|
53 | Q_OBJECT;
|
---|
54 |
|
---|
55 | public:
|
---|
56 |
|
---|
57 | /** Constructs frame-buffer. */
|
---|
58 | UIFrameBuffer();
|
---|
59 | /** Destructs frame-buffer. */
|
---|
60 | virtual ~UIFrameBuffer() RT_OVERRIDE;
|
---|
61 |
|
---|
62 | /** Frame-buffer initialization.
|
---|
63 | * @param pMachineView defines machine-view this frame-buffer is bounded to. */
|
---|
64 | HRESULT init(UIMachineView *pMachineView);
|
---|
65 | /** Returns whether frame-buffer was initialized already. */
|
---|
66 | bool isInitialized() const { return m_fInitialized; }
|
---|
67 |
|
---|
68 | /** Assigns machine-view frame-buffer will be bounded to.
|
---|
69 | * @param pMachineView defines machine-view this frame-buffer is bounded to. */
|
---|
70 | void setView(UIMachineView *pMachineView);
|
---|
71 |
|
---|
72 | /** Attach frame-buffer to the Display. */
|
---|
73 | void attach();
|
---|
74 | /** Detach frame-buffer from the Display. */
|
---|
75 | void detach();
|
---|
76 |
|
---|
77 | /** Returns frame-buffer data address. */
|
---|
78 | uchar* address();
|
---|
79 | /** Returns frame-buffer width. */
|
---|
80 | ulong width() const;
|
---|
81 | /** Returns frame-buffer height. */
|
---|
82 | ulong height() const;
|
---|
83 | /** Returns frame-buffer bits-per-pixel value. */
|
---|
84 | ulong bitsPerPixel() const;
|
---|
85 | /** Returns frame-buffer bytes-per-line value. */
|
---|
86 | ulong bytesPerLine() const;
|
---|
87 | /** Returns the visual-state this frame-buffer is used for. */
|
---|
88 | UIVisualStateType visualState() const;
|
---|
89 |
|
---|
90 | /** Defines whether frame-buffer is <b>unused</b>.
|
---|
91 | * @note Calls to this and any other EMT callback are synchronized (from GUI side). */
|
---|
92 | void setMarkAsUnused(bool fUnused);
|
---|
93 |
|
---|
94 | /** Returns the frame-buffer's scaled-size. */
|
---|
95 | QSize scaledSize() const;
|
---|
96 | /** Defines host-to-guest scale ratio as @a size. */
|
---|
97 | void setScaledSize(const QSize &size = QSize());
|
---|
98 | /** Returns x-origin of the guest (actual) content corresponding to x-origin of host (scaled) content. */
|
---|
99 | int convertHostXTo(int iX) const;
|
---|
100 | /** Returns y-origin of the guest (actual) content corresponding to y-origin of host (scaled) content. */
|
---|
101 | int convertHostYTo(int iY) const;
|
---|
102 |
|
---|
103 | /** Returns the scale-factor used by the frame-buffer. */
|
---|
104 | double scaleFactor() const;
|
---|
105 | /** Define the scale-factor used by the frame-buffer. */
|
---|
106 | void setScaleFactor(double dScaleFactor);
|
---|
107 |
|
---|
108 | /** Returns device-pixel-ratio set for HiDPI frame-buffer. */
|
---|
109 | double devicePixelRatio() const;
|
---|
110 | /** Defines device-pixel-ratio set for HiDPI frame-buffer. */
|
---|
111 | void setDevicePixelRatio(double dDevicePixelRatio);
|
---|
112 | /** Returns actual device-pixel-ratio set for HiDPI frame-buffer. */
|
---|
113 | double devicePixelRatioActual() const;
|
---|
114 | /** Defines actual device-pixel-ratio set for HiDPI frame-buffer. */
|
---|
115 | void setDevicePixelRatioActual(double dDevicePixelRatioActual);
|
---|
116 |
|
---|
117 | /** Returns whether frame-buffer should use unscaled HiDPI output. */
|
---|
118 | bool useUnscaledHiDPIOutput() const;
|
---|
119 | /** Defines whether frame-buffer should use unscaled HiDPI output. */
|
---|
120 | void setUseUnscaledHiDPIOutput(bool fUseUnscaledHiDPIOutput);
|
---|
121 |
|
---|
122 | /** Returns the frame-buffer scaling optimization type. */
|
---|
123 | ScalingOptimizationType scalingOptimizationType() const;
|
---|
124 | /** Defines the frame-buffer scaling optimization type. */
|
---|
125 | void setScalingOptimizationType(ScalingOptimizationType type);
|
---|
126 |
|
---|
127 | /** Handles frame-buffer notify-change-event. */
|
---|
128 | void handleNotifyChange(int iWidth, int iHeight);
|
---|
129 | /** Handles frame-buffer paint-event. */
|
---|
130 | void handlePaintEvent(QPaintEvent *pEvent);
|
---|
131 | /** Handles frame-buffer set-visible-region-event. */
|
---|
132 | void handleSetVisibleRegion(const QRegion ®ion);
|
---|
133 |
|
---|
134 | /** Performs frame-buffer resizing. */
|
---|
135 | void performResize(int iWidth, int iHeight);
|
---|
136 | /** Performs frame-buffer rescaling. */
|
---|
137 | void performRescale();
|
---|
138 |
|
---|
139 | /** Handles viewport resize-event. */
|
---|
140 | void viewportResized(QResizeEvent *pEvent);
|
---|
141 |
|
---|
142 | private:
|
---|
143 |
|
---|
144 | /** Prepares everything. */
|
---|
145 | void prepare();
|
---|
146 | /** Cleanups everything. */
|
---|
147 | void cleanup();
|
---|
148 |
|
---|
149 | /** Holds the frame-buffer private instance. */
|
---|
150 | ComObjPtr<UIFrameBufferPrivate> m_pFrameBuffer;
|
---|
151 |
|
---|
152 | /** Holds whether frame-buffer was initialized already. */
|
---|
153 | bool m_fInitialized;
|
---|
154 | };
|
---|
155 |
|
---|
156 | #endif /* !FEQT_INCLUDED_SRC_runtime_UIFrameBuffer_h */
|
---|