VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBufferQuartz2D.h@ 35740

Last change on this file since 35740 was 35215, checked in by vboxsync, 13 years ago

2d/mac: fix seamles with 2d

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * UIFrameBufferQuartz2D class declarations
5 */
6
7/*
8 * Copyright (C) 2010 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 */
18
19#ifndef ___UIFrameBufferQuartz2D_h___
20#define ___UIFrameBufferQuartz2D_h___
21
22#include <QtGlobal>
23
24#if defined (Q_WS_MAC) && defined (VBOX_GUI_USE_QUARTZ2D)
25
26#include "UIFrameBuffer.h"
27
28#include <ApplicationServices/ApplicationServices.h>
29
30/* Local forward declarations */
31class UIMachineLogic;
32
33class UIFrameBufferQuartz2D : public UIFrameBuffer
34{
35public:
36
37 UIFrameBufferQuartz2D(UIMachineView *pMachineView);
38 virtual ~UIFrameBufferQuartz2D();
39
40 STDMETHOD(NotifyUpdate)(ULONG uX, ULONG uY, ULONG uW, ULONG uH);
41 STDMETHOD(SetVisibleRegion)(BYTE *pRectangles, ULONG uCount);
42
43 uchar* address() { return m_pDataAddress; }
44 ulong bitsPerPixel() { return CGImageGetBitsPerPixel(m_image); }
45 ulong bytesPerLine() { return CGImageGetBytesPerRow(m_image); }
46 ulong pixelFormat() { return m_uPixelFormat; };
47 bool usesGuestVRAM() { return m_pBitmapData == NULL; }
48
49 const CGImageRef imageRef() const { return m_image; }
50
51 void paintEvent(QPaintEvent *pEvent);
52 void resizeEvent(UIResizeEvent *pEvent);
53
54#ifdef VBOX_WITH_VIDEOHWACCEL
55 void setView(UIMachineView *pView);
56#endif
57
58private:
59
60 void clean();
61
62 UIMachineLogic *m_pMachineLogic;
63 uchar *m_pDataAddress;
64 void *m_pBitmapData;
65 ulong m_uPixelFormat;
66 CGImageRef m_image;
67 typedef struct
68 {
69 /** The size of this structure expressed in rcts entries. */
70 ULONG allocated;
71 /** The number of entries in the rcts array. */
72 ULONG used;
73 /** Variable sized array of the rectangle that makes up the region. */
74 CGRect rcts[1];
75 } RegionRects;
76 /** The current valid region, all access is by atomic cmpxchg or atomic xchg.
77 *
78 * The protocol for updating and using this has to take into account that
79 * the producer (SetVisibleRegion) and consumer (paintEvent) are running
80 * on different threads. Therefore the producer will create a new RegionRects
81 * structure before atomically replace the existing one. While the consumer
82 * will read the value by atomically replace it by NULL, and then when its
83 * done try restore it by cmpxchg. If the producer has already put a new
84 * region there, it will be discarded (see mRegionUnused).
85 */
86 RegionRects * volatile mRegion;
87 /** For keeping the unused region and thus avoid some RTMemAlloc/RTMemFree calls.
88 * This is operated with atomic cmpxchg and atomic xchg. */
89 RegionRects * volatile mRegionUnused;
90
91};
92#endif /* Q_WS_MAC && VBOX_GUI_USE_QUARTZ2D */
93
94#endif // !___UIFrameBufferQuartz2D_h___
95
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use