VirtualBox

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

Last change on this file since 6654 was 6601, checked in by vboxsync, 17 years ago

{}.

  • Property svn:eol-style set to native
File size: 4.7 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 * Send mouse pointer shape information to the host.
102 * This version of the function accepts a request for clients that
103 * already allocate and manipulate the request structure directly.
104 *
105 * @returns VBox status code.
106 *
107 * @param pReq Pointer to the VMMDevReqMousePointer structure.
108 */
109VBGLR3DECL(int) VbglR3SetPointerShapeReq(VMMDevReqMousePointer *pReq)
110{
111 int rc = vbglR3GRPerform(&pReq->header);
112 if (RT_SUCCESS(rc))
113 rc = pReq->header.rc;
114 return rc;
115}
116
117
118/**
119 * Query the last display change request.
120 *
121 * @returns iprt status value
122 * @param pcx Where to store the horizontal pixel resolution (0 = do not change).
123 * @param pcy Where to store the vertical pixel resolution (0 = do not change).
124 * @param pcBits Where to store the bits per pixel (0 = do not change).
125 * @param fEventAck Flag that the request is an acknowlegement for the
126 * VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST.
127 * Values:
128 * 0 - just querying,
129 * VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST - event acknowledged.
130 * @param iDisplay 0 for primary display, 1 for the first secondary, etc.
131 */
132VBGLR3DECL(int) VbglR3GetDisplayChangeRequest(uint32_t *pcx, uint32_t *pcy, uint32_t *pcBits,
133 uint32_t fEventAck, uint32_t iDisplay)
134{
135 VMMDevDisplayChangeRequest2 Req;
136 vmmdevInitRequest(&Req.header, VMMDevReq_GetDisplayChangeRequest2);
137 Req.xres = 0;
138 Req.yres = 0;
139 Req.bpp = 0;
140 Req.eventAck = fEventAck;
141 Req.display = iDisplay;
142 int rc = vbglR3GRPerform(&Req.header);
143 if (RT_SUCCESS(rc))
144 rc = Req.header.rc;
145 if (RT_SUCCESS(rc))
146 {
147 *pcx = Req.xres;
148 *pcy = Req.yres;
149 *pcBits = Req.bpp;
150 }
151 return rc;
152}
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