VirtualBox

Ignore:
Timestamp:
Feb 1, 2008 4:59:45 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
27807
Message:

A quick implementation sketch of a solution to the SetVisibleRegion vs. paintEvent race.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxFrameBuffer.h

    r6679 r6725  
    509509    ulong mPixelFormat;
    510510    CGImageRef mImage;
     511#if 1
    511512    CGRect *mRegionRects;
    512513    ULONG mRegionCount;
    513 };
    514 
    515 #endif
    516 
    517 #endif // __VBoxFrameBuffer_h__
     514#else
     515    typedef struct
     516    {
     517        /** The size of this structure expressed in rcts entries. */
     518        ULONG allocated;
     519        /** The number of entries in the rcts array. */
     520        ULONG used;
     521        /** Variable sized array of the rectangle that makes up the region. */
     522        CGRECT rcts[1];
     523    } RegionRects;
     524    /** The current valid region, all access is by atomic cmpxchg or atomic xchg.
     525     *
     526     * The protocol for updating and using this has to take into account that
     527     * the producer (SetVisibleRegion) and consumer (paintEvent) are running
     528     * on different threads. Therefore the producer will create a new RegionRects
     529     * structure before atomically replace the existing one. While the consumer
     530     * will read the value by atomically replace it by NULL, and then when its
     531     * done try restore it by cmpxchg. If the producer has already put a new
     532     * region there, it will be discarded (see mRegionUnused).
     533     */
     534    RegionRects volatile *mRegion;
     535    /** For keeping the unused region and thus avoid some RTMemAlloc/RTMemFree calls.
     536     * This is operated with atomic cmpxchg and atomic xchg. */
     537    RegionRects volatile *mRegionUnused;
     538#endif
     539};
     540
     541#endif
     542
     543#endif // !__VBoxFrameBuffer_h__
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