VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.h@ 35740

Last change on this file since 35740 was 35448, checked in by vboxsync, 13 years ago

Frontends/VirtualBox: get rid of vcc warnings

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.4 KB
RevLine 
[382]1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
[26637]4 * UIFrameBuffer class and subclasses declarations
[382]5 */
6
7/*
[35448]8 * Copyright (C) 2010-2011 Oracle Corporation
[382]9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
[5999]13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
[382]17 */
18
[26637]19#ifndef ___UIFrameBuffer_h___
20#define ___UIFrameBuffer_h___
[382]21
[26637]22/* Global includes */
[26823]23#include <QRegion>
[19670]24#include <QPaintEvent>
[382]25
[26637]26/* Local includes */
27#include "COMDefs.h"
28#include <iprt/critsect.h>
[382]29
[26637]30class UIMachineView;
[7407]31
[382]32/**
33 * Frame buffer resize event.
34 */
[26637]35class UIResizeEvent : public QEvent
[382]36{
37public:
[3761]38
[26637]39 UIResizeEvent(ulong uPixelFormat, uchar *pVRAM,
40 ulong uBitsPerPixel, ulong uBytesPerLine,
41 ulong uWidth, ulong uHeight)
42 : QEvent((QEvent::Type)VBoxDefs::ResizeEventType)
43 , m_uPixelFormat(uPixelFormat), m_pVRAM(pVRAM), m_uBitsPerPixel(uBitsPerPixel)
44 , m_uBytesPerLine(uBytesPerLine), m_uWidth(uWidth), m_uHeight(uHeight) {}
45 ulong pixelFormat() { return m_uPixelFormat; }
46 uchar *VRAM() { return m_pVRAM; }
47 ulong bitsPerPixel() { return m_uBitsPerPixel; }
48 ulong bytesPerLine() { return m_uBytesPerLine; }
49 ulong width() { return m_uWidth; }
50 ulong height() { return m_uHeight; }
[3761]51
[382]52private:
[3761]53
[26637]54 ulong m_uPixelFormat;
55 uchar *m_pVRAM;
56 ulong m_uBitsPerPixel;
57 ulong m_uBytesPerLine;
58 ulong m_uWidth;
59 ulong m_uHeight;
[382]60};
61
62/**
63 * Frame buffer repaint event.
64 */
[26637]65class UIRepaintEvent : public QEvent
[382]66{
67public:
[26637]68
69 UIRepaintEvent(int iX, int iY, int iW, int iH)
70 : QEvent((QEvent::Type)VBoxDefs::RepaintEventType)
71 , m_iX(iX), m_iY(iY), m_iW(iW), m_iH(iH) {}
72 int x() { return m_iX; }
73 int y() { return m_iY; }
74 int width() { return m_iW; }
75 int height() { return m_iH; }
76
[382]77private:
[26637]78
79 int m_iX, m_iY, m_iW, m_iH;
[382]80};
81
[3674]82/**
83 * Frame buffer set region event.
84 */
[26637]85class UISetRegionEvent : public QEvent
[3674]86{
87public:
[26637]88
89 UISetRegionEvent(const QRegion &region)
90 : QEvent((QEvent::Type)VBoxDefs::SetRegionEventType)
91 , m_region(region) {}
92 QRegion region() { return m_region; }
93
[3674]94private:
[26637]95
96 QRegion m_region;
[3674]97};
98
[382]99/**
100 * Common IFramebuffer implementation for all methods used by GUI to maintain
101 * the VM display video memory.
102 *
103 * Note that although this class can be called from multiple threads
104 * (in particular, the GUI thread and EMT) it doesn't protect access to every
105 * data field using its mutex lock. This is because all synchronization between
106 * the GUI and the EMT thread is supposed to be done using the
107 * IFramebuffer::NotifyUpdate() and IFramebuffer::RequestResize() methods
108 * (in particular, the \a aFinished parameter of these methods is responsible
109 * for the synchronization). These methods are always called on EMT and
110 * therefore always follow one another but never in parallel.
111 *
112 * Using this object's mutex lock (exposed also in IFramebuffer::Lock() and
113 * IFramebuffer::Unlock() implementations) usually makes sense only if some
114 * third-party thread (i.e. other than GUI or EMT) needs to make sure that
115 * *no* VM display update or resize event can occur while it is accessing
116 * IFramebuffer properties or the underlying display memory storage area.
117 *
118 * See IFramebuffer documentation for more info.
119 */
[26637]120class UIFrameBuffer : VBOX_SCRIPTABLE_IMPL(IFramebuffer)
[382]121{
122public:
123
[26637]124 UIFrameBuffer(UIMachineView *aView);
125 virtual ~UIFrameBuffer();
[382]126
[27454]127 void setDeleted(bool fIsDeleted) { m_fIsDeleted = fIsDeleted; }
128
[382]129 NS_DECL_ISUPPORTS
130
131#if defined (Q_OS_WIN32)
[3761]132 STDMETHOD_(ULONG, AddRef)()
133 {
[26637]134 return ::InterlockedIncrement(&m_iRefCnt);
[382]135 }
[3761]136
[382]137 STDMETHOD_(ULONG, Release)()
138 {
[26637]139 long cnt = ::InterlockedDecrement(&m_iRefCnt);
[382]140 if (cnt == 0)
141 delete this;
142 return cnt;
143 }
144#endif
[26637]145
[21520]146 VBOX_SCRIPTABLE_DISPATCH_IMPL(IFramebuffer)
[382]147
[26637]148 /* IFramebuffer COM methods */
149 STDMETHOD(COMGETTER(Address)) (BYTE **ppAddress);
150 STDMETHOD(COMGETTER(Width)) (ULONG *puWidth);
151 STDMETHOD(COMGETTER(Height)) (ULONG *puHeight);
152 STDMETHOD(COMGETTER(BitsPerPixel)) (ULONG *puBitsPerPixel);
153 STDMETHOD(COMGETTER(BytesPerLine)) (ULONG *puBytesPerLine);
154 STDMETHOD(COMGETTER(PixelFormat)) (ULONG *puPixelFormat);
155 STDMETHOD(COMGETTER(UsesGuestVRAM)) (BOOL *pbUsesGuestVRAM);
156 STDMETHOD(COMGETTER(HeightReduction)) (ULONG *puHeightReduction);
157 STDMETHOD(COMGETTER(Overlay)) (IFramebufferOverlay **ppOverlay);
[31698]158 STDMETHOD(COMGETTER(WinId)) (LONG64 *pWinId);
[382]159
160 STDMETHOD(Lock)();
161 STDMETHOD(Unlock)();
162
[26637]163 STDMETHOD(RequestResize) (ULONG uScreenId, ULONG uPixelFormat,
164 BYTE *pVRAM, ULONG uBitsPerPixel, ULONG uBytesPerLine,
165 ULONG uWidth, ULONG uHeight,
166 BOOL *pbFinished);
[382]167
[26637]168 STDMETHOD(VideoModeSupported) (ULONG uWidth, ULONG uHeight, ULONG uBPP,
169 BOOL *pbSupported);
[382]170
[26637]171 STDMETHOD(GetVisibleRegion)(BYTE *pRectangles, ULONG uCount, ULONG *puCountCopied);
172 STDMETHOD(SetVisibleRegion)(BYTE *pRectangles, ULONG uCount);
[3576]173
[19844]174 STDMETHOD(ProcessVHWACommand)(BYTE *pCommand);
175
[26637]176 ulong width() { return m_width; }
177 ulong height() { return m_height; }
[382]178
[30753]179 virtual QSize scaledSize() const { return m_scaledSize; }
180 virtual void setScaledSize(const QSize &size = QSize()) { m_scaledSize = size; }
181
[3761]182 virtual ulong pixelFormat()
[382]183 {
[3761]184 return FramebufferPixelFormat_FOURCC_RGB;
[382]185 }
186
[3761]187 virtual bool usesGuestVRAM()
188 {
189 return false;
190 }
191
[26637]192 void lock() { RTCritSectEnter(&m_critSect); }
193 void unlock() { RTCritSectLeave(&m_critSect); }
[382]194
195 virtual uchar *address() = 0;
[3761]196 virtual ulong bitsPerPixel() = 0;
197 virtual ulong bytesPerLine() = 0;
[382]198
199 /**
200 * Called on the GUI thread (from VBoxConsoleView) when some part of the
201 * VM display viewport needs to be repainted on the host screen.
202 */
[26637]203 virtual void paintEvent(QPaintEvent *pEvent) = 0;
[382]204
205 /**
206 * Called on the GUI thread (from VBoxConsoleView) after it gets a
[26637]207 * UIResizeEvent posted from the RequestResize() method implementation.
[382]208 */
[26637]209 virtual void resizeEvent(UIResizeEvent *pEvent)
[382]210 {
[26637]211 m_width = pEvent->width();
212 m_height = pEvent->height();
[382]213 }
214
215 /**
216 * Called on the GUI thread (from VBoxConsoleView) when the VM console
217 * window is moved.
218 */
[26637]219 virtual void moveEvent(QMoveEvent * /* pEvent */) {}
[382]220
[22307]221#ifdef VBOX_WITH_VIDEOHWACCEL
[20243]222 /* this method is called from the GUI thread
[22307]223 * to perform the actual Video HW Acceleration command processing
224 * the event is framebuffer implementation specific */
225 virtual void doProcessVHWACommand(QEvent * pEvent);
[22834]226
[26637]227 virtual void viewportResized(QResizeEvent * /* pEvent */) {}
[22834]228
[26637]229 virtual void viewportScrolled(int /* iX */, int /* iY */) {}
[27757]230
[29219]231 virtual void setView(UIMachineView * pView);
[20243]232#endif
233
[382]234protected:
235
[26637]236 UIMachineView *m_pMachineView;
237 RTCRITSECT m_critSect;
[35448]238 ulong m_width;
239 ulong m_height;
[30753]240 QSize m_scaledSize;
[31698]241 int64_t m_WinId;
[27454]242 bool m_fIsDeleted;
[382]243
244#if defined (Q_OS_WIN32)
245private:
[26637]246
247 long m_iRefCnt;
[382]248#endif
249};
250
[26637]251#endif // !___UIFrameBuffer_h___
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use