1 | /* $Id$ */
|
---|
2 | /** @file
|
---|
3 | * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, Video.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2007 innotek GmbH
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 |
|
---|
19 | /*******************************************************************************
|
---|
20 | * Header Files *
|
---|
21 | *******************************************************************************/
|
---|
22 | #include <iprt/string.h>
|
---|
23 | #include <iprt/mem.h>
|
---|
24 |
|
---|
25 | #include "VBGLR3Internal.h"
|
---|
26 |
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Enable or disable video acceleration.
|
---|
30 | *
|
---|
31 | * @returns VBox status code.
|
---|
32 | *
|
---|
33 | * @param fEnable Pass zero to disable, any other value to enable.
|
---|
34 | */
|
---|
35 | VBGLR3DECL(int) VbglR3VideoAccelEnable(bool fEnable)
|
---|
36 | {
|
---|
37 | VMMDevVideoAccelEnable Req;
|
---|
38 | vmmdevInitRequest(&Req.header, VMMDevReq_VideoAccelEnable);
|
---|
39 | Req.u32Enable = fEnable;
|
---|
40 | Req.cbRingBuffer = VBVA_RING_BUFFER_SIZE;
|
---|
41 | Req.fu32Status = 0;
|
---|
42 | return vbglR3GRPerform(&Req.header);
|
---|
43 | }
|
---|
44 |
|
---|
45 |
|
---|
46 | /**
|
---|
47 | * Flush the video buffer.
|
---|
48 | *
|
---|
49 | * @returns VBox status code.
|
---|
50 | */
|
---|
51 | VBGLR3DECL(int) VbglR3VideoAccelFlush(void)
|
---|
52 | {
|
---|
53 | VMMDevVideoAccelFlush Req;
|
---|
54 | vmmdevInitRequest(&Req.header, VMMDevReq_VideoAccelFlush);
|
---|
55 | return vbglR3GRPerform(&Req.header);
|
---|
56 | }
|
---|
57 |
|
---|
58 |
|
---|
59 | /**
|
---|
60 | * Send mouse pointer shape information to the host.
|
---|
61 | *
|
---|
62 | * @returns VBox status code.
|
---|
63 | *
|
---|
64 | * @param fFlags Mouse pointer flags.
|
---|
65 | * @param xHot X coordinate of hot spot.
|
---|
66 | * @param yHot Y coordinate of hot spot.
|
---|
67 | * @param cx Pointer width.
|
---|
68 | * @param cy Pointer height.
|
---|
69 | * @param pvImg Pointer to the image data (can be NULL).
|
---|
70 | * @param cbReq The complete size of the request.
|
---|
71 | */
|
---|
72 | VBGLR3DECL(int) VbglR3SetPointerShape(uint32_t fFlags, uint32_t xHot, uint32_t yHot, uint32_t cx, uint32_t cy, const void *pvImg, size_t cbReq)
|
---|
73 | {
|
---|
74 | VMMDevReqMousePointer *pReq;
|
---|
75 | int rc = vbglR3GRAlloc((VMMDevRequestHeader **)&pReq, cbReq, VMMDevReq_SetPointerShape);
|
---|
76 | if (RT_SUCCESS(rc))
|
---|
77 | {
|
---|
78 | pReq->fFlags = fFlags;
|
---|
79 | pReq->xHot = xHot;
|
---|
80 | pReq->yHot = yHot;
|
---|
81 | pReq->width = cx;
|
---|
82 | pReq->height = cy;
|
---|
83 | if (pvImg)
|
---|
84 | memcpy(pReq->pointerData, pvImg, cbReq - sizeof(VMMDevReqMousePointer) + sizeof(pReq->pointerData));
|
---|
85 |
|
---|
86 | rc = vbglR3GRPerform(&pReq->header);
|
---|
87 | vbglR3GRFree(&pReq->header);
|
---|
88 | if (RT_SUCCESS(rc))
|
---|
89 | {
|
---|
90 | if (RT_SUCCESS(pReq->header.rc))
|
---|
91 | return VINF_SUCCESS;
|
---|
92 |
|
---|
93 | rc = pReq->header.rc;
|
---|
94 | }
|
---|
95 | }
|
---|
96 | return rc;
|
---|
97 | }
|
---|
98 |
|
---|