author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 15 Sep 2010 12:05:25 +0300 | |
branch | RCL_3 |
changeset 77 | 7cee158cb8cd |
parent 66 | 2455ef1f5bbc |
child 83 | 26b2b12093af |
permissions | -rw-r--r-- |
66 | 1 |
/* |
2 |
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
#include <coemain.h> |
|
19 |
#include <eikenv.h> |
|
20 |
#include <hal.h> |
|
21 |
#include "CMIDEnv.h" |
|
22 |
#include "CMIDToolkit.h" |
|
23 |
#include "CMIDNotify.h" |
|
24 |
#include "CMIDKeyTranslator.h" |
|
25 |
#include "CMIDToLcduiObserver.h" |
|
26 |
||
27 |
#ifdef RD_JAVA_NGA_ENABLED |
|
28 |
#include <EGL/egl.h> |
|
29 |
#include <GLES/gl.h> |
|
30 |
#include <libc/string.h> |
|
31 |
#endif // RD_JAVA_NGA_ENABLED |
|
32 |
||
33 |
const TUint16 KCharComma = ','; |
|
34 |
||
35 |
CMIDEnv::CMIDEnv(CMIDToolkit* aToolkit, const TSize& aSize) |
|
36 |
: iToolkit(aToolkit) |
|
37 |
, iObservers(EGranularity) |
|
38 |
, iCanvasAssumedSize(aSize) |
|
39 |
, iToLcduiObserver(NULL) |
|
40 |
#ifdef RD_JAVA_NGA_ENABLED |
|
41 |
, iHardwareStatus(0) |
|
42 |
#endif |
|
43 |
{ |
|
44 |
iCanvasData.iLock.CreateLocal(); |
|
45 |
} |
|
46 |
||
47 |
void CMIDEnv::ConstructL() |
|
48 |
{ |
|
49 |
iKeyTranslator = new(ELeave) CMIDKeyTranslator(*this); |
|
50 |
iKeyTranslator->ConstructL(); |
|
51 |
iToLcduiObserver = new(ELeave) CMIDToLcduiObserver(); |
|
52 |
||
53 |
// On a non-full-screen (normal) mode Canvas the background image must be initially shown, |
|
54 |
// if the value of the Nokia-UI-Enhancement attribute is "CanvasHasBackground". The |
|
55 |
// attribute may be placed in the JAD or the manifest. |
|
56 |
iCanvasData.iHasBackground = MidletAttributeContainsVal( |
|
57 |
LcduiMidletAttributes::KAttribUIEnhancement, |
|
58 |
LcduiMidletAttributeValues::KUIEnhCanvasBackground); |
|
59 |
#ifdef RD_JAVA_NGA_ENABLED |
|
60 |
InitHardwareStatusL(); |
|
77
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
61 |
|
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
62 |
iVideoOverlayEnabled = MidletAttributeContainsVal( |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
63 |
LcduiMidletAttributes::KAttribUIEnhancement, |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
64 |
LcduiMidletAttributeValues::KUIEnhVideoOverlay); |
66 | 65 |
#endif // RD_JAVA_NGA_ENABLED |
77
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
66 |
|
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
67 |
iMMAPILock.CreateLocal(); |
66 | 68 |
} |
69 |
||
70 |
CMIDEnv::~CMIDEnv() |
|
71 |
{ |
|
72 |
if (iToLcduiObserver) |
|
73 |
{ |
|
74 |
delete iToLcduiObserver; |
|
75 |
iToLcduiObserver = NULL; |
|
76 |
} |
|
77 |
delete iKeyTranslator; |
|
78 |
iObservers.Close(); |
|
79 |
iCanvasData.iLock.Close(); |
|
77
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
80 |
iMMAPILock.Close(); |
66 | 81 |
} |
82 |
||
83 |
void CMIDEnv::SetUtils(MMIDUtils* aUtils) |
|
84 |
{ |
|
85 |
iKeyTranslator->SetUtils(aUtils); |
|
86 |
} |
|
87 |
||
88 |
TPtrC CMIDEnv::MidletName() const |
|
89 |
{ |
|
90 |
return iToolkit->MidletName(); |
|
91 |
} |
|
92 |
||
93 |
TUid CMIDEnv::MidletUid() const |
|
94 |
{ |
|
95 |
return iToolkit->MidletUid(); |
|
96 |
} |
|
97 |
||
98 |
TPtrC CMIDEnv::MidletHome() const |
|
99 |
{ |
|
100 |
return iToolkit->MidletHome(); |
|
101 |
} |
|
102 |
||
103 |
#ifdef RD_SCALABLE_UI_V2 |
|
104 |
TUid CMIDEnv::MidletSuiteUid() |
|
105 |
{ |
|
106 |
if (!iMidletSuiteUid.iUid) |
|
107 |
{ |
|
108 |
//Midlet suite uid is located inside brackets in the midlet home path. |
|
109 |
const TChar KUidStart = '['; |
|
110 |
const TChar KUidEnd = ']'; |
|
111 |
||
112 |
const TPtrC midletHome = MidletHome(); |
|
113 |
||
114 |
//Finding start and end positions |
|
115 |
TInt startPos = midletHome.Locate(KUidStart) + 1; |
|
116 |
TInt endPos = midletHome.LocateReverse(KUidEnd); |
|
117 |
||
118 |
if (startPos != KErrNotFound && endPos != KErrNotFound && |
|
119 |
startPos < endPos && endPos <= midletHome.Length()) |
|
120 |
{ |
|
121 |
//Creating new pointer descriptor representing the midlet suite uid |
|
122 |
const TPtrC uidDesc = midletHome.Mid(startPos, endPos - startPos); |
|
123 |
||
124 |
if (uidDesc.Length()) |
|
125 |
{ |
|
126 |
//Creating unsigned integer out of the hex string. |
|
127 |
TUint uint; |
|
128 |
TLex lexer(uidDesc); |
|
129 |
TInt err = lexer.Val(uint, EHex); |
|
130 |
||
131 |
if (err == KErrNone) |
|
132 |
{ |
|
133 |
iMidletSuiteUid = TUid::Uid(uint); |
|
134 |
} |
|
135 |
else |
|
136 |
{ |
|
137 |
iMidletSuiteUid = TUid::Uid(KNullUidValue); |
|
138 |
} |
|
139 |
} |
|
140 |
else |
|
141 |
{ |
|
142 |
iMidletSuiteUid = TUid::Uid(KNullUidValue); |
|
143 |
} |
|
144 |
} |
|
145 |
else |
|
146 |
{ |
|
147 |
iMidletSuiteUid = TUid::Uid(KNullUidValue); |
|
148 |
} |
|
149 |
} |
|
150 |
return iMidletSuiteUid; |
|
151 |
} |
|
152 |
#endif // RD_SCALABLE_UI_V2 |
|
153 |
||
154 |
||
155 |
TBool CMIDEnv::PostJavaEvent |
|
156 |
( |
|
157 |
MMIDComponent& aSource, |
|
158 |
TSourceType aSourceType, |
|
159 |
TEventType aEventType, |
|
160 |
TInt aEventData, |
|
161 |
TInt aEventData1, |
|
162 |
TInt aEventData2 |
|
163 |
) |
|
164 |
{ |
|
165 |
#ifdef TRACE_EVENTS |
|
166 |
RDebug::Print(_L("CMIDEnv::PostJavaEvent(%x,%d,%d,%d,%d,%d)"), |
|
167 |
aSource, |
|
168 |
aSourceType, |
|
169 |
aEventType, |
|
170 |
aEventData,aEventData1, aEventData2); |
|
171 |
#endif |
|
172 |
switch (aSourceType) |
|
173 |
{ |
|
174 |
case EItem: |
|
175 |
return iToolkit->PostItemEvent(aSource, aEventType, aEventData, aEventData1, aEventData2); |
|
176 |
case EDisplayable: |
|
177 |
return iToolkit->PostDisplayableEvent(aSource, aEventType, aEventData, aEventData1); |
|
178 |
case ECanvasGraphicsItemPainterEvent: |
|
179 |
return iToolkit->PostCanvasGraphicsItemPainterEvent(aSource, aEventType, aEventData, aEventData1); |
|
180 |
default: |
|
181 |
ASSERT(EFalse); |
|
182 |
} |
|
183 |
return EFalse; |
|
184 |
} |
|
185 |
||
186 |
TBool CMIDEnv::PostJavaEvent(MMIDComponent& aSource,TSourceType aSourceType,TEventType aEventType,TInt aEventData) |
|
187 |
{ |
|
188 |
return PostJavaEvent(aSource, aSourceType, aEventType, aEventData, 0, 0); |
|
189 |
} |
|
190 |
||
191 |
TBool CMIDEnv::PostJavaEvent(MMIDComponent& aSource,TSourceType aSourceType,TInt aEventData) |
|
192 |
{ |
|
193 |
return PostJavaEvent(aSource, aSourceType, ENoType, aEventData, 0, 0); |
|
194 |
} |
|
195 |
||
196 |
TBool CMIDEnv::PostMidletEvent(TEventType aEventType) |
|
197 |
{ |
|
198 |
return iToolkit->PostDisplayEvent(aEventType); |
|
199 |
} |
|
200 |
||
201 |
MMIDNotifyEvent* CMIDEnv::NewNotifyL(MMIDComponent& aSource) |
|
202 |
{ |
|
203 |
return new(ELeave) CMIDNotifyEvent(iToolkit->ComponentPeer(aSource)); |
|
204 |
} |
|
205 |
||
206 |
TBool CMIDEnv::PostJavaNotify(MMIDNotifyEvent* aNotifyEvent) |
|
207 |
{ |
|
208 |
CMIDNotifyEvent* notify = static_cast<CMIDNotifyEvent*>(aNotifyEvent); |
|
209 |
return iToolkit->PostEvent(notify, CJavaEventBase::ENotifyPriority); |
|
210 |
} |
|
211 |
||
212 |
TBool CMIDEnv::TranslateKeyL(TMIDKeyEvent& aEvent, const TKeyEvent& aWsEvent, TEventCode aType) |
|
213 |
{ |
|
214 |
return iKeyTranslator->TranslateL(aEvent, aWsEvent, aType); |
|
215 |
} |
|
216 |
||
217 |
TBool CMIDEnv::PostKeyEvent(MMIDComponent& aSource, TMIDKeyEvent& aEvent) |
|
218 |
{ |
|
219 |
return iKeyTranslator->PostKeyEvent(aSource, aEvent); |
|
220 |
} |
|
221 |
||
222 |
void CMIDEnv::ResetKeys() |
|
223 |
{ |
|
224 |
iKeyTranslator->Reset(); |
|
225 |
} |
|
226 |
||
227 |
MMIDDisplayable* CMIDEnv::Current() |
|
228 |
{ |
|
229 |
return iToolkit->Current(); |
|
230 |
} |
|
231 |
||
232 |
/** |
|
233 |
* Set the zoom size which may be queried by Canvas in the |
|
234 |
* plugin. This is a relic from when Canvas was implemented |
|
235 |
* in the framework. Should be deprecated. |
|
236 |
*/ |
|
237 |
void CMIDEnv::SetCanvasZoomSize(const TSize& aSize) |
|
238 |
{ |
|
239 |
iCanvasZoomSize=aSize; |
|
240 |
} |
|
241 |
||
242 |
/** |
|
243 |
* Get the zoom size - used by the Canvas in the plugin. |
|
244 |
* Relic from when Canvas was implementd in the framework. |
|
245 |
* Should be deprecated. |
|
246 |
*/ |
|
247 |
TSize CMIDEnv::CanvasZoomSize() |
|
248 |
{ |
|
249 |
return iCanvasZoomSize; |
|
250 |
} |
|
251 |
||
252 |
TSize CMIDEnv::CanvasAssumedSize() |
|
253 |
{ |
|
254 |
return iCanvasAssumedSize; |
|
255 |
} |
|
256 |
||
257 |
TInt CMIDEnv::NumColors() |
|
258 |
{ |
|
259 |
TDisplayMode mode = DisplayMode(); |
|
260 |
return TDisplayModeUtils::NumDisplayModeColors(mode); |
|
261 |
} |
|
262 |
||
263 |
TDisplayMode CMIDEnv::DisplayMode() |
|
264 |
{ |
|
265 |
MMIDGraphicsFactory& factory = iToolkit->GraphicsFactory(); |
|
266 |
return factory.DisplayMode(); |
|
267 |
} |
|
268 |
||
269 |
void CMIDEnv::AddObserverL(MMIDEnvObserver& aObserver) |
|
270 |
{ |
|
271 |
ASSERT(iObservers.Find(&aObserver) == KErrNotFound); |
|
272 |
// |
|
273 |
User::LeaveIfError(iObservers.Append(&aObserver)); |
|
274 |
} |
|
275 |
||
276 |
void CMIDEnv::RemoveObserver(MMIDEnvObserver& aObserver) |
|
277 |
{ |
|
278 |
TInt index = iObservers.Find(&aObserver); |
|
279 |
if (index != KErrNotFound) |
|
280 |
{ |
|
281 |
iObservers.Remove(index); |
|
282 |
} |
|
283 |
} |
|
284 |
||
285 |
void CMIDEnv::HandleSwitchOnL(TBool aSwitchOn) |
|
286 |
{ |
|
287 |
for (TInt i = iObservers.Count(); i--;) |
|
288 |
iObservers[i]->HandleSwitchOnL(aSwitchOn); |
|
289 |
} |
|
290 |
||
291 |
void CMIDEnv::HandleForegroundL(TBool aForeground) |
|
292 |
{ |
|
293 |
#ifdef RD_JAVA_NGA_ENABLED |
|
294 |
if (aForeground) |
|
295 |
{ |
|
296 |
iFullOrPartialFg = ETrue; |
|
297 |
} |
|
298 |
#endif // RD_JAVA_NGA_ENABLED |
|
299 |
||
300 |
for (TInt i = iObservers.Count(); i--;) |
|
301 |
{ |
|
302 |
iObservers[i]->HandleForegroundL(aForeground); |
|
303 |
} |
|
304 |
if (aForeground && iToolkit && iToolkit->Utils()) |
|
305 |
{ |
|
306 |
iToolkit->Utils()->HandleForegroundL(aForeground); |
|
307 |
} |
|
308 |
} |
|
309 |
||
310 |
void CMIDEnv::HandleResourceChangeL(TInt aType) |
|
311 |
{ |
|
312 |
for (TInt i = iObservers.Count(); i--;) |
|
313 |
{ |
|
314 |
iObservers[i]->HandleResourceChangeL(aType); |
|
315 |
} |
|
316 |
if (iToolkit && iToolkit->Utils()) |
|
317 |
{ |
|
318 |
iToolkit->Utils()->HandleResourceChangedL(); |
|
319 |
} |
|
320 |
} |
|
321 |
||
77
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
322 |
TBool CMIDEnv::VideoOverlayEnabled() const |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
323 |
{ |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
324 |
return iVideoOverlayEnabled; |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
325 |
} |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
326 |
|
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
327 |
RCriticalSection& CMIDEnv::GetMMAPILock() |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
328 |
{ |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
329 |
return iMMAPILock; |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
330 |
} |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
331 |
|
66 | 332 |
#ifdef RD_JAVA_NGA_ENABLED |
333 |
void CMIDEnv::HandleFullOrPartialForegroundL(TBool aForeground) |
|
334 |
{ |
|
335 |
iFullOrPartialFg = aForeground; |
|
336 |
for (TInt i = iObservers.Count(); i--;) |
|
337 |
{ |
|
338 |
iObservers[i]->HandleFullOrPartialForegroundL(aForeground); |
|
339 |
} |
|
340 |
} |
|
341 |
||
342 |
void CMIDEnv::HandleFreeGraphicsMemory() |
|
343 |
{ |
|
344 |
for (TInt i = iObservers.Count(); i--;) |
|
345 |
{ |
|
346 |
iObservers[i]->HandleFreeGraphicsMemory(); |
|
347 |
} |
|
348 |
} |
|
349 |
||
350 |
TBool CMIDEnv::HasFullOrPartialForeground() const |
|
351 |
{ |
|
352 |
return iFullOrPartialFg; |
|
353 |
} |
|
354 |
#endif //RD_JAVA_NGA_ENABLED |
|
355 |
||
356 |
TInt CMIDEnv::MidletAttribute(const TDesC& aAttributeName, TPtrC& aAttributeValue) |
|
357 |
{ |
|
358 |
return iToolkit->MidletAttribute(aAttributeName,aAttributeValue); |
|
359 |
} |
|
360 |
||
361 |
TBool CMIDEnv::MidletAttributeIsSetToVal(const TDesC& aAttributeName, |
|
362 |
const TDesC& aAttributeValue) |
|
363 |
{ |
|
364 |
TPtrC attributeValue; |
|
365 |
||
366 |
if (MidletAttribute(aAttributeName, attributeValue) == KErrNone && |
|
367 |
attributeValue.CompareF(aAttributeValue) == 0) |
|
368 |
{ |
|
369 |
return ETrue; |
|
370 |
} |
|
371 |
else |
|
372 |
{ |
|
373 |
return EFalse; |
|
374 |
} |
|
375 |
} |
|
376 |
||
377 |
TBool CMIDEnv::MidletAttributeContainsVal(const TDesC& aAttributeName, |
|
378 |
const TDesC& aAttributeValue) |
|
379 |
{ |
|
380 |
TPtrC attributeValue; |
|
381 |
||
382 |
if (MidletAttribute(aAttributeName, attributeValue) == KErrNone) |
|
383 |
{ |
|
384 |
TInt startIdx = attributeValue.FindF(aAttributeValue); |
|
385 |
if (startIdx != KErrNotFound) |
|
386 |
{ |
|
387 |
if (aAttributeName.FindF(LcduiMidletAttributes::KAttribUIEnhancement) == KErrNotFound) |
|
388 |
{ |
|
389 |
// If there is a preceding character before the value substring, it must be a comma |
|
390 |
if (startIdx == 0 || attributeValue[ startIdx - 1 ] == KCharComma) |
|
391 |
{ |
|
392 |
// Check what comes after the found value substring. |
|
393 |
TInt endIdx = startIdx + aAttributeValue.Length(); |
|
394 |
if (endIdx < attributeValue.Length()) |
|
395 |
{ |
|
396 |
// only comma is ok |
|
397 |
if (attributeValue[ endIdx ] == KCharComma) |
|
398 |
{ |
|
399 |
return ETrue; |
|
400 |
} |
|
401 |
} |
|
402 |
} |
|
403 |
else // the found substring was right at the end of attributeValue string |
|
404 |
{ |
|
405 |
return ETrue; |
|
406 |
} |
|
407 |
} |
|
408 |
else // it is "Nokia-UI-Enhancement" - it is enough just to identify the substring in list of values |
|
409 |
{ |
|
410 |
return ETrue; |
|
411 |
} |
|
412 |
} |
|
413 |
} |
|
414 |
||
415 |
return EFalse; |
|
416 |
} |
|
417 |
||
418 |
void CMIDEnv::SetCanvasAssumedSize(const TSize& aSize) |
|
419 |
{ |
|
420 |
iCanvasAssumedSize = aSize; |
|
421 |
} |
|
422 |
CFbsBitmap* CMIDEnv::ReserveCanvasFrameBufferL(MMIDCanvas& aCanvas, const TSize& aSz) |
|
423 |
{ |
|
424 |
CMIDEnv::TMutexAutoLock lock(&iCanvasData.iLock); |
|
425 |
if (!aCanvas.IsGameCanvas()) |
|
426 |
{ |
|
427 |
if (!iCanvasData.iFrameBuffer) |
|
428 |
{ |
|
429 |
iCanvasData.iFrameBuffer = CreateCanvasFrameBufferL(aCanvas, ETrue, aSz); |
|
430 |
} |
|
431 |
iCanvasData.iRefCount++; |
|
432 |
return iCanvasData.iFrameBuffer; |
|
433 |
} |
|
434 |
return CreateCanvasFrameBufferL(aCanvas, ETrue, aSz); |
|
435 |
} |
|
436 |
||
437 |
void CMIDEnv::ReleaseCanvasFrameBuffer(MMIDCanvas& aCanvas, CFbsBitmap*& aFrameBuffer) |
|
438 |
{ |
|
439 |
CMIDEnv::TMutexAutoLock lock(&iCanvasData.iLock); |
|
440 |
if (!aCanvas.IsGameCanvas()) |
|
441 |
{ |
|
442 |
if (iCanvasData.iFrameBuffer) |
|
443 |
{ |
|
444 |
iCanvasData.iRefCount--; |
|
445 |
if (iCanvasData.iRefCount <= 0) |
|
446 |
{ |
|
447 |
iCanvasData.Reset(); |
|
448 |
} |
|
449 |
} |
|
450 |
} |
|
451 |
else |
|
452 |
{ |
|
453 |
delete aFrameBuffer; |
|
454 |
aFrameBuffer = NULL; |
|
455 |
} |
|
456 |
} |
|
457 |
||
458 |
CFbsBitmap* CMIDEnv::CreateCanvasFrameBufferL( |
|
459 |
MMIDCanvas& /* aCanvas */, TBool aWsBitmap, const TSize& aSz) |
|
460 |
{ |
|
461 |
CFbsBitmap* bitmap = new(ELeave) CFbsBitmap; |
|
462 |
CleanupStack::PushL(bitmap); |
|
463 |
TInt err = KErrGeneral; |
|
464 |
err = bitmap->CreateHardwareBitmap(aSz, DisplayMode(), MidletUid()); |
|
465 |
if (KErrNone != err) |
|
466 |
{ |
|
467 |
// Failed to create hardware bitmap. Fall back to normal software only bitmaps |
|
468 |
User::LeaveIfError(bitmap->Create(aSz, DisplayMode())); |
|
469 |
} |
|
470 |
if (!aWsBitmap) |
|
471 |
{ |
|
472 |
CleanupStack::Pop(); |
|
473 |
return bitmap; |
|
474 |
} |
|
475 |
CWsBitmap* wsBitmap = |
|
476 |
new(ELeave) CWsBitmap(CCoeEnv::Static()->WsSession()); |
|
477 |
err = wsBitmap->Duplicate(bitmap->Handle()); |
|
478 |
if (KErrNone != err) |
|
479 |
{ |
|
480 |
delete wsBitmap; |
|
481 |
User::Leave(err); |
|
482 |
} |
|
483 |
CleanupStack::PopAndDestroy(bitmap); |
|
484 |
return wsBitmap; |
|
485 |
} |
|
486 |
||
487 |
TBool CMIDEnv::CanvasHasBackground(const MMIDCanvas& /* aCanvas */) const |
|
488 |
{ |
|
489 |
return iCanvasData.iHasBackground; |
|
490 |
} |
|
491 |
||
492 |
#ifdef RD_JAVA_NGA_ENABLED |
|
493 |
// --------------------------------------------------------------------------- |
|
494 |
// |
|
495 |
// --------------------------------------------------------------------------- |
|
496 |
// |
|
497 |
TBool CMIDEnv::IsHardwareAcceleratedL(MMIDEnv::THardwareType aHardwareType) |
|
498 |
{ |
|
499 |
ASSERT(iHardwareStatus); |
|
500 |
return (iHardwareStatus & aHardwareType); |
|
501 |
} |
|
502 |
||
503 |
// --------------------------------------------------------------------------- |
|
504 |
// Checks from OpenGL ES API, if it is HW accelerated |
|
505 |
// --------------------------------------------------------------------------- |
|
506 |
// |
|
507 |
TInt CMIDEnv::InitHardwareStatusL() |
|
508 |
{ |
|
509 |
iHardwareStatus = 1; |
|
510 |
||
511 |
EGLDisplay eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); |
|
512 |
eglInitialize(eglDisplay, NULL, NULL); |
|
513 |
||
514 |
EGLConfig config; |
|
515 |
EGLint numOfConfigs = 0; |
|
516 |
// Choose suitable display config |
|
517 |
const EGLint attribs[] = |
|
518 |
{ |
|
519 |
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, |
|
520 |
EGL_BUFFER_SIZE, 32, |
|
521 |
EGL_DEPTH_SIZE, 16, |
|
522 |
EGL_NONE |
|
523 |
}; |
|
524 |
eglChooseConfig(eglDisplay, attribs, &config, 1, &numOfConfigs); |
|
525 |
// Create a surface |
|
526 |
const EGLint pBuffAttribs[] = |
|
527 |
{ |
|
528 |
EGL_WIDTH, 1, |
|
529 |
EGL_HEIGHT, 1, |
|
530 |
EGL_NONE |
|
531 |
}; |
|
532 |
EGLSurface surface = eglCreatePbufferSurface(eglDisplay, config, pBuffAttribs); |
|
533 |
// Create a context into this thread. |
|
534 |
EGLContext context = eglCreateContext(eglDisplay, config, EGL_NO_CONTEXT, NULL); |
|
535 |
// Try to bind surface to context |
|
536 |
if (context != EGL_NO_CONTEXT && surface != EGL_NO_SURFACE && |
|
537 |
eglMakeCurrent(eglDisplay, surface, surface, context)) |
|
538 |
{ |
|
539 |
if (strstr((const char *)glGetString(GL_RENDERER), "HW")) |
|
540 |
{ |
|
541 |
iHardwareStatus |= MMIDEnv::EHardware3D; |
|
542 |
} |
|
543 |
eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |
|
544 |
} |
|
545 |
||
546 |
if (context != EGL_NO_CONTEXT) |
|
547 |
{ |
|
548 |
eglDestroyContext(eglDisplay, context); |
|
549 |
} |
|
550 |
||
551 |
if (surface != EGL_NO_SURFACE) |
|
552 |
{ |
|
553 |
eglDestroySurface(eglDisplay, surface); |
|
554 |
} |
|
555 |
||
556 |
eglTerminate(eglDisplay); |
|
557 |
||
558 |
return iHardwareStatus; |
|
559 |
} |
|
560 |
||
561 |
#endif // RD_JAVA_NGA_ENABLED |
|
562 |
||
563 |
void CMIDEnv::MappingDataForKey(TKeyEvent& aEvent, TEventCode aType) |
|
564 |
{ |
|
565 |
iToolkit->Utils()->MappingDataForKey(aEvent, aType); |
|
566 |
} |
|
567 |
||
568 |
void CMIDEnv::SetLastKeyEvent(const TKeyEvent& aEvent) |
|
569 |
{ |
|
570 |
iToolkit->Utils()->SetLastKeyEvent(aEvent); |
|
571 |
} |
|
572 |
||
573 |
||
574 |
// --------------------------------------------------------------------------- |
|
575 |
// CMIDEnv::ToLcduiObserver |
|
576 |
// Gets an instance of ToLcduiObserver. |
|
577 |
// --------------------------------------------------------------------------- |
|
578 |
// |
|
579 |
MMIDToLcduiObserver& CMIDEnv::ToLcduiObserver() |
|
580 |
{ |
|
581 |
return *iToLcduiObserver; |
|
582 |
} |
|
583 |
||
584 |
void CMIDEnv::DisplayableIsDestructed(const MMIDDisplayable* aDisplayable) |
|
585 |
{ |
|
586 |
// Inform CMIDToolkit about deleting of displayble. This is needed |
|
587 |
// for prevereting of panic during changing to new Displayable |
|
588 |
iToolkit->DisplayableIsDestructed(aDisplayable); |
|
589 |
} |
|
590 |
||
591 |
const MMIDDisplayable* CMIDEnv::LastFullscreenDisplayable() const |
|
592 |
{ |
|
593 |
return iToolkit->LastFullscreenDisplayable(); |
|
594 |
} |