VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibVideo.cpp@ 6538

Last change on this file since 6538 was 6531, checked in by vboxsync, 17 years ago

Guest Additions (R3 library): fixed todo from r27515

  • Property svn:eol-style set to native
File size: 4.2 KB
Line 
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 */
35VBGLR3DECL(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 */
51VBGLR3DECL(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 cbImg Size of the image data pointed to by pvImg.
71 */
72VBGLR3DECL(int) VbglR3SetPointerShape(uint32_t fFlags, uint32_t xHot, uint32_t yHot, uint32_t cx, uint32_t cy, const void *pvImg, size_t cbImg)
73{
74 VMMDevReqMousePointer *pReq;
75 int rc = vbglR3GRAlloc((VMMDevRequestHeader **)&pReq, RT_OFFSETOF(VMMDevReqMousePointer, pointerData) + cbImg, 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, cbImg);
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
99
100/**
101 * Query the last display change request.
102 *
103 * @returns iprt status value
104 * @param pcx Where to store the horizontal pixel resolution (0 = do not change).
105 * @param pcy Where to store the vertical pixel resolution (0 = do not change).
106 * @param pcBits Where to store the bits per pixel (0 = do not change).
107 * @param fEventAck Flag that the request is an acknowlegement for the
108 * VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST.
109 * Values:
110 * 0 - just querying,
111 * VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST - event acknowledged.
112 * @param iDisplay 0 for primary display, 1 for the first secondary, etc.
113 */
114VBGLR3DECL(int) VbglR3GetDisplayChangeRequest(uint32_t *pcx, uint32_t *pcy, uint32_t *pcBits,
115 uint32_t fEventAck, uint32_t iDisplay)
116{
117 VMMDevDisplayChangeRequest2 Req;
118 vmmdevInitRequest(&Req.header, VMMDevReq_GetDisplayChangeRequest2);
119 Req.xres = 0;
120 Req.yres = 0;
121 Req.bpp = 0;
122 Req.eventAck = fEventAck;
123 Req.display = iDisplay;
124 int rc = vbglR3GRPerform(&Req.header);
125 if (RT_SUCCESS(rc))
126 {
127 *pcx = Req.xres;
128 *pcy = Req.yres;
129 *pcBits = Req.bpp;
130 }
131 return rc;
132}
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette