sl@0
|
1 |
// Copyright (c) 1995-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 |
#ifndef OPENWFCJOBMANAGER_H_
|
sl@0
|
17 |
#define OPENWFCJOBMANAGER_H_
|
sl@0
|
18 |
|
sl@0
|
19 |
#include <e32std.h>
|
sl@0
|
20 |
#include <e32base.h>
|
sl@0
|
21 |
#include <e32debug.h>
|
sl@0
|
22 |
|
sl@0
|
23 |
#include <EGL/egl.h>
|
sl@0
|
24 |
#include <graphics/eglsynchelper.h>
|
sl@0
|
25 |
#include <WF/wfc.h>
|
sl@0
|
26 |
|
sl@0
|
27 |
class COpenWfcWrapper;
|
sl@0
|
28 |
class COpenWfcMonitorThread;
|
sl@0
|
29 |
class TOpenWfcJob;
|
sl@0
|
30 |
|
sl@0
|
31 |
#if defined(ENABLE_JQ_LOGGING)
|
sl@0
|
32 |
#define JQLOG(X) RDebug::Printf X
|
sl@0
|
33 |
#else
|
sl@0
|
34 |
#define JQLOG(X)
|
sl@0
|
35 |
#endif
|
sl@0
|
36 |
|
sl@0
|
37 |
/**
|
sl@0
|
38 |
* Controls the OpenWF composition
|
sl@0
|
39 |
*/
|
sl@0
|
40 |
class COpenWfcJobManger : public CBase
|
sl@0
|
41 |
{
|
sl@0
|
42 |
private:
|
sl@0
|
43 |
|
sl@0
|
44 |
enum EOpenWfcJobId
|
sl@0
|
45 |
{
|
sl@0
|
46 |
EOpenWfcInvalidJobId = 0,
|
sl@0
|
47 |
EOpenWfcComposeJobId,
|
sl@0
|
48 |
EOpenWfcPauseCompositionJobId,
|
sl@0
|
49 |
EOpenWfcResumeCompositionJobId,
|
sl@0
|
50 |
};
|
sl@0
|
51 |
|
sl@0
|
52 |
/**
|
sl@0
|
53 |
* Stores the parameters associated with a composition
|
sl@0
|
54 |
*/
|
sl@0
|
55 |
struct TComposeRequestDetails
|
sl@0
|
56 |
{
|
sl@0
|
57 |
TComposeRequestDetails();
|
sl@0
|
58 |
void Set(TRequestStatus* aCommitRequest, TThreadId aCallingThread);
|
sl@0
|
59 |
void Reset();
|
sl@0
|
60 |
TRequestStatus* iCommitRequest;
|
sl@0
|
61 |
TThreadId iCallingThread;
|
sl@0
|
62 |
TDblQueLink iDlink;
|
sl@0
|
63 |
};
|
sl@0
|
64 |
|
sl@0
|
65 |
/**
|
sl@0
|
66 |
* Auxilliary class to insure the release of a lock
|
sl@0
|
67 |
*/
|
sl@0
|
68 |
class Guard
|
sl@0
|
69 |
{
|
sl@0
|
70 |
public:
|
sl@0
|
71 |
Guard(RMutex& aLock);
|
sl@0
|
72 |
~Guard();
|
sl@0
|
73 |
private:
|
sl@0
|
74 |
RMutex& iLock;
|
sl@0
|
75 |
};
|
sl@0
|
76 |
|
sl@0
|
77 |
public:
|
sl@0
|
78 |
/**
|
sl@0
|
79 |
* Two-phased constructor.
|
sl@0
|
80 |
*/
|
sl@0
|
81 |
static COpenWfcJobManger* NewL(COpenWfcWrapper& aOpenWfcWrapper,
|
sl@0
|
82 |
WFCDevice aDevice,
|
sl@0
|
83 |
WFCContext aContext,
|
sl@0
|
84 |
TInt aManagerId);
|
sl@0
|
85 |
|
sl@0
|
86 |
/**
|
sl@0
|
87 |
* Two-phased constructor.
|
sl@0
|
88 |
*/
|
sl@0
|
89 |
static COpenWfcJobManger* NewLC(COpenWfcWrapper& aOpenWfcWrapper,
|
sl@0
|
90 |
WFCDevice aDevice,
|
sl@0
|
91 |
WFCContext aContext,
|
sl@0
|
92 |
TInt aManagerId);
|
sl@0
|
93 |
/**
|
sl@0
|
94 |
* Destructor.
|
sl@0
|
95 |
*/
|
sl@0
|
96 |
virtual ~COpenWfcJobManger();
|
sl@0
|
97 |
|
sl@0
|
98 |
/**
|
sl@0
|
99 |
* Request to compose the specified scene
|
sl@0
|
100 |
*
|
sl@0
|
101 |
* @param aCompleted The notification to be returned when the composition completes
|
sl@0
|
102 |
* @param aUpdatePolicy Update policy to be used
|
sl@0
|
103 |
* @param the Pointer to the first element from the element list containing the scene to be used by the next commit
|
sl@0
|
104 |
*
|
sl@0
|
105 |
*/
|
sl@0
|
106 |
void ComposeRequest(TRequestStatus* aCompleted);
|
sl@0
|
107 |
|
sl@0
|
108 |
/**
|
sl@0
|
109 |
* Request to pause the composition
|
sl@0
|
110 |
*/
|
sl@0
|
111 |
void CompositionPauseRequest();
|
sl@0
|
112 |
/**
|
sl@0
|
113 |
* Request to resume the composition
|
sl@0
|
114 |
*/
|
sl@0
|
115 |
void CompositionResumeRequest();
|
sl@0
|
116 |
|
sl@0
|
117 |
/**
|
sl@0
|
118 |
* Appends to the compose details list the first detail object from the compose detail list
|
sl@0
|
119 |
*
|
sl@0
|
120 |
* @return NULL if the compose detail pool is empty or a pointer to the appended detail object
|
sl@0
|
121 |
*/
|
sl@0
|
122 |
TComposeRequestDetails* AppendDetailsFromPool();
|
sl@0
|
123 |
|
sl@0
|
124 |
/**
|
sl@0
|
125 |
* Executes an outstanding command, if any.
|
sl@0
|
126 |
*
|
sl@0
|
127 |
*/
|
sl@0
|
128 |
void DoExecuteJob();
|
sl@0
|
129 |
|
sl@0
|
130 |
private:
|
sl@0
|
131 |
/**
|
sl@0
|
132 |
* Executes a compose request.
|
sl@0
|
133 |
* Intended to be invoked by a job
|
sl@0
|
134 |
*
|
sl@0
|
135 |
* @param Reference to the invoking job
|
sl@0
|
136 |
*/
|
sl@0
|
137 |
void DoComposeJob();
|
sl@0
|
138 |
|
sl@0
|
139 |
/**
|
sl@0
|
140 |
* Executes a pause composition request
|
sl@0
|
141 |
* Intended to be invoked by a job
|
sl@0
|
142 |
*
|
sl@0
|
143 |
* @param Reference to the invoking job
|
sl@0
|
144 |
*/
|
sl@0
|
145 |
void DoPauseCompositionJob();
|
sl@0
|
146 |
|
sl@0
|
147 |
/**
|
sl@0
|
148 |
* Executes a resume composition request.
|
sl@0
|
149 |
* Intended to be invoked by a job
|
sl@0
|
150 |
*
|
sl@0
|
151 |
* @param Reference to the invoking job
|
sl@0
|
152 |
*/
|
sl@0
|
153 |
void DoResumeCompositionJob();
|
sl@0
|
154 |
|
sl@0
|
155 |
/**
|
sl@0
|
156 |
* Private constructor
|
sl@0
|
157 |
*/
|
sl@0
|
158 |
COpenWfcJobManger(COpenWfcWrapper& aOpenWfcWrapper,
|
sl@0
|
159 |
WFCDevice aDevice,
|
sl@0
|
160 |
WFCContext aContext,
|
sl@0
|
161 |
TInt aManagerId);
|
sl@0
|
162 |
|
sl@0
|
163 |
/**
|
sl@0
|
164 |
* Symbian constructor used with the two stage construction pattern
|
sl@0
|
165 |
*/
|
sl@0
|
166 |
void ConstructL();
|
sl@0
|
167 |
|
sl@0
|
168 |
/**
|
sl@0
|
169 |
* Implements a fence operation
|
sl@0
|
170 |
*/
|
sl@0
|
171 |
void Fence();
|
sl@0
|
172 |
|
sl@0
|
173 |
/**
|
sl@0
|
174 |
* Waits until the sync is signalled
|
sl@0
|
175 |
*/
|
sl@0
|
176 |
void WaitForSync();
|
sl@0
|
177 |
|
sl@0
|
178 |
/**
|
sl@0
|
179 |
* Activates the composition on the current context
|
sl@0
|
180 |
*/
|
sl@0
|
181 |
void Activate();
|
sl@0
|
182 |
|
sl@0
|
183 |
/**
|
sl@0
|
184 |
* Deactivates the composition on the current context
|
sl@0
|
185 |
*/
|
sl@0
|
186 |
void Deactivate();
|
sl@0
|
187 |
|
sl@0
|
188 |
/**
|
sl@0
|
189 |
* Execute a composition on the current context
|
sl@0
|
190 |
*/
|
sl@0
|
191 |
void Compose();
|
sl@0
|
192 |
|
sl@0
|
193 |
/**
|
sl@0
|
194 |
* Execute a commit on the current context
|
sl@0
|
195 |
*/
|
sl@0
|
196 |
void Commit();
|
sl@0
|
197 |
|
sl@0
|
198 |
/**
|
sl@0
|
199 |
* Completes all the outstanding requests stored locally
|
sl@0
|
200 |
*/
|
sl@0
|
201 |
void CompleteComposeRequests(TInt aResult);
|
sl@0
|
202 |
|
sl@0
|
203 |
/**
|
sl@0
|
204 |
* Completes all the outstanding pause/resumerequests requests
|
sl@0
|
205 |
*/
|
sl@0
|
206 |
void CompletePauseResumeRequest(TInt aResult);
|
sl@0
|
207 |
|
sl@0
|
208 |
private:
|
sl@0
|
209 |
//
|
sl@0
|
210 |
TDblQue<TComposeRequestDetails> iComposeDetailsPool;
|
sl@0
|
211 |
TDblQueIter<TComposeRequestDetails> iComposeDetailsPoolIter;
|
sl@0
|
212 |
TDblQue<TComposeRequestDetails> iComposeDetailsList;
|
sl@0
|
213 |
TDblQueIter<TComposeRequestDetails> iComposeDetailsListIter;
|
sl@0
|
214 |
RMutex iJobLock;
|
sl@0
|
215 |
RMutex iCommandLock;
|
sl@0
|
216 |
COpenWfcWrapper& iOpenWfcWrapper;
|
sl@0
|
217 |
WFCDevice iDevice;
|
sl@0
|
218 |
WFCContext iContext;
|
sl@0
|
219 |
volatile TBool iCompositionPaused;
|
sl@0
|
220 |
volatile TBool iPausedComposePending;
|
sl@0
|
221 |
COpenWfcMonitorThread* iThreadManager;
|
sl@0
|
222 |
TInt iManagerId;
|
sl@0
|
223 |
EGLSyncKHR iSync;
|
sl@0
|
224 |
EGLDisplay iEglDisplay;
|
sl@0
|
225 |
TRequestStatus iPauseResumeRequestStatus;
|
sl@0
|
226 |
TThreadId iPauseResumeThread;
|
sl@0
|
227 |
EOpenWfcJobId iOutstandingJob;
|
sl@0
|
228 |
static const TInt KComposeDetailsPoolSize = 16;
|
sl@0
|
229 |
};
|
sl@0
|
230 |
|
sl@0
|
231 |
inline void COpenWfcJobManger::Fence()
|
sl@0
|
232 |
{
|
sl@0
|
233 |
wfcFence(iDevice, iContext, iEglDisplay, iSync);
|
sl@0
|
234 |
}
|
sl@0
|
235 |
|
sl@0
|
236 |
inline void COpenWfcJobManger::WaitForSync()
|
sl@0
|
237 |
{
|
sl@0
|
238 |
EGLTimeKHR timeout = (EGLTimeKHR) EGL_FOREVER_KHR;
|
sl@0
|
239 |
eglClientWaitSyncKHR(iEglDisplay, iSync, 0, timeout);
|
sl@0
|
240 |
}
|
sl@0
|
241 |
|
sl@0
|
242 |
inline void COpenWfcJobManger::Activate()
|
sl@0
|
243 |
{
|
sl@0
|
244 |
wfcActivate(iDevice, iContext);
|
sl@0
|
245 |
}
|
sl@0
|
246 |
|
sl@0
|
247 |
inline void COpenWfcJobManger::Deactivate()
|
sl@0
|
248 |
{
|
sl@0
|
249 |
wfcDeactivate(iDevice, iContext);
|
sl@0
|
250 |
}
|
sl@0
|
251 |
|
sl@0
|
252 |
inline void COpenWfcJobManger::Compose()
|
sl@0
|
253 |
{
|
sl@0
|
254 |
wfcCompose(iDevice, iContext, WFC_TRUE);
|
sl@0
|
255 |
}
|
sl@0
|
256 |
|
sl@0
|
257 |
inline void COpenWfcJobManger::Commit()
|
sl@0
|
258 |
{
|
sl@0
|
259 |
wfcCommit(iDevice, iContext, WFC_TRUE);
|
sl@0
|
260 |
}
|
sl@0
|
261 |
|
sl@0
|
262 |
#endif /* OPENWFCJOBMANAGER_H_ */
|