diff -r 7cee158cb8cd -r 26b2b12093af javauis/lcdui_akn/lcdui/src/CMIDCanvas.cpp --- a/javauis/lcdui_akn/lcdui/src/CMIDCanvas.cpp Wed Sep 15 12:05:25 2010 +0300 +++ b/javauis/lcdui_akn/lcdui/src/CMIDCanvas.cpp Wed Oct 13 14:23:59 2010 +0300 @@ -483,7 +483,7 @@ CustomComponentControl(KComponentMainControl)->IsVisible())) { // Traversal check - if ((aType == EEventKey) && + if ((aType == EEventKeyDown) && (((aEvent.iCode == EKeyUpArrow) || (aEvent.iCode == EKeyDownArrow)) || ((aEvent.iScanCode == EStdKeyUpArrow) || @@ -856,104 +856,67 @@ return EFalse; } - // Usually only one op code is processed by Canvas. - // Exception is the video overlay case, where MIDlet - // does not draw anything inside Canvas.paint(). - // In this case EDrwOpcPaintStarted and EDrwOpcBitBltRect/EDrwOpcBitBlt - // are received in one ProcessL(). Also EDrwOpcPaintStarted and EDrwOpcM3GContentStart - // may be processed in one ProcessL(), if overlays are enabled. - while (aRead < aEnd) - { - switch (aRead->OpCode()) - { - case EDrwOpcM3GContentStart: + switch (aRead->OpCode()) + { + case EDrwOpcM3GContentStart: + { + // EGL surface is created if canvas window is currently visible + // even if MIDlet would be on background. + if (!iM3GContent && + i3DAccelerated && + iDirectContents.Count() == 0 && + IsWindowVisible()) { - // EGL surface is created if canvas window is currently visible - // even if MIDlet would be on background. - if (!iM3GContent && - i3DAccelerated && - iDirectContents.Count() == 0 && - IsWindowVisible()) - { - DEBUG("CMIDCanvas::ProcessL - M3G content start"); - iM3GContent = ETrue; - iM3GStart = ETrue; - PostEvent(EM3GDraw, iM3GContent, 0); - // First time when M3G content is drawn => - // switch to EGL surface drawing. - // Pixel source must be disposed first. - DisposePixelSource(); - OpenEglL(); - - // if we are scaling with m3g and HW acceleration - // create a pbuffer surface to be used with m3g rendering - if (iScalingOn && iFullScreen) - { - CreatePBufferSurfaceL(); - } - // Draw the whole framebuffer content (as a texture) on top of - // the EGL window surface. - iUpperUpdateRect = TRect(Size()); - UpdateEglContent(); - } - - ASSERT(aRead + aRead->Size() == aEnd); - } - break; - case EDrwOpcBitBltRect: - { - if (iFirstPaintState == EFirstPaintNeverOccurred) + DEBUG("CMIDCanvas::ProcessL - M3G content start"); + iM3GContent = ETrue; + iM3GStart = ETrue; + PostEvent(EM3GDraw, iM3GContent, 0); + // First time when M3G content is drawn => + // switch to EGL surface drawing. + // Pixel source must be disposed first. + DisposePixelSource(); + OpenEglL(); + + // if we are scaling with m3g and HW acceleration + // create a pbuffer surface to be used with m3g rendering + if (iScalingOn && iFullScreen) { - iFirstPaintState = EFirstPaintInitiated; + CreatePBufferSurfaceL(); } - - const TBitBltData& data = BitBltData(aRead); - UpdateL(data.iRect); - - ASSERT(aRead + aRead->Size() == aEnd); + // Draw the whole framebuffer content (as a texture) on top of + // the EGL window surface. + iUpperUpdateRect = TRect(Size()); + UpdateEglContent(); } - break; - case EDrwOpcBitBlt: - { - if (iFirstPaintState == EFirstPaintNeverOccurred) - { - iFirstPaintState = EFirstPaintInitiated; - } - - UpdateL(iViewRect); - - ASSERT(aRead + aRead->Size() == aEnd); - } - break; - case EDrwOpcPaintStarted: + } + break; + case EDrwOpcBitBltRect: + { + if (iFirstPaintState == EFirstPaintNeverOccurred) { - // Clear MMAPI content areas on Canvas to enable overlays. - if (IsVideoOverlayActive()) - { - RRegion directContents; - iDisplayable->GetDirectContentsRegion(directContents); - TInt count = directContents.Count(); - - iFrameContext->SetBrushColor(KTransparentClearColor); - iFrameContext->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); - - for (TInt i = 0; i < count; ++i) - { - const TRect rect = directContents[i]; - iFrameContext->Clear(rect); - } - directContents.Close(); - } + iFirstPaintState = EFirstPaintInitiated; } - break; - default: - User::Leave(KErrNotSupported); - break; + + const TBitBltData& data = BitBltData(aRead); + UpdateL(data.iRect); + } + break; + case EDrwOpcBitBlt: + { + if (iFirstPaintState == EFirstPaintNeverOccurred) + { + iFirstPaintState = EFirstPaintInitiated; } - aRead += aRead->Size(); - } - + UpdateL(iViewRect); + } + break; + default: + User::Leave(KErrNotSupported); + break; + } + + aRead += aRead->Size(); ASSERT(aRead == aEnd); // iFrameReady tells if this is async operation. @@ -1182,7 +1145,7 @@ // Adds a rectangle to be excluded from redrawing. // --------------------------------------------------------------------------- // -void CMIDCanvas::MdcAddMMAPIContentBounds(const TRect& aRect) +void CMIDCanvas::MdcAddContentBounds(const TRect& aRect) { if (iDisplayable) { @@ -1197,29 +1160,11 @@ // Removes a rectangle to be excluded from redrawing. // --------------------------------------------------------------------------- // -void CMIDCanvas::MdcRemoveMMAPIContentBounds(const TRect& aRect) +void CMIDCanvas::MdcRemoveContentBounds(const TRect& aRect) { if (iDisplayable) { -#ifdef RD_JAVA_NGA_ENABLED - if (iEnv.VideoOverlayEnabled()) - { - // iMMAPIAreaUpdated may be modified in LCDUI and MMAPI threads. - // Lock must be released before RemoveDirectContentArea(). - RCriticalSection& lock(iEnv.GetMMAPILock()); - lock.Wait(); - iMMAPIAreaUpdated = ETrue; - lock.Signal(); - - iDisplayable->RemoveDirectContentArea(aRect); - } - else - { - iDisplayable->RemoveDirectContentArea(aRect); - } -#else iDisplayable->RemoveDirectContentArea(aRect); -#endif // RD_JAVA_NGA_ENABLED } } @@ -1507,7 +1452,7 @@ { DEBUG("CMIDCanvas::RegisterComponentL, registering new"); - iCustomComponents.AppendL(aComponent); + iCustomComponents.Append(aComponent); // Update custom components count in order to improve // the performance when counting components @@ -1631,7 +1576,12 @@ // Remove the old index from the components array. iCustomComponents.Remove(index); - iCustomComponents.InsertL(aComponent, aNewIndex); + // Add the component to the new index. Note that the array + // should contain memory for all the components since + // Remove should not decrease the memory used by the array + // Therefore, the following operation is leave-safe and + // return value is ignored intentionally. + iCustomComponents.Insert(aComponent, aNewIndex); // Redraw the whole canvas. DrawDeferred(); @@ -1957,17 +1907,6 @@ gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); } -#ifdef RD_JAVA_NGA_ENABLED - // If overlay is enabled, need to clear previous content - // from CWindowGc. - CMIDCanvas* myself = const_cast(this); - if (myself->IsVideoOverlayActive()) - { - gc.SetBrushColor(KTransparentClearColor); - gc.Clear(aRect); - } -#endif - TRect windowRect(aRect); PrepareDraw(gc, windowRect); @@ -2265,7 +2204,7 @@ { // We need inform TextEditor that input language is changed. if ((iFocusedComponent != KComponentFocusedNone) && - (iFocusedComponent < iCustomComponents.Count())) + (iFocusedComponent < iCustomComponents.Count())) { iCustomComponents[iFocusedComponent]-> CustomComponentControl(KComponentMainControl)-> @@ -2524,10 +2463,7 @@ } // To have the cursor on focused control - if ((iFocusedComponent != KComponentFocusedNone) && - (iFocusedComponent < iCustomComponents.Count()) && - iCustomComponents[iFocusedComponent]-> - CustomComponentControl(KComponentMainControl)->IsVisible()) + if (iFocusedComponent != KComponentFocusedNone) { iCustomComponents[iFocusedComponent]-> CustomComponentControl(KComponentMainControl)-> @@ -2725,13 +2661,13 @@ iLandscape = landscape; PostEvent(ESizeChanged, iContentSize.iWidth, iContentSize.iHeight); + if (IsWindowVisible() && iWndUpdate) { // Post forced paint to enable Canvas repaint behind // Alert or Pop-up TextBox PostForcedPaint(); } - #else iContentSize = contentSize; PostEvent(ESizeChanged, iContentSize.iWidth, iContentSize.iHeight); @@ -2757,14 +2693,6 @@ // We cannot determine whether the control size actually did change or // not, so we have to do the layout no matter what. Layout(); -#ifdef RD_JAVA_NGA_ENABLED - if (IsWindowVisible() && iWndUpdate) - { - // Post forced paint to enable Canvas repaint behind - // Alert or Pop-up TextBox - PostForcedPaint(); - } -#endif // RD_JAVA_NGA_ENABLED } DEBUG("- CMIDCanvas::SizeChanged"); } @@ -2908,24 +2836,24 @@ TBool aUpdateRequired #endif // CANVAS_DIRECT_ACCESS ) : - CCoeControl() - ,iEnv(aEnv) + CCoeControl() + ,iEnv(aEnv) #ifdef CANVAS_DOUBLE_BUFFER - ,iFrameBuffer(NULL) + ,iFrameBuffer(NULL) #endif // CANVAS_DOUBLE_BUFFER - ,iIsGameCanvas(( - aComponentType == MMIDComponent::EGameCanvas ? ETrue : EFalse)) - ,iFlags(EPostKeyEvents) - ,iFullScreen(EFalse) - ,iScalingOn(EFalse) - ,iS60SelectionKeyCompatibility(EFalse) - ,iRestoreContentWhenUnfaded(EFalse) - ,iLastFadeMessage(0) + ,iIsGameCanvas(( + aComponentType == MMIDComponent::EGameCanvas ? ETrue : EFalse)) + ,iFlags(EPostKeyEvents) + ,iFullScreen(EFalse) + ,iScalingOn(EFalse) + ,iS60SelectionKeyCompatibility(EFalse) + ,iRestoreContentWhenUnfaded(EFalse) + ,iLastFadeMessage(0) #ifdef CANVAS_DIRECT_ACCESS - ,iDcDsaToStart(EFalse) + ,iDcDsaToStart(EFalse) #endif // CANVAS_DIRECT_ACCESS - ,iDragEventsStartedInside(EFalse) - ,iFirstPaintState(EFirstPaintNeverOccurred) + ,iDragEventsStartedInside(EFalse) + ,iFirstPaintState(EFirstPaintNeverOccurred) { DEBUG("+ CMIDCanvas::CMIDCanvas - EDirectEnabled"); @@ -4746,28 +4674,6 @@ } // --------------------------------------------------------------------------- -// CMIDCanvas::IsVideoOverlayActive -// --------------------------------------------------------------------------- -// -TBool CMIDCanvas::IsVideoOverlayActive() -{ - if (iEnv.VideoOverlayEnabled() && !iIsGameCanvas) - { - // This method is called also from CMIDGraphics. - // Need to check here if MMAPI video area was removed by calling CheckDirectContentUpdated() - // in order that lcdgr can use the correct alpha blending - // (opaque or transparent target, see CMIDGraphcis.cpp and lcd16ma.cpp). - TBool ret = iDisplayable->DirectContentsCount() > 0; - CheckDirectContentUpdated(); - return ret; - } - else - { - return EFalse; - } -} - -// --------------------------------------------------------------------------- // CMIDCanvas::BlitFrameBufferPixels // Sets up OpenGL state for 2D texture rendering and renders the textures for // updated frame buffer areas by calling BlitSubRect(). @@ -5393,40 +5299,5 @@ TInt sizePacked = (iContentSize.iWidth << 16) | (iContentSize.iHeight); PostEvent(EForcedPaint, posPacked, sizePacked); } - -// --------------------------------------------------------------------------- -// CMIDCanvas::CheckDirectContentUpdated -// Restores opaque alpha channel to direct content areas in -// framebuffer bitmap after video is removed from canvas. -// --------------------------------------------------------------------------- -// -void CMIDCanvas::CheckDirectContentUpdated() -{ - if (iEnv.VideoOverlayEnabled() && iMMAPIAreaUpdated) - { - // iMMAPIAreaUpdated is modified in LCDUI and MMAPI threads. - // Lock must be released before GetDirectContentsRegion(). - RCriticalSection& lock(iEnv.GetMMAPILock()); - lock.Wait(); - iMMAPIAreaUpdated = EFalse; - lock.Signal(); - - RRegion clearedRegion; - RRegion directContentRegion; - iDisplayable->GetDirectContentsRegion(directContentRegion); - clearedRegion.AddRect(TRect(iFrameBuffer->SizeInPixels())); - clearedRegion.SubRegion(directContentRegion); - - iFrameContext->CancelClipping(); - iFrameContext->SetClippingRegion(clearedRegion); - iFrameContext->SetBrushColor(KOpaqueBlackColor); - iFrameContext->SetDrawMode(CGraphicsContext::EDrawModeOR); - iFrameContext->Clear(); - // Restore full clip area - iFrameContext->CancelClipping(); - clearedRegion.Close(); - directContentRegion.Close(); - } -} #endif // RD_JAVA_NGA_ENABLED // End of File.