Changeset 3761 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Jul 22, 2007 10:43:14 AM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 23084
- Location:
- trunk/src/VBox/Frontends
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxBFE/DisplayImpl.cpp
r3670 r3761 308 308 * 309 309 * @returns COM status code 310 * @param colorDepthAddress of result variable.311 */ 312 uint32_t VMDisplay::get ColorDepth()310 * @param bitsPerPixel Address of result variable. 311 */ 312 uint32_t VMDisplay::getBitsPerPixel() 313 313 { 314 314 Assert(mpDrv); … … 409 409 mFramebuffer->getAddress ((uintptr_t *)&mpDrv->Connector.pu8Data); 410 410 mFramebuffer->getLineSize ((ULONG*)&mpDrv->Connector.cbScanline); 411 mFramebuffer->get ColorDepth((ULONG*)&mpDrv->Connector.cBits);411 mFramebuffer->getBitsPerPixel ((ULONG*)&mpDrv->Connector.cBits); 412 412 mFramebuffer->getWidth ((ULONG*)&mpDrv->Connector.cx); 413 413 mFramebuffer->getHeight ((ULONG*)&mpDrv->Connector.cy); … … 426 426 { 427 427 mFramebuffer->getAddress ((uintptr_t *)&mpDrv->Connector.pu8Data); 428 mFramebuffer->get ColorDepth((ULONG*)&mpDrv->Connector.cBits);428 mFramebuffer->getBitsPerPixel ((ULONG*)&mpDrv->Connector.cBits); 429 429 mpDrv->pUpPort->pfnSetRenderVRAM (mpDrv->pUpPort, 430 430 !!(mpDrv->Connector.pu8Data != (uint8_t*)~0UL)); … … 824 824 } 825 825 826 void VMDisplay::SetVideoModeHint(ULONG aWidth, ULONG aHeight, ULONG a ColorDepth, ULONG aDisplay)826 void VMDisplay::SetVideoModeHint(ULONG aWidth, ULONG aHeight, ULONG aBitsPerPixel, ULONG aDisplay) 827 827 { 828 828 PPDMIVMMDEVPORT pVMMDevPort = gVMMDev->getVMMDevPort (); 829 829 830 830 if (pVMMDevPort) 831 pVMMDevPort->pfnRequestDisplayChange(pVMMDevPort, aWidth, aHeight, a ColorDepth, aDisplay);831 pVMMDevPort->pfnRequestDisplayChange(pVMMDevPort, aWidth, aHeight, aBitsPerPixel, aDisplay); 832 832 } 833 833 -
trunk/src/VBox/Frontends/VBoxBFE/DisplayImpl.h
r3110 r3761 47 47 48 48 void updatePointerShape(bool fVisible, bool fAlpha, uint32_t xHot, uint32_t yHot, uint32_t width, uint32_t height, void *pShape); 49 void SetVideoModeHint(ULONG aWidth, ULONG aHeight, ULONG a ColorDepth, ULONG aDisplay);49 void SetVideoModeHint(ULONG aWidth, ULONG aHeight, ULONG aBitsPerPixel, ULONG aDisplay); 50 50 51 51 static const PDMDRVREG DrvReg; … … 53 53 uint32_t getWidth(); 54 54 uint32_t getHeight(); 55 uint32_t get ColorDepth();55 uint32_t getBitsPerPixel(); 56 56 57 57 STDMETHODIMP RegisterExternalFramebuffer(Framebuffer *Framebuffer); -
trunk/src/VBox/Frontends/VBoxBFE/Framebuffer.h
r3576 r3761 42 42 virtual HRESULT Unlock() = 0; 43 43 virtual HRESULT getAddress(uintptr_t *address) = 0; 44 virtual HRESULT get ColorDepth(ULONG *colorDepth) = 0;44 virtual HRESULT getBitsPerPixel(ULONG *bitsPerPixel) = 0; 45 45 virtual HRESULT getLineSize(ULONG *lineSize) = 0; 46 46 virtual HRESULT NotifyUpdate(ULONG x, ULONG y, -
trunk/src/VBox/Frontends/VBoxBFE/SDLFramebuffer.cpp
r3701 r3761 185 185 * 186 186 * @returns COM status code 187 * @param colorDepthAddress of result variable188 */ 189 HRESULT SDLFramebuffer::get ColorDepth(ULONG *colorDepth)190 { 191 LogFlow(("SDLFramebuffer::Get ColorDepth\n"));192 193 if (! colorDepth)187 * @param bitsPerPixel Address of result variable 188 */ 189 HRESULT SDLFramebuffer::getBitsPerPixel(ULONG *bitsPerPixel) 190 { 191 LogFlow(("SDLFramebuffer::GetBitsPerPixel\n")); 192 193 if (!bitsPerPixel) 194 194 return E_INVALIDARG; 195 * colorDepth= (ULONG)(mScreen ? mScreen->format->BitsPerPixel : 0);195 *bitsPerPixel = (ULONG)(mScreen ? mScreen->format->BitsPerPixel : 0); 196 196 return S_OK; 197 197 } -
trunk/src/VBox/Frontends/VBoxBFE/SDLFramebuffer.h
r3669 r3761 48 48 virtual HRESULT Unlock(); 49 49 virtual HRESULT getAddress(uintptr_t *address); 50 virtual HRESULT get ColorDepth(ULONG *colorDepth);50 virtual HRESULT getBitsPerPixel(ULONG *bitsPerPixel); 51 51 virtual HRESULT getLineSize(ULONG *lineSize); 52 52 virtual HRESULT NotifyUpdate(ULONG x, ULONG y, -
trunk/src/VBox/Frontends/VBoxBFE/VBoxBFE.cpp
r3670 r3761 729 729 if (g_u32VRamSizeMB * _1M >= gFramebuffer->getHostXres() 730 730 * gFramebuffer->getHostYres() 731 * (gDisplay->get ColorDepth() / 8))731 * (gDisplay->getBitsPerPixel() / 8)) 732 732 gDisplay->SetVideoModeHint(gFramebuffer->getHostXres(), gFramebuffer->getHostYres(), 0, 0); 733 733 #endif -
trunk/src/VBox/Frontends/VBoxFB/Framebuffer.cpp
r3614 r3761 42 42 } 43 43 fbSurfaceLocked = 0; 44 uint32_t colorDepth;45 Get ColorDepth(&colorDepth);46 fbPitch = fbWidth * ( colorDepth/ 8);44 uint32_t bitsPerPixel; 45 GetBitsPerPixel(&bitsPerPixel); 46 fbPitch = fbWidth * (bitsPerPixel / 8); 47 47 } 48 48 … … 138 138 } 139 139 140 NS_IMETHODIMP VBoxDirectFB::Get ColorDepth(uint32_t *colorDepth)141 { 142 if (! colorDepth)140 NS_IMETHODIMP VBoxDirectFB::GetBitsPerPixel(uint32_t *bitsPerPixel) 141 { 142 if (!bitsPerPixel) 143 143 return NS_ERROR_INVALID_POINTER; 144 144 DFBSurfacePixelFormat pixelFormat; … … 147 147 { 148 148 case DSPF_RGB16: 149 * colorDepth= 16;149 *bitsPerPixel = 16; 150 150 break; 151 151 case DSPF_RGB24: 152 * colorDepth= 24;152 *bitsPerPixel = 24; 153 153 break; 154 154 case DSPF_RGB32: 155 * colorDepth= 32;155 *bitsPerPixel = 32; 156 156 break; 157 157 default: 158 158 // not good! @@@AH do something! 159 *colorDepth = 16; 160 } 161 return NS_OK; 162 } 163 164 NS_IMETHODIMP VBoxDirectFB::GetLineSize(uint32_t *lineSize) 165 { 166 if (!lineSize) 167 return NS_ERROR_INVALID_POINTER; 168 *lineSize = fbPitch; 169 return NS_OK; 170 } 171 172 NS_IMETHODIMP VBoxDirectFB::COMGETTER(PixelFormat) (FramebufferPixelFormat_T *pixelFormat) 173 { 174 if (!lineSize) 175 return NS_ERROR_INVALID_POINTER; 176 *pixelFormat = FramebufferPixelFormat_PixelFormatOpaque; 159 *bitsPerPixel = 16; 160 } 161 return NS_OK; 162 } 163 164 NS_IMETHODIMP VBoxDirectFB::GetBytesPerLine(uint32_t *bytesPerLine) 165 { 166 if (!bytesPerLine) 167 return NS_ERROR_INVALID_POINTER; 168 *bytesPerLine = fbPitch; 169 return NS_OK; 170 } 171 172 NS_IMETHODIMP VBoxDirectFB::COMGETTER(PixelFormat) (ULONG *pixelFormat) 173 { 174 if (!pixelFormat) 175 return NS_ERROR_INVALID_POINTER; 176 *pixelFormat = FramebufferPixelFormat_FOURCC_RGB; 177 return NS_OK; 178 } 179 180 NS_IMETHODIMP VBoxDirectFB::COMGETTER(UsesGuestVRAM) (BOOL *usesGuestVRAM) 181 { 182 if (!usesGuestVRAM) 183 return NS_ERROR_INVALID_POINTER; 184 *usesGuestVRAM = FALSE; 177 185 return NS_OK; 178 186 } … … 213 221 } 214 222 215 NS_IMETHODIMP VBoxDirectFB::RequestResize(ULONG aScreenId, FramebufferPixelFormat_T pixelFormat, uint32_t vram, uint32_t lineSize, uint32_t w, uint32_t h, 216 PRBool *finished) 223 NS_IMETHODIMP VBoxDirectFB::RequestResize(ULONG aScreenId, ULONG pixelFormat, uint32_t vram, 224 uint32_t bitsPerPixel, uint32_t bytesPerLine, 225 uint32_t w, uint32_t h, 226 PRBool *finished) 217 227 { 218 228 uint32_t needsLocking = fbSurfaceLocked; 219 uint32_t colorDepth;220 221 Get ColorDepth(&colorDepth);229 uint32_t bitsPerPixel; 230 231 GetBitsPerPixel(&bitsPerPixel); 222 232 printf("RequestResize: w = %d, h = %d, fbSurfaceLocked = %d\n", w, h, fbSurfaceLocked); 223 233 … … 250 260 { 251 261 // we adopt to the guest resolution or the next higher that is available 252 int32_t bestMode = getBestVideoMode(w, h, colorDepth);262 int32_t bestMode = getBestVideoMode(w, h, bitsPerPixel); 253 263 if (bestMode == -1) 254 264 { … … 260 270 // does the mode differ from what we wanted? 261 271 if ((videoModes[bestMode].width != w) || (videoModes[bestMode].height != h) || 262 (videoModes[bestMode].bpp != colorDepth))272 (videoModes[bestMode].bpp != bitsPerPixel)) 263 273 { 264 274 printf("The mode does not fit exactly!\n"); -
trunk/src/VBox/Frontends/VBoxFB/Framebuffer.h
r3153 r3761 39 39 NS_IMETHOD Unlock(); 40 40 NS_IMETHOD GetAddress(uint32_t *address); 41 NS_IMETHOD GetColorDepth(uint32_t *colorDepth); 42 NS_IMETHOD GetLineSize(uint32_t *lineSize); 43 NS_IMETHOD GetPixelFormat(FramebufferPixelFormat_T *pixelFormat); 41 NS_IMETHOD GetBitsPerPixel(uint32_t *bitsPerPixel); 42 NS_IMETHOD GetBytesPerLine(uint32_t *bytesPerLine); 43 NS_IMETHOD GetPixelFormat(ULONG *pixelFormat); 44 NS_IMETHOD GetUsesGuestVRAM(BOOL *usesGuestVRAM); 44 45 NS_IMETHOD NotifyUpdate(uint32_t x, uint32_t y, 45 46 uint32_t w, uint32_t h, PRBool *finished); 46 NS_IMETHOD RequestResize(ULONG aScreenId, FramebufferPixelFormat_T pixelFormat, uint32_t vram, uint32_t lineSize, uint32_t w, uint32_t h, 47 NS_IMETHOD RequestResize(ULONG aScreenId, ULONG pixelFormat, uint32_t vram, 48 uint32_t bitsPerPixel, uint32_t bytesPerLine, 49 uint32_t w, uint32_t h, 47 50 PRBool *finished); 48 51 private: -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r3730 r3761 1123 1123 CHECK_ERROR_RET(display, COMGETTER(Width)(&xRes), rc); 1124 1124 CHECK_ERROR_RET(display, COMGETTER(Height)(&yRes), rc); 1125 CHECK_ERROR_RET(display, COMGETTER( ColorDepth)(&bpp), rc);1125 CHECK_ERROR_RET(display, COMGETTER(BitsPerPixel)(&bpp), rc); 1126 1126 RTPrintf("Video mode: %dx%dx%d\n", xRes, yRes, bpp); 1127 1127 } -
trunk/src/VBox/Frontends/VBoxSDL/Framebuffer.cpp
r3669 r3761 108 108 mGuestYRes = 480; 109 109 mPixelFormat = FramebufferPixelFormat_PixelFormatOpaque; 110 mUsesGuestVRAM = FALSE; 110 111 mPtrVRAM = NULL; 111 mLineSize = 0; 112 mBitsPerPixel = 0; 113 mBytesPerLine = 0; 112 114 #ifdef VBOX_SECURELABEL 113 115 mLabelFont = NULL; … … 296 298 * 297 299 * @returns COM status code 298 * @param colorDepthAddress of result variable299 */ 300 STDMETHODIMP VBoxSDLFB::COMGETTER( ColorDepth)(ULONG *colorDepth)301 { 302 LogFlow(("VBoxSDLFB::Get ColorDepth\n"));303 if (! colorDepth)300 * @param bitsPerPixel Address of result variable 301 */ 302 STDMETHODIMP VBoxSDLFB::COMGETTER(BitsPerPixel)(ULONG *bitsPerPixel) 303 { 304 LogFlow(("VBoxSDLFB::GetBitsPerPixel\n")); 305 if (!bitsPerPixel) 304 306 return E_INVALIDARG; 305 307 /* get the information directly from the surface in use */ 306 308 Assert(mSurfVRAM); 307 * colorDepth= (ULONG)(mSurfVRAM ? mSurfVRAM->format->BitsPerPixel : 0);309 *bitsPerPixel = (ULONG)(mSurfVRAM ? mSurfVRAM->format->BitsPerPixel : 0); 308 310 return S_OK; 309 311 } … … 315 317 * @param lineSize Address of result variable. 316 318 */ 317 STDMETHODIMP VBoxSDLFB::COMGETTER( LineSize)(ULONG *lineSize)318 { 319 LogFlow(("VBoxSDLFB::Get LineSize\n"));320 if (! lineSize)319 STDMETHODIMP VBoxSDLFB::COMGETTER(BytesPerLine)(ULONG *bytesPerLine) 320 { 321 LogFlow(("VBoxSDLFB::GetBytesPerLine\n")); 322 if (!bytesPerLine) 321 323 return E_INVALIDARG; 322 324 /* get the information directly from the surface */ 323 325 Assert(mSurfVRAM); 324 * lineSize = (ULONG)(mSurfVRAM ? mSurfVRAM->pitch : 0);325 return S_OK; 326 } 327 328 STDMETHODIMP VBoxSDLFB::COMGETTER(PixelFormat) ( FramebufferPixelFormat_T*pixelFormat)326 *bytesPerLine = (ULONG)(mSurfVRAM ? mSurfVRAM->pitch : 0); 327 return S_OK; 328 } 329 330 STDMETHODIMP VBoxSDLFB::COMGETTER(PixelFormat) (ULONG *pixelFormat) 329 331 { 330 332 if (!pixelFormat) 331 333 return E_POINTER; 332 334 *pixelFormat = mPixelFormat; 335 return S_OK; 336 } 337 338 STDMETHODIMP VBoxSDLFB::COMGETTER(UsesGuestVRAM) (BOOL *usesGuestVRAM) 339 { 340 if (!usesGuestVRAM) 341 return E_POINTER; 342 *usesGuestVRAM = mUsesGuestVRAM; 333 343 return S_OK; 334 344 } … … 425 435 * @param pixelFormat The requested pixel format. 426 436 * @param vram Pointer to the guest VRAM buffer (can be NULL). 427 * @param lineSize Size of a scanline in bytes. 437 * @param bitsPerPixel Color depth in bits. 438 * @param bytesPerLine Size of a scanline in bytes. 428 439 * @param w New display width in pixels. 429 440 * @param h New display height in pixels. … … 434 445 * continuing with display updates. 435 446 */ 436 STDMETHODIMP VBoxSDLFB::RequestResize(ULONG aScreenId, FramebufferPixelFormat_T pixelFormat, BYTE *vram, 437 ULONG lineSize, ULONG w, ULONG h, BOOL *finished) 438 { 439 LogFlow(("VBoxSDLFB::RequestResize: w = %d, h = %d, pixelFormat: %d, vram = %p, lineSize = %d\n", 440 w, h, pixelFormat, vram, lineSize)); 447 STDMETHODIMP VBoxSDLFB::RequestResize(ULONG aScreenId, ULONG pixelFormat, BYTE *vram, 448 ULONG bitsPerPixel, ULONG bytesPerLine, 449 ULONG w, ULONG h, BOOL *finished) 450 { 451 LogFlowFunc (("w=%d, h=%d, pixelFormat=0x%08lX, vram=%p, " 452 "bpp=%d, bpl=%d\n", 453 w, h, pixelFormat, vram, bitsPerPixel, bytesPerLine)); 441 454 442 455 /* … … 450 463 return E_FAIL; 451 464 } 465 452 466 mGuestXRes = w; 453 467 mGuestYRes = h; 454 468 mPixelFormat = pixelFormat; 455 469 mPtrVRAM = vram; 456 mLineSize = lineSize; 470 mBitsPerPixel = bitsPerPixel; 471 mBytesPerLine = bytesPerLine; 472 mUsesGuestVRAM = FALSE; /* yet */ 457 473 458 474 SDL_Event event; … … 610 626 void VBoxSDLFB::resizeGuest() 611 627 { 612 LogFlow (("VBoxSDL::resizeGuest()mGuestXRes: %d, mGuestYRes: %d\n", mGuestXRes, mGuestYRes));613 AssertMsg(mSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n"));614 615 int cBitsPerPixel = 32; 628 LogFlowFunc (("mGuestXRes: %d, mGuestYRes: %d\n", mGuestXRes, mGuestYRes)); 629 AssertMsg(mSdlNativeThread == RTThreadNativeSelf(), 630 ("Wrong thread! SDL is not threadsafe!\n")); 631 616 632 uint32_t Rmask, Gmask, Bmask, Amask = 0; 617 633 618 /* pixel characteristics, default to fallback 32bpp format */ 619 if (mPixelFormat == FramebufferPixelFormat_PixelFormatRGB16) 620 cBitsPerPixel = 16; 621 else if (mPixelFormat == FramebufferPixelFormat_PixelFormatRGB24) 622 cBitsPerPixel = 24; 623 624 switch (cBitsPerPixel) 634 mUsesGuestVRAM = FALSE; 635 636 /* pixel characteristics. if we don't support the format directly, we will 637 * fallback to the indirect 32bpp buffer (mUsesGuestVRAM will remain 638 * FALSE) */ 639 if (mPixelFormat == FramebufferPixelFormat_FOURCC_RGB) 640 { 641 switch (mBitsPerPixel) 642 { 643 case 16: 644 case 24: 645 case 32: 646 mUsesGuestVRAM = TRUE; 647 break; 648 default: 649 /* the fallback buffer is always 32bpp */ 650 mBitsPerPixel = 32; 651 mBytesPerLine = mGuestXRes * 4; 652 break; 653 } 654 } 655 else 656 { 657 /* the fallback buffer is always RGB, 32bpp */ 658 mPixelFormat = FramebufferPixelFormat_FOURCC_RGB; 659 mBitsPerPixel = 32; 660 mBytesPerLine = mGuestXRes * 4; 661 } 662 663 switch (mBitsPerPixel) 625 664 { 626 665 case 16: Rmask = 0x0000F800; Gmask = 0x000007E0; Bmask = 0x0000001F; break; … … 636 675 637 676 /* is the guest in a linear framebuffer mode we support? */ 638 if (mPixelFormat != FramebufferPixelFormat_PixelFormatOpaque) 639 { 677 if (mUsesGuestVRAM) 678 { 679 640 680 /* Create a source surface from guest VRAM. */ 641 mSurfVRAM = SDL_CreateRGBSurfaceFrom(mPtrVRAM, mGuestXRes, mGuestYRes, cBitsPerPixel,642 m LineSize, Rmask, Gmask, Bmask, Amask);681 mSurfVRAM = SDL_CreateRGBSurfaceFrom(mPtrVRAM, mGuestXRes, mGuestYRes, mBitsPerPixel, 682 mBytesPerLine, Rmask, Gmask, Bmask, Amask); 643 683 } 644 684 else 645 685 { 646 686 /* Create a software surface for which SDL allocates the RAM */ 647 mSurfVRAM = SDL_CreateRGBSurface(SDL_SWSURFACE, mGuestXRes, mGuestYRes, cBitsPerPixel,687 mSurfVRAM = SDL_CreateRGBSurface(SDL_SWSURFACE, mGuestXRes, mGuestYRes, mBitsPerPixel, 648 688 Rmask, Gmask, Bmask, Amask); 649 689 } … … 1156 1196 * @param lineSize Address of result buffer. 1157 1197 */ 1158 STDMETHODIMP VBoxSDLFBOverlay::COMGETTER( LineSize)(ULONG *lineSize)1159 { 1160 LogFlow(("VBoxSDLFBOverlay::Get LineSize\n"));1161 if (! lineSize)1162 return E_INVALIDARG; 1163 * lineSize = mOverlayBits->pitch;1198 STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(BytesPerLine)(ULONG *bytesPerLine) 1199 { 1200 LogFlow(("VBoxSDLFBOverlay::GetBytesPerLine\n")); 1201 if (!bytesPerLine) 1202 return E_INVALIDARG; 1203 *bytesPerLine = mOverlayBits->pitch; 1164 1204 return S_OK; 1165 1205 } … … 1251 1291 * 1252 1292 * @returns COM status code 1253 * @param colorDepthAddress of result buffer.1254 */ 1255 STDMETHODIMP VBoxSDLFBOverlay::COMGETTER( ColorDepth)(ULONG *colorDepth)1256 { 1257 LogFlow(("VBoxSDLFBOverlay::Get ColorDepth\n"));1258 if (! colorDepth)1259 return E_INVALIDARG; 1260 * colorDepth= 32;1261 return S_OK; 1262 } 1263 1264 /** 1265 * Returns the current pixel format. In fact, this is always RGB 32.1293 * @param bitsPerPixel Address of result buffer. 1294 */ 1295 STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(BitsPerPixel)(ULONG *bitsPerPixel) 1296 { 1297 LogFlow(("VBoxSDLFBOverlay::GetBitsPerPixel\n")); 1298 if (!bitsPerPixel) 1299 return E_INVALIDARG; 1300 *bitsPerPixel = 32; 1301 return S_OK; 1302 } 1303 1304 /** 1305 * Returns the current pixel format. In fact, this is always RGB. 1266 1306 * 1267 1307 * @returns COM status code 1268 1308 * @param pixelFormat Address of result buffer. 1269 1309 */ 1270 STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(PixelFormat)( FramebufferPixelFormat_T*pixelFormat)1310 STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(PixelFormat)(ULONG *pixelFormat) 1271 1311 { 1272 1312 LogFlow(("VBoxSDLFBOverlay::GetPixelFormat\n")); 1273 1313 if (!pixelFormat) 1274 1314 return E_INVALIDARG; 1275 *pixelFormat = FramebufferPixelFormat_PixelFormatRGB32; 1315 *pixelFormat = FramebufferPixelFormat_FOURCC_RGB; 1316 return S_OK; 1317 } 1318 1319 /** 1320 * Returns whether the guest VRAM is used directly. In fact, this is always FALSE. 1321 * 1322 * @returns COM status code 1323 * @param usesGuestVRAM Address of result buffer. 1324 */ 1325 STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(UsesGuestVRAM)(BOOL *usesGuestVRAM) 1326 { 1327 LogFlow(("VBoxSDLFBOverlay::GetUsesGuestVRAM\n")); 1328 if (!usesGuestVRAM) 1329 return E_INVALIDARG; 1330 *usesGuestVRAM = FALSE; 1276 1331 return S_OK; 1277 1332 } … … 1379 1434 * @retval finished Set if the operation has completed. 1380 1435 */ 1381 STDMETHODIMP VBoxSDLFBOverlay::RequestResize(ULONG aScreenId, FramebufferPixelFormat_T pixelFormat,1382 ULONG vram, ULONG lineSize, ULONG w,1383 ULONG h, BOOL *finished)1384 { 1385 AssertReturn(pixelFormat == FramebufferPixelFormat_ PixelFormatRGB32, E_INVALIDARG);1436 STDMETHODIMP VBoxSDLFBOverlay::RequestResize(ULONG aScreenId, ULONG pixelFormat, ULONG vram, 1437 ULONG bitsPerPixel, ULONG bytesPerLine, 1438 ULONG w, ULONG h, BOOL *finished) 1439 { 1440 AssertReturn(pixelFormat == FramebufferPixelFormat_FOURCC_RGB, E_INVALIDARG); 1386 1441 AssertReturn(vram == 0, E_INVALIDARG); 1442 AssertReturn(bitsPerPixel == 32, E_INVALIDARG); 1387 1443 mOverlayWidth = w; 1388 1444 mOverlayHeight = h; -
trunk/src/VBox/Frontends/VBoxSDL/Framebuffer.h
r3669 r3761 90 90 STDMETHOD(Unlock)(); 91 91 STDMETHOD(COMGETTER(Address))(BYTE **address); 92 STDMETHOD(COMGETTER(ColorDepth))(ULONG *colorDepth); 93 STDMETHOD(COMGETTER(LineSize))(ULONG *lineSize); 94 STDMETHOD(COMGETTER(PixelFormat)) (FramebufferPixelFormat_T *pixelFormat); 92 STDMETHOD(COMGETTER(BitsPerPixel))(ULONG *bitsPerPixel); 93 STDMETHOD(COMGETTER(BytesPerLine))(ULONG *bytesPerLine); 94 STDMETHOD(COMGETTER(PixelFormat)) (ULONG *pixelFormat); 95 STDMETHOD(COMGETTER(UsesGuestVRAM)) (BOOL *usesGuestVRAM); 95 96 STDMETHOD(COMGETTER(HeightReduction)) (ULONG *heightReduction); 96 97 STDMETHOD(COMGETTER(Overlay)) (IFramebufferOverlay **aOverlay); … … 98 99 STDMETHOD(NotifyUpdate)(ULONG x, ULONG y, 99 100 ULONG w, ULONG h, BOOL *finished); 100 STDMETHOD(RequestResize)(ULONG aScreenId, FramebufferPixelFormat_T pixelFormat, BYTE *vram, 101 ULONG lineSize, ULONG w, ULONG h, BOOL *finished); 101 STDMETHOD(RequestResize)(ULONG aScreenId, ULONG pixelFormat, BYTE *vram, 102 ULONG bitsPerPixel, ULONG bytesPerLine, 103 ULONG w, ULONG h, BOOL *finished); 102 104 STDMETHOD(OperationSupported)(FramebufferAccelerationOperation_T operation, BOOL *supported); 103 105 STDMETHOD(VideoModeSupported)(ULONG width, ULONG height, ULONG bpp, BOOL *supported); … … 185 187 186 188 BYTE *mPtrVRAM; 187 ULONG mLineSize; 188 FramebufferPixelFormat_T mPixelFormat; 189 ULONG mBitsPerPixel; 190 ULONG mBytesPerLine; 191 ULONG mPixelFormat; 192 BOOL mUsesGuestVRAM; 189 193 190 194 /** the application Icon */ … … 242 246 STDMETHOD(COMSETTER(Alpha))(ULONG alpha); 243 247 STDMETHOD(COMGETTER(Address))(ULONG *address); 244 STDMETHOD(COMGETTER( LineSize))(ULONG *lineSize);248 STDMETHOD(COMGETTER(BytesPerLine))(ULONG *bytesPerLine); 245 249 246 250 /* These are not used, or return standard values. */ 247 STDMETHOD(COMGETTER(ColorDepth))(ULONG *colorDepth); 248 STDMETHOD(COMGETTER(PixelFormat)) (FramebufferPixelFormat_T *pixelFormat); 251 STDMETHOD(COMGETTER(BitsPerPixel))(ULONG *bitsPerPixel); 252 STDMETHOD(COMGETTER(PixelFormat)) (ULONG *pixelFormat); 253 STDMETHOD(COMGETTER(UsesGuestVRAM)) (BOOL *usesGuestVRAM); 249 254 STDMETHOD(COMGETTER(HeightReduction)) (ULONG *heightReduction); 250 255 STDMETHOD(COMGETTER(Overlay)) (IFramebufferOverlay **aOverlay); … … 255 260 STDMETHOD(NotifyUpdate)(ULONG x, ULONG y, 256 261 ULONG w, ULONG h, BOOL *finished); 257 STDMETHOD(RequestResize)(ULONG aScreenId, FramebufferPixelFormat_T pixelFormat, ULONG vram, 258 ULONG lineSize, ULONG w, ULONG h, BOOL *finished); 262 STDMETHOD(RequestResize)(ULONG aScreenId, ULONG pixelFormat, ULONG vram, 263 ULONG bitsPerPixel, ULONG bytesPerLine, 264 ULONG w, ULONG h, BOOL *finished); 259 265 STDMETHOD(OperationSupported)(FramebufferAccelerationOperation_T operation, 260 266 BOOL *supported); -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxFrameBuffer.h
r3674 r3761 73 73 { 74 74 public: 75 VBoxResizeEvent (FramebufferPixelFormat_T f, uchar *v, unsigned l, int w, int h) : 76 QEvent ((QEvent::Type) VBoxDefs::ResizeEventType), fmt (f), vr (v), lsz (l), wdt (w), hgt (h) {} 77 FramebufferPixelFormat_T pixelFormat() { return fmt; } 78 uchar *vram() { return vr; } 79 unsigned lineSize() { return lsz; } 80 int width() { return wdt; } 81 int height() { return hgt; } 82 private: 83 FramebufferPixelFormat_T fmt; 84 uchar *vr; 85 unsigned lsz; 86 int wdt; 87 int hgt; 75 76 VBoxResizeEvent (ulong aPixelFormat, uchar *aVRAM, 77 ulong aBitsPerPixel, ulong aBytesPerLine, 78 ulong aWidth, ulong aHeight) : 79 QEvent ((QEvent::Type) VBoxDefs::ResizeEventType), 80 mPixelFormat (aPixelFormat), mVRAM (aVRAM), mBitsPerPixel (aBitsPerPixel), 81 mBytesPerLine (aBytesPerLine), mWidth (aWidth), mHeight (aHeight) {} 82 ulong pixelFormat() { return mPixelFormat; } 83 uchar *VRAM() { return mVRAM; } 84 ulong bitsPerPixel() { return mBitsPerPixel; } 85 ulong bytesPerLine() { return mBytesPerLine; } 86 ulong width() { return mWidth; } 87 ulong height() { return mHeight; } 88 89 private: 90 91 ulong mPixelFormat; 92 uchar *mVRAM; 93 ulong mBitsPerPixel; 94 ulong mBytesPerLine; 95 ulong mWidth; 96 ulong mHeight; 88 97 }; 89 98 … … 145 154 bool rc = pm.convertFromImage (QImage (addr, 146 155 display.GetWidth(), display.GetHeight(), 147 display.Get ColorDepth(),156 display.GetBitsPerPixel(), 148 157 0, 0, QImage::LittleEndian)); 149 158 AssertMsg (rc, ("convertFromImage() must always return true")); … … 157 166 158 167 ///////////////////////////////////////////////////////////////////////////// 159 160 /* Framebuffer render mode */161 typedef enum162 {163 RenderModeNormal = 0,164 RenderModeSeamless = 1,165 RenderModeHostWindow = 2166 } FramebufferRenderMode;167 168 168 169 /** … … 198 199 199 200 #if defined (Q_OS_WIN32) 200 STDMETHOD_(ULONG, AddRef)() { 201 202 STDMETHOD_(ULONG, AddRef)() 203 { 201 204 return ::InterlockedIncrement (&refcnt); 202 205 } 206 203 207 STDMETHOD_(ULONG, Release)() 204 208 { … … 208 212 return cnt; 209 213 } 214 210 215 STDMETHOD(QueryInterface) (REFIID riid , void **ppObj) 211 216 { … … 223 228 return E_NOINTERFACE; 224 229 } 230 225 231 #endif 226 232 … … 229 235 STDMETHOD(COMGETTER(Width)) (ULONG *aWidth); 230 236 STDMETHOD(COMGETTER(Height)) (ULONG *aHeight); 231 STDMETHOD(COMGETTER(ColorDepth)) (ULONG *aColorDepth); 232 STDMETHOD(COMGETTER(LineSize)) (ULONG *aLineSize); 233 STDMETHOD(COMGETTER(PixelFormat)) (FramebufferPixelFormat_T *aPixelFormat); 237 STDMETHOD(COMGETTER(BitsPerPixel)) (ULONG *aBitsPerPixel); 238 STDMETHOD(COMGETTER(BytesPerLine)) (ULONG *aBytesPerLine); 239 STDMETHOD(COMGETTER(PixelFormat)) (ULONG *aPixelFormat); 240 STDMETHOD(COMGETTER(UsesGuestVRAM)) (BOOL *aUsesGuestVRAM); 234 241 STDMETHOD(COMGETTER(HeightReduction)) (ULONG *aHeightReduction); 235 242 STDMETHOD(COMGETTER(Overlay)) (IFramebufferOverlay **aOverlay); 236 STDMETHOD(COMGETTER(RenderMode)) (FramebufferRenderMode *renderMode);237 STDMETHOD(COMSETTER(RenderMode)) (FramebufferRenderMode renderMode);238 243 239 244 STDMETHOD(Lock)(); 240 245 STDMETHOD(Unlock)(); 241 246 242 STDMETHOD(RequestResize) (ULONG aScreenId, FramebufferPixelFormat_TaPixelFormat,243 BYTE *aVRAM, ULONG a LineSize,247 STDMETHOD(RequestResize) (ULONG aScreenId, ULONG aPixelFormat, 248 BYTE *aVRAM, ULONG aBitsPerPixel, ULONG aBytesPerLine, 244 249 ULONG aWidth, ULONG aHeight, 245 250 BOOL *aFinished); … … 257 262 STDMETHOD(SetVisibleRegion)(BYTE *aRectangles, ULONG aCount); 258 263 259 // Helper functions 260 int width() { return mWdt; } 261 int height() { return mHgt; } 262 263 virtual FramebufferPixelFormat_T pixelFormat() 264 { 265 return FramebufferPixelFormat_PixelFormatOpaque; 264 ulong width() { return mWdt; } 265 ulong height() { return mHgt; } 266 267 virtual ulong pixelFormat() 268 { 269 return FramebufferPixelFormat_FOURCC_RGB; 270 } 271 272 virtual bool usesGuestVRAM() 273 { 274 return false; 266 275 } 267 276 … … 270 279 271 280 virtual uchar *address() = 0; 272 virtual int colorDepth() = 0;273 virtual int lineSize() = 0;281 virtual ulong bitsPerPixel() = 0; 282 virtual ulong bytesPerLine() = 0; 274 283 275 284 /** … … 302 311 int mHgt; 303 312 304 /* Framebuffer render mode */305 FramebufferRenderMode mRenderMode;306 307 313 #if defined (Q_OS_WIN32) 308 314 private: … … 325 331 BOOL *aFinished); 326 332 333 ulong pixelFormat() { return mPixelFormat; } 334 bool usesGuestVRAM() { return mUsesGuestVRAM; } 335 327 336 uchar *address() { return mImg.bits(); } 328 int colorDepth() { return mImg.depth(); }329 int lineSize() { return mImg.bytesPerLine(); }337 ulong bitsPerPixel() { return mImg.depth(); } 338 ulong bytesPerLine() { return mImg.bytesPerLine(); } 330 339 331 340 void paintEvent (QPaintEvent *pe); … … 336 345 QPixmap mPM; 337 346 QImage mImg; 347 ulong mPixelFormat; 348 bool mUsesGuestVRAM; 338 349 }; 339 350 … … 357 368 uchar *address() 358 369 { 359 if (mSurfVRAM) 360 { 361 return (uchar*) (mScreen ? (uintptr_t) mSurfVRAM->pixels : 0); 362 } 363 else 364 { 365 return (uchar*) (mScreen ? (uintptr_t) mScreen->pixels : 0); 366 } 367 } 368 369 int colorDepth() 370 { 371 SDL_Surface *surf = mSurfVRAM ? mSurfVRAM: mScreen; 370 SDL_Surface *surf = mSurfVRAM ? mSurfVRAM : mScreen; 371 return surf ? (uchar *) (uintptr_t) mScreen->pixels : 0; 372 } 373 374 ulong bitsPerPixel() 375 { 376 SDL_Surface *surf = mSurfVRAM ? mSurfVRAM : mScreen; 372 377 return surf ? surf->format->BitsPerPixel : 0; 373 378 } 374 379 375 int lineSize()376 { 377 SDL_Surface *surf = mSurfVRAM ? mSurfVRAM : mScreen;380 ulong bytesPerLine() 381 { 382 SDL_Surface *surf = mSurfVRAM ? mSurfVRAM : mScreen; 378 383 return surf ? surf->pitch : 0; 379 384 } 380 385 381 FramebufferPixelFormat_TpixelFormat()386 ulong pixelFormat() 382 387 { 383 388 return mPixelFormat; 389 } 390 391 bool usesGuestVRAM() 392 { 393 return mSurfVRAM != NULL; 384 394 } 385 395 … … 392 402 SDL_Surface *mSurfVRAM; 393 403 394 uchar *mPtrVRAM; 395 ULONG mLineSize; 396 FramebufferPixelFormat_T mPixelFormat; 404 ulong mPixelFormat; 397 405 }; 398 406 … … 414 422 BOOL *aFinished); 415 423 416 uchar *address() { return (uchar *)mSurfaceDesc.lpSurface; } 417 int colorDepth() { return mSurfaceDesc.ddpfPixelFormat.dwRGBBitCount; } 418 int lineSize() { return mSurfaceDesc.lPitch; } 419 420 FramebufferPixelFormat_T pixelFormat() { return mPixelFormat; }; 424 uchar *address() { return (uchar *) mSurfaceDesc.lpSurface; } 425 ulong bitsPerPixel() { return mSurfaceDesc.ddpfPixelFormat.dwRGBBitCount; } 426 ulong bytesPerLine() { return (ulong) mSurfaceDesc.lPitch; } 427 428 ulong pixelFormat() { return mPixelFormat; }; 429 430 bool usesGuestVRAM() { return mUsesGuestVRAM; } 421 431 422 432 void paintEvent (QPaintEvent *pe); … … 425 435 426 436 private: 437 427 438 void releaseObjects(); 428 439 429 void setupSurface (FramebufferPixelFormat_T pixelFormat, uchar *pvVRAM, ULONG lineSize, ULONG w, ULONG h); 430 void recreateSurface (FramebufferPixelFormat_T pixelFormat, uchar *pvVRAM, ULONG lineSize, ULONG w, ULONG h); 431 void deleteSurface (); 440 bool createSurface (ULONG aPixelFormat, uchar *pvVRAM, 441 ULONG aBitsPerPixel, ULONG aBytesPerLine, 442 ULONG aWidth, ULONG aHeight); 443 void deleteSurface(); 432 444 void drawRect (ULONG x, ULONG y, ULONG w, ULONG h); 433 445 void getWindowPosition (void); … … 439 451 LPDIRECTDRAWSURFACE7 mPrimarySurface; 440 452 441 FramebufferPixelFormat_TmPixelFormat;442 443 BOOL mGuestVRAMSurface;453 ulong mPixelFormat; 454 455 bool mUsesGuestVRAM; 444 456 445 457 int mWndX; 446 458 int mWndY; 447 459 448 BOOLmSynchronousUpdates;460 bool mSynchronousUpdates; 449 461 }; 450 462 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBDDRAW.cpp
r3611 r3761 138 138 mSurface (NULL), 139 139 mPrimarySurface (NULL), 140 mPixelFormat (FramebufferPixelFormat_ PixelFormatOpaque),141 m GuestVRAMSurface (FALSE),140 mPixelFormat (FramebufferPixelFormat_FOURCC_RGB), 141 mUsesGuestVRAM (false), 142 142 mWndX (0), 143 143 mWndY (0), 144 mSynchronousUpdates ( TRUE)144 mSynchronousUpdates (true) 145 145 { 146 146 memset (&mSurfaceDesc, 0, sizeof (mSurfaceDesc)); 147 147 148 LOGDDRAW (("DDRAW: Creating\n"));148 LOGDDRAW (("DDRAW: Creating\n")); 149 149 150 150 /* Release all created objects if something will go wrong. */ … … 167 167 VBoxResizeEvent *re = 168 168 new VBoxResizeEvent (FramebufferPixelFormat_PixelFormatOpaque, 169 NULL, 0, 640, 480);169 NULL, 0, 0, 640, 480); 170 170 171 171 if (re) … … 246 246 void VBoxDDRAWFrameBuffer::paintEvent (QPaintEvent *pe) 247 247 { 248 LOGDDRAW(("DDRAW: paintEvent %d,%d %dx%d\n", pe->rect().x(), pe->rect().y(), pe->rect().width(), pe->rect().height())); 249 250 drawRect (pe->rect().x(), pe->rect().y(), pe->rect().width(), pe->rect().height()); 248 LOGDDRAW (("DDRAW: paintEvent %d,%d %dx%d\n", 249 pe->rect().x(), pe->rect().y(), 250 pe->rect().width(), pe->rect().height())); 251 252 drawRect (pe->rect().x(), pe->rect().y(), 253 pe->rect().width(), pe->rect().height()); 251 254 } 252 255 253 256 void VBoxDDRAWFrameBuffer::resizeEvent (VBoxResizeEvent *re) 254 257 { 255 LOGDDRAW(("DDRAW: resizeEvent %d, %p, %d %dx%d\n", re->pixelFormat (), re->vram (), re->lineSize (), re->width(), re->height())); 258 LOGDDRAW (("DDRAW: resizeEvent %d, %p, %d %d %dx%d\n", 259 re->pixelFormat(), re->VRAM(), re->bitsPerPixel(), 260 re->bytesPerLine(), re->width(), re->height())); 256 261 257 262 VBoxFrameBuffer::resizeEvent (re); 258 263 259 setupSurface (re->pixelFormat (), re->vram (), re->lineSize (), re->width(), re->height()); 260 261 getWindowPosition (); 264 bool ok = createSurface (re->pixelFormat(), re->VRAM (), re->bitsPerPixel(), 265 re->bytesPerLine (), re->width(), re->height()); 266 if (!ok && re->pixelFormat() != FramebufferPixelFormat_PixelFormatOpaque) 267 { 268 /* try to create a fallback surface with indirect buffer 269 * (only if haven't done so already) */ 270 ok = createSurface (FramebufferPixelFormat_PixelFormatOpaque, 271 NULL, 0, 0, re->width(), re->height()); 272 } 273 274 Assert (ok); 275 276 getWindowPosition(); 262 277 263 278 mView->setBackgroundMode (Qt::NoBackground); … … 266 281 void VBoxDDRAWFrameBuffer::moveEvent (QMoveEvent *me) 267 282 { 268 getWindowPosition (); 269 } 270 283 getWindowPosition(); 284 } 271 285 272 286 /* … … 274 288 */ 275 289 276 /* Setups a surface with requested format or a default surface if 277 * requested format is not supportred. 278 * Assigns VBoxDDRAWFrameBuffer::mSurface to the new surface 279 * and VBoxDDRAWFrameBuffer::mPixelFormat to format of the created surface. 280 */ 281 void VBoxDDRAWFrameBuffer::setupSurface (FramebufferPixelFormat_T pixelFormat, uchar *pvVRAM, ULONG lineSize, ULONG w, ULONG h) 282 { 283 /* Check requested pixel format. */ 284 switch (pixelFormat) 285 { 286 case FramebufferPixelFormat_PixelFormatRGB32: 287 case FramebufferPixelFormat_PixelFormatRGB24: 288 case FramebufferPixelFormat_PixelFormatRGB16: 289 { 290 /* Supported formats. Do nothing. */ 291 Assert(lineSize >= w); 292 } break; 293 294 default: 295 { 296 /* Unsupported format leads to use of the default format. */ 297 pixelFormat = FramebufferPixelFormat_PixelFormatOpaque; 298 } 299 } 300 301 recreateSurface (pixelFormat, pvVRAM, lineSize, w, h); 302 303 if (!mSurface && pixelFormat != FramebufferPixelFormat_PixelFormatOpaque) 304 { 305 /* Unable to create a new surface. Try to create a default format surface. */ 306 pixelFormat = FramebufferPixelFormat_PixelFormatOpaque; 307 recreateSurface (pixelFormat, NULL, 0, w, h); 308 } 309 310 mPixelFormat = pixelFormat; 311 } 312 313 /* Deletes existing and creates a new surface with requested format. 314 * Assigns VBoxDDRAWFrameBuffer::mSurface to the new surface if 315 * the requested format is supported and the surface was successfully created. 316 */ 317 void VBoxDDRAWFrameBuffer::recreateSurface (FramebufferPixelFormat_T pixelFormat, uchar *pvVRAM, ULONG lineSize, ULONG w, ULONG h) 318 { 319 HRESULT rc; 320 321 deleteSurface (); 290 /** 291 * Creates a new surface in the requested format. 292 * On success, returns @c true and assigns the created surface to mSurface 293 * and its definition to mSurfaceDesc. On failure, returns @c false. 294 * 295 * If @a aPixelFormat is other than FramebufferPixelFormat_PixelFormatOpaque, 296 * then the method will attempt to attach @a aVRAM directly to the created 297 * surface. If this fails, the caller may call this method again with 298 * @a aPixelFormat set to FramebufferPixelFormat_PixelFormatOpaque to try 299 * setting up an indirect fallback buffer for the surface. This opeartion may 300 * theoretically also fail. 301 * 302 * @note Deletes the existing surface before attemting to create a new one. 303 */ 304 bool VBoxDDRAWFrameBuffer::createSurface (ULONG aPixelFormat, uchar *aVRAM, 305 ULONG aBitsPerPixel, ULONG aBytesPerLine, 306 ULONG aWidth, ULONG aHeight) 307 { 308 deleteSurface(); 322 309 323 310 DDSURFACEDESC2 sd; … … 331 318 332 319 sd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; 333 sd.dwWidth = w; 334 sd.dwHeight = h; 335 336 if (pixelFormat == FramebufferPixelFormat_PixelFormatOpaque) 337 { 338 /* Default format is a 32 bpp surface. */ 339 sd.lPitch = sd.dwWidth * 4; 340 } 341 else 342 { 343 sd.lPitch = lineSize; 344 } 320 sd.dwWidth = aWidth; 321 sd.dwHeight = aHeight; 345 322 346 323 /* Setup the desired pixel format on the surface. */ … … 349 326 sd.ddpfPixelFormat.dwFlags = DDPF_RGB; 350 327 351 switch (pixelFormat) 352 { 353 case FramebufferPixelFormat_PixelFormatOpaque: 354 case FramebufferPixelFormat_PixelFormatRGB32: 355 { 356 sd.ddpfPixelFormat.dwRGBBitCount = 32; 357 sd.ddpfPixelFormat.dwRBitMask = 0x00FF0000; 358 sd.ddpfPixelFormat.dwGBitMask = 0x0000FF00; 359 sd.ddpfPixelFormat.dwBBitMask = 0x000000FF; 360 } break; 361 362 case FramebufferPixelFormat_PixelFormatRGB24: 363 { 364 sd.ddpfPixelFormat.dwRGBBitCount = 24; 365 sd.ddpfPixelFormat.dwRBitMask = 0x00FF0000; 366 sd.ddpfPixelFormat.dwGBitMask = 0x0000FF00; 367 sd.ddpfPixelFormat.dwBBitMask = 0x000000FF; 368 } break; 369 370 case FramebufferPixelFormat_PixelFormatRGB16: 371 { 372 sd.ddpfPixelFormat.dwRGBBitCount = 16; 373 sd.ddpfPixelFormat.dwRBitMask = 0xF800; 374 sd.ddpfPixelFormat.dwGBitMask = 0x07E0; 375 sd.ddpfPixelFormat.dwBBitMask = 0x001F; 376 } break; 377 } 378 379 /* Allocate surface memory. */ 380 if (pvVRAM != NULL && pixelFormat != FramebufferPixelFormat_PixelFormatOpaque) 381 { 382 sd.lpSurface = pvVRAM; 383 mGuestVRAMSurface = TRUE; 328 if (aPixelFormat == FramebufferPixelFormat_FOURCC_RGB) 329 { 330 /* Try to use the guest VRAM directly */ 331 332 switch (aBitsPerPixel) 333 { 334 case 32: 335 sd.ddpfPixelFormat.dwRGBBitCount = 32; 336 sd.ddpfPixelFormat.dwRBitMask = 0x00FF0000; 337 sd.ddpfPixelFormat.dwGBitMask = 0x0000FF00; 338 sd.ddpfPixelFormat.dwBBitMask = 0x000000FF; 339 break; 340 case 24: 341 sd.ddpfPixelFormat.dwRGBBitCount = 24; 342 sd.ddpfPixelFormat.dwRBitMask = 0x00FF0000; 343 sd.ddpfPixelFormat.dwGBitMask = 0x0000FF00; 344 sd.ddpfPixelFormat.dwBBitMask = 0x000000FF; 345 break; 346 case 16: 347 sd.ddpfPixelFormat.dwRGBBitCount = 16; 348 sd.ddpfPixelFormat.dwRBitMask = 0xF800; 349 sd.ddpfPixelFormat.dwGBitMask = 0x07E0; 350 sd.ddpfPixelFormat.dwBBitMask = 0x001F; 351 break; 352 default: 353 /* we don't directly support any other color depth */ 354 return false; 355 } 356 357 sd.lPitch = (LONG) aBytesPerLine; 358 359 sd.lpSurface = aVRAM; 360 mUsesGuestVRAM = true; 361 362 mPixelFormat = FramebufferPixelFormat_FOURCC_RGB; 384 363 } 385 364 else 386 { 365 if (aPixelFormat != FramebufferPixelFormat_PixelFormatOpaque) 366 { 367 /* we don't directly support any other pixel format */ 368 return false; 369 } 370 else 371 { 372 /* for the Opaque format, we use the indirect memory buffer as a 373 * 32 bpp surface. */ 374 375 sd.ddpfPixelFormat.dwRGBBitCount = 32; 376 sd.ddpfPixelFormat.dwRBitMask = 0x00FF0000; 377 sd.ddpfPixelFormat.dwGBitMask = 0x0000FF00; 378 sd.ddpfPixelFormat.dwBBitMask = 0x000000FF; 379 380 sd.lPitch = sd.dwWidth * 4; 381 382 /* Allocate the memory buffer for the surface */ 387 383 sd.lpSurface = RTMemAlloc (sd.lPitch * sd.dwHeight); 388 } 389 390 if (!sd.lpSurface) 391 { 392 LOGDDRAW(("DDRAW: could not allocate memory for surface.\n")); 393 return; 394 } 395 396 rc = mDDRAW->CreateSurface (&sd, &mSurface, NULL); 384 if (sd.lpSurface == NULL) 385 { 386 LOGDDRAW (("DDRAW: could not allocate memory for surface.\n")); 387 return false; 388 } 389 mUsesGuestVRAM = false; 390 391 mPixelFormat = FramebufferPixelFormat_FOURCC_RGB; 392 } 393 394 /* create the surface */ 395 HRESULT rc = mDDRAW->CreateSurface (&sd, &mSurface, NULL); 397 396 398 397 if (rc != DD_OK) 399 398 { 400 LOGDDRAW(("DDRAW: Could not create DirectDraw surface rc = 0x%08X\n", rc)); 401 } 402 else 403 { 404 /* Initialize the surface description. It will be used to obtain address, lineSize and bpp. */ 405 mSurfaceDesc = sd; 406 407 LOGDDRAW(("DDRAW: Created %s surface: format = %d, address = %p\n", 408 mGuestVRAMSurface ? "GuestVRAM": "system memory", 409 pixelFormat, address ())); 410 } 411 412 if (rc != DD_OK) 413 { 414 deleteSurface (); 415 } 416 else 417 { 418 if (!mGuestVRAMSurface) 419 { 420 /* Clear just created surface. */ 421 memset (this->address (), 0, this->lineSize () * this->height ()); 422 } 423 } 399 LOGDDRAW (("DDRAW: Could not create DirectDraw surface, rc=0x%08X\n", rc)); 400 deleteSurface(); 401 return false; 402 } 403 404 /* Initialize the surface description member. It will be used to obtain 405 * address, bpp and bpl. */ 406 mSurfaceDesc = sd; 407 408 LOGDDRAW(("DDRAW: Created %s surface: format = %d, address = %p\n", 409 mUsesGuestVRAM ? "GuestVRAM": "system memory", 410 aPixelFormat, address ())); 411 412 if (!mUsesGuestVRAM) 413 { 414 /* Clear just created surface. */ 415 memset (address(), 0, bytesPerLine() * height()); 416 } 417 418 return true; 424 419 } 425 420 … … 431 426 mSurface = NULL; 432 427 433 if (!m GuestVRAMSurface)428 if (!mUsesGuestVRAM) 434 429 { 435 430 RTMemFree (mSurfaceDesc.lpSurface); … … 437 432 438 433 memset (&mSurfaceDesc, '\0', sizeof (mSurfaceDesc)); 439 mGuestVRAMSurface = FALSE; 440 } 441 } 442 443 /* Draw a rectangular area of guest screen DDRAW surface onto the 434 mUsesGuestVRAM = false; 435 } 436 } 437 438 /** 439 * Draws a rectangular area of guest screen DDRAW surface onto the 444 440 * host screen primary surface. 445 441 */ 446 442 void VBoxDDRAWFrameBuffer::drawRect (ULONG x, ULONG y, ULONG w, ULONG h) 447 443 { 448 LOGDDRAW (("DDRAW: drawRect: %d,%d, %dx%d\n", x, y, w, h));444 LOGDDRAW (("DDRAW: drawRect: %d,%d, %dx%d\n", x, y, w, h)); 449 445 450 446 if (mSurface && w > 0 && h > 0) -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxFrameBuffer.cpp
r3747 r3761 49 49 { 50 50 AssertMsg (mView, ("VBoxConsoleView must not be null\n")); 51 52 /* Default framebuffer render mode is normal (draw the entire framebuffer) */53 mRenderMode = RenderModeNormal;54 51 } 55 52 … … 86 83 } 87 84 88 STDMETHODIMP VBoxFrameBuffer::COMGETTER( ColorDepth) (ULONG *aColorDepth)89 { 90 if (!a ColorDepth)91 return E_POINTER; 92 *a ColorDepth = (ULONG) colorDepth();93 return S_OK; 94 } 95 96 STDMETHODIMP VBoxFrameBuffer::COMGETTER( LineSize) (ULONG *aLineSize)97 { 98 if (!a LineSize)99 return E_POINTER; 100 *a LineSize = (ULONG) lineSize();85 STDMETHODIMP VBoxFrameBuffer::COMGETTER(BitsPerPixel) (ULONG *aBitsPerPixel) 86 { 87 if (!aBitsPerPixel) 88 return E_POINTER; 89 *aBitsPerPixel = bitsPerPixel(); 90 return S_OK; 91 } 92 93 STDMETHODIMP VBoxFrameBuffer::COMGETTER(BytesPerLine) (ULONG *aBytesPerLine) 94 { 95 if (!aBytesPerLine) 96 return E_POINTER; 97 *aBytesPerLine = bytesPerLine(); 101 98 return S_OK; 102 99 } 103 100 104 101 STDMETHODIMP VBoxFrameBuffer::COMGETTER(PixelFormat) ( 105 FramebufferPixelFormat_T*aPixelFormat)102 ULONG *aPixelFormat) 106 103 { 107 104 if (!aPixelFormat) 108 105 return E_POINTER; 109 106 *aPixelFormat = pixelFormat(); 107 return S_OK; 108 } 109 110 STDMETHODIMP VBoxFrameBuffer::COMGETTER(UsesGuestVRAM) ( 111 BOOL *aUsesGuestVRAM) 112 { 113 if (!aUsesGuestVRAM) 114 return E_POINTER; 115 *aUsesGuestVRAM = usesGuestVRAM(); 110 116 return S_OK; 111 117 } … … 129 135 } 130 136 131 /**132 * Return the current framebuffer render mode133 *134 * @returns COM status code135 * @param renderMode framebuffer render mode136 */137 STDMETHODIMP VBoxFrameBuffer::COMGETTER(RenderMode) (FramebufferRenderMode *renderMode)138 {139 if (!renderMode)140 return E_POINTER;141 *renderMode = mRenderMode;142 return S_OK;143 }144 145 /**146 * Change the current framebuffer render mode147 *148 * @returns COM status code149 * @param renderMode framebuffer render mode150 */151 STDMETHODIMP VBoxFrameBuffer::COMSETTER(RenderMode) (FramebufferRenderMode renderMode)152 {153 if (!renderMode)154 return E_POINTER;155 mRenderMode = renderMode;156 return S_OK;157 }158 159 137 STDMETHODIMP VBoxFrameBuffer::Lock() 160 138 { … … 170 148 171 149 /** @note This method is called on EMT from under this object's lock */ 172 STDMETHODIMP VBoxFrameBuffer::RequestResize (ULONG aScreenId, FramebufferPixelFormat_TaPixelFormat,173 BYTE *aVRAM, ULONG a LineSize,150 STDMETHODIMP VBoxFrameBuffer::RequestResize (ULONG aScreenId, ULONG aPixelFormat, 151 BYTE *aVRAM, ULONG aBitsPerPixel, ULONG aBytesPerLine, 174 152 ULONG aWidth, ULONG aHeight, 175 153 BOOL *aFinished) 176 154 { 177 155 QApplication::postEvent (mView, 178 new VBoxResizeEvent (aPixelFormat, aVRAM, 179 a LineSize, aWidth, aHeight));156 new VBoxResizeEvent (aPixelFormat, aVRAM, aBitsPerPixel, 157 aBytesPerLine, aWidth, aHeight)); 180 158 181 159 #ifdef DEBUG_sunlover 182 Log (("VBoxFrameBuffer::RequestResize: pixelFormat %d, vram %p, lineSize %d, w %d, h%d\n",183 aPixelFormat, aVRAM, a LineSize, aWidth, aHeight));160 LogFlowFunc (("pixelFormat=%d, vram=%p, bpp=%d, bpl=%d, w=%d, h=%d\n", 161 aPixelFormat, aVRAM, aBitsPerPixel, aBytesPerLine, aWidth, aHeight)); 184 162 #endif /* DEBUG_sunlover */ 185 163 … … 316 294 { 317 295 resizeEvent (new VBoxResizeEvent (FramebufferPixelFormat_PixelFormatOpaque, 318 NULL, 0, 640, 480));296 NULL, 0, 0, 640, 480)); 319 297 } 320 298 … … 349 327 return; 350 328 351 // LogFlowFunc (("%d,%d-%d,%d (img: %d,%d)\n", 352 // r.x(), r.y(), r.width(), r.height(), 353 // img.width(), img.height())); 329 #if 0 330 LogFlowFunc (("%dx%d-%dx%d (img=%dx%d)\n", 331 r.x(), r.y(), r.width(), r.height(), 332 img.width(), img.height())); 333 #endif 354 334 355 335 FRAMEBUF_DEBUG_START (xxx); … … 385 365 void VBoxQImageFrameBuffer::resizeEvent (VBoxResizeEvent *re) 386 366 { 367 #if 0 368 LogFlowFunc (("fmt=%d, vram=%p, bpp=%d, bpl=%d, width=%d, height=%d\n", 369 re->pixelFormat(), re->VRAM(), 370 re->bitsPerPixel(), re->bytesPerLine(), 371 re->width(), re->height())); 372 #endif 373 387 374 mWdt = re->width(); 388 375 mHgt = re->height(); 389 376 390 377 mImg = QImage (mWdt, mHgt, 32, 0, QImage::LittleEndian); 378 mPixelFormat = FramebufferPixelFormat_FOURCC_RGB; 379 mUsesGuestVRAM = false; 391 380 } 392 381 … … 409 398 { 410 399 mScreen = NULL; 411 mPixelFormat = FramebufferPixelFormat_PixelFormatOpaque; 412 mPtrVRAM = NULL; 400 mPixelFormat = FramebufferPixelFormat_FOURCC_RGB; 413 401 mSurfVRAM = NULL; 414 mLineSize = 0;415 402 416 403 resizeEvent (new VBoxResizeEvent (FramebufferPixelFormat_PixelFormatOpaque, 417 NULL, 0, 640, 480));404 NULL, 0, 0, 640, 480)); 418 405 } 419 406 … … 422 409 if (mSurfVRAM) 423 410 { 424 SDL_FreeSurface (mSurfVRAM);411 SDL_FreeSurface (mSurfVRAM); 425 412 mSurfVRAM = NULL; 426 413 } … … 470 457 } 471 458 472 void VBoxSDLFrameBuffer::resizeEvent ( VBoxResizeEvent *re)459 void VBoxSDLFrameBuffer::resizeEvent (VBoxResizeEvent *re) 473 460 { 474 461 mWdt = re->width(); … … 492 479 */ 493 480 static char sdlHack[64]; 494 sprintf (sdlHack, "SDL_WINDOWID=0x%lx", mView->viewport()->winId()); 481 LogFlowFunc (("Using client window 0x%08lX to initialize SDL\n", 482 mView->viewport()->winId())); 483 /* Note: SDL_WINDOWID must be decimal (not hex) to work on Win32 */ 484 sprintf (sdlHack, "SDL_WINDOWID=%lu", mView->viewport()->winId()); 495 485 putenv (sdlHack); 496 486 int rc = SDL_InitSubSystem (SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE); 497 AssertMsg (rc == 0, ("SDL initialization failed !\n"));487 AssertMsg (rc == 0, ("SDL initialization failed: %s\n", SDL_GetError())); 498 488 NOREF(rc); 499 489 … … 506 496 LogFlowFunc (("Setting SDL video mode to %d x %d\n", mWdt, mHgt)); 507 497 508 mPixelFormat = re->pixelFormat(); 509 mPtrVRAM = re->vram(); 510 mLineSize = re->lineSize(); 511 512 int bitsPerPixel = 0; 498 bool fallback = false; 513 499 514 500 Uint32 Rmask = 0; 515 501 Uint32 Gmask = 0; 516 502 Uint32 Bmask = 0; 517 Uint32 Amask = 0; 518 519 switch (mPixelFormat) 520 { 521 case FramebufferPixelFormat_PixelFormatRGB32: 503 504 if (re->pixelFormat() == FramebufferPixelFormat_FOURCC_RGB) 505 { 506 switch (re->bitsPerPixel()) 522 507 { 523 bitsPerPixel = 32; 524 Rmask = 0x00FF0000; 525 Gmask = 0x0000FF00; 526 Bmask = 0x000000FF; 527 } break; 528 529 case FramebufferPixelFormat_PixelFormatRGB24: 508 case 32: 509 Rmask = 0x00FF0000; 510 Gmask = 0x0000FF00; 511 Bmask = 0x000000FF; 512 break; 513 case 24: 514 Rmask = 0x00FF0000; 515 Gmask = 0x0000FF00; 516 Bmask = 0x000000FF; 517 break; 518 case 16: 519 Rmask = 0xF800; 520 Gmask = 0x07E0; 521 Bmask = 0x001F; 522 default: 523 /* Unsupported format leads to the indirect buffer */ 524 fallback = true; 525 break; 526 } 527 528 if (!fallback) 530 529 { 531 bitsPerPixel = 24; 532 Rmask = 0x00FF0000; 533 Gmask = 0x0000FF00; 534 Bmask = 0x000000FF; 535 } break; 536 537 case FramebufferPixelFormat_PixelFormatRGB16: 538 { 539 bitsPerPixel = 16; 540 Rmask = 0xF800; 541 Gmask = 0x07E0; 542 Bmask = 0x001F; 543 } break; 544 545 default: 546 { 547 /* Unsupported format leads to use of the default format. */ 548 mPixelFormat = FramebufferPixelFormat_PixelFormatOpaque; 530 /* Create a source surface from guest VRAM. */ 531 mSurfVRAM = SDL_CreateRGBSurfaceFrom(re->VRAM(), mWdt, mHgt, 532 re->bitsPerPixel(), 533 re->bytesPerLine(), 534 Rmask, Gmask, Bmask, 0); 535 LogFlowFunc (("Created VRAM surface %p\n", mSurfVRAM)); 536 if (mSurfVRAM == NULL) 537 fallback = true; 549 538 } 550 539 } 551 552 if (mPixelFormat != FramebufferPixelFormat_PixelFormatOpaque)553 {554 /* Create a source surface from guest VRAM. */555 mSurfVRAM = SDL_CreateRGBSurfaceFrom(mPtrVRAM, mWdt, mHgt, bitsPerPixel,556 mLineSize, Rmask, Gmask, Bmask, Amask); 557 LogFlowFunc (("Created VRAM surface %p\n", mSurfVRAM));558 }540 else 541 { 542 /* Unsupported format leads to the indirect buffer */ 543 fallback = true; 544 } 545 546 /* Pixel format is RGB in any case */ 547 mPixelFormat = FramebufferPixelFormat_FOURCC_RGB; 559 548 560 549 mScreen = SDL_SetVideoMode (mWdt, mHgt, 0,
Note:
See TracChangeset
for help on using the changeset viewer.