Changeset 52177 in vbox for trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibVideo.cpp
- Timestamp:
- Jul 24, 2014 8:15:59 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibVideo.cpp
r44528 r52177 29 29 * Header Files * 30 30 *******************************************************************************/ 31 #include "VBGLR3Internal.h" 32 33 #include <VBox/log.h> 34 #include <VBox/HostServices/GuestPropertySvc.h> /* For Save and RetrieveVideoMode */ 31 35 #include <iprt/assert.h> 32 36 #ifndef VBOX_VBGLR3_XFREE86 … … 34 38 #endif 35 39 #include <iprt/string.h> 36 #include <VBox/log.h> 37 #include <VBox/HostServices/GuestPropertySvc.h> /* For Save and RetrieveVideoMode */ 38 39 #include "VBGLR3Internal.h" 40 41 #include <stdio.h> 40 42 41 43 #ifdef VBOX_VBGLR3_XFREE86 … … 276 278 277 279 /** 278 * Save video mode parameters to the registry.280 * Save video mode parameters to the guest property store. 279 281 * 280 282 * @returns iprt status value 281 * @param pszName the name to save the mode parameters under 282 * @param cx mode width 283 * @param cy mode height 284 * @param cBits bits per pixel for the mode 285 */ 286 VBGLR3DECL(int) VbglR3SaveVideoMode(const char *pszName, uint32_t cx, uint32_t cy, uint32_t cBits) 283 * @param cScreen virtual screen number 284 * @param cx mode width 285 * @param cy mode height 286 * @param cBits bits per pixel for the mode 287 * @param x virtual screen X offset 288 * @param y virtual screen Y offset 289 * @param fEnabled is this virtual screen enabled? 290 */ 291 VBGLR3DECL(int) VbglR3SaveVideoMode(unsigned cScreen, unsigned cx, unsigned cy, 292 unsigned cBits, unsigned x, unsigned y, 293 bool fEnabled) 287 294 { 288 295 #if defined(VBOX_WITH_GUEST_PROPS) … … 292 299 char szModeParms[MAX_VALUE_LEN]; 293 300 uint32_t u32ClientId = 0; 294 RTStrPrintf(szModeName, sizeof(szModeName), VIDEO_PROP_PREFIX"%s", pszName); 295 RTStrPrintf(szModeParms, sizeof(szModeParms), "%dx%dx%d", cx, cy, cBits); 301 unsigned cx2, cy2, cBits2, x2, y2; 302 bool fEnabled2; 303 304 RTStrPrintf(szModeName, sizeof(szModeName), VIDEO_PROP_PREFIX"%u", cScreen); 305 RTStrPrintf(szModeParms, sizeof(szModeParms), "%ux%ux%u,%ux%u,%u", cx, cy, 306 cBits, x, y, (unsigned) fEnabled); 296 307 int rc = VbglR3GuestPropConnect(&u32ClientId); 297 308 if (RT_SUCCESS(rc)) … … 299 310 if (u32ClientId != 0) 300 311 VbglR3GuestPropDisconnect(u32ClientId); /* Return value ignored, because what can we do anyway? */ 312 if (RT_SUCCESS(rc)) 313 { 314 rc = VbglR3RetrieveVideoMode(cScreen, &cx2, &cy2, &cBits2, &x2, &y2, 315 &fEnabled2); 316 if ( RT_SUCCESS(rc) 317 && ( cx != cx2 || cy != cy2 || cBits != cBits2 318 || x != x2 || y != y2 || fEnabled != fEnabled2)) 319 rc = VERR_WRITE_ERROR; 320 } 301 321 return rc; 302 322 #else /* !VBOX_WITH_GUEST_PROPS */ … … 310 330 * 311 331 * @returns iprt status value 312 * @param pszName the name under which the mode parameters are saved 313 * @param pcx where to store the mode width 314 * @param pcy where to store the mode height 315 * @param pcBits where to store the bits per pixel for the mode 316 */ 317 VBGLR3DECL(int) VbglR3RetrieveVideoMode(const char *pszName, uint32_t *pcx, uint32_t *pcy, uint32_t *pcBits) 332 * @param cScreen the virtual screen number 333 * @param pcx where to store the mode width 334 * @param pcy where to store the mode height 335 * @param pcBits where to store the bits per pixel for the mode 336 * @param px where to store the virtual screen X offset 337 * @param py where to store the virtual screen Y offset 338 * @param pfEnabled where to store whether this virtual screen is enabled 339 */ 340 VBGLR3DECL(int) VbglR3RetrieveVideoMode(unsigned cScreen, 341 unsigned *pcx, unsigned *pcy, 342 unsigned *pcBits, 343 unsigned *px, unsigned *py, 344 bool *pfEnabled) 318 345 { 319 346 #if defined(VBOX_WITH_GUEST_PROPS) … … 326 353 /* The buffer for VbglR3GuestPropReadValue. If this is too small then 327 354 * something is wrong with the data stored in the property. */ 355 char szModeName[MAX_NAME_LEN]; 328 356 char szModeParms[1024]; 329 357 uint32_t u32ClientId = 0; 330 uint32_t cx, cy, cBits; 331 358 int cMatches; 359 unsigned cx, cy, cBits, x, y, fEnabled; 360 361 /** @todo add a VbglR3GuestPropReadValueF/FV that does the RTStrPrintf for you. */ 362 RTStrPrintf(szModeName, sizeof(szModeName), VIDEO_PROP_PREFIX"%u", cScreen); 332 363 int rc = VbglR3GuestPropConnect(&u32ClientId); 333 364 if (RT_SUCCESS(rc)) 334 {335 char szModeName[MAX_NAME_LEN];336 RTStrPrintf(szModeName, sizeof(szModeName), VIDEO_PROP_PREFIX"%s", pszName);337 /** @todo add a VbglR3GuestPropReadValueF/FV that does the RTStrPrintf for you. */338 365 rc = VbglR3GuestPropReadValue(u32ClientId, szModeName, szModeParms, 339 366 sizeof(szModeParms), NULL); 340 } 367 if (u32ClientId != 0) 368 VbglR3GuestPropDisconnect(u32ClientId); /* Return value ignored, because what can we do anyway? */ 341 369 342 370 /* 343 371 * Now we convert the string returned to numeric values. 344 372 */ 345 char *pszNext; 346 if (RT_SUCCESS(rc)) 347 /* Extract the width from the string */ 348 rc = RTStrToUInt32Ex(szModeParms, &pszNext, 10, &cx); 349 if ((rc != VWRN_TRAILING_CHARS) || (*pszNext != 'x')) 373 cMatches = sscanf(szModeParms, "%ux%ux%u,%ux%u,%u\n", &cx, &cy, &cBits, &x, 374 &y, &fEnabled); 375 if (cMatches == 6) 376 rc = VINF_SUCCESS; 377 else if (cMatches < 0) 378 rc = VERR_READ_ERROR; 379 else 350 380 rc = VERR_PARSE_ERROR; 351 if (RT_SUCCESS(rc))352 {353 /* Extract the height from the string */354 ++pszNext;355 rc = RTStrToUInt32Ex(pszNext, &pszNext, 10, &cy);356 }357 if ((rc != VWRN_TRAILING_CHARS) || (*pszNext != 'x'))358 rc = VERR_PARSE_ERROR;359 if (RT_SUCCESS(rc))360 {361 /* Extract the bpp from the string */362 ++pszNext;363 rc = RTStrToUInt32Full(pszNext, 10, &cBits);364 }365 if (rc != VINF_SUCCESS)366 rc = VERR_PARSE_ERROR;367 368 381 /* 369 382 * And clean up and return the values if we successfully obtained them. 370 383 */ 371 if (u32ClientId != 0) 372 VbglR3GuestPropDisconnect(u32ClientId); /* Return value ignored, because what can we do anyway? */ 373 if (RT_SUCCESS(rc)) 374 { 375 *pcx = cx; 376 *pcy = cy; 377 *pcBits = cBits; 384 if (RT_SUCCESS(rc)) 385 { 386 if (pcx) 387 *pcx = cx; 388 if (pcy) 389 *pcy = cy; 390 if (pcBits) 391 *pcBits = cBits; 392 if (px) 393 *px = x; 394 if (py) 395 *py = y; 396 if (pfEnabled) 397 *pfEnabled = RT_BOOL(fEnabled); 378 398 } 379 399 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.