VirtualBox

Changeset 29518 in vbox


Ignore:
Timestamp:
May 17, 2010 10:06:22 AM (14 years ago)
Author:
vboxsync
Message:

Main: onMousePointerShapeChange reworked

Location:
trunk/src/VBox
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp

    r28960 r29518  
    305305
    306306    STDMETHOD(OnMousePointerShapeChange)(BOOL visible, BOOL alpha, ULONG xHot, ULONG yHot,
    307                                          ULONG width, ULONG height, BYTE *shape)
     307                                         ULONG width, ULONG height, ComSafeArrayIn(BYTE,shape))
    308308    {
    309309        return VBOX_E_DONT_CALL_AGAIN;
     
    12431243}
    12441244#endif /* !VBOX_WITH_HARDENING */
    1245 
  • trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp

    r29431 r29518  
    100100{
    101101    PointerShapeChangeData(BOOL aVisible, BOOL aAlpha, ULONG aXHot, ULONG aYHot,
    102                            ULONG aWidth, ULONG aHeight, const uint8_t *aShape)
     102                           ULONG aWidth, ULONG aHeight, ComSafeArrayIn(BYTE,pShape))
    103103        : visible(aVisible), alpha(aAlpha), xHot(aXHot), yHot(aYHot),
    104           width(aWidth), height(aHeight), shape(NULL)
     104          width(aWidth), height(aHeight)
    105105    {
    106106        // make a copy of the shape
    107         if (aShape)
    108         {
    109             uint32_t shapeSize = ((((aWidth + 7) / 8) * aHeight + 3) & ~3) + aWidth * 4 * aHeight;
    110             shape = new uint8_t [shapeSize];
    111             if (shape)
    112                 memcpy((void *)shape, (void *)aShape, shapeSize);
    113         }
     107        com::SafeArray <BYTE> aShape(ComSafeArrayInArg (pShape));
     108        size_t cbShapeSize = aShape.size();
     109        shape.resize(cbShapeSize);
     110        ::memcpy(shape.raw(), aShape.raw(), cbShapeSize);
    114111    }
    115112
    116113    ~PointerShapeChangeData()
    117114    {
    118         if (shape) delete[] shape;
    119115    }
    120116
     
    125121    const ULONG width;
    126122    const ULONG height;
    127     const uint8_t *shape;
     123    com::SafeArray<BYTE> shape;
    128124};
    129125
     
    401397
    402398    STDMETHOD(OnMousePointerShapeChange)(BOOL visible, BOOL alpha, ULONG xHot, ULONG yHot,
    403                                          ULONG width, ULONG height, BYTE *shape)
     399                                         ULONG width, ULONG height, ComSafeArrayIn(BYTE, shape))
    404400    {
    405401        PointerShapeChangeData *data;
    406402        data = new PointerShapeChangeData(visible, alpha, xHot, yHot, width, height,
    407                                           shape);
     403                                          ComSafeArrayInArg(shape));
    408404        Assert(data);
    409405        if (!data)
     
    44304426        return;
    44314427
    4432     if (data->shape)
     4428    if (data->shape.size() > 0)
    44334429    {
    44344430        bool ok = false;
     
    44374433        uint32_t srcShapePtrScan = data->width * 4;
    44384434
    4439         const uint8_t *srcAndMaskPtr = data->shape;
    4440         const uint8_t *srcShapePtr = data->shape + ((andMaskSize + 3) & ~3);
     4435        const uint8_t* shape = data->shape.raw();
     4436        const uint8_t *srcAndMaskPtr = shape;
     4437        const uint8_t *srcShapePtr = shape + ((andMaskSize + 3) & ~3);
    44414438
    44424439#if 0
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp

    r28960 r29518  
    3030#include "VBoxGlobal.h"
    3131#include "VBoxProblemReporter.h"
     32#include "VBox/com/array.h"
    3233
    3334#ifdef Q_WS_PM
     
    209210    MousePointerChangeEvent (bool visible, bool alpha, uint xhot, uint yhot,
    210211                             uint width, uint height,
    211                              const uchar *shape) :
     212                             ComSafeArrayIn(BYTE,pShape)) :
    212213        QEvent ((QEvent::Type) VBoxDefs::MousePointerChangeEventType),
    213         vis (visible), alph (alpha), xh (xhot), yh (yhot), w (width), h (height),
    214         data (NULL)
    215     {
    216         // make a copy of shape
    217         uint dataSize = ((((width + 7) / 8 * height) + 3) & ~3) + width * 4 * height;
    218 
    219         if (shape) {
    220             data = new uchar [dataSize];
    221             memcpy ((void *) data, (void *) shape, dataSize);
    222         }
     214        vis (visible), alph (alpha), xh (xhot), yh (yhot), w (width), h (height)
     215    {
     216        com::SafeArray <BYTE> aShape(ComSafeArrayInArg (pShape));
     217        size_t cbShapeSize = aShape.size();
     218        shape.resize(cbShapeSize);
     219        ::memcpy(shape.raw(), aShape.raw(), cbShapeSize);
    223220    }
    224221    ~MousePointerChangeEvent()
    225222    {
    226         if (data) delete[] data;
    227223    }
    228224    bool isVisible() const { return vis; }
     
    232228    uint width() const { return w; }
    233229    uint height() const { return h; }
    234     const uchar *shapeData() const { return data; }
     230    const uchar *shapeData() const { return shape.raw(); }
    235231private:
    236232    bool vis, alph;
    237233    uint xh, yh, w, h;
    238     const uchar *data;
     234    com::SafeArray <uint8_t> shape;
    239235};
    240236
     
    423419                                          ULONG xhot, ULONG yhot,
    424420                                          ULONG width, ULONG height,
    425                                           BYTE *shape)
     421                                          ComSafeArrayIn(BYTE,shape))
    426422    {
    427423        QApplication::postEvent (mView,
    428424                                 new MousePointerChangeEvent (visible, alpha,
    429425                                                              xhot, yhot,
    430                                                               width, height, shape));
     426                                                              width, height, ComSafeArrayInArg(shape)));
    431427        return S_OK;
    432428    }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r29485 r29518  
    5555public:
    5656
    57     UIMousePointerShapeChangeEvent(bool bIsVisible, bool bIsAlpha, uint uXHot, uint uYHot, uint uWidth, uint uHeight, const uchar *pShape)
     57    UIMousePointerShapeChangeEvent(bool bIsVisible, bool bIsAlpha, uint uXHot, uint uYHot, uint uWidth, uint uHeight, ComSafeArrayIn(BYTE,pShape))
    5858        : QEvent((QEvent::Type)UIConsoleEventType_MousePointerShapeChange)
    59         , m_bIsVisible(bIsVisible), m_bIsAlpha(bIsAlpha), m_uXHot(uXHot), m_uYHot(uYHot), m_uWidth(uWidth), m_uHeight(uHeight), m_pData(0)
    60     {
    61         uint dataSize = ((((m_uWidth + 7) / 8 * m_uHeight) + 3) & ~3) + m_uWidth * 4 * m_uHeight;
    62         if (pShape)
    63         {
    64             m_pData = new uchar[dataSize];
    65             memcpy((void*)m_pData, (void*)pShape, dataSize);
    66         }
     59        , m_bIsVisible(bIsVisible), m_bIsAlpha(bIsAlpha), m_uXHot(uXHot), m_uYHot(uYHot), m_uWidth(uWidth), m_uHeight(uHeight)
     60    {
     61        com::SafeArray <BYTE> aShape(ComSafeArrayInArg (pShape));
     62        size_t cbShapeSize = aShape.size();
     63        m_shape.resize(cbShapeSize);
     64        ::memcpy(m_shape.raw(), aShape.raw(), cbShapeSize);
    6765    }
    6866
    6967    virtual ~UIMousePointerShapeChangeEvent()
    7068    {
    71         if (m_pData) delete[] m_pData;
    7269    }
    7370
     
    7875    uint width() const { return m_uWidth; }
    7976    uint height() const { return m_uHeight; }
    80     const uchar *shapeData() const { return m_pData; }
     77    const uchar *shapeData() const { return m_shape.raw(); }
    8178
    8279private:
     
    8481    bool m_bIsVisible, m_bIsAlpha;
    8582    uint m_uXHot, m_uYHot, m_uWidth, m_uHeight;
    86     const uchar *m_pData;
     83    com::SafeArray <uint8_t> m_shape;
    8784};
    8885
     
    386383    VBOX_SCRIPTABLE_DISPATCH_IMPL(IConsoleCallback)
    387384
    388     STDMETHOD(OnMousePointerShapeChange)(BOOL bIsVisible, BOOL bAlpha, ULONG uXHot, ULONG uYHot, ULONG uWidth, ULONG uHeight, BYTE *pShape)
    389     {
    390         QApplication::postEvent(m_pEventHandler, new UIMousePointerShapeChangeEvent(bIsVisible, bAlpha, uXHot, uYHot, uWidth, uHeight, pShape));
     385    STDMETHOD(OnMousePointerShapeChange)(BOOL bIsVisible, BOOL bAlpha, ULONG uXHot, ULONG uYHot, ULONG uWidth, ULONG uHeight, ComSafeArrayIn(BYTE,pShape))
     386    {
     387        QApplication::postEvent(m_pEventHandler, new UIMousePointerShapeChangeEvent(bIsVisible, bAlpha, uXHot, uYHot, uWidth, uHeight, ComSafeArrayInArg(pShape)));
    391388        return S_OK;
    392389    }
  • trunk/src/VBox/Main/ConsoleImpl.cpp

    r29480 r29518  
    618618    /* dynamically allocated members of mCallbackData are uninitialized
    619619     * at the end of powerDown() */
    620     Assert(!mCallbackData.mpsc.valid && mCallbackData.mpsc.shape == NULL);
     620    Assert(!mCallbackData.mpsc.valid && mCallbackData.mpsc.shape.isNull());
    621621    Assert(!mCallbackData.mcc.valid);
    622622    Assert(!mCallbackData.klc.valid);
     
    30263026                                             mCallbackData.mpsc.width,
    30273027                                             mCallbackData.mpsc.height,
    3028                                              mCallbackData.mpsc.shape);
     3028                                             ComSafeArrayAsInParam(mCallbackData.mpsc.shape));
    30293029    if (mCallbackData.mcc.valid)
    30303030        aCallback->OnMouseCapabilityChange(mCallbackData.mcc.supportsAbsolute,
     
    46424642                                        uint32_t xHot, uint32_t yHot,
    46434643                                        uint32_t width, uint32_t height,
    4644                                         void *pShape)
     4644                                        ComSafeArrayIn(BYTE,pShape))
    46454645{
    46464646#if 0
     
    46684668    mCallbackData.mpsc.valid = false;
    46694669
    4670     if (pShape != NULL)
    4671     {
    4672         size_t cb = (width + 7) / 8 * height; /* size of the AND mask */
    4673         cb = ((cb + 3) & ~3) + width * 4 * height; /* + gap + size of the XOR mask */
    4674         /* try to reuse the old shape buffer if the size is the same */
    4675         if (!wasValid)
    4676             mCallbackData.mpsc.shape = NULL;
    4677         else
    4678         if (mCallbackData.mpsc.shape != NULL && mCallbackData.mpsc.shapeSize != cb)
    4679         {
    4680             RTMemFree(mCallbackData.mpsc.shape);
    4681             mCallbackData.mpsc.shape = NULL;
    4682         }
    4683         if (mCallbackData.mpsc.shape == NULL)
    4684         {
    4685             mCallbackData.mpsc.shape = (BYTE *) RTMemAllocZ(cb);
    4686             AssertReturnVoid(mCallbackData.mpsc.shape);
    4687         }
    4688         mCallbackData.mpsc.shapeSize = cb;
    4689         memcpy(mCallbackData.mpsc.shape, pShape, cb);
     4670    com::SafeArray <BYTE> aShape(ComSafeArrayInArg (pShape));
     4671    if (aShape.size() != 0)
     4672    {
     4673        mCallbackData.mpsc.shape.resize(aShape.size());
     4674        ::memcpy( mCallbackData.mpsc.shape.raw(), aShape.raw(), aShape.size());
    46904675    }
    46914676    else
    4692     {
    4693         if (wasValid && mCallbackData.mpsc.shape != NULL)
    4694             RTMemFree(mCallbackData.mpsc.shape);
    4695         mCallbackData.mpsc.shape = NULL;
    4696         mCallbackData.mpsc.shapeSize = 0;
    4697     }
    4698 
     4677        mCallbackData.mpsc.shape.setNull();
    46994678    mCallbackData.mpsc.valid = true;
    47004679
    4701     CONSOLE_DO_CALLBACKS(OnMousePointerShapeChange,(fVisible, fAlpha, xHot, yHot, width, height, (BYTE *) pShape));
     4680    CONSOLE_DO_CALLBACKS(OnMousePointerShapeChange,(fVisible, fAlpha, xHot, yHot, width, height, ComSafeArrayInArg(pShape)));
    47024681
    47034682#if 0
     
    56665645        /* uninit dynamically allocated members of mCallbackData */
    56675646        if (mCallbackData.mpsc.valid)
    5668         {
    5669             if (mCallbackData.mpsc.shape != NULL)
    5670                 RTMemFree(mCallbackData.mpsc.shape);
    5671         }
     5647            mCallbackData.mpsc.shape.setNull();
    56725648        memset(&mCallbackData, 0, sizeof(mCallbackData));
    56735649    }
  • trunk/src/VBox/Main/ConsoleVRDPServer.cpp

    r29386 r29518  
    8282
    8383    STDMETHOD(OnMousePointerShapeChange)(BOOL visible, BOOL alpha, ULONG xHot, ULONG yHot,
    84                                          ULONG width, ULONG height, BYTE *shape);
     84                                         ULONG width, ULONG height, ComSafeArrayIn(BYTE,shape));
    8585
    8686    STDMETHOD(OnMouseCapabilityChange)(BOOL supportsAbsolute, BOOL supportsRelative, BOOL needsHostCursor)
     
    431431                                                            ULONG width,
    432432                                                            ULONG height,
    433                                                             BYTE *shape)
     433                                                            ComSafeArrayIn(BYTE,inShape))
    434434{
    435435    LogSunlover(("VRDPConsoleCallback::OnMousePointerShapeChange: %d, %d, %lux%lu, @%lu,%lu\n", visible, alpha, width, height, xHot, yHot));
     
    437437    if (m_server)
    438438    {
    439         if (!shape)
     439        com::SafeArray <BYTE> aShape(ComSafeArrayInArg (inShape));
     440        if (aShape.size() == 0)
    440441        {
    441442            if (!visible)
     
    462463             * because most pointers are 32x32.
    463464             */
     465            uint8_t* shape = aShape.raw();
    464466
    465467            dumpPointer(shape, width, height, true);
  • trunk/src/VBox/Main/DisplayImpl.cpp

    r28927 r29518  
    38293829    Display *pThis = pDrv->pDisplay;
    38303830
     3831    size_t cbShapeSize = (cx + 7) / 8 * cy; /* size of the AND mask */
     3832    cbShapeSize = ((cbShapeSize + 3) & ~3) + cx * 4 * cy; /* + gap + size of the XOR mask */
     3833    com::SafeArray<BYTE> shapeData(cbShapeSize);
     3834    ::memcpy(shapeData.raw(), pvShape, cbShapeSize);
     3835
    38313836    /* Tell the console about it */
    38323837    pDrv->pDisplay->mParent->onMousePointerShapeChange(fVisible, fAlpha,
    3833                                                        xHot, yHot, cx, cy, (void *)pvShape);
     3838                                                       xHot, yHot, cx, cy, ComSafeArrayAsInParam(shapeData));
    38343839
    38353840    return VINF_SUCCESS;
  • trunk/src/VBox/Main/VMMDevInterface.cpp

    r29404 r29518  
    284284
    285285    /* tell the console about it */
     286    size_t cbShapeSize = (width + 7) / 8 * height; /* size of the AND mask */
     287    cbShapeSize = ((cbShapeSize + 3) & ~3) + width * 4 * height; /* + gap + size of the XOR mask */
     288    com::SafeArray<BYTE> shapeData(cbShapeSize);
     289    ::memcpy(shapeData.raw(), pShape, cbShapeSize);
    286290    pDrv->pVMMDev->getParent()->onMousePointerShapeChange(fVisible, fAlpha,
    287                                                           xHot, yHot, width, height, pShape);
     291                                                          xHot, yHot, width, height, ComSafeArrayAsInParam(shapeData));
    288292}
    289293
  • trunk/src/VBox/Main/VirtualBoxCallbackImpl.cpp

    r29453 r29518  
    162162/////////////////////////////////////////////////////////////////////////////
    163163STDMETHODIMP CallbackWrapper::OnMousePointerShapeChange(BOOL visible, BOOL alpha, ULONG xHot, ULONG yHot,
    164                                                         ULONG width, ULONG height, BYTE *shape)
    165 {
    166     if (mConsoleCallback.isNull())
    167         return S_OK;
    168 
    169 #if defined(RT_OS_WINDOWS) && defined(RT_ARCH_AMD64)
    170     /* Letting this thru crashes in VariantInit, probably because the last
    171        parameter is a BYTE pointer.  For now, don't let it thru to python or
    172        what other users this class might have. */
    173     /** @todo Figure if this applies to 32-bit hosts as well. */
    174     /** @todo Find better solution? */
    175     return VBOX_E_DONT_CALL_AGAIN;
    176 #else
    177     return mConsoleCallback->OnMousePointerShapeChange(visible, alpha, xHot, yHot, width, height, shape);
    178 #endif
     164                                                        ULONG width, ULONG height, ComSafeArrayIn(BYTE, shape))
     165{
     166    if (mConsoleCallback.isNull())
     167        return S_OK;
     168
     169    return mConsoleCallback->OnMousePointerShapeChange(visible, alpha, xHot, yHot, width, height, ComSafeArrayInArg(shape));
    179170}
    180171
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r29516 r29518  
    61726172        </desc>
    61736173      </param>
    6174       <param name="shape" type="octet" mod="ptr" dir="in">
    6175         <desc>
    6176           Address of the shape buffer.
     6174      <param name="shape" type="octet" safearray="yes" dir="in">
     6175        <desc>
     6176          Shape buffer arrays.
    61776177
    61786178          The @a shape buffer contains a 1-bpp (bits per pixel) AND mask
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r29480 r29518  
    2121#include "VirtualBoxBase.h"
    2222#include "SchemaDefs.h"
     23#include "VBox/com/array.h"
    2324
    2425class Guest;
     
    206207                                   uint32_t xHot, uint32_t yHot,
    207208                                   uint32_t width, uint32_t height,
    208                                    void *pShape);
     209                                   ComSafeArrayIn(uint8_t, aShape));
    209210    void onMouseCapabilityChange(BOOL supportsAbsolute, BOOL supportsRelative, BOOL needsHostCursor);
    210211    void onStateChange(MachineState_T aMachineState);
     
    675676            uint32_t width;
    676677            uint32_t height;
    677             BYTE *shape;
    678             size_t shapeSize;
     678            com::SafeArray<BYTE> shape;
    679679        }
    680680        mpsc;
  • trunk/src/VBox/Main/include/DisplayImpl.h

    r28973 r29518  
    150150    // IConsoleCallback methods
    151151    STDMETHOD(OnMousePointerShapeChange)(BOOL visible, BOOL alpha, ULONG xHot, ULONG yHot,
    152                                          ULONG width, ULONG height, BYTE *shape)
     152                                         ULONG width, ULONG height, ComSafeArrayIn(BYTE,shape))
    153153    {
    154154        return S_OK;
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