~hikiko/nux/arb-srgba-shader

« back to all changes in this revision

Viewing changes to Nux/WindowCompositor.h

  • Committer: Neil Jagdish Patel
  • Date: 2010-09-02 03:28:11 UTC
  • Revision ID: neil.patel@canonical.com-20100902032811-i2m18tfb6pkasnvt
Remove Win EOL chars

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 */
21
21
 
22
22
 
23
 
#ifndef STACKMANAGER_H
24
 
#define STACKMANAGER_H
25
 
 
26
 
#include "BaseWindow.h"
27
 
 
28
 
NAMESPACE_BEGIN_GUI
29
 
 
30
 
class MenuPage;
31
 
class PBuffer;
32
 
class WindowThread;
33
 
class ActiveInterfaceObject;
34
 
class BaseArea;
35
 
class BaseObject;
36
 
class BaseWindow;
37
 
class PaintLayer;
38
 
 
39
 
class WindowCompositor
40
 
{
41
 
public:
42
 
    void Enumerate();
43
 
 
44
 
    void SetClientSize(int w, int h);
45
 
//    void DrawGrid(Graphics *g);
46
 
    void Draw(IEvent &event, bool force_draw);
47
 
    //void DrawList();
48
 
 
49
 
    void DrawPopup(bool force_draw);
50
 
    void DrawMenu(bool force_draw);
51
 
    void DrawOverlay(bool force_draw);
52
 
    void DrawTooltip(bool force_draw);
53
 
    void DrawFloatingWindows(bool force_draw, const std::list<smptr(BaseWindow)>& WindowList, bool drawModal, bool UseFBO);
54
 
 
55
 
    void RenderMainWindowComposition(bool force_draw, bool UseFBO);
56
 
    void RenderWindowComposition(smptr(BaseWindow) window, bool force_draw);
57
 
 
58
 
 
59
 
    /*!
60
 
        Render a textured quad the quad has the size of the texture. The texture maybe the main window texture or a BaseWindow texture. 
61
 
 
62
 
        @param HWTexture            Texture to render.
63
 
        @param x                    Coordinates of the top left corner of the quad.
64
 
        @param y                    Coordinates of the top left corner of the quad.
65
 
        @param RenderToMainTexture  If true, render to the main window texture. If false, render to the default back buffer.
66
 
        @param BluredBackground     If true, the texture is blended with the blurred version of the main window texture.
67
 
    */
68
 
    void PresentBufferToScreen(TRefGL<IOpenGLTexture2D> HWTexture, int x, int y, bool RenderToMainTexture, bool BluredBackground = false);
69
 
    void PresentRendering();
70
 
 
71
 
    /*!
72
 
        Set the composition render target as the texture to draw into.
73
 
    */
74
 
    void SetCompositionRT();
75
 
 
76
 
    /*!
77
 
        Draw a Texture into the composition render target.
78
 
        @param x    Destination coordinates.
79
 
        @param y    Destination coordinates.
80
 
    */
81
 
    void CopyTextureToCompositionRT(TRefGL<IOpenGLTexture2D> HWTexture, int x, int y);
82
 
 
83
 
    void AddToDrawList(smptr(ActiveInterfaceObject) ic);
84
 
    void ClearDrawList();
85
 
 
86
 
 
87
 
    bool MouseDown(Point pt);
88
 
 
89
 
    bool MouseMove(Point pt);
90
 
    bool MouseUp(Point pt);
91
 
    smptr(BaseWindow) GetSelectedWindow();
92
 
 
93
 
    void ProcessEvent(IEvent &ievent);
94
 
 
95
 
    void RegisterWindow(smptr(BaseWindow));
96
 
    void UnRegisterWindow(smptr(BaseWindow));
97
 
    void MoveWindowToFront(smptr(BaseWindow));
98
 
    void MoveWindowToBack(smptr(BaseWindow));
99
 
 
100
 
    TRefGL<IOpenGLFrameBufferObject>& GetWindowFrameBufferObject(){ return m_FrameBufferObject;}
101
 
    TRefGL<IOpenGLFrameBufferObject> m_FrameBufferObject;
102
 
 
103
 
    TRefGL< IOpenGLBaseTexture > GetScreenBlurTexture();
104
 
 
105
 
    // We use Rectangle texture to attach to the framebuffer because some GPU like the Geforce FX 5600 do not 
106
 
    // have support for ARB_texture_non_power_of_two. However it does support ARB_texture_recatangle.
107
 
    struct RenderTargetTextures
108
 
    {
109
 
        TRefGL<IOpenGLTexture2D> color_rt;
110
 
        TRefGL<IOpenGLTexture2D> depth_rt;
111
 
    };
112
 
    TRefGL<IOpenGLTexture2D> m_MainColorRT;
113
 
    TRefGL<IOpenGLTexture2D> m_MainDepthRT;
114
 
    TRefGL<IOpenGLTexture2D> m_CompositionRT;
115
 
 
116
 
    RenderTargetTextures& GetWindowBuffer(smptr(BaseWindow) window);
117
 
 
118
 
    void StartModalWindow(smptr(BaseWindow) );
119
 
    void StopModalWindow(smptr(BaseWindow) );
120
 
 
121
 
    std::vector<Rect> EventRect;
122
 
    void PushEventRectangle(Rect rect);
123
 
    void PopEventRectangle();
124
 
    void EmptyEventRegion();
125
 
    Rect getEventRect();
126
 
 
127
 
    void AddMenu(MenuPage* menu, smptr(BaseWindow) window, bool OverrideCurrentMenuChain = true);
128
 
    void RemoveMenu(MenuPage* menu);
129
 
    void CleanMenu();
130
 
 
131
 
    void PushModalWindow(smptr(BaseWindow) window);
132
 
 
133
 
//    typedef void(*AuxDrawCallback)();
134
 
//    AuxDrawCallback m_fAuxDrawCallback;
135
 
//
136
 
//    void SetAuxDrawCallback(AuxDrawCallback f) { m_fAuxDrawCallback = f; }
137
 
 
138
 
 
139
 
 
140
 
    void SetWidgetDrawingOverlay(smptr(BaseArea) ic, smptr(BaseWindow) OverlayWindow);
141
 
    smptr(BaseArea) GetWidgetDrawingOverlay();
142
 
 
143
 
    void SetTooltip(smptr(BaseArea) TooltipArea, const TCHAR *TooltipText, int x, int y);
144
 
    /*!
145
 
        Return true if the mouse is still inside the area that initiated the tooltip;
146
 
 
147
 
        @param x    The mouse x coordinate on screen.
148
 
        @param y    The mouse y coordinate on screen.
149
 
        @return     Return true is the mouse is still inside the area.
150
 
    */
151
 
    bool ValidateMouseInsideTooltipArea(int x, int y);
152
 
    /*!
153
 
        Return true if there is a valid tooltip active.
154
 
 
155
 
        @return     Return true if there is a valid tooltip active.
156
 
    */
157
 
    bool IsTooltipActive();
158
 
    void CancelTooltip();
159
 
 
160
 
    void SetAreaEventRoot(int x, int y)
161
 
    {
162
 
        m_EventRoot.Set(x, y);
163
 
    }
164
 
 
165
 
    void SetMouseFocusArea(smptr(BaseArea) area);
166
 
    smptr(BaseArea) GetMouseFocusArea();
167
 
    void SetMouseOverArea(smptr(BaseArea) area);
168
 
    smptr(BaseArea) GetMouseOverArea();
169
 
    void SetPreviousMouseOverArea(smptr(BaseArea) area);
170
 
    smptr(BaseArea) GetPreviousMouseOverArea();
171
 
 
172
 
    const IEvent* GetCurrentEvent() const {return m_CurrentEvent;}
173
 
    long ProcessEventOnObject(IEvent &ievent, smptr(BaseObject) object, long TraverseInfo, long ProcessEventInfo);
174
 
    
175
 
    smptr(BaseWindow) GetCurrentWindow() {return m_CurrentWindow;}
176
 
    smptr(BaseWindow) GetFocusAreaWindow() {return m_FocusAreaWindow;}
177
 
 
178
 
    void SetBackgroundPaintLayer(AbstractPaintLayer* bkg);
179
 
 
180
 
private:
181
 
    void SetCurrentWindow(smptr(BaseWindow) window) {m_CurrentWindow = window;}
182
 
    void SetFocusAreaWindow(smptr(BaseWindow) window) {m_FocusAreaWindow = window;}
183
 
    void SetCurrentEvent(IEvent* event) {m_CurrentEvent = event;}
184
 
 
185
 
    void FormatRenderTargets(int width, int height);
186
 
 
187
 
    void UpdatePostProcessRT();
188
 
 
189
 
    /*!
190
 
        Floating Area need to be informed when the main window has been resized.
191
 
 
192
 
        @param Width    New width of the window.
193
 
        @param Height   New height of the window.
194
 
    */
195
 
    void FloatingAreaConfigureNotify(int Width, int Height);
196
 
 
197
 
    smptr(BaseWindow) m_CurrentWindow;
198
 
    smptr(BaseWindow) m_FocusAreaWindow;
199
 
    smptr(BaseWindow) m_MenuWindow; // the window that owns the menu being displayed;
200
 
    IEvent* m_CurrentEvent; 
201
 
 
202
 
    smptr(BaseArea) m_MouseFocusArea;      // the base ares that has the mouse down.
203
 
    smptr(BaseArea) m_MouseOverArea;  // the base area that has the mouse directly over itself.
204
 
    smptr(BaseArea) m_PreviousMouseOverArea;
205
 
 
206
 
    smptr(BaseArea) OverlayDrawingCommand;
207
 
    smptr(BaseWindow) m_OverlayWindow; // the window that owns the overlay;
208
 
    smptr(BaseWindow) m_TooltipWindow; // the window that owns the tooltip;
209
 
    Point m_EventRoot;
210
 
 
211
 
    AbstractPaintLayer* m_Background;
212
 
 
213
 
    std::list<smptr(BaseWindow)> m_WindowList;
214
 
    std::list<smptr(BaseWindow)> m_ModalWindowList;
215
 
    std::list<smptr(ActiveInterfaceObject)> *m_DrawList;
216
 
    std::list<Rect> *m_EventRectList;
217
 
 
218
 
    std::list<MenuPage*> *m_MenuList;
219
 
 
220
 
    smptr(BaseWindow) m_SelectedWindow;
221
 
 
222
 
    std::map< smptr(BaseWindow), struct RenderTargetTextures > m_WindowToTextureMap;
223
 
 
224
 
    smptr(BaseWindow) m_ModalWindow;
225
 
    Point m_MouseLastPos;
226
 
    Point m_MouseCurrentPos;
227
 
 
228
 
    bool m_PopupRemoved;
229
 
    bool m_MenuRemoved;
230
 
    bool m_MouseUp;
231
 
    bool m_MouseDown;
232
 
 
233
 
    // Window Geometry
234
 
    int m_Width;
235
 
    int m_Height;
236
 
 
237
 
    NString m_TooltipText;
238
 
    smptr(BaseArea) m_TooltipArea;
239
 
    int m_TooltipX;
240
 
    int m_TooltipY;
241
 
 
242
 
    bool m_FullSceneBlurUpdated;
243
 
    TRefGL<IOpenGLTexture2D> m_BlurTexture;
244
 
    TRefGL<IOpenGLTexture2D> m_FullSceneMip0;
245
 
    TRefGL<IOpenGLTexture2D> m_FullSceneMip1;
246
 
    TRefGL<IOpenGLTexture2D> m_FullSceneMip2;
247
 
 
248
 
    //PBuffer *m_pbuffer;
249
 
public:
250
 
    WindowCompositor();
251
 
    WindowCompositor(const WindowCompositor&);
252
 
    // Does not make sense for a singleton. This is a self assignment.
253
 
    WindowCompositor& operator=(const WindowCompositor&);
254
 
    // Declare operator address-of as private 
255
 
    WindowCompositor* operator &();
256
 
    ~WindowCompositor();
257
 
 
258
 
    friend class GfxServerImpl;
259
 
    friend class BaseArea;
260
 
    friend class WindowThread;
261
 
};
262
 
 
263
 
