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