Framebuffer.cpp revision 178020c30cf77bb39f38497c6efe5dd41193db56
7cbae22b7560eefcf086863923459880aa87f014Jaco Jooste * VBox frontends: VBoxSDL (simple frontend based on SDL):
7cbae22b7560eefcf086863923459880aa87f014Jaco Jooste * Implementation of VBoxSDLFB (SDL framebuffer) class
7cbae22b7560eefcf086863923459880aa87f014Jaco Jooste * Copyright (C) 2006-2007 innotek GmbH
7cbae22b7560eefcf086863923459880aa87f014Jaco Jooste * This file is part of VirtualBox Open Source Edition (OSE), as
7cbae22b7560eefcf086863923459880aa87f014Jaco Jooste * available from http://www.virtualbox.org. This file is free software;
7cbae22b7560eefcf086863923459880aa87f014Jaco Jooste * you can redistribute it and/or modify it under the terms of the GNU
7cbae22b7560eefcf086863923459880aa87f014Jaco Jooste * General Public License as published by the Free Software Foundation,
7cbae22b7560eefcf086863923459880aa87f014Jaco Jooste * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
7cbae22b7560eefcf086863923459880aa87f014Jaco Jooste * distribution. VirtualBox OSE is distributed in the hope that it will
7cbae22b7560eefcf086863923459880aa87f014Jaco Jooste * be useful, but WITHOUT ANY WARRANTY of any kind.
7cbae22b7560eefcf086863923459880aa87f014Jaco Jooste * If you received this file as part of a commercial VirtualBox
7cbae22b7560eefcf086863923459880aa87f014Jaco Jooste * distribution, then only the terms of your commercial VirtualBox
7cbae22b7560eefcf086863923459880aa87f014Jaco Jooste * license agreement apply instead of the previous paragraph.
7cbae22b7560eefcf086863923459880aa87f014Jaco Joosteusing namespace com;
c423fd5d4f121413c5e72c134412b6ce5daa0dd9Jaco JoosteNS_IMPL_ISUPPORTS1_CI(VBoxSDLFBOverlay, IFramebufferOverlay)
c423fd5d4f121413c5e72c134412b6ce5daa0dd9Jaco Jooste/* function pointers */
c423fd5d4f121413c5e72c134412b6ce5daa0dd9Jaco JoosteDECLSPEC TTF_Font* (SDLCALL *pTTF_OpenFont)(const char *file, int ptsize);
c423fd5d4f121413c5e72c134412b6ce5daa0dd9Jaco JoosteDECLSPEC SDL_Surface* (SDLCALL *pTTF_RenderUTF8_Solid)(TTF_Font *font, const char *text, SDL_Color fg);
c423fd5d4f121413c5e72c134412b6ce5daa0dd9Jaco JoosteDECLSPEC void (SDLCALL *pTTF_CloseFont)(TTF_Font *font);
7cbae22b7560eefcf086863923459880aa87f014Jaco Jooste#endif /* VBOX_SECURELABEL */
7436da7252e66e7a698239a5c6b9ca04df24179aPhill Cunnington// Constructor / destructor
7436da7252e66e7a698239a5c6b9ca04df24179aPhill Cunnington * SDL framebuffer constructor. It is called from the main
7436da7252e66e7a698239a5c6b9ca04df24179aPhill Cunnington * (i.e. SDL) thread. Therefore it is safe to use SDL calls
7436da7252e66e7a698239a5c6b9ca04df24179aPhill Cunnington * @param fFullscreen flag whether we start in fullscreen mode
7cbae22b7560eefcf086863923459880aa87f014Jaco Jooste * @param fResizable flag whether the SDL window should be resizable
7436da7252e66e7a698239a5c6b9ca04df24179aPhill Cunnington * @param fShowSDLConfig flag whether we print out SDL settings
7436da7252e66e7a698239a5c6b9ca04df24179aPhill Cunnington * @param iFixedWidth fixed SDL width (-1 means not set)
7436da7252e66e7a698239a5c6b9ca04df24179aPhill Cunnington * @param iFixedHeight fixed SDL height (-1 means not set)
7436da7252e66e7a698239a5c6b9ca04df24179aPhill CunningtonVBoxSDLFB::VBoxSDLFB(bool fFullscreen, bool fResizable, bool fShowSDLConfig,
7436da7252e66e7a698239a5c6b9ca04df24179aPhill Cunnington uint32_t u32FixedWidth, uint32_t u32FixedHeight, uint32_t u32FixedBPP)
7436da7252e66e7a698239a5c6b9ca04df24179aPhill Cunnington /* Start with standard screen dimensions. */
7436da7252e66e7a698239a5c6b9ca04df24179aPhill Cunnington mPixelFormat = FramebufferPixelFormat_PixelFormatDefault;
#ifdef VBOX_SECURELABEL
mLabelHeight = 0;
#ifdef __WIN__
#ifdef __LINUX__
if (rc != 0)
#ifdef __LINUX__
if (videoInfo)
if (mfShowSDLConfig)
if (mWMIcon)
resizeGuest();
mfInitialized = true;
if (!width)
return E_INVALIDARG;
return S_OK;
if (!height)
return E_INVALIDARG;
return S_OK;
return S_OK;
return S_OK;
if (!address)
return E_INVALIDARG;
if (mSurfVRAM)
return E_FAIL;
return S_OK;
if (!colorDepth)
return E_INVALIDARG;
return S_OK;
if (!lineSize)
return E_INVALIDARG;
return S_OK;
if (!pixelFormat)
return E_POINTER;
return S_OK;
if (!heightReduction)
return E_POINTER;
#ifdef VBOX_SECURELABEL
*heightReduction = 0;
return S_OK;
if (!aOverlay)
return E_POINTER;
*aOverlay = 0;
return S_OK;
#ifdef __LINUX__
if (finished)
return S_OK;
STDMETHODIMP VBoxSDLFB::RequestResize(ULONG aScreenId, FramebufferPixelFormat_T pixelFormat, BYTE *vram,
if (!finished)
return E_FAIL;
mGuestXRes = w;
mGuestYRes = h;
*finished = false;
return S_OK;
STDMETHODIMP VBoxSDLFB::OperationSupported(FramebufferAccelerationOperation_T operation, BOOL *supported)
if (!supported)
return E_POINTER;
*supported = false;
switch (operation)
*supported = true;
*supported = true;
*supported = false;
return S_OK;
if (!supported)
return E_POINTER;
#ifdef DEBUG
*supported = false;
*supported = true;
return S_OK;
if (!handled)
return E_POINTER;
*handled = true;
*handled = false;
return S_OK;
if (!handled)
return E_POINTER;
*handled = true;
*handled = false;
return S_OK;
switch (cBitsPerPixel)
if (mSurfVRAM)
resizeSDL();
if (mfResizable)
if (mfFullscreen)
/* Get available fullscreen/hardware modes */
mCenterXOffset = 0;
mCenterYOffset = 0;
#ifdef VBOX_SECURELABEL
mTopOffset = 0;
#ifdef VBOX_SECURELABEL
if (!mScreen)
if (mScreen)
#ifdef VBOX_WIN32_UI
if (mfShowSDLConfig)
repaint();
#ifdef __LINUX__
int yCutoffGuest = 0;
#ifdef VBOX_SECURELABEL
bool fPaintLabel = false;
if (y < (int)mLabelHeight)
if (!fGuestRelative)
#ifdef VBOX_SECURELABEL
if (y < (int)mLabelHeight)
fPaintLabel = true;
w = mGuestXRes;
h = mGuestYRes;
srcRect.x = x;
srcRect.w = w;
#ifdef VBOX_SECURELABEL
dstRect.w = w;
//RTPrintf("y = %d h = %d mapped to srcY %d srcH %d mapped to dstY = %d dstH %d (guestrel: %d, mLabelHeight: %d, mTopOffset: %d)\n",
#ifdef VBOX_SECURELABEL
if (fPaintLabel)
paintSecureLabel(0, 0, 0, 0, false);
return mfFullscreen;
resizeSDL();
return mCenterXOffset;
#ifdef VBOX_SECURELABEL
pTTF_Init();
if (!mLabelFont)
return VERR_OPEN_FAILED;
repaint();
return VINF_SUCCESS;
paintSecureLabel(0, 0, 0, 0, true);
paintSecureLabel(0, 0, 0, 0, true);
#ifdef __LINUX__
if (!pTTF_RenderUTF8_Solid)
if (mSurfVRAM)
#ifdef VBOX_SECURELABEL
if (mLabelFont)
if (pTTF_Quit)
pTTF_Quit();
if (mWMIcon)
return S_OK;
return E_INVALIDARG;
*x = mOverlayX;
return S_OK;
return E_INVALIDARG;
*y = mOverlayY;
return S_OK;
if (!width)
return E_INVALIDARG;
return S_OK;
if (!lineSize)
return E_INVALIDARG;
return S_OK;
if (!height)
return E_INVALIDARG;
return S_OK;
if (!visible)
return E_INVALIDARG;
return S_OK;
return S_OK;
return E_NOTIMPL;
return E_NOTIMPL;
if (!address)
return E_INVALIDARG;
return S_OK;
if (!colorDepth)
return E_INVALIDARG;
return S_OK;
if (!pixelFormat)
return E_INVALIDARG;
return S_OK;
if (!heightReduction)
return E_INVALIDARG;
*heightReduction = 0;
return S_OK;
if (!aOverlay)
return E_INVALIDARG;
*aOverlay = 0;
return S_OK;
return E_NOTIMPL;
return E_NOTIMPL;
mOverlayX = x;
mOverlayY = y;
return S_OK;
mOverlayWidth = w;
mOverlayHeight = h;
return S_OK;
if (!supported)
return E_POINTER;
*supported = false;
return S_OK;
if (!supported)
return E_POINTER;
*supported = true;
*supported = false;
return S_OK;
if (!handled)
return E_POINTER;
*handled = false;
return S_OK;
if (!handled)
return E_POINTER;
*handled = false;
return S_OK;