157 // Check if downscaling in use. |
167 // Check if downscaling in use. |
158 // @param aSourceSize Source rect size. |
168 // @param aSourceSize Source rect size. |
159 // @param aDestRect Destination rect. |
169 // @param aDestRect Destination rect. |
160 // --------------------------------------------------------------------------- |
170 // --------------------------------------------------------------------------- |
161 // |
171 // |
162 inline TBool IsDownScaling(const TSize& aSourceSize, const TRect& aDestRect, TBool aM3GContent) |
172 TBool CMIDCanvas::IsDownScaling(const TSize& aSourceSize, const TRect& aDestRect,TBool aM3GContent) const |
163 { |
173 { |
164 // if m3G is drawing then downscaling is turn off |
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; |
165 if (aM3GContent) |
181 if (aM3GContent) |
166 { |
182 { |
167 return EFalse; |
183 return EFalse; |
168 } |
184 } |
169 return (aSourceSize.iWidth > aDestRect.Width() || |
185 return (aSourceSize.iWidth > aDestRect.Width() || |
174 // IsDownScaling |
190 // IsDownScaling |
175 // Check if downscaling in use. |
191 // Check if downscaling in use. |
176 // @param aSourceSize Source rect size. |
192 // @param aSourceSize Source rect size. |
177 // @param aDestRect Destination rect. |
193 // @param aDestRect Destination rect. |
178 // --------------------------------------------------------------------------- |
194 // --------------------------------------------------------------------------- |
179 inline TBool IsDownScaling(const TSize& aSourceSize, const TRect& aDestRect) |
195 TBool CMIDCanvas::IsDownScaling(const TSize& aSourceSize, const TRect& aDestRect) const |
180 { |
196 { |
181 return (aSourceSize.iWidth > aDestRect.Width() || |
197 return (aSourceSize.iWidth > aDestRect.Width() || |
182 aSourceSize.iHeight > aDestRect.Height()); |
198 aSourceSize.iHeight > aDestRect.Height()); |
183 } |
199 } |
184 |
200 |
302 delete iPointerEventSuppressor; |
318 delete iPointerEventSuppressor; |
303 iPointerEventSuppressor = NULL; |
319 iPointerEventSuppressor = NULL; |
304 } |
320 } |
305 |
321 |
306 #ifdef RD_JAVA_NGA_ENABLED |
322 #ifdef RD_JAVA_NGA_ENABLED |
307 CloseEgl(); |
323 CloseEgl(EFalse); |
308 DisposePixelSource(); |
324 DisposePixelSource(); |
309 delete[] iTexturePixels; |
325 delete[] iTexturePixels; |
310 delete[] iVertexArray; |
326 delete[] iVertexArray; |
311 delete[] iTriangleStrip; |
327 delete[] iTriangleStrip; |
312 #endif // RD_JAVA_NGA_ENABLED |
328 #endif // RD_JAVA_NGA_ENABLED |
830 const TMIDBufferOp*& aRead, |
846 const TMIDBufferOp*& aRead, |
831 const TMIDBufferOp* aEnd, |
847 const TMIDBufferOp* aEnd, |
832 TInt& /* aCycles */, |
848 TInt& /* aCycles */, |
833 java::util::Monitor* aMonitor) |
849 java::util::Monitor* aMonitor) |
834 { |
850 { |
835 if (!iForeground) |
851 |
836 { |
852 if (!iForeground && iFirstPaintState == EFirstPaintNeverOccurred) |
837 DEBUG("CMIDCanvas::ProcessL() - not foreground"); |
853 { |
838 ASSERT(!iAlfMonitor); |
854 ASSERT(!iAlfMonitor); |
839 aRead = aEnd; |
855 aRead = aEnd; |
840 return EFalse; |
856 return EFalse; |
841 } |
857 } |
842 |
858 |
843 switch (aRead->OpCode()) |
859 switch (aRead->OpCode()) |
844 { |
860 { |
845 case EDrwOpcM3GContentStart: |
861 case EDrwOpcM3GContentStart: |
846 { |
862 { |
|
863 // EGL surface is created if canvas window is currently visible |
|
864 // even if MIDlet would be on background. |
847 if (!iM3GContent && |
865 if (!iM3GContent && |
848 i3DAccelerated && |
866 i3DAccelerated && |
849 iDirectContents.Count() == 0) |
867 iDirectContents.Count() == 0 && |
|
868 IsWindowVisible()) |
850 { |
869 { |
851 DEBUG("CMIDCanvas::ProcessL - M3G content start"); |
870 DEBUG("CMIDCanvas::ProcessL - M3G content start"); |
852 iM3GContent = ETrue; |
871 iM3GContent = ETrue; |
853 iM3GStart = ETrue; |
872 iM3GStart = ETrue; |
854 PostEvent(EM3GDraw, iM3GContent, 0); |
873 PostEvent(EM3GDraw, iM3GContent, 0); |
909 iAlfMonitor = aMonitor; |
928 iAlfMonitor = aMonitor; |
910 } |
929 } |
911 return iFrameReady; |
930 return iFrameReady; |
912 } |
931 } |
913 |
932 |
914 #else // RD_JAVA_NGA_ENABLED |
933 #else // RD_JAVA_NGA_ENABLED |
915 |
934 |
916 // --------------------------------------------------------------------------- |
935 // --------------------------------------------------------------------------- |
917 // From class MMIDBufferProcessor. |
936 // From class MMIDBufferProcessor. |
918 // CMIDCanvas::ProcessL |
937 // CMIDCanvas::ProcessL |
919 // Process a block of commands, updating read pointer as you go. |
938 // Process a block of commands, updating read pointer as you go. |
1088 TInt sizePacked = (size.iWidth << 16) | (size.iHeight); |
1107 TInt sizePacked = (size.iWidth << 16) | (size.iHeight); |
1089 |
1108 |
1090 PostEvent(EPaint, posPacked, sizePacked); |
1109 PostEvent(EPaint, posPacked, sizePacked); |
1091 } |
1110 } |
1092 |
1111 |
1093 // If is added first direct content, then NGA is switched off |
1112 if (iDirectContents.Count() > 0) |
1094 // and move of iViewRect is needed. |
1113 { |
1095 if (iFullScreen && iScalingOn && iDirectContents.Count() == 1) |
1114 iEnv.ToLcduiObserver().InvokeLcduiEvent(*this, EVideoAdded); |
1096 { |
|
1097 iViewRect.Move(-iPositionRelativeToScreen); |
|
1098 } |
1115 } |
1099 #endif // RD_JAVA_NGA_ENABLED |
1116 #endif // RD_JAVA_NGA_ENABLED |
1100 } |
1117 } |
1101 |
1118 |
1102 |
1119 |
1282 // because it may be called in MMAPI thread. |
1291 // because it may be called in MMAPI thread. |
1283 // --------------------------------------------------------------------------- |
1292 // --------------------------------------------------------------------------- |
1284 // |
1293 // |
1285 void CMIDCanvas::MdcNotifyContentAdded() |
1294 void CMIDCanvas::MdcNotifyContentAdded() |
1286 { |
1295 { |
1287 DisposePixelSource(); |
1296 // no implementation |
1288 CloseEgl(); |
|
1289 } |
1297 } |
1290 #endif // RD_JAVA_NGA_ENABLED |
1298 #endif // RD_JAVA_NGA_ENABLED |
1291 |
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 } |
1292 |
1345 |
1293 // --------------------------------------------------------------------------- |
1346 // --------------------------------------------------------------------------- |
1294 // From class MMIDMediaKeysListener. |
1347 // From class MMIDMediaKeysListener. |
1295 // CMIDCanvas::HandleMediaKeyEvent |
1348 // CMIDCanvas::HandleMediaKeyEvent |
1296 // This method is called when a media key has been pressed. |
1349 // This method is called when a media key has been pressed. |
1397 |
1450 |
1398 if (iCustomComponents.Find(aComponent) == KErrNotFound) |
1451 if (iCustomComponents.Find(aComponent) == KErrNotFound) |
1399 { |
1452 { |
1400 DEBUG("CMIDCanvas::RegisterComponentL, registering new"); |
1453 DEBUG("CMIDCanvas::RegisterComponentL, registering new"); |
1401 |
1454 |
1402 iCustomComponents.Append(aComponent); |
1455 iCustomComponents.AppendL(aComponent); |
1403 |
1456 |
1404 // Update custom components count in order to improve |
1457 // Update custom components count in order to improve |
1405 // the performance when counting components |
1458 // the performance when counting components |
1406 iCustomComponentsControlCount += |
1459 iCustomComponentsControlCount += |
1407 aComponent->CustomComponentControlCount(); |
1460 aComponent->CustomComponentControlCount(); |
1521 } |
1574 } |
1522 |
1575 |
1523 // Remove the old index from the components array. |
1576 // Remove the old index from the components array. |
1524 iCustomComponents.Remove(index); |
1577 iCustomComponents.Remove(index); |
1525 |
1578 |
1526 // Add the component to the new index. Note that the array |
1579 iCustomComponents.InsertL(aComponent, aNewIndex); |
1527 // should contain memory for all the components since |
|
1528 // Remove should not decrease the memory used by the array |
|
1529 // Therefore, the following operation is leave-safe and |
|
1530 // return value is ignored intentionally. |
|
1531 iCustomComponents.Insert(aComponent, aNewIndex); |
|
1532 |
1580 |
1533 // Redraw the whole canvas. |
1581 // Redraw the whole canvas. |
1534 DrawDeferred(); |
1582 DrawDeferred(); |
1535 } |
1583 } |
1536 |
1584 |
1575 // Update screen from frame buffer. |
1623 // Update screen from frame buffer. |
1576 // --------------------------------------------------------------------------- |
1624 // --------------------------------------------------------------------------- |
1577 // |
1625 // |
1578 void CMIDCanvas::UpdateL(const TRect& aRect) |
1626 void CMIDCanvas::UpdateL(const TRect& aRect) |
1579 { |
1627 { |
|
1628 if (!IsWindowVisible()) |
|
1629 { |
|
1630 return; |
|
1631 } |
|
1632 |
|
1633 // Don't update screen after canvas size has been changed, |
|
1634 // if there is no valid content from Java side yet |
|
1635 if (iWndUpdate && |
|
1636 (iContentSize.iWidth > aRect.Size().iWidth || |
|
1637 iContentSize.iHeight > aRect.Size().iHeight)) |
|
1638 { |
|
1639 return; |
|
1640 } |
|
1641 |
|
1642 iWndUpdate = EFalse; |
|
1643 |
1580 // Drawing Network indicator only when Update is called. |
1644 // Drawing Network indicator only when Update is called. |
1581 if (iFullScreen && iNetworkIndicator) |
1645 if (iFullScreen && iNetworkIndicator) |
1582 { |
1646 { |
1583 iNetworkIndicator->SetDrawIndicator(ETrue); |
1647 iNetworkIndicator->SetDrawIndicator(ETrue); |
1584 } |
1648 } |
1585 |
1649 |
1586 // iRestoreContentWhenUnfaded is used when Canvas should be faded |
1650 if (iDirectContents.Count() == 0) |
1587 // DrawNow need to be called, otherwise Canvas will be unfaded |
|
1588 if (iDirectContents.Count() == 0 && !iRestoreContentWhenUnfaded && IsFocused()) |
|
1589 { |
1651 { |
1590 // In case direct content content was removed |
1652 // In case direct content content was removed |
1591 // from canvas, recreate pixel source here |
1653 // from canvas, recreate pixel source here |
1592 if (!iAlfCompositionPixelSource && !IsEglAvailable()) |
1654 if (!iAlfCompositionPixelSource && |
|
1655 !IsEglAvailable()) |
1593 { |
1656 { |
1594 InitPixelSourceL(); |
1657 InitPixelSourceL(); |
1595 } |
1658 } |
1596 DrawWindowNgaL(aRect); |
1659 DrawWindowNgaL(aRect); |
1597 } |
1660 } |
1777 ActivatePixelSourceL(EFalse); |
1833 ActivatePixelSourceL(EFalse); |
1778 DEBUG("CMIDCanvas::Draw - Pixel Source activated"); |
1834 DEBUG("CMIDCanvas::Draw - Pixel Source activated"); |
1779 } |
1835 } |
1780 else // M3G content, use EGL surface |
1836 else // M3G content, use EGL surface |
1781 { |
1837 { |
1782 // Invalidates window so that wserv does not |
|
1783 // draw window content on top our EGL surface. |
|
1784 // This is needed only once when starting to use EGL surface. |
|
1785 if (iM3GStart) |
|
1786 { |
|
1787 DEBUG("CMIDCanvas::DrawWindow - invalidate"); |
|
1788 Window().Invalidate(); |
|
1789 iM3GStart = EFalse; |
|
1790 } |
|
1791 |
|
1792 if (iScalingOn && iFullScreen) |
1838 if (iScalingOn && iFullScreen) |
1793 { |
1839 { |
1794 SetCurrentEglType(EEglPbuffer); |
1840 SetCurrentEglType(EEglPbuffer); |
1795 BlitFrameBufferPixels(); |
1841 BlitFrameBufferPixels(); |
1796 SetCurrentEglType(EEglWindow); |
1842 SetCurrentEglType(EEglWindow); |
1812 ELOG1(EJavaUI, "eglSwapBuffers() failed, eglError=%d", eglGetError()); |
1858 ELOG1(EJavaUI, "eglSwapBuffers() failed, eglError=%d", eglGetError()); |
1813 ASSERT(EFalse); |
1859 ASSERT(EFalse); |
1814 } |
1860 } |
1815 |
1861 |
1816 SetCurrentEglType(EEglNone); |
1862 SetCurrentEglType(EEglNone); |
|
1863 |
|
1864 // Invalidates window so that wserv does not |
|
1865 // draw window content on top our EGL surface. |
|
1866 // This is needed only once when starting to use EGL surface. |
|
1867 if (iM3GStart) |
|
1868 { |
|
1869 DEBUG("CMIDCanvas::DrawWindow - invalidate"); |
|
1870 Window().Invalidate(); |
|
1871 iM3GStart = EFalse; |
|
1872 } |
1817 |
1873 |
1818 if (iFirstPaintState != EFirstPaintOccurred) |
1874 if (iFirstPaintState != EFirstPaintOccurred) |
1819 { |
1875 { |
1820 iFirstPaintState = EFirstPaintOccurred; |
1876 iFirstPaintState = EFirstPaintOccurred; |
1821 java::ui::CoreUiAvkonLcdui::getInstance().getJavaUiAppUi()->stopStartScreen(); |
1877 java::ui::CoreUiAvkonLcdui::getInstance().getJavaUiAppUi()->stopStartScreen(); |
2120 // is open or closed. This is needed only when partial VKB changes |
2176 // is open or closed. This is needed only when partial VKB changes |
2121 // its state. |
2177 // its state. |
2122 TBool partialVKBOpen = (aType == KAknSplitInputEnabled); |
2178 TBool partialVKBOpen = (aType == KAknSplitInputEnabled); |
2123 if (partialVKBOpen != iPartialVKBOpen) |
2179 if (partialVKBOpen != iPartialVKBOpen) |
2124 { |
2180 { |
|
2181 // setting member variable |
2125 iPartialVKBOpen = partialVKBOpen; |
2182 iPartialVKBOpen = partialVKBOpen; |
|
2183 |
|
2184 // First we need inform focused item, after other. |
|
2185 iCustomComponents[iFocusedComponent]->HandleResourceChange(aType); |
2126 for (int i = 0; i < iCustomComponents.Count(); i++) |
2186 for (int i = 0; i < iCustomComponents.Count(); i++) |
2127 { |
2187 { |
2128 iCustomComponents[i]->HandleResourceChange(aType); |
2188 if (i != iFocusedComponent) |
|
2189 { |
|
2190 iCustomComponents[i]->HandleResourceChange(aType); |
|
2191 } |
2129 } |
2192 } |
2130 } |
2193 } |
2131 } |
2194 } |
2132 else if (aType == KEikInputLanguageChange) |
2195 else if (aType == KEikInputLanguageChange) |
2133 #else |
2196 #else |
2134 if (aType == KEikInputLanguageChange) |
2197 if (aType == KEikInputLanguageChange) |
2135 #endif // RD_JAVA_S60_RELEASE_9_2 |
2198 #endif // RD_JAVA_S60_RELEASE_9_2 |
2136 { |
2199 { |
2137 // We need inform TextEditor that input language is changed. |
2200 // We need inform TextEditor that input language is changed. |
2138 if ((iFocusedComponent != KComponentFocusedNone) && |
2201 if ((iFocusedComponent != KComponentFocusedNone) && |
2139 (iFocusedComponent < iCustomComponents.Count())) |
2202 (iFocusedComponent < iCustomComponents.Count())) |
2140 { |
2203 { |
2141 iCustomComponents[iFocusedComponent]-> |
2204 iCustomComponents[iFocusedComponent]-> |
2142 CustomComponentControl(KComponentMainControl)-> |
2205 CustomComponentControl(KComponentMainControl)-> |
2143 HandleResourceChange(aType); |
2206 HandleResourceChange(aType); |
2144 } |
2207 } |
2318 // |
2381 // |
2319 // iViewRect.iTl -> (0, 0) |
2382 // iViewRect.iTl -> (0, 0) |
2320 // iViewRect.iBr - TSize(1, 1) -> (iContentSize.iWidth - 1, |
2383 // iViewRect.iBr - TSize(1, 1) -> (iContentSize.iWidth - 1, |
2321 // iContentSize.iHeight - 1) |
2384 // iContentSize.iHeight - 1) |
2322 point -= iViewRect.iTl; |
2385 point -= iViewRect.iTl; |
2323 |
|
2324 #ifdef RD_JAVA_NGA_ENABLED |
|
2325 // If NGA is started and scaling is on then the drawing rectangle |
|
2326 // is moved. Them we need move pointer events too. |
|
2327 if (iFullScreen && iScalingOn && iDirectContents.Count() == 0) |
|
2328 { |
|
2329 // Fix coordinates |
|
2330 point += iPositionRelativeToScreen; |
|
2331 } |
|
2332 #endif // RD_JAVA_NGA_ENABLED |
|
2333 |
2386 |
2334 if (javaMaxCoords != nativeMaxCoords) |
2387 if (javaMaxCoords != nativeMaxCoords) |
2335 { |
2388 { |
2336 point.iX = (point.iX * javaMaxCoords.iWidth) / |
2389 point.iX = (point.iX * javaMaxCoords.iWidth) / |
2337 nativeMaxCoords.iWidth; |
2390 nativeMaxCoords.iWidth; |
2475 SetFocus(ETrue); |
2528 SetFocus(ETrue); |
2476 } |
2529 } |
2477 |
2530 |
2478 #ifdef RD_JAVA_NGA_ENABLED |
2531 #ifdef RD_JAVA_NGA_ENABLED |
2479 // To avoid situation when Canvas is redrawn but black area remains |
2532 // To avoid situation when Canvas is redrawn but black area remains |
2480 if (iAlfCompositionPixelSource) |
2533 if (iAlfCompositionPixelSource && iDirectContents.Count() == 0) |
2481 { |
2534 { |
2482 TRAPD(err, ActivatePixelSourceL(EFalse)); |
2535 TRAPD(err, ActivatePixelSourceL(EFalse)); |
2483 if (err != KErrNone) |
2536 if (err != KErrNone) |
2484 { |
2537 { |
2485 DEBUG_INT("CMIDCanvas::FocusChanged - ActivatePixelSourceL error %d", err); |
2538 DEBUG_INT("CMIDCanvas::FocusChanged - ActivatePixelSourceL error %d", err); |
2510 } |
2563 } |
2511 } |
2564 } |
2512 |
2565 |
2513 // To remove cursor on focused control. |
2566 // To remove cursor on focused control. |
2514 if ((iFocusedComponent != KComponentFocusedNone) && |
2567 if ((iFocusedComponent != KComponentFocusedNone) && |
2515 (iFocusedComponent < iCustomComponents.Count()) && |
2568 (iFocusedComponent < iCustomComponents.Count()) && |
2516 iCustomComponents[iFocusedComponent]-> |
2569 iCustomComponents[iFocusedComponent]-> |
2517 CustomComponentControl(KComponentMainControl)->IsVisible()) |
2570 CustomComponentControl(KComponentMainControl)->IsVisible()) |
2518 { |
2571 { |
2519 iCustomComponents[iFocusedComponent]-> |
2572 iCustomComponents[iFocusedComponent]-> |
2520 CustomComponentControl(KComponentMainControl)-> |
2573 CustomComponentControl(KComponentMainControl)-> |
2521 SetFocus(EFalse); |
2574 SetFocus(EFalse); |
2522 } |
2575 } |
2523 |
2576 |
2524 #ifdef RD_JAVA_NGA_ENABLED |
|
2525 // Avoid the situation when the content is drawn over the menu |
|
2526 SuspendPixelSource(); |
|
2527 #endif // RD_JAVA_NGA_ENABLED |
|
2528 |
|
2529 // Repaint to ensure that fading will be displayed correctly for Alert |
2577 // Repaint to ensure that fading will be displayed correctly for Alert |
2530 // or PopupTextBox when DSA is paused. |
2578 // or PopupTextBox when DSA is paused. No redraw, if canvas is using |
2531 DrawDeferred(); |
2579 // background surfaces i.e. EGL or pixel source |
|
2580 if (iDirectContents.Count() > 0) |
|
2581 { |
|
2582 DrawDeferred(); |
|
2583 } |
2532 } |
2584 } |
2533 |
2585 |
2534 DEBUG("- CMIDCanvas::FocusChanged"); |
2586 DEBUG("- CMIDCanvas::FocusChanged"); |
2535 } |
2587 } |
2536 |
2588 |
2577 contentSize = controlSize; |
2629 contentSize = controlSize; |
2578 } |
2630 } |
2579 |
2631 |
2580 if ((contentSize != iContentSize) || iScalingOn) |
2632 if ((contentSize != iContentSize) || iScalingOn) |
2581 { |
2633 { |
|
2634 #ifdef RD_JAVA_NGA_ENABLED |
|
2635 TSize oldContentSize = iContentSize; |
2582 iContentSize = contentSize; |
2636 iContentSize = contentSize; |
2583 |
2637 |
2584 #ifdef RD_JAVA_NGA_ENABLED |
2638 TBool landscape = Layout_Meta_Data::IsLandscapeOrientation(); |
2585 HandleSizeChanged(); |
2639 |
|
2640 if (IsWindowVisible() && |
|
2641 (oldContentSize.iWidth < iContentSize.iWidth || |
|
2642 oldContentSize.iHeight < iContentSize.iHeight || |
|
2643 landscape != iLandscape)) |
|
2644 { |
|
2645 iWndUpdate = ETrue; |
|
2646 if (IsEglAvailable()) |
|
2647 { |
|
2648 // Clear with black to avoid incorrectly sized |
|
2649 // surface flashing on screen in orientation switch |
|
2650 TRgb color(KOpaqueBlackColor); |
|
2651 ClearEglSurface(EEglWindow, &color); |
|
2652 } |
|
2653 } |
|
2654 |
|
2655 HandleSizeChanged(landscape != iLandscape); |
|
2656 iLandscape = landscape; |
|
2657 |
|
2658 PostEvent(ESizeChanged, iContentSize.iWidth, iContentSize.iHeight); |
|
2659 |
|
2660 if (IsWindowVisible() && iWndUpdate) |
|
2661 { |
|
2662 // Post forced paint to enable Canvas repaint behind |
|
2663 // Alert or Pop-up TextBox |
|
2664 PostForcedPaint(); |
|
2665 } |
|
2666 #else |
|
2667 iContentSize = contentSize; |
|
2668 PostEvent(ESizeChanged, iContentSize.iWidth, iContentSize.iHeight); |
2586 #endif // RD_JAVA_NGA_ENABLED |
2669 #endif // RD_JAVA_NGA_ENABLED |
2587 PostEvent(ESizeChanged, iContentSize.iWidth, iContentSize.iHeight); |
|
2588 } |
2670 } |
2589 |
2671 |
2590 #ifdef CANVAS_DIRECT_ACCESS |
2672 #ifdef CANVAS_DIRECT_ACCESS |
2591 // Stop direct screen access to avoid restarting |
2673 // Stop direct screen access to avoid restarting |
2592 // of direct content DSA during MdcContentBoundsChanged. |
2674 // of direct content DSA during MdcContentBoundsChanged. |
2629 // Drawing. |
2711 // Drawing. |
2630 // --------------------------------------------------------------------------- |
2712 // --------------------------------------------------------------------------- |
2631 // |
2713 // |
2632 void CMIDCanvas::Draw(const TRect& aRect) const |
2714 void CMIDCanvas::Draw(const TRect& aRect) const |
2633 { |
2715 { |
2634 if (!iStartUpTraceDone) |
|
2635 { |
|
2636 java::util::JavaOsLayer::startUpTrace("MIDP: CMIDCanvas::Draw starts", -1, -1); |
|
2637 } |
|
2638 DEBUG("CMIDCanvas::Draw ++"); |
2716 DEBUG("CMIDCanvas::Draw ++"); |
2639 |
2717 |
2640 // While changing the orientation method DrawWindow() not called, |
2718 if (iWndUpdate) |
2641 // variable iWndUpdate is set to True. If iWndUpdate is True |
2719 { |
2642 // DrawWindow() is called from method Update() |
2720 return; |
2643 // This is needed to avoid artifacting after orientation switch. |
2721 } |
2644 TBool landscape = Layout_Meta_Data::IsLandscapeOrientation(); |
2722 |
2645 |
2723 if (iDirectContents.Count() > 0) |
2646 if (iLandscape != landscape && !iAlfCompositionPixelSource) |
2724 { |
2647 { |
2725 DrawWindow(aRect); |
2648 iLandscape = landscape; |
|
2649 iWndUpdate = ETrue; |
|
2650 } |
2726 } |
2651 else |
2727 else |
2652 { |
2728 { |
2653 // iRestoreContentWhenUnfaded is used when Canvas should be faded |
2729 CMIDCanvas* myself = const_cast<CMIDCanvas*>(this); |
2654 // DrawWindow need to be called, otherwise Canvas will be unfaded |
2730 |
2655 // Sometimes iRestoreContentWhenUnfaded is not set yet and Canvas |
2731 if (IsEglAvailable()) |
2656 // already lost focus, then IsFocused is used |
2732 { |
2657 if (iDirectContents.Count() > 0 || iRestoreContentWhenUnfaded || !IsFocused()) |
2733 myself->ClearUiSurface(ETrue); |
2658 { |
2734 } |
|
2735 else if (iAlfCompositionPixelSource) |
|
2736 { |
|
2737 myself->ClearUiSurface(ETrue); |
|
2738 TRAP_IGNORE(myself->ActivatePixelSourceL(ETrue)); |
|
2739 } |
|
2740 else |
|
2741 { |
|
2742 // This is the case when M3G midlet is |
|
2743 // coming back to foreground and EGL |
|
2744 // surface is not re-created yet |
2659 DrawWindow(aRect); |
2745 DrawWindow(aRect); |
2660 } |
2746 } |
2661 else |
2747 } |
2662 { |
2748 |
2663 CMIDCanvas* myself = const_cast<CMIDCanvas*>(this); |
|
2664 myself->ClearUiSurface(ETrue); |
|
2665 if (iAlfCompositionPixelSource) |
|
2666 { |
|
2667 TRAP_IGNORE(myself->ActivatePixelSourceL(ETrue)); |
|
2668 } |
|
2669 } |
|
2670 iWndUpdate = EFalse; |
|
2671 } |
|
2672 |
|
2673 if (!iStartUpTraceDone) |
|
2674 { |
|
2675 java::util::JavaOsLayer::startUpTrace("MIDP: CMIDCanvas::Draw ends", -1, -1); |
|
2676 iStartUpTraceDone = ETrue; |
|
2677 } |
|
2678 DEBUG("CMIDCanvas::Draw --"); |
2749 DEBUG("CMIDCanvas::Draw --"); |
2679 } |
2750 } |
2680 #else // !RD_JAVA_NGA_ENABLED |
2751 #else // !RD_JAVA_NGA_ENABLED |
2681 |
2752 |
2682 // --------------------------------------------------------------------------- |
2753 // --------------------------------------------------------------------------- |
2685 // Drawing. |
2756 // Drawing. |
2686 // --------------------------------------------------------------------------- |
2757 // --------------------------------------------------------------------------- |
2687 // |
2758 // |
2688 void CMIDCanvas::Draw(const TRect& aRect) const |
2759 void CMIDCanvas::Draw(const TRect& aRect) const |
2689 { |
2760 { |
2690 if (!iStartUpTraceDone) |
|
2691 { |
|
2692 java::util::JavaOsLayer::startUpTrace("MIDP: CMIDCanvas::Draw starts", -1, -1); |
|
2693 } |
|
2694 DEBUG("+ CMIDCanvas::Draw"); |
2761 DEBUG("+ CMIDCanvas::Draw"); |
2695 |
2762 |
2696 #ifdef CANVAS_DOUBLE_BUFFER |
2763 #ifdef CANVAS_DOUBLE_BUFFER |
2697 ASSERT(iFrameBuffer); |
2764 ASSERT(iFrameBuffer); |
2698 #endif // CANVAS_DOUBLE_BUFFER |
2765 #endif // CANVAS_DOUBLE_BUFFER |
2742 iWndUpdate = EFalse; |
2809 iWndUpdate = EFalse; |
2743 } |
2810 } |
2744 #endif // CANVAS_DOUBLE_BUFFER |
2811 #endif // CANVAS_DOUBLE_BUFFER |
2745 #endif // CANVAS_ASYNC_PAINT |
2812 #endif // CANVAS_ASYNC_PAINT |
2746 |
2813 |
2747 if (!iStartUpTraceDone) |
|
2748 { |
|
2749 java::util::JavaOsLayer::startUpTrace("MIDP: CMIDCanvas::Draw ends", -1, -1); |
|
2750 iStartUpTraceDone = ETrue; |
|
2751 } |
|
2752 DEBUG("- CMIDCanvas::Draw"); |
2814 DEBUG("- CMIDCanvas::Draw"); |
2753 } |
2815 } |
2754 #endif // RD_JAVA_NGA_ENABLED |
2816 #endif // RD_JAVA_NGA_ENABLED |
2755 |
2817 |
2756 // --------------------------------------------------------------------------- |
2818 // --------------------------------------------------------------------------- |
2978 #endif // CANVAS_DIRECT_ACCESS |
3040 #endif // CANVAS_DIRECT_ACCESS |
2979 |
3041 |
2980 iDisplayable = (CMIDDisplayable*) &aWindow; |
3042 iDisplayable = (CMIDDisplayable*) &aWindow; |
2981 CCoeControl::SetContainerWindowL(aWindow); |
3043 CCoeControl::SetContainerWindowL(aWindow); |
2982 Window().SetBackgroundColor(); |
3044 Window().SetBackgroundColor(); |
|
3045 MakeVisible(aWindow.IsVisible()); |
2983 |
3046 |
2984 #ifdef RD_SCALABLE_UI_V2 |
3047 #ifdef RD_SCALABLE_UI_V2 |
2985 Window().SetPointerGrab(ETrue); |
3048 Window().SetPointerGrab(ETrue); |
2986 #endif // RD_SCALABLE_UI_V2 |
3049 #endif // RD_SCALABLE_UI_V2 |
2987 |
3050 |
3186 TSize size(rect.Size()); |
3249 TSize size(rect.Size()); |
3187 TSize viewSize; |
3250 TSize viewSize; |
3188 |
3251 |
3189 if (iFullScreen) |
3252 if (iFullScreen) |
3190 { |
3253 { |
3191 #ifdef RD_JAVA_NGA_ENABLED |
|
3192 // If both NGA and scaling are on, then iViewRect is needed move |
|
3193 // for preverifing wrong position of Canvas. |
|
3194 if (iScalingOn && (!iFullScreen || iDirectContents.Count() == 0)) |
|
3195 { |
|
3196 // Translate to screen coordinates. |
|
3197 rect.Move(iPositionRelativeToScreen); |
|
3198 } |
|
3199 #endif // RD_JAVA_NGA_ENABLED |
|
3200 |
|
3201 if (iNetworkIndicator) |
3254 if (iNetworkIndicator) |
3202 { |
3255 { |
3203 // Refresh the layout data for network indicator. |
3256 // Refresh the layout data for network indicator. |
3204 iNetworkIndicator->GetLayoutData(); |
3257 iNetworkIndicator->GetLayoutData(); |
3205 } |
3258 } |
3206 |
3259 |
3207 // Get original MIDlet size which eventually reflects display |
3260 // Get original MIDlet size which eventually reflects display |
3208 // orientation. |
3261 // orientation. |
3209 TSize orientedOrgMIDletScrSize(OrientedOrgMIDletScrSize()); |
3262 TSize orientedOrgMIDletScrSize(OrientedOrgMIDletScrSize()); |
3210 |
|
3211 // If Nokia-MIDlet-Target-Display-Size is defined, Canvas will be |
|
3212 // scaled to that size. |
|
3213 if (iTargetMIDletScrSize != KZeroSize) |
|
3214 { |
|
3215 viewSize = iTargetMIDletScrSize; |
|
3216 } |
|
3217 |
3263 |
3218 #ifdef RD_JAVA_S60_RELEASE_9_2 |
3264 #ifdef RD_JAVA_S60_RELEASE_9_2 |
3219 // If partial VKB is open then MIDlet is not scaled. |
3265 // If partial VKB is open then MIDlet is not scaled. |
3220 // That we need set iViewRect to whole size of Canvas. |
3266 // That we need set iViewRect to whole size of Canvas. |
3221 if (iPartialVKBOpen) |
3267 if (iPartialVKBOpen) |
3222 { |
3268 { |
3223 viewSize = Size(); |
3269 viewSize = Size(); |
3224 } |
3270 } |
3225 #endif //RD_JAVA_S60_RELEASE_9_2 |
3271 else if (iTargetMIDletScrSize != KZeroSize) |
3226 |
3272 #else |
|
3273 if (iTargetMIDletScrSize != KZeroSize) |
|
3274 #endif //RD_JAVA_S60_RELEASE_9_2 |
|
3275 { |
|
3276 // If Nokia-MIDlet-Target-Display-Size is defined, Canvas will be |
|
3277 // scaled to that size. |
|
3278 viewSize = iTargetMIDletScrSize; |
|
3279 } |
3227 // If optional JAD parameter Nokia-MIDlet-Target-Display-Size is NOT |
3280 // If optional JAD parameter Nokia-MIDlet-Target-Display-Size is NOT |
3228 // defined and Nokia-MIDlet-Original-Display-Size is defined to |
3281 // defined and Nokia-MIDlet-Original-Display-Size is defined to |
3229 // smaller size than the device's screen size, we will scale the |
3282 // smaller size than the device's screen size, we will scale the |
3230 // Canvas to fit the screen without changing aspect ratio. |
3283 // Canvas to fit the screen without changing aspect ratio. |
3231 // If the aspect ratio of Nokia-MIDlet-Original-Display-Size is not |
3284 // If the aspect ratio of Nokia-MIDlet-Original-Display-Size is not |
3320 iViewRect = TRect(viewPos, viewSize); |
3373 iViewRect = TRect(viewPos, viewSize); |
3321 |
3374 |
3322 #ifdef CANVAS_DIRECT_ACCESS |
3375 #ifdef CANVAS_DIRECT_ACCESS |
3323 StartDirectAccess(); |
3376 StartDirectAccess(); |
3324 #endif // CANVAS_DIRECT_ACCESS |
3377 #endif // CANVAS_DIRECT_ACCESS |
3325 #ifdef RD_JAVA_NGA_ENABLED |
|
3326 // To avoid situation when Orientation was changed and black screen is shown |
|
3327 TRAPD(err, UpdateL(iViewRect)); |
|
3328 if (err != KErrNone) |
|
3329 { |
|
3330 DEBUG_INT("CMIDCanvas::Layout - update error %d", err); |
|
3331 } |
|
3332 #endif // RD_JAVA_NGA_ENABLED |
|
3333 |
3378 |
3334 TInt contentsCount(iDirectContents.Count()); |
3379 TInt contentsCount(iDirectContents.Count()); |
3335 |
3380 |
3336 for (TInt j = 0; j < contentsCount; j++) |
3381 for (TInt j = 0; j < contentsCount; j++) |
3337 { |
3382 { |
3563 // |
3608 // |
3564 void CMIDCanvas::HandleForeground(TBool aForeground) |
3609 void CMIDCanvas::HandleForeground(TBool aForeground) |
3565 { |
3610 { |
3566 DEBUG_INT("CMIDCanvas::HandleForeground(%d) ++", aForeground); |
3611 DEBUG_INT("CMIDCanvas::HandleForeground(%d) ++", aForeground); |
3567 |
3612 |
|
3613 // If foreground/background state is changed, |
|
3614 // then we need resize all custom components. |
|
3615 if (iForeground != aForeground && iCustomComponents.Count() > 0) |
|
3616 { |
|
3617 for (int i = 0; i < iCustomComponents.Count(); i++) |
|
3618 { |
|
3619 iCustomComponents[i]->HandleForeground(aForeground); |
|
3620 } |
|
3621 } |
|
3622 |
3568 iForeground = aForeground; |
3623 iForeground = aForeground; |
3569 |
3624 |
3570 #ifdef RD_JAVA_NGA_ENABLED |
3625 #ifdef RD_JAVA_NGA_ENABLED |
3571 if (!iForeground) |
3626 if (!aForeground) |
3572 { |
3627 { |
3573 if (IsEglAvailable()) |
3628 FreeGraphicsMemory(EFalse); |
3574 { |
3629 } |
3575 if (iEglOccupied) |
3630 #endif // RD_JAVA_NGA_ENABLED |
|
3631 |
|
3632 DEBUG("CMIDCanvas::HandleForeground --"); |
|
3633 } |
|
3634 |
|
3635 #ifdef RD_JAVA_NGA_ENABLED |
|
3636 // --------------------------------------------------------------------------- |
|
3637 // CMIDCanvas::HandleFullOrPartialForegroundL |
|
3638 // --------------------------------------------------------------------------- |
|
3639 // |
|
3640 void CMIDCanvas::HandleFullOrPartialForegroundL( |
|
3641 TBool aFullOrPartialFg, TBool aCurrentDisplayable) |
|
3642 { |
|
3643 if (!aFullOrPartialFg && aCurrentDisplayable) |
|
3644 { |
|
3645 FreeGraphicsMemory(ETrue); |
|
3646 } |
|
3647 else if (!iPrevM3GContent && iAlfCompositionPixelSource) |
|
3648 { |
|
3649 SuspendPixelSource(); |
|
3650 ActivatePixelSourceL(ETrue); |
|
3651 } |
|
3652 } |
|
3653 |
|
3654 // --------------------------------------------------------------------------- |
|
3655 // CMIDCanvas::FreeGraphicsMemory |
|
3656 // Free GPU memory if the canvas is not visible anymore. If aForced is true, |
|
3657 // visibility is not checked. |
|
3658 // --------------------------------------------------------------------------- |
|
3659 // |
|
3660 void CMIDCanvas::FreeGraphicsMemory(TBool aForced) |
|
3661 { |
|
3662 // No freeing in exit case to avoid flickering |
|
3663 if ((!aForced && IsWindowVisible()) || iExiting) |
|
3664 { |
|
3665 return; |
|
3666 } |
|
3667 |
|
3668 if (IsEglAvailable()) |
|
3669 { |
|
3670 if (iEglOccupied) |
|
3671 { |
|
3672 DEBUG("CMIDCanvas::FreeGraphcisMemory() - egl - pending dispose"); |
|
3673 iEglPendingDispose = ETrue; |
|
3674 } |
|
3675 else |
|
3676 { |
|
3677 CloseEgl(ETrue); |
|
3678 // If MIDlet is not visible on foreground post event to Java |
|
3679 // so that M3G is notfied and frees the m3gCore memory |
|
3680 if (!iEnv.HasFullOrPartialForeground()) |
3576 { |
3681 { |
3577 DEBUG("CMIDCanvas::HandleForeground() - egl - pending dispose"); |
3682 iEnv.PostMidletEvent(EFreeGraphicsMemory); |
3578 iEglPendingDispose = ETrue; |
3683 eglReleaseThread(); |
3579 } |
3684 } |
3580 else |
3685 } |
3581 { |
3686 } |
3582 CloseEgl(); |
3687 |
3583 } |
3688 SuspendPixelSource(); |
3584 } |
3689 } |
3585 |
|
3586 SuspendPixelSource(); |
|
3587 } |
|
3588 #endif // RD_JAVA_NGA_ENABLED |
|
3589 |
|
3590 DEBUG("CMIDCanvas::HandleForeground --"); |
|
3591 } |
|
3592 |
|
3593 #ifdef RD_JAVA_NGA_ENABLED |
|
3594 |
3690 |
3595 // --------------------------------------------------------------------------- |
3691 // --------------------------------------------------------------------------- |
3596 // CMIDCanvas::InitPixelSourceL() |
3692 // CMIDCanvas::InitPixelSourceL() |
3597 // --------------------------------------------------------------------------- |
3693 // --------------------------------------------------------------------------- |
3598 // |
3694 // |
3666 if (iDirectContents.Count() > 0) |
3762 if (iDirectContents.Count() > 0) |
3667 { |
3763 { |
3668 return; |
3764 return; |
3669 } |
3765 } |
3670 |
3766 |
3671 // ProduceNewFrameL() is called in some cases |
3767 // Don't activate, if there is no valid content from Java yet |
3672 // directly from ActivateSyncL(), need to set iFrameReady |
3768 if (!ReadyToBlit()) |
|
3769 { |
|
3770 return; |
|
3771 } |
|
3772 |
|
3773 // ProduceNewFrameL() is called directly from ActivateSyncL() |
|
3774 // if pixel source is suspended, need to set iFrameReady |
3673 // before ActivateSyncL() |
3775 // before ActivateSyncL() |
3674 iFrameReady = ETrue; |
3776 iFrameReady = ETrue; |
3675 TRAPD(err, iAlfCompositionPixelSource->ActivateSyncL()); |
3777 TRAPD(err, iAlfCompositionPixelSource->ActivateSyncL()); |
3676 if (err != KErrNone) |
3778 if (err != KErrNone) |
3677 { |
3779 { |
3679 User::Leave(err); |
3781 User::Leave(err); |
3680 } |
3782 } |
3681 |
3783 |
3682 if (iPixelSourceSuspended) |
3784 if (iPixelSourceSuspended) |
3683 { |
3785 { |
3684 ClearUiSurface(aDrawingOngoing); |
|
3685 iPixelSourceSuspended = EFalse; |
3786 iPixelSourceSuspended = EFalse; |
3686 if (iFullScreen && iScalingOn) |
3787 if (iFullScreen && iScalingOn) |
3687 { |
3788 { |
3688 iAlfCompositionPixelSource->SetExtent(iViewRect, KPhoneScreen); |
3789 TRect targetRect = iViewRect; |
|
3790 targetRect.Move(iPositionRelativeToScreen); |
|
3791 iAlfCompositionPixelSource->SetExtent(targetRect, KPhoneScreen); |
|
3792 // Flag is set to in order that screen gets updated at least once |
|
3793 // after SetExtent() call |
|
3794 iFrameReady = ETrue; |
|
3795 } |
|
3796 |
|
3797 if (!aDrawingOngoing) |
|
3798 { |
|
3799 ClearUiSurface(aDrawingOngoing); |
|
3800 iCoeEnv->WsSession().Finish(); |
3689 } |
3801 } |
3690 } |
3802 } |
3691 } |
3803 } |
3692 |
3804 |
3693 // --------------------------------------------------------------------------- |
3805 // --------------------------------------------------------------------------- |
3703 } |
3815 } |
3704 CWindowGc& gc = SystemGc(); |
3816 CWindowGc& gc = SystemGc(); |
3705 gc.SetBrushColor(KTransparentClearColor); |
3817 gc.SetBrushColor(KTransparentClearColor); |
3706 gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); |
3818 gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); |
3707 gc.Clear(); |
3819 gc.Clear(); |
|
3820 |
|
3821 // Clearing is done via EGL in scaled M3G case |
|
3822 if (iScalingOn && iFullScreen && !IsEglAvailable()) |
|
3823 { |
|
3824 const TRect rect = Rect(); |
|
3825 if (rect != iViewRect) |
|
3826 { |
|
3827 gc.SetBrushColor(KRgbBlack); |
|
3828 gc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
3829 DrawUtils::ClearBetweenRects(gc, rect, iViewRect); |
|
3830 } |
|
3831 } |
|
3832 |
3708 if (!aDrawing) |
3833 if (!aDrawing) |
3709 { |
3834 { |
3710 DeactivateGc(); |
3835 DeactivateGc(); |
3711 Window().EndRedraw(); |
3836 Window().EndRedraw(); |
3712 } |
3837 } |
|
3838 } |
|
3839 |
|
3840 // --------------------------------------------------------------------------- |
|
3841 // CMIDCanvas::DrawToWindowGc |
|
3842 // Draws current frame buffer content to CWindowGc |
|
3843 // --------------------------------------------------------------------------- |
|
3844 // |
|
3845 void CMIDCanvas::DrawToWindowGc() |
|
3846 { |
|
3847 if (iDirectContents.Count() > 0 || |
|
3848 !IsWindowVisible() || |
|
3849 !iForeground) |
|
3850 { |
|
3851 return; |
|
3852 } |
|
3853 |
|
3854 Window().BeginRedraw(); |
|
3855 ActivateGc(); |
|
3856 |
|
3857 TRect rect = (iFullScreen && iScalingOn) ? iViewRect : Rect(); |
|
3858 DrawWindow(rect); |
|
3859 |
|
3860 DeactivateGc(); |
|
3861 Window().EndRedraw(); |
|
3862 |
3713 iCoeEnv->WsSession().Finish(); |
3863 iCoeEnv->WsSession().Finish(); |
3714 } |
3864 } |
3715 |
3865 |
|
3866 // --------------------------------------------------------------------------- |
3716 // CMIDCanvas::SuspendPixelSource |
3867 // CMIDCanvas::SuspendPixelSource |
3717 // --------------------------------------------------------------------------- |
3868 // --------------------------------------------------------------------------- |
3718 // |
3869 // |
3719 void CMIDCanvas::SuspendPixelSource() |
3870 void CMIDCanvas::SuspendPixelSource() |
3720 { |
3871 { |
3974 // --------------------------------------------------------------------------- |
4125 // --------------------------------------------------------------------------- |
3975 // CMIDCanvas::CloseEgl |
4126 // CMIDCanvas::CloseEgl |
3976 // Destroys EGL contexts and surfaces. |
4127 // Destroys EGL contexts and surfaces. |
3977 // --------------------------------------------------------------------------- |
4128 // --------------------------------------------------------------------------- |
3978 // |
4129 // |
3979 void CMIDCanvas::CloseEgl() |
4130 void CMIDCanvas::CloseEgl(TBool aReadback) |
3980 { |
4131 { |
3981 DEBUG("CMIDCanvas::CloseEglL() ++"); |
4132 DEBUG("CMIDCanvas::CloseEglL() ++"); |
3982 |
4133 |
3983 iM3GContent = EFalse; |
4134 iM3GContent = EFalse; |
3984 iM3GStart = EFalse; |
4135 iM3GStart = EFalse; |
3990 return; |
4141 return; |
3991 } |
4142 } |
3992 |
4143 |
3993 // MIDlet might draw only 2D after this => |
4144 // MIDlet might draw only 2D after this => |
3994 // need to set frame buffer opaque to be compatible with |
4145 // need to set frame buffer opaque to be compatible with |
3995 // blending methods in Lcdgd. UpdateOffScreenBitmapL() does this |
4146 // blending methods in Lcdgd. UpdateOffScreenBitmapL() does this too. |
3996 // for GameCanvas. |
4147 if (!aReadback && iFrameContext) |
3997 if (!IsGameCanvas() && iFrameContext) |
|
3998 { |
4148 { |
3999 iFrameContext->SetBrushColor(KOpaqueClearColor); |
4149 iFrameContext->SetBrushColor(KOpaqueClearColor); |
4000 iFrameContext->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); |
4150 iFrameContext->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); |
4001 iFrameContext->Clear(); |
4151 iFrameContext->Clear(); |
4002 } |
4152 } |
4003 |
4153 |
4004 // Take a snapshot from window surface to the frame buffer. |
4154 // Take a snapshot from window surface to the frame buffer. |
4005 TRAPD(err, UpdateOffScreenBitmapL(EFalse)); |
4155 if (aReadback) |
4006 if (err != KErrNone) |
4156 { |
4007 { |
4157 TRAPD(err, UpdateOffScreenBitmapL(ETrue)); |
4008 DEBUG("CMIDCanvas::CloseEgl() - UpdateOffScreenBitmapL() failed"); |
4158 if (err != KErrNone) |
|
4159 { |
|
4160 DEBUG("CMIDCanvas::CloseEgl() - UpdateOffScreenBitmapL() failed"); |
|
4161 } |
4009 } |
4162 } |
4010 |
4163 |
4011 // make sure the we have no current target |
4164 // make sure the we have no current target |
4012 // so that surfaces and contexts are destoyed immediately |
4165 // so that surfaces and contexts are destoyed immediately |
4013 SetCurrentEglType(EEglNone); |
4166 SetCurrentEglType(EEglNone); |
4137 // recreate the surface. If recreation is needed (and M3G is not using our |
4290 // recreate the surface. If recreation is needed (and M3G is not using our |
4138 // surface) EGL context and surface are destoryed here and recreated in |
4291 // surface) EGL context and surface are destoryed here and recreated in |
4139 // next ProcessL() when M3G_CONTENT_START is recieved from Java side. |
4292 // next ProcessL() when M3G_CONTENT_START is recieved from Java side. |
4140 // --------------------------------------------------------------------------- |
4293 // --------------------------------------------------------------------------- |
4141 // |
4294 // |
4142 void CMIDCanvas::HandleSizeChanged() |
4295 void CMIDCanvas::HandleSizeChanged(TBool aOrientationChange) |
4143 { |
4296 { |
4144 DEBUG("CMIDCanvas::HandleSizeChanged ++"); |
4297 DEBUG("CMIDCanvas::HandleSizeChanged ++"); |
4145 |
4298 |
4146 SuspendPixelSource(); |
4299 SuspendPixelSource(); |
4147 |
4300 |
4148 if (IsEglAvailable()) |
4301 if (IsEglAvailable()) |
4149 { |
4302 { |
4150 TSize surfaceSize = GetEglSurfaceSize(iEglWindowSurface); |
4303 TSize surfaceSize = GetEglSurfaceSize(iEglWindowSurface); |
4151 TSize controlSize = Size(); |
4304 TSize controlSize = Size(); |
4152 if (surfaceSize.iHeight < controlSize.iHeight || |
4305 if (aOrientationChange || |
|
4306 surfaceSize.iHeight < controlSize.iHeight || |
4153 surfaceSize.iWidth < controlSize.iWidth) |
4307 surfaceSize.iWidth < controlSize.iWidth) |
4154 { |
4308 { |
4155 // Check if egl surface is currently occupied. |
4309 // Check if egl surface is currently occupied. |
4156 if (iEglOccupied) |
4310 if (iEglOccupied) |
4157 { |
4311 { |
4158 // Delayed resizing. It is done when the ReleaseEglSurface method |
4312 // Delayed resizing. It is done when the ReleaseEglSurface method |
4159 // is called. |
4313 // is called. |
4160 DEBUG("CMIDCanvas::HandleSizeChanged - egl - resize pending"); |
|
4161 iEglPendingResize = ETrue; |
4314 iEglPendingResize = ETrue; |
4162 } |
4315 } |
4163 else |
4316 else |
4164 { |
4317 { |
4165 DEBUG("CMIDCanvas::SizeChanged - close egl"); |
|
4166 // Surface recreation is done in next ProcessL() call |
4318 // Surface recreation is done in next ProcessL() call |
4167 CloseEgl(); |
4319 // No readback from EGL, because canvas needs to |
|
4320 // repaint itself anyway in new size |
|
4321 CloseEgl(EFalse); |
4168 } |
4322 } |
4169 } |
4323 } |
4170 } |
4324 } |
4171 DEBUG("CMIDCanvas::HandleSizeChanged --"); |
4325 DEBUG("CMIDCanvas::HandleSizeChanged --"); |
4172 } |
4326 } |
4209 // From MMIDComponentNgaExtension |
4363 // From MMIDComponentNgaExtension |
4210 // CMIDCanvas::IsEglAvailable |
4364 // CMIDCanvas::IsEglAvailable |
4211 // Return ETrue, if EGL based drawing is in use. |
4365 // Return ETrue, if EGL based drawing is in use. |
4212 // --------------------------------------------------------------------------- |
4366 // --------------------------------------------------------------------------- |
4213 // |
4367 // |
4214 TBool CMIDCanvas::IsEglAvailable() |
4368 TBool CMIDCanvas::IsEglAvailable() const |
4215 { |
4369 { |
4216 return (iEglWindowSurface != EGL_NO_SURFACE); |
4370 return (iEglWindowSurface != EGL_NO_SURFACE); |
4217 } |
4371 } |
4218 |
4372 |
4219 // --------------------------------------------------------------------------- |
4373 // --------------------------------------------------------------------------- |
4251 { |
4405 { |
4252 // Pending dispose. Egl context must be released. |
4406 // Pending dispose. Egl context must be released. |
4253 if (iEglPendingDispose) |
4407 if (iEglPendingDispose) |
4254 { |
4408 { |
4255 DEBUG("CMIDCanvas::ReleaseEglSurface() - dispose egl"); |
4409 DEBUG("CMIDCanvas::ReleaseEglSurface() - dispose egl"); |
4256 CloseEgl(); |
4410 FreeGraphicsMemory(ETrue); |
4257 } |
4411 } |
4258 else if (iEglPendingResize) |
4412 else if (iEglPendingResize) |
4259 { |
4413 { |
4260 DEBUG("CMIDCanvas::ReleaseEglSurface() - pending resize"); |
4414 DEBUG("CMIDCanvas::ReleaseEglSurface() - pending resize"); |
4261 HandleSizeChanged(); |
4415 HandleSizeChanged(ETrue); |
4262 } |
4416 } |
4263 ClearFrameBuffer(); |
4417 |
|
4418 if (IsEglAvailable()) |
|
4419 { |
|
4420 ClearFrameBuffer(); |
|
4421 } |
4264 } |
4422 } |
4265 } |
4423 } |
4266 |
4424 |
4267 // --------------------------------------------------------------------------- |
4425 // --------------------------------------------------------------------------- |
4268 // From MMIDComponentNgaExtension |
4426 // From MMIDComponentNgaExtension |
4441 |
4599 |
4442 TRect rect(aRect); |
4600 TRect rect(aRect); |
4443 TRect canvasRect = IsDownScaling(iContentSize, iViewRect, iM3GContent) ? |
4601 TRect canvasRect = IsDownScaling(iContentSize, iViewRect, iM3GContent) ? |
4444 TRect(iViewRect.Size()) : TRect(iContentSize); |
4602 TRect(iViewRect.Size()) : TRect(iContentSize); |
4445 rect.Intersection(canvasRect); |
4603 rect.Intersection(canvasRect); |
|
4604 // Checking if rect have intersection with frameRect |
|
4605 TRect frameRect(TPoint(), iFrameBuffer->SizeInPixels()); |
|
4606 if (!rect.Intersects(frameRect)) |
|
4607 { |
|
4608 return; |
|
4609 } |
|
4610 rect.Intersection(frameRect); |
|
4611 if (rect.IsEmpty()) |
|
4612 { |
|
4613 return; |
|
4614 } |
4446 |
4615 |
4447 // Update the member rects |
4616 // Update the member rects |
4448 if (iUpperUpdateRect.Intersects(rect)) |
4617 if (iUpperUpdateRect.Intersects(rect)) |
4449 { |
4618 { |
4450 iUpperUpdateRect.BoundingRect(rect); |
4619 iUpperUpdateRect.BoundingRect(rect); |
4475 else |
4644 else |
4476 { |
4645 { |
4477 iUpperUpdateRect.BoundingRect(rect); |
4646 iUpperUpdateRect.BoundingRect(rect); |
4478 } |
4647 } |
4479 } |
4648 } |
|
4649 } |
|
4650 |
|
4651 // --------------------------------------------------------------------------- |
|
4652 // From MMIDCanvas |
|
4653 // CMIDCanvas::MidletExiting |
|
4654 // Draws content to CWindowGc to enable the system effect on MIDlet exit. |
|
4655 // Canvas might be in the middle of rendering new frame when this is called. |
|
4656 // Having incomplete frame on screen in some exit cases is anyway better than |
|
4657 // fully black always. |
|
4658 // --------------------------------------------------------------------------- |
|
4659 // |
|
4660 void CMIDCanvas::MidletExiting() |
|
4661 { |
|
4662 iExiting = ETrue; |
|
4663 TRAP_IGNORE(UpdateOffScreenBitmapL(ETrue)); |
|
4664 DrawToWindowGc(); |
4480 } |
4665 } |
4481 |
4666 |
4482 // --------------------------------------------------------------------------- |
4667 // --------------------------------------------------------------------------- |
4483 // CMIDCanvas::BlitFrameBufferPixels |
4668 // CMIDCanvas::BlitFrameBufferPixels |
4484 // Sets up OpenGL state for 2D texture rendering and renders the textures for |
4669 // Sets up OpenGL state for 2D texture rendering and renders the textures for |
4612 // then rectangle is moved right and upwards. |
4797 // then rectangle is moved right and upwards. |
4613 // OpenGL y-coordinate increases upwards. |
4798 // OpenGL y-coordinate increases upwards. |
4614 TInt srcOffset = (canvasHeight - (yStart + ySize)) * stride + |
4799 TInt srcOffset = (canvasHeight - (yStart + ySize)) * stride + |
4615 xStart * KBytesPerPixel; |
4800 xStart * KBytesPerPixel; |
4616 |
4801 |
4617 BlitSubRectTexture(xStart, yStart, xSize, ySize, stride, |
4802 if ((xSize > 0) && (xSize <= 256) && (ySize > 0) && (ySize <= 256)) |
4618 (TUint8*)iFrameBuffer->DataAddress() + srcOffset); |
4803 { |
|
4804 BlitSubRectTexture(xStart, yStart, xSize, ySize, stride, |
|
4805 (TUint8*)iFrameBuffer->DataAddress() + srcOffset); |
|
4806 } |
4619 } |
4807 } |
4620 } |
4808 } |
4621 } |
4809 } |
4622 |
4810 |
4623 |
4811 |
4676 // Raise out-of-memory if OpenGL ran out of resources |
4864 // Raise out-of-memory if OpenGL ran out of resources |
4677 GLint err = glGetError(); |
4865 GLint err = glGetError(); |
4678 if (err == GL_OUT_OF_MEMORY) |
4866 if (err == GL_OUT_OF_MEMORY) |
4679 { |
4867 { |
4680 glDeleteTextures(KTexturesCount, tempTexObj); |
4868 glDeleteTextures(KTexturesCount, tempTexObj); |
4681 DEBUG("CMIDCanvas::BlitSubRectTexture(): Out of memory when creating OpenGL texture"); |
4869 ELOG(EJavaUI, "CMIDCanvas::BlitSubRectTexture(): Out of memory when creating OpenGL texture"); |
4682 return; |
4870 return; |
4683 } |
4871 } |
4684 else if (err != GL_NO_ERROR) |
4872 else if (err != GL_NO_ERROR) |
4685 { |
4873 { |
4686 ELOG1(EJavaUI, "CMIDCanvas::BlitSubRectTexture(): GL error after glTexImage2D(): %d", err); |
4874 ELOG1(EJavaUI, "CMIDCanvas::BlitSubRectTexture(): GL error after glTexImage2D(): %d", err); |
4711 if (tileWidth > aWidth || |
4899 if (tileWidth > aWidth || |
4712 tileHeight > aHeight) |
4900 tileHeight > aHeight) |
4713 { |
4901 { |
4714 // Clear the pixel data with transparent for case where |
4902 // Clear the pixel data with transparent for case where |
4715 // actual texture data does not cover the full tile. |
4903 // actual texture data does not cover the full tile. |
4716 // This should be actually done with glClear(). |
|
4717 Mem::FillZ(dst, tileWidth * tileHeight * KBytesPerPixel); |
4904 Mem::FillZ(dst, tileWidth * tileHeight * KBytesPerPixel); |
4718 dst += tileWidth * (tileHeight - aHeight) * KBytesPerPixel; |
4905 dst += tileWidth * (tileHeight - aHeight) * KBytesPerPixel; |
4719 } |
4906 } |
4720 |
4907 |
4721 while (h-- > 0) |
4908 while (h-- > 0) |
4959 glEnableClientState(GL_VERTEX_ARRAY); |
5146 glEnableClientState(GL_VERTEX_ARRAY); |
4960 glMatrixMode(GL_TEXTURE); |
5147 glMatrixMode(GL_TEXTURE); |
4961 glLoadIdentity(); |
5148 glLoadIdentity(); |
4962 |
5149 |
4963 // position texture screen coordinates |
5150 // position texture screen coordinates |
4964 pos[0] = (GLshort)iViewRect.iTl.iX - iPositionRelativeToScreen.iX; |
5151 pos[0] = (GLshort)iViewRect.iTl.iX; |
4965 pos[1] = (GLshort)iViewRect.Height() + (height - iViewRect.iBr.iY); |
5152 pos[1] = (GLshort)iViewRect.Height() + (height - iViewRect.iBr.iY); |
4966 pos[2] = pos[0]; |
5153 pos[2] = pos[0]; |
4967 pos[3] = (GLshort)height - iViewRect.iBr.iY; |
5154 pos[3] = (GLshort)height - iViewRect.iBr.iY; |
4968 pos[4] = (GLshort)iViewRect.iBr.iX - iPositionRelativeToScreen.iX; |
5155 pos[4] = (GLshort)iViewRect.iBr.iX; |
4969 pos[5] = pos[1]; |
5156 pos[5] = pos[1]; |
4970 pos[6] = pos[4]; |
5157 pos[6] = pos[4]; |
4971 pos[7] = pos[3]; |
5158 pos[7] = pos[3]; |
4972 |
5159 |
4973 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); |
5160 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); |
5075 return KEglBadNativeWindow; |
5262 return KEglBadNativeWindow; |
5076 } |
5263 } |
5077 return KEglSuccess; |
5264 return KEglSuccess; |
5078 } |
5265 } |
5079 |
5266 |
|
5267 // --------------------------------------------------------------------------- |
|
5268 // CMIDCanvas::IsWindowVisible |
|
5269 // Checks if canvas window is currently visible on display. Canvas may be visible |
|
5270 // e.g. behind task switcher or system dialogs even though MIDlet is not the |
|
5271 // foreground application in that case. This function relies on |
|
5272 // CMIDDisplayble setting canvas window invisible when some other full-screen |
|
5273 // displayble is set as current. |
|
5274 // --------------------------------------------------------------------------- |
|
5275 // |
|
5276 TBool CMIDCanvas::IsWindowVisible() const |
|
5277 { |
|
5278 return iEnv.HasFullOrPartialForeground() && IsVisible(); |
|
5279 } |
|
5280 |
|
5281 // --------------------------------------------------------------------------- |
|
5282 // CMIDCanvas::PostForcedPaint |
|
5283 // Send forced paint to Java. Canvas.paint() will be called even if canvas is |
|
5284 // not the current displayable. |
|
5285 // --------------------------------------------------------------------------- |
|
5286 // |
|
5287 void CMIDCanvas::PostForcedPaint() |
|
5288 { |
|
5289 TInt posPacked = 0; |
|
5290 TInt sizePacked = (iContentSize.iWidth << 16) | (iContentSize.iHeight); |
|
5291 PostEvent(EForcedPaint, posPacked, sizePacked); |
|
5292 } |
5080 #endif // RD_JAVA_NGA_ENABLED |
5293 #endif // RD_JAVA_NGA_ENABLED |
5081 // End of File. |
5294 // End of File. |