10 #include "ViewLayer.h"
20 MSG_BEGIN_UPDATE
= 'bgud',
21 MSG_END_UPDATE
= 'edud',
22 MSG_DRAWING_COMMAND
= 'draw',
26 MSG_INVALIDATE_VIEW
= 'invl',
27 MSG_DRAW_POLYGON
= 'drwp',
33 virtual ~UpdateSession();
35 void Include(BRegion
* additionalDirty
);
36 void Exclude(BRegion
* dirtyInNextSession
);
38 inline BRegion
& DirtyRegion()
39 { return fDirtyRegion
; }
41 void MoveBy(int32 x
, int32 y
);
43 void SetUsed(bool used
);
44 inline bool IsUsed() const
47 UpdateSession
& operator=(const UpdateSession
& other
);
54 class WindowLayer
: public BLooper
{
56 WindowLayer(BRect frame
, const char* name
,
57 DrawingEngine
* drawingEngine
,
59 virtual ~WindowLayer();
61 virtual void MessageReceived(BMessage
* message
);
62 virtual bool QuitRequested();
64 inline BRect
Frame() const
66 // setting and getting the "hard" clipping
67 void SetClipping(BRegion
* stillAvailableOnScreen
);
68 inline BRegion
& VisibleRegion()
69 { return fVisibleRegion
; }
70 BRegion
& VisibleContentRegion();
72 void GetFullRegion(BRegion
* region
) const;
73 void GetBorderRegion(BRegion
* region
);
74 void GetContentRegion(BRegion
* region
);
76 void SetFocus(bool focus
);
78 void MoveBy(int32 x
, int32 y
);
79 void ResizeBy(int32 x
, int32 y
, BRegion
* dirtyRegion
);
81 void ScrollViewBy(ViewLayer
* view
, int32 dx
, int32 dy
);
83 void AddChild(ViewLayer
* layer
);
85 ViewLayer
* ViewAt(const BPoint
& where
);
87 void SetHidden(bool hidden
);
88 inline bool IsHidden() const
91 void MarkDirty(BRegion
* regionOnScreen
);
92 void MarkContentDirty(BRegion
* regionOnScreen
);
93 void InvalidateView(int32 token
);
95 void ProcessDirtyRegion(BRegion
* region
);
97 DrawingEngine
* GetDrawingEngine() const
98 { return fDrawingEngine
; }
100 void CopyContents(BRegion
* region
,
101 int32 xOffset
, int32 yOffset
);
104 void _ShiftPartOfRegion(BRegion
* region
, BRegion
* regionToShift
,
105 int32 xOffset
, int32 yOffset
);
107 // different types of drawing
108 void _TriggerContentRedraw();
109 void _DrawClient(int32 token
);
110 void _DrawClientPolygon(int32 token
, BPoint polygon
[4]);
113 // handling update sessions
114 void _MarkContentDirty(BRegion
* contentDirtyRegion
);
118 void _UpdateContentRegion();
122 // the visible region is only recalculated from the
123 // Desktop thread, when using it, Desktop::ReadLockClipping()
125 BRegion fVisibleRegion
;
126 BRegion fVisibleContentRegion
;
127 bool fVisibleContentRegionValid
;
128 // our part of the "global" dirty region
129 // it is calculated from the desktop thread,
130 // but we can write to it when we read locked
131 // the clipping, since it is local and the desktop
133 BRegion fDirtyRegion
;
135 // caching local regions
136 BRegion fBorderRegion
;
137 bool fBorderRegionValid
;
138 BRegion fContentRegion
;
139 bool fContentRegionValid
;
140 BRegion fEffectiveDrawingRegion
;
141 bool fEffectiveDrawingRegionValid
;
145 ViewLayer
* fTopLayer
;
149 DrawingEngine
* fDrawingEngine
;
152 // for mapping drawing requests from the client
153 // to the local view pointers
156 // the client looper, which will do asynchronous
157 // drawing (the window will clear the content
158 // and the client is supposed to draw onto
159 // the cleared regions)
160 ClientLooper
* fClient
;
161 // The synchronization, which client drawing commands
162 // belong to the redraw of which region is handled
163 // through an UpdateSession. When the client has
164 // been informed that it should redraw stuff, then
165 // this is the current update session. All new
166 // redraw requests from the root layer will go
167 // into the pending update session.
168 UpdateSession fCurrentUpdateSession
;
169 UpdateSession fPendingUpdateSession
;
170 // these two flags are supposed to ensure a sane
171 // and consistent update session
172 bool fUpdateRequested
;
176 #endif // WINDOW_LAYER_H