author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:23:59 +0300 | |
branch | RCL_3 |
changeset 83 | 26b2b12093af |
parent 77 | 7cee158cb8cd |
permissions | -rw-r--r-- |
66 | 1 |
/* |
2 |
* Copyright (c) 2003-2009 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: CMIDCanvas - Implements the native part of the Canvas class. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
// Using auto_ptr |
|
19 |
#include <memory> |
|
20 |
||
21 |
// API used for getting the layout for the network indicator bitmap and for |
|
22 |
// retrieving info if pen is enabled (in CMIDCanvas::HandlePointerEventL |
|
23 |
// function). |
|
24 |
#include <AknUtils.h> |
|
25 |
||
26 |
// Using Layout_Meta_Data::IsLandscapeOrientation() |
|
27 |
#include <layoutmetadata.cdl.h> |
|
28 |
||
29 |
||
30 |
// Using CRepository class used in CMIDCanvas::IsNetworkIndicatorEnabledL |
|
31 |
// function. |
|
32 |
#include <centralrepository.h> |
|
33 |
#ifdef RD_JAVA_NGA_ENABLED |
|
34 |
#include <logger.h> |
|
35 |
#include <e32cmn.h> |
|
36 |
#include <EGL/egl.h> |
|
37 |
#include <GLES/gl.h> |
|
38 |
#endif // RD_JAVA_NGA_ENABLED |
|
39 |
||
40 |
||
41 |
// Using debug macros. |
|
42 |
#include <j2me/jdebug.h> |
|
43 |
||
44 |
// OMJ storage |
|
45 |
#include <securitystoragedatadefs.h> |
|
46 |
#include <javastorageentry.h> |
|
47 |
#include <javastorage.h> |
|
48 |
#include <javastoragenames.h> |
|
49 |
#include <javauid.h> |
|
50 |
#include <javasymbianoslayer.h> |
|
51 |
#ifdef RD_JAVA_S60_RELEASE_9_2 |
|
52 |
// Used with partial VKB |
|
53 |
#include <AknPriv.hrh> |
|
54 |
#endif // RD_JAVA_S60_RELEASE_9_2 |
|
55 |
||
56 |
#include "javaoslayer.h" |
|
57 |
||
58 |
// Using constants for S60 LCDUI Plugin internal keys. |
|
59 |
#include "S60LCDUIInternalCRKeys.h" |
|
60 |
||
61 |
#include "CMIDCanvas.h" |
|
62 |
||
63 |
// Using CMIDUIManager for iKeyDecoder and iScaler initialization. |
|
64 |
#include "CMIDUIManager.h" |
|
65 |
||
66 |
// Using CMIDScaler as member iScaler. |
|
67 |
#include "CMIDScaler.h" |
|
68 |
||
69 |
// Using CMIDKeyDecoder as member iKeyDecoder. |
|
70 |
#include "CMIDKeyDecoder.h" |
|
71 |
||
72 |
// Using CMIDNetworkIndicator as member iNetworkIndicator. |
|
73 |
#include "CMIDNetworkIndicator.h" |
|
74 |
||
75 |
// Using CMIDCallIndicator as member iCallIndicator. |
|
76 |
#include "CMIDCallIndicator.h" |
|
77 |
||
78 |
// Using CMIDRemConObserver as memeber iRemConObserver. |
|
79 |
#include "CMIDRemConObserver.h" |
|
80 |
||
81 |
||
82 |
#ifdef RD_TACTILE_FEEDBACK |
|
83 |
// Using CMIDTactileFeedbackExtension as member iTactileFeedback. |
|
84 |
#include "CMIDTactileFeedbackExtension.h" |
|
85 |
#endif // RD_TACTILE_FEEDBACK |
|
86 |
||
87 |
#include "MMIDCustomComponent.h" |
|
88 |
||
89 |
// Using CoreUiAvkonLcdui for the splash screen |
|
90 |
#include "coreuiavkonlcdui.h" |
|
91 |
||
92 |
#ifdef DEFER_BITBLT |
|
93 |
const TInt KEstCyclesPerPixel = 32; |
|
94 |
#endif // DEFER_BITBLT |
|
95 |
||
96 |
const TInt KAllowedTimeBetweenDragEvents = 50000; // 50ms |
|
97 |
||
98 |
// Used with component controls |
|
99 |
const TInt KComponentMainControl = 0; |
|
100 |
const TInt KComponentFocusedNone = -1; |
|
101 |
||
102 |
// Using enumeration TFocusState. |
|
103 |
#include "MMIDTextEditor.h" |
|
104 |
||
105 |
#ifdef RD_JAVA_NGA_ENABLED |
|
106 |
// Max dimension for openGL texture, must be power of 2 |
|
107 |
const TInt KMaxBlitSize = 256; |
|
108 |
const TInt KTexturesCount = 1; |
|
109 |
const TInt KBytesPerPixel = 4; |
|
110 |
const TInt KPhoneScreen = 0; |
|
111 |
// The color that is used to clear the framebuffer when |
|
112 |
// mixing 3D & 2D rendering |
|
113 |
#define KTransparentClearColor TRgb(0x000000, 0x0) |
|
114 |
#define KOpaqueClearColor TRgb(0xFFFFFF, 0xFF) |
|
115 |
#define KOpaqueBlackColor TRgb(0x000000, 255) |
|
116 |
||
117 |
#ifdef _DEBUG |
|
118 |
#define ASSERT_GL() AssertGL() |
|
119 |
#else |
|
120 |
#define ASSERT_GL() |
|
121 |
#endif |
|
122 |
||
123 |
#endif // RD_JAVA_NGA_ENABLED |
|
124 |
||
125 |
#define KZeroSize TSize() |
|
126 |
||
127 |
// --------------------------------------------------------------------------- |
|
128 |
// TBitBltData |
|
129 |
// BitBlt buffer data datatype. |
|
130 |
// --------------------------------------------------------------------------- |
|
131 |
// |
|
132 |
struct TBitBltData |
|
133 |
{ |
|
134 |
TRect iRect; |
|
135 |
}; |
|
136 |
||
137 |
// --------------------------------------------------------------------------- |
|
138 |
// TLcduiEvent |
|
139 |
// --------------------------------------------------------------------------- |
|
140 |
// |
|
141 |
enum TLcduiEvent |
|
142 |
{ |
|
143 |
EFixUIOrientation, |
|
144 |
EUnFixUIOrientation, |
|
145 |
EVideoAdded |
|
146 |
}; |
|
147 |
||
148 |
// ======== LOCAL FUNCTIONS ======== |
|
149 |
||
150 |
// --------------------------------------------------------------------------- |
|
151 |
// BitBltData |
|
152 |
// Get BitBlt buffer data from buffered operation passed to buffer processor. |
|
153 |
// Used in CMIDCanvas::ProcessL function. |
|
154 |
// --------------------------------------------------------------------------- |
|
155 |
// |
|
156 |
inline const TBitBltData& BitBltData(const TMIDBufferOp* aOp) |
|
157 |
{ |
|
158 |
ASSERT(aOp->Size() >= TInt(1 + ( |
|
159 |
sizeof(TBitBltData) / sizeof(TMIDBufferOp)))); |
|
160 |
||
161 |
return *static_cast< const TBitBltData* >(aOp->Data()); |
|
162 |
} |
|
163 |
||
164 |
#ifdef RD_JAVA_NGA_ENABLED |
|
165 |
// --------------------------------------------------------------------------- |
|
166 |
// IsDownScaling |
|
167 |
// Check if downscaling in use. |
|
168 |
// @param aSourceSize Source rect size. |
|
169 |
// @param aDestRect Destination rect. |
|
170 |
// --------------------------------------------------------------------------- |
|
171 |
// |
|
172 |
TBool CMIDCanvas::IsDownScaling(const TSize& aSourceSize, const TRect& aDestRect,TBool aM3GContent) const |
|
173 |
{ |
|
174 |
// if m3G is drawing then downscaling is turn off |
|
175 |
// Send event in case of the M3G draw. |
|
176 |
if (iM3GContent != iPrevM3GContent) |
|
177 |
{ |
|
178 |
PostEvent(EM3GDraw, iM3GContent, 0); |
|
179 |
} |
|
180 |
iPrevM3GContent=iM3GContent; |
|
181 |
if (aM3GContent) |
|
182 |
{ |
|
183 |
return EFalse; |
|
184 |
} |
|
185 |
return (aSourceSize.iWidth > aDestRect.Width() || |
|
186 |
aSourceSize.iHeight > aDestRect.Height()); |
|
187 |
} |
|
188 |
#else |
|
189 |
// --------------------------------------------------------------------------- |
|
190 |
// IsDownScaling |
|
191 |
// Check if downscaling in use. |
|
192 |
// @param aSourceSize Source rect size. |
|
193 |
// @param aDestRect Destination rect. |
|
194 |
// --------------------------------------------------------------------------- |
|
195 |
TBool CMIDCanvas::IsDownScaling(const TSize& aSourceSize, const TRect& aDestRect) const |
|
196 |
{ |
|
197 |
return (aSourceSize.iWidth > aDestRect.Width() || |
|
198 |
aSourceSize.iHeight > aDestRect.Height()); |
|
199 |
} |
|
200 |
||
201 |
#endif //RD_JAVA_NGA_ENABLED |
|
202 |
// ======== MEMBER FUNCTIONS ======== |
|
203 |
||
204 |
// --------------------------------------------------------------------------- |
|
205 |
// CMIDCanvas::NewL |
|
206 |
// Two-phased constructor. Use this method to create a CMIDCanvas instance. |
|
207 |
// --------------------------------------------------------------------------- |
|
208 |
// |
|
209 |
CMIDCanvas* CMIDCanvas::NewL( |
|
210 |
MMIDEnv& aEnv, |
|
211 |
CCoeControl& aWindow, |
|
212 |
MMIDComponent::TType aComponentType, |
|
213 |
TBool aUpdateRequired) |
|
214 |
{ |
|
215 |
CMIDCanvas* self = new(ELeave) CMIDCanvas(aEnv, |
|
216 |
aComponentType, |
|
217 |
aUpdateRequired); |
|
218 |
||
219 |
CleanupStack::PushL(self); |
|
220 |
self->ConstructL(aWindow); |
|
221 |
CleanupStack::Pop(self); |
|
222 |
||
223 |
return self; |
|
224 |
} |
|
225 |
||
226 |
||
227 |
// --------------------------------------------------------------------------- |
|
228 |
// CMIDCanvas::~CMIDCanvas |
|
229 |
// Destructor. |
|
230 |
// --------------------------------------------------------------------------- |
|
231 |
// |
|
232 |
CMIDCanvas::~CMIDCanvas() |
|
233 |
{ |
|
234 |
DEBUG("+ CMIDCanvas::~CMIDCanvas"); |
|
235 |
||
236 |
// Notify custom components that this container is disposing. |
|
237 |
TInt customCount = iCustomComponents.Count(); |
|
238 |
||
239 |
for (TInt i = 0; i < customCount; i++) |
|
240 |
{ |
|
241 |
iCustomComponents[i]->CustomComponentContainerDisposing(); |
|
242 |
} |
|
243 |
||
244 |
// Close the array. Objects are not owned. |
|
245 |
iCustomComponents.Close(); |
|
246 |
||
247 |
// Inform all listeners |
|
248 |
TInt contentsCount(iDirectContents.Count()); |
|
249 |
||
250 |
for (TInt j = 0; j < contentsCount; j++) |
|
251 |
{ |
|
252 |
iDirectContents[j]->MdcContainerDestroyed(); |
|
253 |
} |
|
254 |
||
255 |
iDirectContents.Reset(); |
|
256 |
||
257 |
// Unregister the component from the observer |
|
258 |
// if it were previously registered from MdcAddContent. |
|
259 |
iEnv.ToLcduiObserver().UnregisterControl(*this); |
|
260 |
||
261 |
#ifdef CANVAS_DIRECT_ACCESS |
|
262 |
StopDirectAccess(); |
|
263 |
delete iDirectAccess; |
|
264 |
#endif // CANVAS_DIRECT_ACCESS |
|
265 |
||
266 |
// Network indicator |
|
267 |
if (iNetworkIndicator) |
|
268 |
{ |
|
269 |
iNetworkIndicator->Close(); // Use cancel here. |
|
270 |
delete iNetworkIndicator; |
|
271 |
} |
|
272 |
||
273 |
// Call indicator |
|
274 |
if (iCallIndicator) |
|
275 |
{ |
|
276 |
iCallIndicator->Cancel(); |
|
277 |
delete iCallIndicator; |
|
278 |
} |
|
279 |
||
280 |
// Canvas removes itself from the CMIDRemConObserver. |
|
281 |
ASSERT(iKeyDecoder); |
|
282 |
||
283 |
if (iRemConObserver && iKeyDecoder->MediaKeysEnabled()) |
|
284 |
{ |
|
285 |
iRemConObserver->RemoveMediaKeysListener(this); |
|
286 |
} |
|
287 |
||
288 |
if (iDisplayable) |
|
289 |
{ |
|
290 |
if (iScaler) |
|
291 |
{ |
|
292 |
iDisplayable->GetUIManager()->CloseScaler(iScaler); |
|
293 |
} |
|
294 |
||
295 |
// Displayable is notified about content control deletion. |
|
296 |
iDisplayable->NotifyContentDestroyed(); |
|
297 |
} |
|
298 |
||
299 |
#ifdef CANVAS_DOUBLE_BUFFER |
|
300 |
if (iFrameBuffer) |
|
301 |
{ |
|
302 |
iEnv.ReleaseCanvasFrameBuffer((*this), iFrameBuffer); |
|
303 |
iFrameBuffer = NULL; |
|
304 |
} |
|
305 |
||
306 |
delete iFrameContext; |
|
307 |
iFrameContext = NULL; |
|
308 |
delete iFrameDevice; |
|
309 |
iFrameDevice = NULL; |
|
310 |
#endif // CANVAS_DOUBLE_BUFFER |
|
311 |
||
312 |
#ifdef RD_TACTILE_FEEDBACK |
|
313 |
delete iTactileFeedback; |
|
314 |
#endif // RD_TACTILE_FEEDBACK |
|
315 |
||
316 |
if (iPointerEventSuppressor) |
|
317 |
{ |
|
318 |
delete iPointerEventSuppressor; |
|
319 |
iPointerEventSuppressor = NULL; |
|
320 |
} |
|
321 |
||
322 |
#ifdef RD_JAVA_NGA_ENABLED |
|
323 |
CloseEgl(EFalse); |
|
324 |
DisposePixelSource(); |
|
325 |
delete[] iTexturePixels; |
|
326 |
delete[] iVertexArray; |
|
327 |
delete[] iTriangleStrip; |
|
328 |
#endif // RD_JAVA_NGA_ENABLED |
|
329 |
DEBUG("- CMIDCanvas::~CMIDCanvas"); |
|
330 |
} |
|
331 |
||
332 |
||
333 |
// --------------------------------------------------------------------------- |
|
334 |
// CMIDCanvas::FullScreen |
|
335 |
// Set fullscreen mode on/off. |
|
336 |
// --------------------------------------------------------------------------- |
|
337 |
// |
|
338 |
void CMIDCanvas::FullScreen(TBool aFullScreen) |
|
339 |
{ |
|
340 |
DEBUG_INT("CMIDCanvas::FullScreen(%d) ++--", aFullScreen); |
|
341 |
if (iFullScreen != aFullScreen) |
|
342 |
{ |
|
343 |
iFullScreen = aFullScreen; |
|
344 |
// We have to inform all components on this Canvas. |
|
345 |
if (iCustomComponents.Count() > 0) |
|
346 |
{ |
|
347 |
for (int i = 0; i < iCustomComponents.Count(); i++) |
|
348 |
{ |
|
349 |
iCustomComponents[i]->HandleFullscreenModeChange(); |
|
350 |
} |
|
351 |
} |
|
352 |
} |
|
353 |
} |
|
354 |
||
355 |
||
356 |
// --------------------------------------------------------------------------- |
|
357 |
// CMIDCanvas::IsScalingOn |
|
358 |
// Tells whether scaling is on or off. |
|
359 |
// --------------------------------------------------------------------------- |
|
360 |
// |
|
361 |
TBool CMIDCanvas::IsScalingOn() |
|
362 |
{ |
|
363 |
return iScalingOn; |
|
364 |
} |
|
365 |
||
366 |
||
367 |
// --------------------------------------------------------------------------- |
|
368 |
// CMIDCanvas::SelectionKeyCompatibility |
|
369 |
// Tells whether application attribute |
|
370 |
// Nokia-MIDlet-S60-Selection-Key-Compatibility is set true or not. |
|
371 |
// --------------------------------------------------------------------------- |
|
372 |
// |
|
373 |
TBool CMIDCanvas::SelectionKeyCompatibility() |
|
374 |
{ |
|
375 |
return iS60SelectionKeyCompatibility; |
|
376 |
} |
|
377 |
||
378 |
// --------------------------------------------------------------------------- |
|
379 |
// CMIDCanvas::CountComponentControls |
|
380 |
// (other items are commented in the header file) |
|
381 |
// --------------------------------------------------------------------------- |
|
382 |
// |
|
383 |
TInt CMIDCanvas::CountComponentControls() const |
|
384 |
{ |
|
385 |
return iCustomComponentsControlCount; |
|
386 |
} |
|
387 |
||
388 |
// --------------------------------------------------------------------------- |
|
389 |
// CMIDCanvas::ComponentControl |
|
390 |
// (other items are commented in the header file) |
|
391 |
// --------------------------------------------------------------------------- |
|
392 |
// |
|
393 |
CCoeControl* CMIDCanvas::ComponentControl(TInt aIndex) const |
|
394 |
{ |
|
395 |
TInt index = 0; |
|
396 |
||
397 |
TInt count = iCustomComponents.Count(); |
|
398 |
||
399 |
for (int i = 0; i < count; i++) |
|
400 |
{ |
|
401 |
TInt compoundCount = |
|
402 |
iCustomComponents[i]->CustomComponentControlCount(); |
|
403 |
||
404 |
for (int j = 0; j < compoundCount; j++) |
|
405 |
{ |
|
406 |
if (index == aIndex) |
|
407 |
{ |
|
408 |
return iCustomComponents[i]->CustomComponentControl(j); |
|
409 |
} |
|
410 |
||
411 |
index++; |
|
412 |
} |
|
413 |
} |
|
414 |
||
415 |
return NULL; |
|
416 |
} |
|
417 |
||
418 |
// --------------------------------------------------------------------------- |
|
419 |
// CMIDCanvas::SetFocusedComponent |
|
420 |
// (other items are commented in the header file) |
|
421 |
// --------------------------------------------------------------------------- |
|
422 |
// |
|
423 |
void CMIDCanvas::SetFocusedComponent(MMIDCustomComponent* aComponent) |
|
424 |
{ |
|
425 |
if (!aComponent) |
|
426 |
{ |
|
427 |
iFocusedComponent = KComponentFocusedNone; |
|
428 |
iPressedComponent = NULL; |
|
429 |
} |
|
430 |
else |
|
431 |
{ |
|
432 |
TInt count = iCustomComponents.Count(); |
|
433 |
TInt index = iCustomComponents.Find(aComponent); |
|
434 |
if ((index != KErrNotFound) && (iFocusedComponent != index)) |
|
435 |
{ |
|
436 |
iFocusedComponent = index; |
|
437 |
} |
|
438 |
} |
|
439 |
} |
|
440 |
||
441 |
// --------------------------------------------------------------------------- |
|
442 |
// From class CCoeControl. |
|
443 |
// CMIDCanvas::OfferKeyEventL |
|
444 |
// Process a key event. We ask the java environment to translate the key event |
|
445 |
// and we send it java side only if the translation allows it. The translation |
|
446 |
// is controlled by CMIDKeyDecoder via its interface to the java environment. |
|
447 |
// CBA keys are special. We only try and send them java side if we are full |
|
448 |
// screen and have no commands nor CommandListener, as stated in the specs. |
|
449 |
// Otherwise - if we are full screen with at least one command and |
|
450 |
// CommandListener we display the options menu or if we are not full screen |
|
451 |
// we simply return so that the CBA will process the key event and display the |
|
452 |
// options menu if needed. Note that in this context MSK is considered to be a |
|
453 |
// softkey, it must not be delivered as a key event to the Java side. |
|
454 |
// --------------------------------------------------------------------------- |
|
455 |
// |
|
456 |
TKeyResponse CMIDCanvas::OfferKeyEventL( |
|
457 |
const TKeyEvent& aEvent, |
|
458 |
TEventCode aType) |
|
459 |
{ |
|
460 |
DEBUG("+ CMIDCanvas::OfferKeyEventL"); |
|
461 |
||
462 |
DEBUG_INT( |
|
463 |
"+ CMIDCanvas::OfferKeyEventL - received TKeyEvent: iCode = %d", |
|
464 |
aEvent.iCode); |
|
465 |
||
466 |
DEBUG_INT( |
|
467 |
"+ CMIDCanvas::OfferKeyEventL - received TKeyEvent: iModifiers = %d", |
|
468 |
aEvent.iModifiers); |
|
469 |
||
470 |
DEBUG_INT( |
|
471 |
"+ CMIDCanvas::OfferKeyEventL - received TKeyEvent: iRepeats = %d", |
|
472 |
aEvent.iRepeats); |
|
473 |
||
474 |
DEBUG_INT( |
|
475 |
"+ CMIDCanvas::OfferKeyEventL - received TKeyEvent: iScanCode = %d", |
|
476 |
aEvent.iScanCode); |
|
477 |
||
478 |
TKeyResponse response = EKeyWasNotConsumed; |
|
479 |
||
480 |
if ((iFocusedComponent != KComponentFocusedNone) && |
|
481 |
(iFocusedComponent < iCustomComponents.Count()) && |
|
482 |
(iCustomComponents[iFocusedComponent]-> |
|
483 |
CustomComponentControl(KComponentMainControl)->IsVisible())) |
|
484 |
{ |
|
485 |
// Traversal check |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
486 |
if ((aType == EEventKeyDown) && |
66 | 487 |
(((aEvent.iCode == EKeyUpArrow) || |
488 |
(aEvent.iCode == EKeyDownArrow)) || |
|
489 |
((aEvent.iScanCode == EStdKeyUpArrow) || |
|
490 |
(aEvent.iScanCode == EStdKeyDownArrow)))) |
|
491 |
{ |
|
492 |
// Traversing is not allowed when editing with VKB |
|
493 |
if (iDisplayable && !iDisplayable->IsVKBOnScreen()) |
|
494 |
{ |
|
495 |
iCustomComponents[iFocusedComponent]->TraverseL(aEvent); |
|
496 |
response = EKeyWasConsumed; |
|
497 |
} |
|
498 |
} |
|
499 |
||
500 |
if (response != EKeyWasConsumed) |
|
501 |
{ |
|
502 |
// Passing the keyevent to focused component |
|
503 |
response = iCustomComponents[iFocusedComponent]-> |
|
504 |
CustomComponentControl(KComponentMainControl)-> |
|
505 |
OfferKeyEventL(aEvent, aType); |
|
506 |
} |
|
507 |
} |
|
508 |
||
509 |
// Check if the key event was consumed by the child control. |
|
510 |
if (response == EKeyWasConsumed) |
|
511 |
{ |
|
512 |
DEBUG_INT( |
|
513 |
"CMIDCanvas::OfferKeyEventL - key consumed by custom control: %d", |
|
514 |
iFocusedComponent); |
|
515 |
||
516 |
// Return response. |
|
517 |
return response; |
|
518 |
} |
|
519 |
||
520 |
||
521 |
DEBUG("CMIDCanvas::OfferKeyEventL, \ |
|
522 |
event not consumed by any custom component"); |
|
523 |
||
524 |
TInt keycode = aEvent.iScanCode; |
|
525 |
||
526 |
// If there is additional selection key mapping (e.g. to Enter key) and |
|
527 |
// scan code of delivered key is this additional key, flag is set to ETrue |
|
528 |
TBool additionalSelectionKey = |
|
529 |
(iKeyDecoder->AdditionalSelectionKeyMappingCode() != 0) && |
|
530 |
(keycode == iKeyDecoder->AdditionalSelectionKeyMappingCode()); |
|
531 |
||
532 |
if (keycode == EStdKeyDevice0 || |
|
533 |
keycode == EStdKeyDevice1 || |
|
534 |
keycode == EStdKeyDevice3 || |
|
535 |
additionalSelectionKey) |
|
536 |
{ |
|
537 |
// CBA keys |
|
538 |
||
539 |
// In S60SelectionKeyCompatibility mode turned on and MSK pressed |
|
540 |
// don't map any command, send key event to Java. |
|
541 |
if (iS60SelectionKeyCompatibility && |
|
542 |
(keycode == EStdKeyDevice3 || additionalSelectionKey)) |
|
543 |
{ |
|
544 |
SendKeyEventToJavaSideL(aEvent, aType); |
|
545 |
DEBUG("- CMIDCanvas::OfferKeyEventL = key was not consumed"); |
|
546 |
return EKeyWasNotConsumed; |
|
547 |
} |
|
548 |
||
549 |
if (iDisplayable && !iDisplayable->IsFullScreenMode()) |
|
550 |
{ |
|
551 |
// Pressing selection key is handled in CEikCba so that command |
|
552 |
// mapped to selection (MSK) key is invoked from there. |
|
553 |
// But CEikCba doesn't handle additional selection key |
|
554 |
// mapping, so it is done here. |
|
555 |
if (additionalSelectionKey && aType == EEventKey) |
|
556 |
{ |
|
557 |
iDisplayable->ProcessMSKCommandL(); |
|
558 |
} |
|
559 |
else if (aType == EEventKeyDown && keycode == EStdKeyDevice3) |
|
560 |
{ |
|
561 |
CMIDMenuHandler* menuHandler = iDisplayable->MenuHandler(); |
|
562 |
||
563 |
// If there is no additional selection key mapping |
|
564 |
// and scan code of delivered key is MSK then show menu, |
|
565 |
// used when ENavigationKeysFire or MSK were pressed |
|
566 |
if (iDisplayable->NumCommandsForOkOptionsMenu() == 0 |
|
567 |
&& menuHandler) |
|
568 |
{ |
|
569 |
menuHandler->ProcessCommandL(EAknSoftkeyEmpty); |
|
570 |
} |
|
571 |
else if (iDisplayable->NumCommandsForOkOptionsMenu() > 0 |
|
572 |
&& menuHandler) |
|
573 |
{ |
|
574 |
menuHandler->ProcessCommandL(EAknSoftkeyContextOptions); |
|
575 |
} |
|
576 |
} |
|
577 |
||
578 |
// Not a full screen mode, return so that the CBA gets the event. |
|
579 |
DEBUG("- CMIDCanvas::OfferKeyEventL = key was not consumed"); |
|
580 |
return EKeyWasNotConsumed; |
|
581 |
} |
|
582 |
||
583 |
if (iDisplayable && iDisplayable->IsFullScreenMode() && |
|
584 |
iDisplayable->IsCommandListenerSet() && |
|
585 |
iDisplayable->CommandCount() > 0) |
|
586 |
{ |
|
587 |
CMIDMenuHandler* menuHandler = iDisplayable->MenuHandler(); |
|
588 |
||
589 |
// If full screen and command listener is set and there are |
|
590 |
// Commands added to Canvas, then options menu is displayed. |
|
591 |
if (aType == EEventKey && menuHandler) |
|
592 |
{ |
|
593 |
menuHandler->ShowMenuL( |
|
594 |
CMIDMenuHandler::EOptionsMenu); |
|
595 |
} |
|
596 |
||
597 |
DEBUG("- CMIDCanvas::OfferKeyEventL = key was not consumed"); |
|
598 |
return EKeyWasNotConsumed; |
|
599 |
} |
|
600 |
} |
|
601 |
||
602 |
SendKeyEventToJavaSideL(aEvent, aType); |
|
603 |
||
604 |
DEBUG("- CMIDCanvas::OfferKeyEventL = key was not consumed"); |
|
605 |
return EKeyWasNotConsumed; |
|
606 |
} |
|
607 |
||
608 |
||
609 |
// --------------------------------------------------------------------------- |
|
610 |
// From class MMIDComponent. |
|
611 |
// CMIDCanvas::Dispose |
|
612 |
// Invoked by the framework to clean up resources. |
|
613 |
// --------------------------------------------------------------------------- |
|
614 |
// |
|
615 |
void CMIDCanvas::Dispose() |
|
616 |
{ |
|
617 |
delete this; |
|
618 |
} |
|
619 |
||
620 |
||
621 |
// --------------------------------------------------------------------------- |
|
622 |
// From class MMIDComponent. |
|
623 |
// CMIDCanvas::Type |
|
624 |
// Always returns the type MMIDComponent::ECanvas as component type. |
|
625 |
// --------------------------------------------------------------------------- |
|
626 |
// |
|
627 |
MMIDComponent::TType CMIDCanvas::Type() const |
|
628 |
{ |
|
629 |
return MMIDComponent::ECanvas; |
|
630 |
} |
|
631 |
||
632 |
||
633 |
// --------------------------------------------------------------------------- |
|
634 |
// From class MMIDComponent. |
|
635 |
// CMIDCanvas::Processor |
|
636 |
// Always returns this-> as buffer processor associated with this component. |
|
637 |
// --------------------------------------------------------------------------- |
|
638 |
// |
|
639 |
MMIDBufferProcessor* CMIDCanvas::Processor() |
|
640 |
{ |
|
641 |
return this; |
|
642 |
} |
|
643 |
||
644 |
||
645 |
// --------------------------------------------------------------------------- |
|
646 |
// From class MMIDCanvas. |
|
647 |
// CMIDCanvas::Control |
|
648 |
// Returns a reference to the CCoeControl corresponding to this canvas. |
|
649 |
// --------------------------------------------------------------------------- |
|
650 |
// |
|
651 |
CCoeControl& CMIDCanvas::Control() |
|
652 |
{ |
|
653 |
return *this; |
|
654 |
} |
|
655 |
||
656 |
||
657 |
// --------------------------------------------------------------------------- |
|
658 |
// From class MMIDCanvas. |
|
659 |
// CMIDCanvas::FrameBuffer |
|
660 |
// Returns a pointer to the frame buffer. If double buffering is supported |
|
661 |
// this method must not return NULL. There is no ownership transfer. |
|
662 |
// --------------------------------------------------------------------------- |
|
663 |
// |
|
664 |
CFbsBitmap* CMIDCanvas::FrameBuffer() const |
|
665 |
{ |
|
666 |
#ifdef CANVAS_DOUBLE_BUFFER |
|
667 |
return iFrameBuffer; |
|
668 |
#else |
|
669 |
return NULL; |
|
670 |
#endif // CANVAS_DOUBLE_BUFFER |
|
671 |
} |
|
672 |
||
673 |
||
674 |
// --------------------------------------------------------------------------- |
|
675 |
// From class MMIDCanvas. |
|
676 |
// CMIDCanvas::ContentSize |
|
677 |
// Returns the size of the canvas content. |
|
678 |
// --------------------------------------------------------------------------- |
|
679 |
// |
|
680 |
TSize CMIDCanvas::ContentSize() const |
|
681 |
{ |
|
682 |
return iContentSize; |
|
683 |
} |
|
684 |
||
685 |
||
686 |
// --------------------------------------------------------------------------- |
|
687 |
// From class MMIDCanvas. |
|
688 |
// CMIDCanvas::PauseDirectAccess |
|
689 |
// Disables temporarily direct screen access. |
|
690 |
// This method should be called to disable direct screen access when a popup |
|
691 |
// menu is about to be displayed. This is a workaround for menu's failing to |
|
692 |
// correctly draw their shadows on Techview and other UI's that have floating |
|
693 |
// menubars. |
|
694 |
// --------------------------------------------------------------------------- |
|
695 |
// |
|
696 |
void CMIDCanvas::PauseDirectAccess() |
|
697 |
{ |
|
698 |
#ifdef CANVAS_DIRECT_ACCESS |
|
699 |
StopDirectAccess(); |
|
700 |
#endif // CANVAS_DIRECT_ACCESS |
|
701 |
||
702 |
iFlags |= EDirectPaused; |
|
703 |
} |
|
704 |
||
705 |
||
706 |
// --------------------------------------------------------------------------- |
|
707 |
// From class MMIDCanvas. |
|
708 |
// CMIDCanvas::ResumeDirectAccess |
|
709 |
// Re-enables direct screen access. |
|
710 |
// To be called when the menu has disappeared. |
|
711 |
// --------------------------------------------------------------------------- |
|
712 |
// |
|
713 |
void CMIDCanvas::ResumeDirectAccess() |
|
714 |
{ |
|
715 |
iFlags &= ~EDirectPaused; |
|
716 |
||
717 |
#ifdef CANVAS_DIRECT_ACCESS |
|
718 |
StartDirectAccess(); |
|
719 |
#endif // CANVAS_DIRECT_ACCESS |
|
720 |
} |
|
721 |
||
722 |
||
723 |
// --------------------------------------------------------------------------- |
|
724 |
// From class MMIDCanvas. |
|
725 |
// CMIDCanvas::SuppressKeys |
|
726 |
// Switch off key event posting. Game keys will still be tracked, but |
|
727 |
// keyPressed()/keyReleased() callbacks will not be called. |
|
728 |
// --------------------------------------------------------------------------- |
|
729 |
// |
|
730 |
void CMIDCanvas::SuppressKeys() |
|
731 |
{ |
|
732 |
iFlags &= ~EPostKeyEvents; |
|
733 |
iEnv.ResetKeys(); |
|
734 |
} |
|
735 |
||
736 |
||
737 |
// --------------------------------------------------------------------------- |
|
738 |
// From class MMIDCanvas. |
|
739 |
// CMIDCanvas::GameActions |
|
740 |
// Returns the latched state of the game action keys. |
|
741 |
// --------------------------------------------------------------------------- |
|
742 |
// |
|
743 |
TUint32 CMIDCanvas::GameActions() |
|
744 |
{ |
|
745 |
TUint32 latch = (iGameKeyLatch | iGameKeyState); |
|
746 |
iGameKeyLatch = 0; |
|
747 |
return latch; |
|
748 |
} |
|
749 |
||
750 |
||
751 |
// --------------------------------------------------------------------------- |
|
752 |
// From class MMIDCanvas. |
|
753 |
// CMIDCanvas::DirectContainer |
|
754 |
// Returns a direct container on which video can be rendered. |
|
755 |
// --------------------------------------------------------------------------- |
|
756 |
// |
|
757 |
MDirectContainer& CMIDCanvas::DirectContainer() |
|
758 |
{ |
|
759 |
return *this; |
|
760 |
} |
|
761 |
||
762 |
||
763 |
// --------------------------------------------------------------------------- |
|
764 |
// From class MMIDCanvas. |
|
765 |
// CMIDCanvas::DrawBackground |
|
766 |
// Draw a background image. |
|
767 |
// --------------------------------------------------------------------------- |
|
768 |
// |
|
769 |
void CMIDCanvas::DrawBackground( |
|
770 |
CBitmapContext& aGc, const TPoint& aPosition, const TSize& aSize) |
|
771 |
{ |
|
772 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
773 |
MAknsControlContext* cc = iDisplayable->BackGroundControlContext(); |
|
774 |
||
775 |
AknsDrawUtils::DrawBackground( |
|
776 |
skin, cc, NULL, aGc, aPosition, aSize, KAknsDrawParamDefault); |
|
777 |
} |
|
778 |
||
779 |
||
780 |
// --------------------------------------------------------------------------- |
|
781 |
// From class MMIDCanvas. |
|
782 |
// CMIDCanvas::IsGameCanvas |
|
783 |
// Returns the type of Canvas object. |
|
784 |
// --------------------------------------------------------------------------- |
|
785 |
// |
|
786 |
TBool CMIDCanvas::IsGameCanvas() const |
|
787 |
{ |
|
788 |
return iIsGameCanvas; |
|
789 |
} |
|
790 |
||
791 |
||
792 |
// --------------------------------------------------------------------------- |
|
793 |
// From class MMIDCanvas. |
|
794 |
// Gets the Network indicator location for fullscreen |
|
795 |
// If not in fullscreenmode EFalse is returned |
|
796 |
// --------------------------------------------------------------------------- |
|
797 |
// |
|
798 |
TBool CMIDCanvas::NetworkIndicatorLocation( |
|
799 |
TPoint& aPosition, |
|
800 |
TSize& aSize) const |
|
801 |
{ |
|
802 |
if (iFullScreen) |
|
803 |
{ |
|
804 |
if (iNetworkIndicator) |
|
805 |
{ |
|
806 |
iNetworkIndicator->GetLocation(aPosition, aSize); |
|
807 |
return ETrue; |
|
808 |
} |
|
809 |
} |
|
810 |
return EFalse; |
|
811 |
} |
|
812 |
||
813 |
||
814 |
#ifdef RD_TACTILE_FEEDBACK |
|
815 |
// --------------------------------------------------------------------------- |
|
816 |
// From MMIDCanvas. |
|
817 |
// CMIDCanvas::TactileFeedbackComponent |
|
818 |
// Retutrns this as tactile feedback component. |
|
819 |
// --------------------------------------------------------------------------- |
|
820 |
// |
|
821 |
MMIDTactileFeedbackComponent* CMIDCanvas::TactileFeedbackComponent() |
|
822 |
{ |
|
823 |
return this; |
|
824 |
} |
|
825 |
#endif // RD_TACTILE_FEEDBACK |
|
826 |
||
827 |
||
828 |
// --------------------------------------------------------------------------- |
|
829 |
// From class MMIDCanvas. |
|
830 |
// --------------------------------------------------------------------------- |
|
831 |
// |
|
832 |
TBool CMIDCanvas::ReadyToBlit() const |
|
833 |
{ |
|
834 |
return iFirstPaintState != EFirstPaintNeverOccurred; |
|
835 |
} |
|
836 |
||
837 |
#ifdef RD_JAVA_NGA_ENABLED |
|
838 |
||
839 |
// --------------------------------------------------------------------------- |
|
840 |
// From class MMIDBufferProcessor. |
|
841 |
// CMIDCanvas::ProcessL |
|
842 |
// Process a block of commands, updating read pointer as you go. |
|
843 |
// --------------------------------------------------------------------------- |
|
844 |
// |
|
845 |
TBool CMIDCanvas::ProcessL( |
|
846 |
const TMIDBufferOp*& aRead, |
|
847 |
const TMIDBufferOp* aEnd, |
|
848 |
TInt& /* aCycles */, |
|
849 |
java::util::Monitor* aMonitor) |
|
850 |
{ |
|
851 |
||
852 |
if (!iForeground && iFirstPaintState == EFirstPaintNeverOccurred) |
|
853 |
{ |
|
854 |
ASSERT(!iAlfMonitor); |
|
855 |
aRead = aEnd; |
|
856 |
return EFalse; |
|
857 |
} |
|
858 |
||
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
859 |
switch (aRead->OpCode()) |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
860 |
{ |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
861 |
case EDrwOpcM3GContentStart: |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
862 |
{ |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
863 |
// EGL surface is created if canvas window is currently visible |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
864 |
// even if MIDlet would be on background. |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
865 |
if (!iM3GContent && |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
866 |
i3DAccelerated && |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
867 |
iDirectContents.Count() == 0 && |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
868 |
IsWindowVisible()) |
66 | 869 |
{ |
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
870 |
DEBUG("CMIDCanvas::ProcessL - M3G content start"); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
871 |
iM3GContent = ETrue; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
872 |
iM3GStart = ETrue; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
873 |
PostEvent(EM3GDraw, iM3GContent, 0); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
874 |
// First time when M3G content is drawn => |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
875 |
// switch to EGL surface drawing. |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
876 |
// Pixel source must be disposed first. |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
877 |
DisposePixelSource(); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
878 |
OpenEglL(); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
879 |
|
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
880 |
// if we are scaling with m3g and HW acceleration |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
881 |
// create a pbuffer surface to be used with m3g rendering |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
882 |
if (iScalingOn && iFullScreen) |
77
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
71
diff
changeset
|
883 |
{ |
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
884 |
CreatePBufferSurfaceL(); |
77
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
71
diff
changeset
|
885 |
} |
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
886 |
// Draw the whole framebuffer content (as a texture) on top of |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
887 |
// the EGL window surface. |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
888 |
iUpperUpdateRect = TRect(Size()); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
889 |
UpdateEglContent(); |
77
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
71
diff
changeset
|
890 |
} |
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
891 |
} |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
892 |
break; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
893 |
case EDrwOpcBitBltRect: |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
894 |
{ |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
895 |
if (iFirstPaintState == EFirstPaintNeverOccurred) |
66 | 896 |
{ |
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
897 |
iFirstPaintState = EFirstPaintInitiated; |
66 | 898 |
} |
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
899 |
|
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
900 |
const TBitBltData& data = BitBltData(aRead); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
901 |
UpdateL(data.iRect); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
902 |
} |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
903 |
break; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
904 |
case EDrwOpcBitBlt: |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
905 |
{ |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
906 |
if (iFirstPaintState == EFirstPaintNeverOccurred) |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
907 |
{ |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
908 |
iFirstPaintState = EFirstPaintInitiated; |
77
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
71
diff
changeset
|
909 |
} |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
71
diff
changeset
|
910 |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
911 |
UpdateL(iViewRect); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
912 |
} |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
913 |
break; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
914 |
default: |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
915 |
User::Leave(KErrNotSupported); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
916 |
break; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
917 |
} |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
918 |
|
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
919 |
aRead += aRead->Size(); |
66 | 920 |
ASSERT(aRead == aEnd); |
921 |
||
922 |
// iFrameReady tells if this is async operation. |
|
923 |
// In async case CMIDBuffer waits until canvas |
|
924 |
// gets callback from Alf. |
|
925 |
// See CMIDBuffer.cpp and ProduceNewFrameL() |
|
926 |
if (iFrameReady) |
|
927 |
{ |
|
928 |
iAlfMonitor = aMonitor; |
|
929 |
} |
|
930 |
return iFrameReady; |
|
931 |
} |
|
932 |
||
933 |
#else // RD_JAVA_NGA_ENABLED |
|
934 |
||
935 |
// --------------------------------------------------------------------------- |
|
936 |
// From class MMIDBufferProcessor. |
|
937 |
// CMIDCanvas::ProcessL |
|
938 |
// Process a block of commands, updating read pointer as you go. |
|
939 |
// --------------------------------------------------------------------------- |
|
940 |
// |
|
941 |
TBool CMIDCanvas::ProcessL( |
|
942 |
const TMIDBufferOp*& aRead, |
|
943 |
const TMIDBufferOp* aEnd, |
|
944 |
TInt& aCycles, |
|
945 |
TRequestStatus* /* aStatus */) |
|
946 |
{ |
|
947 |
DEBUG("+ CMIDCanvas::ProcessL"); |
|
948 |
||
949 |
#ifdef CANVAS_DOUBLE_BUFFER |
|
950 |
while (aRead < aEnd) |
|
951 |
{ |
|
952 |
switch (aRead->OpCode()) |
|
953 |
{ |
|
954 |
case EDrwOpcBitBlt: |
|
955 |
{ |
|
956 |
TSize size = iFrameBuffer->SizeInPixels(); |
|
957 |
||
958 |
#ifdef DEFER_BITBLT |
|
959 |
aCycles -= BitBltCycles(size); |
|
960 |
||
961 |
if (aCycles < 0) |
|
962 |
{ |
|
963 |
return EFalse; |
|
964 |
} |
|
965 |
#endif // DEFER_BITBLT |
|
966 |
||
967 |
Update(TRect(size)); |
|
968 |
} |
|
969 |
break; |
|
970 |
||
971 |
case EDrwOpcBitBltRect: |
|
972 |
{ |
|
973 |
const TBitBltData& data = BitBltData(aRead); |
|
974 |
TRect rect = data.iRect; |
|
975 |
||
976 |
// This is needed to avoid artifacting after orientation switch. |
|
977 |
// While changing orientation, wrong rect was not updated. |
|
978 |
if (iWndUpdate && (rect.Size() != iViewRect.Size()) |
|
979 |
&& !iScalingOn) |
|
980 |
{ |
|
981 |
break; |
|
982 |
} |
|
983 |
||
984 |
TRect frameRect(iFrameBuffer->SizeInPixels()); |
|
985 |
||
986 |
rect.Intersection(frameRect); |
|
987 |
||
988 |
#ifdef DEFER_BITBLT |
|
989 |
aCycles -= BitBltCycles(rect.Size()); |
|
990 |
||
991 |
if (aCycles < 0) |
|
992 |
{ |
|
993 |
return EFalse; |
|
994 |
} |
|
995 |
#endif // DEFER_BITBLT |
|
996 |
||
997 |
Update(rect); |
|
998 |
} |
|
999 |
break; |
|
1000 |
default: |
|
1001 |
User::Leave(KErrNotSupported); |
|
1002 |
break; |
|
1003 |
} |
|
1004 |
||
1005 |
aRead += aRead->Size(); |
|
1006 |
} |
|
1007 |
#endif // CANVAS_DOUBLE_BUFFER |
|
1008 |
||
1009 |
if (iFirstPaintState == EFirstPaintNeverOccurred) |
|
1010 |
{ |
|
1011 |
if (iForeground) |
|
1012 |
{ |
|
1013 |
// The canvas is current, therefore we can flush |
|
1014 |
// the graphics and take the start screen snapshot. |
|
1015 |
iFirstPaintState = EFirstPaintOccurred; |
|
1016 |
java::ui::CoreUiAvkonLcdui::getInstance().getJavaUiAppUi()->stopStartScreen(); |
|
1017 |
} |
|
1018 |
else |
|
1019 |
{ |
|
1020 |
// The window is not visible, the start screen snapshot |
|
1021 |
// will be taken when the canvas will be set current. |
|
1022 |
iFirstPaintState = EFirstPaintInitiated; |
|
1023 |
} |
|
1024 |
} |
|
1025 |
||
1026 |
DEBUG("- CMIDCanvas::ProcessL"); |
|
1027 |
||
1028 |
return EFalse; |
|
1029 |
} |
|
1030 |
#endif // RD_JAVA_NGA_ENABLED |
|
1031 |
||
1032 |
||
1033 |
// --------------------------------------------------------------------------- |
|
1034 |
// From class MMIDBufferProcessor. |
|
1035 |
// CMIDCanvas::AbortAsync |
|
1036 |
// Does nothing. |
|
1037 |
// --------------------------------------------------------------------------- |
|
1038 |
// |
|
1039 |
void CMIDCanvas::AbortAsync() |
|
1040 |
{ |
|
1041 |
// nop |
|
1042 |
} |
|
1043 |
||
1044 |
||
1045 |
#ifdef CANVAS_DIRECT_ACCESS |
|
1046 |
// --------------------------------------------------------------------------- |
|
1047 |
// From class MAbortDirectScreenAccess. |
|
1048 |
// CMIDCanvas::AbortNow |
|
1049 |
// This function is called by the window server when direct screen access |
|
1050 |
// must stop (for example because a dialogue is moved in front of the area |
|
1051 |
// where direct screen access is taking place). |
|
1052 |
// --------------------------------------------------------------------------- |
|
1053 |
// |
|
1054 |
void CMIDCanvas::AbortNow( |
|
1055 |
RDirectScreenAccess::TTerminationReasons /* aReasons */) |
|
1056 |
{ |
|
1057 |
StopDirectAccess(); |
|
1058 |
} |
|
1059 |
||
1060 |
||
1061 |
// --------------------------------------------------------------------------- |
|
1062 |
// From class MDirectScreenAccess. |
|
1063 |
// CMIDCanvas::Restart |
|
1064 |
// This function is called by the window server as soon as direct screen |
|
1065 |
// access can resume. |
|
1066 |
// --------------------------------------------------------------------------- |
|
1067 |
// |
|
1068 |
void CMIDCanvas::Restart( |
|
1069 |
RDirectScreenAccess::TTerminationReasons /* aReasons */) |
|
1070 |
{ |
|
1071 |
StartDirectAccess(); |
|
1072 |
} |
|
1073 |
#endif // CANVAS_DIRECT_ACCESS |
|
1074 |
||
1075 |
||
1076 |
// --------------------------------------------------------------------------- |
|
1077 |
// From class MDirectContainer. |
|
1078 |
// CMIDCanvas::MdcAddContent |
|
1079 |
// Set the content of this direct container. |
|
1080 |
// --------------------------------------------------------------------------- |
|
1081 |
// |
|
1082 |
void CMIDCanvas::MdcAddContent(MDirectContent* aContent) |
|
1083 |
{ |
|
1084 |
TInt error = iDirectContents.Append(aContent); |
|
1085 |
||
1086 |
__ASSERT_DEBUG(error == KErrNone, User::Invariant()); |
|
1087 |
||
1088 |
// Register this control to observer |
|
1089 |
// in order to provide possibility to call |
|
1090 |
// methods from another than LCDUI ES thread. |
|
1091 |
// Unregistration is done in destructor. |
|
1092 |
#ifdef RD_JAVA_NGA_ENABLED |
|
1093 |
iEnv.ToLcduiObserver().RegisterControl(*this, this); |
|
1094 |
#else |
|
1095 |
iEnv.ToLcduiObserver().RegisterControl(*this); |
|
1096 |
#endif // RD_JAVA_NGA_ENABLED |
|
1097 |
||
1098 |
#ifdef RD_JAVA_NGA_ENABLED |
|
1099 |
if (iFirstPaintState != EFirstPaintOccurred && |
|
1100 |
iDirectContents.Count() == 1) |
|
1101 |
{ |
|
1102 |
// The first canvas paint using NGA might be interrupted |
|
1103 |
// by addition of the direct content. |
|
1104 |
// Invoking repaint event to restore the first paint. |
|
1105 |
TInt posPacked = (iViewRect.iTl.iX << 16) | (iViewRect.iTl.iY); |
|
1106 |
TSize size = iViewRect.Size(); |
|
1107 |
TInt sizePacked = (size.iWidth << 16) | (size.iHeight); |
|
1108 |
||
1109 |
PostEvent(EPaint, posPacked, sizePacked); |
|
1110 |
} |
|
1111 |
||
1112 |
if (iDirectContents.Count() > 0) |
|
1113 |
{ |
|
1114 |
iEnv.ToLcduiObserver().InvokeLcduiEvent(*this, EVideoAdded); |
|
1115 |
} |
|
1116 |
#endif // RD_JAVA_NGA_ENABLED |
|
1117 |
} |
|
1118 |
||
1119 |
||
1120 |
// --------------------------------------------------------------------------- |
|
1121 |
// From class MDirectContainer. |
|
1122 |
// CMIDCanvas::MdcRemoveContent |
|
1123 |
// Remove the content from this direct container. This will called when |
|
1124 |
// the Player is closed. |
|
1125 |
// --------------------------------------------------------------------------- |
|
1126 |
// |
|
1127 |
void CMIDCanvas::MdcRemoveContent(MDirectContent* aContent) |
|
1128 |
{ |
|
1129 |
TInt index = iDirectContents.Find(aContent); |
|
1130 |
||
1131 |
if (index != KErrNotFound) |
|
1132 |
{ |
|
1133 |
iDirectContents.Remove(index); |
|
1134 |
if (iDirectContents.Count() == 0) |
|
1135 |
{ |
|
1136 |
iRestoreContentWhenUnfaded = EFalse; |
|
1137 |
} |
|
1138 |
} |
|
1139 |
} |
|
1140 |
||
1141 |
||
1142 |
// --------------------------------------------------------------------------- |
|
1143 |
// From class MDirectContainer. |
|
1144 |
// CMIDCanvas::MdcAddContentBounds |
|
1145 |
// Adds a rectangle to be excluded from redrawing. |
|
1146 |
// --------------------------------------------------------------------------- |
|
1147 |
// |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
1148 |
void CMIDCanvas::MdcAddContentBounds(const TRect& aRect) |
66 | 1149 |
{ |
1150 |
if (iDisplayable) |
|
1151 |
{ |
|
1152 |
iDisplayable->AddDirectContentArea(aRect); |
|
1153 |
} |
|
1154 |
} |
|
1155 |
||
1156 |
||
1157 |
// --------------------------------------------------------------------------- |
|
1158 |
// From class MDirectContainer. |
|
1159 |
// CMIDCanvas::MdcRemoveContentBounds |
|
1160 |
// Removes a rectangle to be excluded from redrawing. |
|
1161 |
// --------------------------------------------------------------------------- |
|
1162 |
// |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
1163 |
void CMIDCanvas::MdcRemoveContentBounds(const TRect& aRect) |
66 | 1164 |
{ |
1165 |
if (iDisplayable) |
|
1166 |
{ |
|
1167 |
iDisplayable->RemoveDirectContentArea(aRect); |
|
1168 |
} |
|
1169 |
} |
|
1170 |
||
1171 |
||
1172 |
// --------------------------------------------------------------------------- |
|
1173 |
// From class MDirectContainer. |
|
1174 |
// CMIDCanvas::MdcContainerWindowRect() |
|
1175 |
// --------------------------------------------------------------------------- |
|
1176 |
// |
|
1177 |
TRect CMIDCanvas::MdcContainerWindowRect() const |
|
1178 |
{ |
|
1179 |
// CMIDCanvas has the size of the window always |
|
1180 |
return MdcContentBounds(); |
|
1181 |
} |
|
1182 |
||
1183 |
||
1184 |
// --------------------------------------------------------------------------- |
|
1185 |
// From class MDirectContainer. |
|
1186 |
// CMIDCanvas::MdcContainerVisibility |
|
1187 |
// Get the visiblity of this direct container. |
|
1188 |
// --------------------------------------------------------------------------- |
|
1189 |
// |
|
1190 |
TBool CMIDCanvas::MdcContainerVisibility() const |
|
1191 |
{ |
|
1192 |
return iDisplayable->IsVisible(); |
|
1193 |
} |
|
1194 |
||
1195 |
||
1196 |
// --------------------------------------------------------------------------- |
|
1197 |
// From class MDirectContainer. |
|
1198 |
// CMIDCanvas::MdcContentBounds |
|
1199 |
// Get the bounds of the area that the content of this direct container can |
|
1200 |
// occupy. |
|
1201 |
// Return content rect in screen co-ordinates. Position is stored in |
|
1202 |
// member variable because CCoeControl::PositionRelativeToScreen cannot |
|
1203 |
// be called from another thread. |
|
1204 |
// --------------------------------------------------------------------------- |
|
1205 |
// |
|
1206 |
TRect CMIDCanvas::MdcContentBounds() const |
|
1207 |
{ |
|
1208 |
return TRect(iPositionRelativeToScreen, Size()); |
|
1209 |
} |
|
1210 |
||
1211 |
||
1212 |
// --------------------------------------------------------------------------- |
|
1213 |
// From class MDirectContainer. |
|
1214 |
// CMIDCanvas::MdcItemContentRect |
|
1215 |
// Get the area on the Item on which content can be displayed. |
|
1216 |
// This should only be called when the direct content is displayed on an Item, |
|
1217 |
// so always panic if it is called on Canvas. |
|
1218 |
// --------------------------------------------------------------------------- |
|
1219 |
// |
|
1220 |
void CMIDCanvas::MdcItemContentRect( |
|
1221 |
TRect& /* aContentRect */, |
|
1222 |
TRect& /* aScreenRect */) const |
|
1223 |
{ |
|
1224 |
__ASSERT_DEBUG(EFalse, User::Invariant()); |
|
1225 |
} |
|
1226 |
||
1227 |
||
1228 |
// --------------------------------------------------------------------------- |
|
1229 |
// From class MDirectContainer. |
|
1230 |
// CMIDCanvas::MdcHandlePointerEventL |
|
1231 |
// Allows a control created for direct container content display to pass on |
|
1232 |
// pointer events. |
|
1233 |
// Though this is the leaving function nothing can leave actually. |
|
1234 |
// --------------------------------------------------------------------------- |
|
1235 |
// |
|
1236 |
void CMIDCanvas::MdcHandlePointerEventL(TPointerEvent& /* aPointerEvent */) |
|
1237 |
{ |
|
1238 |
__ASSERT_DEBUG(EFalse, User::Invariant()); |
|
1239 |
} |
|
1240 |
||
1241 |
||
1242 |
// --------------------------------------------------------------------------- |
|
1243 |
// From class MDirectContainer. |
|
1244 |
// CMIDCanvas::MdcFlushContainer |
|
1245 |
// Flush the direct container content. |
|
1246 |
// --------------------------------------------------------------------------- |
|
1247 |
// |
|
1248 |
void CMIDCanvas::MdcFlushContainer(const TRect& aRect) |
|
1249 |
{ |
|
1250 |
// Flush the framebuffer on screen |
|
1251 |
iEnv.ToLcduiObserver().FlushControl(*this, aRect); |
|
1252 |
} |
|
1253 |
||
1254 |
||
1255 |
// --------------------------------------------------------------------------- |
|
1256 |
// From class MDirectContainer. |
|
1257 |
// CMIDCanvas::MdcGetDSAResources |
|
1258 |
// Invokes callback aConsumer->MdcDSAResourcesCallback in LCDUI thread. |
|
1259 |
// --------------------------------------------------------------------------- |
|
1260 |
// |
|
1261 |
void CMIDCanvas::MdcGetDSAResources(MUiEventConsumer& aConsumer) |
|
1262 |
{ |
|
1263 |
// May run in non-LCDUI ES thread |
|
1264 |
// Invoke the callback running in LCDUI ES thread |
|
1265 |
iEnv.ToLcduiObserver().InvokeDSAResourcesCallback(*this, aConsumer); |
|
1266 |
} |
|
1267 |
||
1268 |
||
1269 |
// --------------------------------------------------------------------------- |
|
1270 |
// From class MDirectContainer. |
|
1271 |
// CMIDCanvas::MdcGetUICallback |
|
1272 |
// Invokes callback aConsumer->MdcUICallback in LCDUI thread. |
|
1273 |
// --------------------------------------------------------------------------- |
|
1274 |
// |
|
1275 |
void CMIDCanvas::MdcGetUICallback( |
|
1276 |
MUiEventConsumer& aConsumer, |
|
1277 |
TInt aCallbackId) |
|
1278 |
{ |
|
1279 |
// May run in non-LCDUI ES thread |
|
1280 |
// Invoke the callback running in LCDUI ES thread |
|
1281 |
iEnv.ToLcduiObserver().InvokeUICallback(aConsumer, aCallbackId); |
|
1282 |
} |
|
1283 |
||
1284 |
#ifdef RD_JAVA_NGA_ENABLED |
|
1285 |
// --------------------------------------------------------------------------- |
|
1286 |
// From class MDirectContainer. |
|
1287 |
// CMIDCanvas::MdcNotifyContentAdded |
|
1288 |
// Notification about added direct content, called in LCDUI thread. |
|
1289 |
// Canvas needs to dispose pixel source before MMAPI adds video surface |
|
1290 |
// to canvas window. Pixel source cannot be disposed in MdcAddContent |
|
1291 |
// because it may be called in MMAPI thread. |
|
1292 |
// --------------------------------------------------------------------------- |
|
1293 |
// |
|
1294 |
void CMIDCanvas::MdcNotifyContentAdded() |
|
1295 |
{ |
|
1296 |
// no implementation |
|
1297 |
} |
|
1298 |
#endif // RD_JAVA_NGA_ENABLED |
|
1299 |
||
1300 |
// --------------------------------------------------------------------------- |
|
1301 |
// From class MDirectContainer. |
|
1302 |
// CMIDCanvas::MdcFixUIOrientation(TBool aEnableFix) |
|
1303 |
// --------------------------------------------------------------------------- |
|
1304 |
// |
|
1305 |
void CMIDCanvas::MdcFixUIOrientation(TBool aEnableFix) |
|
1306 |
{ |
|
1307 |
if (aEnableFix) |
|
1308 |
{ |
|
1309 |
iEnv.ToLcduiObserver().InvokeLcduiEvent(*this, EFixUIOrientation); |
|
1310 |
} |
|
1311 |
else |
|
1312 |
{ |
|
1313 |
iEnv.ToLcduiObserver().InvokeLcduiEvent(*this, EUnFixUIOrientation); |
|
1314 |
} |
|
1315 |
} |
|
1316 |
||
1317 |
// --------------------------------------------------------------------------- |
|
1318 |
// From class MMIDLcduiEventConsumer. |
|
1319 |
// CMIDCanvas::HandleLcduiEvent(int aType) |
|
1320 |
// --------------------------------------------------------------------------- |
|
1321 |
// |
|
1322 |
void CMIDCanvas::HandleLcduiEvent(int aType) |
|
1323 |
{ |
|
1324 |
if (!iDisplayable) |
|
1325 |
{ |
|
1326 |
return; |
|
1327 |
} |
|
1328 |
||
1329 |
switch (aType) |
|
1330 |
{ |
|
1331 |
case EFixUIOrientation: |
|
1332 |
iDisplayable->FixOrientation(); |
|
1333 |
break; |
|
1334 |
case EUnFixUIOrientation: |
|
1335 |
iDisplayable->ReleaseOrientation(); |
|
1336 |
break; |
|
1337 |
case EVideoAdded: |
|
1338 |
#ifdef RD_JAVA_NGA_ENABLED |
|
1339 |
DisposePixelSource(); |
|
1340 |
CloseEgl(IsGameCanvas()); |
|
1341 |
#endif // RD_JAVA_NGA_ENABLED |
|
1342 |
break; |
|
1343 |
} |
|
1344 |
} |
|
1345 |
||
1346 |
// --------------------------------------------------------------------------- |
|
1347 |
// From class MMIDMediaKeysListener. |
|
1348 |
// CMIDCanvas::HandleMediaKeyEvent |
|
1349 |
// This method is called when a media key has been pressed. |
|
1350 |
// --------------------------------------------------------------------------- |
|
1351 |
// |
|
1352 |
void CMIDCanvas::HandleMediaKeyEvent(TMIDKeyEvent& aKeyEvent) |
|
1353 |
{ |
|
1354 |
if (PostKeyEvents()) |
|
1355 |
{ |
|
1356 |
DEBUG_INT3( |
|
1357 |
"CMIDCanvas::HandleMediaKeyEvent - PostKeyEvent() - \ |
|
1358 |
JAVA code %d type %d repeats %d", |
|
1359 |
aKeyEvent.iKeyCode, |
|
1360 |
aKeyEvent.iEvents, |
|
1361 |
aKeyEvent.iRepeats); |
|
1362 |
||
1363 |
iEnv.PostKeyEvent(*this, aKeyEvent); |
|
1364 |
} |
|
1365 |
} |
|
1366 |
||
1367 |
||
1368 |
#ifdef RD_TACTILE_FEEDBACK |
|
1369 |
// --------------------------------------------------------------------------- |
|
1370 |
// From class MMIDTactileFeedbackComponent. |
|
1371 |
// CMIDCanvas::UpdateTactileFeedback |
|
1372 |
// Update tactile feedback areas. |
|
1373 |
// --------------------------------------------------------------------------- |
|
1374 |
// |
|
1375 |
void CMIDCanvas::UpdateTactileFeedback() |
|
1376 |
{ |
|
1377 |
TInt areaCount = iTactileFeedback->GetAreasCount(); |
|
1378 |
||
1379 |
for (TInt i = 0; i < areaCount; i++) |
|
1380 |
{ |
|
1381 |
CMIDTactileFeedbackExtension::FeedbackArea* area = |
|
1382 |
iTactileFeedback->GetArea(i); |
|
1383 |
||
1384 |
TRect physicalRect = area->rect; |
|
1385 |
||
1386 |
iTactileFeedback->SetFeedbackArea(area->id, |
|
1387 |
physicalRect, |
|
1388 |
(TInt)area->style); |
|
1389 |
} |
|
1390 |
} |
|
1391 |
||
1392 |
||
1393 |
// --------------------------------------------------------------------------- |
|
1394 |
// From class MMIDTactileFeedbackComponent. |
|
1395 |
// CMIDCanvas::RegisterFeedbackArea |
|
1396 |
// Register feedback area. |
|
1397 |
// --------------------------------------------------------------------------- |
|
1398 |
// |
|
1399 |
void CMIDCanvas::RegisterFeedbackArea(TInt aId, TRect aRect, TInt aStyle) |
|
1400 |
{ |
|
1401 |
iTactileFeedback->RegisterFeedbackArea(aId, aRect, aStyle); |
|
1402 |
} |
|
1403 |
||
1404 |
||
1405 |
// --------------------------------------------------------------------------- |
|
1406 |
// From class MMIDTactileFeedbackComponent. |
|
1407 |
// CMIDCanvas::UnregisterFeedbackArea |
|
1408 |
// Unregister feedback area. |
|
1409 |
// --------------------------------------------------------------------------- |
|
1410 |
// |
|
1411 |
void CMIDCanvas::UnregisterFeedbackArea(TInt aId) |
|
1412 |
{ |
|
1413 |
iTactileFeedback->UnregisterFeedbackArea(aId); |
|
1414 |
} |
|
1415 |
||
1416 |
||
1417 |
// --------------------------------------------------------------------------- |
|
1418 |
// From class MMIDTactileFeedbackComponent. |
|
1419 |
// CMIDCanvas::UnregisterFeedbackForControl |
|
1420 |
// Unregister feedback for the control. |
|
1421 |
// --------------------------------------------------------------------------- |
|
1422 |
// |
|
1423 |
void CMIDCanvas::UnregisterFeedbackForControl() |
|
1424 |
{ |
|
1425 |
iTactileFeedback->UnregisterFeedbackForControl(); |
|
1426 |
} |
|
1427 |
||
1428 |
||
1429 |
// --------------------------------------------------------------------------- |
|
1430 |
// From class MMIDTactileFeedbackComponent. |
|
1431 |
// CMIDCanvas::MoveAreaToFirstPriority |
|
1432 |
// Move area to first priority. |
|
1433 |
// --------------------------------------------------------------------------- |
|
1434 |
// |
|
1435 |
void CMIDCanvas::MoveAreaToFirstPriority(TInt aId) |
|
1436 |
{ |
|
1437 |
iTactileFeedback->MoveAreaToFirstPriority(aId); |
|
1438 |
} |
|
1439 |
#endif // RD_TACTILE_FEEDBACK |
|
1440 |
||
1441 |
// --------------------------------------------------------------------------- |
|
1442 |
// CMIDCanvas::RegisterComponentL |
|
1443 |
// Registers a new custom component to this container. |
|
1444 |
// (other items are commented in the header file) |
|
1445 |
// --------------------------------------------------------------------------- |
|
1446 |
// |
|
1447 |
void CMIDCanvas::RegisterComponentL(MMIDCustomComponent* aComponent) |
|
1448 |
{ |
|
1449 |
DEBUG("CMIDCanvas::RegisterComponentL +"); |
|
1450 |
||
1451 |
if (iCustomComponents.Find(aComponent) == KErrNotFound) |
|
1452 |
{ |
|
1453 |
DEBUG("CMIDCanvas::RegisterComponentL, registering new"); |
|
1454 |
||
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
1455 |
iCustomComponents.Append(aComponent); |
66 | 1456 |
|
1457 |
// Update custom components count in order to improve |
|
1458 |
// the performance when counting components |
|
1459 |
iCustomComponentsControlCount += |
|
1460 |
aComponent->CustomComponentControlCount(); |
|
1461 |
||
1462 |
} |
|
1463 |
||
1464 |
DEBUG("CMIDCanvas::RegisterComponentL -"); |
|
1465 |
} |
|
1466 |
||
1467 |
// --------------------------------------------------------------------------- |
|
1468 |
// CMIDCanvas::UnregisterComponent |
|
1469 |
// Unregisters an existing custom component from this container. |
|
1470 |
// (other items are commented in the header file) |
|
1471 |
// --------------------------------------------------------------------------- |
|
1472 |
// |
|
1473 |
void CMIDCanvas::UnregisterComponent(MMIDCustomComponent* aComponent) |
|
1474 |
{ |
|
1475 |
DEBUG("CMIDCanvas::UnregisterComponent +"); |
|
1476 |
||
1477 |
TInt index = iCustomComponents.Find(aComponent); |
|
1478 |
||
1479 |
if (index != KErrNotFound) |
|
1480 |
{ |
|
1481 |
// Update of iFocusedComponent index. |
|
1482 |
if (index < iFocusedComponent) |
|
1483 |
{ |
|
1484 |
iFocusedComponent--; |
|
1485 |
} |
|
1486 |
else if (index == iFocusedComponent) |
|
1487 |
{ |
|
1488 |
iFocusedComponent = KComponentFocusedNone; |
|
1489 |
} |
|
1490 |
||
1491 |
if ((iPressedComponent) && (iPressedComponent == aComponent)) |
|
1492 |
{ |
|
1493 |
iPressedComponent = NULL; |
|
1494 |
} |
|
1495 |
||
1496 |
iCustomComponents.Remove(index); |
|
1497 |
// Compress the array to keep the object indexes in order. |
|
1498 |
iCustomComponents.Compress(); |
|
1499 |
// Update custom components count in order to improve |
|
1500 |
// the performance when counting components |
|
1501 |
iCustomComponentsControlCount -= |
|
1502 |
aComponent->CustomComponentControlCount(); |
|
1503 |
||
1504 |
// Redraw the whole canvas. |
|
1505 |
DrawDeferred(); |
|
1506 |
} |
|
1507 |
||
1508 |
DEBUG("CMIDCanvas::UnregisterComponent -"); |
|
1509 |
} |
|
1510 |
||
1511 |
// --------------------------------------------------------------------------- |
|
1512 |
// CMIDCanvas::IsFullScreen |
|
1513 |
// (other items are commented in the header file) |
|
1514 |
// --------------------------------------------------------------------------- |
|
1515 |
// |
|
1516 |
TBool CMIDCanvas::IsFullScreen() const |
|
1517 |
{ |
|
1518 |
return iFullScreen; |
|
1519 |
} |
|
1520 |
||
1521 |
#ifdef RD_JAVA_S60_RELEASE_9_2 |
|
1522 |
// --------------------------------------------------------------------------- |
|
1523 |
// CMIDCanvas::GetDisplayable |
|
1524 |
// (other items are commented in the header file) |
|
1525 |
// --------------------------------------------------------------------------- |
|
1526 |
// |
|
1527 |
CMIDDisplayable* CMIDCanvas::GetDisplayable() const |
|
1528 |
{ |
|
1529 |
return iDisplayable; |
|
1530 |
} |
|
1531 |
#endif // RD_JAVA_S60_RELEASE_9_2 |
|
1532 |
||
1533 |
// --------------------------------------------------------------------------- |
|
1534 |
// CMIDCanvas::SetComponentIndexL |
|
1535 |
// Changes the index of the specified custom component. |
|
1536 |
// (other items are commented in the header file) |
|
1537 |
// --------------------------------------------------------------------------- |
|
1538 |
// |
|
1539 |
void CMIDCanvas::SetComponentIndexL( |
|
1540 |
MMIDCustomComponent* aComponent, |
|
1541 |
TInt aNewIndex) |
|
1542 |
{ |
|
1543 |
DEBUG("CMIDCanvas::SetComponentIndexL +"); |
|
1544 |
||
1545 |
// Adjust the index if it is out of bounds. |
|
1546 |
TInt count = iCustomComponents.Count(); |
|
1547 |
if (aNewIndex >= count) |
|
1548 |
{ |
|
1549 |
aNewIndex = count - 1; |
|
1550 |
} |
|
1551 |
||
1552 |
// The index must not be negative. |
|
1553 |
__ASSERT_DEBUG(aNewIndex >= 0, User::Invariant()); |
|
1554 |
||
1555 |
TInt index = iCustomComponents.Find(aComponent); |
|
1556 |
||
1557 |
// Do not adjust the position if there is no need for it |
|
1558 |
// or if the component does not exist in the array. |
|
1559 |
if (index != KErrNotFound && index != aNewIndex) |
|
1560 |
{ |
|
1561 |
// Update index of focused component |
|
1562 |
||
1563 |
if (index == iFocusedComponent) |
|
1564 |
{ |
|
1565 |
iFocusedComponent = aNewIndex; |
|
1566 |
} |
|
1567 |
else if ((iFocusedComponent < index) && (iFocusedComponent >= aNewIndex)) |
|
1568 |
{ |
|
1569 |
iFocusedComponent++; |
|
1570 |
} |
|
1571 |
else if ((iFocusedComponent > index) && (iFocusedComponent <= aNewIndex)) |
|
1572 |
{ |
|
1573 |
iFocusedComponent--; |
|
1574 |
} |
|
1575 |
||
1576 |
// Remove the old index from the components array. |
|
1577 |
iCustomComponents.Remove(index); |
|
1578 |
||
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
1579 |
// Add the component to the new index. Note that the array |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
1580 |
// should contain memory for all the components since |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
1581 |
// Remove should not decrease the memory used by the array |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
1582 |
// Therefore, the following operation is leave-safe and |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
1583 |
// return value is ignored intentionally. |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
1584 |
iCustomComponents.Insert(aComponent, aNewIndex); |
66 | 1585 |
|
1586 |
// Redraw the whole canvas. |
|
1587 |
DrawDeferred(); |
|
1588 |
} |
|
1589 |
||
1590 |
DEBUG("CMIDCanvas::SetComponentIndexL -"); |
|
1591 |
} |
|
1592 |
||
1593 |
// --------------------------------------------------------------------------- |
|
1594 |
// CMIDCanvas::ComponentIndex |
|
1595 |
// Returns the index of the given component in this container. |
|
1596 |
// (other items are commented in the header file) |
|
1597 |
// --------------------------------------------------------------------------- |
|
1598 |
// |
|
1599 |
TInt CMIDCanvas::ComponentIndex(MMIDCustomComponent* aComponent) const |
|
1600 |
{ |
|
1601 |
DEBUG("CMIDCanvas::ComponentIndex"); |
|
1602 |
||
1603 |
return iCustomComponents.Find(aComponent); |
|
1604 |
} |
|
1605 |
||
1606 |
// --------------------------------------------------------------------------- |
|
1607 |
// CMIDCanvas::PostEvent |
|
1608 |
// Post an event to Java side. |
|
1609 |
// --------------------------------------------------------------------------- |
|
1610 |
// |
|
1611 |
TBool CMIDCanvas::PostEvent( |
|
1612 |
TEventType aType, |
|
1613 |
TInt aData0, |
|
1614 |
TInt aData1) const |
|
1615 |
{ |
|
1616 |
return iEnv.PostJavaEvent(const_cast< CMIDCanvas& >(*this), |
|
1617 |
EDisplayable, |
|
1618 |
aType, |
|
1619 |
aData0, |
|
1620 |
aData1, |
|
1621 |
0); |
|
1622 |
} |
|
1623 |
||
1624 |
#ifdef RD_JAVA_NGA_ENABLED |
|
1625 |
||
1626 |
// --------------------------------------------------------------------------- |
|
1627 |
// CMIDCanvas::Update |
|
1628 |
// Update screen from frame buffer. |
|
1629 |
// --------------------------------------------------------------------------- |
|
1630 |
// |
|
1631 |
void CMIDCanvas::UpdateL(const TRect& aRect) |
|
1632 |
{ |
|
1633 |
if (!IsWindowVisible()) |
|
1634 |
{ |
|
1635 |
return; |
|
1636 |
} |
|
1637 |
||
1638 |
// Don't update screen after canvas size has been changed, |
|
1639 |
// if there is no valid content from Java side yet |
|
1640 |
if (iWndUpdate && |
|
1641 |
(iContentSize.iWidth > aRect.Size().iWidth || |
|
1642 |
iContentSize.iHeight > aRect.Size().iHeight)) |
|
1643 |
{ |
|
1644 |
return; |
|
1645 |
} |
|
1646 |
||
1647 |
iWndUpdate = EFalse; |
|
1648 |
||
1649 |
// Drawing Network indicator only when Update is called. |
|
1650 |
if (iFullScreen && iNetworkIndicator) |
|
1651 |
{ |
|
1652 |
iNetworkIndicator->SetDrawIndicator(ETrue); |
|
1653 |
} |
|
1654 |
||
1655 |
if (iDirectContents.Count() == 0) |
|
1656 |
{ |
|
1657 |
// In case direct content content was removed |
|
1658 |
// from canvas, recreate pixel source here |
|
1659 |
if (!iAlfCompositionPixelSource && |
|
1660 |
!IsEglAvailable()) |
|
1661 |
{ |
|
1662 |
InitPixelSourceL(); |
|
1663 |
} |
|
1664 |
DrawWindowNgaL(aRect); |
|
1665 |
} |
|
1666 |
else |
|
1667 |
{ |
|
1668 |
// Must draw via CCoeControl framework |
|
1669 |
if (iFullScreen && iScalingOn) |
|
1670 |
{ |
|
1671 |
DrawNow(iViewRect); |
|
1672 |
} |
|
1673 |
else |
|
1674 |
{ |
|
1675 |
DrawNow(aRect); |
|
1676 |
} |
|
1677 |
||
1678 |
iCoeEnv->WsSession().Finish(); |
|
1679 |
||
1680 |
if (iFirstPaintState == EFirstPaintInitiated || |
|
1681 |
iFirstPaintState == EFirstPaintPrepared) |
|
1682 |
{ |
|
1683 |
// NGA is not used, StartScreen can be informed now |
|
1684 |
if (iForeground) |
|
1685 |
{ |
|
1686 |
// The canvas is current, therefore we can flush |
|
1687 |
// the graphics and take the start screen snapshot. |
|
1688 |
iFirstPaintState = EFirstPaintOccurred; |
|
1689 |
java::ui::CoreUiAvkonLcdui::getInstance().getJavaUiAppUi()->stopStartScreen(); |
|
1690 |
} |
|
1691 |
} |
|
1692 |
} |
|
1693 |
||
1694 |
} |
|
1695 |
||
1696 |
#else // !RD_JAVA_NGA_ENABLED |
|
1697 |
// --------------------------------------------------------------------------- |
|
1698 |
// CMIDCanvas::Update |
|
1699 |
// Update screen from frame buffer. |
|
1700 |
// --------------------------------------------------------------------------- |
|
1701 |
// |
|
1702 |
void CMIDCanvas::Update(const TRect& aRect) |
|
1703 |
{ |
|
1704 |
DEBUG("- CMIDCanvas::Update"); |
|
1705 |
||
1706 |
#ifdef CANVAS_DOUBLE_BUFFER |
|
1707 |
if (IsVisible()) |
|
1708 |
{ |
|
1709 |
// Drawing Network indicator only when Update is called. |
|
1710 |
if (iFullScreen && iNetworkIndicator) |
|
1711 |
{ |
|
1712 |
iNetworkIndicator->SetDrawIndicator(ETrue); |
|
1713 |
} |
|
1714 |
||
1715 |
#ifdef CANVAS_DIRECT_ACCESS |
|
1716 |
// Check if some direct screen content is drawn. |
|
1717 |
if (iDirectContents.Count() > 0) |
|
1718 |
{ |
|
1719 |
// There is some direct screen content drawn, DSA is not free for |
|
1720 |
// us at the moment. |
|
1721 |
DrawNow(aRect); |
|
1722 |
} |
|
1723 |
else |
|
1724 |
{ |
|
1725 |
// No direct screen content is drawn, so we can try to use DSA. |
|
1726 |
StartDirectAccess(); |
|
1727 |
||
1728 |
if (iDirectGc) |
|
1729 |
{ |
|
1730 |
// DSA is ready to use, draw directly. |
|
1731 |
DrawDirect(aRect); |
|
1732 |
} |
|
1733 |
else |
|
1734 |
#endif // CANVAS_DIRECT_ACCESS |
|
1735 |
{ |
|
1736 |
ActivateGc(); |
|
1737 |
DrawWindow(aRect); |
|
1738 |
DeactivateGc(); |
|
1739 |
} |
|
1740 |
#ifdef CANVAS_DIRECT_ACCESS |
|
1741 |
} |
|
1742 |
#endif // CANVAS_DIRECT_ACCESS |
|
1743 |
||
1744 |
// This is needed to avoid artifacting after orientation switch. |
|
1745 |
// It is called once after orientation change. |
|
1746 |
if (iWndUpdate) |
|
1747 |
{ |
|
1748 |
iWndUpdate = EFalse; |
|
1749 |
} |
|
1750 |
} |
|
1751 |
#endif // CANVAS_DOUBLE_BUFFER |
|
1752 |
||
1753 |
DEBUG("+ CMIDCanvas::Update"); |
|
1754 |
} |
|
1755 |
||
1756 |
#endif // RD_JAVA_NGA_ENABLED |
|
1757 |
||
1758 |
// --------------------------------------------------------------------------- |
|
1759 |
// CMIDCanvas::PrepareDraw |
|
1760 |
// Prepare drawing. Used in DrawWindow and DrawDirect. |
|
1761 |
// aWindowRect is in bitmap coords. |
|
1762 |
// --------------------------------------------------------------------------- |
|
1763 |
// |
|
1764 |
inline void CMIDCanvas::PrepareDraw( |
|
1765 |
CGraphicsContext& aGc, TRect& aWinRect) const |
|
1766 |
{ |
|
1767 |
const TRect rect = Rect(); |
|
1768 |
#ifdef RD_JAVA_NGA_ENABLED |
|
1769 |
if (iDirectContents.Count() > 0) |
|
1770 |
{ |
|
1771 |
||
1772 |
// Content may be centered in which case we need to clear the background. |
|
1773 |
if (rect != iViewRect) |
|
1774 |
{ |
|
1775 |
// Clear background with black if centered. |
|
1776 |
aGc.SetBrushColor(KRgbBlack); |
|
1777 |
aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1778 |
||
1779 |
DrawUtils::ClearBetweenRects(aGc, rect, iViewRect); |
|
1780 |
} |
|
1781 |
} |
|
1782 |
#else |
|
1783 |
// Content may be centered in which case we need to clear the background. |
|
1784 |
if (rect != iViewRect) |
|
1785 |
{ |
|
1786 |
// Clear background with black if centered. |
|
1787 |
aGc.SetBrushColor(KRgbBlack); |
|
1788 |
aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1789 |
||
1790 |
DrawUtils::ClearBetweenRects(aGc, rect, iViewRect); |
|
1791 |
} |
|
1792 |
#endif // RD_JAVA_NGA_ENABLED |
|
1793 |
||
1794 |
if (iFullScreen && iNetworkIndicator) |
|
1795 |
{ |
|
1796 |
// Network indicator or call indicator is drawn to the off-screen |
|
1797 |
// buffer if connection is open. |
|
1798 |
iNetworkIndicator->DrawNetworkIndicator( |
|
1799 |
*iFrameContext, aWinRect, iViewRect); |
|
1800 |
} |
|
1801 |
||
1802 |
if (iViewRect.Size() == iContentSize) |
|
1803 |
{ |
|
1804 |
// Transform the source rect to window coords. |
|
1805 |
aWinRect.Move(iViewRect.iTl); |
|
1806 |
||
1807 |
// Clip to viewport. |
|
1808 |
aWinRect.Intersection(iViewRect); |
|
1809 |
} |
|
1810 |
else |
|
1811 |
{ |
|
1812 |
aWinRect = iViewRect; |
|
1813 |
} |
|
1814 |
} |
|
1815 |
||
1816 |
||
1817 |
#ifdef RD_JAVA_NGA_ENABLED |
|
1818 |
// --------------------------------------------------------------------------- |
|
1819 |
// CMIDCanvas::DrawWindowNgaL |
|
1820 |
// Draw using pixel source of EGL surface depending on what canvas content |
|
1821 |
// has been drawn. |
|
1822 |
// --------------------------------------------------------------------------- |
|
1823 |
// |
|
1824 |
void CMIDCanvas::DrawWindowNgaL(const TRect& aRect) |
|
1825 |
{ |
|
1826 |
ASSERT(IsEglAvailable() || iAlfCompositionPixelSource); |
|
1827 |
||
1828 |
if (iFullScreen && iNetworkIndicator) |
|
1829 |
{ |
|
1830 |
TRect windowRect(aRect); |
|
1831 |
iNetworkIndicator->DrawNetworkIndicator( |
|
1832 |
*iFrameContext, windowRect, iViewRect); |
|
1833 |
} |
|
1834 |
||
1835 |
if (!IsEglAvailable()) |
|
1836 |
{ |
|
1837 |
// No M3G content, use pixel source |
|
1838 |
ActivatePixelSourceL(EFalse); |
|
1839 |
DEBUG("CMIDCanvas::Draw - Pixel Source activated"); |
|
1840 |
} |
|
1841 |
else // M3G content, use EGL surface |
|
1842 |
{ |
|
1843 |
if (iScalingOn && iFullScreen) |
|
1844 |
{ |
|
1845 |
SetCurrentEglType(EEglPbuffer); |
|
1846 |
BlitFrameBufferPixels(); |
|
1847 |
SetCurrentEglType(EEglWindow); |
|
1848 |
if (iWndUpdate) |
|
1849 |
{ |
|
1850 |
DEBUG("CMIDCanvas::DrawWindowNgaL() - clearing window surface"); |
|
1851 |
ClearEglSurface(EEglWindow); |
|
1852 |
} |
|
1853 |
BlitPBufferScaledToWindowSurface(); |
|
1854 |
} |
|
1855 |
else |
|
1856 |
{ |
|
1857 |
SetCurrentEglType(EEglWindow); |
|
1858 |
BlitFrameBufferPixels(); |
|
1859 |
} |
|
1860 |
||
1861 |
if (eglSwapBuffers(iEglDisplay, iEglWindowSurface) == EGL_FALSE) |
|
1862 |
{ |
|
1863 |
ELOG1(EJavaUI, "eglSwapBuffers() failed, eglError=%d", eglGetError()); |
|
1864 |
ASSERT(EFalse); |
|
1865 |
} |
|
1866 |
||
1867 |
SetCurrentEglType(EEglNone); |
|
1868 |
||
1869 |
// Invalidates window so that wserv does not |
|
1870 |
// draw window content on top our EGL surface. |
|
1871 |
// This is needed only once when starting to use EGL surface. |
|
1872 |
if (iM3GStart) |
|
1873 |
{ |
|
1874 |
DEBUG("CMIDCanvas::DrawWindow - invalidate"); |
|
1875 |
Window().Invalidate(); |
|
1876 |
iM3GStart = EFalse; |
|
1877 |
} |
|
1878 |
||
1879 |
if (iFirstPaintState != EFirstPaintOccurred) |
|
1880 |
{ |
|
1881 |
iFirstPaintState = EFirstPaintOccurred; |
|
1882 |
java::ui::CoreUiAvkonLcdui::getInstance().getJavaUiAppUi()->stopStartScreen(); |
|
1883 |
} |
|
1884 |
} |
|
1885 |
} |
|
1886 |
#endif // RD_JAVA_NGA_ENABLED |
|
1887 |
||
1888 |
||
1889 |
#ifdef CANVAS_DOUBLE_BUFFER |
|
1890 |
// --------------------------------------------------------------------------- |
|
1891 |
// CMIDCanvas::DrawWindow |
|
1892 |
// Draw through Window server using native frame buffer. |
|
1893 |
// --------------------------------------------------------------------------- |
|
1894 |
// |
|
1895 |
void CMIDCanvas::DrawWindow(const TRect& aRect) const |
|
1896 |
{ |
|
1897 |
DEBUG("CMIDCanvas::DrawWindow ++"); |
|
1898 |
ASSERT(iFrameBuffer); |
|
1899 |
||
1900 |
CWindowGc& gc = SystemGc(); |
|
1901 |
||
1902 |
// If EColor16MA display mode is used, graphics context needs to set its |
|
1903 |
// draw mode to EDrawModeWriteAlpha for just to copy an alpha channel and |
|
1904 |
// not to do any blending. |
|
1905 |
if (iFrameBuffer->DisplayMode() == EColor16MA) |
|
1906 |
{ |
|
1907 |
gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); |
|
1908 |
} |
|
1909 |
||
1910 |
TRect windowRect(aRect); |
|
1911 |
PrepareDraw(gc, windowRect); |
|
1912 |
||
1913 |
// Check if Canvas scaling is used. |
|
1914 |
if (iViewRect.Size() == iContentSize) |
|
1915 |
{ |
|
1916 |
DEBUG("DrawWindow - Not scaled - BitBlt"); |
|
1917 |
gc.BitBlt(windowRect.iTl, iFrameBuffer, windowRect); |
|
1918 |
} |
|
1919 |
||
1920 |
#ifdef RD_JAVA_NGA_ENABLED |
|
1921 |
else if (IsDownScaling(iContentSize, iViewRect, iM3GContent)) |
|
1922 |
#else |
|
1923 |
else if (IsDownScaling(iContentSize, iViewRect)) |
|
1924 |
#endif //RD_JAVA_NGA_ENABLED |
|
1925 |
{ |
|
1926 |
DEBUG("DrawWindow - Downscaling - BitBlt"); |
|
1927 |
gc.BitBlt(windowRect.iTl, iFrameBuffer, windowRect.Size()); |
|
1928 |
} |
|
1929 |
// Upscaling |
|
1930 |
else if (iScaler) |
|
1931 |
{ |
|
1932 |
iFrameBuffer->LockHeap(); |
|
1933 |
TUint32* pixelData = iFrameBuffer->DataAddress(); |
|
1934 |
// Scale the framebuffer content. |
|
1935 |
CFbsBitmap* map = iScaler->Process( |
|
1936 |
iFrameBuffer->DisplayMode(), |
|
1937 |
pixelData, |
|
1938 |
iContentSize.iWidth, |
|
1939 |
iContentSize.iHeight, |
|
1940 |
iFrameBuffer->SizeInPixels().iWidth - iContentSize.iWidth, |
|
1941 |
iViewRect.Width(), |
|
1942 |
iViewRect.Height()); |
|
1943 |
||
1944 |
iFrameBuffer->UnlockHeap(); |
|
1945 |
||
1946 |
if (map) |
|
1947 |
{ |
|
1948 |
DEBUG("DrawWindow - Upscaling - BitBlt - map ok"); |
|
1949 |
gc.BitBlt(windowRect.iTl, map, windowRect.Size()); |
|
1950 |
} |
|
1951 |
else |
|
1952 |
{ |
|
1953 |
DEBUG("DrawWindow - Upscaling - DrawBitmap - no map"); |
|
1954 |
gc.DrawBitmap(windowRect, iFrameBuffer, iContentSize); |
|
1955 |
} |
|
1956 |
} |
|
1957 |
DEBUG("CMIDCanvas::DrawWindow --"); |
|
1958 |
} |
|
1959 |
#endif // CANVAS_DOUBLE_BUFFER |
|
1960 |
||
1961 |
||
1962 |
#ifdef CANVAS_DIRECT_ACCESS |
|
1963 |
// --------------------------------------------------------------------------- |
|
1964 |
// CMIDCanvas::StartDirectAccess |
|
1965 |
// Start Direct Screen Access. |
|
1966 |
// --------------------------------------------------------------------------- |
|
1967 |
// |
|
1968 |
void CMIDCanvas::StartDirectAccess() |
|
1969 |
{ |
|
1970 |
// If DSA is not enabled or paused, or direct GC already exists just get |
|
1971 |
// out of here. |
|
1972 |
if (!DirectEnabled() || DirectPaused() || iDirectGc) |
|
1973 |
{ |
|
1974 |
return; |
|
1975 |
} |
|
1976 |
||
1977 |
CCoeAppUi& appUi = *static_cast< CCoeAppUi* >(ControlEnv()->AppUi()); |
|
1978 |
||
1979 |
if (appUi.IsDisplayingMenuOrDialog()) |
|
1980 |
{ |
|
1981 |
return; |
|
1982 |
} |
|
1983 |
||
1984 |
TRAPD(err, RestartL()); |
|
1985 |
||
1986 |
if (KErrNone != err) |
|
1987 |
{ |
|
1988 |
StopDirectAccess(); |
|
1989 |
} |
|
1990 |
else |
|
1991 |
{ |
|
1992 |
if (iDcDsaToStart && iDirectGc) |
|
1993 |
{ |
|
1994 |
// Resume DSA for all direct contents |
|
1995 |
iDcDsaToStart = EFalse; |
|
1996 |
TInt contentsCount(iDirectContents.Count()); |
|
1997 |
||
1998 |
for (TInt j = 0; j < contentsCount; j++) |
|
1999 |
{ |
|
2000 |
iDirectContents[j]->MdcResumeDSA(); |
|
2001 |
} |
|
2002 |
} |
|
2003 |
} |
|
2004 |
} |
|
2005 |
||
2006 |
||
2007 |
// --------------------------------------------------------------------------- |
|
2008 |
// CMIDCanvas::StopDirectAccess |
|
2009 |
// Stop Direct Screen Access. |
|
2010 |
// --------------------------------------------------------------------------- |
|
2011 |
// |
|
2012 |
void CMIDCanvas::StopDirectAccess() |
|
2013 |
{ |
|
2014 |
iDirectGc = NULL; |
|
2015 |
if (!iDcDsaToStart) |
|
2016 |
{ |
|
2017 |
// Abort direct DSA for all direct contents |
|
2018 |
||
2019 |
TInt contentsCount(iDirectContents.Count()); |
|
2020 |
||
2021 |
if (contentsCount > 0) |
|
2022 |
{ |
|
2023 |
iDcDsaToStart = ETrue; |
|
2024 |
} |
|
2025 |
||
2026 |
for (TInt j = 0; j < contentsCount; j++) |
|
2027 |
{ |
|
2028 |
iDirectContents[j]->MdcAbortDSA(); |
|
2029 |
} |
|
2030 |
} |
|
2031 |
||
2032 |
if (iDirectAccess) |
|
2033 |
{ |
|
2034 |
iDirectAccess->Cancel(); |
|
2035 |
} |
|
2036 |
} |
|
2037 |
||
2038 |
||
2039 |
// --------------------------------------------------------------------------- |
|
2040 |
// CMIDCanvas::RestartL |
|
2041 |
// Restart Direct Screen Access. |
|
2042 |
// --------------------------------------------------------------------------- |
|
2043 |
// |
|
2044 |
void CMIDCanvas::RestartL() |
|
2045 |
{ |
|
2046 |
ASSERT(DirectEnabled()); |
|
2047 |
ASSERT(iDirectAccess); |
|
2048 |
||
2049 |
if (!iDirectAccess->IsActive()) |
|
2050 |
{ |
|
2051 |
iDirectAccess->StartL(); |
|
2052 |
} |
|
2053 |
||
2054 |
iDirectGc = NULL; |
|
2055 |
||
2056 |
if (iDirectAccess->DrawingRegion()->Count() == 1) |
|
2057 |
{ |
|
2058 |
// Check that the drawing region is fully visibile (not covered) |
|
2059 |
TRect drawableRect((*iDirectAccess->DrawingRegion())[0]); |
|
2060 |
TRect canvasRect(PositionRelativeToScreen(), Size()); |
|
2061 |
||
2062 |
drawableRect.Intersection(canvasRect); |
|
2063 |
||
2064 |
// Check that the drawing region has the proper size |
|
2065 |
if (drawableRect == canvasRect) |
|
2066 |
{ |
|
2067 |
// Prepare context for actual drawing |
|
2068 |
iDirectGc = iDirectAccess->Gc(); |
|
2069 |
||
2070 |
// Direct draw is using only BitBlt and DrawBitmap so we can |
|
2071 |
// always use EDrawModeWriteAlpha draw mode to optimize drawing |
|
2072 |
// process. If EColor16MA display mode is used, graphics context |
|
2073 |
// needs to set its draw mode to EDrawModeWriteAlpha to just copy |
|
2074 |
// an alpha channel and not do any blending. |
|
2075 |
if (iFrameBuffer->DisplayMode() == EColor16MA) |
|
2076 |
{ |
|
2077 |
iDirectGc->SetDrawMode( |
|
2078 |
CGraphicsContext::EDrawModeWriteAlpha); |
|
2079 |
} |
|
2080 |
} |
|
2081 |
} |
|
2082 |
} |
|
2083 |
||
2084 |
||
2085 |
// --------------------------------------------------------------------------- |
|
2086 |
// CMIDCanvas::DrawDirect |
|
2087 |
// Draw using Direct Screen Access. |
|
2088 |
// aRect is in framebuffer coords. |
|
2089 |
// --------------------------------------------------------------------------- |
|
2090 |
// |
|
2091 |
void CMIDCanvas::DrawDirect(const TRect& aRect) const |
|
2092 |
{ |
|
2093 |
DEBUG("+ CMIDCanvas::DrawDirect"); |
|
2094 |
||
2095 |
ASSERT(DirectEnabled()); |
|
2096 |
ASSERT(iDirectGc); |
|
2097 |
ASSERT(iDirectAccess); |
|
2098 |
ASSERT(iFrameBuffer); |
|
2099 |
||
2100 |
// Visible region in screen coordinates. Should only contain a single clip |
|
2101 |
// rect otherwise direct access should have aborted. |
|
2102 |
const RRegion& visibleRegion = *(iDirectAccess->DrawingRegion()); |
|
2103 |
||
2104 |
ASSERT(visibleRegion.Count() == 1); |
|
2105 |
||
2106 |
TRect windowRect(aRect); |
|
2107 |
PrepareDraw(*iDirectGc, windowRect); |
|
2108 |
||
2109 |
// Check if Canvas scaling is used. |
|
2110 |
if (iViewRect == iContentSize) |
|
2111 |
{ |
|
2112 |
// No scaling, plain draw. |
|
2113 |
DEBUG("DrawDirect - NotScaled"); |
|
2114 |
iDirectGc->BitBlt(windowRect.iTl, iFrameBuffer, windowRect); |
|
2115 |
} |
|
2116 |
else if (IsDownScaling(iContentSize, iViewRect)) |
|
2117 |
{ |
|
2118 |
DEBUG("DrawDirect - Downscaling"); |
|
2119 |
iDirectGc->BitBlt(windowRect.iTl, iFrameBuffer, windowRect.Size()); |
|
2120 |
} |
|
2121 |
// Upscaling |
|
2122 |
else if (iScaler) |
|
2123 |
{ |
|
2124 |
iFrameBuffer->LockHeap(); |
|
2125 |
TUint32* pixelData = iFrameBuffer->DataAddress(); |
|
2126 |
||
2127 |
// Scale the framebuffer content. |
|
2128 |
CFbsBitmap* map = iScaler->Process( |
|
2129 |
iFrameBuffer->DisplayMode(), |
|
2130 |
pixelData, |
|
2131 |
iContentSize.iWidth, |
|
2132 |
iContentSize.iHeight, |
|
2133 |
iFrameBuffer->SizeInPixels().iWidth - iContentSize.iWidth, |
|
2134 |
iViewRect.Width(), |
|
2135 |
iViewRect.Height()); |
|
2136 |
||
2137 |
iFrameBuffer->UnlockHeap(); |
|
2138 |
||
2139 |
if (map) |
|
2140 |
{ |
|
2141 |
DEBUG("DrawDirect - Upscaling - BitBlt - map ok"); |
|
2142 |
iDirectGc->BitBlt(windowRect.iTl, map, windowRect.Size()); |
|
2143 |
} |
|
2144 |
else |
|
2145 |
{ |
|
2146 |
DEBUG("DrawDirect - Upscaling - DrawBitmap - no map"); |
|
2147 |
iDirectGc->DrawBitmap(windowRect, iFrameBuffer, iContentSize); |
|
2148 |
} |
|
2149 |
} |
|
2150 |
||
2151 |
if (UpdateRequired()) |
|
2152 |
{ |
|
2153 |
windowRect.Move(PositionRelativeToScreen()); |
|
2154 |
windowRect.Intersection(visibleRegion.RectangleList()[0]); |
|
2155 |
||
2156 |
// Direct screen drawing does not show up on some devices unless the |
|
2157 |
// screen device Update() method is called. |
|
2158 |
iUpdateRegion.Clear(); |
|
2159 |
iUpdateRegion.AddRect(windowRect); |
|
2160 |
iDirectAccess->ScreenDevice()->Update(iUpdateRegion); |
|
2161 |
} |
|
2162 |
||
2163 |
DEBUG("- CMIDCanvas::DrawDirect"); |
|
2164 |
} |
|
2165 |
#endif //CANVAS_DIRECT_ACCESS |
|
2166 |
||
2167 |
||
2168 |
// --------------------------------------------------------------------------- |
|
2169 |
// From class CCoeControl. |
|
2170 |
// CMIDCanvas::HandleResourceChange |
|
2171 |
// Resource change handling. |
|
2172 |
// --------------------------------------------------------------------------- |
|
2173 |
// |
|
2174 |
void CMIDCanvas::HandleResourceChange(TInt aType) |
|
2175 |
{ |
|
2176 |
#ifdef RD_JAVA_S60_RELEASE_9_2 |
|
2177 |
if ((aType == KAknSplitInputEnabled) | |
|
2178 |
(aType == KAknSplitInputDisabled)) |
|
2179 |
{ |
|
2180 |
// We need inform CanvasItems that partial virtual keyboard |
|
2181 |
// is open or closed. This is needed only when partial VKB changes |
|
2182 |
// its state. |
|
2183 |
TBool partialVKBOpen = (aType == KAknSplitInputEnabled); |
|
2184 |
if (partialVKBOpen != iPartialVKBOpen) |
|
2185 |
{ |
|
2186 |
// setting member variable |
|
2187 |
iPartialVKBOpen = partialVKBOpen; |
|
2188 |
||
2189 |
// First we need inform focused item, after other. |
|
2190 |
iCustomComponents[iFocusedComponent]->HandleResourceChange(aType); |
|
2191 |
for (int i = 0; i < iCustomComponents.Count(); i++) |
|
2192 |
{ |
|
2193 |
if (i != iFocusedComponent) |
|
2194 |
{ |
|
2195 |
iCustomComponents[i]->HandleResourceChange(aType); |
|
2196 |
} |
|
2197 |
} |
|
2198 |
} |
|
2199 |
} |
|
2200 |
else if (aType == KEikInputLanguageChange) |
|
2201 |
#else |
|
2202 |
if (aType == KEikInputLanguageChange) |
|
2203 |
#endif // RD_JAVA_S60_RELEASE_9_2 |
|
2204 |
{ |
|
2205 |
// We need inform TextEditor that input language is changed. |
|
2206 |
if ((iFocusedComponent != KComponentFocusedNone) && |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
2207 |
(iFocusedComponent < iCustomComponents.Count())) |
66 | 2208 |
{ |
2209 |
iCustomComponents[iFocusedComponent]-> |
|
2210 |
CustomComponentControl(KComponentMainControl)-> |
|
2211 |
HandleResourceChange(aType); |
|
2212 |
} |
|
2213 |
||
2214 |
} |
|
2215 |
else if (aType == KEikDynamicLayoutVariantSwitch) |
|
2216 |
{ |
|
2217 |
// If orientation change is done, |
|
2218 |
// then we have to inform all components about it. |
|
2219 |
if (iFullScreen && iScalingOn) |
|
2220 |
{ |
|
2221 |
for (int i = 0; i < iCustomComponents.Count(); i++) |
|
2222 |
{ |
|
2223 |
iCustomComponents[i]->HandleResourceChange(aType); |
|
2224 |
} |
|
2225 |
} |
|
2226 |
} |
|
2227 |
else if ((aType == KEikMessageUnfadeWindows) || |
|
2228 |
(aType == KEikMessageFadeAllWindows)) |
|
2229 |
{ |
|
2230 |
iLastFadeMessage = aType; |
|
2231 |
} |
|
2232 |
else if ((aType == KEikMessageWindowsFadeChange) && |
|
2233 |
((iLastFadeMessage == KEikMessageUnfadeWindows) || |
|
2234 |
(iLastFadeMessage == KEikMessageFadeAllWindows))) |
|
2235 |
{ |
|
2236 |
TInt contentsCount(iDirectContents.Count()); |
|
2237 |
||
2238 |
switch (iLastFadeMessage) |
|
2239 |
{ |
|
2240 |
case KEikMessageUnfadeWindows: |
|
2241 |
iRestoreContentWhenUnfaded = EFalse; |
|
2242 |
||
2243 |
#ifdef CANVAS_DIRECT_ACCESS |
|
2244 |
ResumeDirectAccess(); |
|
2245 |
#endif // CANVAS_DIRECT_ACCESS |
|
2246 |
||
2247 |
for (TInt j = 0; j < contentsCount; j++) |
|
2248 |
{ |
|
2249 |
iDirectContents[j]->MdcContainerVisibilityChanged(ETrue); |
|
2250 |
} |
|
2251 |
break; |
|
2252 |
||
2253 |
case KEikMessageFadeAllWindows: |
|
2254 |
iRestoreContentWhenUnfaded = ETrue; |
|
2255 |
||
2256 |
#ifdef CANVAS_DIRECT_ACCESS |
|
2257 |
PauseDirectAccess(); |
|
2258 |
#endif // CANVAS_DIRECT_ACCESS |
|
2259 |
||
2260 |
for (TInt j = 0; j < contentsCount; j++) |
|
2261 |
{ |
|
2262 |
iDirectContents[j]->MdcContainerVisibilityChanged(EFalse); |
|
2263 |
} |
|
2264 |
break; |
|
2265 |
} |
|
2266 |
iLastFadeMessage = 0; |
|
2267 |
} |
|
2268 |
} |
|
2269 |
||
2270 |
#ifdef RD_SCALABLE_UI_V2 |
|
2271 |
// --------------------------------------------------------------------------- |
|
2272 |
// CMIDCanvas::HandlePointerEventInControlsL |
|
2273 |
// Pointer events handling in controls. |
|
2274 |
// --------------------------------------------------------------------------- |
|
2275 |
// |
|
2276 |
TBool CMIDCanvas::HandlePointerEventInControlsL( |
|
2277 |
const TPointerEvent& aPointerEvent) |
|
2278 |
{ |
|
2279 |
TBool inControl = EFalse; |
|
2280 |
||
2281 |
switch (aPointerEvent.iType) |
|
2282 |
{ |
|
2283 |
case TPointerEvent::EButton1Down: |
|
2284 |
case TPointerEvent::EButton2Down: |
|
2285 |
case TPointerEvent::EButton3Down: |
|
2286 |
// Pointer pressed |
|
2287 |
if ((iFocusedComponent > KComponentFocusedNone)&& |
|
2288 |
(iFocusedComponent < iCustomComponents.Count()) && |
|
2289 |
(PointerEventInControl(iCustomComponents[iFocusedComponent], |
|
2290 |
aPointerEvent.iPosition))) |
|
2291 |
{ |
|
2292 |
// Store the control for receiving pointer events until release |
|
2293 |
iPressedComponent = iCustomComponents[iFocusedComponent]; |
|
2294 |
// Pass the pointer event |
|
2295 |
iPressedComponent->CustomComponentControl |
|
2296 |
(KComponentMainControl)->HandlePointerEventL(aPointerEvent); |
|
2297 |
inControl = ETrue; |
|
2298 |
} |
|
2299 |
break; |
|
2300 |
case TPointerEvent::EButton1Up: |
|
2301 |
case TPointerEvent::EButton2Up: |
|
2302 |
case TPointerEvent::EButton3Up: |
|
2303 |
// Pointer released |
|
2304 |
if ((iPressedComponent) && (PointerEventInControl(iPressedComponent, |
|
2305 |
aPointerEvent.iPosition))) |
|
2306 |
{ |
|
2307 |
// Pass the pointer event |
|
2308 |
iPressedComponent->CustomComponentControl |
|
2309 |
(KComponentMainControl)->HandlePointerEventL(aPointerEvent); |
|
2310 |
iPressedComponent = NULL; |
|
2311 |
inControl = ETrue; |
|
2312 |
} |
|
2313 |
break; |
|
2314 |
case TPointerEvent::EDrag: |
|
2315 |
if (iPressedComponent) |
|
2316 |
{ |
|
2317 |
iPressedComponent->ProcessPointerEventL(aPointerEvent); |
|
2318 |
inControl = ETrue; |
|
2319 |
} |
|
2320 |
break; |
|
2321 |
default: |
|
2322 |
break; |
|
2323 |
} |
|
2324 |
return inControl; |
|
2325 |
} |
|
2326 |
||
2327 |
// --------------------------------------------------------------------------- |
|
2328 |
// CMIDCanvas::PointerEventInControl |
|
2329 |
// Pointer events checking. |
|
2330 |
// --------------------------------------------------------------------------- |
|
2331 |
// |
|
2332 |
TBool CMIDCanvas::PointerEventInControl(MMIDCustomComponent* aControl, |
|
2333 |
TPoint aPoint) |
|
2334 |
{ |
|
2335 |
TBool inControl = EFalse; |
|
2336 |
TInt compoundCount = aControl->CustomComponentControlCount(); |
|
2337 |
for (int j = 0; j < compoundCount; j++) |
|
2338 |
{ |
|
2339 |
// Check if the pointer event position is in visible control's |
|
2340 |
// area. |
|
2341 |
if (aControl->CustomComponentControl(j)->IsVisible()) |
|
2342 |
{ |
|
2343 |
inControl |= aControl->CustomComponentControl(j)-> |
|
2344 |
Rect().Contains(aPoint); |
|
2345 |
} |
|
2346 |
} |
|
2347 |
return inControl; |
|
2348 |
} |
|
2349 |
||
2350 |
// --------------------------------------------------------------------------- |
|
2351 |
// From class CCoeControl. |
|
2352 |
// CMIDCanvas::HandlePointerEventL |
|
2353 |
// Pointer events handling. |
|
2354 |
// --------------------------------------------------------------------------- |
|
2355 |
// |
|
2356 |
void CMIDCanvas::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
2357 |
{ |
|
2358 |
if (AknLayoutUtils::PenEnabled()) |
|
2359 |
{ |
|
2360 |
TPoint point = aPointerEvent.iPosition; |
|
2361 |
TInt count = iCustomComponents.Count(); |
|
2362 |
TBool consumed = EFalse; |
|
2363 |
||
2364 |
// Long tap not allowed in full screen mode. |
|
2365 |
if (!iFullScreen) |
|
2366 |
{ |
|
2367 |
consumed = iDisplayable->TryDetectLongTapL(aPointerEvent); |
|
2368 |
} |
|
2369 |
||
2370 |
if (!consumed && (iFocusedComponent != KComponentFocusedNone) && |
|
2371 |
(iFocusedComponent < iCustomComponents.Count()) && |
|
2372 |
(iCustomComponents[iFocusedComponent]->IsTouchEnabled())) |
|
2373 |
{ |
|
2374 |
consumed = HandlePointerEventInControlsL(aPointerEvent); |
|
2375 |
} |
|
2376 |
||
2377 |
if (!consumed) |
|
2378 |
{ |
|
2379 |
// Points are counted from 0 to width - 1, resp. height -1, |
|
2380 |
// so we compute maxima for points coordinates based |
|
2381 |
// on native view size and java canvas size. |
|
2382 |
TSize nativeMaxCoords = iViewRect.Size() - TSize(1, 1); |
|
2383 |
TSize javaMaxCoords = iContentSize - TSize(1, 1); |
|
2384 |
||
2385 |
// Transform point to content coordinates. |
|
2386 |
// |
|
2387 |
// iViewRect.iTl -> (0, 0) |
|
2388 |
// iViewRect.iBr - TSize(1, 1) -> (iContentSize.iWidth - 1, |
|
2389 |
// iContentSize.iHeight - 1) |
|
2390 |
point -= iViewRect.iTl; |
|
2391 |
||
2392 |
if (javaMaxCoords != nativeMaxCoords) |
|
2393 |
{ |
|
2394 |
point.iX = (point.iX * javaMaxCoords.iWidth) / |
|
2395 |
nativeMaxCoords.iWidth; |
|
2396 |
point.iY = (point.iY * javaMaxCoords.iHeight) / |
|
2397 |
nativeMaxCoords.iHeight; |
|
2398 |
} |
|
2399 |
||
2400 |
TEventType type; |
|
2401 |
TTime now; |
|
2402 |
||
2403 |
switch (aPointerEvent.iType) |
|
2404 |
{ |
|
2405 |
case TPointerEvent::EButton1Down: |
|
2406 |
case TPointerEvent::EButton2Down: |
|
2407 |
case TPointerEvent::EButton3Down: |
|
2408 |
type = EPointerPressed; |
|
2409 |
iPointerPressedCoordinates = TPoint(point.iX, point.iY); |
|
2410 |
if (point.iX >= 0 && point.iX <= javaMaxCoords.iWidth && |
|
2411 |
point.iY >= 0 && point.iY <= javaMaxCoords.iHeight) |
|
2412 |
{ |
|
2413 |
// Translated point is inside of java canvas |
|
2414 |
iDragEventsStartedInside = ETrue; |
|
2415 |
} |
|
2416 |
break; |
|
2417 |
case TPointerEvent::EButton1Up: |
|
2418 |
case TPointerEvent::EButton2Up: |
|
2419 |
case TPointerEvent::EButton3Up: |
|
2420 |
type = EPointerReleased; |
|
2421 |
if (iPointerEventSuppressionOngoing) |
|
2422 |
{ |
|
2423 |
point.iX = iPointerPressedCoordinates.iX; |
|
2424 |
point.iY = iPointerPressedCoordinates.iY; |
|
2425 |
} |
|
2426 |
break; |
|
2427 |
case TPointerEvent::EDrag: |
|
2428 |
type = EPointerDragged; |
|
2429 |
// If pointerEventSuppressor time is set to 0 don't do any |
|
2430 |
// drag event filtering. (default time here is 500ms and it |
|
2431 |
// can be changed with JAD parameter |
|
2432 |
// Nokia-MIDlet-Tap-Detection-Options) |
|
2433 |
if (iPESTimeInMilliseconds != 0) |
|
2434 |
{ |
|
2435 |
now.HomeTime(); |
|
2436 |
if (now.MicroSecondsFrom(iPreviousDragTimeStamp) < |
|
2437 |
KAllowedTimeBetweenDragEvents) |
|
2438 |
{ |
|
2439 |
// Ignore drag event because time between drags is |
|
2440 |
// shorter than allowed interval. |
|
2441 |
return; |
|
2442 |
} |
|
2443 |
else |
|
2444 |
{ |
|
2445 |
iPreviousDragTimeStamp = now; |
|
2446 |
} |
|
2447 |
} |
|
2448 |
break; |
|
2449 |
default: |
|
2450 |
type = ENoType; |
|
2451 |
} |
|
2452 |
||
2453 |
// Pointer Event Suppressor for helping tap detection with finger |
|
2454 |
// usage |
|
2455 |
if (iPointerEventSuppressor->SuppressPointerEvent(aPointerEvent)) |
|
2456 |
{ |
|
2457 |
iPointerEventSuppressionOngoing = ETrue; |
|
2458 |
return; |
|
2459 |
} |
|
2460 |
else |
|
2461 |
{ |
|
2462 |
iPointerEventSuppressionOngoing = EFalse; |
|
2463 |
} |
|
2464 |
||
2465 |
// To have the cursor on focused control |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
2466 |
if (iFocusedComponent != KComponentFocusedNone) |
66 | 2467 |
{ |
2468 |
iCustomComponents[iFocusedComponent]-> |
|
2469 |
CustomComponentControl(KComponentMainControl)-> |
|
2470 |
SetFocus(ETrue); |
|
2471 |
} |
|
2472 |
||
2473 |
// Ignore pointer events outside of Canvas content. |
|
2474 |
if (!iDragEventsStartedInside) |
|
2475 |
{ |
|
2476 |
return; |
|
2477 |
} |
|
2478 |
||
2479 |
PostEvent(type, point.iX, point.iY); |
|
2480 |
||
2481 |
// Flag is reset, if release event happened. However reset |
|
2482 |
// has to be done after event is sent to java, because of possible |
|
2483 |
// dragging, which started inside of canvas. In this case |
|
2484 |
// also release event should be delivered to java |
|
2485 |
if (type == EPointerReleased) |
|
2486 |
{ |
|
2487 |
iDragEventsStartedInside = EFalse; |
|
2488 |
} |
|
2489 |
} |
|
2490 |
} |
|
2491 |
} |
|
2492 |
#endif // RD_SCALABLE_UI_V2 |
|
2493 |
||
2494 |
||
2495 |
// --------------------------------------------------------------------------- |
|
2496 |
// From class CCoeControl. |
|
2497 |
// CMIDCanvas::FocusChanged |
|
2498 |
// Change of focus. |
|
2499 |
// --------------------------------------------------------------------------- |
|
2500 |
// |
|
2501 |
void CMIDCanvas::FocusChanged(TDrawNow /* aDrawNow */) |
|
2502 |
{ |
|
2503 |
DEBUG("+ CMIDCanvas::FocusChanged"); |
|
2504 |
||
2505 |
iEnv.ResetKeys(); |
|
2506 |
iGameKeyState = 0; |
|
2507 |
iGameKeyLatch = 0; |
|
2508 |
||
2509 |
TInt contentsCount(iDirectContents.Count()); |
|
2510 |
||
2511 |
if (IsFocused()) |
|
2512 |
{ |
|
2513 |
#ifdef CANVAS_DIRECT_ACCESS |
|
2514 |
ResumeDirectAccess(); |
|
2515 |
#endif // CANVAS_DIRECT_ACCESS |
|
2516 |
||
2517 |
if (!iRestoreContentWhenUnfaded) |
|
2518 |
{ |
|
2519 |
for (TInt j = 0; j < contentsCount; j++) |
|
2520 |
{ |
|
2521 |
iDirectContents[j]->MdcContainerVisibilityChanged(ETrue); |
|
2522 |
} |
|
2523 |
} |
|
2524 |
||
2525 |
// To have cursor on focused control. |
|
2526 |
if ((iFocusedComponent != KComponentFocusedNone) && |
|
2527 |
(iFocusedComponent < iCustomComponents.Count()) && |
|
2528 |
iCustomComponents[iFocusedComponent]-> |
|
2529 |
CustomComponentControl(KComponentMainControl)->IsVisible()) |
|
2530 |
{ |
|
2531 |
iCustomComponents[iFocusedComponent]-> |
|
2532 |
CustomComponentControl(KComponentMainControl)-> |
|
2533 |
SetFocus(ETrue); |
|
2534 |
} |
|
2535 |
||
2536 |
#ifdef RD_JAVA_NGA_ENABLED |
|
2537 |
// To avoid situation when Canvas is redrawn but black area remains |
|
2538 |
if (iAlfCompositionPixelSource && iDirectContents.Count() == 0) |
|
2539 |
{ |
|
2540 |
TRAPD(err, ActivatePixelSourceL(EFalse)); |
|
2541 |
if (err != KErrNone) |
|
2542 |
{ |
|
2543 |
DEBUG_INT("CMIDCanvas::FocusChanged - ActivatePixelSourceL error %d", err); |
|
2544 |
} |
|
2545 |
} |
|
2546 |
else |
|
2547 |
{ |
|
2548 |
// Redraw the canvas after unfading |
|
2549 |
DrawDeferred(); |
|
2550 |
} |
|
2551 |
#else // !RD_JAVA_NGA_ENABLED |
|
2552 |
// Redraw the canvas after unfading |
|
2553 |
DrawDeferred(); |
|
2554 |
#endif // RD_JAVA_NGA_ENABLED |
|
2555 |
||
2556 |
} |
|
2557 |
else |
|
2558 |
{ |
|
2559 |
#ifdef CANVAS_DIRECT_ACCESS |
|
2560 |
PauseDirectAccess(); |
|
2561 |
#endif // CANVAS_DIRECT_ACCESS |
|
2562 |
||
2563 |
if (!iRestoreContentWhenUnfaded) |
|
2564 |
{ |
|
2565 |
for (TInt j = 0; j < contentsCount; j++) |
|
2566 |
{ |
|
2567 |
iDirectContents[j]->MdcContainerVisibilityChanged(EFalse); |
|
2568 |
} |
|
2569 |
} |
|
2570 |
||
2571 |
// To remove cursor on focused control. |
|
2572 |
if ((iFocusedComponent != KComponentFocusedNone) && |
|
2573 |
(iFocusedComponent < iCustomComponents.Count()) && |
|
2574 |
iCustomComponents[iFocusedComponent]-> |
|
2575 |
CustomComponentControl(KComponentMainControl)->IsVisible()) |
|
2576 |
{ |
|
2577 |
iCustomComponents[iFocusedComponent]-> |
|
2578 |
CustomComponentControl(KComponentMainControl)-> |
|
2579 |
SetFocus(EFalse); |
|
2580 |
} |
|
2581 |
||
2582 |
// Repaint to ensure that fading will be displayed correctly for Alert |
|
2583 |
// or PopupTextBox when DSA is paused. No redraw, if canvas is using |
|
2584 |
// background surfaces i.e. EGL or pixel source |
|
2585 |
if (iDirectContents.Count() > 0) |
|
2586 |
{ |
|
2587 |
DrawDeferred(); |
|
2588 |
} |
|
2589 |
} |
|
2590 |
||
2591 |
DEBUG("- CMIDCanvas::FocusChanged"); |
|
2592 |
} |
|
2593 |
||
2594 |
||
2595 |
// --------------------------------------------------------------------------- |
|
2596 |
// From class CCoeControl. |
|
2597 |
// CMIDCanvas::SizeChanged |
|
2598 |
// Change of size. |
|
2599 |
// --------------------------------------------------------------------------- |
|
2600 |
// |
|
2601 |
void CMIDCanvas::SizeChanged() |
|
2602 |
{ |
|
2603 |
DEBUG("+ CMIDCanvas::SizeChanged"); |
|
2604 |
||
2605 |
TSize controlSize = Size(); |
|
2606 |
||
2607 |
// Position in screen co-ordinates changes when mode (full/normal) is |
|
2608 |
// changed. |
|
2609 |
iPositionRelativeToScreen = PositionRelativeToScreen(); |
|
2610 |
TRect contentBounds = TRect(iPositionRelativeToScreen, controlSize); |
|
2611 |
||
2612 |
// If JAD attribute Nokia-MIDlet-Original-Display-Size for graphics |
|
2613 |
// scaling is defined, the iContentSize must follow it. |
|
2614 |
TSize orientedOrgMIDletScrSize(OrientedOrgMIDletScrSize()); |
|
2615 |
||
2616 |
if (contentBounds != iOldContentBounds) |
|
2617 |
{ |
|
2618 |
iOldContentBounds = contentBounds; |
|
2619 |
||
2620 |
TSize contentSize; |
|
2621 |
||
2622 |
#ifdef RD_JAVA_S60_RELEASE_9_2 |
|
2623 |
if (iFullScreen && (orientedOrgMIDletScrSize != controlSize) |
|
2624 |
&& !iPartialVKBOpen) |
|
2625 |
#else |
|
2626 |
if (iFullScreen && (orientedOrgMIDletScrSize != controlSize)) |
|
2627 |
#endif // RD_JAVA_S60_RELEASE_9_2 |
|
2628 |
{ |
|
2629 |
contentSize = orientedOrgMIDletScrSize; |
|
2630 |
} |
|
2631 |
||
2632 |
if (contentSize == KZeroSize) |
|
2633 |
{ |
|
2634 |
contentSize = controlSize; |
|
2635 |
} |
|
2636 |
||
2637 |
if ((contentSize != iContentSize) || iScalingOn) |
|
2638 |
{ |
|
2639 |
#ifdef RD_JAVA_NGA_ENABLED |
|
2640 |
TSize oldContentSize = iContentSize; |
|
2641 |
iContentSize = contentSize; |
|
2642 |
||
2643 |
TBool landscape = Layout_Meta_Data::IsLandscapeOrientation(); |
|
2644 |
||
2645 |
if (IsWindowVisible() && |
|
2646 |
(oldContentSize.iWidth < iContentSize.iWidth || |
|
2647 |
oldContentSize.iHeight < iContentSize.iHeight || |
|
2648 |
landscape != iLandscape)) |
|
2649 |
{ |
|
2650 |
iWndUpdate = ETrue; |
|
2651 |
if (IsEglAvailable()) |
|
2652 |
{ |
|
2653 |
// Clear with black to avoid incorrectly sized |
|
2654 |
// surface flashing on screen in orientation switch |
|
2655 |
TRgb color(KOpaqueBlackColor); |
|
2656 |
ClearEglSurface(EEglWindow, &color); |
|
2657 |
} |
|
2658 |
} |
|
2659 |
||
2660 |
HandleSizeChanged(landscape != iLandscape); |
|
2661 |
iLandscape = landscape; |
|
2662 |
||
2663 |
PostEvent(ESizeChanged, iContentSize.iWidth, iContentSize.iHeight); |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
2664 |
|
66 | 2665 |
if (IsWindowVisible() && iWndUpdate) |
2666 |
{ |
|
2667 |
// Post forced paint to enable Canvas repaint behind |
|
2668 |
// Alert or Pop-up TextBox |
|
2669 |
PostForcedPaint(); |
|
2670 |
} |
|
2671 |
#else |
|
2672 |
iContentSize = contentSize; |
|
2673 |
PostEvent(ESizeChanged, iContentSize.iWidth, iContentSize.iHeight); |
|
2674 |
#endif // RD_JAVA_NGA_ENABLED |
|
2675 |
} |
|
2676 |
||
2677 |
#ifdef CANVAS_DIRECT_ACCESS |
|
2678 |
// Stop direct screen access to avoid restarting |
|
2679 |
// of direct content DSA during MdcContentBoundsChanged. |
|
2680 |
// DSA is resumed by Layout method. |
|
2681 |
StopDirectAccess(); |
|
2682 |
#endif // CANVAS_DIRECT_ACCESS |
|
2683 |
||
2684 |
// Inform all listeners. |
|
2685 |
TInt contentsCount(iDirectContents.Count()); |
|
2686 |
||
2687 |
for (TInt j = 0; j < contentsCount; j++) |
|
2688 |
{ |
|
2689 |
iDirectContents[j]->MdcContentBoundsChanged(contentBounds); |
|
2690 |
iDirectContents[j]->MdcContainerWindowRectChanged(MdcContainerWindowRect()); |
|
2691 |
} |
|
2692 |
||
2693 |
// We cannot determine whether the control size actually did change or |
|
2694 |
// not, so we have to do the layout no matter what. |
|
2695 |
Layout(); |
|
2696 |
} |
|
2697 |
DEBUG("- CMIDCanvas::SizeChanged"); |
|
2698 |
} |
|
2699 |
||
2700 |
||
2701 |
// --------------------------------------------------------------------------- |
|
2702 |
// From class CCoeControl. |
|
2703 |
// CMIDCanvas::PositionChanged |
|
2704 |
// Change of position. |
|
2705 |
// --------------------------------------------------------------------------- |
|
2706 |
// |
|
2707 |
void CMIDCanvas::PositionChanged() |
|
2708 |
{ |
|
2709 |
Layout(); |
|
2710 |
} |
|
2711 |
||
2712 |
#ifdef RD_JAVA_NGA_ENABLED |
|
2713 |
// --------------------------------------------------------------------------- |
|
2714 |
// From class CCoeControl. |
|
2715 |
// CMIDCanvas::Draw |
|
2716 |
// Drawing. |
|
2717 |
// --------------------------------------------------------------------------- |
|
2718 |
// |
|
2719 |
void CMIDCanvas::Draw(const TRect& aRect) const |
|
2720 |
{ |
|
2721 |
DEBUG("CMIDCanvas::Draw ++"); |
|
2722 |
||
2723 |
if (iWndUpdate) |
|
2724 |
{ |
|
2725 |
return; |
|
2726 |
} |
|
2727 |
||
2728 |
if (iDirectContents.Count() > 0) |
|
2729 |
{ |
|
2730 |
DrawWindow(aRect); |
|
2731 |
} |
|
2732 |
else |
|
2733 |
{ |
|
2734 |
CMIDCanvas* myself = const_cast<CMIDCanvas*>(this); |
|
2735 |
||
2736 |
if (IsEglAvailable()) |
|
2737 |
{ |
|
2738 |
myself->ClearUiSurface(ETrue); |
|
2739 |
} |
|
77
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
71
diff
changeset
|
2740 |
// Pixel source is not activated if Canvas is not visible, |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
71
diff
changeset
|
2741 |
// in order that graphics memory is not reserved while being on background |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
71
diff
changeset
|
2742 |
else if (iAlfCompositionPixelSource && IsWindowVisible()) |
66 | 2743 |
{ |
2744 |
myself->ClearUiSurface(ETrue); |
|
2745 |
TRAP_IGNORE(myself->ActivatePixelSourceL(ETrue)); |
|
2746 |
} |
|
2747 |
else |
|
2748 |
{ |
|
2749 |
// This is the case when M3G midlet is |
|
2750 |
// coming back to foreground and EGL |
|
2751 |
// surface is not re-created yet |
|
2752 |
DrawWindow(aRect); |
|
2753 |
} |
|
2754 |
} |
|
2755 |
||
2756 |
DEBUG("CMIDCanvas::Draw --"); |
|
2757 |
} |
|
2758 |
#else // !RD_JAVA_NGA_ENABLED |
|
2759 |
||
2760 |
// --------------------------------------------------------------------------- |
|
2761 |
// From class CCoeControl. |
|
2762 |
// CMIDCanvas::Draw |
|
2763 |
// Drawing. |
|
2764 |
// --------------------------------------------------------------------------- |
|
2765 |
// |
|
2766 |
void CMIDCanvas::Draw(const TRect& aRect) const |
|
2767 |
{ |
|
2768 |
DEBUG("+ CMIDCanvas::Draw"); |
|
2769 |
||
2770 |
#ifdef CANVAS_DOUBLE_BUFFER |
|
2771 |
ASSERT(iFrameBuffer); |
|
2772 |
#endif // CANVAS_DOUBLE_BUFFER |
|
2773 |
||
2774 |
#ifdef CANVAS_ASYNC_PAINT |
|
2775 |
TRect rect(aRect); |
|
2776 |
||
2777 |
rect.Intersection(iViewRect); |
|
2778 |
rect.Move(-iViewRect.iTl); |
|
2779 |
||
2780 |
TSize size(rect.Size()); |
|
2781 |
||
2782 |
TInt posPacked = (rect.iTl.iX << 16) | (rect.iTl.iY); |
|
2783 |
TInt sizePacked = (size.iWidth << 16) | (size.iHeight); |
|
2784 |
||
2785 |
PostEvent(EPaint, posPacked, sizePacked); |
|
2786 |
#else |
|
2787 |
#ifdef CANVAS_DOUBLE_BUFFER |
|
2788 |
||
2789 |
// While changing the orientation method DrawWindow() not called, |
|
2790 |
// variable iWndUpdate is set to True. If iWndUpdate is True |
|
2791 |
// DrawWindow() is called from method Update() |
|
2792 |
// This is needed to avoid artifacting after orientation switch. |
|
2793 |
TBool landscape = Layout_Meta_Data::IsLandscapeOrientation(); |
|
2794 |
||
2795 |
if (iLandscape != landscape) |
|
2796 |
{ |
|
2797 |
iLandscape = landscape; |
|
2798 |
iWndUpdate = ETrue; |
|
2799 |
} |
|
2800 |
else |
|
2801 |
{ |
|
2802 |
#ifdef CANVAS_DIRECT_ACCESS |
|
2803 |
// Check if DSA is ready and not used by some other client. |
|
2804 |
if (iDirectGc && !iDirectContents.Count() && !DirectPaused()) |
|
2805 |
{ |
|
2806 |
DrawDirect(aRect); // Draw directly to screen. |
|
2807 |
} |
|
2808 |
else |
|
2809 |
{ |
|
2810 |
#endif // CANVAS_DIRECT_ACCESS |
|
2811 |
DrawWindow(aRect); // Bitblt via window server. |
|
2812 |
#ifdef CANVAS_DIRECT_ACCESS |
|
2813 |
} |
|
2814 |
#endif // CANVAS_DIRECT_ACCESS |
|
2815 |
||
2816 |
iWndUpdate = EFalse; |
|
2817 |
} |
|
2818 |
#endif // CANVAS_DOUBLE_BUFFER |
|
2819 |
#endif // CANVAS_ASYNC_PAINT |
|
2820 |
||
2821 |
DEBUG("- CMIDCanvas::Draw"); |
|
2822 |
} |
|
2823 |
#endif // RD_JAVA_NGA_ENABLED |
|
2824 |
||
2825 |
// --------------------------------------------------------------------------- |
|
2826 |
// CMIDCanvas::CMIDCanvas |
|
2827 |
// C++ constructor. |
|
2828 |
// --------------------------------------------------------------------------- |
|
2829 |
// |
|
2830 |
CMIDCanvas::CMIDCanvas( |
|
2831 |
MMIDEnv& aEnv, |
|
2832 |
MMIDComponent::TType aComponentType, |
|
2833 |
#ifdef CANVAS_DIRECT_ACCESS |
|
2834 |
TBool /*aUpdateRequired*/ |
|
2835 |
#else |
|
2836 |
TBool aUpdateRequired |
|
2837 |
#endif // CANVAS_DIRECT_ACCESS |
|
2838 |
) : |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
2839 |
CCoeControl() |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
2840 |
,iEnv(aEnv) |
66 | 2841 |
#ifdef CANVAS_DOUBLE_BUFFER |
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
2842 |
,iFrameBuffer(NULL) |
66 | 2843 |
#endif // CANVAS_DOUBLE_BUFFER |
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
2844 |
,iIsGameCanvas(( |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
2845 |
aComponentType == MMIDComponent::EGameCanvas ? ETrue : EFalse)) |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
2846 |
,iFlags(EPostKeyEvents) |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
2847 |
,iFullScreen(EFalse) |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
2848 |
,iScalingOn(EFalse) |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
2849 |
,iS60SelectionKeyCompatibility(EFalse) |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
2850 |
,iRestoreContentWhenUnfaded(EFalse) |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
2851 |
,iLastFadeMessage(0) |
66 | 2852 |
#ifdef CANVAS_DIRECT_ACCESS |
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
2853 |
,iDcDsaToStart(EFalse) |
66 | 2854 |
#endif // CANVAS_DIRECT_ACCESS |
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
2855 |
,iDragEventsStartedInside(EFalse) |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
2856 |
,iFirstPaintState(EFirstPaintNeverOccurred) |
66 | 2857 |
{ |
2858 |
DEBUG("+ CMIDCanvas::CMIDCanvas - EDirectEnabled"); |
|
2859 |
||
2860 |
#ifdef CANVAS_DIRECT_ACCESS |
|
2861 |
iFlags |= (EDirectPaused | EDirectEnabled | EUpdateRequired); |
|
2862 |
#else |
|
2863 |
||
2864 |
#if defined( __WINS__ ) || defined( __WINSCW__ ) |
|
2865 |
aUpdateRequired = ETrue; |
|
2866 |
#endif |
|
2867 |
||
2868 |
if (aUpdateRequired) |
|
2869 |
{ |
|
2870 |
iFlags |= EUpdateRequired; |
|
2871 |
} |
|
2872 |
#endif // CANVAS_DIRECT_ACCESS |
|
2873 |
||
2874 |
//Default values for PointerEventSuppressor |
|
2875 |
iPESPointerMovementInTwips = CMIDUIManager::EPESPointerMovementInTwips; |
|
2876 |
iPESTimeInMilliseconds = CMIDUIManager:: EPESTimeInMilliseconds; |
|
2877 |
||
2878 |
DEBUG("- CMIDCanvas::CMIDCanvas"); |
|
2879 |
} |
|
2880 |
||
2881 |
||
2882 |
// --------------------------------------------------------------------------- |
|
2883 |
// CMIDCanvas::ConstructL |
|
2884 |
// Symbian 2nd phase constructor can leave. |
|
2885 |
// --------------------------------------------------------------------------- |
|
2886 |
// |
|
2887 |
void CMIDCanvas::ConstructL(CCoeControl& aWindow) |
|
2888 |
{ |
|
2889 |
SetContainerWindowL(aWindow); |
|
2890 |
||
2891 |
iFocusedComponent = KComponentFocusedNone; |
|
2892 |
iPressedComponent = NULL; |
|
2893 |
iOrgMIDletScrSize = TSize(); |
|
2894 |
iTargetMIDletScrSize = TSize(); |
|
2895 |
||
2896 |
#ifdef CANVAS_DOUBLE_BUFFER |
|
2897 |
// Create a framebuffer large enough for full screen mode. |
|
2898 |
// In normal mode we will waste the border pixels. This may be offset in |
|
2899 |
// future by sharing the framebuffer between displayables. |
|
2900 |
// |
|
2901 |
// Allow dynamic changing of screen modes find the |
|
2902 |
// largest available screen size to allocate a frame buffer big enough to |
|
2903 |
// deal with all screen modes; |
|
2904 |
CWsScreenDevice* device = ControlEnv()->ScreenDevice(); |
|
2905 |
TInt noModes = device->NumScreenModes(); |
|
2906 |
TPixelsAndRotation pixelAndRot; |
|
2907 |
TSize frameBufferSize(0, 0); |
|
2908 |
||
2909 |
for (TInt ii=0 ; ii < noModes; ++ii) |
|
2910 |
{ |
|
2911 |
device->GetScreenModeSizeAndRotation(ii, pixelAndRot); |
|
2912 |
||
2913 |
if (frameBufferSize.iHeight < pixelAndRot.iPixelSize.iHeight) |
|
2914 |
{ |
|
2915 |
frameBufferSize.iHeight = pixelAndRot.iPixelSize.iHeight; |
|
2916 |
} |
|
2917 |
||
2918 |
if (frameBufferSize.iWidth < pixelAndRot.iPixelSize.iWidth) |
|
2919 |
{ |
|
2920 |
frameBufferSize.iWidth = pixelAndRot.iPixelSize.iWidth; |
|
2921 |
} |
|
2922 |
} |
|
2923 |
||
2924 |
DEBUG_INT2("Canvas FrameBuffer Size: Width: %d, Height %d", |
|
2925 |
frameBufferSize.iWidth, frameBufferSize.iHeight); |
|
2926 |
||
2927 |
CreateFrameBufferL(frameBufferSize); |
|
2928 |
||
2929 |
if (iFrameBuffer) |
|
2930 |
{ |
|
2931 |
iFrameDevice = CFbsBitmapDevice::NewL(iFrameBuffer); |
|
2932 |
User::LeaveIfError(iFrameDevice->CreateContext(iFrameContext)); |
|
2933 |
} |
|
2934 |
||
2935 |
// Set iLandscape set as True according to landscape orientation mode |
|
2936 |
// and initialize iWndUpdat. iWndUpdat variable notify us, when |
|
2937 |
// orienation was changed |
|
2938 |
iLandscape = Layout_Meta_Data::IsLandscapeOrientation(); |
|
2939 |
iWndUpdate = EFalse; |
|
2940 |
||
2941 |
#endif // CANVAS_DOUBLE_BUFFER |
|
2942 |
||
2943 |
SetScalingFactors(); |
|
2944 |
||
2945 |
if (iScalingOn) |
|
2946 |
{ |
|
2947 |
// We need iScaler only when scaling is on. |
|
2948 |
iScaler = iDisplayable->GetUIManager()->OpenScalerL(); |
|
2949 |
} |
|
2950 |
||
2951 |
#ifdef CANVAS_DIRECT_ACCESS |
|
2952 |
ResumeDirectAccess(); |
|
2953 |
#endif // CANVAS_DIRECT_ACCESS |
|
2954 |
||
2955 |
if (IsNetworkIndicatorEnabledL()) |
|
2956 |
{ |
|
2957 |
iNetworkIndicator = CMIDNetworkIndicator::NewL(this); |
|
2958 |
||
2959 |
// Initialize and set active CallIndicator to receive notification |
|
2960 |
// when voiceline status changes. |
|
2961 |
iCallIndicator = CMIDCallIndicator::NewL(iNetworkIndicator); |
|
2962 |
iCallIndicator->SetActiveLocal(); |
|
2963 |
} |
|
2964 |
||
2965 |
iKeyDecoder = iDisplayable->GetUIManager()->OpenKeyDecoderL(); |
|
2966 |
ASSERT(iKeyDecoder); |
|
2967 |
||
2968 |
// Canvas listens Media key events if CMIDRemConObserver is initialized |
|
2969 |
// and media keys keys are enabled. |
|
2970 |
iRemConObserver = iKeyDecoder->GetRemConObserver(); |
|
2971 |
if (iRemConObserver && iKeyDecoder->MediaKeysEnabled()) |
|
2972 |
{ |
|
2973 |
iRemConObserver->AddMediaKeysListenerL(this); |
|
2974 |
} |
|
2975 |
||
2976 |
// Set S60 Selection Key Compatibility to provide MSK key events to |
|
2977 |
// canvas. |
|
2978 |
iS60SelectionKeyCompatibility = iEnv.MidletAttributeIsSetToVal( |
|
2979 |
LcduiMidletAttributes::KAttribS60SelectionKeyCompatibility, |
|
2980 |
LcduiMidletAttributeValues::KTrueValue); |
|
2981 |
||
2982 |
if (iDisplayable) |
|
2983 |
{ |
|
2984 |
iDisplayable->SetS60SelectionKeyCompatibility( |
|
2985 |
iS60SelectionKeyCompatibility); |
|
2986 |
} |
|
2987 |
||
2988 |
#ifdef RD_TACTILE_FEEDBACK |
|
2989 |
// Create a CMIDTactileFeedbackExtension in case tactile feedback is |
|
2990 |
// supported. |
|
2991 |
iTactileFeedback = new(ELeave) CMIDTactileFeedbackExtension(this, 1); |
|
2992 |
#endif // RD_TACTILE_FEEDBACK |
|
2993 |
||
2994 |
//Create PointerEventSuppressor with default values or JAD parameter defined values |
|
2995 |
iPointerEventSuppressor = CAknPointerEventSuppressor::NewL(); |
|
2996 |
TInt pointerMovementInPixels = |
|
2997 |
ControlEnv()->ScreenDevice()->HorizontalTwipsToPixels(iPESPointerMovementInTwips); |
|
2998 |
TSize suppressorValues = |
|
2999 |
iDisplayable->GetUIManager()->ReadPointerEventSuppressorValues(); |
|
3000 |
if (!(suppressorValues.iWidth == KPESErrorValue && |
|
3001 |
suppressorValues.iHeight == KPESErrorValue)) |
|
3002 |
{ |
|
3003 |
iPESTimeInMilliseconds = suppressorValues.iHeight; |
|
3004 |
pointerMovementInPixels = |
|
3005 |
ControlEnv()->ScreenDevice()->HorizontalTwipsToPixels(suppressorValues.iWidth); |
|
3006 |
} |
|
3007 |
iPointerEventSuppressor->SetMaxTapDuration(iPESTimeInMilliseconds * 1000); |
|
3008 |
iPointerEventSuppressor->SetMaxTapMove(TSize(pointerMovementInPixels, |
|
3009 |
pointerMovementInPixels)); |
|
3010 |
||
3011 |
iForeground = EFalse; |
|
3012 |
#ifdef RD_JAVA_NGA_ENABLED |
|
3013 |
iEglDisplay = EGL_NO_DISPLAY; |
|
3014 |
iEglWindowSurface = EGL_NO_SURFACE; |
|
3015 |
iEglWindowSurfaceContext = EGL_NO_CONTEXT; |
|
3016 |
iEglPbufferSurface = EGL_NO_SURFACE; |
|
3017 |
iEglPbufferSurfaceContext = EGL_NO_CONTEXT; |
|
3018 |
iPbufferTexture = 0; |
|
3019 |
||
3020 |
i3DAccelerated = |
|
3021 |
iEnv.IsHardwareAcceleratedL(MMIDEnv::EHardware3D) > 0; |
|
3022 |
||
3023 |
InitPixelSourceL(); |
|
3024 |
#endif // RD_JAVA_NGA_ENABLED |
|
3025 |
||
3026 |
#ifdef RD_JAVA_S60_RELEASE_9_2 |
|
3027 |
iPartialVKBOpen = EFalse; |
|
3028 |
#endif // RD_JAVA_S60_RELEASE_9_2 |
|
3029 |
} |
|
3030 |
||
3031 |
||
3032 |
// --------------------------------------------------------------------------- |
|
3033 |
// CMIDCanvas::SetContainerWindowL |
|
3034 |
// Set the container window. |
|
3035 |
// --------------------------------------------------------------------------- |
|
3036 |
// |
|
3037 |
void CMIDCanvas::SetContainerWindowL(const CCoeControl& aWindow) |
|
3038 |
{ |
|
3039 |
#ifdef CANVAS_DIRECT_ACCESS |
|
3040 |
StopDirectAccess(); |
|
3041 |
||
3042 |
if (iDirectAccess) |
|
3043 |
{ |
|
3044 |
delete iDirectAccess; |
|
3045 |
iDirectAccess = NULL; |
|
3046 |
} |
|
3047 |
#endif // CANVAS_DIRECT_ACCESS |
|
3048 |
||
3049 |
iDisplayable = (CMIDDisplayable*) &aWindow; |
|
3050 |
CCoeControl::SetContainerWindowL(aWindow); |
|
3051 |
Window().SetBackgroundColor(); |
|
3052 |
MakeVisible(aWindow.IsVisible()); |
|
3053 |
||
3054 |
#ifdef RD_SCALABLE_UI_V2 |
|
3055 |
Window().SetPointerGrab(ETrue); |
|
3056 |
#endif // RD_SCALABLE_UI_V2 |
|
3057 |
||
3058 |
#ifdef CANVAS_DIRECT_ACCESS |
|
3059 |
if (DirectEnabled()) |
|
3060 |
{ |
|
3061 |
RWsSession& session = ControlEnv()->WsSession(); |
|
3062 |
CWsScreenDevice* device = ControlEnv()->ScreenDevice(); |
|
3063 |
||
3064 |
iDirectAccess = CDirectScreenAccess::NewL( |
|
3065 |
session, *device, *DrawableWindow(), *this); |
|
3066 |
} |
|
3067 |
#endif // CANVAS_DIRECT_ACCESS |
|
3068 |
||
3069 |
// Position in screen co-ordinates is first time available when container |
|
3070 |
// window is set. |
|
3071 |
iPositionRelativeToScreen = PositionRelativeToScreen(); |
|
3072 |
} |
|
3073 |
||
3074 |
||
3075 |
// --------------------------------------------------------------------------- |
|
3076 |
// CMIDCanvas::SendKeyEventToJavaSideL |
|
3077 |
// Send key event to Java side. |
|
3078 |
// --------------------------------------------------------------------------- |
|
3079 |
// |
|
3080 |
void CMIDCanvas::SendKeyEventToJavaSideL( |
|
3081 |
const TKeyEvent& aEvent, TEventCode aType) |
|
3082 |
{ |
|
3083 |
DEBUG("+ CMIDCanvas::SendKeyEventToJavaSideL"); |
|
3084 |
TMIDKeyEvent event; |
|
3085 |
||
3086 |
// See if the key can be sent java side. |
|
3087 |
DEBUG_INT2("CMIDCanvas::PostKeyEvent - SOS code %d SOS type %d", |
|
3088 |
aEvent.iCode, |
|
3089 |
aType); |
|
3090 |
||
3091 |
// map key event data |
|
3092 |
TKeyEvent wsEvent = aEvent; |
|
3093 |
||
3094 |
DEBUG_INT("+ CMIDCanvas::SendKeyEventToJavaSideL - received TKeyEvent: iCode = %d", aEvent.iCode); |
|
3095 |
DEBUG_INT("+ CMIDCanvas::SendKeyEventToJavaSideL - received TKeyEvent: iModifiers = %d", aEvent.iModifiers); |
|
3096 |
DEBUG_INT("+ CMIDCanvas::SendKeyEventToJavaSideL - received TKeyEvent: iRepeats = %d", aEvent.iRepeats); |
|
3097 |
DEBUG_INT("+ CMIDCanvas::SendKeyEventToJavaSideL - received TKeyEvent: iScanCode = %d", aEvent.iScanCode); |
|
3098 |
||
3099 |
iEnv.MappingDataForKey(wsEvent, aType); |
|
3100 |
||
3101 |
DEBUG_INT("+ CMIDCanvas::SendKeyEventToJavaSideL - mapped TKeyEvent: iCode = %d", aEvent.iCode); |
|
3102 |
DEBUG_INT("+ CMIDCanvas::SendKeyEventToJavaSideL - mapped TKeyEvent: iModifiers = %d", aEvent.iModifiers); |
|
3103 |
DEBUG_INT("+ CMIDCanvas::SendKeyEventToJavaSideL - mapped TKeyEvent: iRepeats = %d", aEvent.iRepeats); |
|
3104 |
DEBUG_INT("+ CMIDCanvas::SendKeyEventToJavaSideL - mapped TKeyEvent: iScanCode = %d", aEvent.iScanCode); |
|
3105 |
||
3106 |
//See if the key can be sent java side. |
|
3107 |
if (iEnv.TranslateKeyL(event, wsEvent, aType)) |
|
3108 |
{ |
|
3109 |
DEBUG_INT("+ CMIDCanvas::SendKeyEventToJavaSideL - translated TMIDKeyEvent: iEvents = %d", event.iEvents); |
|
3110 |
DEBUG_INT("+ CMIDCanvas::SendKeyEventToJavaSideL - translated TMIDKeyEvent: iKeyCode = %d", event.iKeyCode); |
|
3111 |
DEBUG_INT("+ CMIDCanvas::SendKeyEventToJavaSideL - translated TMIDKeyEvent: iRepeats = %d", event.iRepeats); |
|
3112 |
||
3113 |
ASSERT(iKeyDecoder); |
|
3114 |
||
3115 |
TInt gameAction = iKeyDecoder->GameAction(event.iKeyCode); |
|
3116 |
||
3117 |
if (0 != gameAction) |
|
3118 |
{ |
|
3119 |
if (event.iEvents & TMIDKeyEvent::EPressed) |
|
3120 |
{ |
|
3121 |
GamePress(gameAction); |
|
3122 |
} |
|
3123 |
||
3124 |
if (event.iEvents & TMIDKeyEvent::EReleased) |
|
3125 |
{ |
|
3126 |
GameRelease(gameAction); |
|
3127 |
} |
|
3128 |
} |
|
3129 |
||
3130 |
if (PostKeyEvents() || (0 == gameAction)) |
|
3131 |
{ |
|
3132 |
DEBUG_INT2( |
|
3133 |
"CMIDCanvas::PostKeyEvent - JAVA code %d JAVA type %d", |
|
3134 |
event.iKeyCode, |
|
3135 |
event.iEvents); |
|
3136 |
||
3137 |
// 9-way Navigation Support |
|
3138 |
// Send two arrow events generated when press diagonal direction |
|
3139 |
switch (event.iKeyCode) |
|
3140 |
{ |
|
3141 |
//KeyLeftUpArrow |
|
3142 |
case EKeyLeftUpArrow: |
|
3143 |
{ |
|
3144 |
TMIDKeyEvent pevent; |
|
3145 |
pevent.iKeyCode = iKeyDecoder->MapNonUnicodeKey(EStdKeyUpArrow); |
|
3146 |
pevent.iEvents = event.iEvents; |
|
3147 |
pevent.iRepeats = event.iRepeats; |
|
3148 |
iEnv.PostKeyEvent(*this, pevent); |
|
3149 |
pevent.iKeyCode = iKeyDecoder->MapNonUnicodeKey(EStdKeyLeftArrow); |
|
3150 |
pevent.iEvents = event.iEvents; |
|
3151 |
pevent.iRepeats = event.iRepeats; |
|
3152 |
iEnv.PostKeyEvent(*this, pevent); |
|
3153 |
break; |
|
3154 |
} |
|
3155 |
//KeyRightUpArrow |
|
3156 |
case EKeyRightUpArrow: |
|
3157 |
{ |
|
3158 |
TMIDKeyEvent pevent; |
|
3159 |
pevent.iKeyCode = iKeyDecoder->MapNonUnicodeKey(EStdKeyUpArrow); |
|
3160 |
pevent.iEvents = event.iEvents; |
|
3161 |
pevent.iRepeats = event.iRepeats; |
|
3162 |
iEnv.PostKeyEvent(*this, pevent); |
|
3163 |
pevent.iKeyCode = iKeyDecoder->MapNonUnicodeKey(EStdKeyRightArrow); |
|
3164 |
pevent.iEvents = event.iEvents; |
|
3165 |
pevent.iRepeats = event.iRepeats; |
|
3166 |
iEnv.PostKeyEvent(*this, pevent); |
|
3167 |
break; |
|
3168 |
} |
|
3169 |
//KeyRightDownArrow |
|
3170 |
case EKeyRightDownArrow: |
|
3171 |
{ |
|
3172 |
TMIDKeyEvent pevent; |
|
3173 |
pevent.iKeyCode = iKeyDecoder->MapNonUnicodeKey(EStdKeyDownArrow); |
|
3174 |
pevent.iEvents = event.iEvents; |
|
3175 |
pevent.iRepeats = event.iRepeats; |
|
3176 |
iEnv.PostKeyEvent(*this, pevent); |
|
3177 |
pevent.iKeyCode = iKeyDecoder->MapNonUnicodeKey(EStdKeyRightArrow); |
|
3178 |
pevent.iEvents = event.iEvents; |
|
3179 |
pevent.iRepeats = event.iRepeats; |
|
3180 |
iEnv.PostKeyEvent(*this, pevent); |
|
3181 |
break; |
|
3182 |
} |
|
3183 |
//KeyLeftDownArrow |
|
3184 |
case EKeyLeftDownArrow: |
|
3185 |
{ |
|
3186 |
TMIDKeyEvent pevent; |
|
3187 |
pevent.iKeyCode = iKeyDecoder->MapNonUnicodeKey(EStdKeyDownArrow); |
|
3188 |
pevent.iEvents = event.iEvents; |
|
3189 |
pevent.iRepeats = event.iRepeats; |
|
3190 |
iEnv.PostKeyEvent(*this, pevent); |
|
3191 |
pevent.iKeyCode = iKeyDecoder->MapNonUnicodeKey(EStdKeyLeftArrow); |
|
3192 |
pevent.iEvents = event.iEvents; |
|
3193 |
pevent.iRepeats = event.iRepeats; |
|
3194 |
iEnv.PostKeyEvent(*this, pevent); |
|
3195 |
break; |
|
3196 |
} |
|
3197 |
default: |
|
3198 |
iEnv.PostKeyEvent(*this, event); |
|
3199 |
} |
|
3200 |
} |
|
3201 |
} |
|
3202 |
DEBUG("- CMIDCanvas::SendKeyEventToJavaSideL"); |
|
3203 |
} |
|
3204 |
||
3205 |
||
3206 |
#ifdef CANVAS_DOUBLE_BUFFER |
|
3207 |
// --------------------------------------------------------------------------- |
|
3208 |
// CMIDCanvas::CreateFrameBufferL |
|
3209 |
// Create frame buffer. |
|
3210 |
// --------------------------------------------------------------------------- |
|
3211 |
// |
|
3212 |
void CMIDCanvas::CreateFrameBufferL(const TSize& aSize) |
|
3213 |
{ |
|
3214 |
DEBUG_INT2("+ CMIDCanvas::CreateFrameBufferL( %D, %D)", |
|
3215 |
aSize.iWidth, |
|
3216 |
aSize.iHeight); |
|
3217 |
||
3218 |
iFrameBuffer = iEnv.ReserveCanvasFrameBufferL((*this), aSize); |
|
3219 |
||
3220 |
DEBUG("- CMIDCanvas::CreateFrameBufferL"); |
|
3221 |
} |
|
3222 |
#endif // CANVAS_DOUBLE_BUFFER |
|
3223 |
||
3224 |
||
3225 |
#ifdef DEFER_BITBLT |
|
3226 |
// --------------------------------------------------------------------------- |
|
3227 |
// CMIDCanvas::BitBltCycles |
|
3228 |
// Get BitBlt cycles count. |
|
3229 |
// --------------------------------------------------------------------------- |
|
3230 |
// |
|
3231 |
TInt CMIDCanvas::BitBltCycles(const TSize& aSize) const |
|
3232 |
{ |
|
3233 |
TInt cycles = (aSize.iWidth * aSize.iHeight * KEstCyclesPerPixel); |
|
3234 |
||
3235 |
if (cycles < KMinOpCycles) cycles = KMinOpCycles; |
|
3236 |
if (cycles > KMaxOpCycles) cycles = KMaxOpCycles; |
|
3237 |
||
3238 |
return cycles; |
|
3239 |
} |
|
3240 |
#endif // DEFER_BITBLT |
|
3241 |
||
3242 |
||
3243 |
// --------------------------------------------------------------------------- |
|
3244 |
// CMIDCanvas::Layout |
|
3245 |
// Layout Canvas control. |
|
3246 |
// --------------------------------------------------------------------------- |
|
3247 |
// |
|
3248 |
void CMIDCanvas::Layout() |
|
3249 |
{ |
|
3250 |
DEBUG("+ CMIDCanvas::Layout"); |
|
3251 |
#ifdef CANVAS_DIRECT_ACCESS |
|
3252 |
StopDirectAccess(); |
|
3253 |
#endif // CANVAS_DIRECT_ACCESS |
|
3254 |
||
3255 |
TRect rect(Rect()); |
|
3256 |
TSize size(rect.Size()); |
|
3257 |
TSize viewSize; |
|
3258 |
||
3259 |
if (iFullScreen) |
|
3260 |
{ |
|
3261 |
if (iNetworkIndicator) |
|
3262 |
{ |
|
3263 |
// Refresh the layout data for network indicator. |
|
3264 |
iNetworkIndicator->GetLayoutData(); |
|
3265 |
} |
|
3266 |
||
3267 |
// Get original MIDlet size which eventually reflects display |
|
3268 |
// orientation. |
|
3269 |
TSize orientedOrgMIDletScrSize(OrientedOrgMIDletScrSize()); |
|
3270 |
||
3271 |
#ifdef RD_JAVA_S60_RELEASE_9_2 |
|
3272 |
// If partial VKB is open then MIDlet is not scaled. |
|
3273 |
// That we need set iViewRect to whole size of Canvas. |
|
3274 |
if (iPartialVKBOpen) |
|
3275 |
{ |
|
3276 |
viewSize = Size(); |
|
3277 |
} |
|
3278 |
else if (iTargetMIDletScrSize != KZeroSize) |
|
3279 |
#else |
|
3280 |
if (iTargetMIDletScrSize != KZeroSize) |
|
3281 |
#endif //RD_JAVA_S60_RELEASE_9_2 |
|
3282 |
{ |
|
3283 |
// If Nokia-MIDlet-Target-Display-Size is defined, Canvas will be |
|
3284 |
// scaled to that size. |
|
3285 |
viewSize = iTargetMIDletScrSize; |
|
3286 |
} |
|
3287 |
// If optional JAD parameter Nokia-MIDlet-Target-Display-Size is NOT |
|
3288 |
// defined and Nokia-MIDlet-Original-Display-Size is defined to |
|
3289 |
// smaller size than the device's screen size, we will scale the |
|
3290 |
// Canvas to fit the screen without changing aspect ratio. |
|
3291 |
// If the aspect ratio of Nokia-MIDlet-Original-Display-Size is not |
|
3292 |
// same as the display has, we need to leave black borders to both |
|
3293 |
// sides or up and down. |
|
3294 |
else if ( |
|
3295 |
(orientedOrgMIDletScrSize.iWidth != 0) && |
|
3296 |
(orientedOrgMIDletScrSize.iHeight != 0)) |
|
3297 |
{ |
|
3298 |
TReal widthScalingFactor = |
|
3299 |
(TReal)size.iWidth / |
|
3300 |
(TReal)orientedOrgMIDletScrSize.iWidth; |
|
3301 |
||
3302 |
TReal heightScalingFactor = |
|
3303 |
(TReal)size.iHeight / |
|
3304 |
(TReal)orientedOrgMIDletScrSize.iHeight; |
|
3305 |
||
3306 |
// Aspect ratio of MIDlet is same as display. |
|
3307 |
if (widthScalingFactor == heightScalingFactor) |
|
3308 |
{ |
|
3309 |
viewSize.SetSize(size.iWidth, size.iHeight); |
|
3310 |
} |
|
3311 |
// Aspect ratio of MIDlet is "wider" than display. |
|
3312 |
else if (widthScalingFactor < heightScalingFactor) |
|
3313 |
{ |
|
3314 |
viewSize.SetSize(size.iWidth, |
|
3315 |
widthScalingFactor * iContentSize.iHeight); |
|
3316 |
} |
|
3317 |
//Aspect ratio of MIDlet is "narrower" than display. |
|
3318 |
else |
|
3319 |
{ |
|
3320 |
viewSize.SetSize(heightScalingFactor * iContentSize.iWidth, |
|
3321 |
size.iHeight); |
|
3322 |
} |
|
3323 |
} |
|
3324 |
// If JAD parameters for graphics scaling are not defined, Canvas |
|
3325 |
// won't be scaled. |
|
3326 |
else |
|
3327 |
{ |
|
3328 |
viewSize = iContentSize; |
|
3329 |
} |
|
3330 |
} |
|
3331 |
// If Canvas is not in full screen mode, it won't be scaled. |
|
3332 |
else |
|
3333 |
{ |
|
3334 |
viewSize = iContentSize; |
|
3335 |
} |
|
3336 |
||
3337 |
TSize border = (size - viewSize); |
|
3338 |
TBool center = ((border.iWidth != 0) || (border.iHeight != 0)); |
|
3339 |
TPoint viewPos = rect.iTl; |
|
3340 |
||
3341 |
// Compute position of view rect in window. |
|
3342 |
// |
|
3343 |
// If content does not fill the control, center it, but try |
|
3344 |
// to keep the left hand pixel of content aligned to a word |
|
3345 |
// boundary of screen memory to enable faster blts. |
|
3346 |
if (center) |
|
3347 |
{ |
|
3348 |
viewPos.iX += border.iWidth / 2; |
|
3349 |
viewPos.iY += border.iHeight / 2; |
|
3350 |
||
3351 |
const TPoint screenPos = PositionRelativeToScreen(); |
|
3352 |
||
3353 |
// Align to 4-pixel boundary - this is overkill but covers both |
|
3354 |
// EColor256 and EColor4K. Should query graphics plugin for the |
|
3355 |
// alignment. |
|
3356 |
const TInt KAlignBoundary = 4; |
|
3357 |
TInt alignment = KAlignBoundary |
|
3358 |
- ((viewPos.iX + screenPos.iX) & 0x3); |
|
3359 |
||
3360 |
// This alignment change is made to keep canvas as more center |
|
3361 |
// as it is possible. Alignment can have values between 0 and 4 |
|
3362 |
// so if it have value more than 2, there is a -4 subtraction |
|
3363 |
// to prevent moving canvas too much to right side of display. |
|
3364 |
if (alignment > 2) |
|
3365 |
{ |
|
3366 |
alignment -= KAlignBoundary; |
|
3367 |
} |
|
3368 |
||
3369 |
viewPos.iX += alignment; |
|
3370 |
||
3371 |
// Fallback to original position - we'll just have to take the |
|
3372 |
// unaligned bitblt performance hit. |
|
3373 |
if (viewPos.iX < rect.iTl.iX || |
|
3374 |
(viewPos.iX + viewSize.iWidth) > rect.iBr.iX) |
|
3375 |
{ |
|
3376 |
viewPos.iX -= alignment; |
|
3377 |
} |
|
3378 |
} |
|
3379 |
||
3380 |
iViewRect = TRect(viewPos, viewSize); |
|
3381 |
||
3382 |
#ifdef CANVAS_DIRECT_ACCESS |
|
3383 |
StartDirectAccess(); |
|
3384 |
#endif // CANVAS_DIRECT_ACCESS |
|
3385 |
||
3386 |
TInt contentsCount(iDirectContents.Count()); |
|
3387 |
||
3388 |
for (TInt j = 0; j < contentsCount; j++) |
|
3389 |
{ |
|
3390 |
iDirectContents[j]->MdcContentBoundsChanged( |
|
3391 |
TRect(PositionRelativeToScreen(), Size())); |
|
3392 |
} |
|
3393 |
||
3394 |
DEBUG_PROFILE("CMIDCanvas::Layout Canvas up and running \n"); |
|
3395 |
DEBUG("- CMIDCanvas::Layout"); |
|
3396 |
} |
|
3397 |
||
3398 |
||
3399 |
#ifdef CANVAS_DIRECT_ACCESS |
|
3400 |
// --------------------------------------------------------------------------- |
|
3401 |
// CMIDCanvas::DirectEnabled |
|
3402 |
// Tells whether Direct Screen Access is enabled or disabled. |
|
3403 |
// --------------------------------------------------------------------------- |
|
3404 |
// |
|
3405 |
inline TBool CMIDCanvas::DirectEnabled() const |
|
3406 |
{ |
|
3407 |
return iFlags & EDirectEnabled; |
|
3408 |
} |
|
3409 |
||
3410 |
||
3411 |
// --------------------------------------------------------------------------- |
|
3412 |
// CMIDCanvas::DirectPaused |
|
3413 |
// Tells whether Direct Screen Access is paused or not. |
|
3414 |
// --------------------------------------------------------------------------- |
|
3415 |
// |
|
3416 |
inline TBool CMIDCanvas::DirectPaused() const |
|
3417 |
{ |
|
3418 |
return iFlags & EDirectPaused; |
|
3419 |
} |
|
3420 |
||
3421 |
||
3422 |
// --------------------------------------------------------------------------- |
|
3423 |
// CMIDCanvas::UpdateRequired |
|
3424 |
// Tells whether update is required or not. |
|
3425 |
// --------------------------------------------------------------------------- |
|
3426 |
// |
|
3427 |
inline TBool CMIDCanvas::UpdateRequired() const |
|
3428 |
{ |
|
3429 |
return iFlags & EUpdateRequired; |
|
3430 |
} |
|
3431 |
#endif //CANVAS_DIRECT_ACCESS |
|
3432 |
||
3433 |
||
3434 |
// --------------------------------------------------------------------------- |
|
3435 |
// CMIDCanvas::PostKeyEvents |
|
3436 |
// Tells whether posting of key events is enabled or disabled. |
|
3437 |
// --------------------------------------------------------------------------- |
|
3438 |
// |
|
3439 |
inline TBool CMIDCanvas::PostKeyEvents() const |
|
3440 |
{ |
|
3441 |
return iFlags & EPostKeyEvents; |
|
3442 |
} |
|
3443 |
||
3444 |
||
3445 |
// --------------------------------------------------------------------------- |
|
3446 |
// CMIDCanvas::GamePress |
|
3447 |
// Process game press action. |
|
3448 |
// --------------------------------------------------------------------------- |
|
3449 |
// |
|
3450 |
void CMIDCanvas::GamePress(TInt aGameAction) |
|
3451 |
{ |
|
3452 |
const TInt gameBit = 1 << aGameAction; |
|
3453 |
iGameKeyState |= gameBit; |
|
3454 |
iGameKeyLatch |= iGameKeyState; |
|
3455 |
} |
|
3456 |
||
3457 |
||
3458 |
// --------------------------------------------------------------------------- |
|
3459 |
// CMIDCanvas::GameRelease |
|
3460 |
// Process game release action. |
|
3461 |
// --------------------------------------------------------------------------- |
|
3462 |
// |
|
3463 |
void CMIDCanvas::GameRelease(TInt aGameAction) |
|
3464 |
{ |
|
3465 |
const TInt gameBit = 1 << aGameAction; |
|
3466 |
iGameKeyState &= ~ gameBit; |
|
3467 |
iGameKeyLatch |= iGameKeyState; |
|
3468 |
} |
|
3469 |
||
3470 |
||
3471 |
// --------------------------------------------------------------------------- |
|
3472 |
// CMIDCanvas::SetScalingFactors |
|
3473 |
// Sets MIDlet's original size and target size resolutions if those are |
|
3474 |
// defined in JAD or manifest. If attribute is missing or it's not defined |
|
3475 |
// correctly, the value will be 0,0. This value is later used as an "error |
|
3476 |
// value". |
|
3477 |
// --------------------------------------------------------------------------- |
|
3478 |
// |
|
3479 |
void CMIDCanvas::SetScalingFactors() |
|
3480 |
{ |
|
3481 |
CMIDMenuHandler* menuHandler = iDisplayable->MenuHandler(); |
|
3482 |
||
3483 |
ASSERT(menuHandler); |
|
3484 |
||
3485 |
iScalingOn = menuHandler->IsScalingEnabled(); |
|
3486 |
||
3487 |
iOrgMIDletScrSize = menuHandler->GetScalingParameterOrgMIDletScrSize(); |
|
3488 |
||
3489 |
iTargetMIDletScrSize = |
|
3490 |
menuHandler->GetScalingParameterTargetMIDletScrSize(); |
|
3491 |
||
3492 |
iScaleMIDletOnOrientSwitch = |
|
3493 |
menuHandler->GetScalingParameterScaleMIDletOnOrientSwitch(); |
|
3494 |
} |
|
3495 |
||
3496 |
||
3497 |
// --------------------------------------------------------------------------- |
|
3498 |
// CMIDCanvas::OrientedOrgMIDletScrSize |
|
3499 |
// Returns original MIDlet screen size with regards to display orientation. |
|
3500 |
// --------------------------------------------------------------------------- |
|
3501 |
// |
|
3502 |
TSize CMIDCanvas::OrientedOrgMIDletScrSize() const |
|
3503 |
{ |
|
3504 |
// Ensure that scaling and scaling-on-orientation-switch is enabled. |
|
3505 |
if (iScalingOn && iScaleMIDletOnOrientSwitch) |
|
3506 |
{ |
|
3507 |
TSize orientedSize; |
|
3508 |
||
3509 |
// Ensure that original size is defined as portrait. |
|
3510 |
if (iOrgMIDletScrSize.iWidth < iOrgMIDletScrSize.iHeight) |
|
3511 |
{ |
|
3512 |
orientedSize = iOrgMIDletScrSize; |
|
3513 |
} |
|
3514 |
else |
|
3515 |
{ |
|
3516 |
orientedSize.iWidth = iOrgMIDletScrSize.iHeight; |
|
3517 |
orientedSize.iHeight = iOrgMIDletScrSize.iWidth; |
|
3518 |
} |
|
3519 |
||
3520 |
// Change original size orientation if actuall display orientation |
|
3521 |
// is landscape. |
|
3522 |
if (Layout_Meta_Data::IsLandscapeOrientation()) |
|
3523 |
{ |
|
3524 |
TInt swap = orientedSize.iWidth; |
|
3525 |
orientedSize.iWidth = orientedSize.iHeight; |
|
3526 |
orientedSize.iHeight = swap; |
|
3527 |
} |
|
3528 |
||
3529 |
return orientedSize; |
|
3530 |
} |
|
3531 |
else |
|
3532 |
{ |
|
3533 |
return iOrgMIDletScrSize; |
|
3534 |
} |
|
3535 |
} |
|
3536 |
||
3537 |
// --------------------------------------------------------------------------- |
|
3538 |
// CMIDCanvas::IsNetworkIndicatorEnabledL |
|
3539 |
// Check if the network indicator should be shown in Canvas. |
|
3540 |
// --------------------------------------------------------------------------- |
|
3541 |
// |
|
3542 |
TBool CMIDCanvas::IsNetworkIndicatorEnabledL() const |
|
3543 |
{ |
|
3544 |
#ifndef RD_JAVA_S60_RELEASE_9_2 |
|
3545 |
if (RProcess().SecureId().iId != 0x102033E6) |
|
3546 |
{ |
|
3547 |
// For standalone type apps we don't show indicator. |
|
3548 |
return EFalse; |
|
3549 |
} |
|
3550 |
TBool enabled = ETrue; // Return ETrue by default. |
|
3551 |
||
3552 |
std::auto_ptr<java::storage::JavaStorage> js(java::storage::JavaStorage::createInstance()); |
|
3553 |
java::storage::JavaStorageApplicationEntry_t entries; |
|
3554 |
try |
|
3555 |
{ |
|
3556 |
js->open(); |
|
3557 |
java::util::Uid uid; |
|
3558 |
TUidToUid(iEnv.MidletSuiteUid(), uid); |
|
3559 |
js->read(java::storage::MIDP_PACKAGE_TABLE, uid, entries); |
|
3560 |
js->close(); |
|
3561 |
} |
|
3562 |
catch (java::storage::JavaStorageException& ex) |
|
3563 |
{ |
|
3564 |
DEBUG_INT("CMIDCanvas::IsNetworkIndicatorEnabledL: JavaStorage error: \ |
|
3565 |
reading MIDP_PACKAGE_TABLE failed, error code = %D", ex.mStatus); |
|
3566 |
} |
|
3567 |
java::storage::JavaStorageEntry attribute; |
|
3568 |
attribute.setEntry(java::storage::SECURITY_DOMAIN_CATEGORY, L""); |
|
3569 |
java::storage::JavaStorageApplicationEntry_t::const_iterator findIterator = entries.find(attribute); |
|
3570 |
std::wstring res = L""; |
|
3571 |
if (findIterator != entries.end()) |
|
3572 |
{ |
|
3573 |
res = (*findIterator).entryValue(); |
|
3574 |
} |
|
3575 |
entries.clear(); |
|
3576 |
||
3577 |
if (res == MANUFACTURER_DOMAIN_CATEGORY) |
|
3578 |
{ |
|
3579 |
enabled = EFalse; |
|
3580 |
} |
|
3581 |
else if (res == OPERATOR_DOMAIN_CATEGORY) |
|
3582 |
{ |
|
3583 |
// Read the central repository key to find out if the |
|
3584 |
// network indicator should be shown for midlets in |
|
3585 |
// operator domain. |
|
3586 |
CRepository* repository = NULL; |
|
3587 |
TRAPD(err, repository = CRepository::NewL(KCRUidMidpLcdui)); |
|
3588 |
||
3589 |
if (err == KErrNone) |
|
3590 |
{ |
|
3591 |
err = repository->Get(KShowCanvasNetIndicatorInOperatorDomain, enabled); |
|
3592 |
if (err != KErrNone) |
|
3593 |
{ |
|
3594 |
DEBUG_INT("CMIDCanvas::IsNetworkIndicatorEnabledL: \ |
|
3595 |
reading CenRep key failed, error code = %D", err); |
|
3596 |
} |
|
3597 |
} |
|
3598 |
||
3599 |
delete repository; |
|
3600 |
repository = NULL; |
|
3601 |
} |
|
3602 |
||
3603 |
return enabled; |
|
3604 |
#else |
|
3605 |
// Network and Call indicator is disabled for 9_2 |
|
3606 |
return EFalse; |
|
3607 |
#endif //RD_JAVA_S60_RELEASE_9_2 |
|
3608 |
} |
|
3609 |
||
3610 |
// --------------------------------------------------------------------------- |
|
3611 |
// CMIDCanvas::HandleForeground |
|
3612 |
// Relases resources in graphics HW (=pixel source or EGL resources) |
|
3613 |
// when going to background. |
|
3614 |
// --------------------------------------------------------------------------- |
|
3615 |
// |
|
3616 |
void CMIDCanvas::HandleForeground(TBool aForeground) |
|
3617 |
{ |
|
3618 |
DEBUG_INT("CMIDCanvas::HandleForeground(%d) ++", aForeground); |
|
3619 |
||
3620 |
// If foreground/background state is changed, |
|
3621 |
// then we need resize all custom components. |
|
3622 |
if (iForeground != aForeground && iCustomComponents.Count() > 0) |
|
3623 |
{ |
|
3624 |
for (int i = 0; i < iCustomComponents.Count(); i++) |
|
3625 |
{ |
|
3626 |
iCustomComponents[i]->HandleForeground(aForeground); |
|
3627 |
} |
|
3628 |
} |
|
3629 |
||
3630 |
iForeground = aForeground; |
|
3631 |
||
3632 |
#ifdef RD_JAVA_NGA_ENABLED |
|
3633 |
if (!aForeground) |
|
3634 |
{ |
|
3635 |
FreeGraphicsMemory(EFalse); |
|
3636 |
} |
|
3637 |
#endif // RD_JAVA_NGA_ENABLED |
|
3638 |
||
3639 |
DEBUG("CMIDCanvas::HandleForeground --"); |
|
3640 |
} |
|
3641 |
||
3642 |
#ifdef RD_JAVA_NGA_ENABLED |
|
3643 |
// --------------------------------------------------------------------------- |
|
3644 |
// CMIDCanvas::HandleFullOrPartialForegroundL |
|
3645 |
// --------------------------------------------------------------------------- |
|
3646 |
// |
|
3647 |
void CMIDCanvas::HandleFullOrPartialForegroundL( |
|
3648 |
TBool aFullOrPartialFg, TBool aCurrentDisplayable) |
|
3649 |
{ |
|
77
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
71
diff
changeset
|
3650 |
if (!aFullOrPartialFg) |
66 | 3651 |
{ |
3652 |
FreeGraphicsMemory(ETrue); |
|
3653 |
} |
|
77
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
71
diff
changeset
|
3654 |
|
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
71
diff
changeset
|
3655 |
// If canvas is not the current displayable but visible when MIDlet has gained |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
71
diff
changeset
|
3656 |
// foreground, need to invoke forced paint to get content updated on screen |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
71
diff
changeset
|
3657 |
if (aFullOrPartialFg && !aCurrentDisplayable && IsVisible()) |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
71
diff
changeset
|
3658 |
{ |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
71
diff
changeset
|
3659 |
PostForcedPaint(); |
66 | 3660 |
} |
3661 |
} |
|
3662 |
||
3663 |
// --------------------------------------------------------------------------- |
|
3664 |
// CMIDCanvas::FreeGraphicsMemory |
|
3665 |
// Free GPU memory if the canvas is not visible anymore. If aForced is true, |
|
3666 |
// visibility is not checked. |
|
3667 |
// --------------------------------------------------------------------------- |
|
3668 |
// |
|
3669 |
void CMIDCanvas::FreeGraphicsMemory(TBool aForced) |
|
3670 |
{ |
|
3671 |
// No freeing in exit case to avoid flickering |
|
3672 |
if ((!aForced && IsWindowVisible()) || iExiting) |
|
3673 |
{ |
|
3674 |
return; |
|
3675 |
} |
|
3676 |
||
3677 |
if (IsEglAvailable()) |
|
3678 |
{ |
|
3679 |
if (iEglOccupied) |
|
3680 |
{ |
|
3681 |
DEBUG("CMIDCanvas::FreeGraphcisMemory() - egl - pending dispose"); |
|
3682 |
iEglPendingDispose = ETrue; |
|
3683 |
} |
|
3684 |
else |
|
3685 |
{ |
|
3686 |
CloseEgl(ETrue); |
|
3687 |
// If MIDlet is not visible on foreground post event to Java |
|
3688 |
// so that M3G is notfied and frees the m3gCore memory |
|
3689 |
if (!iEnv.HasFullOrPartialForeground()) |
|
3690 |
{ |
|
3691 |
iEnv.PostMidletEvent(EFreeGraphicsMemory); |
|
3692 |
eglReleaseThread(); |
|
3693 |
} |
|
3694 |
} |
|
3695 |
} |
|
3696 |
||
3697 |
SuspendPixelSource(); |
|
3698 |
} |
|
3699 |
||
3700 |
// --------------------------------------------------------------------------- |
|
3701 |
// CMIDCanvas::InitPixelSourceL() |
|
3702 |
// --------------------------------------------------------------------------- |
|
3703 |
// |
|
3704 |
void CMIDCanvas::InitPixelSourceL() |
|
3705 |
{ |
|
3706 |
if (iAlfCompositionPixelSource) |
|
3707 |
{ |
|
3708 |
return; |
|
3709 |
} |
|
3710 |
iPixelSourceSuspended = ETrue; |
|
3711 |
TBool modeSupported = EFalse; |
|
3712 |
switch (iFrameBuffer->DisplayMode()) |
|
3713 |
{ |
|
3714 |
case EColor16MU: |
|
3715 |
modeSupported = ETrue; |
|
3716 |
iAlfBufferAttributes.iFormat = |
|
3717 |
MAlfBufferProvider::ESourceFormatXRGB_8888; |
|
3718 |
break; |
|
3719 |
case EColor16MA: |
|
3720 |
modeSupported = ETrue; |
|
3721 |
iAlfBufferAttributes.iFormat = |
|
3722 |
MAlfBufferProvider::ESourceFormatARGB_8888; |
|
3723 |
break; |
|
3724 |
case EColor16MAP: |
|
3725 |
modeSupported = ETrue; |
|
3726 |
iAlfBufferAttributes.iFormat = |
|
3727 |
MAlfBufferProvider::ESourceFormatARGB_8888_PRE; |
|
3728 |
break; |
|
3729 |
default: |
|
3730 |
break; |
|
3731 |
} |
|
3732 |
||
3733 |
if (modeSupported) |
|
3734 |
{ |
|
3735 |
iAlfCompositionPixelSource = CAlfCompositionPixelSource::NewL(*this, &Window()); |
|
3736 |
||
3737 |
iAlfBufferAttributes.iWidth = iContentSize.iWidth; |
|
3738 |
iAlfBufferAttributes.iHeight = iContentSize.iHeight; |
|
3739 |
iAlfBufferAttributes.iStride = iAlfBufferAttributes.iWidth * KBytesPerPixel; |
|
3740 |
iAlfBufferAttributes.iAlignment = 32; |
|
3741 |
} |
|
3742 |
} |
|
3743 |
||
3744 |
// --------------------------------------------------------------------------- |
|
3745 |
// CMIDCanvas::DisposePixelSource |
|
3746 |
// --------------------------------------------------------------------------- |
|
3747 |
// |
|
3748 |
void CMIDCanvas::DisposePixelSource() |
|
3749 |
{ |
|
3750 |
DEBUG("CMIDCanvas::DisposePixelSource ++"); |
|
3751 |
NotifyMonitor(); |
|
3752 |
if (iAlfCompositionPixelSource) |
|
3753 |
{ |
|
3754 |
DEBUG("CMIDCanvas::DisposePixelSource - delete alf"); |
|
3755 |
iAlfCompositionPixelSource->Suspend(); |
|
3756 |
delete iAlfCompositionPixelSource; |
|
3757 |
iAlfCompositionPixelSource = NULL; |
|
3758 |
} |
|
3759 |
DEBUG("CMIDCanvas::DisposePixelSource --"); |
|
3760 |
} |
|
3761 |
||
3762 |
// --------------------------------------------------------------------------- |
|
3763 |
// CMIDCanvas::ActivatePixelSourceL |
|
3764 |
// In scaling case need to call SetExtent() again if pixel source was suspended. |
|
3765 |
// --------------------------------------------------------------------------- |
|
3766 |
// |
|
3767 |
void CMIDCanvas::ActivatePixelSourceL(TBool aDrawingOngoing) |
|
3768 |
{ |
|
3769 |
ASSERT(iAlfCompositionPixelSource); |
|
3770 |
||
3771 |
if (iDirectContents.Count() > 0) |
|
3772 |
{ |
|
3773 |
return; |
|
3774 |
} |
|
3775 |
||
3776 |
// Don't activate, if there is no valid content from Java yet |
|
3777 |
if (!ReadyToBlit()) |
|
3778 |
{ |
|
3779 |
return; |
|
3780 |
} |
|
3781 |
||
3782 |
// ProduceNewFrameL() is called directly from ActivateSyncL() |
|
3783 |
// if pixel source is suspended, need to set iFrameReady |
|
3784 |
// before ActivateSyncL() |
|
3785 |
iFrameReady = ETrue; |
|
3786 |
TRAPD(err, iAlfCompositionPixelSource->ActivateSyncL()); |
|
3787 |
if (err != KErrNone) |
|
3788 |
{ |
|
3789 |
iFrameReady = EFalse; |
|
3790 |
User::Leave(err); |
|
3791 |
} |
|
3792 |
||
3793 |
if (iPixelSourceSuspended) |
|
3794 |
{ |
|
3795 |
iPixelSourceSuspended = EFalse; |
|
3796 |
if (iFullScreen && iScalingOn) |
|
3797 |
{ |
|
3798 |
TRect targetRect = iViewRect; |
|
3799 |
targetRect.Move(iPositionRelativeToScreen); |
|
3800 |
iAlfCompositionPixelSource->SetExtent(targetRect, KPhoneScreen); |
|
3801 |
// Flag is set to in order that screen gets updated at least once |
|
3802 |
// after SetExtent() call |
|
3803 |
iFrameReady = ETrue; |
|
3804 |
} |
|
3805 |
||
3806 |
if (!aDrawingOngoing) |
|
3807 |
{ |
|
3808 |
ClearUiSurface(aDrawingOngoing); |
|
3809 |
iCoeEnv->WsSession().Finish(); |
|
3810 |
} |
|
3811 |
} |
|
3812 |
} |
|
3813 |
||
3814 |
// --------------------------------------------------------------------------- |
|
3815 |
// CMIDCanvas::ClearUiSurface |
|
3816 |
// --------------------------------------------------------------------------- |
|
3817 |
// |
|
3818 |
void CMIDCanvas::ClearUiSurface(TBool aDrawing) |
|
3819 |
{ |
|
3820 |
if (!aDrawing) |
|
3821 |
{ |
|
3822 |
Window().BeginRedraw(); |
|
3823 |
ActivateGc(); |
|
3824 |
} |
|
3825 |
CWindowGc& gc = SystemGc(); |
|
3826 |
gc.SetBrushColor(KTransparentClearColor); |
|
3827 |
gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); |
|
3828 |
gc.Clear(); |
|
3829 |
||
3830 |
// Clearing is done via EGL in scaled M3G case |
|
3831 |
if (iScalingOn && iFullScreen && !IsEglAvailable()) |
|
3832 |
{ |
|
3833 |
const TRect rect = Rect(); |
|
3834 |
if (rect != iViewRect) |
|
3835 |
{ |
|
3836 |
gc.SetBrushColor(KRgbBlack); |
|
3837 |
gc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
3838 |
DrawUtils::ClearBetweenRects(gc, rect, iViewRect); |
|
3839 |
} |
|
3840 |
} |
|
3841 |
||
3842 |
if (!aDrawing) |
|
3843 |
{ |
|
3844 |
DeactivateGc(); |
|
3845 |
Window().EndRedraw(); |
|
3846 |
} |
|
3847 |
} |
|
3848 |
||
3849 |
// --------------------------------------------------------------------------- |
|
3850 |
// CMIDCanvas::DrawToWindowGc |
|
3851 |
// Draws current frame buffer content to CWindowGc |
|
3852 |
// --------------------------------------------------------------------------- |
|
3853 |
// |
|
3854 |
void CMIDCanvas::DrawToWindowGc() |
|
3855 |
{ |
|
3856 |
if (iDirectContents.Count() > 0 || |
|
3857 |
!IsWindowVisible() || |
|
3858 |
!iForeground) |
|
3859 |
{ |
|
3860 |
return; |
|
3861 |
} |
|
3862 |
||
3863 |
Window().BeginRedraw(); |
|
3864 |
ActivateGc(); |
|
3865 |
||
3866 |
TRect rect = (iFullScreen && iScalingOn) ? iViewRect : Rect(); |
|
3867 |
DrawWindow(rect); |
|
3868 |
||
3869 |
DeactivateGc(); |
|
3870 |
Window().EndRedraw(); |
|
3871 |
||
3872 |
iCoeEnv->WsSession().Finish(); |
|
3873 |
} |
|
3874 |
||
3875 |
// --------------------------------------------------------------------------- |
|
3876 |
// CMIDCanvas::SuspendPixelSource |
|
3877 |
// --------------------------------------------------------------------------- |
|
3878 |
// |
|
3879 |
void CMIDCanvas::SuspendPixelSource() |
|
3880 |
{ |
|
3881 |
NotifyMonitor(); |
|
3882 |
if (iAlfCompositionPixelSource && !iPixelSourceSuspended) |
|
3883 |
{ |
|
3884 |
iAlfCompositionPixelSource->Suspend(); |
|
3885 |
iPixelSourceSuspended = ETrue; |
|
3886 |
} |
|
3887 |
} |
|
3888 |
||
3889 |
// --------------------------------------------------------------------------- |
|
3890 |
// CMIDCanvas::NotifyMonitor |
|
3891 |
// CMIDCanvas::ProcessL() is asyncronous when CAlfCompositionPixelSource is used. |
|
3892 |
// This notiCMIDBuffer's monitor so that waiting Java thread is resumed. |
|
3893 |
// --------------------------------------------------------------------------- |
|
3894 |
// |
|
3895 |
void CMIDCanvas::NotifyMonitor() |
|
3896 |
{ |
|
3897 |
if (iAlfMonitor) |
|
3898 |
{ |
|
3899 |
iAlfMonitor->notify(); |
|
3900 |
iAlfMonitor = NULL; |
|
3901 |
} |
|
3902 |
iFrameReady = EFalse; |
|
3903 |
} |
|
3904 |
||
3905 |
// --------------------------------------------------------------------------- |
|
3906 |
// From MAlfBufferProvider |
|
3907 |
// CMIDCanvas::ProduceNewFrameL |
|
3908 |
// Callback from CAlfCompositionPixelSource. Copy RGB data from framebuffer |
|
3909 |
// to pixel source's buffer. Return ETrue if we have a frame ready, |
|
3910 |
// EFalse otherwise. |
|
3911 |
// --------------------------------------------------------------------------- |
|
3912 |
// |
|
3913 |
TBool CMIDCanvas::ProduceNewFrameL(const TRegion& aVisibleRegion, TUint8*& aBuffer) |
|
3914 |
{ |
|
3915 |
DEBUG_INT("CMIDCanvas::ProduceNewFrameL (thread=%d) ++", RThread().Id().Id()); |
|
3916 |
TRect bbox(aVisibleRegion.BoundingRect()); |
|
3917 |
DEBUG_INT4("CMIDCanvas::ProduceNewFrameL - visible region(x=%d, y=%d, w=%d, h=%d) ++", |
|
3918 |
bbox.iTl.iX, bbox.iTl.iY, bbox.Width(), bbox.Height()); |
|
3919 |
||
3920 |
// If iDirectContents.Count() > 0, canvas hasn't received |
|
3921 |
// MdcNotifyContentAdded in LCDUI thread yet. |
|
3922 |
TBool res; |
|
3923 |
if (!iFrameReady || iDirectContents.Count() > 0) |
|
3924 |
{ |
|
3925 |
DEBUG("CMIDCanvas::ProduceNewFrameL - FRAME IS NOT READY --"); |
|
3926 |
NotifyMonitor(); |
|
3927 |
res = EFalse; |
|
3928 |
} |
|
3929 |
else |
|
3930 |
{ |
|
3931 |
NotifyMonitor(); |
|
3932 |
||
3933 |
TUint8* from = (TUint8*)iFrameBuffer->DataAddress(); |
|
3934 |
||
3935 |
TBool downScaling = IsDownScaling(iContentSize, iViewRect, iM3GContent); |
|
3936 |
TInt width = downScaling ? iViewRect.Width() : iContentSize.iWidth; |
|
3937 |
TInt height = downScaling ? iViewRect.Height() : iContentSize.iHeight; |
|
3938 |
||
3939 |
TUint bytes = width * KBytesPerPixel; |
|
3940 |
TInt scanLength = CFbsBitmap::ScanLineLength( |
|
3941 |
iFrameBuffer->SizeInPixels().iWidth, iFrameBuffer->DisplayMode()); |
|
3942 |
||
3943 |
for (TInt y = 0; y < height; ++y) |
|
3944 |
{ |
|
3945 |
Mem::Copy(aBuffer, from, bytes); |
|
3946 |
aBuffer += iAlfBufferAttributes.iStride; |
|
3947 |
from += scanLength; |
|
3948 |
} |
|
3949 |
||
3950 |
res = ETrue; |
|
3951 |
} |
|
3952 |
||
3953 |
if (iFirstPaintState == EFirstPaintInitiated || iFirstPaintState == EFirstPaintPrepared) |
|
3954 |
{ |
|
3955 |
if (iFirstPaintState == EFirstPaintInitiated) |
|
3956 |
{ |
|
3957 |
iFirstPaintState = EFirstPaintPrepared; |
|
3958 |
} |
|
3959 |
else |
|
3960 |
{ |
|
3961 |
iFirstPaintState = EFirstPaintOccurred; |
|
3962 |
java::ui::CoreUiAvkonLcdui::getInstance().getJavaUiAppUi()->stopStartScreen(); |
|
3963 |
} |
|
3964 |
} |
|
3965 |
||
3966 |
DEBUG("CMIDCanvas::ProduceNewFrameL --"); |
|
3967 |
||
3968 |
return res; |
|
3969 |
} |
|
3970 |
||
3971 |
// --------------------------------------------------------------------------- |
|
3972 |
// From MAlfBufferProvider |
|
3973 |
// CMIDCanvas::BufferAttributes |
|
3974 |
// Called by CAlfCompositionPixelSource to get the size of RGB data. |
|
3975 |
// --------------------------------------------------------------------------- |
|
3976 |
// |
|
3977 |
MAlfBufferProvider::TBufferCreationAttributes& CMIDCanvas::BufferAttributes() |
|
3978 |
{ |
|
3979 |
DEBUG_INT2("CMIDCanvas::BufferAttributes - iContentSize(w=%d, h=%d) ++", |
|
3980 |
iContentSize.iWidth, iContentSize.iHeight); |
|
3981 |
||
3982 |
TBool downScaling = IsDownScaling(iContentSize, iViewRect, iM3GContent); |
|
3983 |
iAlfBufferAttributes.iWidth = downScaling ? iViewRect.Width() : iContentSize.iWidth; |
|
3984 |
iAlfBufferAttributes.iHeight = downScaling ? iViewRect.Height() : iContentSize.iHeight; |
|
3985 |
||
3986 |
iAlfBufferAttributes.iStride = iAlfBufferAttributes.iWidth * KBytesPerPixel; |
|
3987 |
return iAlfBufferAttributes; |
|
3988 |
} |
|
3989 |
||
3990 |
// --------------------------------------------------------------------------- |
|
3991 |
// From MAlfBufferProvider |
|
3992 |
// CMIDCanvas::ContextAboutToSuspend |
|
3993 |
// Notification from Alf. |
|
3994 |
// --------------------------------------------------------------------------- |
|
3995 |
// |
|
3996 |
void CMIDCanvas::ContextAboutToSuspend() |
|
3997 |
{ |
|
3998 |
DEBUG("CMIDCanvas::ContextAboutToSuspend() ++"); |
|
3999 |
NotifyMonitor(); |
|
4000 |
iPixelSourceSuspended = ETrue; |
|
4001 |
DEBUG("CMIDCanvas::ContextAboutToSuspend() --"); |
|
4002 |
} |
|
4003 |
||
4004 |
// --------------------------------------------------------------------------- |
|
4005 |
// From MAlfBufferProvider |
|
4006 |
// CMIDCanvas::OnActivation |
|
4007 |
// Notification from Alf. |
|
4008 |
// --------------------------------------------------------------------------- |
|
4009 |
// |
|
4010 |
void CMIDCanvas::OnActivation() |
|
4011 |
{ |
|
4012 |
DEBUG("CMIDCanvas::OnActivation()++--"); |
|
4013 |
} |
|
4014 |
||
4015 |
||
4016 |
// --------------------------------------------------------------------------- |
|
4017 |
// CMIDCanvas::OpenEglL |
|
4018 |
// Creates EGL window surface and context. Only 32 bit display modes are |
|
4019 |
// supported. |
|
4020 |
// --------------------------------------------------------------------------- |
|
4021 |
// |
|
4022 |
void CMIDCanvas::OpenEglL() |
|
4023 |
{ |
|
4024 |
if (IsEglAvailable()) |
|
4025 |
{ |
|
4026 |
return; |
|
4027 |
} |
|
4028 |
||
4029 |
DEBUG("CMIDCanvas::OpenEglL() ++"); |
|
4030 |
||
4031 |
if (iEglDisplay == EGL_NO_DISPLAY) |
|
4032 |
{ |
|
4033 |
iEglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); |
|
4034 |
||
4035 |
// Initializing an already initialized display has no effect. |
|
4036 |
// eglTerminate is not called in LCDUI side ever, only by M3G |
|
4037 |
if (eglInitialize(iEglDisplay, NULL, NULL) == EGL_FALSE) |
|
4038 |
{ |
|
4039 |
ELOG1(EJavaUI, "eglInitialize() failed, eglError=%d", eglGetError()); |
|
4040 |
User::Leave(KErrNotSupported); |
|
4041 |
} |
|
4042 |
} |
|
4043 |
||
4044 |
RWindow& window = Window(); |
|
4045 |
// Choose the buffer size based on the Window's display mode. |
|
4046 |
TDisplayMode displayMode = window.DisplayMode(); |
|
4047 |
TInt bufferSize = 0; |
|
4048 |
switch (displayMode) |
|
4049 |
{ |
|
4050 |
case(EColor16MU): |
|
4051 |
case(EColor16MA): |
|
4052 |
case(EColor16MAP): |
|
4053 |
bufferSize = 32; |
|
4054 |
break; |
|
4055 |
default: |
|
4056 |
ELOG1(EJavaUI, "CMIDCanvas::OpenEglL(): unsupported window display mode %d", |
|
4057 |
displayMode); |
|
4058 |
User::Leave(KErrNotSupported); |
|
4059 |
break; |
|
4060 |
} |
|
4061 |
||
4062 |
EGLint surfaceType = EGL_WINDOW_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT; |
|
4063 |
||
4064 |
const EGLint attributeList[] = |
|
4065 |
{ |
|
4066 |
EGL_SURFACE_TYPE, surfaceType, |
|
4067 |
EGL_RED_SIZE, 8, |
|
4068 |
EGL_GREEN_SIZE, 8, |
|
4069 |
EGL_BLUE_SIZE, 8, |
|
4070 |
EGL_ALPHA_SIZE, 8, |
|
4071 |
EGL_BUFFER_SIZE, bufferSize, |
|
4072 |
EGL_TRANSPARENT_TYPE, EGL_NONE, |
|
4073 |
EGL_DEPTH_SIZE, 16, |
|
4074 |
EGL_NONE |
|
4075 |
}; |
|
4076 |
||
4077 |
EGLint numConfigs = 0; |
|
4078 |
||
4079 |
// Choose the best EGLConfig that matches the desired properties. |
|
4080 |
if ((eglChooseConfig(iEglDisplay, attributeList, &iEglConfig, 1, &numConfigs) == EGL_FALSE) || |
|
4081 |
numConfigs == 0) |
|
4082 |
{ |
|
4083 |
ELOG1(EJavaUI, "eglChooseConfig() failed, eglError=%d", eglGetError()); |
|
4084 |
User::Leave(KErrNotSupported); |
|
4085 |
} |
|
4086 |
||
4087 |
// Check that surface content is preserved in swap, otherwise the |
|
4088 |
// game canvas content cannot be preserved. |
|
4089 |
eglGetConfigAttrib(iEglDisplay, iEglConfig, EGL_SURFACE_TYPE, &surfaceType); |
|
4090 |
if (surfaceType & EGL_SWAP_BEHAVIOR_PRESERVED_BIT == 0) |
|
4091 |
{ |
|
4092 |
ELOG(EJavaUI, "Egl config does not support EGL_SWAP_BEHAVIOR_PRESERVED_BIT"); |
|
4093 |
User::Leave(KErrNotSupported); |
|
4094 |
} |
|
4095 |
||
4096 |
// Create a window surface where the graphics are blitted. |
|
4097 |
// Pass the Native Window handle to egl. |
|
4098 |
iEglWindowSurface = eglCreateWindowSurface(iEglDisplay, iEglConfig, (void*)&window, NULL); |
|
4099 |
if (iEglWindowSurface == EGL_NO_SURFACE) |
|
4100 |
{ |
|
4101 |
ELOG1(EJavaUI, "eglCreateWindowSurface() failed, eglError=%d", eglGetError()); |
|
4102 |
User::Leave(KErrNoMemory); |
|
4103 |
} |
|
4104 |
// Need to preserve surface content after swapping |
|
4105 |
eglSurfaceAttrib(iEglDisplay, iEglWindowSurface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED); |
|
4106 |
||
4107 |
CreateEglContext(); |
|
4108 |
ClearEglSurface(EEglWindow); |
|
4109 |
||
4110 |
// Allocate memory for ARGB->RGBA conversion needed by |
|
4111 |
// openGL texture |
|
4112 |
if (!iTexturePixels) |
|
4113 |
{ |
|
4114 |
iTexturePixels = new(ELeave) TUint8[KMaxBlitSize * KMaxBlitSize * KBytesPerPixel]; |
|
4115 |
} |
|
4116 |
glDisable(GL_DEPTH_TEST); |
|
4117 |
glDisable(GL_LIGHTING); |
|
4118 |
glEnableClientState(GL_VERTEX_ARRAY); |
|
4119 |
if (!iVertexArray) |
|
4120 |
{ |
|
4121 |
iVertexArray = new(ELeave) GLshort[8]; |
|
4122 |
} |
|
4123 |
if (!iTriangleStrip) |
|
4124 |
{ |
|
4125 |
iTriangleStrip = new(ELeave) GLubyte[4]; |
|
4126 |
iTriangleStrip[0] = 0; |
|
4127 |
iTriangleStrip[1] = 1; |
|
4128 |
iTriangleStrip[2] = 3; |
|
4129 |
iTriangleStrip[3] = 2; |
|
4130 |
} |
|
4131 |
DEBUG("CMIDCanvas::OpenEglL() --"); |
|
4132 |
} |
|
4133 |
||
4134 |
// --------------------------------------------------------------------------- |
|
4135 |
// CMIDCanvas::CloseEgl |
|
4136 |
// Destroys EGL contexts and surfaces. |
|
4137 |
// --------------------------------------------------------------------------- |
|
4138 |
// |
|
4139 |
void CMIDCanvas::CloseEgl(TBool aReadback) |
|
4140 |
{ |
|
4141 |
DEBUG("CMIDCanvas::CloseEglL() ++"); |
|
4142 |
||
4143 |
iM3GContent = EFalse; |
|
4144 |
iM3GStart = EFalse; |
|
4145 |
iEglPendingResize = EFalse; |
|
4146 |
iEglPendingDispose = EFalse; |
|
4147 |
PostEvent(EM3GDraw, iM3GContent, 0); |
|
4148 |
if (iEglDisplay == EGL_NO_DISPLAY) |
|
4149 |
{ |
|
4150 |
return; |
|
4151 |
} |
|
4152 |
||
4153 |
// MIDlet might draw only 2D after this => |
|
4154 |
// need to set frame buffer opaque to be compatible with |
|
4155 |
// blending methods in Lcdgd. UpdateOffScreenBitmapL() does this too. |
|
4156 |
if (!aReadback && iFrameContext) |
|
4157 |
{ |
|
4158 |
iFrameContext->SetBrushColor(KOpaqueClearColor); |
|
4159 |
iFrameContext->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); |
|
4160 |
iFrameContext->Clear(); |
|
4161 |
} |
|
4162 |
||
4163 |
// Take a snapshot from window surface to the frame buffer. |
|
4164 |
if (aReadback) |
|
4165 |
{ |
|
4166 |
TRAPD(err, UpdateOffScreenBitmapL(ETrue)); |
|
4167 |
if (err != KErrNone) |
|
4168 |
{ |
|
4169 |
DEBUG("CMIDCanvas::CloseEgl() - UpdateOffScreenBitmapL() failed"); |
|
4170 |
} |
|
4171 |
} |
|
4172 |
||
4173 |
// make sure the we have no current target |
|
4174 |
// so that surfaces and contexts are destoyed immediately |
|
4175 |
SetCurrentEglType(EEglNone); |
|
4176 |
||
4177 |
// If pbuffer has been created dispose that here |
|
4178 |
if (iEglPbufferSurfaceContext != EGL_NO_CONTEXT || |
|
4179 |
iEglPbufferSurface != EGL_NO_SURFACE) |
|
4180 |
{ |
|
4181 |
DisposePBufferSurface(); |
|
4182 |
} |
|
4183 |
||
4184 |
if (iEglWindowSurfaceContext != EGL_NO_CONTEXT) |
|
4185 |
{ |
|
4186 |
eglDestroyContext(iEglDisplay, iEglWindowSurfaceContext); |
|
4187 |
iEglWindowSurfaceContext = EGL_NO_CONTEXT; |
|
4188 |
} |
|
4189 |
if (iEglWindowSurface != EGL_NO_SURFACE) |
|
4190 |
{ |
|
4191 |
eglDestroySurface(iEglDisplay, iEglWindowSurface); |
|
4192 |
iEglWindowSurface = EGL_NO_SURFACE; |
|
4193 |
} |
|
4194 |
||
4195 |
DEBUG("CMIDCanvas::CloseEglL() --"); |
|
4196 |
} |
|
4197 |
||
4198 |
// --------------------------------------------------------------------------- |
|
4199 |
// CMIDCanvas::CreateEglContext |
|
4200 |
// (Re)create EGL context |
|
4201 |
// --------------------------------------------------------------------------- |
|
4202 |
// |
|
4203 |
void CMIDCanvas::CreateEglContext() |
|
4204 |
{ |
|
4205 |
if (iEglWindowSurfaceContext != EGL_NO_CONTEXT) |
|
4206 |
{ |
|
4207 |
SetCurrentEglType(EEglNone); |
|
4208 |
eglDestroyContext(iEglDisplay, iEglWindowSurfaceContext); |
|
4209 |
iEglWindowSurfaceContext = EGL_NO_CONTEXT; |
|
4210 |
} |
|
4211 |
// Create a rendering context |
|
4212 |
iEglWindowSurfaceContext = eglCreateContext(iEglDisplay, iEglConfig, EGL_NO_CONTEXT, NULL); |
|
4213 |
if (iEglWindowSurfaceContext == EGL_NO_CONTEXT) |
|
4214 |
{ |
|
4215 |
ELOG1(EJavaUI, "eglCreateContext() failed, eglError=%d", eglGetError()); |
|
4216 |
} |
|
4217 |
} |
|
4218 |
||
4219 |
// --------------------------------------------------------------------------- |
|
4220 |
// CMIDCanvas::SetCurrentEglType |
|
4221 |
// Sets the current EGL context and surface. |
|
4222 |
// --------------------------------------------------------------------------- |
|
4223 |
// |
|
4224 |
TBool CMIDCanvas::SetCurrentEglType(TEglType aType) |
|
4225 |
{ |
|
4226 |
EGLBoolean res = EGL_TRUE; |
|
4227 |
if (aType == EEglPbuffer) |
|
4228 |
{ |
|
4229 |
res = eglMakeCurrent( |
|
4230 |
iEglDisplay, iEglPbufferSurface, iEglPbufferSurface, iEglPbufferSurfaceContext); |
|
4231 |
} |
|
4232 |
else if (aType == EEglWindow) |
|
4233 |
{ |
|
4234 |
res = eglMakeCurrent( |
|
4235 |
iEglDisplay, iEglWindowSurface, iEglWindowSurface, iEglWindowSurfaceContext); |
|
4236 |
} |
|
4237 |
else |
|
4238 |
{ |
|
4239 |
res = eglMakeCurrent( |
|
4240 |
iEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |
|
4241 |
} |
|
4242 |
if (res == EGL_FALSE) |
|
4243 |
{ |
|
4244 |
ELOG1(EJavaUI, "eglMakeCurrent() failed, eglError=%s", GetEglError(eglGetError()).Ptr()); |
|
4245 |
} |
|
4246 |
return (res == EGL_FALSE ? EFalse : ETrue); |
|
4247 |
} |
|
4248 |
||
4249 |
// --------------------------------------------------------------------------- |
|
4250 |
// CMIDCanvas::GetCurrentEgl |
|
4251 |
// Gets the current EGL type |
|
4252 |
// --------------------------------------------------------------------------- |
|
4253 |
// |
|
4254 |
CMIDCanvas::TEglType CMIDCanvas::GetCurrentEglType() |
|
4255 |
{ |
|
4256 |
EGLSurface surface = eglGetCurrentSurface(EGL_READ); |
|
4257 |
if (surface == EGL_NO_SURFACE) |
|
4258 |
{ |
|
4259 |
return EEglNone; |
|
4260 |
} |
|
4261 |
else if (surface == iEglPbufferSurface) |
|
4262 |
{ |
|
4263 |
return EEglPbuffer; |
|
4264 |
} |
|
4265 |
else |
|
4266 |
{ |
|
4267 |
return EEglWindow; |
|
4268 |
} |
|
4269 |
} |
|
4270 |
||
4271 |
// --------------------------------------------------------------------------- |
|
4272 |
// CMIDCanvas::GetEglSurfaceSize |
|
4273 |
// Returns size of the EGL surface. |
|
4274 |
// --------------------------------------------------------------------------- |
|
4275 |
// |
|
4276 |
TSize CMIDCanvas::GetEglSurfaceSize(EGLSurface aSurface) |
|
4277 |
{ |
|
4278 |
TSize sz; |
|
4279 |
if (aSurface == EGL_NO_SURFACE) |
|
4280 |
{ |
|
4281 |
aSurface = iEglWindowSurface; |
|
4282 |
if (iScalingOn && iFullScreen) |
|
4283 |
{ |
|
4284 |
aSurface = iEglPbufferSurface; |
|
4285 |
} |
|
4286 |
} |
|
4287 |
if (!(eglQuerySurface(iEglDisplay, aSurface, EGL_WIDTH, &sz.iWidth) && |
|
4288 |
eglQuerySurface(iEglDisplay, aSurface, EGL_HEIGHT, &sz.iHeight))) |
|
4289 |
{ |
|
4290 |
sz.SetSize(0, 0); |
|
4291 |
} |
|
4292 |
DEBUG_INT2("CMIDCanvas::GetEglSurfaceSizeL() - w=%d, h=%d", sz.iWidth, sz.iHeight); |
|
4293 |
return sz; |
|
4294 |
} |
|
4295 |
||
4296 |
// --------------------------------------------------------------------------- |
|
4297 |
// CMIDCanvas::HandleSizeChanged() |
|
4298 |
// EGL cannot handle window resize upwards and in this case we need to |
|
4299 |
// recreate the surface. If recreation is needed (and M3G is not using our |
|
4300 |
// surface) EGL context and surface are destoryed here and recreated in |
|
4301 |
// next ProcessL() when M3G_CONTENT_START is recieved from Java side. |
|
4302 |
// --------------------------------------------------------------------------- |
|
4303 |
// |
|
4304 |
void CMIDCanvas::HandleSizeChanged(TBool aOrientationChange) |
|
4305 |
{ |
|
4306 |
DEBUG("CMIDCanvas::HandleSizeChanged ++"); |
|
4307 |
||
4308 |
SuspendPixelSource(); |
|
4309 |
||
4310 |
if (IsEglAvailable()) |
|
4311 |
{ |
|
4312 |
TSize surfaceSize = GetEglSurfaceSize(iEglWindowSurface); |
|
4313 |
TSize controlSize = Size(); |
|
4314 |
if (aOrientationChange || |
|
4315 |
surfaceSize.iHeight < controlSize.iHeight || |
|
4316 |
surfaceSize.iWidth < controlSize.iWidth) |
|
4317 |
{ |
|
4318 |
// Check if egl surface is currently occupied. |
|
4319 |
if (iEglOccupied) |
|
4320 |
{ |
|
4321 |
// Delayed resizing. It is done when the ReleaseEglSurface method |
|
4322 |
// is called. |
|
4323 |
iEglPendingResize = ETrue; |
|
4324 |
} |
|
4325 |
else |
|
4326 |
{ |
|
4327 |
// Surface recreation is done in next ProcessL() call |
|
4328 |
// No readback from EGL, because canvas needs to |
|
4329 |
// repaint itself anyway in new size |
|
4330 |
CloseEgl(EFalse); |
|
4331 |
} |
|
4332 |
} |
|
4333 |
} |
|
4334 |
DEBUG("CMIDCanvas::HandleSizeChanged --"); |
|
4335 |
} |
|
4336 |
||
4337 |
// --------------------------------------------------------------------------- |
|
4338 |
// From MMIDComponentNgaExtension |
|
4339 |
// CMIDCanvas::UpdateEglContent |
|
4340 |
// Renders current 2D content in frame buffer as an OpenGL texture to |
|
4341 |
// EGL surface. If scaling is on, renders to pbuffer, otherwise to window surface. |
|
4342 |
// Called from M3G (via CMIDGraphics) when EGL surface needs to be updated with |
|
4343 |
// 2D content. This will not be called if M3G Background is used for clearing |
|
4344 |
// entire canvas area. |
|
4345 |
// --------------------------------------------------------------------------- |
|
4346 |
// |
|
4347 |
void CMIDCanvas::UpdateEglContent() |
|
4348 |
{ |
|
4349 |
if (!IsEglAvailable()) |
|
4350 |
{ |
|
4351 |
return; |
|
4352 |
} |
|
4353 |
||
4354 |
DEBUG("CMIDCanvas::UpdateEglContent() ++"); |
|
4355 |
||
4356 |
// If scaling update framebuffer to pbuffer, otherwise to windowsurface |
|
4357 |
if (iScalingOn && iFullScreen) |
|
4358 |
{ |
|
4359 |
SetCurrentEglType(EEglPbuffer); |
|
4360 |
} |
|
4361 |
else |
|
4362 |
{ |
|
4363 |
SetCurrentEglType(EEglWindow); |
|
4364 |
} |
|
4365 |
BlitFrameBufferPixels(); |
|
4366 |
SetCurrentEglType(EEglNone); |
|
4367 |
||
4368 |
DEBUG("CMIDCanvas::UpdateEglContent() --"); |
|
4369 |
} |
|
4370 |
||
4371 |
// --------------------------------------------------------------------------- |
|
4372 |
// From MMIDComponentNgaExtension |
|
4373 |
// CMIDCanvas::IsEglAvailable |
|
4374 |
// Return ETrue, if EGL based drawing is in use. |
|
4375 |
// --------------------------------------------------------------------------- |
|
4376 |
// |
|
4377 |
TBool CMIDCanvas::IsEglAvailable() const |
|
4378 |
{ |
|
4379 |
return (iEglWindowSurface != EGL_NO_SURFACE); |
|
4380 |
} |
|
4381 |
||
4382 |
// --------------------------------------------------------------------------- |
|
4383 |
// From MMIDComponentNgaExtension |
|
4384 |
// CMIDCanvas::BindEglSurface |
|
4385 |
// Called from M3G (via CMIDGraphics) when M3G binds to canvas |
|
4386 |
// graphics rendering target. |
|
4387 |
// --------------------------------------------------------------------------- |
|
4388 |
// |
|
4389 |
EGLSurface CMIDCanvas::BindEglSurface() |
|
4390 |
{ |
|
4391 |
if (IsEglAvailable()) |
|
4392 |
{ |
|
4393 |
iEglOccupied = ETrue; |
|
4394 |
} |
|
4395 |
||
4396 |
if (iScalingOn && iFullScreen) |
|
4397 |
{ |
|
4398 |
return iEglPbufferSurface; |
|
4399 |
} |
|
4400 |
return iEglWindowSurface; |
|
4401 |
} |
|
4402 |
||
4403 |
// --------------------------------------------------------------------------- |
|
4404 |
// From MMIDComponentNgaExtension |
|
4405 |
// CMIDCanvas::ReleaseEglSurface |
|
4406 |
// Called from M3G (via CMIDGraphics) when M3G releases canvas |
|
4407 |
// graphics rendering target. |
|
4408 |
// --------------------------------------------------------------------------- |
|
4409 |
// |
|
4410 |
void CMIDCanvas::ReleaseEglSurface() |
|
4411 |
{ |
|
4412 |
iEglOccupied = EFalse; |
|
4413 |
if (IsEglAvailable()) |
|
4414 |
{ |
|
4415 |
// Pending dispose. Egl context must be released. |
|
4416 |
if (iEglPendingDispose) |
|
4417 |
{ |
|
4418 |
DEBUG("CMIDCanvas::ReleaseEglSurface() - dispose egl"); |
|
4419 |
FreeGraphicsMemory(ETrue); |
|
4420 |
} |
|
4421 |
else if (iEglPendingResize) |
|
4422 |
{ |
|
4423 |
DEBUG("CMIDCanvas::ReleaseEglSurface() - pending resize"); |
|
4424 |
HandleSizeChanged(ETrue); |
|
4425 |
} |
|
4426 |
||
4427 |
if (IsEglAvailable()) |
|
4428 |
{ |
|
4429 |
ClearFrameBuffer(); |
|
4430 |
} |
|
4431 |
} |
|
4432 |
} |
|
4433 |
||
4434 |
// --------------------------------------------------------------------------- |
|
4435 |
// From MMIDComponentNgaExtension |
|
4436 |
// CMIDCanvas::UpdateOffScreenBitmap() |
|
4437 |
// --------------------------------------------------------------------------- |
|
4438 |
// |
|
4439 |
void CMIDCanvas::UpdateOffScreenBitmapL(TBool aForced) |
|
4440 |
{ |
|
4441 |
if (IsEglAvailable() && iFrameContext && (IsGameCanvas() || aForced)) |
|
4442 |
{ |
|
4443 |
DEBUG("CMIDCanvas::UpdateOffScreenBitmapL() ++"); |
|
4444 |
||
4445 |
UpdateEglContent(); |
|
4446 |
||
4447 |
EGLSurface surface = EGL_NO_SURFACE; |
|
4448 |
TEglType current = GetCurrentEglType(); |
|
4449 |
||
4450 |
if (iScalingOn && iFullScreen) |
|
4451 |
{ |
|
4452 |
SetCurrentEglType(EEglPbuffer); |
|
4453 |
surface = iEglPbufferSurface; |
|
4454 |
} |
|
4455 |
else |
|
4456 |
{ |
|
4457 |
SetCurrentEglType(EEglWindow); |
|
4458 |
surface = iEglWindowSurface; |
|
4459 |
} |
|
4460 |
||
4461 |
CFbsBitmap* bitmap = new(ELeave) CFbsBitmap; |
|
4462 |
CleanupStack::PushL(bitmap); |
|
4463 |
User::LeaveIfError(bitmap->Create( |
|
4464 |
GetEglSurfaceSize(surface), iEnv.DisplayMode())); |
|
4465 |
||
4466 |
if (EGL_FALSE == eglCopyBuffers(iEglDisplay, surface, bitmap)) |
|
4467 |
{ |
|
4468 |
ELOG1(EJavaUI, "eglCopyBuffers() failed, eglError=%s", |
|
4469 |
GetEglError(eglGetError()).Ptr()); |
|
4470 |
User::Leave(KErrUnknown); |
|
4471 |
} |
|
4472 |
||
4473 |
// Clear with opaque black so that EDrawModeOR can be used in BitBlt() |
|
4474 |
iFrameContext->SetBrushColor(KOpaqueBlackColor); |
|
4475 |
iFrameContext->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); |
|
4476 |
iFrameContext->Clear(); |
|
4477 |
iFrameContext->SetDrawMode(CGraphicsContext::EDrawModeOR); |
|
4478 |
iFrameContext->BitBlt(TPoint(), bitmap); |
|
4479 |
CleanupStack::PopAndDestroy(); |
|
4480 |
SetCurrentEglType(current); |
|
4481 |
||
4482 |
// Make sure that full Canvas area |
|
4483 |
// is made transparent in next ClearFrameBuffer() call. |
|
4484 |
// This is needed in case UpdateOffScreenBitmapL is called |
|
4485 |
// from Nokia UI API |
|
4486 |
iUpperUpdateRect = TRect(Size()); |
|
4487 |
||
4488 |
DEBUG("CMIDCanvas::UpdateOffScreenBitmapL() --"); |
|
4489 |
} |
|
4490 |
} |
|
4491 |
||
4492 |
// --------------------------------------------------------------------------- |
|
4493 |
// From MMIDComponentNgaExtension |
|
4494 |
// CMIDCanvas::UpdateOffScreenBitmap() |
|
4495 |
// --------------------------------------------------------------------------- |
|
4496 |
// |
|
4497 |
TBool CMIDCanvas::FillEglSurface(const TRect& aRect, const TRgb& aColor) |
|
4498 |
{ |
|
4499 |
if (!IsEglAvailable() || |
|
4500 |
!iUpperUpdateRect.IsEmpty() || |
|
4501 |
!iLowerUpdateRect.IsEmpty()) |
|
4502 |
{ |
|
4503 |
return EFalse; |
|
4504 |
} |
|
4505 |
TSize sz(this->GetEglSurfaceSize()); |
|
4506 |
if (aRect.Width() >= sz.iWidth && aRect.Height() >= sz.iHeight) |
|
4507 |
{ |
|
4508 |
return ClearEglSurface(EEglNone, &aColor); |
|
4509 |
} |
|
4510 |
TEglType current = GetCurrentEglType(); |
|
4511 |
if (iScalingOn && iFullScreen) |
|
4512 |
{ |
|
4513 |
if (current != EEglPbuffer) |
|
4514 |
{ |
|
4515 |
SetCurrentEglType(EEglPbuffer); |
|
4516 |
} |
|
4517 |
} |
|
4518 |
else if (current != EEglWindow) |
|
4519 |
{ |
|
4520 |
SetCurrentEglType(EEglWindow); |
|
4521 |
} |
|
4522 |
InitOpenGl(ETrue); |
|
4523 |
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
|
4524 |
glVertexPointer(2, GL_SHORT, 0, iVertexArray); |
|
4525 |
iVertexArray[0] = aRect.iTl.iX; |
|
4526 |
iVertexArray[1] = aRect.iTl.iY; |
|
4527 |
||
4528 |
iVertexArray[2] = aRect.iBr.iX; |
|
4529 |
iVertexArray[3] = aRect.iTl.iY; |
|
4530 |
||
4531 |
iVertexArray[4] = iVertexArray[2]; |
|
4532 |
iVertexArray[5] = aRect.iBr.iY; |
|
4533 |
||
4534 |
iVertexArray[6] = iVertexArray[0]; |
|
4535 |
iVertexArray[7] = iVertexArray[5]; |
|
4536 |
||
4537 |
glColor4f( |
|
4538 |
aColor.Red() / 255.0f, aColor.Green() / 255.0f, |
|
4539 |
aColor.Blue() / 255.0f, aColor.Alpha() / 255.0f); |
|
4540 |
||
4541 |
glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, iTriangleStrip); |
|
4542 |
SetCurrentEglType(EEglNone); |
|
4543 |
return ETrue; |
|
4544 |
} |
|
4545 |
||
4546 |
// --------------------------------------------------------------------------- |
|
4547 |
// From CMIDCanvas |
|
4548 |
// CMIDCanvas::ClearEglSurface |
|
4549 |
// --------------------------------------------------------------------------- |
|
4550 |
// |
|
4551 |
TBool CMIDCanvas::ClearEglSurface( |
|
4552 |
CMIDCanvas::TEglType aSurfaceType, const TRgb* aRgba) |
|
4553 |
{ |
|
4554 |
if (!IsEglAvailable()) |
|
4555 |
{ |
|
4556 |
return EFalse; |
|
4557 |
} |
|
4558 |
TEglType current = GetCurrentEglType(); |
|
4559 |
if (aSurfaceType == EEglNone || !aRgba) |
|
4560 |
{ |
|
4561 |
if (iScalingOn && iFullScreen) |
|
4562 |
{ |
|
4563 |
if (aSurfaceType == EEglNone) |
|
4564 |
{ |
|
4565 |
aSurfaceType = EEglPbuffer; |
|
4566 |
} |
|
4567 |
if (!aRgba) |
|
4568 |
{ |
|
4569 |
glClearColor(0.f, 0.f, 0.f, 1.f); |
|
4570 |
} |
|
4571 |
} |
|
4572 |
else |
|
4573 |
{ |
|
4574 |
if (aSurfaceType == EEglNone) |
|
4575 |
{ |
|
4576 |
aSurfaceType = EEglWindow; |
|
4577 |
} |
|
4578 |
if (!aRgba) |
|
4579 |
{ |
|
4580 |
glClearColor(1.f, 1.f, 1.f, 1.f); |
|
4581 |
} |
|
4582 |
} |
|
4583 |
} |
|
4584 |
SetCurrentEglType(aSurfaceType); |
|
4585 |
if (aRgba) |
|
4586 |
{ |
|
4587 |
glClearColor( |
|
4588 |
aRgba->Red() / 255.f, aRgba->Green() / 255.0f, |
|
4589 |
aRgba->Blue() / 255.0f, aRgba->Alpha() / 255.0f); |
|
4590 |
} |
|
4591 |
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
|
4592 |
SetCurrentEglType(current); |
|
4593 |
return ETrue; |
|
4594 |
} |
|
4595 |
||
4596 |
// --------------------------------------------------------------------------- |
|
4597 |
// From MMIDCanvas |
|
4598 |
// CMIDCanvas::UpdateRect |
|
4599 |
// Notifies canvas about which areas have been updated with 2D content. |
|
4600 |
// --------------------------------------------------------------------------- |
|
4601 |
// |
|
4602 |
void CMIDCanvas::UpdateRect(const TRect& aRect) |
|
4603 |
{ |
|
4604 |
if (aRect.IsEmpty()) |
|
4605 |
{ |
|
4606 |
return; |
|
4607 |
} |
|
4608 |
||
4609 |
TRect rect(aRect); |
|
4610 |
TRect canvasRect = IsDownScaling(iContentSize, iViewRect, iM3GContent) ? |
|
4611 |
TRect(iViewRect.Size()) : TRect(iContentSize); |
|
4612 |
rect.Intersection(canvasRect); |
|
4613 |
// Checking if rect have intersection with frameRect |
|
4614 |
TRect frameRect(TPoint(), iFrameBuffer->SizeInPixels()); |
|
4615 |
if (!rect.Intersects(frameRect)) |
|
4616 |
{ |
|
4617 |
return; |
|
4618 |
} |
|
4619 |
rect.Intersection(frameRect); |
|
4620 |
if (rect.IsEmpty()) |
|
4621 |
{ |
|
4622 |
return; |
|
4623 |
} |
|
4624 |
||
4625 |
// Update the member rects |
|
4626 |
if (iUpperUpdateRect.Intersects(rect)) |
|
4627 |
{ |
|
4628 |
iUpperUpdateRect.BoundingRect(rect); |
|
4629 |
} |
|
4630 |
else if (iLowerUpdateRect.Intersects(rect)) |
|
4631 |
{ |
|
4632 |
iLowerUpdateRect.BoundingRect(rect); |
|
4633 |
} |
|
4634 |
// If rect is fully in the lower half of canvas, |
|
4635 |
// merge it with iLowerUpdateRect, otherwise with iUpperUpdateRect |
|
4636 |
else if (rect.iTl.iY > canvasRect.Height() / 2) |
|
4637 |
{ |
|
4638 |
if (iLowerUpdateRect.IsEmpty()) |
|
4639 |
{ |
|
4640 |
iLowerUpdateRect = rect; |
|
4641 |
} |
|
4642 |
else |
|
4643 |
{ |
|
4644 |
iLowerUpdateRect.BoundingRect(rect); |
|
4645 |
} |
|
4646 |
} |
|
4647 |
else |
|
4648 |
{ |
|
4649 |
if (iUpperUpdateRect.IsEmpty()) |
|
4650 |
{ |
|
4651 |
iUpperUpdateRect = rect; |
|
4652 |
} |
|
4653 |
else |
|
4654 |
{ |
|
4655 |
iUpperUpdateRect.BoundingRect(rect); |
|
4656 |
} |
|
4657 |
} |
|
4658 |
} |
|
4659 |
||
4660 |
// --------------------------------------------------------------------------- |
|
4661 |
// From MMIDCanvas |
|
4662 |
// CMIDCanvas::MidletExiting |
|
4663 |
// Draws content to CWindowGc to enable the system effect on MIDlet exit. |
|
4664 |
// Canvas might be in the middle of rendering new frame when this is called. |
|
4665 |
// Having incomplete frame on screen in some exit cases is anyway better than |
|
4666 |
// fully black always. |
|
4667 |
// --------------------------------------------------------------------------- |
|
4668 |
// |
|
4669 |
void CMIDCanvas::MidletExiting() |
|
4670 |
{ |
|
4671 |
iExiting = ETrue; |
|
4672 |
TRAP_IGNORE(UpdateOffScreenBitmapL(ETrue)); |
|
4673 |
DrawToWindowGc(); |
|
4674 |
} |
|
4675 |
||
4676 |
// --------------------------------------------------------------------------- |
|
4677 |
// CMIDCanvas::BlitFrameBufferPixels |
|
4678 |
// Sets up OpenGL state for 2D texture rendering and renders the textures for |
|
4679 |
// updated frame buffer areas by calling BlitSubRect(). |
|
4680 |
// --------------------------------------------------------------------------- |
|
4681 |
// |
|
4682 |
void CMIDCanvas::BlitFrameBufferPixels() |
|
4683 |
{ |
|
4684 |
if (iUpperUpdateRect.IsEmpty() && iLowerUpdateRect.IsEmpty()) |
|
4685 |
{ |
|
4686 |
return; |
|
4687 |
} |
|
4688 |
InitOpenGl(); |
|
4689 |
// Must use this blending function because frame buffer |
|
4690 |
// content is in pre-multiplied ARGB format. |
|
4691 |
// See alpha blending in Lcdgd, lcdc16ma.cpp. |
|
4692 |
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
|
4693 |
||
4694 |
glEnable(GL_ALPHA_TEST); |
|
4695 |
glAlphaFunc(GL_GREATER, 0.0f); |
|
4696 |
||
4697 |
// Disable any stray state we don't want |
|
4698 |
glDisable(GL_CULL_FACE); |
|
4699 |
glDisableClientState(GL_NORMAL_ARRAY); |
|
4700 |
glDisableClientState(GL_COLOR_ARRAY); |
|
4701 |
glDisable(GL_LIGHTING); |
|
4702 |
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
|
4703 |
glDepthMask(GL_FALSE); |
|
4704 |
glDepthFunc(GL_ALWAYS); |
|
4705 |
||
4706 |
ASSERT_GL(); |
|
4707 |
||
4708 |
if (iUpperUpdateRect.Intersects(iLowerUpdateRect)) |
|
4709 |
{ |
|
4710 |
iUpperUpdateRect.BoundingRect(iLowerUpdateRect); |
|
4711 |
iLowerUpdateRect = TRect(); |
|
4712 |
BlitSubRect(iUpperUpdateRect); |
|
4713 |
} |
|
4714 |
else |
|
4715 |
{ |
|
4716 |
BlitSubRect(iUpperUpdateRect); |
|
4717 |
BlitSubRect(iLowerUpdateRect); |
|
4718 |
} |
|
4719 |
||
4720 |
ClearFrameBuffer(); |
|
4721 |
} |
|
4722 |
||
4723 |
// --------------------------------------------------------------------------- |
|
4724 |
// CMIDCanvas::InitOpenGl |
|
4725 |
// Initiazes OpenGL before 2d rendering |
|
4726 |
// --------------------------------------------------------------------------- |
|
4727 |
// |
|
4728 |
TSize CMIDCanvas::InitOpenGl(TBool aTopLeftOrigo, const TRect* aRect) |
|
4729 |
{ |
|
4730 |
// scaling is on the framebuffer is blitted to pbuffer instead of |
|
4731 |
// window surface so get the size of appropriate surface for |
|
4732 |
// setting correct values for viewport, projection etc. |
|
4733 |
TSize size = GetEglSurfaceSize(); |
|
4734 |
glViewport(0, 0, size.iWidth, size.iHeight); |
|
4735 |
if (aRect) |
|
4736 |
{ |
|
4737 |
glScissor(aRect->iTl.iX, aRect->iTl.iY, aRect->Width(), aRect->Height()); |
|
4738 |
} |
|
4739 |
else |
|
4740 |
{ |
|
4741 |
glScissor(0, 0, size.iWidth, size.iHeight); |
|
4742 |
} |
|
4743 |
glEnable(GL_BLEND); |
|
4744 |
glMatrixMode(GL_PROJECTION); |
|
4745 |
glLoadIdentity(); |
|
4746 |
// Checks where the origo should be |
|
4747 |
if (aTopLeftOrigo) |
|
4748 |
{ |
|
4749 |
// Top-left |
|
4750 |
glOrthof(0, TReal32(size.iWidth), TReal32(size.iHeight), 0.f, -1.f, 1.f); |
|
4751 |
} |
|
4752 |
else |
|
4753 |
{ |
|
4754 |
// Bottom-left |
|
4755 |
glOrthox(0, size.iWidth << 16, 0, size.iHeight << 16, -1 << 16, 1 << 16); |
|
4756 |
} |
|
4757 |
glMatrixMode(GL_MODELVIEW); |
|
4758 |
glLoadIdentity(); |
|
4759 |
glDisable(GL_DEPTH_TEST); |
|
4760 |
glEnableClientState(GL_VERTEX_ARRAY); |
|
4761 |
glDisable(GL_LIGHTING); |
|
4762 |
glDepthMask(GL_FALSE); |
|
4763 |
glDepthFunc(GL_ALWAYS); |
|
4764 |
return size; |
|
4765 |
} |
|
4766 |
||
4767 |
// --------------------------------------------------------------------------- |
|
4768 |
// CMIDCanvas::BlitSubRect |
|
4769 |
// OpenGL texture dimensions must be powers of 2. Devides aRect into smaller |
|
4770 |
// areas for texture rendering so that texture dimensions won't exceed |
|
4771 |
// KMaxBlitSize. |
|
4772 |
// --------------------------------------------------------------------------- |
|
4773 |
// |
|
4774 |
void CMIDCanvas::BlitSubRect(const TRect& aRect) |
|
4775 |
{ |
|
4776 |
if (aRect.IsEmpty()) |
|
4777 |
{ |
|
4778 |
return; |
|
4779 |
} |
|
4780 |
||
4781 |
// OpenGL coordinate origin is in bottom left corner of screen |
|
4782 |
TInt yOffset = iContentSize.iHeight - aRect.iBr.iY; |
|
4783 |
TInt xOffset = aRect.iTl.iX; |
|
4784 |
TInt width = aRect.Width(); |
|
4785 |
TInt height = aRect.Height(); |
|
4786 |
||
4787 |
TInt canvasHeight = iContentSize.iHeight; |
|
4788 |
||
4789 |
TInt xBlits = (width == KMaxBlitSize) ? 1 : (width / KMaxBlitSize) + 1; |
|
4790 |
TInt yBlits = (height == KMaxBlitSize) ? 1 : (height / KMaxBlitSize) + 1; |
|
4791 |
||
4792 |
TInt stride = iFrameBuffer->ScanLineLength( |
|
4793 |
iFrameBuffer->SizeInPixels().iWidth, iFrameBuffer->DisplayMode()); |
|
4794 |
||
4795 |
for (TInt yBlit = 0; yBlit < yBlits; ++yBlit) |
|
4796 |
{ |
|
4797 |
for (TInt xBlit = 0; xBlit < xBlits; ++xBlit) |
|
4798 |
{ |
|
4799 |
||
4800 |
TInt xStart = xOffset + xBlit * KMaxBlitSize; |
|
4801 |
TInt yStart = yOffset + yBlit * KMaxBlitSize; |
|
4802 |
TInt xSize = Min(KMaxBlitSize, width - (xStart - xOffset)); |
|
4803 |
TInt ySize = Min(KMaxBlitSize, height - (yStart - yOffset)); |
|
4804 |
||
4805 |
// The first rectangle will be in bottom left corner, |
|
4806 |
// then rectangle is moved right and upwards. |
|
4807 |
// OpenGL y-coordinate increases upwards. |
|
4808 |
TInt srcOffset = (canvasHeight - (yStart + ySize)) * stride + |
|
4809 |
xStart * KBytesPerPixel; |
|
4810 |
||
4811 |
if ((xSize > 0) && (xSize <= 256) && (ySize > 0) && (ySize <= 256)) |
|
4812 |
{ |
|
4813 |
BlitSubRectTexture(xStart, yStart, xSize, ySize, stride, |
|
4814 |
(TUint8*)iFrameBuffer->DataAddress() + srcOffset); |
|
4815 |
} |
|
4816 |
} |
|
4817 |
} |
|
4818 |
} |
|
4819 |
||
4820 |
||
4821 |
// --------------------------------------------------------------------------- |
|
4822 |
// CMIDCanvas::BlitSubRectTexture |
|
4823 |
// Creates OpenGL texture from the pixels passed as a parameter and draws |
|
4824 |
// texture to the current EGL surface. |
|
4825 |
// --------------------------------------------------------------------------- |
|
4826 |
// |
|
4827 |
void CMIDCanvas::BlitSubRectTexture(TInt aXOffset, TInt aYOffset, |
|
4828 |
TInt aWidth, TInt aHeight, |
|
4829 |
TInt aStride, const TUint8* aPixels) |
|
4830 |
{ |
|
4831 |
DEBUG_INT4("BlitSubRectTextureL: aXOffset=%d, aYOffset=%d, aWidth=%d, aHeight=%d", |
|
4832 |
aXOffset, aYOffset, aWidth, aHeight); |
|
4833 |
DEBUG_INT("BlitSubRectTextureL: aStride=%d", aStride); |
|
4834 |
||
4835 |
ASSERT((aWidth > 0) && (aWidth <= 256)); |
|
4836 |
ASSERT((aHeight > 0) && (aHeight <= 256)); |
|
4837 |
ASSERT(iTexturePixels); |
|
4838 |
ASSERT_GL(); |
|
4839 |
||
4840 |
TInt tileWidth = KMaxBlitSize; |
|
4841 |
TInt tileHeight = KMaxBlitSize; |
|
4842 |
||
4843 |
// Tweak tile size to avoid using excessive amounts of memory for |
|
4844 |
// portions outside the blit area |
|
4845 |
while (tileWidth >= aWidth * 2) |
|
4846 |
{ |
|
4847 |
tileWidth >>= 1; |
|
4848 |
tileHeight <<= 1; |
|
4849 |
} |
|
4850 |
||
4851 |
while (tileHeight >= aHeight * 2) |
|
4852 |
{ |
|
4853 |
tileHeight >>= 1; |
|
4854 |
} |
|
4855 |
||
4856 |
glActiveTexture(GL_TEXTURE0); |
|
4857 |
glEnable(GL_TEXTURE_2D); |
|
4858 |
||
4859 |
TUint tempTexObj[KTexturesCount]; |
|
4860 |
glGenTextures(KTexturesCount, tempTexObj); |
|
4861 |
||
4862 |
glBindTexture(GL_TEXTURE_2D, tempTexObj[0]); |
|
4863 |
||
4864 |
glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
|
4865 |
||
4866 |
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
|
4867 |
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
|
4868 |
||
4869 |
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, |
|
4870 |
tileWidth, tileHeight, 0, |
|
4871 |
GL_RGBA, GL_UNSIGNED_BYTE, NULL); |
|
4872 |
||
4873 |
// Raise out-of-memory if OpenGL ran out of resources |
|
4874 |
GLint err = glGetError(); |
|
4875 |
if (err == GL_OUT_OF_MEMORY) |
|
4876 |
{ |
|
4877 |
glDeleteTextures(KTexturesCount, tempTexObj); |
|
4878 |
ELOG(EJavaUI, "CMIDCanvas::BlitSubRectTexture(): Out of memory when creating OpenGL texture"); |
|
4879 |
return; |
|
4880 |
} |
|
4881 |
else if (err != GL_NO_ERROR) |
|
4882 |
{ |
|
4883 |
ELOG1(EJavaUI, "CMIDCanvas::BlitSubRectTexture(): GL error after glTexImage2D(): %d", err); |
|
4884 |
ASSERT(EFalse); |
|
4885 |
} |
|
4886 |
||
4887 |
// Set up texture and vertex coordinate arrays for the image tiles |
|
4888 |
const TUint8 tc[8] = { 0, 0, 0, 1, 1, 0, 1, 1 }; |
|
4889 |
GLshort pos[8]; |
|
4890 |
||
4891 |
glClientActiveTexture(GL_TEXTURE0); |
|
4892 |
glTexCoordPointer(2, GL_BYTE, 0, tc); |
|
4893 |
glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
|
4894 |
glVertexPointer(2, GL_SHORT, 0, pos); |
|
4895 |
glEnableClientState(GL_VERTEX_ARRAY); |
|
4896 |
glMatrixMode(GL_TEXTURE); |
|
4897 |
glLoadIdentity(); |
|
4898 |
glMatrixMode(GL_MODELVIEW); |
|
4899 |
||
4900 |
ASSERT_GL(); |
|
4901 |
||
4902 |
glBindTexture(GL_TEXTURE_2D, tempTexObj[0]); |
|
4903 |
TUint8* dst = iTexturePixels; |
|
4904 |
const TUint8* src = aPixels; |
|
4905 |
||
4906 |
TInt h = aHeight; |
|
4907 |
||
4908 |
if (tileWidth > aWidth || |
|
4909 |
tileHeight > aHeight) |
|
4910 |
{ |
|
4911 |
// Clear the pixel data with transparent for case where |
|
4912 |
// actual texture data does not cover the full tile. |
|
4913 |
Mem::FillZ(dst, tileWidth * tileHeight * KBytesPerPixel); |
|
4914 |
dst += tileWidth * (tileHeight - aHeight) * KBytesPerPixel; |
|
4915 |
} |
|
4916 |
||
4917 |
while (h-- > 0) |
|
4918 |
{ |
|
4919 |
ConvertPixels((TUint32*)src, dst, aWidth); |
|
4920 |
src += aStride; |
|
4921 |
dst += tileWidth * KBytesPerPixel; |
|
4922 |
} |
|
4923 |
||
4924 |
glTexSubImage2D(GL_TEXTURE_2D, 0, |
|
4925 |
0, 0, |
|
4926 |
tileWidth, tileHeight, |
|
4927 |
GL_RGBA, GL_UNSIGNED_BYTE, iTexturePixels); |
|
4928 |
||
4929 |
// If scaling is on and pbuffer is used, the framebuffer contents |
|
4930 |
// must be positioned to the top part of the puffer as m3g renders |
|
4931 |
// there as well, thus 2D and 3D content are correctly on top of each other |
|
4932 |
if (iScalingOn && iFullScreen) |
|
4933 |
{ |
|
4934 |
TSize pbufferSize = GetEglSurfaceSize(iEglPbufferSurface); |
|
4935 |
TInt offset = pbufferSize.iHeight - iContentSize.iHeight; |
|
4936 |
||
4937 |
pos[0] = (GLshort)aXOffset; |
|
4938 |
pos[1] = (GLshort)(tileHeight + aYOffset + offset); |
|
4939 |
pos[2] = pos[0]; |
|
4940 |
pos[3] = (GLshort)aYOffset + offset; |
|
4941 |
pos[4] = (GLshort)(tileWidth + aXOffset); |
|
4942 |
pos[5] = pos[1]; |
|
4943 |
pos[6] = pos[4]; |
|
4944 |
pos[7] = pos[3]; |
|
4945 |
} |
|
4946 |
else |
|
4947 |
{ |
|
4948 |
pos[0] = (GLshort)aXOffset; |
|
4949 |
pos[1] = (GLshort)(tileHeight + aYOffset); |
|
4950 |
pos[2] = pos[0]; |
|
4951 |
pos[3] = (GLshort)aYOffset; |
|
4952 |
pos[4] = (GLshort)(tileWidth + aXOffset); |
|
4953 |
pos[5] = pos[1]; |
|
4954 |
pos[6] = pos[4]; |
|
4955 |
pos[7] = pos[3]; |
|
4956 |
} |
|
4957 |
||
4958 |
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); |
|
4959 |
||
4960 |
// release resources |
|
4961 |
glDeleteTextures(KTexturesCount, tempTexObj); |
|
4962 |
ASSERT_GL(); |
|
4963 |
} |
|
4964 |
||
4965 |
// --------------------------------------------------------------------------- |
|
4966 |
// CMIDCanvas::CreatePBufferSurfaceL |
|
4967 |
// Create EGL pbuffer to be used in scaling case. |
|
4968 |
// --------------------------------------------------------------------------- |
|
4969 |
// |
|
4970 |
void CMIDCanvas::CreatePBufferSurfaceL() |
|
4971 |
{ |
|
4972 |
DEBUG("CMIDCanvas::CreatePBufferSurface() ++"); |
|
4973 |
ASSERT(iEglDisplay != EGL_NO_DISPLAY); |
|
4974 |
||
4975 |
RWindow& window = Window(); |
|
4976 |
||
4977 |
// Choose the buffer size based on the Window's display mode. |
|
4978 |
TDisplayMode displayMode = window.DisplayMode(); |
|
4979 |
TInt bufferSize = 0; |
|
4980 |
switch (displayMode) |
|
4981 |
{ |
|
4982 |
case(EColor16MU): |
|
4983 |
case(EColor16MA): |
|
4984 |
case(EColor16MAP): |
|
4985 |
bufferSize = 32; |
|
4986 |
break; |
|
4987 |
default: |
|
4988 |
ELOG1(EJavaUI, "CMIDCanvas::OpenEglL(): unsupported window display mode %d", |
|
4989 |
displayMode); |
|
4990 |
User::Leave(KErrNotSupported); |
|
4991 |
break; |
|
4992 |
} |
|
4993 |
||
4994 |
// Set the desired properties for the EGLSurface |
|
4995 |
const EGLint attributeList[] = |
|
4996 |
{ |
|
4997 |
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, |
|
4998 |
EGL_RED_SIZE, 8, |
|
4999 |
EGL_GREEN_SIZE, 8, |
|
5000 |
EGL_BLUE_SIZE, 8, |
|
5001 |
EGL_ALPHA_SIZE, 8, |
|
5002 |
EGL_BUFFER_SIZE, bufferSize, |
|
5003 |
EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE, |
|
5004 |
EGL_TRANSPARENT_TYPE, EGL_NONE, |
|
5005 |
EGL_DEPTH_SIZE, 16, |
|
5006 |
EGL_NONE |
|
5007 |
}; |
|
5008 |
||
5009 |
EGLConfig bestConfig; |
|
5010 |
EGLint numConfigs = 0; |
|
5011 |
||
5012 |
// Choose the best EGLConfig that matches the desired properties. |
|
5013 |
if (!eglChooseConfig(iEglDisplay, attributeList, &bestConfig, 1, &numConfigs) || |
|
5014 |
numConfigs == 0) |
|
5015 |
{ |
|
5016 |
ELOG1(EJavaUI, "eglChooseConfig() for pbuffer failed, eglError=%d", eglGetError()); |
|
5017 |
User::Leave(KErrNotSupported); |
|
5018 |
} |
|
5019 |
||
5020 |
// find buffer size based on the framebuffer size |
|
5021 |
// pbuffer size must be power of two so that it can be bound |
|
5022 |
// as texture image |
|
5023 |
TInt width = 2; |
|
5024 |
TInt height = 2; |
|
5025 |
||
5026 |
while (width < iContentSize.iWidth) |
|
5027 |
{ |
|
5028 |
width <<= 1; |
|
5029 |
} |
|
5030 |
while (height < iContentSize.iHeight) |
|
5031 |
{ |
|
5032 |
height <<= 1; |
|
5033 |
} |
|
5034 |
||
5035 |
DEBUG_INT4("CMIDCanvas::CreatePBufferSurface - pbuffer size resolved as (width=%d, height=%d), contentSize(%d, %d)", |
|
5036 |
width, height, iContentSize.iWidth, iContentSize.iHeight); |
|
5037 |
||
5038 |
// Special attributes in order for binding this surface as texture image |
|
5039 |
EGLint attrib[] = |
|
5040 |
{ |
|
5041 |
EGL_WIDTH, width, |
|
5042 |
EGL_HEIGHT, height, |
|
5043 |
EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA, |
|
5044 |
EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, |
|
5045 |
EGL_MIPMAP_TEXTURE, EGL_TRUE, |
|
5046 |
EGL_NONE |
|
5047 |
}; |
|
5048 |
||
5049 |
iEglPbufferSurface = eglCreatePbufferSurface(iEglDisplay, bestConfig, attrib); |
|
5050 |
if (iEglPbufferSurface == EGL_NO_SURFACE) |
|
5051 |
{ |
|
5052 |
ELOG1(EJavaUI, "eglCreatePbufferSurface() failed, eglError=%d", eglGetError()); |
|
5053 |
User::Leave(KErrNoMemory); |
|
5054 |
} |
|
5055 |
||
5056 |
// Create a rendering context |
|
5057 |
iEglPbufferSurfaceContext = eglCreateContext(iEglDisplay, bestConfig, NULL, NULL); |
|
5058 |
if (iEglPbufferSurfaceContext == EGL_NO_CONTEXT) |
|
5059 |
{ |
|
5060 |
ELOG1(EJavaUI, "eglCreateContext() for pbuffer failed, eglError=%d", eglGetError()); |
|
5061 |
User::Leave(KErrNoMemory); |
|
5062 |
} |
|
5063 |
||
5064 |
DEBUG("CMIDCanvas::CreatePBufferSurface() --"); |
|
5065 |
} |
|
5066 |
||
5067 |
// --------------------------------------------------------------------------- |
|
5068 |
// CMIDCanvas::DisposePBufferSurface |
|
5069 |
// Destroys EGL pbuffer surface and context. |
|
5070 |
// --------------------------------------------------------------------------- |
|
5071 |
// |
|
5072 |
void CMIDCanvas::DisposePBufferSurface() |
|
5073 |
{ |
|
5074 |
if (iEglPbufferSurfaceContext != EGL_NO_CONTEXT) |
|
5075 |
{ |
|
5076 |
eglDestroyContext(iEglDisplay, iEglPbufferSurfaceContext); |
|
5077 |
iEglPbufferSurfaceContext = EGL_NO_CONTEXT; |
|
5078 |
||
5079 |
// textures are destoyed along with the context so it's safe |
|
5080 |
// set texture name to zero |
|
5081 |
iPbufferTexture = 0; |
|
5082 |
} |
|
5083 |
if (iEglPbufferSurface != EGL_NO_SURFACE) |
|
5084 |
{ |
|
5085 |
eglDestroySurface(iEglDisplay, iEglPbufferSurface); |
|
5086 |
iEglPbufferSurface = EGL_NO_SURFACE; |
|
5087 |
} |
|
5088 |
} |
|
5089 |
||
5090 |
// --------------------------------------------------------------------------- |
|
5091 |
// CMIDCanvas::BlitPBufferScaledToWindowSurface |
|
5092 |
// In scaling case renders and scales pbuffer content (=canvas 2D + 3D |
|
5093 |
// content in orig size) to EGL window surface. |
|
5094 |
// --------------------------------------------------------------------------- |
|
5095 |
// |
|
5096 |
void CMIDCanvas::BlitPBufferScaledToWindowSurface() |
|
5097 |
{ |
|
5098 |
DEBUG("CMIDCanvas::BlitPBufferScaledToWindowSurface() ++"); |
|
5099 |
||
5100 |
// Get screen size for setting clips and |
|
5101 |
// parallel projection correctly |
|
5102 |
TRect screenRect = Rect(); |
|
5103 |
TInt width = screenRect.Width(); |
|
5104 |
TInt height = screenRect.Height(); |
|
5105 |
||
5106 |
glScissor(0, 0, width, height); |
|
5107 |
glViewport(0, 0, width, height); |
|
5108 |
glMatrixMode(GL_PROJECTION); |
|
5109 |
glLoadIdentity(); |
|
5110 |
||
5111 |
glOrthox(0, width << 16, |
|
5112 |
0, height << 16, |
|
5113 |
-1 << 16, 1 << 16); |
|
5114 |
||
5115 |
glMatrixMode(GL_MODELVIEW); |
|
5116 |
glLoadIdentity(); |
|
5117 |
||
5118 |
glActiveTexture(GL_TEXTURE0); |
|
5119 |
glEnable(GL_TEXTURE_2D); |
|
5120 |
||
5121 |
// generate texture name if not already generated |
|
5122 |
if (glIsTexture(iPbufferTexture) == GL_FALSE) |
|
5123 |
{ |
|
5124 |
glGenTextures(1, &iPbufferTexture); |
|
5125 |
} |
|
5126 |
||
5127 |
glBindTexture(GL_TEXTURE_2D, iPbufferTexture); |
|
5128 |
if (eglBindTexImage(iEglDisplay, iEglPbufferSurface, EGL_BACK_BUFFER) == EGL_FALSE) |
|
5129 |
{ |
|
5130 |
ELOG1(EJavaUI, "eglBindTexImage() failed, eglError=%d", eglGetError()); |
|
5131 |
ASSERT(EFalse); |
|
5132 |
} |
|
5133 |
||
5134 |
glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
|
5135 |
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
|
5136 |
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
|
5137 |
||
5138 |
// calculate texture coordinates, i.e. the area in pbuffer |
|
5139 |
// that has the actual frame content |
|
5140 |
GLfloat contentWidth = iContentSize.iWidth; |
|
5141 |
GLfloat contentHeight = iContentSize.iHeight; |
|
5142 |
TSize bufferSize = GetEglSurfaceSize(iEglPbufferSurface); |
|
5143 |
GLfloat horRatio = contentWidth / bufferSize.iWidth; |
|
5144 |
GLfloat yoffset = (bufferSize.iHeight - contentHeight) / bufferSize.iHeight; |
|
5145 |
GLfloat tc[8] = { 0.0f, 1.0f, 0.0f, yoffset, horRatio, 1.0f, horRatio, yoffset}; |
|
5146 |
||
5147 |
GLshort pos[8]; |
|
5148 |
||
5149 |
ASSERT_GL(); |
|
5150 |
||
5151 |
glClientActiveTexture(GL_TEXTURE0); |
|
5152 |
glTexCoordPointer(2, GL_FLOAT, 0, tc); |
|
5153 |
glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
|
5154 |
glVertexPointer(2, GL_SHORT, 0, pos); |
|
5155 |
glEnableClientState(GL_VERTEX_ARRAY); |
|
5156 |
glMatrixMode(GL_TEXTURE); |
|
5157 |
glLoadIdentity(); |
|
5158 |
||
5159 |
// position texture screen coordinates |
|
5160 |
pos[0] = (GLshort)iViewRect.iTl.iX; |
|
5161 |
pos[1] = (GLshort)iViewRect.Height() + (height - iViewRect.iBr.iY); |
|
5162 |
pos[2] = pos[0]; |
|
5163 |
pos[3] = (GLshort)height - iViewRect.iBr.iY; |
|
5164 |
pos[4] = (GLshort)iViewRect.iBr.iX; |
|
5165 |
pos[5] = pos[1]; |
|
5166 |
pos[6] = pos[4]; |
|
5167 |
pos[7] = pos[3]; |
|
5168 |
||
5169 |
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); |
|
5170 |
||
5171 |
// release pbuffer from texture |
|
5172 |
eglReleaseTexImage(iEglDisplay, iEglPbufferSurface, EGL_BACK_BUFFER); |
|
5173 |
||
5174 |
DEBUG("CMIDCanvas::BlitPBufferScaledToWindowSurface() --"); |
|
5175 |
} |
|
5176 |
||
5177 |
||
5178 |
// --------------------------------------------------------------------------- |
|
5179 |
// CMIDCanvas::ClearFrameBuffer |
|
5180 |
// Clears the frame buffer with fully transparent color. Rendering canvas 2D |
|
5181 |
// content as an OpenGL texture requires that texture is transparent in |
|
5182 |
// the areas where no 2D content has been drawn. |
|
5183 |
// --------------------------------------------------------------------------- |
|
5184 |
// |
|
5185 |
void CMIDCanvas::ClearFrameBuffer() |
|
5186 |
{ |
|
5187 |
if (!iM3GStart && iUpperUpdateRect.IsEmpty() && iLowerUpdateRect.IsEmpty()) |
|
5188 |
{ |
|
5189 |
return; |
|
5190 |
} |
|
5191 |
// Clear the frame buffer |
|
5192 |
iFrameContext->SetBrushColor(KTransparentClearColor); |
|
5193 |
iFrameContext->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); |
|
5194 |
||
5195 |
iFrameContext->Clear(iUpperUpdateRect); |
|
5196 |
iFrameContext->Clear(iLowerUpdateRect); |
|
5197 |
||
5198 |
// Reset members |
|
5199 |
iUpperUpdateRect.SetRect(0,0,0,0); |
|
5200 |
iLowerUpdateRect.SetRect(0,0,0,0); |
|
5201 |
} |
|
5202 |
||
5203 |
||
5204 |
// --------------------------------------------------------------------------- |
|
5205 |
// CMIDCanvas::AssertGL |
|
5206 |
// Check for OpenGL ES errors. Only for debug builds. |
|
5207 |
// --------------------------------------------------------------------------- |
|
5208 |
// |
|
5209 |
void CMIDCanvas::AssertGL() |
|
5210 |
{ |
|
5211 |
GLint err = glGetError(); |
|
5212 |
if (err == GL_NO_ERROR) |
|
5213 |
{ |
|
5214 |
return; |
|
5215 |
} |
|
5216 |
else |
|
5217 |
{ |
|
5218 |
ELOG1(EJavaUI, "OpenGL ES error=%d", err); |
|
5219 |
ASSERT(EFalse); |
|
5220 |
} |
|
5221 |
} |
|
5222 |
||
5223 |
// --------------------------------------------------------------------------- |
|
5224 |
// CMIDCanvas::AssertGL |
|
5225 |
// Check for OpenGL ES errors. Only for debug builds. |
|
5226 |
// --------------------------------------------------------------------------- |
|
5227 |
// |
|
5228 |
const TDesC8& CMIDCanvas::GetEglError(EGLint aErr) |
|
5229 |
{ |
|
5230 |
_LIT8(KEglSuccess, "EGL_SUCCESS"); |
|
5231 |
_LIT8(KEglNotInitialized, "EGL_NOT_INITIALIZED"); |
|
5232 |
_LIT8(KEglBadAccess, "EGL_BAD_ACCESS"); |
|
5233 |
_LIT8(KEglBadAlloc, "EGL_BAD_ALLOC"); |
|
5234 |
_LIT8(KEglBadAttribute, "EGL_BAD_ATTRIBUTE"); |
|
5235 |
_LIT8(KEglBadContext, "EGL_BAD_CONTEXT"); |
|
5236 |
_LIT8(KEglBadConfig, "EGL_BAD_CONFIG"); |
|
5237 |
_LIT8(KEglBadCurrentSurface, "EGL_BAD_CURRENT_SURFACE"); |
|
5238 |
_LIT8(KEglBadDisplay, "EGL_BAD_DISPLAY"); |
|
5239 |
_LIT8(KEglBadSurface, "EGL_BAD_SURFACE"); |
|
5240 |
_LIT8(KEglBadMatch, "EGL_BAD_MATCH"); |
|
5241 |
_LIT8(KEglBadParameter, "EGL_BAD_PARAMETER"); |
|
5242 |
_LIT8(KEglBadNativePixmap, "EGL_BAD_NATIVE_PIXMAP"); |
|
5243 |
_LIT8(KEglBadNativeWindow, "EGL_BAD_NATIVE_WINDOW"); |
|
5244 |
switch (aErr) |
|
5245 |
{ |
|
5246 |
case EGL_NOT_INITIALIZED: |
|
5247 |
return KEglNotInitialized; |
|
5248 |
case EGL_BAD_ACCESS: |
|
5249 |
return KEglBadAccess; |
|
5250 |
case EGL_BAD_ALLOC: |
|
5251 |
return KEglBadAlloc; |
|
5252 |
case EGL_BAD_ATTRIBUTE: |
|
5253 |
return KEglBadAttribute; |
|
5254 |
case EGL_BAD_CONTEXT: |
|
5255 |
return KEglBadContext; |
|
5256 |
case EGL_BAD_CONFIG: |
|
5257 |
return KEglBadConfig; |
|
5258 |
case EGL_BAD_CURRENT_SURFACE: |
|
5259 |
return KEglBadCurrentSurface; |
|
5260 |
case EGL_BAD_DISPLAY: |
|
5261 |
return KEglBadDisplay; |
|
5262 |
case EGL_BAD_SURFACE: |
|
5263 |
return KEglBadSurface; |
|
5264 |
case EGL_BAD_MATCH: |
|
5265 |
return KEglBadMatch; |
|
5266 |
case EGL_BAD_PARAMETER: |
|
5267 |
return KEglBadParameter; |
|
5268 |
case EGL_BAD_NATIVE_PIXMAP: |
|
5269 |
return KEglBadNativePixmap; |
|
5270 |
case EGL_BAD_NATIVE_WINDOW: |
|
5271 |
return KEglBadNativeWindow; |
|
5272 |
} |
|
5273 |
return KEglSuccess; |
|
5274 |
} |
|
5275 |
||
5276 |
// --------------------------------------------------------------------------- |
|
5277 |
// CMIDCanvas::IsWindowVisible |
|
5278 |
// Checks if canvas window is currently visible on display. Canvas may be visible |
|
5279 |
// e.g. behind task switcher or system dialogs even though MIDlet is not the |
|
5280 |
// foreground application in that case. This function relies on |
|
5281 |
// CMIDDisplayble setting canvas window invisible when some other full-screen |
|
5282 |
// displayble is set as current. |
|
5283 |
// --------------------------------------------------------------------------- |
|
5284 |
// |
|
5285 |
TBool CMIDCanvas::IsWindowVisible() const |
|
5286 |
{ |
|
5287 |
return iEnv.HasFullOrPartialForeground() && IsVisible(); |
|
5288 |
} |
|
5289 |
||
5290 |
// --------------------------------------------------------------------------- |
|
5291 |
// CMIDCanvas::PostForcedPaint |
|
5292 |
// Send forced paint to Java. Canvas.paint() will be called even if canvas is |
|
5293 |
// not the current displayable. |
|
5294 |
// --------------------------------------------------------------------------- |
|
5295 |
// |
|
5296 |
void CMIDCanvas::PostForcedPaint() |
|
5297 |
{ |
|
5298 |
TInt posPacked = 0; |
|
5299 |
TInt sizePacked = (iContentSize.iWidth << 16) | (iContentSize.iHeight); |
|
5300 |
PostEvent(EForcedPaint, posPacked, sizePacked); |
|
5301 |
} |
|
5302 |
#endif // RD_JAVA_NGA_ENABLED |
|
5303 |
// End of File. |