UIFrameBuffer.h revision 0bf057d00e68485e3f1eece5429b2f50d2f398eb
/** @file
* VBox Qt GUI - UIFrameBuffer class declaration.
*/
/*
* Copyright (C) 2010-2014 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#ifndef ___UIFrameBuffer_h___
#define ___UIFrameBuffer_h___
/* Qt includes: */
#include <QRegion>
#include <QImage>
/* GUI includes: */
#include "UIDefs.h"
#include "UIExtraDataDefs.h"
/* COM includes: */
#include "CDisplaySourceBitmap.h"
/* Other VBox includes: */
#include <iprt/critsect.h>
/* Forward declarations: */
/** Common IFramebuffer implementation used to maintain VM display video memory. */
{
/** Notifies listener about guest-screen resolution changes. */
/** Notifies listener about guest-screen updates. */
/** Notifies listener about guest-screen visible-region changes. */
/** Notifies listener about guest 3D capability changes. */
void sigNotifyAbout3DOverlayVisibilityChange(bool fVisible);
/** Frame-buffer constructor. */
/** Frame-buffer destructor. */
~UIFrameBuffer();
/** Frame-buffer initialization.
* @param pMachineView defines machine-view this frame-buffer is bounded to. */
/** Assigns machine-view frame-buffer will be bounded to.
* @param pMachineView defines machine-view this frame-buffer is bounded to. */
/** Defines whether frame-buffer is <b>unused</b>.
* @note Refer to m_fUnused for more information.
* @note Calls to this and any other EMT callback are synchronized (from GUI side). */
void setMarkAsUnused(bool fUnused);
/** Returns whether frame-buffer is <b>auto-enabled</b>.
* @note Refer to m_fAutoEnabled for more information. */
bool isAutoEnabled() const { return m_fAutoEnabled; }
/** Defines whether frame-buffer is <b>auto-enabled</b>.
* @note Refer to m_fAutoEnabled for more information. */
void FinalRelease();
/* IFramebuffer COM methods: */
/** EMT callback: Notifies frame-buffer about guest-screen size change.
* @param uScreenId Guest screen number.
* @param uX Horizontal origin of the update rectangle, in pixels.
* @param uY Vertical origin of the update rectangle, in pixels.
* @param uWidth Width of the guest display, in pixels.
* @param uHeight Height of the guest display, in pixels.
* @note Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
* @note Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
/** EMT callback: Notifies frame-buffer about guest-screen update.
* @param uX Horizontal origin of the update rectangle, in pixels.
* @param uY Vertical origin of the update rectangle, in pixels.
* @param uWidth Width of the update rectangle, in pixels.
* @param uHeight Height of the update rectangle, in pixels.
* @note Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
* @note Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
/** EMT callback which is not used in current implementation. */
STDMETHOD(NotifyUpdateImage)(ULONG uX, ULONG uY, ULONG uWidth, ULONG uHeight, ComSafeArrayIn(BYTE, image));
/** EMT callback: Returns whether the frame-buffer implementation is willing to support a given video-mode.
* @param uWidth Width of the guest display, in pixels.
* @param uHeight Height of the guest display, in pixels.
* @param uBPP Color depth, bits per pixel.
* @note Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
* @note Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
/** EMT callback which is not used in current implementation. */
/** EMT callback: Suggests new visible-region to this frame-buffer.
* @param pRectangles Pointer to the RTRECT array.
* @param uCount Number of RTRECT elements in the rectangles array.
* @note Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
* @note Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
/** EMT callback which is not used in current implementation. */
/** EMT callback: Notifies frame-buffer about 3D backend event.
* @param uType Event type. Currently only VBOX3D_NOTIFY_EVENT_TYPE_VISIBLE_3DDATA is supported.
* @param aData Event-specific data, depends on the supplied event type.
* @note Any EMT callback is subsequent. No any other EMT callback can be called until this one processed.
* @note Calls to this and #setMarkAsUnused method are synchronized (from GUI side). */
/** Returns frame-buffer data address. */
/** Returns frame-buffer width. */
/** Returns frame-buffer height. */
/** Returns frame-buffer bits-per-pixel value. */
/** Returns frame-buffer bytes-per-line value. */
/** Returns default frame-buffer pixel-format. */
/** Locks frame-buffer access. */
/** Unlocks frame-buffer access. */
/** Returns host-to-guest scale ratio. */
/** Defines host-to-guest scale ratio as @a size. */
/** Returns x-origin of the host (scaled) content corresponding to x-origin of guest (actual) content. */
inline int convertGuestXTo(int x) const { return m_scaledSize.isValid() ? qRound((double)m_scaledSize.width() / m_iWidth * x) : x; }
/** Returns y-origin of the host (scaled) content corresponding to y-origin of guest (actual) content. */
inline int convertGuestYTo(int y) const { return m_scaledSize.isValid() ? qRound((double)m_scaledSize.height() / m_iHeight * y) : y; }
/** Returns x-origin of the guest (actual) content corresponding to x-origin of host (scaled) content. */
inline int convertHostXTo(int x) const { return m_scaledSize.isValid() ? qRound((double)m_iWidth / m_scaledSize.width() * x) : x; }
/** Returns y-origin of the guest (actual) content corresponding to y-origin of host (scaled) content. */
inline int convertHostYTo(int y) const { return m_scaledSize.isValid() ? qRound((double)m_iHeight / m_scaledSize.height() * y) : y; }
/** Handles frame-buffer notify-change-event. */
/** Handles frame-buffer resize-event. */
/** Handles frame-buffer paint-event. */
/** Handles frame-buffer apply-visible-region-event. */
#ifdef VBOX_WITH_VIDEOHWACCEL
/** Performs Video HW Acceleration command. */
/** Handles viewport resize-event. */
/** Handles viewport scroll-event. */
#endif /* VBOX_WITH_VIDEOHWACCEL */
/** Return HiDPI frame-buffer optimization type. */
/** Define HiDPI frame-buffer optimization type: */
void setHiDPIOptimizationType(HiDPIOptimizationType optimizationType) { m_hiDPIOptimizationType = optimizationType; }
/** Return backing scale factor used by HiDPI frame-buffer. */
double backingScaleFactor() const { return m_dBackingScaleFactor; }
/** Define backing scale factor used by HiDPI frame-buffer. */
void setBackingScaleFactor(double dBackingScaleFactor) { m_dBackingScaleFactor = dBackingScaleFactor; }
/** Prepare connections routine. */
void prepareConnections();
/** Cleanup connections routine. */
void cleanupConnections();
/** Default paint routine. */
/** Paint routine for seamless mode. */
/** Paint routine for scaled mode. */
/** Draws corresponding @a rect of passed @a image with @a painter. */
int iContentsShiftX, int iContentsShiftY,
double dBackingScaleFactor);
/** Holds the QImage buffer. */
/** Holds frame-buffer width. */
int m_iWidth;
/** Holds frame-buffer height. */
int m_iHeight;
/** Source bitmap from IDisplay. */
/** Source bitmap from IDisplay (acquired but not yet applied). */
/** Holds machine-view this frame-buffer is bounded to. */
/** Holds window ID this frame-buffer referring to. */
/** Reflects whether screen-updates are allowed. */
bool m_fUpdatesAllowed;
/** Defines whether frame-buffer is <b>unused</b>.
* <b>Unused</b> status determines whether frame-buffer should ignore EMT events or not. */
bool m_fUnused;
/** Defines whether frame-buffer is <b>auto-enabled</b>.
* <b>Auto-enabled</b> status means that guest-screen corresponding to this frame-buffer
* was automatically enabled by the multi-screen layout (auto-mount guest-screen) functionality,
* so have potentially incorrect size-hint posted into guest event queue.
* Machine-view will try to automatically adjust guest-screen size as soon as possible. */
bool m_fAutoEnabled;
/** RTCRITSECT object to protect frame-buffer access. */
/** @name Scaled mode related variables.
* @{ */
/** Holds frame-buffer scaled size. */
/** @} */
/** @name Seamless mode related variables.
* @{ */
/* To avoid a seamless flicker which caused by the latency between
* the initial visible-region arriving from EMT thread
* and actual visible-region appliance on GUI thread
* it was decided to use two visible-region instances: */
/** Sync visible-region which being updated synchronously by locking EMT thread.
* Used for immediate manual clipping of the painting operations. */
/** Async visible-region which being updated asynchronously by posting async-event from EMT to GUI thread,
* Used to update viewport parts for visible-region changes,
* because NotifyUpdate doesn't take into account these changes. */
/** When the framebuffer is being resized, visible region is saved here.
* The saved region is applied when updates are enabled again. */
/** @} */
/** @name HiDPI screens related variables.
* @{ */
/** Holds HiDPI frame-buffer optimization type. */
/** Holds backing scale factor used by HiDPI frame-buffer. */
double m_dBackingScaleFactor;
/** @} */
#ifdef Q_OS_WIN
#endif /* Q_OS_WIN */
};
#endif /* !___UIFrameBuffer_h___ */