Changeset 28220 in vbox for trunk/src/VBox/Devices/Graphics/DevVGA.cpp
- Timestamp:
- Apr 12, 2010 5:04:54 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA.cpp
r28129 r28220 5304 5304 } 5305 5305 5306 static DECLCALLBACK(void) vgaPortUpdateDisplayRectEx (PPDMIDISPLAYPORT pInterface, 5307 int32_t x, 5308 int32_t y, 5309 uint32_t w, 5310 uint32_t h, 5311 const uint8_t *pu8SrcVRAM, 5312 uint32_t u32SrcWidth, 5313 uint32_t u32SrcHeight, 5314 uint32_t u32SrcLineSize, 5315 uint32_t u32SrcBitsPerPixel, 5316 uint8_t *pu8DstBuffer, 5317 uint32_t u32DstWidth, 5318 uint32_t u32DstHeight, 5319 uint32_t u32DstLineSize, 5320 uint32_t u32DstBitsPerPixel) 5321 { 5322 NOREF(u32DstWidth); 5323 NOREF(u32DstHeight); 5324 5306 static DECLCALLBACK(int) vgaPortCopyRect (PPDMIDISPLAYPORT pInterface, 5307 uint32_t w, 5308 uint32_t h, 5309 const uint8_t *pu8Src, 5310 int32_t xSrc, 5311 int32_t ySrc, 5312 uint32_t u32SrcWidth, 5313 uint32_t u32SrcHeight, 5314 uint32_t u32SrcLineSize, 5315 uint32_t u32SrcBitsPerPixel, 5316 uint8_t *pu8Dst, 5317 int32_t xDst, 5318 int32_t yDst, 5319 uint32_t u32DstWidth, 5320 uint32_t u32DstHeight, 5321 uint32_t u32DstLineSize, 5322 uint32_t u32DstBitsPerPixel) 5323 { 5325 5324 uint32_t v; 5326 5325 vga_draw_line_func *vga_draw_line; … … 5328 5327 uint32_t cbPixelDst; 5329 5328 uint32_t cbLineDst; 5330 uint8_t *pu8Dst ;5329 uint8_t *pu8DstPtr; 5331 5330 5332 5331 uint32_t cbPixelSrc; 5333 5332 uint32_t cbLineSrc; 5334 const uint8_t *pu8Src; 5335 5336 uint32_t u32OffsetSrc, u32Dummy; 5333 const uint8_t *pu8SrcPtr; 5334 5335 #ifdef DEBUG_sunlover 5336 LogFlow(("vgaPortCopyRect: %d,%d %dx%d -> %d,%d\n", xSrc, ySrc, w, h, xDst, yDst)); 5337 #endif /* DEBUG_sunlover */ 5337 5338 5338 5339 PVGASTATE s = IDISPLAYPORT_2_VGASTATE(pInterface); 5339 5340 #ifdef DEBUG_sunlover5341 LogFlow(("vgaPortUpdateDisplayRectEx: %d,%d %dx%d\n", x, y, w, h));5342 #endif /* DEBUG_sunlover */5343 5340 5344 5341 Assert(pInterface); 5345 5342 Assert(s->pDrv); 5346 5343 5347 int rc = PDMCritSectEnter(&s->lock, VERR_SEM_BUSY); 5348 AssertRC(rc); 5349 5350 /* Correct negative x and y coordinates. */ 5351 if (x < 0) 5352 { 5353 x += w; /* Compute xRight which is also the new width. */ 5354 w = (x < 0) ? 0 : x; 5355 x = 0; 5356 } 5357 5358 if (y < 0) 5359 { 5360 y += h; /* Compute yBottom, which is also the new height. */ 5361 h = (y < 0) ? 0 : y; 5362 y = 0; 5344 int32_t xSrcCorrected = xSrc; 5345 int32_t ySrcCorrected = ySrc; 5346 uint32_t wCorrected = w; 5347 uint32_t hCorrected = h; 5348 5349 /* Correct source coordinates to be within the source bitmap. */ 5350 if (xSrcCorrected < 0) 5351 { 5352 xSrcCorrected += wCorrected; /* Compute xRight which is also the new width. */ 5353 wCorrected = (xSrcCorrected < 0) ? 0 : xSrcCorrected; 5354 xSrcCorrected = 0; 5355 } 5356 5357 if (ySrcCorrected < 0) 5358 { 5359 ySrcCorrected += hCorrected; /* Compute yBottom, which is also the new height. */ 5360 hCorrected = (ySrcCorrected < 0) ? 0 : ySrcCorrected; 5361 ySrcCorrected = 0; 5363 5362 } 5364 5363 5365 5364 /* Also check if coords are greater than the display resolution. */ 5366 if (x + w> u32SrcWidth)5367 { 5368 / / x < 0 is not possible here5369 w = u32SrcWidth > (uint32_t)x? u32SrcWidth - x: 0;5370 } 5371 5372 if (y + h> u32SrcHeight)5373 { 5374 / / y < 0 is not possible here5375 h = u32SrcHeight > (uint32_t)y? u32SrcHeight - y: 0;5365 if (xSrcCorrected + wCorrected > u32SrcWidth) 5366 { 5367 /* xSrcCorrected < 0 is not possible here */ 5368 wCorrected = u32SrcWidth > (uint32_t)xSrcCorrected? u32SrcWidth - xSrcCorrected: 0; 5369 } 5370 5371 if (ySrcCorrected + hCorrected > u32SrcHeight) 5372 { 5373 /* y < 0 is not possible here */ 5374 hCorrected = u32SrcHeight > (uint32_t)ySrcCorrected? u32SrcHeight - ySrcCorrected: 0; 5376 5375 } 5377 5376 5378 5377 #ifdef DEBUG_sunlover 5379 LogFlow(("vgaPort UpdateDisplayRectEx: %d,%d %dx%d (corrected coords)\n", x, y, w, h));5378 LogFlow(("vgaPortCopyRect: %d,%d %dx%d (corrected coords)\n", xSrcCorrected, ySrcCorrected, wCorrected, hCorrected)); 5380 5379 #endif /* DEBUG_sunlover */ 5381 5380 5382 5381 /* Check if there is something to do at all. */ 5383 if (w == 0 || h== 0)5382 if (wCorrected == 0 || hCorrected == 0) 5384 5383 { 5385 5384 /* Empty rectangle. */ 5386 5385 #ifdef DEBUG_sunlover 5387 LogFlow(("vgaPortUpdateDisplayRectEx: nothing to do: %dx%d\n", w , h));5386 LogFlow(("vgaPortUpdateDisplayRectEx: nothing to do: %dx%d\n", wCorrected, hCorrected)); 5388 5387 #endif /* DEBUG_sunlover */ 5389 PDMCritSectLeave(&s->lock); 5390 return; 5388 return VINF_SUCCESS; 5389 } 5390 5391 /* Check that the corrected source rectangle is within the destination. 5392 * Note: source rectangle is adjusted, but the target must be large enough. 5393 */ 5394 if ( xDst < 0 5395 || yDst < 0 5396 || xDst + wCorrected > u32DstWidth 5397 || yDst + hCorrected > u32SrcHeight) 5398 { 5399 return VERR_INVALID_PARAMETER; 5391 5400 } 5392 5401 … … 5397 5406 case 0: 5398 5407 /* Nothing to do, just return. */ 5399 PDMCritSectLeave(&s->lock); 5400 return; 5408 return VINF_SUCCESS; 5401 5409 case 8: 5402 5410 v = VGA_DRAW_LINE8; … … 5415 5423 break; 5416 5424 } 5425 5426 int rc = PDMCritSectEnter(&s->lock, VERR_SEM_BUSY); 5427 AssertRC(rc); 5417 5428 5418 5429 vga_draw_line = vga_draw_line_table[v * 4 + get_depth_index(u32DstBitsPerPixel)]; … … 5421 5432 cbPixelDst = (u32DstBitsPerPixel + 7) / 8; 5422 5433 cbLineDst = u32DstLineSize; 5423 pu8Dst = pu8DstBuffer + y * cbLineDst + x* cbPixelDst;5434 pu8DstPtr = pu8Dst + yDst * cbLineDst + xDst * cbPixelDst; 5424 5435 5425 5436 cbPixelSrc = (u32SrcBitsPerPixel + 7) / 8; 5426 5437 cbLineSrc = u32SrcLineSize; 5427 5428 pu8Src = pu8SrcVRAM; 5429 pu8Src += y * cbLineSrc + x * cbPixelSrc; 5430 5431 /* Render VRAM to the buffer. */ 5438 pu8SrcPtr = pu8Src + ySrcCorrected * cbLineSrc + xSrcCorrected * cbPixelSrc; 5432 5439 5433 5440 #ifdef DEBUG_sunlover 5434 LogFlow(("vgaPort UpdateDisplayRectEx: dst: %p, %d, %d. src: %p, %d, %d\n", pu8Dst, cbLineDst, cbPixelDst, pu8Src, cbLineSrc, cbPixelSrc));5441 LogFlow(("vgaPortCopyRect: dst: %p, %d, %d. src: %p, %d, %d\n", pu8DstPtr, cbLineDst, cbPixelDst, pu8SrcPtr, cbLineSrc, cbPixelSrc)); 5435 5442 #endif /* DEBUG_sunlover */ 5436 5443 5437 while (h -- > 0)5438 { 5439 vga_draw_line (s, pu8Dst , pu8Src, w);5440 pu8Dst += cbLineDst;5441 pu8Src += cbLineSrc;5444 while (hCorrected-- > 0) 5445 { 5446 vga_draw_line (s, pu8DstPtr, pu8SrcPtr, wCorrected); 5447 pu8DstPtr += cbLineDst; 5448 pu8SrcPtr += cbLineSrc; 5442 5449 } 5443 5450 PDMCritSectLeave(&s->lock); 5444 5451 5445 5452 #ifdef DEBUG_sunlover 5446 LogFlow(("vgaPort UpdateDisplayRectEx: completed.\n"));5453 LogFlow(("vgaPortCopyRect: completed.\n")); 5447 5454 #endif /* DEBUG_sunlover */ 5455 5456 return VINF_SUCCESS; 5448 5457 } 5449 5458 … … 6118 6127 pThis->IPort.pfnDisplayBlt = vgaPortDisplayBlt; 6119 6128 pThis->IPort.pfnUpdateDisplayRect = vgaPortUpdateDisplayRect; 6120 pThis->IPort.pfn UpdateDisplayRectEx = vgaPortUpdateDisplayRectEx;6129 pThis->IPort.pfnCopyRect = vgaPortCopyRect; 6121 6130 pThis->IPort.pfnSetRenderVRAM = vgaPortSetRenderVRAM; 6122 6131
Note:
See TracChangeset
for help on using the changeset viewer.