VBoxGuestR3LibVideo.cpp revision b0dfb334954c0552bb583967a3077ec88fd00471
9ad572a3ac0fd3845a9abecfbf41e8db9b3a5cf0vboxsync/* $Id$ */
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync/** @file
adf2bcd2e5d07d5a11553b88e147c1f4b2249bffvboxsync * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, Video.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync */
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync/*
c58f1213e628a545081c70e26c6b67a841cff880vboxsync * Copyright (C) 2007 innotek GmbH
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync *
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * available from http://www.virtualbox.org. This file is free software;
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * you can redistribute it and/or modify it under the terms of the GNU
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * General Public License (GPL) as published by the Free Software
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync */
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync/*******************************************************************************
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync* Header Files *
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync*******************************************************************************/
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync#include "VBGLR3Internal.h"
70bb61ea2f96e80150e807529ce5df435607706bvboxsync#include <iprt/string.h>
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync#include <iprt/mem.h>
23179f1443b03947d85eccc81cbc6b5153a4abf3vboxsync
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync/**
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * Enable or disable video acceleration.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync *
edefdc20eedaf9ef5b1293e56ba9b8cca7b5c740vboxsync * @returns VBox status code.
edefdc20eedaf9ef5b1293e56ba9b8cca7b5c740vboxsync *
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @param fEnable Pass zero to disable, any other value to enable.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync */
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsyncVBGLR3DECL(int) VbglR3VideoAccelEnable(uint32_t fEnable)
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync{
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync VMMDevVideoAccelEnable Req;
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync vmmdevInitRequest(&Req.header, VMMDevReq_VideoAccelEnable);
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync Req.u32Enable = fEnable;
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync Req.cbRingBuffer = VBVA_RING_BUFFER_SIZE;
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync Req.fu32Status = 0;
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync return vbglR3GRPerform(&Req.header);
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync}
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync/**
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * Flush the video buffer.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync *
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * @returns VBox status code.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync */
1147e980f6ab0b7ff1d08c13ad1c03eea30d102dvboxsyncVBGLR3DECL(int) VbglR3VideoAccelFlush(void)
e59069cf1c98c1c2e90a18ec76fbc2e9907fb917vboxsync{
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync VMMDevVideoAccelFlush Req;
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync vmmdevInitRequest(&Req.header, VMMDevReq_VideoAccelFlush);
b304856b23107864c9c594a80cebca6006623f31vboxsync return vbglR3GRPerform(&Req.header);
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync}
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync/**
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * Send mouse pointer shape information to the host.
8fdb854581fe3cb394d84835dc09b02e6e18d4edvboxsync *
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @returns VBox status code.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync *
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @param fFlags Mouse pointer flags.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @param xHot X coordinate of hot spot.
c33fc49611f2444dade533488bf431e29eb88bcdvboxsync * @param yHot Y coordinate of hot spot.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @param width Pointer width.
1bf151411167b02ebdc6d6a18de8b97030341e1fvboxsync * @param height Pointer height.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @param pv Pointer to the image data (can be NULL).
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync * @param cbImgSize The size of the image data not including the pre-allocated area.
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync * This should be the size of the image data exceeding the size of
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync * the VMMDevReqMousePointer structure.
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsync */
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsyncVBGLR3DECL(int) VbglR3SetPointerShape(uint32_t fFlags, uint32_t xHot, uint32_t yHot, uint32_t width, uint32_t height, void *pv, size_t cbImgSize)
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsync{
8b36957d815c23b479eb35d93ac76c66392e9402vboxsync VMMDevReqMousePointer *pReq;
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync int rc = vbglR3GRAlloc((VMMDevRequestHeader **)&pReq, sizeof(VMMDevReqMousePointer) + cbImgSize, VMMDevReq_SetPointerShape);
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync if (RT_SUCCESS(rc))
9353e321b583ed6f2b42414257a5212885575b5cvboxsync {
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync pReq->fFlags = fFlags;
9353e321b583ed6f2b42414257a5212885575b5cvboxsync pReq->xHot = xHot;
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync pReq->yHot = yHot;
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync pReq->width = width;
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync pReq->height = height;
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync if (pv)
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync memcpy(pReq->pointerData, pv, sizeof(pReq->pointerData) + cbImgSize);
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync rc = vbglR3GRPerform(&pReq->header);
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync vbglR3GRFree(&pReq->header);
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync if (RT_SUCCESS(rc))
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync {
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync if (RT_SUCCESS(pReq->header.rc))
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync return VINF_SUCCESS;
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync rc = pReq->header.rc;
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync }
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync }
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync return rc;
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync}
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync