Changeset 6520 in vbox
- Timestamp:
- Jan 28, 2008 5:57:15 AM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 27537
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/xgraphics/vboxutils-new.c
r6518 r6520 65 65 CARD32 *color; 66 66 unsigned char *mask; 67 size_t size _mask;67 size_t sizeMask; 68 68 69 69 image += offsetof(VMMDevReqMousePointer, pointerData); 70 70 mask = image; 71 71 pitch = (w + 7) / 8; 72 size _mask= (pitch * h + 3) & ~3;73 color = (CARD32 *)(image + size _mask);72 sizeMask = (pitch * h + 3) & ~3; 73 color = (CARD32 *)(image + sizeMask); 74 74 75 75 TRACE_ENTRY(); … … 179 179 180 180 /* Get the active record and move the pointer along */ 181 indexRecordNext = (pMem->indexRecordFree + 1) 182 % VBVA_MAX_RECORDS; 181 indexRecordNext = (pMem->indexRecordFree + 1) % VBVA_MAX_RECORDS; 183 182 if (indexRecordNext == pMem->indexRecordFirst) 184 183 { … … 208 207 */ 209 208 i32Diff = off32Data - off32Free; 210 cbHwBufferAvail = i32Diff > 0? i32Diff: VBVA_RING_BUFFER_SIZE 211 + i32Diff; 209 cbHwBufferAvail = i32Diff > 0 ? i32Diff : VBVA_RING_BUFFER_SIZE + i32Diff; 212 210 if (cbHwBufferAvail <= VBVA_RING_BUFFER_THRESHOLD) 213 211 { … … 231 229 if (off32Free + sizeof(cmdHdr) < VBVA_RING_BUFFER_SIZE) 232 230 { 233 memcpy(&pMem->au8RingBuffer[off32Free], &cmdHdr, 234 sizeof(cmdHdr)); 231 memcpy(&pMem->au8RingBuffer[off32Free], &cmdHdr, sizeof(cmdHdr)); 235 232 pMem->off32Free = pMem->off32Free + sizeof(cmdHdr); 236 233 } … … 494 491 unsigned short w, h, x, y; 495 492 unsigned char *c, *p, *pm, *ps, *m; 496 size_t size , size_rgba, size_mask, src_pitch, dst_pitch;493 size_t sizeRequest, sizeRgba, sizeMask, srcPitch, dstPitch; 497 494 CARD32 fc, bc, *cp; 498 495 int rc, scrnIndex = infoPtr->pScrn->scrnIndex; … … 513 510 bitsp->xhot, bitsp->yhot, w, h); 514 511 515 src _pitch = PixmapBytePad (bitsp->width, 1);516 dst _pitch = (w + 7) / 8;517 size _mask = ((dst_pitch * h) + 3) & (size_t) ~3;518 size _rgba = w * h * 4;519 pVBox->pointerSize = size _mask + size_rgba;520 size 521 522 p = c = xcalloc (1, size );512 srcPitch = PixmapBytePad (bitsp->width, 1); 513 dstPitch = (w + 7) / 8; 514 sizeMask = ((dstPitch * h) + 3) & (size_t) ~3; 515 sizeRgba = w * h * 4; 516 pVBox->pointerSize = sizeMask + sizeRgba; 517 sizeRequest = pVBox->pointerSize + pVBox->pointerHeaderSize; 518 519 p = c = xcalloc (1, sizeRequest); 523 520 if (!c) 524 521 RETERROR(scrnIndex, NULL, 525 522 "Error failed to alloc %lu bytes for cursor\n", 526 (unsigned long) size );523 (unsigned long) sizeRequest); 527 524 528 525 rc = vmmdevInitRequest((VMMDevRequestHeader *)p, VMMDevReq_SetPointerShape); … … 535 532 536 533 m = p + offsetof(VMMDevReqMousePointer, pointerData); 537 cp = (CARD32 *)(m + size _mask);534 cp = (CARD32 *)(m + sizeMask); 538 535 539 536 dolog ("w=%d h=%d sm=%d sr=%d p=%d\n", 540 w, h, (int) size _mask, (int) size_rgba, (int) dst_pitch);537 w, h, (int) sizeMask, (int) sizeRgba, (int) dstPitch); 541 538 dolog ("m=%p c=%p cp=%p\n", m, c, cp); 542 539 … … 569 566 for (pm = bitsp->mask, ps = bitsp->source, y = 0; 570 567 y < h; 571 ++y, pm += src _pitch, ps += src_pitch, m += dst_pitch)568 ++y, pm += srcPitch, ps += srcPitch, m += dstPitch) 572 569 { 573 570 for (x = 0; x < w; ++x) … … 605 602 reqp->yHot = bitsp->yhot; 606 603 reqp->fFlags = VBOX_MOUSE_POINTER_SHAPE; 607 reqp->header.size = size ;604 reqp->header.size = sizeRequest; 608 605 609 606 #ifdef DEBUG_X … … 635 632 unsigned char *pm; 636 633 CARD32 *pc; 637 size_t size , mask_size;634 size_t sizeRequest, sizeMask; 638 635 CARD8 *p; 639 636 int scrnIndex; … … 647 644 /* Mask must be generated for alpha cursors, that is required by VBox. */ 648 645 /* note: (michael) the next struct must be 32bit aligned. */ 649 mask_size= ((w + 7) / 8 * h + 3) & ~3;646 sizeMask = ((w + 7) / 8 * h + 3) & ~3; 650 647 651 648 if (!w || !h || w > VBOX_MAX_CURSOR_WIDTH || h > VBOX_MAX_CURSOR_HEIGHT) … … 658 655 bitsp->xhot, bitsp->yhot, w, h); 659 656 660 pVBox->pointerSize = w * h * 4 + mask_size;661 size = pVBox->pointerSize + pVBox->pointerHeaderSize;662 p = xcalloc(1, size );657 pVBox->pointerSize = w * h * 4 + sizeMask; 658 sizeRequest = pVBox->pointerSize + pVBox->pointerHeaderSize; 659 p = xcalloc(1, sizeRequest); 663 660 if (!p) 664 661 RETERROR(scrnIndex, , 665 662 "Error failed to alloc %lu bytes for cursor\n", 666 (unsigned long) size );663 (unsigned long) sizeRequest); 667 664 668 665 reqp = (VMMDevReqMousePointer *)p; … … 673 670 reqp->yHot = bitsp->yhot; 674 671 reqp->fFlags = VBOX_MOUSE_POINTER_SHAPE | VBOX_MOUSE_POINTER_ALPHA; 675 reqp->header.size = size; 676 677 memcpy(p + offsetof(VMMDevReqMousePointer, pointerData) + mask_size, 678 bitsp->argb, w * h * 4); 672 reqp->header.size = sizeRequest; 673 674 memcpy(p + offsetof(VMMDevReqMousePointer, pointerData) + sizeMask, bitsp->argb, w * h * 4); 679 675 680 676 /* Emulate the AND mask. */ … … 683 679 684 680 /* Init AND mask to 1 */ 685 memset(pm, 0xFF, mask_size);681 memset(pm, 0xFF, sizeMask); 686 682 687 683 /*
Note:
See TracChangeset
for help on using the changeset viewer.