VirtualBox

Changeset 6520 in vbox


Ignore:
Timestamp:
Jan 28, 2008 5:57:15 AM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
27537
Message:

Cleanups.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/x11/xgraphics/vboxutils-new.c

    r6518 r6520  
    6565    CARD32 *color;
    6666    unsigned char *mask;
    67     size_t size_mask;
     67    size_t sizeMask;
    6868
    6969    image    += offsetof(VMMDevReqMousePointer, pointerData);
    7070    mask      = image;
    7171    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);
    7474
    7575    TRACE_ENTRY();
     
    179179
    180180        /* 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;
    183182        if (indexRecordNext == pMem->indexRecordFirst)
    184183        {
     
    208207         */
    209208        i32Diff = off32Data - off32Free;
    210         cbHwBufferAvail = i32Diff > 0? i32Diff: VBVA_RING_BUFFER_SIZE
    211                                               + i32Diff;
     209        cbHwBufferAvail = i32Diff > 0 ? i32Diff : VBVA_RING_BUFFER_SIZE + i32Diff;
    212210        if (cbHwBufferAvail <= VBVA_RING_BUFFER_THRESHOLD)
    213211        {
     
    231229        if (off32Free + sizeof(cmdHdr) < VBVA_RING_BUFFER_SIZE)
    232230        {
    233             memcpy(&pMem->au8RingBuffer[off32Free], &cmdHdr,
    234                    sizeof(cmdHdr));
     231            memcpy(&pMem->au8RingBuffer[off32Free], &cmdHdr, sizeof(cmdHdr));
    235232            pMem->off32Free = pMem->off32Free + sizeof(cmdHdr);
    236233        }
     
    494491    unsigned short w, h, x, y;
    495492    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;
    497494    CARD32 fc, bc, *cp;
    498495    int rc, scrnIndex = infoPtr->pScrn->scrnIndex;
     
    513510            bitsp->xhot, bitsp->yhot, w, h);
    514511
    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      = pVBox->pointerSize + pVBox->pointerHeaderSize;
    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);
    523520    if (!c)
    524521        RETERROR(scrnIndex, NULL,
    525522                 "Error failed to alloc %lu bytes for cursor\n",
    526                  (unsigned long) size);
     523                 (unsigned long) sizeRequest);
    527524
    528525    rc = vmmdevInitRequest((VMMDevRequestHeader *)p, VMMDevReq_SetPointerShape);
     
    535532
    536533    m = p + offsetof(VMMDevReqMousePointer, pointerData);
    537     cp = (CARD32 *)(m + size_mask);
     534    cp = (CARD32 *)(m + sizeMask);
    538535
    539536    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);
    541538    dolog ("m=%p c=%p cp=%p\n", m, c, cp);
    542539
     
    569566    for (pm = bitsp->mask, ps = bitsp->source, y = 0;
    570567         y < h;
    571          ++y, pm += src_pitch, ps += src_pitch, m += dst_pitch)
     568         ++y, pm += srcPitch, ps += srcPitch, m += dstPitch)
    572569    {
    573570        for (x = 0; x < w; ++x)
     
    605602    reqp->yHot   = bitsp->yhot;
    606603    reqp->fFlags = VBOX_MOUSE_POINTER_SHAPE;
    607     reqp->header.size = size;
     604    reqp->header.size = sizeRequest;
    608605
    609606#ifdef DEBUG_X
     
    635632    unsigned char *pm;
    636633    CARD32 *pc;
    637     size_t size, mask_size;
     634    size_t sizeRequest, sizeMask;
    638635    CARD8 *p;
    639636    int scrnIndex;
     
    647644    /* Mask must be generated for alpha cursors, that is required by VBox. */
    648645    /* 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;
    650647
    651648    if (!w || !h || w > VBOX_MAX_CURSOR_WIDTH || h > VBOX_MAX_CURSOR_HEIGHT)
     
    658655            bitsp->xhot, bitsp->yhot, w, h);
    659656
    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);
    663660    if (!p)
    664661        RETERROR(scrnIndex, ,
    665662            "Error failed to alloc %lu bytes for cursor\n",
    666             (unsigned long) size);
     663            (unsigned long) sizeRequest);
    667664
    668665    reqp = (VMMDevReqMousePointer *)p;
     
    673670    reqp->yHot   = bitsp->yhot;
    674671    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);
    679675
    680676    /* Emulate the AND mask. */
     
    683679
    684680    /* Init AND mask to 1 */
    685     memset(pm, 0xFF, mask_size);
     681    memset(pm, 0xFF, sizeMask);
    686682
    687683    /*
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette