DisplayImpl.h revision c7a97a05c12bda5a9a857d5d4d910d929fe9709e
1ef682c649d3f26392a8b7a091337adb78ddd87dvboxsync/** @file
b2640405e06105d868b5fc8f7b676bb680884380vboxsync *
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * VirtualBox COM class implementation
1ef682c649d3f26392a8b7a091337adb78ddd87dvboxsync */
1ef682c649d3f26392a8b7a091337adb78ddd87dvboxsync
1ef682c649d3f26392a8b7a091337adb78ddd87dvboxsync/*
1ef682c649d3f26392a8b7a091337adb78ddd87dvboxsync * Copyright (C) 2006 InnoTek Systemberatung GmbH
b2640405e06105d868b5fc8f7b676bb680884380vboxsync *
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * available from http://www.virtualbox.org. This file is free software;
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * you can redistribute it and/or modify it under the terms of the GNU
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * General Public License as published by the Free Software Foundation,
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * distribution. VirtualBox OSE is distributed in the hope that it will
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * be useful, but WITHOUT ANY WARRANTY of any kind.
b2640405e06105d868b5fc8f7b676bb680884380vboxsync *
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * If you received this file as part of a commercial VirtualBox
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * distribution, then only the terms of your commercial VirtualBox
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * license agreement apply instead of the previous paragraph.
b2640405e06105d868b5fc8f7b676bb680884380vboxsync */
b2640405e06105d868b5fc8f7b676bb680884380vboxsync
b2640405e06105d868b5fc8f7b676bb680884380vboxsync#ifndef ____H_DISPLAYIMPL
b2640405e06105d868b5fc8f7b676bb680884380vboxsync#define ____H_DISPLAYIMPL
b2640405e06105d868b5fc8f7b676bb680884380vboxsync
b2640405e06105d868b5fc8f7b676bb680884380vboxsync#include "VirtualBoxBase.h"
b2640405e06105d868b5fc8f7b676bb680884380vboxsync#include <iprt/semaphore.h>
b2640405e06105d868b5fc8f7b676bb680884380vboxsync#include <VBox/pdm.h>
b2640405e06105d868b5fc8f7b676bb680884380vboxsync#include <VBox/VBoxGuest.h>
b2640405e06105d868b5fc8f7b676bb680884380vboxsync
b2640405e06105d868b5fc8f7b676bb680884380vboxsyncclass Console;
b2640405e06105d868b5fc8f7b676bb680884380vboxsync
b2640405e06105d868b5fc8f7b676bb680884380vboxsyncclass ATL_NO_VTABLE Display :
8ad79874169cc981a694a15e8a806b9a39133673vboxsync public IConsoleCallback,
8ad79874169cc981a694a15e8a806b9a39133673vboxsync public VirtualBoxSupportErrorInfoImpl <Display, IDisplay>,
8ad79874169cc981a694a15e8a806b9a39133673vboxsync public VirtualBoxSupportTranslation <Display>,
b2640405e06105d868b5fc8f7b676bb680884380vboxsync public VirtualBoxBase,
b2640405e06105d868b5fc8f7b676bb680884380vboxsync public IDisplay
b2640405e06105d868b5fc8f7b676bb680884380vboxsync{
543d2dd34b3036927165be4f72c0cccd85daaa33vboxsync
543d2dd34b3036927165be4f72c0cccd85daaa33vboxsyncpublic:
543d2dd34b3036927165be4f72c0cccd85daaa33vboxsync
543d2dd34b3036927165be4f72c0cccd85daaa33vboxsync DECLARE_NOT_AGGREGATABLE(Display)
b2640405e06105d868b5fc8f7b676bb680884380vboxsync
b2640405e06105d868b5fc8f7b676bb680884380vboxsync DECLARE_PROTECT_FINAL_CONSTRUCT()
b2640405e06105d868b5fc8f7b676bb680884380vboxsync
b2640405e06105d868b5fc8f7b676bb680884380vboxsync BEGIN_COM_MAP(Display)
b2640405e06105d868b5fc8f7b676bb680884380vboxsync COM_INTERFACE_ENTRY(ISupportErrorInfo)
b2640405e06105d868b5fc8f7b676bb680884380vboxsync COM_INTERFACE_ENTRY(IDisplay)
b2640405e06105d868b5fc8f7b676bb680884380vboxsync END_COM_MAP()
b2640405e06105d868b5fc8f7b676bb680884380vboxsync
bda3dd52e256c637c703aecf163ecc5b682a43a4vboxsync NS_DECL_ISUPPORTS
b2640405e06105d868b5fc8f7b676bb680884380vboxsync
b2640405e06105d868b5fc8f7b676bb680884380vboxsync HRESULT FinalConstruct();
8ad79874169cc981a694a15e8a806b9a39133673vboxsync void FinalRelease();
b2640405e06105d868b5fc8f7b676bb680884380vboxsync
b2640405e06105d868b5fc8f7b676bb680884380vboxsync // public initializer/uninitializer for internal purposes only
b2640405e06105d868b5fc8f7b676bb680884380vboxsync HRESULT init (Console *parent);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync void uninit();
b2640405e06105d868b5fc8f7b676bb680884380vboxsync
b2640405e06105d868b5fc8f7b676bb680884380vboxsync // public methods only for internal purposes
b2640405e06105d868b5fc8f7b676bb680884380vboxsync void handleDisplayResize (uint32_t bpp, void *pvVRAM, uint32_t cbLine, int w, int h);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync void handleDisplayUpdate (int x, int y, int cx, int cy);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync IFramebuffer *getFramebuffer()
b2640405e06105d868b5fc8f7b676bb680884380vboxsync {
b2640405e06105d868b5fc8f7b676bb680884380vboxsync return mFramebuffer;
b2640405e06105d868b5fc8f7b676bb680884380vboxsync }
b2640405e06105d868b5fc8f7b676bb680884380vboxsync
b2640405e06105d868b5fc8f7b676bb680884380vboxsync int VideoAccelEnable (bool fEnable, VBVAMEMORY *pVbvaMemory);
8ad79874169cc981a694a15e8a806b9a39133673vboxsync void VideoAccelFlush (void);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync
a57b3586d0f1a87e0024e318f3c8dad382113611vboxsync bool VideoAccelAllowed (void);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync
a57b3586d0f1a87e0024e318f3c8dad382113611vboxsync#ifdef VBOX_VRDP
b2640405e06105d868b5fc8f7b676bb680884380vboxsync#ifdef VRDP_MC
b2640405e06105d868b5fc8f7b676bb680884380vboxsync void VideoAccelVRDP (bool fEnable);
8ad79874169cc981a694a15e8a806b9a39133673vboxsync#else
a57b3586d0f1a87e0024e318f3c8dad382113611vboxsync void VideoAccelVRDP (bool fEnable, uint32_t fu32SupportedOrders);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync#endif /* VRDP_MC */
b2640405e06105d868b5fc8f7b676bb680884380vboxsync#endif /* VBOX_VRDP */
b2640405e06105d868b5fc8f7b676bb680884380vboxsync
b2640405e06105d868b5fc8f7b676bb680884380vboxsync /* IConsoleCallback methods */
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(OnMousePointerShapeChange)(BOOL visible, BOOL alpha, ULONG xHot, ULONG yHot, ULONG width, ULONG height, ULONG shape)
a57b3586d0f1a87e0024e318f3c8dad382113611vboxsync {
b2640405e06105d868b5fc8f7b676bb680884380vboxsync return S_OK;
b2640405e06105d868b5fc8f7b676bb680884380vboxsync }
b2640405e06105d868b5fc8f7b676bb680884380vboxsync
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(OnMouseCapabilityChange)(BOOL supportsAbsolute, BOOL needsHostCursor)
b2640405e06105d868b5fc8f7b676bb680884380vboxsync {
b2640405e06105d868b5fc8f7b676bb680884380vboxsync return S_OK;
b2640405e06105d868b5fc8f7b676bb680884380vboxsync }
b2640405e06105d868b5fc8f7b676bb680884380vboxsync
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(OnStateChange)(MachineState_T machineState);
8ad79874169cc981a694a15e8a806b9a39133673vboxsync
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(OnAdditionsStateChange)()
b2640405e06105d868b5fc8f7b676bb680884380vboxsync {
b2640405e06105d868b5fc8f7b676bb680884380vboxsync return S_OK;
b2640405e06105d868b5fc8f7b676bb680884380vboxsync }
b2640405e06105d868b5fc8f7b676bb680884380vboxsync
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(OnKeyboardLedsChange)(BOOL fNumLock, BOOL fCapsLock, BOOL fScrollLock)
b2640405e06105d868b5fc8f7b676bb680884380vboxsync {
b2640405e06105d868b5fc8f7b676bb680884380vboxsync return S_OK;
b2640405e06105d868b5fc8f7b676bb680884380vboxsync }
b2640405e06105d868b5fc8f7b676bb680884380vboxsync
8ad79874169cc981a694a15e8a806b9a39133673vboxsync STDMETHOD(OnRuntimeError)(BOOL fatal, INPTR BSTR id, INPTR BSTR message)
b2640405e06105d868b5fc8f7b676bb680884380vboxsync {
cf2d13234ccc8755e2610badbdab5dc0b7bfb1dcvboxsync return S_OK;
cf2d13234ccc8755e2610badbdab5dc0b7bfb1dcvboxsync }
b2640405e06105d868b5fc8f7b676bb680884380vboxsync
b2640405e06105d868b5fc8f7b676bb680884380vboxsync // IDisplay properties
a57b3586d0f1a87e0024e318f3c8dad382113611vboxsync STDMETHOD(COMGETTER(Width)) (ULONG *width);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(COMGETTER(Height)) (ULONG *height);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(COMGETTER(ColorDepth)) (ULONG *colorDepth);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync
b2640405e06105d868b5fc8f7b676bb680884380vboxsync // IDisplay methods
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(SetupInternalFramebuffer)(ULONG depth);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(LockFramebuffer)(ULONG *address);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(UnlockFramebuffer)();
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(RegisterExternalFramebuffer)(IFramebuffer *frameBuf);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(SetVideoModeHint)(ULONG width, ULONG height, ULONG colorDepth);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(TakeScreenShot)(ULONG address, ULONG width, ULONG height);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(DrawToScreen)(ULONG address, ULONG x, ULONG y, ULONG width, ULONG height);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(InvalidateAndUpdate)();
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(ResizeCompleted)();
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(UpdateCompleted)();
b2640405e06105d868b5fc8f7b676bb680884380vboxsync
a57b3586d0f1a87e0024e318f3c8dad382113611vboxsync // for VirtualBoxSupportErrorInfoImpl
b2640405e06105d868b5fc8f7b676bb680884380vboxsync static const wchar_t *getComponentName() { return L"Display"; }
b2640405e06105d868b5fc8f7b676bb680884380vboxsync
b2640405e06105d868b5fc8f7b676bb680884380vboxsync static const PDMDRVREG DrvReg;
b2640405e06105d868b5fc8f7b676bb680884380vboxsync
b2640405e06105d868b5fc8f7b676bb680884380vboxsyncprivate:
b2640405e06105d868b5fc8f7b676bb680884380vboxsync
b2640405e06105d868b5fc8f7b676bb680884380vboxsync void updateDisplayData (bool aCheckParams = false);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync
b2640405e06105d868b5fc8f7b676bb680884380vboxsync static DECLCALLBACK(int) changeFramebuffer (Display *that, IFramebuffer *aFB,
b2640405e06105d868b5fc8f7b676bb680884380vboxsync bool aInternal);
8ad79874169cc981a694a15e8a806b9a39133673vboxsync
2b9f3669ba8ae44c1791107537a3b5995aee29a3vboxsync static DECLCALLBACK(void*) drvQueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync static DECLCALLBACK(int) drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync static DECLCALLBACK(void) displayResizeCallback(PPDMIDISPLAYCONNECTOR pInterface, uint32_t bpp, void *pvVRAM, uint32_t cbLine, uint32_t cx, uint32_t cy);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync static DECLCALLBACK(void) displayUpdateCallback(PPDMIDISPLAYCONNECTOR pInterface,
b2640405e06105d868b5fc8f7b676bb680884380vboxsync uint32_t x, uint32_t y, uint32_t cx, uint32_t cy);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync static DECLCALLBACK(void) displayRefreshCallback(PPDMIDISPLAYCONNECTOR pInterface);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync static DECLCALLBACK(void) displayResetCallback(PPDMIDISPLAYCONNECTOR pInterface);
8ad79874169cc981a694a15e8a806b9a39133673vboxsync static DECLCALLBACK(void) displayLFBModeChangeCallback(PPDMIDISPLAYCONNECTOR pInterface, bool fEnabled);
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync ComObjPtr <Console, ComWeakRef> mParent;
cf2d13234ccc8755e2610badbdab5dc0b7bfb1dcvboxsync /** Pointer to the associated display driver. */
b2640405e06105d868b5fc8f7b676bb680884380vboxsync struct DRVMAINDISPLAY *mpDrv;
b2640405e06105d868b5fc8f7b676bb680884380vboxsync /** Pointer to the device instance for the VMM Device. */
b2640405e06105d868b5fc8f7b676bb680884380vboxsync PPDMDEVINS mpVMMDev;
b2640405e06105d868b5fc8f7b676bb680884380vboxsync /** Set after the first attempt to find the VMM Device. */
8ad79874169cc981a694a15e8a806b9a39133673vboxsync bool mfVMMDevInited;
b2640405e06105d868b5fc8f7b676bb680884380vboxsync bool mInternalFramebuffer;
b2640405e06105d868b5fc8f7b676bb680884380vboxsync ComPtr<IFramebuffer> mFramebuffer;
b2640405e06105d868b5fc8f7b676bb680884380vboxsync bool mFramebufferOpened;
b2640405e06105d868b5fc8f7b676bb680884380vboxsync /** bitmask of acceleration operations supported by current framebuffer */
8ad79874169cc981a694a15e8a806b9a39133673vboxsync ULONG mSupportedAccelOps;
cf2d13234ccc8755e2610badbdab5dc0b7bfb1dcvboxsync RTSEMEVENTMULTI mResizeSem;
b2640405e06105d868b5fc8f7b676bb680884380vboxsync RTSEMEVENTMULTI mUpdateSem;
b2640405e06105d868b5fc8f7b676bb680884380vboxsync
b2640405e06105d868b5fc8f7b676bb680884380vboxsync /* arguments of the last handleDisplayResize() call */
b2640405e06105d868b5fc8f7b676bb680884380vboxsync void *mLastAddress;
8ad79874169cc981a694a15e8a806b9a39133673vboxsync uint32_t mLastLineSize;
b2640405e06105d868b5fc8f7b676bb680884380vboxsync uint32_t mLastColorDepth;
b2640405e06105d868b5fc8f7b676bb680884380vboxsync int mLastWidth;
2347f07aa55c4c0035118a2a1634e5187a3ffdf4vboxsync int mLastHeight;
eb4f1fa4c357485330370c0eaba27e5a2af7d9c4vboxsync
b2640405e06105d868b5fc8f7b676bb680884380vboxsync VBVAMEMORY *mpVbvaMemory;
8ad79874169cc981a694a15e8a806b9a39133673vboxsync bool mfVideoAccelEnabled;
b2640405e06105d868b5fc8f7b676bb680884380vboxsync bool mfVideoAccelVRDP;
b2640405e06105d868b5fc8f7b676bb680884380vboxsync uint32_t mfu32SupportedOrders;
8ad79874169cc981a694a15e8a806b9a39133673vboxsync
b2640405e06105d868b5fc8f7b676bb680884380vboxsync int32_t volatile mcVideoAccelVRDPRefs;
083344b49cc7370da15d3cb7e3a9c9cb2d8dfbb0vboxsync
083344b49cc7370da15d3cb7e3a9c9cb2d8dfbb0vboxsync VBVAMEMORY *mpPendingVbvaMemory;
083344b49cc7370da15d3cb7e3a9c9cb2d8dfbb0vboxsync bool mfPendingVideoAccelEnable;
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync bool mfMachineRunning;
083344b49cc7370da15d3cb7e3a9c9cb2d8dfbb0vboxsync
8ad79874169cc981a694a15e8a806b9a39133673vboxsync uint8_t *mpu8VbvaPartial;
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync uint32_t mcbVbvaPartial;
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync
cf2d13234ccc8755e2610badbdab5dc0b7bfb1dcvboxsync bool vbvaFetchCmd (VBVACMDHDR **ppHdr, uint32_t *pcbCmd);
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync void vbvaReleaseCmd (VBVACMDHDR *pHdr, int32_t cbCmd);
cf2d13234ccc8755e2610badbdab5dc0b7bfb1dcvboxsync
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync void callFramebufferResize (FramebufferPixelFormat_T pixelFormat, void *pvVRAM, uint32_t cbLine, int w, int h);
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync};
cf2d13234ccc8755e2610badbdab5dc0b7bfb1dcvboxsync
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync#endif // ____H_DISPLAYIMPL
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync