sl@0
|
1 |
// Copyright (c) 2006-2010 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 |
#ifndef __SURFACEUPDATESERVER_H__
|
sl@0
|
17 |
#define __SURFACEUPDATESERVER_H__
|
sl@0
|
18 |
|
sl@0
|
19 |
/**
|
sl@0
|
20 |
@file
|
sl@0
|
21 |
@internalTechnology
|
sl@0
|
22 |
*/
|
sl@0
|
23 |
|
sl@0
|
24 |
#include <e32std.h>
|
sl@0
|
25 |
#include <e32base.h>
|
sl@0
|
26 |
#include <graphics/updateserverprovider.h>
|
sl@0
|
27 |
#include <graphics/compositionsurfaceupdate.h>
|
sl@0
|
28 |
|
sl@0
|
29 |
enum TSurfaceUpdateServPanic
|
sl@0
|
30 |
{
|
sl@0
|
31 |
EUpdateServPanicBadRequest = 1,
|
sl@0
|
32 |
EUpdateServPanicNoMemory,
|
sl@0
|
33 |
EUpdateServPanicStartUp,
|
sl@0
|
34 |
EUpdateServPanicDataIntegrity,
|
sl@0
|
35 |
EUpdateServPanicRegister,
|
sl@0
|
36 |
EUpdateServPanicGlobalFastLock,
|
sl@0
|
37 |
};
|
sl@0
|
38 |
|
sl@0
|
39 |
enum TSurfaceUpdateEvent
|
sl@0
|
40 |
{
|
sl@0
|
41 |
EUpdateServEventRegister = 1,
|
sl@0
|
42 |
EUpdateServEventTerminate //this event will only be used for test purpose
|
sl@0
|
43 |
};
|
sl@0
|
44 |
|
sl@0
|
45 |
class CSurfaceUpdateServer;
|
sl@0
|
46 |
|
sl@0
|
47 |
/**
|
sl@0
|
48 |
The class implements interface(s) required for content update
|
sl@0
|
49 |
Intended to be used by Surface-update control flow
|
sl@0
|
50 |
@see MSurfaceUpdateServerProvider
|
sl@0
|
51 |
*/
|
sl@0
|
52 |
class CSurfaceUpdateServerProvider : public CActive, public MSurfaceUpdateServerProvider
|
sl@0
|
53 |
{
|
sl@0
|
54 |
public:
|
sl@0
|
55 |
static CSurfaceUpdateServerProvider* NewL(CActive::TPriority aPriority, CSurfaceUpdateServer* aServer);
|
sl@0
|
56 |
~CSurfaceUpdateServerProvider();
|
sl@0
|
57 |
//from MSurfaceUpdateServerProvider
|
sl@0
|
58 |
IMPORT_C TInt Register(TInt aScreen, CBase* aUpdateReceiver, TInt aPriority);
|
sl@0
|
59 |
//the following function is intended to be used for test purpose only,
|
sl@0
|
60 |
//will have no effect in the release build
|
sl@0
|
61 |
IMPORT_C void Terminate();
|
sl@0
|
62 |
protected:
|
sl@0
|
63 |
CSurfaceUpdateServerProvider(CActive::TPriority aPriority, CSurfaceUpdateServer* aServer);
|
sl@0
|
64 |
void ConstructL();
|
sl@0
|
65 |
void RunL();
|
sl@0
|
66 |
void DoCancel();
|
sl@0
|
67 |
protected:
|
sl@0
|
68 |
CSurfaceUpdateServer* iServer;
|
sl@0
|
69 |
TThreadId iThreadId;
|
sl@0
|
70 |
TInt iRegisterErr;
|
sl@0
|
71 |
CBase* iUpdateReceiver;
|
sl@0
|
72 |
TInt iScreen;
|
sl@0
|
73 |
TInt iPriority;
|
sl@0
|
74 |
RSemaphore iSemaphore;
|
sl@0
|
75 |
};
|
sl@0
|
76 |
/**
|
sl@0
|
77 |
Priority is used to identify the master screen for the surface.
|
sl@0
|
78 |
*/
|
sl@0
|
79 |
class TUpdateReceiverPriorityEntry
|
sl@0
|
80 |
{
|
sl@0
|
81 |
public:
|
sl@0
|
82 |
TInt iPriority; //Highest number signifies highest priority of the screen.
|
sl@0
|
83 |
MCompositionSurfaceUpdate* iUpdateReceiver; //doesn't own
|
sl@0
|
84 |
};
|
sl@0
|
85 |
|
sl@0
|
86 |
|
sl@0
|
87 |
/**
|
sl@0
|
88 |
The server maintains session with the clients.
|
sl@0
|
89 |
It starts during the initialization of the Compositor thread.
|
sl@0
|
90 |
*/
|
sl@0
|
91 |
class CSurfaceUpdateServer : public CServer2
|
sl@0
|
92 |
{
|
sl@0
|
93 |
friend class CSurfaceUpdateSession;
|
sl@0
|
94 |
public:
|
sl@0
|
95 |
static CSurfaceUpdateServer* NewL();
|
sl@0
|
96 |
|
sl@0
|
97 |
~CSurfaceUpdateServer();
|
sl@0
|
98 |
|
sl@0
|
99 |
TInt Register(TInt aScreen, CBase* aUpdateReceiver, TInt aPriority);
|
sl@0
|
100 |
virtual CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
|
sl@0
|
101 |
static void PanicServer(TSurfaceUpdateServPanic aPanic);
|
sl@0
|
102 |
|
sl@0
|
103 |
/**
|
sl@0
|
104 |
Provide surface update provider for usage by the content update receiver.
|
sl@0
|
105 |
|
sl@0
|
106 |
@return surface update provider
|
sl@0
|
107 |
*/
|
sl@0
|
108 |
MSurfaceUpdateServerProvider* SurfaceUpdateProvider() const
|
sl@0
|
109 |
{
|
sl@0
|
110 |
return static_cast <MSurfaceUpdateServerProvider*> (iServerProvider);
|
sl@0
|
111 |
}
|
sl@0
|
112 |
static TInt ThreadFunction(TAny* aAny);
|
sl@0
|
113 |
// for DEF118736: [v9.5] turfaceupdatetestserver unexecuted
|
sl@0
|
114 |
// For test purposes, only if iNumberPendingNotification reaches zero, the surface update server can be shut.
|
sl@0
|
115 |
// The counter is incremented by one when the CUpdateReceiverNotification AO is set to self-destroyed in surface update session's destructor()
|
sl@0
|
116 |
// The counter is decremented by one before its self-destruction in CUpdateReceiverNotification AO's RunL()
|
sl@0
|
117 |
#ifdef TEST_SURFACE_UPDATE
|
sl@0
|
118 |
TInt iNumberPendingNotification;
|
sl@0
|
119 |
#endif
|
sl@0
|
120 |
protected:
|
sl@0
|
121 |
void ConstructL();
|
sl@0
|
122 |
CSurfaceUpdateServer(CActive::TPriority aPriority);
|
sl@0
|
123 |
MCompositionSurfaceUpdate* UpdateReceiver(TInt aScreen) const;
|
sl@0
|
124 |
/**
|
sl@0
|
125 |
@return content update receiver priority list
|
sl@0
|
126 |
*/
|
sl@0
|
127 |
inline const RPointerArray<TUpdateReceiverPriorityEntry>& UpdateReceiverPriority() const;
|
sl@0
|
128 |
|
sl@0
|
129 |
inline TInt NumUpdateReceivers() const;
|
sl@0
|
130 |
static TInt CompareUpdateReceiverPriority(const TUpdateReceiverPriorityEntry& aEntry1, const TUpdateReceiverPriorityEntry& aEntry2);
|
sl@0
|
131 |
protected:
|
sl@0
|
132 |
RPointerArray<MCompositionSurfaceUpdate> iUpdateReceiver; //Screen number is the index for the access of the receiver entry in the array
|
sl@0
|
133 |
RPointerArray<TUpdateReceiverPriorityEntry> iUpdateReceiverPriorityOrder; //stored in priority order, the higher the priority of the receiver the closer to the beginning of the array
|
sl@0
|
134 |
CSurfaceUpdateServerProvider* iServerProvider;
|
sl@0
|
135 |
};
|
sl@0
|
136 |
|
sl@0
|
137 |
|
sl@0
|
138 |
enum TNotificationType
|
sl@0
|
139 |
{
|
sl@0
|
140 |
EUpdateSrvReusable = 1, /**< When a notification batch doesn’t contain any active notifiers, i.e. they have been processed by the content update receiver, the batch will not be deleted but becomes available for the following reuse.*/
|
sl@0
|
141 |
EUpdateSrvAvailable,
|
sl@0
|
142 |
EUpdateSrvDisplayed,
|
sl@0
|
143 |
EUpdateSrvDisplayedXTimes,
|
sl@0
|
144 |
};
|
sl@0
|
145 |
|
sl@0
|
146 |
class CSurfaceUpdateSession;
|
sl@0
|
147 |
class CUpdateReceiverNotificationBatch;
|
sl@0
|
148 |
|
sl@0
|
149 |
/**
|
sl@0
|
150 |
Notification object. Content update receiver signals the server via this object of composition events.
|
sl@0
|
151 |
*/
|
sl@0
|
152 |
class CUpdateReceiverNotification : public CActive
|
sl@0
|
153 |
{
|
sl@0
|
154 |
public:
|
sl@0
|
155 |
CUpdateReceiverNotification(CActive::TPriority aPriority, TInt aReceiverPriority, CUpdateReceiverNotificationBatch *aParentNotificationBatch);
|
sl@0
|
156 |
~CUpdateReceiverNotification();
|
sl@0
|
157 |
TRequestStatus& Status();
|
sl@0
|
158 |
void Activate();
|
sl@0
|
159 |
protected:
|
sl@0
|
160 |
void DoCancel();
|
sl@0
|
161 |
virtual void RunL();
|
sl@0
|
162 |
public:
|
sl@0
|
163 |
TUint32 iTimeStamp;
|
sl@0
|
164 |
TInt iUpdateReceiverPriority;
|
sl@0
|
165 |
TBool iSelfDestructWhenRun;
|
sl@0
|
166 |
protected:
|
sl@0
|
167 |
#ifdef TEST_SURFACE_UPDATE
|
sl@0
|
168 |
void DecNumberPendingNotifications();
|
sl@0
|
169 |
#endif
|
sl@0
|
170 |
protected:
|
sl@0
|
171 |
CUpdateReceiverNotificationBatch *iParentNotificationBatch; //doesn't own
|
sl@0
|
172 |
#ifdef TEST_SURFACE_UPDATE
|
sl@0
|
173 |
CSurfaceUpdateServer* iServer;
|
sl@0
|
174 |
#endif
|
sl@0
|
175 |
};
|
sl@0
|
176 |
|
sl@0
|
177 |
/**
|
sl@0
|
178 |
The class manages the batch of notification objects with the same type and
|
sl@0
|
179 |
initiated by the particular SubmitUpdate request.
|
sl@0
|
180 |
*/
|
sl@0
|
181 |
class CUpdateReceiverNotificationBatch : public CBase
|
sl@0
|
182 |
{
|
sl@0
|
183 |
public:
|
sl@0
|
184 |
CUpdateReceiverNotificationBatch(CSurfaceUpdateSession *aSession, TInt aNumReceivers);
|
sl@0
|
185 |
~CUpdateReceiverNotificationBatch();
|
sl@0
|
186 |
void ProcessNotificationEvent(CUpdateReceiverNotification* aReceiverNotification);
|
sl@0
|
187 |
TBool IsActive() const;
|
sl@0
|
188 |
CUpdateReceiverNotification* UpdateReceiverNotification(TInt aReceiverPriority = 0);
|
sl@0
|
189 |
void CheckForReuse();
|
sl@0
|
190 |
void SetNumUpdateReceivers(TInt aNumUpdateReceivers);
|
sl@0
|
191 |
#ifdef TEST_SURFACE_UPDATE
|
sl@0
|
192 |
CSurfaceUpdateServer* Server();
|
sl@0
|
193 |
void IncNumberPendingNotifications();
|
sl@0
|
194 |
#endif
|
sl@0
|
195 |
public:
|
sl@0
|
196 |
RMessage2 iMsg;
|
sl@0
|
197 |
TNotificationType iType;
|
sl@0
|
198 |
RPointerArray<CUpdateReceiverNotification> iUpdateReceiverNotifications; //for multiple entries stored in priority order, the higher the priority of the receiver the closer to the beginning of the array
|
sl@0
|
199 |
protected:
|
sl@0
|
200 |
CSurfaceUpdateSession *iSession; //doesn't own
|
sl@0
|
201 |
TInt iNumUpdateReceivers;
|
sl@0
|
202 |
TBool iCompleteWithSuccess;
|
sl@0
|
203 |
TInt iHighestPriority; //attributed to successful notification
|
sl@0
|
204 |
TUint32 iTimeStamp; //attributed to successful notification
|
sl@0
|
205 |
};
|
sl@0
|
206 |
|
sl@0
|
207 |
/**
|
sl@0
|
208 |
Maintain the channel between clients and the server.
|
sl@0
|
209 |
Functions are provided will respond appropriately to client messages.
|
sl@0
|
210 |
*/
|
sl@0
|
211 |
class CSurfaceUpdateSession : public CSession2
|
sl@0
|
212 |
{
|
sl@0
|
213 |
public:
|
sl@0
|
214 |
CSurfaceUpdateSession(const RPointerArray<TUpdateReceiverPriorityEntry>& aReceiverEntryList);
|
sl@0
|
215 |
~CSurfaceUpdateSession();
|
sl@0
|
216 |
void SubmitUpdate(const RMessage2& aMessage);
|
sl@0
|
217 |
void NotifyWhenAvailable(const RMessage2& aMessage);
|
sl@0
|
218 |
void NotifyWhenDisplayed(const RMessage2& aMessage);
|
sl@0
|
219 |
void NotifyWhenDisplayedXTimes(const RMessage2& aMessage);
|
sl@0
|
220 |
void CancelAllUpdateNotifications();
|
sl@0
|
221 |
protected:
|
sl@0
|
222 |
void DoSubmitUpdateL(const RMessage2& aMessage);
|
sl@0
|
223 |
void StoreNotification(CUpdateReceiverNotificationBatch*& aNotifier, const RMessage2& aMessage, TNotificationType aType);
|
sl@0
|
224 |
virtual void ServiceL(const RMessage2& aMessage);
|
sl@0
|
225 |
void PanicClient(const RMessage2& aMessage, TInt aPanic) const;
|
sl@0
|
226 |
CUpdateReceiverNotificationBatch* UpdateReceiverNotificationBatchL();
|
sl@0
|
227 |
void IssueRequestComplete(TInt aErr);
|
sl@0
|
228 |
void DispatchUpdate(const TSurfaceId& aSurfaceId, TInt aBuffer, RRegion* aRegion, TInt* aDisplayedXTimes, MCompositionSurfaceUpdate* aReceiver = NULL );
|
sl@0
|
229 |
#ifdef TEST_SURFACE_UPDATE
|
sl@0
|
230 |
void SetHeapFailure(const RMessage2& aMessage);
|
sl@0
|
231 |
#endif
|
sl@0
|
232 |
private:
|
sl@0
|
233 |
RPointerArray<CUpdateReceiverNotificationBatch> iUpdateReceiverNotificationBatches;
|
sl@0
|
234 |
CUpdateReceiverNotificationBatch* iAvailable;
|
sl@0
|
235 |
CUpdateReceiverNotificationBatch* iDisplayed;
|
sl@0
|
236 |
CUpdateReceiverNotificationBatch* iDisplayedXTimes;
|
sl@0
|
237 |
const RPointerArray<TUpdateReceiverPriorityEntry>& iUpdateReceiverEntryList; //doesn't own
|
sl@0
|
238 |
enum
|
sl@0
|
239 |
{
|
sl@0
|
240 |
EUpdateMethodNone,
|
sl@0
|
241 |
EUpdateMethodPerScreen,
|
sl@0
|
242 |
EUpdateMethodGlobal,
|
sl@0
|
243 |
} iUpdateMethod;
|
sl@0
|
244 |
};
|
sl@0
|
245 |
|
sl@0
|
246 |
inline const RPointerArray<TUpdateReceiverPriorityEntry>& CSurfaceUpdateServer::UpdateReceiverPriority() const
|
sl@0
|
247 |
{
|
sl@0
|
248 |
return iUpdateReceiverPriorityOrder;
|
sl@0
|
249 |
}
|
sl@0
|
250 |
|
sl@0
|
251 |
#endif
|