854 ASSERT(!iAlfMonitor); |
854 ASSERT(!iAlfMonitor); |
855 aRead = aEnd; |
855 aRead = aEnd; |
856 return EFalse; |
856 return EFalse; |
857 } |
857 } |
858 |
858 |
859 // Usually only one op code is processed by Canvas. |
859 switch (aRead->OpCode()) |
860 // Exception is the video overlay case, where MIDlet |
860 { |
861 // does not draw anything inside Canvas.paint(). |
861 case EDrwOpcM3GContentStart: |
862 // In this case EDrwOpcPaintStarted and EDrwOpcBitBltRect/EDrwOpcBitBlt |
862 { |
863 // are received in one ProcessL(). Also EDrwOpcPaintStarted and EDrwOpcM3GContentStart |
863 // EGL surface is created if canvas window is currently visible |
864 // may be processed in one ProcessL(), if overlays are enabled. |
864 // even if MIDlet would be on background. |
865 while (aRead < aEnd) |
865 if (!iM3GContent && |
866 { |
866 i3DAccelerated && |
867 switch (aRead->OpCode()) |
867 iDirectContents.Count() == 0 && |
868 { |
868 IsWindowVisible()) |
869 case EDrwOpcM3GContentStart: |
869 { |
870 { |
870 DEBUG("CMIDCanvas::ProcessL - M3G content start"); |
871 // EGL surface is created if canvas window is currently visible |
871 iM3GContent = ETrue; |
872 // even if MIDlet would be on background. |
872 iM3GStart = ETrue; |
873 if (!iM3GContent && |
873 PostEvent(EM3GDraw, iM3GContent, 0); |
874 i3DAccelerated && |
874 // First time when M3G content is drawn => |
875 iDirectContents.Count() == 0 && |
875 // switch to EGL surface drawing. |
876 IsWindowVisible()) |
876 // Pixel source must be disposed first. |
|
877 DisposePixelSource(); |
|
878 OpenEglL(); |
|
879 |
|
880 // if we are scaling with m3g and HW acceleration |
|
881 // create a pbuffer surface to be used with m3g rendering |
|
882 if (iScalingOn && iFullScreen) |
877 { |
883 { |
878 DEBUG("CMIDCanvas::ProcessL - M3G content start"); |
884 CreatePBufferSurfaceL(); |
879 iM3GContent = ETrue; |
|
880 iM3GStart = ETrue; |
|
881 PostEvent(EM3GDraw, iM3GContent, 0); |
|
882 // First time when M3G content is drawn => |
|
883 // switch to EGL surface drawing. |
|
884 // Pixel source must be disposed first. |
|
885 DisposePixelSource(); |
|
886 OpenEglL(); |
|
887 |
|
888 // if we are scaling with m3g and HW acceleration |
|
889 // create a pbuffer surface to be used with m3g rendering |
|
890 if (iScalingOn && iFullScreen) |
|
891 { |
|
892 CreatePBufferSurfaceL(); |
|
893 } |
|
894 // Draw the whole framebuffer content (as a texture) on top of |
|
895 // the EGL window surface. |
|
896 iUpperUpdateRect = TRect(Size()); |
|
897 UpdateEglContent(); |
|
898 } |
885 } |
899 |
886 // Draw the whole framebuffer content (as a texture) on top of |
900 ASSERT(aRead + aRead->Size() == aEnd); |
887 // the EGL window surface. |
901 } |
888 iUpperUpdateRect = TRect(Size()); |
|
889 UpdateEglContent(); |
|
890 } |
|
891 } |
|
892 break; |
|
893 case EDrwOpcBitBltRect: |
|
894 { |
|
895 if (iFirstPaintState == EFirstPaintNeverOccurred) |
|
896 { |
|
897 iFirstPaintState = EFirstPaintInitiated; |
|
898 } |
|
899 |
|
900 const TBitBltData& data = BitBltData(aRead); |
|
901 UpdateL(data.iRect); |
|
902 } |
|
903 break; |
|
904 case EDrwOpcBitBlt: |
|
905 { |
|
906 if (iFirstPaintState == EFirstPaintNeverOccurred) |
|
907 { |
|
908 iFirstPaintState = EFirstPaintInitiated; |
|
909 } |
|
910 |
|
911 UpdateL(iViewRect); |
|
912 } |
|
913 break; |
|
914 default: |
|
915 User::Leave(KErrNotSupported); |
902 break; |
916 break; |
903 case EDrwOpcBitBltRect: |
917 } |
904 { |
918 |
905 if (iFirstPaintState == EFirstPaintNeverOccurred) |
919 aRead += aRead->Size(); |
906 { |
|
907 iFirstPaintState = EFirstPaintInitiated; |
|
908 } |
|
909 |
|
910 const TBitBltData& data = BitBltData(aRead); |
|
911 UpdateL(data.iRect); |
|
912 |
|
913 ASSERT(aRead + aRead->Size() == aEnd); |
|
914 } |
|
915 break; |
|
916 case EDrwOpcBitBlt: |
|
917 { |
|
918 if (iFirstPaintState == EFirstPaintNeverOccurred) |
|
919 { |
|
920 iFirstPaintState = EFirstPaintInitiated; |
|
921 } |
|
922 |
|
923 UpdateL(iViewRect); |
|
924 |
|
925 ASSERT(aRead + aRead->Size() == aEnd); |
|
926 } |
|
927 break; |
|
928 case EDrwOpcPaintStarted: |
|
929 { |
|
930 // Clear MMAPI content areas on Canvas to enable overlays. |
|
931 if (IsVideoOverlayActive()) |
|
932 { |
|
933 RRegion directContents; |
|
934 iDisplayable->GetDirectContentsRegion(directContents); |
|
935 TInt count = directContents.Count(); |
|
936 |
|
937 iFrameContext->SetBrushColor(KTransparentClearColor); |
|
938 iFrameContext->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); |
|
939 |
|
940 for (TInt i = 0; i < count; ++i) |
|
941 { |
|
942 const TRect rect = directContents[i]; |
|
943 iFrameContext->Clear(rect); |
|
944 } |
|
945 directContents.Close(); |
|
946 } |
|
947 } |
|
948 break; |
|
949 default: |
|
950 User::Leave(KErrNotSupported); |
|
951 break; |
|
952 } |
|
953 |
|
954 aRead += aRead->Size(); |
|
955 } |
|
956 |
|
957 ASSERT(aRead == aEnd); |
920 ASSERT(aRead == aEnd); |
958 |
921 |
959 // iFrameReady tells if this is async operation. |
922 // iFrameReady tells if this is async operation. |
960 // In async case CMIDBuffer waits until canvas |
923 // In async case CMIDBuffer waits until canvas |
961 // gets callback from Alf. |
924 // gets callback from Alf. |
1195 // From class MDirectContainer. |
1158 // From class MDirectContainer. |
1196 // CMIDCanvas::MdcRemoveContentBounds |
1159 // CMIDCanvas::MdcRemoveContentBounds |
1197 // Removes a rectangle to be excluded from redrawing. |
1160 // Removes a rectangle to be excluded from redrawing. |
1198 // --------------------------------------------------------------------------- |
1161 // --------------------------------------------------------------------------- |
1199 // |
1162 // |
1200 void CMIDCanvas::MdcRemoveMMAPIContentBounds(const TRect& aRect) |
1163 void CMIDCanvas::MdcRemoveContentBounds(const TRect& aRect) |
1201 { |
1164 { |
1202 if (iDisplayable) |
1165 if (iDisplayable) |
1203 { |
1166 { |
1204 #ifdef RD_JAVA_NGA_ENABLED |
|
1205 if (iEnv.VideoOverlayEnabled()) |
|
1206 { |
|
1207 // iMMAPIAreaUpdated may be modified in LCDUI and MMAPI threads. |
|
1208 // Lock must be released before RemoveDirectContentArea(). |
|
1209 RCriticalSection& lock(iEnv.GetMMAPILock()); |
|
1210 lock.Wait(); |
|
1211 iMMAPIAreaUpdated = ETrue; |
|
1212 lock.Signal(); |
|
1213 |
|
1214 iDisplayable->RemoveDirectContentArea(aRect); |
|
1215 } |
|
1216 else |
|
1217 { |
|
1218 iDisplayable->RemoveDirectContentArea(aRect); |
|
1219 } |
|
1220 #else |
|
1221 iDisplayable->RemoveDirectContentArea(aRect); |
1167 iDisplayable->RemoveDirectContentArea(aRect); |
1222 #endif // RD_JAVA_NGA_ENABLED |
|
1223 } |
1168 } |
1224 } |
1169 } |
1225 |
1170 |
1226 |
1171 |
1227 // --------------------------------------------------------------------------- |
1172 // --------------------------------------------------------------------------- |
1955 if (iFrameBuffer->DisplayMode() == EColor16MA) |
1905 if (iFrameBuffer->DisplayMode() == EColor16MA) |
1956 { |
1906 { |
1957 gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); |
1907 gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); |
1958 } |
1908 } |
1959 |
1909 |
1960 #ifdef RD_JAVA_NGA_ENABLED |
|
1961 // If overlay is enabled, need to clear previous content |
|
1962 // from CWindowGc. |
|
1963 CMIDCanvas* myself = const_cast<CMIDCanvas*>(this); |
|
1964 if (myself->IsVideoOverlayActive()) |
|
1965 { |
|
1966 gc.SetBrushColor(KTransparentClearColor); |
|
1967 gc.Clear(aRect); |
|
1968 } |
|
1969 #endif |
|
1970 |
|
1971 TRect windowRect(aRect); |
1910 TRect windowRect(aRect); |
1972 PrepareDraw(gc, windowRect); |
1911 PrepareDraw(gc, windowRect); |
1973 |
1912 |
1974 // Check if Canvas scaling is used. |
1913 // Check if Canvas scaling is used. |
1975 if (iViewRect.Size() == iContentSize) |
1914 if (iViewRect.Size() == iContentSize) |
2723 |
2659 |
2724 HandleSizeChanged(landscape != iLandscape); |
2660 HandleSizeChanged(landscape != iLandscape); |
2725 iLandscape = landscape; |
2661 iLandscape = landscape; |
2726 |
2662 |
2727 PostEvent(ESizeChanged, iContentSize.iWidth, iContentSize.iHeight); |
2663 PostEvent(ESizeChanged, iContentSize.iWidth, iContentSize.iHeight); |
|
2664 |
2728 if (IsWindowVisible() && iWndUpdate) |
2665 if (IsWindowVisible() && iWndUpdate) |
2729 { |
2666 { |
2730 // Post forced paint to enable Canvas repaint behind |
2667 // Post forced paint to enable Canvas repaint behind |
2731 // Alert or Pop-up TextBox |
2668 // Alert or Pop-up TextBox |
2732 PostForcedPaint(); |
2669 PostForcedPaint(); |
2733 } |
2670 } |
2734 |
|
2735 #else |
2671 #else |
2736 iContentSize = contentSize; |
2672 iContentSize = contentSize; |
2737 PostEvent(ESizeChanged, iContentSize.iWidth, iContentSize.iHeight); |
2673 PostEvent(ESizeChanged, iContentSize.iWidth, iContentSize.iHeight); |
2738 #endif // RD_JAVA_NGA_ENABLED |
2674 #endif // RD_JAVA_NGA_ENABLED |
2739 } |
2675 } |
2906 TBool /*aUpdateRequired*/ |
2834 TBool /*aUpdateRequired*/ |
2907 #else |
2835 #else |
2908 TBool aUpdateRequired |
2836 TBool aUpdateRequired |
2909 #endif // CANVAS_DIRECT_ACCESS |
2837 #endif // CANVAS_DIRECT_ACCESS |
2910 ) : |
2838 ) : |
2911 CCoeControl() |
2839 CCoeControl() |
2912 ,iEnv(aEnv) |
2840 ,iEnv(aEnv) |
2913 #ifdef CANVAS_DOUBLE_BUFFER |
2841 #ifdef CANVAS_DOUBLE_BUFFER |
2914 ,iFrameBuffer(NULL) |
2842 ,iFrameBuffer(NULL) |
2915 #endif // CANVAS_DOUBLE_BUFFER |
2843 #endif // CANVAS_DOUBLE_BUFFER |
2916 ,iIsGameCanvas(( |
2844 ,iIsGameCanvas(( |
2917 aComponentType == MMIDComponent::EGameCanvas ? ETrue : EFalse)) |
2845 aComponentType == MMIDComponent::EGameCanvas ? ETrue : EFalse)) |
2918 ,iFlags(EPostKeyEvents) |
2846 ,iFlags(EPostKeyEvents) |
2919 ,iFullScreen(EFalse) |
2847 ,iFullScreen(EFalse) |
2920 ,iScalingOn(EFalse) |
2848 ,iScalingOn(EFalse) |
2921 ,iS60SelectionKeyCompatibility(EFalse) |
2849 ,iS60SelectionKeyCompatibility(EFalse) |
2922 ,iRestoreContentWhenUnfaded(EFalse) |
2850 ,iRestoreContentWhenUnfaded(EFalse) |
2923 ,iLastFadeMessage(0) |
2851 ,iLastFadeMessage(0) |
2924 #ifdef CANVAS_DIRECT_ACCESS |
2852 #ifdef CANVAS_DIRECT_ACCESS |
2925 ,iDcDsaToStart(EFalse) |
2853 ,iDcDsaToStart(EFalse) |
2926 #endif // CANVAS_DIRECT_ACCESS |
2854 #endif // CANVAS_DIRECT_ACCESS |
2927 ,iDragEventsStartedInside(EFalse) |
2855 ,iDragEventsStartedInside(EFalse) |
2928 ,iFirstPaintState(EFirstPaintNeverOccurred) |
2856 ,iFirstPaintState(EFirstPaintNeverOccurred) |
2929 { |
2857 { |
2930 DEBUG("+ CMIDCanvas::CMIDCanvas - EDirectEnabled"); |
2858 DEBUG("+ CMIDCanvas::CMIDCanvas - EDirectEnabled"); |
2931 |
2859 |
2932 #ifdef CANVAS_DIRECT_ACCESS |
2860 #ifdef CANVAS_DIRECT_ACCESS |
2933 iFlags |= (EDirectPaused | EDirectEnabled | EUpdateRequired); |
2861 iFlags |= (EDirectPaused | EDirectEnabled | EUpdateRequired); |
4744 TRAP_IGNORE(UpdateOffScreenBitmapL(ETrue)); |
4672 TRAP_IGNORE(UpdateOffScreenBitmapL(ETrue)); |
4745 DrawToWindowGc(); |
4673 DrawToWindowGc(); |
4746 } |
4674 } |
4747 |
4675 |
4748 // --------------------------------------------------------------------------- |
4676 // --------------------------------------------------------------------------- |
4749 // CMIDCanvas::IsVideoOverlayActive |
|
4750 // --------------------------------------------------------------------------- |
|
4751 // |
|
4752 TBool CMIDCanvas::IsVideoOverlayActive() |
|
4753 { |
|
4754 if (iEnv.VideoOverlayEnabled() && !iIsGameCanvas) |
|
4755 { |
|
4756 // This method is called also from CMIDGraphics. |
|
4757 // Need to check here if MMAPI video area was removed by calling CheckDirectContentUpdated() |
|
4758 // in order that lcdgr can use the correct alpha blending |
|
4759 // (opaque or transparent target, see CMIDGraphcis.cpp and lcd16ma.cpp). |
|
4760 TBool ret = iDisplayable->DirectContentsCount() > 0; |
|
4761 CheckDirectContentUpdated(); |
|
4762 return ret; |
|
4763 } |
|
4764 else |
|
4765 { |
|
4766 return EFalse; |
|
4767 } |
|
4768 } |
|
4769 |
|
4770 // --------------------------------------------------------------------------- |
|
4771 // CMIDCanvas::BlitFrameBufferPixels |
4677 // CMIDCanvas::BlitFrameBufferPixels |
4772 // Sets up OpenGL state for 2D texture rendering and renders the textures for |
4678 // Sets up OpenGL state for 2D texture rendering and renders the textures for |
4773 // updated frame buffer areas by calling BlitSubRect(). |
4679 // updated frame buffer areas by calling BlitSubRect(). |
4774 // --------------------------------------------------------------------------- |
4680 // --------------------------------------------------------------------------- |
4775 // |
4681 // |
5391 { |
5297 { |
5392 TInt posPacked = 0; |
5298 TInt posPacked = 0; |
5393 TInt sizePacked = (iContentSize.iWidth << 16) | (iContentSize.iHeight); |
5299 TInt sizePacked = (iContentSize.iWidth << 16) | (iContentSize.iHeight); |
5394 PostEvent(EForcedPaint, posPacked, sizePacked); |
5300 PostEvent(EForcedPaint, posPacked, sizePacked); |
5395 } |
5301 } |
5396 |
|
5397 // --------------------------------------------------------------------------- |
|
5398 // CMIDCanvas::CheckDirectContentUpdated |
|
5399 // Restores opaque alpha channel to direct content areas in |
|
5400 // framebuffer bitmap after video is removed from canvas. |
|
5401 // --------------------------------------------------------------------------- |
|
5402 // |
|
5403 void CMIDCanvas::CheckDirectContentUpdated() |
|
5404 { |
|
5405 if (iEnv.VideoOverlayEnabled() && iMMAPIAreaUpdated) |
|
5406 { |
|
5407 // iMMAPIAreaUpdated is modified in LCDUI and MMAPI threads. |
|
5408 // Lock must be released before GetDirectContentsRegion(). |
|
5409 RCriticalSection& lock(iEnv.GetMMAPILock()); |
|
5410 lock.Wait(); |
|
5411 iMMAPIAreaUpdated = EFalse; |
|
5412 lock.Signal(); |
|
5413 |
|
5414 RRegion clearedRegion; |
|
5415 RRegion directContentRegion; |
|
5416 iDisplayable->GetDirectContentsRegion(directContentRegion); |
|
5417 clearedRegion.AddRect(TRect(iFrameBuffer->SizeInPixels())); |
|
5418 clearedRegion.SubRegion(directContentRegion); |
|
5419 |
|
5420 iFrameContext->CancelClipping(); |
|
5421 iFrameContext->SetClippingRegion(clearedRegion); |
|
5422 iFrameContext->SetBrushColor(KOpaqueBlackColor); |
|
5423 iFrameContext->SetDrawMode(CGraphicsContext::EDrawModeOR); |
|
5424 iFrameContext->Clear(); |
|
5425 // Restore full clip area |
|
5426 iFrameContext->CancelClipping(); |
|
5427 clearedRegion.Close(); |
|
5428 directContentRegion.Close(); |
|
5429 } |
|
5430 } |
|
5431 #endif // RD_JAVA_NGA_ENABLED |
5302 #endif // RD_JAVA_NGA_ENABLED |
5432 // End of File. |
5303 // End of File. |