1 | /* $Id: UIFrameBuffer.h 98848 2023-03-07 07:55:33Z 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 |
|
---|
88 | /** Defines whether frame-buffer is <b>unused</b>.
|
---|
89 | * @note Calls to this and any other EMT callback are synchronized (from GUI side). */
|
---|
90 | void setMarkAsUnused(bool fUnused);
|
---|
91 |
|
---|
92 | /** Returns the frame-buffer's scaled-size. */
|
---|
93 | QSize scaledSize() const;
|
---|
94 | /** Defines host-to-guest scale ratio as @a size. */
|
---|
95 | void setScaledSize(const QSize &size = QSize());
|
---|
96 | /** Returns x-origin of the guest (actual) content corresponding to x-origin of host (scaled) content. */
|
---|
97 | int convertHostXTo(int iX) const;
|
---|
98 | /** Returns y-origin of the guest (actual) content corresponding to y-origin of host (scaled) content. */
|
---|
99 | int convertHostYTo(int iY) const;
|
---|
100 |
|
---|
101 | /** Returns the scale-factor used by the frame-buffer. */
|
---|
102 | double scaleFactor() const;
|
---|
103 | /** Define the scale-factor used by the frame-buffer. */
|
---|
104 | void setScaleFactor(double dScaleFactor);
|
---|
105 |
|
---|
106 | /** Returns device-pixel-ratio set for HiDPI frame-buffer. */
|
---|
107 | double devicePixelRatio() const;
|
---|
108 | /** Defines device-pixel-ratio set for HiDPI frame-buffer. */
|
---|
109 | void setDevicePixelRatio(double dDevicePixelRatio);
|
---|
110 | /** Returns actual device-pixel-ratio set for HiDPI frame-buffer. */
|
---|
111 | double devicePixelRatioActual() const;
|
---|
112 | /** Defines actual device-pixel-ratio set for HiDPI frame-buffer. */
|
---|
113 | void setDevicePixelRatioActual(double dDevicePixelRatioActual);
|
---|
114 |
|
---|
115 | /** Returns whether frame-buffer should use unscaled HiDPI output. */
|
---|
116 | bool useUnscaledHiDPIOutput() const;
|
---|
117 | /** Defines whether frame-buffer should use unscaled HiDPI output. */
|
---|
118 | void setUseUnscaledHiDPIOutput(bool fUseUnscaledHiDPIOutput);
|
---|
119 |
|
---|
120 | /** Returns the frame-buffer scaling optimization type. */
|
---|
121 | ScalingOptimizationType scalingOptimizationType() const;
|
---|
122 | /** Defines the frame-buffer scaling optimization type. */
|
---|
123 | void setScalingOptimizationType(ScalingOptimizationType type);
|
---|
124 |
|
---|
125 | /** Handles frame-buffer notify-change-event. */
|
---|
126 | void handleNotifyChange(int iWidth, int iHeight);
|
---|
127 | /** Handles frame-buffer paint-event. */
|
---|
128 | void handlePaintEvent(QPaintEvent *pEvent);
|
---|
129 | /** Handles frame-buffer set-visible-region-event. */
|
---|
130 | void handleSetVisibleRegion(const QRegion ®ion);
|
---|
131 |
|
---|
132 | /** Performs frame-buffer resizing. */
|
---|
133 | void performResize(int iWidth, int iHeight);
|
---|
134 | /** Performs frame-buffer rescaling. */
|
---|
135 | void performRescale();
|
---|
136 |
|
---|
137 | /** Handles viewport resize-event. */
|
---|
138 | void viewportResized(QResizeEvent *pEvent);
|
---|
139 |
|
---|
140 | private:
|
---|
141 |
|
---|
142 | /** Prepares everything. */
|
---|
143 | void prepare();
|
---|
144 | /** Cleanups everything. */
|
---|
145 | void cleanup();
|
---|
146 |
|
---|
147 | /** Holds the frame-buffer private instance. */
|
---|
148 | ComObjPtr<UIFrameBufferPrivate> m_pFrameBuffer;
|
---|
149 |
|
---|
150 | /** Holds whether frame-buffer was initialized already. */
|
---|
151 | bool m_fInitialized;
|
---|
152 | };
|
---|
153 |
|
---|
154 | #endif /* !FEQT_INCLUDED_SRC_runtime_UIFrameBuffer_h */
|
---|