|
1 // Copyright (c) 2007-2009 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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @test |
|
19 @internalComponent - Internal Symbian test code |
|
20 */ |
|
21 |
|
22 #ifndef __EGLTEST_SURFACE_H__ |
|
23 #define __EGLTEST_SURFACE_H__ |
|
24 |
|
25 |
|
26 #include <e32base.h> |
|
27 #include <w32std.h> |
|
28 #include <graphics/surface.h> |
|
29 #include <graphics/surfacemanager.h> |
|
30 #include <graphics/surfaceupdateclient.h> |
|
31 #include <graphics/suerror.h> |
|
32 #include <EGL/egl.h> |
|
33 |
|
34 enum TSurfaceType |
|
35 { |
|
36 ESurfTypeRaw, |
|
37 ESurfTypeEglWindow, |
|
38 ESurfTypeRawSingleBuffered, |
|
39 ESurfTypePBuffer, |
|
40 ESurfTypeMaxTypes // Should be the last enum. |
|
41 }; |
|
42 |
|
43 // Index to Surface Parameters. |
|
44 enum TSurfaceIndex |
|
45 { |
|
46 EStandardSurface, |
|
47 EBadAttribSurface, |
|
48 EEmptyAttribSurface, |
|
49 EStandard128sqSurface, |
|
50 EUnusualStrideSurface, |
|
51 EUnalignedPixelSizeSurface, |
|
52 ELargeSurface, |
|
53 ELargestPossibleSurface, |
|
54 ESmallSurface, |
|
55 ETinySurface |
|
56 }; |
|
57 |
|
58 // Notification enums - allows us to use one function to request several notifications. |
|
59 enum TNotification |
|
60 { |
|
61 ENotifyWhenAvailable, |
|
62 ENotifyWhenDisplayed, |
|
63 ENotifyWhenDispXTimes, |
|
64 }; |
|
65 |
|
66 const TInt KNumAttribs = 3; |
|
67 |
|
68 // Common between local and remote |
|
69 struct TSurfaceParamsCommon |
|
70 { |
|
71 TSurfaceIndex iIndex; // Check that it matches - or we've got the table wrong. |
|
72 TInt iXSize, iYSize; |
|
73 TInt iBuffers; |
|
74 TInt iAlignment; |
|
75 TInt iStrideInBytes; |
|
76 TInt iOffsetToFirstBuffer; |
|
77 TUidPixelFormat iPixelFormat; |
|
78 TBool iUseAttribList; //when false use NULL in at attribute parameter |
|
79 EGLint iAttribs[KNumAttribs]; |
|
80 // Window info. |
|
81 TInt iXPos, iYPos; |
|
82 TDisplayMode iDisplayMode; |
|
83 }; |
|
84 |
|
85 struct TSurfaceParamsRemote |
|
86 { |
|
87 TSurfaceId iSurfaceId; |
|
88 TSurfaceParamsCommon iCommonParams; |
|
89 TSurfaceType iSurfaceType; |
|
90 }; |
|
91 |
|
92 |
|
93 |
|
94 //Interface for creating, drawing to and submitting content for a surface |
|
95 //Derived classes can implement different types of surface, that can be |
|
96 //used in the same test code. Ie surface manager surface (raw), egl window |
|
97 //surface, video surface, viewfinder surface. |
|
98 class CSurface: public CBase |
|
99 { |
|
100 public: |
|
101 // This function is kept for compatibility - new code should use offset |
|
102 // form of CreateL... |
|
103 virtual void CreateL(TInt aIndex); |
|
104 // Allow an offset for the top left corner of the surface on screen. |
|
105 virtual void CreateL(TInt aIndex, const TPoint& aOffset) = 0; |
|
106 virtual void DrawContentL(TInt aImageIndex) = 0; |
|
107 virtual void DrawContentL(const TRgb& aColour) = 0; |
|
108 virtual void DrawComplexL(const TRgb& aColour) = 0; |
|
109 virtual TInt SubmitContent(TBool aShouldWaitForDisplay, TInt aRectIndex = 0) = 0; |
|
110 virtual TSurfaceId SurfaceId() const = 0; |
|
111 virtual void GetSurfaceParamsL(TSurfaceParamsRemote &aParams) = 0; |
|
112 virtual const TText *GetSurfaceTypeStr() const = 0; |
|
113 virtual TInt Notify(TNotification aWhen, TRequestStatus &aStatus, TUint32 aXTimes) = 0; |
|
114 virtual TInt WaitFor(TNotification aWhen, TRequestStatus &aStatus, TInt aTimeoutInMicroseconds, TUint32& aTimeStamp) = 0; |
|
115 virtual TInt SizeInBytes() const; |
|
116 |
|
117 |
|
118 TSize Size(); |
|
119 |
|
120 public: |
|
121 // Factory function to create a surface of aSurfType. |
|
122 static CSurface *SurfaceFactoryL(TSurfaceType aSurfType); |
|
123 protected: |
|
124 TInt iParamIndex; |
|
125 TSize iActualSize; |
|
126 }; |
|
127 |
|
128 |
|
129 //Raw surface implements CSurface for basic surface manager surface. |
|
130 class CRawSurface : public CSurface |
|
131 { |
|
132 public: |
|
133 static CRawSurface* NewL(); |
|
134 ~CRawSurface(); |
|
135 |
|
136 // From CSurface |
|
137 virtual void CreateL(TInt aIndex, const TPoint& aOffset); |
|
138 void DrawContentL(TInt aIndex); |
|
139 void DrawContentL(const TRgb& aColour); |
|
140 void DrawComplexL(const TRgb& aColour); |
|
141 TInt SubmitContent(TBool aShouldWaitForDisplay, TInt aRectIndex = 0); |
|
142 TSurfaceId SurfaceId() const; |
|
143 void GetSurfaceParamsL(TSurfaceParamsRemote &aParams); |
|
144 virtual const TText *GetSurfaceTypeStr() const; |
|
145 virtual TInt Notify(TNotification aWhen, TRequestStatus &aStatus, TUint32 aXTimes); |
|
146 virtual TInt WaitFor(TNotification aWhen, TRequestStatus &aStatus, TInt aTimeoutInMicroseconds, TUint32& aTimeStamp); |
|
147 |
|
148 protected: |
|
149 CRawSurface(); |
|
150 void ConstructL(); |
|
151 TUint8* MapSurfaceAndGetInfoLC(RSurfaceManager::TSurfaceInfoV01& aInfo); |
|
152 void GetSurfAttribs(RSurfaceManager::TSurfaceCreationAttributesBuf &aSurfaceAttribs, TInt aIndex, TInt aSizeIndex); |
|
153 |
|
154 private: |
|
155 static TInt PixelSize(TUidPixelFormat aPixelFormat); |
|
156 static TRequestStatus *GetRequestPtr(TNotification aWhen); |
|
157 |
|
158 private: |
|
159 RSurfaceUpdateSession iSurfaceUpdate; |
|
160 TRequestStatus iAvailable; |
|
161 TRequestStatus iDisplayed; |
|
162 TRequestStatus iDisplayedXTimes; |
|
163 TTimeStamp iTimeStamp; |
|
164 TInt iDrawBuffer; |
|
165 RChunk iSurfaceChunk; |
|
166 |
|
167 protected: |
|
168 TInt iBuffers; |
|
169 RSurfaceManager iSurfaceManager; |
|
170 TSurfaceId iSurfaceId; |
|
171 }; |
|
172 |
|
173 // Simple wrapper to enable a list of "singlebuffer" in the list of buffer types. |
|
174 class CRawSingleBufferSurface : public CRawSurface |
|
175 { |
|
176 public: |
|
177 static CRawSingleBufferSurface* NewL(); |
|
178 ~CRawSingleBufferSurface(); |
|
179 |
|
180 virtual void CreateL(TInt aIndex, const TPoint& aOffset); |
|
181 virtual const TText *GetSurfaceTypeStr() const; |
|
182 }; |
|
183 |
|
184 // Forward declare classes that we do not need to know the content of. |
|
185 class CWindow; |
|
186 class CTestVgImage; |
|
187 |
|
188 class CEglSurfaceBase : public CSurface |
|
189 { |
|
190 public: |
|
191 void CreateL(TInt aIndex, const TPoint& aOffset); |
|
192 void DrawContentL(TInt aImageIndex); |
|
193 void DrawContentL(const TRgb& aColour); |
|
194 void DrawComplexL(const TRgb& aColour); |
|
195 TInt SubmitContent(TBool aShouldWaitForDisplay, TInt aRectIndex = 0); |
|
196 TInt Activate(); |
|
197 void ActivateL(); |
|
198 void GetSurfaceParamsL(TSurfaceParamsRemote &aParams); |
|
199 virtual TInt Notify(TNotification aWhen, TRequestStatus &aStatus, TUint32 aXTimes); |
|
200 virtual TInt WaitFor(TNotification aWhen, TRequestStatus &aStatus, TInt aTimeoutInMicroseconds, TUint32& aTimeStamp); |
|
201 |
|
202 protected: |
|
203 void BaseCreateL(TInt aIndex, EGLint aSurfaceType); |
|
204 virtual void DoCreateL(TInt aIndex, const TPoint& aOffset, TInt aSizeIndex) = 0; |
|
205 void Destroy(); |
|
206 |
|
207 protected: |
|
208 EGLContext iContext; |
|
209 EGLSurface iSurface; |
|
210 EGLDisplay iDisplay; |
|
211 EGLConfig iConfig; |
|
212 }; |
|
213 |
|
214 class CEglWindowSurface : public CEglSurfaceBase |
|
215 { |
|
216 public: |
|
217 static CEglWindowSurface* NewL(); |
|
218 ~CEglWindowSurface(); |
|
219 |
|
220 TSurfaceId SurfaceId() const; |
|
221 virtual const TText *GetSurfaceTypeStr() const; |
|
222 |
|
223 private: |
|
224 CEglWindowSurface(); |
|
225 void DoCreateL(TInt aIndex, const TPoint& aOffset, TInt aSizeIndex); |
|
226 void ConstructL(); |
|
227 |
|
228 private: |
|
229 CWindow* iWindow; |
|
230 }; |
|
231 |
|
232 class CEglPBufferSurface : public CEglSurfaceBase |
|
233 { |
|
234 public: |
|
235 static CEglPBufferSurface* NewL(); |
|
236 ~CEglPBufferSurface(); |
|
237 TSurfaceId SurfaceId() const; |
|
238 |
|
239 virtual const TText *GetSurfaceTypeStr() const; |
|
240 |
|
241 TInt SizeInBytes() const; |
|
242 |
|
243 private: |
|
244 CEglPBufferSurface(); |
|
245 void ConstructL(); |
|
246 void DoCreateL(TInt aIndex, const TPoint& aOffset, TInt aSizeIndex); |
|
247 }; |
|
248 |
|
249 |
|
250 #endif |