VirtualBox

Changeset 29518 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
May 17, 2010 10:06:22 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
61658
Message:

Main: onMousePointerShapeChange reworked

Location:
trunk/src/VBox/Frontends
Files:
4 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    }
Note: See TracChangeset for help on using the changeset viewer.

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