VBoxGuestR3LibVideo.cpp revision 2b4afb8fb52455af86dd07f49409085babff82e6
/* $Id$ */
/** @file
* VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, Video.
*/
/*
* Copyright (C) 2007-2012 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.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "VBGLR3Internal.h"
#if !defined(VBOX_VBGLR3_XFREE86) && !defined(VBOX_VBGLR3_XORG)
#endif
#include <stdio.h>
#ifdef VBOX_VBGLR3_XFREE86
/* Rather than try to resolve all the header file conflicts, I will just
prototype what we need here. */
# define memcpy xf86memcpy
# define memset xf86memset
#endif /* VBOX_VBGLR3_XFREE86 */
#define VIDEO_PROP_PREFIX "/VirtualBox/GuestAdd/Vbgl/Video/"
/**
* Enable or disable video acceleration.
*
* @returns VBox status code.
*
* @param fEnable Pass zero to disable, any other value to enable.
*/
{
Req.fu32Status = 0;
}
/**
* Flush the video buffer.
*
* @returns VBox status code.
*/
VBGLR3DECL(int) VbglR3VideoAccelFlush(void)
{
}
/**
* Send mouse pointer shape information to the host.
*
* @returns VBox status code.
*
* @param fFlags Mouse pointer flags.
* @param xHot X coordinate of hot spot.
* @param yHot Y coordinate of hot spot.
* @param cx Pointer width.
* @param cy Pointer height.
* @param pvImg Pointer to the image data (can be NULL).
* @param cbImg Size of the image data pointed to by pvImg.
*/
VBGLR3DECL(int) VbglR3SetPointerShape(uint32_t fFlags, uint32_t xHot, uint32_t yHot, uint32_t cx, uint32_t cy, const void *pvImg, size_t cbImg)
{
if (RT_SUCCESS(rc))
{
if (pvImg)
if (RT_SUCCESS(rc))
}
return rc;
}
/**
* Send mouse pointer shape information to the host.
* This version of the function accepts a request for clients that
* already allocate and manipulate the request structure directly.
*
* @returns VBox status code.
*
* @param pReq Pointer to the VMMDevReqMousePointer structure.
*/
{
if (RT_SUCCESS(rc))
return rc;
}
/**
* Query the last display change request sent from the host to the guest.
*
* @returns iprt status value
* @param pcx Where to store the horizontal pixel resolution
* @param pcy Where to store the vertical pixel resolution
* requested (a value of zero means do not change).
* @param pcBits Where to store the bits per pixel requested (a value
* of zero means do not change).
* @param iDisplay Where to store the display number the request was for
* - 0 for the primary display, 1 for the first
* secondary display, etc.
* @param fAck whether or not to acknowledge the newest request sent by
* the host. If this is set, the function will return the
* most recent host request, otherwise it will return the
* last request to be acknowledged.
*
*/
bool fAck)
{
if (fAck)
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
{
}
return rc;
}
/**
* Query the last display change request sent from the host to the guest.
*
* @returns iprt status value
* @param pcx Where to store the horizontal pixel resolution
* requested (a value of zero means do not change).
* @param pcy Where to store the vertical pixel resolution
* requested (a value of zero means do not change).
* @param pcBits Where to store the bits per pixel requested (a value
* of zero means do not change).
* @param piDisplay Where to store the display number the request was for
* - 0 for the primary display, 1 for the first
* secondary display, etc.
* @param fAck whether or not to acknowledge the newest request sent by
* the host. If this is set, the function will return the
* most recent host request, otherwise it will return the
* last request to be acknowledged.
*
* @param pdx New horizontal position of the secondary monitor.
* Optional.
* @param pdy New vertical position of the secondary monitor.
* Optional.
* param pfEnabled Secondary monitor is enabled or not.
* Optional.
* param pfChangeOrigin Whether the mode hint retrieved included information
* Optional.
*
*/
bool *pfEnabled,
bool *pfChangeOrigin,
bool fAck)
{
int rc = VINF_SUCCESS;
if (fAck)
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
{
if (pdx)
if (pdy)
if (pfEnabled)
if (pfChangeOrigin)
}
/* NEEDS TESTING: test below with current Additions on VBox 4.1 or older. */
/** @todo Can we find some standard grep-able string for "NEEDS TESTING"? */
{
if (pfEnabled)
*pfEnabled = true;
if (pfChangeOrigin)
*pfChangeOrigin = false;
}
return rc;
}
/**
* Query the host as to whether it likes a specific video mode.
*
* @returns the result of the query
* @param cx the width of the mode being queried
* @param cy the height of the mode being queried
* @param cBits the bpp of the mode being queried
*/
{
bool fRc = true; /* If for some reason we can't contact the host then
* we like everything. */
int rc;
req.fSupported = true;
return fRc;
}
/**
* Get the highest screen number for which there is a saved video mode or "0"
* if there are no saved modes.
*
* @returns iprt status value
* @returns VERR_NOT_SUPPORTED if the guest property service is not available.
* @param pcScreen where to store the virtual screen number
*/
{
#if defined(VBOX_WITH_GUEST_PROPS)
using namespace guestProp;
uint32_t u32ClientId = 0;
const char *pszName;
unsigned cHighestScreen = 0;
if (RT_SUCCESS(rc))
if (u32ClientId != 0)
if (RT_SUCCESS(rc))
{
&cScreen);
}
if (RT_SUCCESS(rc))
return rc;
#else /* !VBOX_WITH_GUEST_PROPS */
return VERR_NOT_SUPPORTED;
#endif /* !VBOX_WITH_GUEST_PROPS */
}
/**
* Save video mode parameters to the guest property store.
*
* @returns iprt status value
* @param cScreen virtual screen number
* @param cx mode width
* @param cy mode height
* @param cBits bits per pixel for the mode
* @param x virtual screen X offset
* @param y virtual screen Y offset
* @param fEnabled is this virtual screen enabled?
*/
unsigned cBits, unsigned x, unsigned y,
bool fEnabled)
{
#if defined(VBOX_WITH_GUEST_PROPS)
using namespace guestProp;
char szModeName[MAX_NAME_LEN];
char szModeParms[MAX_VALUE_LEN];
uint32_t u32ClientId = 0;
bool fEnabled2;
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
{
/* Write out the mode using the legacy name too, in case the user
* re-installs older Additions. */
if (cScreen == 0)
{
cBits);
}
}
if (u32ClientId != 0)
if (RT_SUCCESS(rc))
/* Sanity check 1. We do not try to make allowance for someone else
* changing saved settings at the same time as us. */
if (RT_SUCCESS(rc))
{
&fEnabled2);
if ( RT_SUCCESS(rc)
}
/* Sanity check 2. Same comment. */
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
return rc;
#else /* !VBOX_WITH_GUEST_PROPS */
return VERR_NOT_SUPPORTED;
#endif /* !VBOX_WITH_GUEST_PROPS */
}
/**
* Retrieve video mode parameters from the guest property store.
*
* @returns iprt status value
* @param cScreen the virtual screen number
* @param pcx where to store the mode width
* @param pcy where to store the mode height
* @param pcBits where to store the bits per pixel for the mode
* @param px where to store the virtual screen X offset
* @param py where to store the virtual screen Y offset
* @param pfEnabled where to store whether this virtual screen is enabled
*/
unsigned *pcBits,
bool *pfEnabled)
{
#if defined(VBOX_WITH_GUEST_PROPS)
using namespace guestProp;
/*
* First we retrieve the video mode which is saved as a string in the
* guest property store.
*/
/* The buffer for VbglR3GuestPropReadValue. If this is too small then
* something is wrong with the data stored in the property. */
char szModeName[MAX_NAME_LEN];
char szModeParms[1024];
uint32_t u32ClientId = 0;
int cMatches;
unsigned x = 0;
unsigned y = 0;
unsigned fEnabled = 1;
int rc;
int rc2 = VERR_UNRESOLVED_ERROR;
/** @todo add a VbglR3GuestPropReadValueF/FV that does the RTStrPrintf for you. */
if (RT_SUCCESS(rc))
{
sizeof(szModeParms), NULL);
/* Try legacy single screen name. */
VIDEO_PROP_PREFIX"SavedMode",
szModeParms, sizeof(szModeParms),
NULL);
}
if (u32ClientId != 0)
if (RT_SUCCESS(rc))
/*
* Now we convert the string returned to numeric values.
*/
if (RT_SUCCESS(rc))
{
rc = VINF_SUCCESS;
else if (cMatches < 0)
else
}
/*
* And clean up and return the values if we successfully obtained them.
*/
if (RT_SUCCESS(rc))
{
if (pcx)
if (pcy)
if (pcBits)
if (px)
*px = x;
if (py)
*py = y;
if (pfEnabled)
}
return rc;
#else /* !VBOX_WITH_GUEST_PROPS */
return VERR_NOT_SUPPORTED;
#endif /* !VBOX_WITH_GUEST_PROPS */
}