|
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 |
|
19 |
|
20 #ifndef CMIDCANVAS_H |
|
21 #define CMIDCANVAS_H |
|
22 |
|
23 /** |
|
24 * Enables platform support for accelerated GDI operations. |
|
25 * |
|
26 * Used for creating of hardware bitmap (e.g. in LcdFbsImage.cpp) which can be |
|
27 * used in hardware graphics accelerator if available. |
|
28 * |
|
29 * FIX for BITGDI failing to transparently support drawing to hardware |
|
30 * bitmaps. Certain accelerator operations fail silently rather than falling |
|
31 * back to software routines. If the licencee can be sure that their hardware |
|
32 * accelerator supports all BITGDI operations then it may be worth |
|
33 * uncommenting the following line. |
|
34 */ |
|
35 #define ACCELERATED_BITGDI 1 |
|
36 |
|
37 /** |
|
38 * Enables deffered BitBlting. With this flag on, CMIDCanvas counts BitBlt |
|
39 * cycles and tries to optimize BitBlt process. |
|
40 */ |
|
41 #define DEFER_BITBLT 1 |
|
42 |
|
43 /** |
|
44 * Enables update invalidate method of drawing. Use RWindow::BeginRedraw and |
|
45 * RWindow::EndRedraw to tell the window server when the window is about to |
|
46 * respond to the last redraw event by redrawing. |
|
47 */ |
|
48 #define CANVAS_UPDATE_INVALIDATE 1 |
|
49 |
|
50 /** |
|
51 * Used double buffer for Canvas. Enabled by MIDP 2.1 specification. |
|
52 * |
|
53 * Define to switch on native double buffering in canvas. Canvas may still be |
|
54 * double buffered in java even if this is switched off, however this has not |
|
55 * been tested without JSR_135_SUPPORT. |
|
56 */ |
|
57 #define CANVAS_DOUBLE_BUFFER 1 |
|
58 |
|
59 /** |
|
60 * Enable direct screen access for Canvas when not using double buffering. |
|
61 * Define to switch on direct access in canvas. Cannot be used without |
|
62 * CANVAS_DOUBLE_BUFFER. |
|
63 */ |
|
64 #ifndef RD_JAVA_NGA_ENABLED |
|
65 #define CANVAS_DIRECT_ACCESS 1 |
|
66 #endif // !RD_JAVA_NGA_ENABLED |
|
67 |
|
68 |
|
69 /** |
|
70 * If canvas is using direct access itself, it must provide a native |
|
71 * framebuffer. |
|
72 */ |
|
73 #ifdef CANVAS_DIRECT_ACCESS |
|
74 #ifndef CANVAS_DOUBLE_BUFFER |
|
75 #define CANVAS_DOUBLE_BUFFER |
|
76 #endif |
|
77 #endif |
|
78 |
|
79 /** |
|
80 * Without a native framebuffer we cannot handle redraw events natively, but |
|
81 * will have to generate a java repaint. |
|
82 */ |
|
83 #ifndef CANVAS_DOUBLE_BUFFER |
|
84 #define CANVAS_ASYNC_REPAINT |
|
85 #endif |
|
86 |
|
87 |
|
88 #include <w32std.h> |
|
89 #include <gulgcmap.h> |
|
90 #include <coemain.h> |
|
91 #include <coecntrl.h> |
|
92 |
|
93 #ifdef RD_JAVA_NGA_ENABLED |
|
94 #include <EGL/egl.h> |
|
95 #include <GLES/gl.h> |
|
96 #include <platform/mw/alf/alfcompositionclient.h> |
|
97 #include "monitor.h" |
|
98 #endif // RD_JAVA_NGA_ENABLED |
|
99 |
|
100 |
|
101 #include <lcdui.h> |
|
102 #include <reflcdui.h> |
|
103 #include <aknpointereventsuppressor.h> |
|
104 #include <MMIDCustomComponentContainer.h> |
|
105 |
|
106 |
|
107 /** MMIDMediaKeysListener in declaration. */ |
|
108 #include "MMIDMediaKeysListener.h" |
|
109 |
|
110 /** Used CMIDDisplayable as member iDisplayable. */ |
|
111 #include "CMIDDisplayable.h" |
|
112 |
|
113 |
|
114 class CMIDKeyDecoder; |
|
115 class CMIDScaler; |
|
116 class CMIDCallIndicator; |
|
117 class CMIDNetworkIndicator; |
|
118 class CMIDRemConObserver; |
|
119 class CMIDTactileFeedbackExtension; |
|
120 |
|
121 |
|
122 /** |
|
123 * Drawable canvas control. |
|
124 * Can be used as drawing surface of MIDP Canvas. |
|
125 * Key events, game actions, pointer events and size change events are |
|
126 * generated in the CMIDCanvas class. Whenever a key is pressed, that key is |
|
127 * translated and an event is posted to the Java side. |
|
128 * |
|
129 * @lib lcdui.dll |
|
130 * @since S60 v3.0 |
|
131 */ |
|
132 NONSHARABLE_CLASS(CMIDCanvas) : |
|
133 public CCoeControl, |
|
134 public MMIDCanvas, |
|
135 public MMIDBufferProcessor, |
|
136 public MDirectContainer, |
|
137 #ifdef CANVAS_DIRECT_ACCESS |
|
138 public MDirectScreenAccess, |
|
139 #endif |
|
140 public MMIDMediaKeysListener, |
|
141 #ifdef RD_TACTILE_FEEDBACK |
|
142 public MMIDTactileFeedbackComponent, |
|
143 #endif |
|
144 #ifdef RD_JAVA_NGA_ENABLED |
|
145 public MAlfBufferProvider, |
|
146 #endif // RD_JAVA_NGA_ENABLED |
|
147 public MMIDCustomComponentContainer |
|
148 { |
|
149 /** CMIDNetworkIndicator is using protected function PostEvent. */ |
|
150 friend class CMIDNetworkIndicator; |
|
151 |
|
152 public: |
|
153 |
|
154 /** |
|
155 * Two-phased constructor. |
|
156 * |
|
157 * @param aEnv Environment object. |
|
158 * @param aComponentType The component type, can be ECanvas |
|
159 * or EGameCanvas. |
|
160 * @param aUpdateRequired Update is requied. |
|
161 */ |
|
162 static CMIDCanvas* NewL( |
|
163 MMIDEnv& aEnv, |
|
164 CCoeControl& aWindow, |
|
165 MMIDComponent::TType aComponentType = MMIDComponent::ECanvas, |
|
166 TBool aUpdateRequired = EFalse); |
|
167 |
|
168 /** |
|
169 * Destructor. |
|
170 */ |
|
171 virtual ~CMIDCanvas(); |
|
172 |
|
173 /** |
|
174 * Set fullscreen mode on/off. |
|
175 * |
|
176 * @since S60 v3.0 |
|
177 * @param aFullScreen The fullscreen mode state to be set. |
|
178 */ |
|
179 void FullScreen(TBool aFullScreen); |
|
180 |
|
181 /** |
|
182 * Tells whether scaling is on or off. |
|
183 * |
|
184 * @since S60 v3.0 |
|
185 * @return ETrue if scaling is on, otherwise returns EFalse. |
|
186 */ |
|
187 TBool IsScalingOn(); |
|
188 |
|
189 /** |
|
190 * Tells whether application attribute |
|
191 * Nokia-MIDlet-S60-Selection-Key-Compatibility is set true or not. |
|
192 * |
|
193 * @since S60 v5.0 |
|
194 * @return ETrue if the attribute value is true, otherwise returns EFalse. |
|
195 */ |
|
196 TBool SelectionKeyCompatibility(); |
|
197 |
|
198 |
|
199 // from base class CCoeControl |
|
200 |
|
201 /** |
|
202 * Counts the number of compound controls in this CCoeControl. |
|
203 * |
|
204 * @return The number of compound controls in this CCoeControl |
|
205 * @since S60 5.0 |
|
206 */ |
|
207 TInt CountComponentControls() const; |
|
208 |
|
209 /** |
|
210 * Returns the compound control in the specified index. |
|
211 * |
|
212 * @param aIndex The index of the control to be retrieved. |
|
213 * @return The control in the specified index or NULL if there |
|
214 * is no control in that index. |
|
215 * @since S60 5.0 |
|
216 */ |
|
217 CCoeControl* ComponentControl(TInt aIndex) const; |
|
218 |
|
219 /** |
|
220 * From CCoeControl. |
|
221 * Process a key event. |
|
222 * |
|
223 * @since S60 v3.0 |
|
224 * @param aKeyEvent Key event. |
|
225 * @param aType Event code. |
|
226 * @return Key response. |
|
227 */ |
|
228 TKeyResponse OfferKeyEventL( |
|
229 const TKeyEvent& aKeyEvent, |
|
230 TEventCode aType); |
|
231 |
|
232 |
|
233 // from base class MMIDCanvas |
|
234 |
|
235 /** |
|
236 * From MMIDComponent. |
|
237 * Invoked by the framework to clean up any resources used by the |
|
238 * implementation. Deletes this. |
|
239 * |
|
240 * @since S60 v3.0 |
|
241 */ |
|
242 void Dispose(); |
|
243 |
|
244 /** |
|
245 * From MMIDComponent. |
|
246 * Returns the component type as a MMIDComponent::TType enum. |
|
247 * |
|
248 * @since S60 v3.0 |
|
249 * @return Always returns MMIDComponent::ECanvas. |
|
250 */ |
|
251 MMIDComponent::TType Type() const; |
|
252 |
|
253 /** |
|
254 * From MMIDComponent. |
|
255 * Returns buffer processor associated with this component. |
|
256 * |
|
257 * @since S60 v3.0 |
|
258 * @return Always returns this. |
|
259 */ |
|
260 MMIDBufferProcessor* Processor(); |
|
261 |
|
262 /** |
|
263 * From MMIDCancas. |
|
264 * Returns a reference to the CCoeControl corresponding to this canvas. |
|
265 * |
|
266 * @since S60 v3.0 |
|
267 * @return Reference to the CCoeControl corresponding to this canvas. |
|
268 */ |
|
269 CCoeControl& Control(); |
|
270 |
|
271 /** |
|
272 * From MMIDCancas. |
|
273 * Double buffering support. |
|
274 * |
|
275 * Returns the frame buffer. |
|
276 * |
|
277 * @since S60 v3.0 |
|
278 * @return A pointer to the frame buffer. |
|
279 */ |
|
280 CFbsBitmap* FrameBuffer() const; |
|
281 |
|
282 /** |
|
283 * From MMIDCancas. |
|
284 * Returns the size of the canvas content. |
|
285 * |
|
286 * @since S60 v3.0 |
|
287 * @return The size of the displayable content. |
|
288 */ |
|
289 TSize ContentSize() const; |
|
290 |
|
291 /** |
|
292 * From MMIDCancas. |
|
293 * Direct screen access support. |
|
294 * |
|
295 * Disables temporarily direct screen access. |
|
296 * |
|
297 * @since S60 v3.0 |
|
298 */ |
|
299 void PauseDirectAccess(); |
|
300 |
|
301 /** |
|
302 * From MMIDCancas. |
|
303 * Re-enables direct screen access. |
|
304 * |
|
305 * @since S60 v3.0 |
|
306 */ |
|
307 void ResumeDirectAccess(); |
|
308 |
|
309 /** |
|
310 * From MMIDCancas. |
|
311 * Switch off key event posting. Game keys will still be tracked, but |
|
312 * keyPressed()/keyReleased() callbacks will not be called. |
|
313 * |
|
314 * @since S60 v3.0 |
|
315 */ |
|
316 void SuppressKeys(); |
|
317 |
|
318 /** |
|
319 * From MMIDCancas. |
|
320 * Returns the latched state of the game action keys. |
|
321 * |
|
322 * @since S60 v3.0 |
|
323 * @return The latched state of the game action keys. |
|
324 */ |
|
325 TUint32 GameActions(); |
|
326 |
|
327 /** |
|
328 * From MMIDCancas. |
|
329 * Returns a direct container on which video can be rendered. |
|
330 * |
|
331 * @since S60 v3.0 |
|
332 * @return A container on which video can be rendered |
|
333 */ |
|
334 MDirectContainer& DirectContainer(); |
|
335 |
|
336 /** |
|
337 * From MMIDCancas. |
|
338 * Draw a background image. |
|
339 * |
|
340 * @since S60 v3.2 |
|
341 * @param aGc Target graphical context |
|
342 * @param aPosition Position |
|
343 * @param aSize Size |
|
344 */ |
|
345 void DrawBackground( |
|
346 CBitmapContext& aGc, |
|
347 const TPoint& aPosition, |
|
348 const TSize& aSize); |
|
349 |
|
350 /** |
|
351 * From MMIDCancas. |
|
352 * Returns the type of Canvas object. |
|
353 * |
|
354 * @since S60 v3.2 |
|
355 * @return ETrue if the type is |
|
356 * MMIDComponent::EGameCanvas and EFalse |
|
357 * when the type is MMIDComponent::ECanvas. |
|
358 */ |
|
359 TBool IsGameCanvas() const; |
|
360 |
|
361 /** |
|
362 * From MMIDCancas. |
|
363 * Gets a network indicator location and size on fullscreen Canvas. |
|
364 * |
|
365 * @since S60 v5.0 |
|
366 * @param aPosition Returned top left position of network indicator |
|
367 * @param aSize Returned size of nw indicator |
|
368 * @return EFalse if Canvas is not able to display nw indicator (not |
|
369 * fullscreen), otherwise ETrue. |
|
370 */ |
|
371 TBool NetworkIndicatorLocation(TPoint& aPosition, TSize& aSize) const; |
|
372 |
|
373 |
|
374 #ifdef RD_TACTILE_FEEDBACK |
|
375 /** |
|
376 * From MMIDCancas. |
|
377 * Get tactile feedback component. |
|
378 * |
|
379 * @since S60 v5.0 |
|
380 * @return this as tactile feedback component. |
|
381 */ |
|
382 MMIDTactileFeedbackComponent* TactileFeedbackComponent(); |
|
383 #endif // RD_TACTILE_FEEDBACK |
|
384 |
|
385 |
|
386 // from base class MMIDBufferProcessor |
|
387 |
|
388 /** |
|
389 * From MMIDBufferProcessor. |
|
390 * Process a block of commands, updating read pointer as you go. |
|
391 * |
|
392 * @since S60 v3.0 |
|
393 * @param aRead The address of the first command in the buffer for this |
|
394 * processor. |
|
395 * @param aEnd The address of the command *after* the last command in the |
|
396 * buffer for this processor. |
|
397 * @param aCycles The amount of 'compute effort' remaining in the current |
|
398 * AO RunL. |
|
399 * @param aStatus The request status. |
|
400 * @return Returns ETrue if processing will be async. |
|
401 */ |
|
402 TBool ProcessL( |
|
403 const TMIDBufferOp*& aRead, |
|
404 const TMIDBufferOp* aEnd, |
|
405 TInt& aCycles, |
|
406 #ifdef RD_JAVA_NGA_ENABLED |
|
407 java::util::Monitor* aMonitor); |
|
408 #else |
|
409 TRequestStatus* aStatus = NULL); |
|
410 #endif |
|
411 |
|
412 /** |
|
413 * From MMIDBufferProcessor. |
|
414 * Called by framework if the processor is doing some async operation |
|
415 * when the MIDlet is closed down. Processor should cancel the async |
|
416 * operation and clean up any resources. |
|
417 * |
|
418 * @since S60 v3.0 |
|
419 */ |
|
420 void AbortAsync(); |
|
421 |
|
422 |
|
423 #ifdef CANVAS_DIRECT_ACCESS |
|
424 // from base class MDirectScreenAccess |
|
425 |
|
426 /** |
|
427 * From MAbortDirectScreenAccess. |
|
428 * This function is called by the window server when direct screen access |
|
429 * must stop (for example because a dialogue is moved in front of the area |
|
430 * where direct screen access is taking place). |
|
431 * |
|
432 * @since S60 v3.0 |
|
433 * @param aReason The reason why direct screen access was terminated. |
|
434 */ |
|
435 void AbortNow(RDirectScreenAccess::TTerminationReasons aReasons); |
|
436 |
|
437 /** |
|
438 * From MDirectScreenAccess. |
|
439 * This function is called by the window server as soon as direct screen |
|
440 * access can resume. |
|
441 * |
|
442 * @since S60 v3.0 |
|
443 * @param aReason Provides the reason why direct screen access was |
|
444 * terminated. |
|
445 */ |
|
446 void Restart(RDirectScreenAccess::TTerminationReasons aReasons); |
|
447 #endif // CANVAS_DIRECT_ACCESS |
|
448 |
|
449 |
|
450 // from base class MDirectContainer |
|
451 |
|
452 /** |
|
453 * From MDirectContainer. |
|
454 * Set the content of this direct container. |
|
455 * |
|
456 * @since S60 v3.0 |
|
457 * @param aContent Content which is displayed on this container. |
|
458 */ |
|
459 void MdcAddContent(MDirectContent* aContent); |
|
460 |
|
461 /** |
|
462 * From MDirectContainer. |
|
463 * Remove the content from this direct container. This will called when |
|
464 * the Player is closed. |
|
465 * |
|
466 * @since S60 v3.0 |
|
467 * @param aContent Content which is displayed on this container. |
|
468 */ |
|
469 void MdcRemoveContent(MDirectContent* aContent); |
|
470 |
|
471 /** |
|
472 * From MDirectContainer. |
|
473 * Add content bound to this direct container. |
|
474 * Container will not allow painting in this region. |
|
475 * |
|
476 * @since S60 v3.0 |
|
477 * @param aRect Content bounds. |
|
478 */ |
|
479 void MdcAddContentBounds(const TRect& aRect); |
|
480 |
|
481 /** |
|
482 * From MDirectContainer. |
|
483 * Removes one content bound from this direct container. |
|
484 * |
|
485 * @since S60 v3.2 |
|
486 * @param aRect Content bound to be removed. |
|
487 */ |
|
488 void MdcRemoveContentBounds(const TRect& aRect); |
|
489 |
|
490 /** |
|
491 * From MDirectContainer. |
|
492 * Get rect of a window on which content of this direct container can be |
|
493 * displayed. |
|
494 * |
|
495 * @since S60 v3.2 |
|
496 * @return Rect of a window. |
|
497 */ |
|
498 TRect MdcContainerWindowRect() const; |
|
499 |
|
500 /** |
|
501 * From MDirectContainer. |
|
502 * Get the visiblity of this direct container. |
|
503 * |
|
504 * @since S60 v3.0 |
|
505 * @return ETrue if the container is visible, EFalse if it is |
|
506 * invisible. |
|
507 */ |
|
508 TBool MdcContainerVisibility() const; |
|
509 |
|
510 /** |
|
511 * From MDirectContainer. |
|
512 * Get the bounds of the area that the content of this direct container |
|
513 * can occupy. |
|
514 * |
|
515 * @since S60 v3.0 |
|
516 * @return Maximum area that the content can occupy in screen |
|
517 * co-ordinates. |
|
518 */ |
|
519 TRect MdcContentBounds() const; |
|
520 |
|
521 /** |
|
522 * From MDirectContainer. |
|
523 * Get the area on the Item on which content can be displayed. |
|
524 * |
|
525 * @since S60 v3.0 |
|
526 * @param aContentRect Return parameter for content area in Item |
|
527 * co-ordinates. |
|
528 * @param aScreenRect Return parameter for content area in screen |
|
529 * co-ordinates. |
|
530 */ |
|
531 void MdcItemContentRect(TRect& aContentRect, TRect& aScreenRect) const; |
|
532 |
|
533 /** |
|
534 * From MDirectContainer. |
|
535 * Allows a control created for direct container content display to pass |
|
536 * on pointer events. |
|
537 * |
|
538 * @since S60 v3.0 |
|
539 * @param aPointerEvent The pointer event. iPosition will be reset to the |
|
540 * parent window position. iParentPosition will be invalid for the |
|
541 * container. |
|
542 */ |
|
543 void MdcHandlePointerEventL(TPointerEvent& aPointerEvent); |
|
544 |
|
545 /** |
|
546 * From MDirectContainer. |
|
547 * Flush the direct container content. |
|
548 * |
|
549 * @since S60 v3.2 |
|
550 * @param aContentRect The content area to be proceeded. |
|
551 */ |
|
552 void MdcFlushContainer(const TRect& aRect); |
|
553 |
|
554 /** |
|
555 * From MDirectContainer. |
|
556 * Invokes callback aConsumer->MdcDSAResourcesCallback in LCDUI thread. |
|
557 * Used in case when MMAPI needs to start DSA within LCDUI thread. |
|
558 * |
|
559 * @since S60 v5.0 |
|
560 * @param "aConsumer" A consumer of callback |
|
561 */ |
|
562 void MdcGetDSAResources(MUiEventConsumer& aConsumer); |
|
563 |
|
564 /** |
|
565 * From MDirectContainer. |
|
566 * Invokes callback aConsumer->MdcUICallback in LCDUI thread. |
|
567 * Used in case when MMAPI needs to run some operation |
|
568 * within LCDUI thread. |
|
569 * |
|
570 * @since S60 v5.0 |
|
571 * @param "aConsumer" A consumer of callback |
|
572 * @param "aCallbackId" A number identifying the callback |
|
573 */ |
|
574 void MdcGetUICallback(MUiEventConsumer& aConsumer, TInt aCallbackId); |
|
575 |
|
576 #ifdef RD_JAVA_NGA_ENABLED |
|
577 /** |
|
578 * From MDirectContainer. |
|
579 * Notification about added content in LCDUI thread. |
|
580 * @since S60 v9.2 |
|
581 */ |
|
582 void MdcNotifyContentAdded(); |
|
583 #endif |
|
584 |
|
585 |
|
586 // from base class MMIDMediaKeysListener |
|
587 |
|
588 /** |
|
589 * From MMIDMediaKeysListener. |
|
590 * This method is called when a media key has been pressed. |
|
591 * |
|
592 * @since S60 3.2 |
|
593 * @param TMIDKeyEvent The media key event that has occured. |
|
594 */ |
|
595 void HandleMediaKeyEvent(TMIDKeyEvent& aKeyEvent); |
|
596 |
|
597 |
|
598 #ifdef RD_TACTILE_FEEDBACK |
|
599 // from base class MMIDTactileFeedbackComponent |
|
600 |
|
601 /** |
|
602 * From MMIDTactileFeedbackComponent. |
|
603 * Update tactile feedback areas. |
|
604 * |
|
605 * @since S60 v5.0 |
|
606 */ |
|
607 void UpdateTactileFeedback(); |
|
608 |
|
609 /** |
|
610 * From MMIDTactileFeedbackComponent. |
|
611 * Register feedback area. |
|
612 * |
|
613 * @since S60 v5.0 |
|
614 * @param aId The area Id. |
|
615 * @param aRect The area rectangle. |
|
616 * @param aStyle The area style. |
|
617 */ |
|
618 void RegisterFeedbackArea(TInt aId, TRect aRect, TInt aStyle); |
|
619 |
|
620 /** |
|
621 * From MMIDTactileFeedbackComponent. |
|
622 * Unregister feedback area. |
|
623 * |
|
624 * @since S60 v5.0 |
|
625 * @param aId The area Id. |
|
626 */ |
|
627 void UnregisterFeedbackArea(TInt aId); |
|
628 |
|
629 /** |
|
630 * From MMIDTactileFeedbackComponent. |
|
631 * Unregister feedback for the control. |
|
632 * |
|
633 * @since S60 v5.0 |
|
634 */ |
|
635 void UnregisterFeedbackForControl(); |
|
636 |
|
637 /** |
|
638 * From MMIDTactileFeedbackComponent. |
|
639 * Move area to first priority. |
|
640 * |
|
641 * @since S60 v5.0 |
|
642 * @param aId The area Id. |
|
643 */ |
|
644 void MoveAreaToFirstPriority(TInt aId); |
|
645 #endif // RD_TACTILE_FEEDBACK |
|
646 |
|
647 // From MMIDCustomComponentContainer |
|
648 |
|
649 /** |
|
650 * Registers a new custom component to this container. |
|
651 * |
|
652 * The ownership of the component is NOT transfferred. Nothing happens |
|
653 * if the component has already been registered. The component is added |
|
654 * on top of the stack in this container. Index can be changed later. |
|
655 * |
|
656 * @param aComponent The component to be registered. |
|
657 * @since S60 5.0 |
|
658 */ |
|
659 void RegisterComponentL(MMIDCustomComponent* aComponent); |
|
660 |
|
661 /** |
|
662 * Unregisters an existing custom component from this container. |
|
663 * |
|
664 * Nothing happens if the component is not found from this container. |
|
665 * |
|
666 * @param aComponent The component to be unregistered. |
|
667 * @since S60 5.0 |
|
668 */ |
|
669 void UnregisterComponent(MMIDCustomComponent* aComponent); |
|
670 |
|
671 /** |
|
672 * Changes the index of the specified custom component. |
|
673 * |
|
674 * @param aComponent The component which index will be changed |
|
675 * @param aNewIndex The new index of the component. |
|
676 * @since S60 5.0 |
|
677 */ |
|
678 void SetComponentIndexL( |
|
679 MMIDCustomComponent* aComponent, |
|
680 TInt aNewIndex); |
|
681 |
|
682 /** |
|
683 * Stores the index of focused component in parent. |
|
684 * |
|
685 * @param aComponent The component which gained focus |
|
686 * @since S60 5.0 |
|
687 */ |
|
688 void SetFocusedComponent(MMIDCustomComponent* aComponent); |
|
689 |
|
690 /** |
|
691 * Returns the index of the given component in this container. |
|
692 * |
|
693 * @return The index of the given component in this container. KErrNotFound |
|
694 * is returned if this container does not have the specified component. |
|
695 * @since S60 5.0 |
|
696 */ |
|
697 TInt ComponentIndex(MMIDCustomComponent* aComponent) const; |
|
698 |
|
699 /** |
|
700 * Gets the full screen status of this component container. |
|
701 * |
|
702 * Typically the container is the same object which is returned when |
|
703 * calling <code>Control()</code>. |
|
704 * |
|
705 * @return <code>ETrue</code> if this component container is set to full screen |
|
706 * and <code>EFalse</code> if not. |
|
707 * @since S60 5.0 |
|
708 */ |
|
709 TBool IsFullScreen() const; |
|
710 |
|
711 protected: |
|
712 |
|
713 /** |
|
714 * Post an event to Java side. |
|
715 * |
|
716 * @since S60 v3.0 |
|
717 * @param aType Event type. |
|
718 * @param aData0 Event data. |
|
719 * @param aData1 Event data. |
|
720 * @return ETrue on success, otherwise returns EFalse . |
|
721 */ |
|
722 TBool PostEvent(TEventType aType, TInt aData0, TInt aData1) const; |
|
723 |
|
724 /** |
|
725 * Update screen from frame buffer. |
|
726 * |
|
727 * @since S60 v3.0 |
|
728 * @param aRect Source rectangle in frame buffer co-ordinates. |
|
729 */ |
|
730 #ifdef RD_JAVA_NGA_ENABLED |
|
731 void UpdateL(const TRect& aRect); |
|
732 #else |
|
733 void Update(const TRect& aRect); |
|
734 #endif |
|
735 |
|
736 /** |
|
737 * Prepare draw operation. |
|
738 * |
|
739 * @since S60 v5.0 |
|
740 * @param aGc Graphics context for drawing. |
|
741 * @param aWinRect Source rectangle in frame buffer co-ordinates. |
|
742 */ |
|
743 inline void PrepareDraw(CGraphicsContext& aGc, TRect& aWinRect) const; |
|
744 |
|
745 #ifdef RD_JAVA_NGA_ENABLED |
|
746 /** |
|
747 * Draws canvas content using |
|
748 * - pixel source when canvas has plain 2D content. |
|
749 * - EGL surface when M3G content has been drawn. |
|
750 * This method is not used if canvas has direct content. |
|
751 * In this case drawing is done via CCoeControl framework. |
|
752 * |
|
753 * @since S60 v9.2 |
|
754 * @param aRect Rectangle to be drawn in frame buffer co-ordinates. |
|
755 */ |
|
756 void DrawWindowNgaL(const TRect& aRect); |
|
757 #endif |
|
758 |
|
759 #ifdef CANVAS_DOUBLE_BUFFER |
|
760 /** |
|
761 * Draw through Window server using native frame buffer. |
|
762 * |
|
763 * @since S60 v3.0 |
|
764 * @param aRect Source rectangle in frame buffer co-ordinates. |
|
765 */ |
|
766 void DrawWindow(const TRect& aRect) const; |
|
767 #endif // CANVAS_DOUBLE_BUFFER |
|
768 |
|
769 #ifdef CANVAS_DIRECT_ACCESS |
|
770 /** |
|
771 * Start Direct Screen Access. |
|
772 * |
|
773 * @since S60 v3.0 |
|
774 */ |
|
775 void StartDirectAccess(); |
|
776 |
|
777 /** |
|
778 * Stop Direct Screen Access. |
|
779 * |
|
780 * @since S60 v3.0 |
|
781 */ |
|
782 void StopDirectAccess(); |
|
783 |
|
784 /** |
|
785 * Restart Direct Screen Access. |
|
786 * |
|
787 * @since S60 v3.0 |
|
788 */ |
|
789 void RestartL(); |
|
790 |
|
791 /** |
|
792 * Draw using Direct Screen Access. |
|
793 * |
|
794 * @since S60 v3.0 |
|
795 * @param aRect Source rectangle in frame buffer co-ordinates. |
|
796 */ |
|
797 void DrawDirect(const TRect& aRect) const; |
|
798 #endif // CANVAS_DIRECT_ACCESS |
|
799 |
|
800 // from base class CCoeControl |
|
801 |
|
802 /** |
|
803 * From CCoeControl. |
|
804 * Resource change handling. |
|
805 * |
|
806 * @since S60 v5.0 |
|
807 * @param aType The message type code. |
|
808 */ |
|
809 void HandleResourceChange(TInt aType); |
|
810 |
|
811 /** |
|
812 * Scale II (Pen and Touch) support to S60 release 5.0 builds. |
|
813 * Conditional compilation required by the implementation. |
|
814 */ |
|
815 #ifdef RD_SCALABLE_UI_V2 |
|
816 /** |
|
817 * From CCoeControl. |
|
818 * Pointer events handling. |
|
819 * |
|
820 * @since S60 v5.0 |
|
821 * @param aEvent The received pointer event. |
|
822 */ |
|
823 virtual void HandlePointerEventL(const TPointerEvent& aEvent); |
|
824 #endif // RD_SCALABLE_UI_V2 |
|
825 |
|
826 /** |
|
827 * From CCoeControl. |
|
828 * Change of focus. |
|
829 * |
|
830 * @since S60 v3.0 |
|
831 * @param aDrawNow The redraw of the control is or is not required |
|
832 * immediatelly. |
|
833 */ |
|
834 virtual void FocusChanged(TDrawNow aDrawNow); |
|
835 |
|
836 /** |
|
837 * From CCoeControl. |
|
838 * Change of size. |
|
839 * |
|
840 * @since S60 v3.0 |
|
841 */ |
|
842 virtual void SizeChanged(); |
|
843 |
|
844 /** |
|
845 * From CCoeControl. |
|
846 * Change of position. |
|
847 * |
|
848 * @since S60 v3.0 |
|
849 */ |
|
850 virtual void PositionChanged(); |
|
851 |
|
852 /** |
|
853 * From CCoeControl. |
|
854 * Drawing. |
|
855 * |
|
856 * @since S60 v3.0 |
|
857 * @param aRect The clipping rectangle. |
|
858 */ |
|
859 virtual void Draw(const TRect& aRect) const; |
|
860 |
|
861 |
|
862 private: |
|
863 |
|
864 #ifdef RD_SCALABLE_UI_V2 |
|
865 /** |
|
866 * Pointer events handling in controls. |
|
867 * |
|
868 * @param aPointerEvent The received pointer event on canvas. |
|
869 * |
|
870 * @return ETrue if event was consumed by any control, Efalse otherwise. |
|
871 * @since S60 v5.0 |
|
872 */ |
|
873 TBool HandlePointerEventInControlsL(const TPointerEvent& aPointerEvent); |
|
874 |
|
875 /** |
|
876 * Pointer event pressed in the control. |
|
877 * |
|
878 * @param aControl The control to be checked. |
|
879 * @param apoint The received pointer event transformed position. |
|
880 * |
|
881 * @return ETrue if event is in the control, Efalse otherwise. |
|
882 * @since S60 v5.0 |
|
883 */ |
|
884 TBool PointerEventInControl(MMIDCustomComponent* aControl, |
|
885 TPoint aPoint); |
|
886 |
|
887 #endif // RD_SCALABLE_UI_V2 |
|
888 |
|
889 /** |
|
890 * Constructor. |
|
891 * @see CMIDCanvas::NewL() |
|
892 */ |
|
893 CMIDCanvas( |
|
894 MMIDEnv& aEnv, |
|
895 MMIDComponent::TType aCanvasType, |
|
896 TBool aUpdateRequired); |
|
897 |
|
898 /** |
|
899 * Second phase construction. |
|
900 * |
|
901 * @since S60 v3.0 |
|
902 * @param aWindow Container window. |
|
903 */ |
|
904 void ConstructL(CCoeControl& aWindow); |
|
905 |
|
906 /** |
|
907 * Set the container window. |
|
908 * |
|
909 * @since S60 v3.0 |
|
910 * @param aWindow Container window. |
|
911 */ |
|
912 void SetContainerWindowL(const CCoeControl& aWindow); |
|
913 |
|
914 /** |
|
915 * Send key event to Java side. |
|
916 * |
|
917 * @since S60 v3.2 |
|
918 * @param aEvent Key event. |
|
919 * @param aType Event code. |
|
920 */ |
|
921 void SendKeyEventToJavaSideL(const TKeyEvent& aEvent, TEventCode aType); |
|
922 |
|
923 |
|
924 #ifdef CANVAS_DOUBLE_BUFFER |
|
925 /** |
|
926 * Create frame buffer. |
|
927 * |
|
928 * @since S60 v3.0 |
|
929 * @param aSize The size of a frame buffer. |
|
930 */ |
|
931 void CreateFrameBufferL(const TSize& aSize); |
|
932 #endif // CANVAS_DOUBLE_BUFFER |
|
933 |
|
934 #ifdef DEFER_BITBLT |
|
935 /** |
|
936 * Get BitBlt cycles count. |
|
937 * |
|
938 * @since S60 v3.0 |
|
939 * @param aSize The size of a pixel region. |
|
940 * @return Cycles count. |
|
941 */ |
|
942 TInt BitBltCycles(const TSize& aSize) const; |
|
943 #endif // DEFER_BITBLT |
|
944 |
|
945 /** |
|
946 * Layout Canvas control. |
|
947 * |
|
948 * @since S60 v3.0 |
|
949 */ |
|
950 void Layout(); |
|
951 |
|
952 #ifdef CANVAS_DIRECT_ACCESS |
|
953 /** |
|
954 * Tells whether Direct Screen Access is enabled or disabled. |
|
955 * |
|
956 * @since S60 v3.0 |
|
957 * @return ETrue if DSA is enabled, otherwise returns EFalse. |
|
958 */ |
|
959 inline TBool DirectEnabled() const; |
|
960 |
|
961 /** |
|
962 * Tells whether Direct Screen Access is paused or not. |
|
963 * |
|
964 * @since S60 v3.0 |
|
965 * @return ETrue if DSA is paused, otherwise returns EFalse. |
|
966 */ |
|
967 inline TBool DirectPaused() const; |
|
968 |
|
969 /** |
|
970 * Tells whether screen device update is required or not. |
|
971 * |
|
972 * @since S60 v3.0 |
|
973 * @return ETrue if update is required, otherwise returns EFalse. |
|
974 */ |
|
975 inline TBool UpdateRequired() const; |
|
976 #endif // CANVAS_DIRECT_ACCESS |
|
977 |
|
978 /** |
|
979 * Tells whether posting of key events is enabled or disabled. |
|
980 * |
|
981 * @since S60 v3.0 |
|
982 * @return ETrue if posting of key events is enabled, otherwise returns |
|
983 * EFalse. |
|
984 */ |
|
985 inline TBool PostKeyEvents() const; |
|
986 |
|
987 /** |
|
988 * Process game press action. |
|
989 * |
|
990 * @since S60 v3.0 |
|
991 * @param aAction Game action. |
|
992 */ |
|
993 void GamePress(TInt aAction); |
|
994 |
|
995 /** |
|
996 * Process game release action. |
|
997 * |
|
998 * @since S60 v3.0 |
|
999 * @param aAction Game action. |
|
1000 */ |
|
1001 void GameRelease(TInt aAction); |
|
1002 |
|
1003 /** |
|
1004 * Sets MIDlet's original size and target size resolutions if those are |
|
1005 * defined in JAD or manifest. If attribute is missing or it's not |
|
1006 * defined correctly, the value will be 0,0. This value is later used as |
|
1007 * an "error value". |
|
1008 * |
|
1009 * @since S60 v3.0 |
|
1010 */ |
|
1011 void SetScalingFactors(); |
|
1012 |
|
1013 /** |
|
1014 * Returns original MIDlet screen size with regards to display |
|
1015 * orientation. |
|
1016 * |
|
1017 * When "MIDlet scaling on orientation switch" is allowed and Canvas |
|
1018 * scaling is enabled then this function reflects display orientation |
|
1019 * when accessing original MIDlet screen size. This means that it |
|
1020 * eventually swaps original MIDlet size orientation if it does not |
|
1021 * correspond to actual display orientation. |
|
1022 * |
|
1023 * @since S60 v3.2 |
|
1024 * @return Original MIDlet screen size with regards to display |
|
1025 * orientation. |
|
1026 */ |
|
1027 TSize OrientedOrgMIDletScrSize() const; |
|
1028 |
|
1029 /** |
|
1030 * Check if the network indicator should be shown in Canvas depending on |
|
1031 * the midlet's domain: |
|
1032 * - in manufacturer domain the indicator is not shown |
|
1033 * - in operator domain a central reposotory key defines whether the |
|
1034 * indicator is shown |
|
1035 * - in trusted/untrusted 3rd patry domain the indicator is shown |
|
1036 * |
|
1037 * @since S60 3.2 |
|
1038 * @return ETrue, if network indicator is shown in Canvas, otherwise |
|
1039 * returns EFalse. |
|
1040 */ |
|
1041 TBool IsNetworkIndicatorEnabledL() const; |
|
1042 |
|
1043 #ifdef RD_JAVA_NGA_ENABLED |
|
1044 |
|
1045 /** EGL surface types */ |
|
1046 typedef enum |
|
1047 { |
|
1048 EEglNone = 0, |
|
1049 EEglWindow, |
|
1050 EEglPbuffer |
|
1051 } TEglType; |
|
1052 |
|
1053 |
|
1054 // from MAlfBufferProvider |
|
1055 public: |
|
1056 /** |
|
1057 * Called by framework when the next buffer is ready and available for the client to draw. |
|
1058 * |
|
1059 * @since S60 v9.2 |
|
1060 * @param aVisibleRegion is currently visible surface region |
|
1061 * @return ETrue to continue drawing of frames. EFalse to pause drawing. |
|
1062 * After pausing drawing client needs to call CAlfCompositionPixelSource::ActivateL to |
|
1063 * continue drawing of frames |
|
1064 */ |
|
1065 TBool ProduceNewFrameL(const TRegion& aVisibleRegion, TUint8*& aBuffer); |
|
1066 |
|
1067 /** |
|
1068 * Called by framework when new buffer is been created. |
|
1069 * Client should provide desired creation attributes. |
|
1070 * |
|
1071 * @since S60 v9.2 |
|
1072 */ |
|
1073 TBufferCreationAttributes& BufferAttributes(); |
|
1074 |
|
1075 /** |
|
1076 * Notifications from Alf composition FW |
|
1077 * |
|
1078 * @since S60 v9.2 |
|
1079 */ |
|
1080 void ContextAboutToSuspend(); |
|
1081 void OnActivation(); |
|
1082 |
|
1083 public: |
|
1084 /** |
|
1085 * Handles switching from foreground to |
|
1086 * background and vice versa. Mainly rendering |
|
1087 * context and surfaces need to be relased. |
|
1088 */ |
|
1089 void HandleForeground(TBool aForeground); |
|
1090 |
|
1091 // From MMIDComponentNgaExtension |
|
1092 public: |
|
1093 /** |
|
1094 * @see MMIDComponentNgaExtension#UpdateEglContent() |
|
1095 * @since S60 9.2 |
|
1096 */ |
|
1097 void UpdateEglContent(); |
|
1098 |
|
1099 /** |
|
1100 * @see MMIDComponentNgaExtension#IsEglAvailable() |
|
1101 * @since S60 9.2 |
|
1102 */ |
|
1103 TBool IsEglAvailable(); |
|
1104 |
|
1105 /** |
|
1106 * @see MMIDComponentNgaExtension#BindEglSurface() |
|
1107 * @since S60 9.2 |
|
1108 */ |
|
1109 EGLSurface BindEglSurface(); |
|
1110 |
|
1111 /** |
|
1112 * @see MMIDComponentNgaExtension#ReleaseEglSurface() |
|
1113 * @since S60 9.2 |
|
1114 */ |
|
1115 void ReleaseEglSurface(); |
|
1116 |
|
1117 /** |
|
1118 * @see MMIDComponentNgaExtension#UpdateOffScreenBitmapL() |
|
1119 * @since S60 9.2 |
|
1120 */ |
|
1121 virtual void UpdateOffScreenBitmapL(TBool aForced); |
|
1122 |
|
1123 /** |
|
1124 * @see MMIDComponentNgaExtension#FillEglSurface() |
|
1125 * @since S60 9.2 |
|
1126 */ |
|
1127 virtual TBool FillEglSurface(const TRect& aRect, const TRgb& aColor); |
|
1128 |
|
1129 /** |
|
1130 * Clear whole OpenGL ES surface (color buffer). |
|
1131 * @param aSurfaceType A surface to be cleared. If the value is |
|
1132 * <code>EEglNone</code> then the defualt surface is used |
|
1133 * (e.g. Pbuffer in case of scaling). |
|
1134 * @param aRgba A clear color. If null then a default color will be used: |
|
1135 * black in case of scaling and otherwise the clear color is white. |
|
1136 * @return <code>ETrue</code> if succeeded. |
|
1137 * @since S60 9.2 |
|
1138 */ |
|
1139 virtual TBool ClearEglSurface( |
|
1140 TEglType aSurfaceType = EEglWindow, const TRgb* aRgba = NULL); |
|
1141 |
|
1142 // From MMIDCanvas |
|
1143 public: |
|
1144 /** |
|
1145 * @see MMIDCanvas::UpdateRect(const TRect&) |
|
1146 */ |
|
1147 void UpdateRect(const TRect& aRect); |
|
1148 |
|
1149 private: |
|
1150 /** |
|
1151 * Blits pbuffer surface scaled to window surface |
|
1152 * @since S60 9.2 |
|
1153 */ |
|
1154 void BlitPBufferScaledToWindowSurface(); |
|
1155 |
|
1156 /** |
|
1157 * Initializes pixel source |
|
1158 * @since S60 9.2 |
|
1159 */ |
|
1160 void InitPixelSourceL(); |
|
1161 |
|
1162 /** |
|
1163 * Releases resources occupied by the pixel source |
|
1164 * @since S60 9.2 |
|
1165 */ |
|
1166 void DisposePixelSource(); |
|
1167 |
|
1168 /** |
|
1169 * Creates an EGL pbuffer surface and context |
|
1170 * for openGL based scaling |
|
1171 * @since S60 9.2 |
|
1172 */ |
|
1173 void CreatePBufferSurfaceL(); |
|
1174 |
|
1175 /** |
|
1176 * Disposes pbuffer surface and context |
|
1177 * created with CreatePBufferSurface() |
|
1178 * @since S60 9.2 |
|
1179 */ |
|
1180 void DisposePBufferSurface(); |
|
1181 |
|
1182 /* |
|
1183 * Initializes EGL resources |
|
1184 * @since S60 9.2 |
|
1185 */ |
|
1186 void OpenEglL(); |
|
1187 |
|
1188 /** |
|
1189 * Releases EGL resources |
|
1190 * @since S60 9.2 |
|
1191 */ |
|
1192 void CloseEgl(); |
|
1193 |
|
1194 /** |
|
1195 * Creates EGL context |
|
1196 * @since S60 9.2 |
|
1197 */ |
|
1198 void CreateEglContext(); |
|
1199 |
|
1200 /** |
|
1201 * Sets current EGL |
|
1202 * @param aType The EGL type that is set active: Window, PBuffer or NULL. |
|
1203 * @return ETrue if succeeded. |
|
1204 * @since S60 9.2 |
|
1205 */ |
|
1206 TBool SetCurrentEglType(TEglType aType = EEglNone); |
|
1207 |
|
1208 /** |
|
1209 * Gets current EGL |
|
1210 * @since S60 9.2 |
|
1211 */ |
|
1212 TEglType GetCurrentEglType(); |
|
1213 |
|
1214 /** |
|
1215 * Reads EGL surface size |
|
1216 * @param aSurface Egl surface. If the value is <code>EGL_NO_SURFACE</code> |
|
1217 * then the defualt surface is used (e.g. Pbuffer in case of scaling). |
|
1218 * @return Surface size. Returns TSize(0, 0) if failed. |
|
1219 * @since S60 9.2 |
|
1220 */ |
|
1221 TSize GetEglSurfaceSize(EGLSurface aSurface = EGL_NO_SURFACE); |
|
1222 |
|
1223 /** |
|
1224 * Handles size changed. EGL window surface needs to be recreated |
|
1225 * if window size increases. |
|
1226 * @since S60 9.2 |
|
1227 */ |
|
1228 void HandleSizeChanged(); |
|
1229 |
|
1230 /** |
|
1231 * Draws frame buffer 2D content as OpenGL texture in case of |
|
1232 * M3G + 2D mixing. |
|
1233 * @since S60 9.2 |
|
1234 */ |
|
1235 void BlitFrameBufferPixels(); |
|
1236 |
|
1237 /** |
|
1238 * Initializes the OpenGL ES content before 2d rendering |
|
1239 * @param aTopLeftOrigo If false then the origo is viewport's |
|
1240 * bottom left corner. |
|
1241 * @param aRect Scissor rectangle. If NULL then the scissor |
|
1242 * will be the same as the viewport rectangle. |
|
1243 * @since S60 9.2 |
|
1244 */ |
|
1245 TSize InitOpenGl(TBool aTopLeftOrigo = EFalse, const TRect* aRect = NULL); |
|
1246 |
|
1247 /** |
|
1248 * Draws a rectangular area of frame buffer as OpenGL texture. |
|
1249 * aRect Part of frame buffer that is drawn. |
|
1250 * @since S60 9.2 |
|
1251 */ |
|
1252 void BlitSubRect(const TRect& aRect); |
|
1253 |
|
1254 /** |
|
1255 * Creates OpenGL texture out of aPixels and draws it to |
|
1256 * EGL surface. Parameters define the texture location on EGL surface. |
|
1257 * @since S60 9.2 |
|
1258 */ |
|
1259 void BlitSubRectTexture( |
|
1260 TInt aXOffset, TInt aYOffset, TInt aWidth, TInt aHeight, |
|
1261 TInt aStride, const TUint8* aPixels); |
|
1262 /** |
|
1263 * Clears the frame buffer with transparent color. |
|
1264 * Clearing is needed in M3G + 2D mixing case in order |
|
1265 * 2D content can be rendered as an OpenGL texture. |
|
1266 * @since S60 9.2 |
|
1267 */ |
|
1268 void ClearFrameBuffer(); |
|
1269 |
|
1270 /** |
|
1271 * Pixel source is activated when canvas has a frame ready to be passed |
|
1272 * to Alf composition. |
|
1273 * @since S60 9.2 |
|
1274 */ |
|
1275 void ActivatePixelSourceL(); |
|
1276 |
|
1277 /** |
|
1278 * Suspending pixel source releases its resources on graphics HW. |
|
1279 * @since S60 9.2 |
|
1280 */ |
|
1281 void SuspendPixelSource(); |
|
1282 |
|
1283 /** |
|
1284 * Notifies monitor omwned by CMIDBuffer after async ProcessL() |
|
1285 * is completed (i.e. in normal case when ProduceNewFrameL() is called). |
|
1286 * @since S60 9.2 |
|
1287 */ |
|
1288 void NotifyMonitor(); |
|
1289 |
|
1290 /** |
|
1291 * Check for OpenGL errors. |
|
1292 * @since S60 9.2 |
|
1293 */ |
|
1294 void AssertGL(); |
|
1295 |
|
1296 /** |
|
1297 * @since S60 9.2 |
|
1298 * Converts pixels from ARGB to RGBA. |
|
1299 */ |
|
1300 inline void ConvertPixels( |
|
1301 const TUint32* aSrc, TUint8* aDst, TInt aPixelCount); |
|
1302 |
|
1303 /** |
|
1304 * EGL error |
|
1305 * @since S60 9.2 |
|
1306 */ |
|
1307 const TDesC8& GetEglError(EGLint aErr); |
|
1308 |
|
1309 #endif // RD_JAVA_NGA_ENABLED |
|
1310 |
|
1311 private: // data |
|
1312 |
|
1313 /** CMIDCanvas flags datatype */ |
|
1314 enum TFlags |
|
1315 { |
|
1316 EDirectEnabled = 1, |
|
1317 EDirectPaused = 2, |
|
1318 EPostKeyEvents = 4, |
|
1319 EUpdateRequired = 8 |
|
1320 }; |
|
1321 |
|
1322 /** |
|
1323 * A MIDlet environment. |
|
1324 */ |
|
1325 MMIDEnv& iEnv; |
|
1326 |
|
1327 #ifdef CANVAS_DOUBLE_BUFFER |
|
1328 /** |
|
1329 * Frame buffer. |
|
1330 * Not own. |
|
1331 */ |
|
1332 CFbsBitmap* iFrameBuffer; |
|
1333 |
|
1334 /** |
|
1335 * Frame bitmapped graphics context. |
|
1336 * Own. |
|
1337 */ |
|
1338 CFbsBitGc* iFrameContext; |
|
1339 |
|
1340 /** |
|
1341 * Frame bitmap graphics device. |
|
1342 * Own. |
|
1343 */ |
|
1344 CFbsBitmapDevice* iFrameDevice; |
|
1345 #endif // CANVAS_DOUBLE_BUFFER |
|
1346 |
|
1347 /** |
|
1348 * Stores information whether this control is the game canvas or not. |
|
1349 */ |
|
1350 TBool iIsGameCanvas; |
|
1351 |
|
1352 /** |
|
1353 * View rectangle. |
|
1354 */ |
|
1355 TRect iViewRect; |
|
1356 |
|
1357 /** |
|
1358 * Content size. |
|
1359 */ |
|
1360 TSize iContentSize; |
|
1361 |
|
1362 #ifdef CANVAS_DIRECT_ACCESS |
|
1363 /** |
|
1364 * An active object used to start direct screen access. |
|
1365 * Own. |
|
1366 */ |
|
1367 CDirectScreenAccess* iDirectAccess; |
|
1368 |
|
1369 /** |
|
1370 * Direct screen access bitmapped graphics context. |
|
1371 * Not own. |
|
1372 */ |
|
1373 CFbsBitGc* iDirectGc; |
|
1374 |
|
1375 /** |
|
1376 * Update region. |
|
1377 */ |
|
1378 mutable RRegion iUpdateRegion; |
|
1379 #endif // CANVAS_DIRECT_ACCESS |
|
1380 |
|
1381 /** |
|
1382 * Status flags. |
|
1383 */ |
|
1384 TUint32 iFlags; |
|
1385 |
|
1386 /** |
|
1387 * Game key state. |
|
1388 */ |
|
1389 TUint32 iGameKeyState; |
|
1390 |
|
1391 /** |
|
1392 * Game key latch. |
|
1393 */ |
|
1394 TUint32 iGameKeyLatch; |
|
1395 |
|
1396 /** |
|
1397 * Displayable. |
|
1398 * Not own. |
|
1399 */ |
|
1400 CMIDDisplayable* iDisplayable; |
|
1401 |
|
1402 /** |
|
1403 * Fullscreen - status flag. |
|
1404 */ |
|
1405 TBool iFullScreen; |
|
1406 |
|
1407 /** |
|
1408 * Scaling on - status flag. |
|
1409 */ |
|
1410 TBool iScalingOn; |
|
1411 |
|
1412 /** |
|
1413 * Nokia-MIDlet-Original-Display-Size JAD attribute value. |
|
1414 */ |
|
1415 TSize iOrgMIDletScrSize; |
|
1416 |
|
1417 /** |
|
1418 * Nokia-MIDlet-Target-Display-Size JAD attribute value. |
|
1419 */ |
|
1420 TSize iTargetMIDletScrSize; |
|
1421 |
|
1422 /** |
|
1423 * Nokia-MIDlet-allow-scaling-on-orientation-switch JAD attribute value. |
|
1424 */ |
|
1425 TBool iScaleMIDletOnOrientSwitch; |
|
1426 |
|
1427 /** |
|
1428 * Nokia-MIDlet-S60-Selection-Key-Compatibility JAD attribute value. |
|
1429 */ |
|
1430 TBool iS60SelectionKeyCompatibility; |
|
1431 |
|
1432 /** |
|
1433 * Network indicator. |
|
1434 * Own. |
|
1435 */ |
|
1436 CMIDNetworkIndicator* iNetworkIndicator; |
|
1437 |
|
1438 /** |
|
1439 * Call indicator. |
|
1440 * Own. |
|
1441 */ |
|
1442 CMIDCallIndicator* iCallIndicator; |
|
1443 |
|
1444 /** |
|
1445 * Scaler. |
|
1446 * Not own. |
|
1447 */ |
|
1448 CMIDScaler* iScaler; |
|
1449 |
|
1450 /** |
|
1451 * PointerEventSuppressor. |
|
1452 * Own. |
|
1453 */ |
|
1454 CAknPointerEventSuppressor* iPointerEventSuppressor; |
|
1455 TPoint iPointerPressedCoordinates; |
|
1456 TBool iPointerEventSuppressionOngoing; |
|
1457 TInt iPESPointerMovementInTwips; |
|
1458 TInt iPESTimeInMilliseconds; |
|
1459 |
|
1460 /** |
|
1461 * For drag event filtering. |
|
1462 */ |
|
1463 TTime iPreviousDragTimeStamp; |
|
1464 |
|
1465 /** |
|
1466 * Direct content listeners. |
|
1467 * Not own. |
|
1468 */ |
|
1469 RPointerArray< MDirectContent > iDirectContents; |
|
1470 |
|
1471 /** |
|
1472 * Restore content when unfaded - status flag. |
|
1473 */ |
|
1474 TBool iRestoreContentWhenUnfaded; |
|
1475 |
|
1476 /** |
|
1477 * Position in screen co-ordinates. |
|
1478 * Stored in member variable because CCoeControl::PositionRelativeToScreen |
|
1479 * cannot be called from another thread. Value is set in |
|
1480 * SetContainerWindowL and in SizeChanged methods. Used in |
|
1481 * MdcContentBounds method. |
|
1482 */ |
|
1483 TPoint iPositionRelativeToScreen; |
|
1484 |
|
1485 /** |
|
1486 * Key decoder. |
|
1487 * Not own. |
|
1488 */ |
|
1489 CMIDKeyDecoder* iKeyDecoder; |
|
1490 |
|
1491 /** |
|
1492 * Remote connection observer. |
|
1493 * Not own. |
|
1494 */ |
|
1495 CMIDRemConObserver* iRemConObserver; |
|
1496 |
|
1497 /** |
|
1498 * The last fade message. |
|
1499 */ |
|
1500 TInt iLastFadeMessage; |
|
1501 |
|
1502 #ifdef RD_TACTILE_FEEDBACK |
|
1503 /** |
|
1504 * To handle tactile feedback areas. |
|
1505 * Own. |
|
1506 */ |
|
1507 CMIDTactileFeedbackExtension* iTactileFeedback; |
|
1508 #endif // RD_TACTILE_FEEDBACK |
|
1509 |
|
1510 /** |
|
1511 * Stores information about screen orientation, if screen |
|
1512 * in landscape mode, variable iLandscape is True |
|
1513 */ |
|
1514 mutable TBool iLandscape; |
|
1515 |
|
1516 /** |
|
1517 * Stores information about screen need of screen refresh |
|
1518 * after orientation change to avoid artifacting |
|
1519 */ |
|
1520 mutable TBool iWndUpdate; |
|
1521 |
|
1522 #ifdef CANVAS_DIRECT_ACCESS |
|
1523 /** |
|
1524 * Stores information that DirectContent |
|
1525 * needs to be informed about DSA restart |
|
1526 */ |
|
1527 TBool iDcDsaToStart; |
|
1528 #endif // CANVAS_DIRECT_ACCESS |
|
1529 |
|
1530 |
|
1531 /** |
|
1532 * Stores old bounds of the direct content |
|
1533 * used before SizeChanged is called |
|
1534 */ |
|
1535 TRect iOldContentBounds; |
|
1536 |
|
1537 /** |
|
1538 * The startup trace should be done only once. |
|
1539 */ |
|
1540 mutable TBool iStartUpTraceDone; |
|
1541 |
|
1542 // The list of registered custom components. |
|
1543 RPointerArray< MMIDCustomComponent > iCustomComponents; |
|
1544 |
|
1545 // The count of custom components. |
|
1546 TInt iCustomComponentsControlCount; |
|
1547 |
|
1548 // The index of focused custom component |
|
1549 TInt iFocusedComponent; |
|
1550 |
|
1551 // Stores the control on which was press event generated |
|
1552 MMIDCustomComponent* iPressedComponent; |
|
1553 |
|
1554 #ifdef RD_JAVA_NGA_ENABLED |
|
1555 |
|
1556 /** |
|
1557 * Flag incdicating the foreground status of canvas. |
|
1558 * Set to EFalse when some other displayable is made current |
|
1559 * or when MIDlet goes to background. |
|
1560 */ |
|
1561 TBool iForeground; |
|
1562 |
|
1563 /** |
|
1564 * CAlfCompositionPixelSource is used for drawing canvas |
|
1565 * content when only basic content is drawn |
|
1566 * (no M3G or direct content). |
|
1567 * Own. |
|
1568 */ |
|
1569 CAlfCompositionPixelSource* iAlfCompositionPixelSource; |
|
1570 |
|
1571 /** |
|
1572 * Flag indicating if pixel source is in suspended state. |
|
1573 * When pixel source is suspended, it releases its surface |
|
1574 * on Graphics HW. |
|
1575 */ |
|
1576 TBool iPixelSourceSuspended; |
|
1577 |
|
1578 /** |
|
1579 * Buffer attributes define the size of ARGB data that is |
|
1580 * passed to CAlfCompositionPixelSource. |
|
1581 * Read by CAlfCompositionPixelSource in BufferAttributes(). |
|
1582 */ |
|
1583 TBufferCreationAttributes iAlfBufferAttributes; |
|
1584 |
|
1585 /** |
|
1586 * Indicates if frame buffer contains a complete frame that |
|
1587 * should be passed to Alf compostion. |
|
1588 */ |
|
1589 mutable TBool iFrameReady; |
|
1590 |
|
1591 /** |
|
1592 * Monitor that needs to be signalled after |
|
1593 * ProduceNewFrameL callback is received. |
|
1594 * Not own. |
|
1595 */ |
|
1596 java::util::Monitor* iAlfMonitor; |
|
1597 |
|
1598 /** |
|
1599 * Flag indicating whether device has 3D HW accelerator. |
|
1600 */ |
|
1601 TBool i3DAccelerated; |
|
1602 |
|
1603 /** |
|
1604 * Flag indicating whether midlet is drawing M3G content. |
|
1605 * Reset to EFalse in CloseEgl(). |
|
1606 */ |
|
1607 TBool iM3GContent; |
|
1608 |
|
1609 /** |
|
1610 * ETrue, while M3G has bound to canvas EGL surface. |
|
1611 */ |
|
1612 TBool iEglOccupied; |
|
1613 |
|
1614 /** |
|
1615 * ETrue, when canvas is drawing the first frame |
|
1616 * that has M3G content. Reset to EFalse in CloseEgl(). |
|
1617 */ |
|
1618 TBool iM3GStart; |
|
1619 |
|
1620 /** |
|
1621 * Set to ETrue, if canvas is resized while M3G was bound to |
|
1622 * EGL surface. |
|
1623 */ |
|
1624 TBool iEglPendingResize; |
|
1625 |
|
1626 /** |
|
1627 * Set to ETrue, if canvas canvas goes to background |
|
1628 * (i.e. canvas needs to release resources on graphics HW) |
|
1629 * while M3G was bound to EGL surface. |
|
1630 */ |
|
1631 TBool iEglPendingDispose; |
|
1632 |
|
1633 /** |
|
1634 * Handles to the EGL display, surface, context and config. |
|
1635 */ |
|
1636 EGLDisplay iEglDisplay; |
|
1637 EGLSurface iEglWindowSurface; |
|
1638 EGLContext iEglWindowSurfaceContext; |
|
1639 EGLConfig iEglConfig; |
|
1640 |
|
1641 /** |
|
1642 * Handles to the EGL pbuffer surface, context and texture in case of |
|
1643 * OpenGL based scaling |
|
1644 */ |
|
1645 EGLSurface iEglPbufferSurface; |
|
1646 EGLContext iEglPbufferSurfaceContext; |
|
1647 GLuint iPbufferTexture; |
|
1648 |
|
1649 /** |
|
1650 * These rects define the framebuffer areas that |
|
1651 * need to be blitted to EGL surface as OpenGL texture. |
|
1652 * Canvas is devided vertically into 2 parts, but it is |
|
1653 * a common case that iUpperUpdateRect covers the full canvas |
|
1654 * (E.g. if fillRect() is used in MIDlet for full canvas area). |
|
1655 * Updated by UpdateRects(). |
|
1656 */ |
|
1657 TRect iUpperUpdateRect; |
|
1658 TRect iLowerUpdateRect; |
|
1659 |
|
1660 /** |
|
1661 * Pointer to converted pixel data that is given to |
|
1662 * OpenGL when creating the frame buffer texture. |
|
1663 * Added the member variable because this is needed continuosly. |
|
1664 * Own. |
|
1665 */ |
|
1666 TUint8* iTexturePixels; |
|
1667 |
|
1668 /** |
|
1669 * OpenGL coordinate arrays used fo r rendering filled rectangles |
|
1670 */ |
|
1671 GLshort* iVertexArray; |
|
1672 GLubyte* iTriangleStrip; |
|
1673 |
|
1674 #endif // RD_JAVA_NGA_ENABLED |
|
1675 |
|
1676 /** |
|
1677 * If dragging was started (by pointer down) inside the canvas, |
|
1678 * all drag events and release event should go to canvas |
|
1679 * even if it is outside of canvas. |
|
1680 * All events, which started outside the canvas have to be ignored. |
|
1681 */ |
|
1682 TBool iDragEventsStartedInside; |
|
1683 }; |
|
1684 |
|
1685 #ifdef RD_JAVA_NGA_ENABLED |
|
1686 // ------------------------------------ |
|
1687 // Converts pixels from ARGB to RGBA |
|
1688 // ------------------------------------ |
|
1689 // |
|
1690 inline void CMIDCanvas::ConvertPixels( |
|
1691 const TUint32* aSrc, TUint8* aDst, TInt aPixelCount) |
|
1692 { |
|
1693 while (aPixelCount--) |
|
1694 { |
|
1695 TUint argb = *aSrc++; |
|
1696 *aDst++ = (argb >> 16) & 0xFFu; |
|
1697 *aDst++ = (argb >> 8) & 0xFFu; |
|
1698 *aDst++ = argb & 0xFFu; |
|
1699 *aDst++ = (argb >> 24) & 0xFFu; |
|
1700 } |
|
1701 } |
|
1702 #endif // RD_JAVA_NGA_ENABLED |
|
1703 |
|
1704 #endif // CMIDCANVAS_H |