|
1 // Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // This file is intended for use by clients of EGL. It provides |
|
15 // the window type that clients must use in order to create EGL |
|
16 // window surfaces that have no dependency on the window server. |
|
17 |
|
18 |
|
19 /** |
|
20 @file |
|
21 @publishedPartner |
|
22 @prototype |
|
23 */ |
|
24 |
|
25 |
|
26 #ifndef __EGLWINDOW_H__ |
|
27 #define __EGLWINDOW_H__ |
|
28 |
|
29 |
|
30 #include <graphics/eglwindowcommon.h> |
|
31 |
|
32 |
|
33 /** |
|
34 Base class for all EGL window types except for RWindow. If an |
|
35 RWindow pointer is cast to this type, IsRWindow() will return true. |
|
36 */ |
|
37 NONSHARABLE_CLASS(REglWindowBase) |
|
38 { |
|
39 public: |
|
40 virtual TBool IsValid() const = 0; |
|
41 virtual TSize SizeInPixels() const = 0; |
|
42 virtual TSize SizeInTwips() const = 0; |
|
43 virtual TInt ScreenNumber() const = 0; |
|
44 virtual void SetBackgroundColor(TRgb aColor, TBool aTriggerRedraw) = 0; |
|
45 virtual TInt SetBackgroundSurface(const TSurfaceConfiguration &aConfiguration, TBool aTriggerRedraw) = 0; |
|
46 virtual void RemoveBackgroundSurface(TBool aTriggerRedraw) = 0; |
|
47 |
|
48 protected: |
|
49 REglWindowBase(); |
|
50 |
|
51 private: |
|
52 friend class TEglWindowInterface; |
|
53 TBool IsRWindow() const; |
|
54 |
|
55 private: |
|
56 //This is aligned with RWindow::iBuffer, which is at offset 4 in RWindow. |
|
57 //Note that this class has virtual functions to the vptr occupies bytes 0-3. |
|
58 TInt iIsRWindow; |
|
59 }; |
|
60 |
|
61 |
|
62 /** |
|
63 Forward Declarations. |
|
64 */ |
|
65 class MEglStandAloneWindowObserver; |
|
66 |
|
67 |
|
68 /** |
|
69 Concrete EGL window type that has mutable size. It informs its |
|
70 delegate whenever a surface is attached and removed from it. It is |
|
71 intended that render stages requiring an EGL window surface create a |
|
72 window of this type, passing itself as the delegate. When creating |
|
73 the EGL window surface, the render stage passes this window as the |
|
74 EGLNativeWindowType. Whenever EGL attaches and removes surfaces, the |
|
75 render stage is notified via the delegate and can act accordingly by |
|
76 modifying the compositor's scene. The symbian composition surface |
|
77 can be retrieved by calling GetBackgroundSurface(). This surface |
|
78 is considered unmappable. Users must not call RSurfaceManager:: |
|
79 MapSurface() for this surface. |
|
80 */ |
|
81 NONSHARABLE_CLASS(REglStandAloneWindow) : public REglWindowBase |
|
82 { |
|
83 public: |
|
84 IMPORT_C REglStandAloneWindow(); |
|
85 IMPORT_C TInt Create(const TSize& aSizeInPixels, const TSize& aSizeInTwips, TInt aScreenNumber, MEglStandAloneWindowObserver& aObserver); |
|
86 IMPORT_C void Close(); |
|
87 |
|
88 IMPORT_C void SetSizeInPixels(const TSize& aSize); |
|
89 IMPORT_C void SetSizeInTwips(const TSize& aSize); |
|
90 IMPORT_C TRgb BackgroundColor() const; |
|
91 IMPORT_C TBool GetBackgroundSurface(TSurfaceConfiguration& aConfiguration) const; |
|
92 |
|
93 public: //From REglWindowBase. |
|
94 IMPORT_C TBool IsValid() const; |
|
95 IMPORT_C TSize SizeInPixels() const; |
|
96 IMPORT_C TSize SizeInTwips() const; |
|
97 IMPORT_C TInt ScreenNumber() const; |
|
98 IMPORT_C void SetBackgroundColor(TRgb aColor, TBool aTriggerRedraw); |
|
99 IMPORT_C TInt SetBackgroundSurface(const TSurfaceConfiguration& aConfiguration, TBool aTriggerRedraw); |
|
100 IMPORT_C void RemoveBackgroundSurface(TBool aTriggerRedraw); |
|
101 |
|
102 private: |
|
103 class TEglStandAloneWindowData; |
|
104 TEglStandAloneWindowData* iData; |
|
105 }; |
|
106 |
|
107 |
|
108 /** |
|
109 Delegate class intended for implementation by a render stage that |
|
110 requires an EGL window surface. See REglStandAloneWindow. |
|
111 */ |
|
112 class MEglStandAloneWindowObserver |
|
113 { |
|
114 public: |
|
115 /** |
|
116 This method is called by REglStandAloneWindow just after a new |
|
117 background color was set for the REglStandAloneWindow instance. |
|
118 It provides the observer with an oportunity to adjust the |
|
119 compositor's scene to reflect this change. |
|
120 |
|
121 @param aWindow The instance of REglStandAloneWindow that |
|
122 the background color was set upon. |
|
123 |
|
124 @param aTriggerRedraw If set, the client that set the |
|
125 background surface expects that it will |
|
126 appear on screen immediately. |
|
127 */ |
|
128 virtual void ColorWasSetForWindow(const REglStandAloneWindow& aWindow, TBool aTriggerRedraw) = 0; |
|
129 |
|
130 /** |
|
131 This method is called by REglStandAloneWindow just after a new |
|
132 background surface was set on the REglStandAloneWindow instance. |
|
133 It provides the observer with an oportunity to adjust the |
|
134 compositor's scene to include this new surface. |
|
135 |
|
136 @param aWindow The instance of REglStandAloneWindow that |
|
137 the background surface was set upon. |
|
138 |
|
139 @param aTriggerRedraw If set, the client that set the |
|
140 background surface expects that it will |
|
141 appear on screen immediately. |
|
142 |
|
143 @return KErrNone on success or any system-wide error code. This |
|
144 is reported back to the caller of REglStandAloneWindow:: |
|
145 SetBackgroundSurface(). |
|
146 */ |
|
147 virtual TInt SurfaceWasSetForWindow(const REglStandAloneWindow& aWindow, TBool aTriggerRedraw) = 0; |
|
148 |
|
149 /** |
|
150 This method is called by REglStandAloneWindow just before the |
|
151 current background surface will be removed from the |
|
152 REglStandAloneWindow instance. It provides the observer with an |
|
153 oportunity to adjust the compositor's scene to exclude this |
|
154 surface and unregister the surface with the compositor. |
|
155 |
|
156 @param aWindow The instance of REglStandAloneWindow that |
|
157 the background surface was removed from. |
|
158 |
|
159 @param aTriggerRedraw If set, the client that removed the |
|
160 background surface expects that the |
|
161 changes will appear on screen |
|
162 immediately. |
|
163 */ |
|
164 virtual void SurfaceWillBeRemovedForWindow(const REglStandAloneWindow& aWindow, TBool aTriggerRedraw) = 0; |
|
165 }; |
|
166 |
|
167 |
|
168 #endif //__EGLWINDOW_H__ |