NAMESPACE_END_GUI
 
23
#ifndef STACKMANAGER_H
 
24
#define STACKMANAGER_H
 
25
 
 
26
#include "BaseWindow.h"
 
27
 
 
28
NAMESPACE_BEGIN_GUI
 
29
 
 
30
class MenuPage;
 
31
class PBuffer;
 
32
class WindowThread;
 
33
class ActiveInterfaceObject;
 
34
class BaseArea;
 
35
class BaseObject;
 
36
class BaseWindow;
 
37
class PaintLayer;
 
38
 
 
39
class WindowCompositor
 
40
{
 
41
public:
 
42
    void Enumerate();
 
43
 
 
44
    void SetClientSize(int w, int h);
 
45
//    void DrawGrid(Graphics *g);
 
46
    void Draw(IEvent &event, bool force_draw);
 
47
    //void DrawList();
 
48
 
 
49
    void DrawPopup(bool force_draw);
 
50
    void DrawMenu(bool force_draw);
 
51
    void DrawOverlay(bool force_draw);
 
52
    void DrawTooltip(bool force_draw);
 
53
    void DrawFloatingWindows(bool force_draw, const std::list<smptr(BaseWindow)>& WindowList, bool drawModal, bool UseFBO);
 
54
 
 
55
    void RenderMainWindowComposition(bool force_draw, bool UseFBO);
 
56
    void RenderWindowComposition(smptr(BaseWindow) window, bool force_draw);
 
57
 
 
58
 
 
59
    /*!
 
60
        Render a textured quad the quad has the size of the texture. The texture maybe the main window texture or a BaseWindow texture. 
 
61
 
 
62
        @param HWTexture            Texture to render.
 
63
        @param x                    Coordinates of the top left corner of the quad.
 
64
        @param y                    Coordinates of the top left corner of the quad.
 
65
        @param RenderToMainTexture  If true, render to the main window texture. If false, render to the default back buffer.
 
66
        @param BluredBackground     If true, the texture is blended with the blurred version of the main window texture.
 
67
    */
 
68
    void PresentBufferToScreen(TRefGL<IOpenGLTexture2D> HWTexture, int x, int y, bool RenderToMainTexture, bool BluredBackground = false);
 
69
    void PresentRendering();
 
70
 
 
71
    /*!
 
72
        Set the composition render target as the texture to draw into.
 
73
    */
 
74
    void SetCompositionRT();
 
75
 
 
76
    /*!
 
77
        Draw a Texture into the composition render target.
 
78
        @param x    Destination coordinates.
 
79
        @param y    Destination coordinates.
 
80
    */
 
81
    void CopyTextureToCompositionRT(TRefGL<IOpenGLTexture2D> HWTexture, int x, int y);
 
82
 
 
83
    void AddToDrawList(smptr(ActiveInterfaceObject) ic);
 
84
    void ClearDrawList();
 
85
 
 
86
 
 
87
    bool MouseDown(Point pt);
 
88
 
 
89
    bool MouseMove(Point pt);
 
90
    bool MouseUp(Point pt);
 
91
    smptr(BaseWindow) GetSelectedWindow();
 
92
 
 
93
    void ProcessEvent(IEvent &ievent);
 
94
 
 
95
    void RegisterWindow(smptr(BaseWindow));
 
96
    void UnRegisterWindow(smptr(BaseWindow));
 
97
    void MoveWindowToFront(smptr(BaseWindow));
 
98
    void MoveWindowToBack(smptr(BaseWindow));
 
99
 
 
100
    TRefGL<IOpenGLFrameBufferObject>& GetWindowFrameBufferObject(){ return m_FrameBufferObject;}
 
101
    TRefGL<IOpenGLFrameBufferObject> m_FrameBufferObject;
 
102
 
 
103
    TRefGL< IOpenGLBaseTexture > GetScreenBlurTexture();
 
104
 
 
105
    // We use Rectangle texture to attach to the framebuffer because some GPU like the Geforce FX 5600 do not 
 
106
    // have support for ARB_texture_non_power_of_two. However it does support ARB_texture_recatangle.
 
107
    struct RenderTargetTextures
 
108
    {
 
109
        TRefGL<IOpenGLTexture2D> color_rt;
 
110
        TRefGL<IOpenGLTexture2D> depth_rt;
 
111
    };
 
112
    TRefGL<IOpenGLTexture2D> m_MainColorRT;
 
113
    TRefGL<IOpenGLTexture2D> m_MainDepthRT;
 
114
    TRefGL<IOpenGLTexture2D> m_CompositionRT;
 
115
 
 
116
    RenderTargetTextures& GetWindowBuffer(smptr(BaseWindow) window);
 
117
 
 
118
    void StartModalWindow(smptr(BaseWindow) );
 
119
    void StopModalWindow(smptr(BaseWindow) );
 
120
 
 
121
    std::vector<Rect> EventRect;
 
122
    void PushEventRectangle(Rect rect);
 
123
    void PopEventRectangle();
 
124
    void EmptyEventRegion();
 
125
    Rect getEventRect();
 
126
 
 
127
    void AddMenu(MenuPage* menu, smptr(BaseWindow) window, bool OverrideCurrentMenuChain = true);
 
128
    void RemoveMenu(MenuPage* menu);
 
129
    void CleanMenu();
 
130
 
 
131
    void PushModalWindow(smptr(BaseWindow) window);
 
132
 
 
133
//    typedef void(*AuxDrawCallback)();
 
134
//    AuxDrawCallback m_fAuxDrawCallback;
 
135
//
 
136
//    void SetAuxDrawCallback(AuxDrawCallback f) { m_fAuxDrawCallback = f; }
 
137
 
 
138
 
 
139
 
 
140
    void SetWidgetDrawingOverlay(smptr(BaseArea) ic, smptr(BaseWindow) OverlayWindow);
 
141
    smptr(BaseArea) GetWidgetDrawingOverlay();
 
142
 
 
143
    void SetTooltip(smptr(BaseArea) TooltipArea, const TCHAR *TooltipText, int x, int y);
 
144
    /*!
 
145
        Return true if the mouse is still inside the area that initiated the tooltip;
 
146
 
 
147
        @param x    The mouse x coordinate on screen.
 
148
        @param y    The mouse y coordinate on screen.
 
149
        @return     Return true is the mouse is still inside the area.
 
150
    */
 
151
    bool ValidateMouseInsideTooltipArea(int x, int y);
 
152
    /*!
 
153
        Return true if there is a valid tooltip active.
 
154
 
 
155
        @return     Return true if there is a valid tooltip active.
 
156
    */
 
157
    bool IsTooltipActive();
 
158
    void CancelTooltip();
 
159
 
 
160
    void SetAreaEventRoot(int x, int y)
 
161
    {
 
162
        m_EventRoot.Set(x, y);
 
163
    }
 
164
 
 
165
    void SetMouseFocusArea(smptr(BaseArea) area);
 
166
    smptr(BaseArea) GetMouseFocusArea();
 
167
    void SetMouseOverArea(smptr(BaseArea) area);
 
168
    smptr(BaseArea) GetMouseOverArea();
 
169
    void SetPreviousMouseOverArea(smptr(BaseArea) area);
 
170
    smptr(BaseArea) GetPreviousMouseOverArea();
 
171
 
 
172
    const IEvent* GetCurrentEvent() const {return m_CurrentEvent;}
 
173
    long ProcessEventOnObject(IEvent &ievent, smptr(BaseObject) object, long TraverseInfo, long ProcessEventInfo);
 
174
    
 
175
    smptr(BaseWindow) GetCurrentWindow() {return m_CurrentWindow;}
 
176
    smptr(BaseWindow) GetFocusAreaWindow() {return m_FocusAreaWindow;}
 
177
 
 
178
    void SetBackgroundPaintLayer(AbstractPaintLayer* bkg);
 
179
 
 
180
private:
 
181
    void SetCurrentWindow(smptr(BaseWindow) window) {m_CurrentWindow = window;}
 
182
    void SetFocusAreaWindow(smptr(BaseWindow) window) {m_FocusAreaWindow = window;}
 
183
    void SetCurrentEvent(IEvent* event) {m_CurrentEvent = event;}
 
184
 
 
185
    void FormatRenderTargets(int width, int height);
 
186
 
 
187
    void UpdatePostProcessRT();
 
188
 
 
189
    /*!
 
190
        Floating Area need to be informed when the main window has been resized.
 
191
 
 
192
        @param Width    New width of the window.
 
193
        @param Height   New height of the window.
 
194
    */
 
195
    void FloatingAreaConfigureNotify(int Width, int Height);
 
196
 
 
197
    smptr(BaseWindow) m_CurrentWindow;
 
198
    smptr(BaseWindow) m_FocusAreaWindow;
 
199
    smptr(BaseWindow) m_MenuWindow; // the window that owns the menu being displayed;
 
200
    IEvent* m_CurrentEvent; 
 
201
 
 
202
    smptr(BaseArea) m_MouseFocusArea;      // the base ares that has the mouse down.
 
203
    smptr(BaseArea) m_MouseOverArea;  // the base area that has the mouse directly over itself.
 
204
    smptr(BaseArea) m_PreviousMouseOverArea;
 
205
 
 
206
    smptr(BaseArea) OverlayDrawingCommand;
 
207
    smptr(BaseWindow) m_OverlayWindow; // the window that owns the overlay;
 
208
    smptr(BaseWindow) m_TooltipWindow; // the window that owns the tooltip;
 
209
    Point m_EventRoot;
 
210
 
 
211
    AbstractPaintLayer* m_Background;
 
212
 
 
213
    std::list<smptr(BaseWindow)> m_WindowList;
 
214
    std::list<smptr(BaseWindow)> m_ModalWindowList;
 
215
    std::list<smptr(ActiveInterfaceObject)> *m_DrawList;
 
216
    std::list<Rect> *m_EventRectList;
 
217
 
 
218
    std::list<MenuPage*> *m_MenuList;
 
219
 
 
220
    smptr(BaseWindow) m_SelectedWindow;
 
221
 
 
222
    std::map< smptr(BaseWindow), struct RenderTargetTextures > m_WindowToTextureMap;
 
223
 
 
224
    smptr(BaseWindow) m_ModalWindow;
 
225
    Point m_MouseLastPos;
 
226
    Point m_MouseCurrentPos;
 
227
 
 
228
    bool m_PopupRemoved;
 
229
    bool m_MenuRemoved;
 
230
    bool m_MouseUp;
 
231
    bool m_MouseDown;
 
232
 
 
233
    // Window Geometry
 
234
    int m_Width;
 
235
    int m_Height;
 
236
 
 
237
    NString m_TooltipText;
 
238
    smptr(BaseArea) m_TooltipArea;
 
239
    int m_TooltipX;
 
240
    int m_TooltipY;
 
241
 
 
242
    bool m_FullSceneBlurUpdated;
 
243
    TRefGL<IOpenGLTexture2D> m_BlurTexture;
 
244
    TRefGL<IOpenGLTexture2D> m_FullSceneMip0;
 
245
    TRefGL<IOpenGLTexture2D> m_FullSceneMip1;
 
246
    TRefGL<IOpenGLTexture2D> m_FullSceneMip2;
 
247
 
 
248
    //PBuffer *m_pbuffer;
 
249
public:
 
250
    WindowCompositor();
 
251
    WindowCompositor(const WindowCompositor&);
 
252
    // Does not make sense for a singleton. This is a self assignment.
 
253
    WindowCompositor& operator=(const WindowCompositor&);
 
254
    // Declare operator address-of as private 
 
255
    WindowCompositor* operator &();
 
256
    ~WindowCompositor();
 
257
 
 
258
    friend class GfxServerImpl;
 
259
    friend class BaseArea;
 
260
    friend class WindowThread;
 
261
};
 
262
 
 
263
NAMESPACE_END_GUI
264
264
#endif // STACKMANAGER_H
 
 
b'\\ No newline at end of file'