VBoxFrameBuffer.h revision b9042bb7a5efd07d617a8a7d812b669d75682779
/** @file
*
* VBox frontends: Qt GUI ("VirtualBox"):
* VBoxFrameBuffer class and subclasses declarations
*/
/*
* Copyright (C) 2006 InnoTek Systemberatung GmbH
*
* 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 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.
*
* If you received this file as part of a commercial VirtualBox
* distribution, then only the terms of your commercial VirtualBox
* license agreement apply instead of the previous paragraph.
*/
#ifndef __VBoxFrameBuffer_h__
#define __VBoxFrameBuffer_h__
#include "COMDefs.h"
#include <qmutex.h>
#include <qevent.h>
#include <qpixmap.h>
#include <qimage.h>
#if defined (VBOX_GUI_USE_SDL)
#include <SDL.h>
#include <signal.h>
#endif
#if defined (Q_WS_WIN) && defined (VBOX_GUI_USE_DDRAW)
#include <ddraw.h>
#endif
//#define VBOX_GUI_FRAMEBUF_STAT
#if defined (VBOX_GUI_DEBUG) && defined (VBOX_GUI_FRAMEBUF_STAT)
#define FRAMEBUF_DEBUG_START(prefix) \
#define FRAMEBUF_DEBUG_STOP(prefix,w,h) { \
V_DEBUG(( "Last update: %04d x %04d px, %03.3f ms, %.0f ticks", \
(w), (h), \
)); \
}
#else
#define FRAMEBUF_DEBUG_START(prefix) {}
#define FRAMEBUF_DEBUG_STOP(prefix,w,h) {}
#endif
/////////////////////////////////////////////////////////////////////////////
/**
* Frame buffer resize event.
*/
{
VBoxResizeEvent (FramebufferPixelFormat_T f, void *v, unsigned l, int w, int h) :
void *vr;
unsigned lsz;
int wdt;
int hgt;
};
/**
* Frame buffer repaint event.
*/
{
VBoxRepaintEvent (int x, int y, int w, int h) :
{}
int x() { return ex; }
int y() { return ey; }
};
/////////////////////////////////////////////////////////////////////////////
#if defined (VBOX_GUI_USE_REFRESH_TIMER)
/**
* Copies the current VM video buffer contents to the pixmap referenced
* by the argument. The return value indicates whether the
* buffer has been updated since the last call to this method or not.
*
* The copy operation is atomic (guarded by a mutex).
*
* This method is intentionally inlined for faster execution and should be
* called only by VBoxConsoleView members.
*
* @return true if the pixmap is updated, and false otherwise.
*/
{
0, 0, QImage::LittleEndian));
return rc;
}
#endif
/////////////////////////////////////////////////////////////////////////////
/**
* Common IFramebuffer implementation for all methods used by GUI to maintain
* the VM display video memory.
*
* Note that although this class can be called from multiple threads
* (in particular, the GUI thread and EMT) it doesn't protect access to every
* data field using its mutex lock. This is because all synchronization between
* the GUI and the EMT thread is supposed to be done using the
* IFramebuffer::NotifyUpdate() and IFramebuffer::RequestResize() methods
* (in particular, the \a aFinished parameter of these methods is responsible
* for the synchronization). These methods are always called on EMT and
* therefore always follow one another but never in parallel.
*
* Using this object's mutex lock (exposed also in IFramebuffer::Lock() and
* IFramebuffer::Unlock() implementations) usually makes sense only if some
* third-party thread (i.e. other than GUI or EMT) needs to make sure that
* *no* VM display update or resize event can occur while it is accessing
* IFramebuffer properties or the underlying display memory storage area.
*
* See IFramebuffer documentation for more info.
*/
{
#if defined (Q_OS_WIN32)
return ::InterlockedIncrement (&refcnt);
}
{
if (cnt == 0)
return cnt;
}
{
if (riid == IID_IUnknown) {
AddRef();
return S_OK;
}
if (riid == IID_IFramebuffer) {
AddRef();
return S_OK;
}
return E_NOINTERFACE;
}
#endif
// IFramebuffer COM methods
BOOL *aSupported);
BOOL *aSupported);
// Helper functions
{
}
virtual int colorDepth() = 0;
/**
* Called on the GUI thread (from VBoxConsoleView) when some part of the
* VM display viewport needs to be repainted on the host screen.
*/
/**
* Called on the GUI thread (from VBoxConsoleView) after it gets a
* VBoxResizeEvent posted from the RequestResize() method implementation.
*/
{
}
/**
* Called on the GUI thread (from VBoxConsoleView) when the VM console
* window is moved.
*/
int mWdt;
int mHgt;
#if defined (Q_OS_WIN32)
long refcnt;
#endif
};
/////////////////////////////////////////////////////////////////////////////
#if defined (VBOX_GUI_USE_QIMAGE)
{
};
#endif
/////////////////////////////////////////////////////////////////////////////
#if defined (VBOX_GUI_USE_SDL)
{
{
if (mSurfVRAM)
{
}
else
{
}
}
int colorDepth()
{
}
int lineSize()
{
}
{
return mPixelFormat;
}
void *mPtrVRAM;
};
#endif
/////////////////////////////////////////////////////////////////////////////
#if defined (VBOX_GUI_USE_DDRAW)
{
void releaseObjects();
void setupSurface (FramebufferPixelFormat_T pixelFormat, void *pvVRAM, ULONG lineSize, ULONG w, ULONG h);
void recreateSurface (FramebufferPixelFormat_T pixelFormat, void *pvVRAM, ULONG lineSize, ULONG w, ULONG h);
void deleteSurface ();
void getWindowPosition (void);
int mWndX;
int mWndY;
};
#endif
#endif // __VBoxFrameBuffer_h__