[55401] | 1 | /* $Id: UIFrameBuffer.h 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
[382] | 2 | /** @file
|
---|
[49167] | 3 | * VBox Qt GUI - UIFrameBuffer class declaration.
|
---|
[382] | 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[106061] | 7 | * Copyright (C) 2010-2024 Oracle and/or its affiliates.
|
---|
[382] | 8 | *
|
---|
[96407] | 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
|
---|
[382] | 26 | */
|
---|
| 27 |
|
---|
[76581] | 28 | #ifndef FEQT_INCLUDED_SRC_runtime_UIFrameBuffer_h
|
---|
| 29 | #define FEQT_INCLUDED_SRC_runtime_UIFrameBuffer_h
|
---|
[76532] | 30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 31 | # pragma once
|
---|
| 32 | #endif
|
---|
[382] | 33 |
|
---|
[41587] | 34 | /* Qt includes: */
|
---|
[54590] | 35 | #include <QSize>
|
---|
[382] | 36 |
|
---|
[41587] | 37 | /* GUI includes: */
|
---|
[51187] | 38 | #include "UIExtraDataDefs.h"
|
---|
[41689] | 39 |
|
---|
[41587] | 40 | /* Other VBox includes: */
|
---|
[54590] | 41 | #include <VBox/com/ptr.h>
|
---|
[382] | 42 |
|
---|
[41587] | 43 | /* Forward declarations: */
|
---|
[54590] | 44 | class UIFrameBufferPrivate;
|
---|
| 45 | class UIMachineView;
|
---|
[51487] | 46 | class QResizeEvent;
|
---|
| 47 | class QPaintEvent;
|
---|
[54590] | 48 | class QRegion;
|
---|
[7407] | 49 |
|
---|
[54587] | 50 | /** IFramebuffer implementation used to maintain VM display video memory. */
|
---|
[54590] | 51 | class UIFrameBuffer : public QObject
|
---|
[382] | 52 | {
|
---|
[46293] | 53 | Q_OBJECT;
|
---|
| 54 |
|
---|
[382] | 55 | public:
|
---|
| 56 |
|
---|
[98838] | 57 | /** Constructs frame-buffer. */
|
---|
[52086] | 58 | UIFrameBuffer();
|
---|
[98838] | 59 | /** Destructs frame-buffer. */
|
---|
| 60 | virtual ~UIFrameBuffer() RT_OVERRIDE;
|
---|
[54590] | 61 |
|
---|
[52086] | 62 | /** Frame-buffer initialization.
|
---|
| 63 | * @param pMachineView defines machine-view this frame-buffer is bounded to. */
|
---|
[54590] | 64 | HRESULT init(UIMachineView *pMachineView);
|
---|
[98841] | 65 | /** Returns whether frame-buffer was initialized already. */
|
---|
| 66 | bool isInitialized() const { return m_fInitialized; }
|
---|
[52086] | 67 |
|
---|
[51487] | 68 | /** Assigns machine-view frame-buffer will be bounded to.
|
---|
| 69 | * @param pMachineView defines machine-view this frame-buffer is bounded to. */
|
---|
[54590] | 70 | void setView(UIMachineView *pMachineView);
|
---|
[27454] | 71 |
|
---|
[54589] | 72 | /** Attach frame-buffer to the Display. */
|
---|
| 73 | void attach();
|
---|
| 74 | /** Detach frame-buffer from the Display. */
|
---|
| 75 | void detach();
|
---|
[54587] | 76 |
|
---|
| 77 | /** Returns frame-buffer data address. */
|
---|
[98848] | 78 | uchar *address();
|
---|
[54587] | 79 | /** Returns frame-buffer width. */
|
---|
[54590] | 80 | ulong width() const;
|
---|
[54587] | 81 | /** Returns frame-buffer height. */
|
---|
[54590] | 82 | ulong height() const;
|
---|
[54587] | 83 | /** Returns frame-buffer bits-per-pixel value. */
|
---|
[54590] | 84 | ulong bitsPerPixel() const;
|
---|
[54587] | 85 | /** Returns frame-buffer bytes-per-line value. */
|
---|
[54590] | 86 | ulong bytesPerLine() const;
|
---|
[54587] | 87 |
|
---|
[51487] | 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);
|
---|
[49306] | 91 |
|
---|
[54587] | 92 | /** Returns the frame-buffer's scaled-size. */
|
---|
[54590] | 93 | QSize scaledSize() const;
|
---|
[54587] | 94 | /** Defines host-to-guest scale ratio as @a size. */
|
---|
[54590] | 95 | void setScaledSize(const QSize &size = QSize());
|
---|
[54587] | 96 | /** Returns x-origin of the guest (actual) content corresponding to x-origin of host (scaled) content. */
|
---|
[54590] | 97 | int convertHostXTo(int iX) const;
|
---|
[54587] | 98 | /** Returns y-origin of the guest (actual) content corresponding to y-origin of host (scaled) content. */
|
---|
[54590] | 99 | int convertHostYTo(int iY) const;
|
---|
[54587] | 100 |
|
---|
| 101 | /** Returns the scale-factor used by the frame-buffer. */
|
---|
[54590] | 102 | double scaleFactor() const;
|
---|
[54587] | 103 | /** Define the scale-factor used by the frame-buffer. */
|
---|
[54590] | 104 | void setScaleFactor(double dScaleFactor);
|
---|
[54587] | 105 |
|
---|
[69931] | 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);
|
---|
[71074] | 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);
|
---|
[54587] | 114 |
|
---|
| 115 | /** Returns whether frame-buffer should use unscaled HiDPI output. */
|
---|
[54590] | 116 | bool useUnscaledHiDPIOutput() const;
|
---|
[54587] | 117 | /** Defines whether frame-buffer should use unscaled HiDPI output. */
|
---|
[54590] | 118 | void setUseUnscaledHiDPIOutput(bool fUseUnscaledHiDPIOutput);
|
---|
[54587] | 119 |
|
---|
[55187] | 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 |
|
---|
[51487] | 125 | /** Handles frame-buffer notify-change-event. */
|
---|
[54590] | 126 | void handleNotifyChange(int iWidth, int iHeight);
|
---|
[51487] | 127 | /** Handles frame-buffer paint-event. */
|
---|
[54590] | 128 | void handlePaintEvent(QPaintEvent *pEvent);
|
---|
[54100] | 129 | /** Handles frame-buffer set-visible-region-event. */
|
---|
[54590] | 130 | void handleSetVisibleRegion(const QRegion ®ion);
|
---|
[382] | 131 |
|
---|
[54100] | 132 | /** Performs frame-buffer resizing. */
|
---|
[54590] | 133 | void performResize(int iWidth, int iHeight);
|
---|
[54104] | 134 | /** Performs frame-buffer rescaling. */
|
---|
[54590] | 135 | void performRescale();
|
---|
[54100] | 136 |
|
---|
[51487] | 137 | /** Handles viewport resize-event. */
|
---|
[54590] | 138 | void viewportResized(QResizeEvent *pEvent);
|
---|
[27757] | 139 |
|
---|
[52086] | 140 | private:
|
---|
| 141 |
|
---|
[98838] | 142 | /** Prepares everything. */
|
---|
| 143 | void prepare();
|
---|
| 144 | /** Cleanups everything. */
|
---|
| 145 | void cleanup();
|
---|
| 146 |
|
---|
[54590] | 147 | /** Holds the frame-buffer private instance. */
|
---|
[98848] | 148 | ComObjPtr<UIFrameBufferPrivate> m_pFrameBuffer;
|
---|
[98841] | 149 |
|
---|
| 150 | /** Holds whether frame-buffer was initialized already. */
|
---|
| 151 | bool m_fInitialized;
|
---|
[382] | 152 | };
|
---|
| 153 |
|
---|
[76581] | 154 | #endif /* !FEQT_INCLUDED_SRC_runtime_UIFrameBuffer_h */
|
---|