Update contrib.
1 // Copyright (c) 2006-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __SURFACEUPDATESERVER_H__
17 #define __SURFACEUPDATESERVER_H__
26 #include <graphics/updateserverprovider.h>
27 #include <graphics/compositionsurfaceupdate.h>
29 enum TSurfaceUpdateServPanic
31 EUpdateServPanicBadRequest = 1,
32 EUpdateServPanicNoMemory,
33 EUpdateServPanicStartUp,
34 EUpdateServPanicDataIntegrity,
35 EUpdateServPanicRegister,
36 EUpdateServPanicGlobalFastLock,
39 enum TSurfaceUpdateEvent
41 EUpdateServEventRegister = 1,
42 EUpdateServEventTerminate //this event will only be used for test purpose
45 class CSurfaceUpdateServer;
48 The class implements interface(s) required for content update
49 Intended to be used by Surface-update control flow
50 @see MSurfaceUpdateServerProvider
52 class CSurfaceUpdateServerProvider : public CActive, public MSurfaceUpdateServerProvider
55 static CSurfaceUpdateServerProvider* NewL(CActive::TPriority aPriority, CSurfaceUpdateServer* aServer);
56 ~CSurfaceUpdateServerProvider();
57 //from MSurfaceUpdateServerProvider
58 IMPORT_C TInt Register(TInt aScreen, CBase* aUpdateReceiver, TInt aPriority);
59 //the following function is intended to be used for test purpose only,
60 //will have no effect in the release build
61 IMPORT_C void Terminate();
63 CSurfaceUpdateServerProvider(CActive::TPriority aPriority, CSurfaceUpdateServer* aServer);
68 CSurfaceUpdateServer* iServer;
71 CBase* iUpdateReceiver;
74 RSemaphore iSemaphore;
77 Priority is used to identify the master screen for the surface.
79 class TUpdateReceiverPriorityEntry
82 TInt iPriority; //Highest number signifies highest priority of the screen.
83 MCompositionSurfaceUpdate* iUpdateReceiver; //doesn't own
88 The server maintains session with the clients.
89 It starts during the initialization of the Compositor thread.
91 class CSurfaceUpdateServer : public CServer2
93 friend class CSurfaceUpdateSession;
95 static CSurfaceUpdateServer* NewL();
97 ~CSurfaceUpdateServer();
99 TInt Register(TInt aScreen, CBase* aUpdateReceiver, TInt aPriority);
100 virtual CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
101 static void PanicServer(TSurfaceUpdateServPanic aPanic);
104 Provide surface update provider for usage by the content update receiver.
106 @return surface update provider
108 MSurfaceUpdateServerProvider* SurfaceUpdateProvider() const
110 return static_cast <MSurfaceUpdateServerProvider*> (iServerProvider);
112 static TInt ThreadFunction(TAny* aAny);
113 // for DEF118736: [v9.5] turfaceupdatetestserver unexecuted
114 // For test purposes, only if iNumberPendingNotification reaches zero, the surface update server can be shut.
115 // The counter is incremented by one when the CUpdateReceiverNotification AO is set to self-destroyed in surface update session's destructor()
116 // The counter is decremented by one before its self-destruction in CUpdateReceiverNotification AO's RunL()
117 #ifdef TEST_SURFACE_UPDATE
118 TInt iNumberPendingNotification;
122 CSurfaceUpdateServer(CActive::TPriority aPriority);
123 MCompositionSurfaceUpdate* UpdateReceiver(TInt aScreen) const;
125 @return content update receiver priority list
127 inline const RPointerArray<TUpdateReceiverPriorityEntry>& UpdateReceiverPriority() const;
129 inline TInt NumUpdateReceivers() const;
130 static TInt CompareUpdateReceiverPriority(const TUpdateReceiverPriorityEntry& aEntry1, const TUpdateReceiverPriorityEntry& aEntry2);
132 RPointerArray<MCompositionSurfaceUpdate> iUpdateReceiver; //Screen number is the index for the access of the receiver entry in the array
133 RPointerArray<TUpdateReceiverPriorityEntry> iUpdateReceiverPriorityOrder; //stored in priority order, the higher the priority of the receiver the closer to the beginning of the array
134 CSurfaceUpdateServerProvider* iServerProvider;
138 enum TNotificationType
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.*/
143 EUpdateSrvDisplayedXTimes,
146 class CSurfaceUpdateSession;
147 class CUpdateReceiverNotificationBatch;
150 Notification object. Content update receiver signals the server via this object of composition events.
152 class CUpdateReceiverNotification : public CActive
155 CUpdateReceiverNotification(CActive::TPriority aPriority, TInt aReceiverPriority, CUpdateReceiverNotificationBatch *aParentNotificationBatch);
156 ~CUpdateReceiverNotification();
157 TRequestStatus& Status();
164 TInt iUpdateReceiverPriority;
165 TBool iSelfDestructWhenRun;
167 #ifdef TEST_SURFACE_UPDATE
168 void DecNumberPendingNotifications();
171 CUpdateReceiverNotificationBatch *iParentNotificationBatch; //doesn't own
172 #ifdef TEST_SURFACE_UPDATE
173 CSurfaceUpdateServer* iServer;
178 The class manages the batch of notification objects with the same type and
179 initiated by the particular SubmitUpdate request.
181 class CUpdateReceiverNotificationBatch : public CBase
184 CUpdateReceiverNotificationBatch(CSurfaceUpdateSession *aSession, TInt aNumReceivers);
185 ~CUpdateReceiverNotificationBatch();
186 void ProcessNotificationEvent(CUpdateReceiverNotification* aReceiverNotification);
187 TBool IsActive() const;
188 CUpdateReceiverNotification* UpdateReceiverNotification(TInt aReceiverPriority = 0);
189 void CheckForReuse();
190 void SetNumUpdateReceivers(TInt aNumUpdateReceivers);
191 #ifdef TEST_SURFACE_UPDATE
192 CSurfaceUpdateServer* Server();
193 void IncNumberPendingNotifications();
197 TNotificationType iType;
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
200 CSurfaceUpdateSession *iSession; //doesn't own
201 TInt iNumUpdateReceivers;
202 TBool iCompleteWithSuccess;
203 TInt iHighestPriority; //attributed to successful notification
204 TUint32 iTimeStamp; //attributed to successful notification
208 Maintain the channel between clients and the server.
209 Functions are provided will respond appropriately to client messages.
211 class CSurfaceUpdateSession : public CSession2
214 CSurfaceUpdateSession(const RPointerArray<TUpdateReceiverPriorityEntry>& aReceiverEntryList);
215 ~CSurfaceUpdateSession();
216 void SubmitUpdate(const RMessage2& aMessage);
217 void NotifyWhenAvailable(const RMessage2& aMessage);
218 void NotifyWhenDisplayed(const RMessage2& aMessage);
219 void NotifyWhenDisplayedXTimes(const RMessage2& aMessage);
220 void CancelAllUpdateNotifications();
222 void DoSubmitUpdateL(const RMessage2& aMessage);
223 void StoreNotification(CUpdateReceiverNotificationBatch*& aNotifier, const RMessage2& aMessage, TNotificationType aType);
224 virtual void ServiceL(const RMessage2& aMessage);
225 void PanicClient(const RMessage2& aMessage, TInt aPanic) const;
226 CUpdateReceiverNotificationBatch* UpdateReceiverNotificationBatchL();
227 void IssueRequestComplete(TInt aErr);
228 void DispatchUpdate(const TSurfaceId& aSurfaceId, TInt aBuffer, RRegion* aRegion, TInt* aDisplayedXTimes, MCompositionSurfaceUpdate* aReceiver = NULL );
229 #ifdef TEST_SURFACE_UPDATE
230 void SetHeapFailure(const RMessage2& aMessage);
233 RPointerArray<CUpdateReceiverNotificationBatch> iUpdateReceiverNotificationBatches;
234 CUpdateReceiverNotificationBatch* iAvailable;
235 CUpdateReceiverNotificationBatch* iDisplayed;
236 CUpdateReceiverNotificationBatch* iDisplayedXTimes;
237 const RPointerArray<TUpdateReceiverPriorityEntry>& iUpdateReceiverEntryList; //doesn't own
241 EUpdateMethodPerScreen,
246 inline const RPointerArray<TUpdateReceiverPriorityEntry>& CSurfaceUpdateServer::UpdateReceiverPriority() const
248 return iUpdateReceiverPriorityOrder;