javauis/lcdui_akn/lcdui/src/CMIDCanvas.cpp
branchRCL_3
changeset 24 0fd27995241b
parent 19 04becd199f91
child 25 9ac0a0a7da70
equal deleted inserted replaced
20:f9bb0fca356a 24:0fd27995241b
   117 
   117 
   118 #endif // RD_JAVA_NGA_ENABLED
   118 #endif // RD_JAVA_NGA_ENABLED
   119 
   119 
   120 #define KZeroSize TSize()
   120 #define KZeroSize TSize()
   121 
   121 
   122 
       
   123 // ---------------------------------------------------------------------------
   122 // ---------------------------------------------------------------------------
   124 // TBitBltData
   123 // TBitBltData
   125 // BitBlt buffer data datatype.
   124 // BitBlt buffer data datatype.
   126 // ---------------------------------------------------------------------------
   125 // ---------------------------------------------------------------------------
   127 //
   126 //
   774 }
   773 }
   775 
   774 
   776 
   775 
   777 #ifdef RD_TACTILE_FEEDBACK
   776 #ifdef RD_TACTILE_FEEDBACK
   778 // ---------------------------------------------------------------------------
   777 // ---------------------------------------------------------------------------
   779 // From MMIDCancas.
   778 // From MMIDCanvas.
   780 // CMIDCanvas::TactileFeedbackComponent
   779 // CMIDCanvas::TactileFeedbackComponent
   781 // Retutrns this as tactile feedback component.
   780 // Retutrns this as tactile feedback component.
   782 // ---------------------------------------------------------------------------
   781 // ---------------------------------------------------------------------------
   783 //
   782 //
   784 MMIDTactileFeedbackComponent* CMIDCanvas::TactileFeedbackComponent()
   783 MMIDTactileFeedbackComponent* CMIDCanvas::TactileFeedbackComponent()
   785 {
   784 {
   786     return this;
   785     return this;
   787 }
   786 }
   788 #endif // RD_TACTILE_FEEDBACK
   787 #endif // RD_TACTILE_FEEDBACK
       
   788 
       
   789 
       
   790 // ---------------------------------------------------------------------------
       
   791 // From class MMIDCanvas.
       
   792 // ---------------------------------------------------------------------------
       
   793 //
       
   794 TBool CMIDCanvas::ReadyToBlit() const
       
   795 {
       
   796     return iFirstPaintState != EFirstPaintNeverOccurred;
       
   797 }
   789 
   798 
   790 #ifdef RD_JAVA_NGA_ENABLED
   799 #ifdef RD_JAVA_NGA_ENABLED
   791 
   800 
   792 // ---------------------------------------------------------------------------
   801 // ---------------------------------------------------------------------------
   793 // From class MMIDBufferProcessor.
   802 // From class MMIDBufferProcessor.
   839         }
   848         }
   840     }
   849     }
   841     break;
   850     break;
   842     case EDrwOpcBitBltRect:
   851     case EDrwOpcBitBltRect:
   843     {
   852     {
       
   853         if (iFirstPaintState == EFirstPaintNeverOccurred)
       
   854         {
       
   855             iFirstPaintState = EFirstPaintInitiated;
       
   856         }
       
   857         
   844         const TBitBltData& data = BitBltData(aRead);
   858         const TBitBltData& data = BitBltData(aRead);
   845         UpdateL(data.iRect);
   859         UpdateL(data.iRect);
   846     }
   860     }
   847     break;
   861     break;
   848     case EDrwOpcBitBlt:
   862     case EDrwOpcBitBlt:
   849     {
   863     {
       
   864         if (iFirstPaintState == EFirstPaintNeverOccurred)
       
   865         {
       
   866             iFirstPaintState = EFirstPaintInitiated;
       
   867         }
       
   868         
   850         UpdateL(iViewRect);
   869         UpdateL(iViewRect);
   851     }
       
   852     break;
       
   853     case EDrwOpcFirstPaint:
       
   854     {
       
   855         java::ui::CoreUiAvkonLcdui::getInstance().getJavaUiAppUi()->stopStartScreen();
       
   856     }
   870     }
   857     break;
   871     break;
   858     default:
   872     default:
   859         User::Leave(KErrNotSupported);
   873         User::Leave(KErrNotSupported);
   860         break;
   874         break;
   939 #endif // DEFER_BITBLT
   953 #endif // DEFER_BITBLT
   940 
   954 
   941             Update(rect);
   955             Update(rect);
   942         }
   956         }
   943         break;
   957         break;
   944         case EDrwOpcFirstPaint:
       
   945         {
       
   946             java::ui::CoreUiAvkonLcdui::getInstance().getJavaUiAppUi()->stopStartScreen();
       
   947         }
       
   948         break;
       
   949         default:
   958         default:
   950             User::Leave(KErrNotSupported);
   959             User::Leave(KErrNotSupported);
   951             break;
   960             break;
   952         }
   961         }
   953 
   962 
   954         aRead += aRead->Size();
   963         aRead += aRead->Size();
   955     }
   964     }
   956 #endif // CANVAS_DOUBLE_BUFFER
   965 #endif // CANVAS_DOUBLE_BUFFER
   957 
   966     
       
   967     if (iFirstPaintState == EFirstPaintNeverOccurred)
       
   968     {
       
   969         if (iForeground)
       
   970         {
       
   971             // The canvas is current, therefore we can flush 
       
   972             // the graphics and take the start screen snapshot.
       
   973             iFirstPaintState = EFirstPaintOccurred;
       
   974             java::ui::CoreUiAvkonLcdui::getInstance().getJavaUiAppUi()->stopStartScreen();
       
   975         }
       
   976         else
       
   977         {
       
   978             // The window is not visible, the start screen snapshot
       
   979             // will be taken when the canvas will be set current.
       
   980             iFirstPaintState = EFirstPaintInitiated;
       
   981         }
       
   982     }
       
   983     
   958     DEBUG("- CMIDCanvas::ProcessL");
   984     DEBUG("- CMIDCanvas::ProcessL");
   959 
   985     
   960     return EFalse;
   986     return EFalse;
   961 }
   987 }
   962 #endif // RD_JAVA_NGA_ENABLED
   988 #endif // RD_JAVA_NGA_ENABLED
   963 
   989 
   964 
   990 
  1697         if (eglSwapBuffers(iEglDisplay, iEglWindowSurface) == EGL_FALSE)
  1723         if (eglSwapBuffers(iEglDisplay, iEglWindowSurface) == EGL_FALSE)
  1698         {
  1724         {
  1699             ELOG1(EJavaUI, "eglSwapBuffers() failed, eglError=%d", eglGetError());
  1725             ELOG1(EJavaUI, "eglSwapBuffers() failed, eglError=%d", eglGetError());
  1700             ASSERT(EFalse);
  1726             ASSERT(EFalse);
  1701         }
  1727         }
       
  1728         
  1702         SetCurrentEglType(EEglNone);
  1729         SetCurrentEglType(EEglNone);
       
  1730         
       
  1731         if (iFirstPaintState != EFirstPaintOccurred)
       
  1732         {
       
  1733             iFirstPaintState = EFirstPaintOccurred;
       
  1734             java::ui::CoreUiAvkonLcdui::getInstance().getJavaUiAppUi()->stopStartScreen();
       
  1735         }
  1703     }
  1736     }
  1704 }
  1737 }
  1705 #endif // RD_JAVA_NGA_ENABLED
  1738 #endif // RD_JAVA_NGA_ENABLED
  1706 
  1739 
  1707 
  1740 
  2158         {
  2191         {
  2159             consumed = iDisplayable->TryDetectLongTapL(aPointerEvent);
  2192             consumed = iDisplayable->TryDetectLongTapL(aPointerEvent);
  2160         }
  2193         }
  2161 
  2194 
  2162         if (!consumed && (iFocusedComponent != KComponentFocusedNone) &&
  2195         if (!consumed && (iFocusedComponent != KComponentFocusedNone) &&
       
  2196                 (iFocusedComponent < iCustomComponents.Count()) &&
  2163                 (iCustomComponents[iFocusedComponent]->IsTouchEnabled()))
  2197                 (iCustomComponents[iFocusedComponent]->IsTouchEnabled()))
  2164         {
  2198         {
  2165             consumed = HandlePointerEventInControlsL(aPointerEvent);
  2199             consumed = HandlePointerEventInControlsL(aPointerEvent);
  2166         }
  2200         }
  2167 
  2201 
  2357         {
  2391         {
  2358             iCustomComponents[iFocusedComponent]->
  2392             iCustomComponents[iFocusedComponent]->
  2359             CustomComponentControl(KComponentMainControl)->
  2393             CustomComponentControl(KComponentMainControl)->
  2360             SetFocus(EFalse);
  2394             SetFocus(EFalse);
  2361         }
  2395         }
       
  2396         
       
  2397 #ifdef RD_JAVA_NGA_ENABLED        
       
  2398         // Avoid the situation when the content is drawn over the menu
       
  2399         SuspendPixelSource();
       
  2400 #endif // RD_JAVA_NGA_ENABLED
       
  2401         
  2362         // Repaint to ensure that fading will be displayed correctly for Alert
  2402         // Repaint to ensure that fading will be displayed correctly for Alert
  2363         // or PopupTextBox when DSA is paused.
  2403         // or PopupTextBox when DSA is paused.
  2364         DrawDeferred();
  2404         DrawDeferred();
  2365     }
  2405     }
  2366 
  2406 
  2760     }
  2800     }
  2761     iPointerEventSuppressor->SetMaxTapDuration(iPESTimeInMilliseconds * 1000);
  2801     iPointerEventSuppressor->SetMaxTapDuration(iPESTimeInMilliseconds * 1000);
  2762     iPointerEventSuppressor->SetMaxTapMove(TSize(pointerMovementInPixels,
  2802     iPointerEventSuppressor->SetMaxTapMove(TSize(pointerMovementInPixels,
  2763                                            pointerMovementInPixels));
  2803                                            pointerMovementInPixels));
  2764 
  2804 
       
  2805     iForeground = EFalse;
  2765 #ifdef RD_JAVA_NGA_ENABLED
  2806 #ifdef RD_JAVA_NGA_ENABLED
  2766     iForeground = EFalse;
       
  2767     iEglDisplay = EGL_NO_DISPLAY;
  2807     iEglDisplay = EGL_NO_DISPLAY;
  2768     iEglWindowSurface = EGL_NO_SURFACE;
  2808     iEglWindowSurface = EGL_NO_SURFACE;
  2769     iEglWindowSurfaceContext = EGL_NO_CONTEXT;
  2809     iEglWindowSurfaceContext = EGL_NO_CONTEXT;
  2770     iEglPbufferSurface = EGL_NO_SURFACE;
  2810     iEglPbufferSurface = EGL_NO_SURFACE;
  2771     iEglPbufferSurfaceContext = EGL_NO_CONTEXT;
  2811     iEglPbufferSurfaceContext = EGL_NO_CONTEXT;
  3356     }
  3396     }
  3357 
  3397 
  3358     return enabled;
  3398     return enabled;
  3359 }
  3399 }
  3360 
  3400 
  3361 #ifdef RD_JAVA_NGA_ENABLED
       
  3362 
       
  3363 // ---------------------------------------------------------------------------
  3401 // ---------------------------------------------------------------------------
  3364 // CMIDCanvas::HandleForeground
  3402 // CMIDCanvas::HandleForeground
  3365 // Relases resources in graphics HW (=pixel source or EGL resources)
  3403 // Relases resources in graphics HW (=pixel source or EGL resources)
  3366 // when going to background.
  3404 // when going to background.
  3367 // ---------------------------------------------------------------------------
  3405 // ---------------------------------------------------------------------------
  3368 //
  3406 //
  3369 void CMIDCanvas::HandleForeground(TBool aForeground)
  3407 void CMIDCanvas::HandleForeground(TBool aForeground)
  3370 {
  3408 {
  3371     DEBUG_INT("CMIDCanvas::HandleForeground(%d) ++", aForeground);
  3409     DEBUG_INT("CMIDCanvas::HandleForeground(%d) ++", aForeground);
       
  3410     
  3372     iForeground = aForeground;
  3411     iForeground = aForeground;
  3373 
  3412 
       
  3413 #ifdef RD_JAVA_NGA_ENABLED
  3374     if (!iForeground)
  3414     if (!iForeground)
  3375     {
  3415     {
  3376         if (IsEglAvailable())
  3416         if (IsEglAvailable())
  3377         {
  3417         {
  3378             if (iEglOccupied)
  3418             if (iEglOccupied)
  3386             }
  3426             }
  3387         }
  3427         }
  3388 
  3428 
  3389         SuspendPixelSource();
  3429         SuspendPixelSource();
  3390     }
  3430     }
       
  3431 #endif // RD_JAVA_NGA_ENABLED
       
  3432     
  3391     DEBUG("CMIDCanvas::HandleForeground --");
  3433     DEBUG("CMIDCanvas::HandleForeground --");
  3392 }
  3434 }
       
  3435 
       
  3436 #ifdef RD_JAVA_NGA_ENABLED
  3393 
  3437 
  3394 // ---------------------------------------------------------------------------
  3438 // ---------------------------------------------------------------------------
  3395 // CMIDCanvas::InitPixelSourceL()
  3439 // CMIDCanvas::InitPixelSourceL()
  3396 // ---------------------------------------------------------------------------
  3440 // ---------------------------------------------------------------------------
  3397 //
  3441 //
  3465     if (iDirectContents.Count() > 0)
  3509     if (iDirectContents.Count() > 0)
  3466     {
  3510     {
  3467         return;
  3511         return;
  3468     }
  3512     }
  3469 
  3513 
  3470     iAlfCompositionPixelSource->ActivateSyncL();
  3514     // ProduceNewFrameL() is called in some cases 
       
  3515     // directly from ActivateSyncL(), need to set iFrameReady
       
  3516     // before ActivateSyncL()
  3471     iFrameReady = ETrue;
  3517     iFrameReady = ETrue;
       
  3518     TRAPD(err, iAlfCompositionPixelSource->ActivateSyncL());
       
  3519     if (err != KErrNone)
       
  3520     {
       
  3521         iFrameReady = EFalse;
       
  3522         User::Leave(err);
       
  3523     }
  3472 
  3524 
  3473     if (iPixelSourceSuspended)
  3525     if (iPixelSourceSuspended)
  3474     {
  3526     {
  3475         iPixelSourceSuspended = EFalse;
  3527         iPixelSourceSuspended = EFalse;
  3476         if (iFullScreen && iScalingOn)
  3528         if (iFullScreen && iScalingOn)
  3525     DEBUG_INT4("CMIDCanvas::ProduceNewFrameL - visible region(x=%d, y=%d, w=%d, h=%d) ++",
  3577     DEBUG_INT4("CMIDCanvas::ProduceNewFrameL - visible region(x=%d, y=%d, w=%d, h=%d) ++",
  3526                bbox.iTl.iX, bbox.iTl.iY, bbox.Width(), bbox.Height());
  3578                bbox.iTl.iX, bbox.iTl.iY, bbox.Width(), bbox.Height());
  3527 
  3579 
  3528     // If iDirectContents.Count() > 0, canvas hasn't received
  3580     // If iDirectContents.Count() > 0, canvas hasn't received
  3529     // MdcNotifyContentAdded in LCDUI thread yet.
  3581     // MdcNotifyContentAdded in LCDUI thread yet.
       
  3582     TBool res;
  3530     if (!iFrameReady || iDirectContents.Count() > 0)
  3583     if (!iFrameReady || iDirectContents.Count() > 0)
  3531     {
  3584     {
  3532         DEBUG("CMIDCanvas::ProduceNewFrameL - FRAME IS NOT READY --");
  3585         DEBUG("CMIDCanvas::ProduceNewFrameL - FRAME IS NOT READY --");
  3533         NotifyMonitor();
  3586         NotifyMonitor();
  3534         return EFalse;
  3587         res = EFalse;
  3535     }
  3588     }
  3536 
  3589     else
  3537     NotifyMonitor();
  3590     {
  3538 
  3591         NotifyMonitor();
  3539     TUint8* from = (TUint8*)iFrameBuffer->DataAddress();
  3592     
  3540 
  3593         TUint8* from = (TUint8*)iFrameBuffer->DataAddress();
  3541     TBool downScaling = IsDownScaling(iContentSize, iViewRect);
  3594     
  3542     TInt width =  downScaling ? iViewRect.Width()  : iContentSize.iWidth;
  3595         TBool downScaling = IsDownScaling(iContentSize, iViewRect);
  3543     TInt height = downScaling ? iViewRect.Height() : iContentSize.iHeight;
  3596         TInt width =  downScaling ? iViewRect.Width()  : iContentSize.iWidth;
  3544 
  3597         TInt height = downScaling ? iViewRect.Height() : iContentSize.iHeight;
  3545     TUint bytes = width * KBytesPerPixel;
  3598     
  3546     TInt scanLength = CFbsBitmap::ScanLineLength(
  3599         TUint bytes = width * KBytesPerPixel;
  3547                           iFrameBuffer->SizeInPixels().iWidth, iFrameBuffer->DisplayMode());
  3600         TInt scanLength = CFbsBitmap::ScanLineLength(
  3548 
  3601                               iFrameBuffer->SizeInPixels().iWidth, iFrameBuffer->DisplayMode());
  3549     for (TInt y = 0; y < height; ++y)
  3602     
  3550     {
  3603         for (TInt y = 0; y < height; ++y)
  3551         Mem::Copy(aBuffer, from, bytes);
  3604         {
  3552         aBuffer += iAlfBufferAttributes.iStride;
  3605             Mem::Copy(aBuffer, from, bytes);
  3553         from += scanLength;
  3606             aBuffer += iAlfBufferAttributes.iStride;
  3554     }
  3607             from += scanLength;
  3555 
  3608         }
       
  3609     
       
  3610         res = ETrue;
       
  3611     }
       
  3612     
       
  3613     if (iFirstPaintState == EFirstPaintInitiated || iFirstPaintState == EFirstPaintPrepared)
       
  3614     {
       
  3615         if (iFirstPaintState == EFirstPaintInitiated)
       
  3616         {
       
  3617             iFirstPaintState = EFirstPaintPrepared;
       
  3618         }
       
  3619         else
       
  3620         {
       
  3621             iFirstPaintState = EFirstPaintOccurred;
       
  3622             java::ui::CoreUiAvkonLcdui::getInstance().getJavaUiAppUi()->stopStartScreen();
       
  3623         }
       
  3624     }
       
  3625     
  3556     DEBUG("CMIDCanvas::ProduceNewFrameL --");
  3626     DEBUG("CMIDCanvas::ProduceNewFrameL --");
  3557     return ETrue;
  3627     
       
  3628     return res;
  3558 }
  3629 }
  3559 
  3630 
  3560 // ---------------------------------------------------------------------------
  3631 // ---------------------------------------------------------------------------
  3561 // From MAlfBufferProvider
  3632 // From MAlfBufferProvider
  3562 // CMIDCanvas::BufferAttributes
  3633 // CMIDCanvas::BufferAttributes
  4708     glEnableClientState(GL_VERTEX_ARRAY);
  4779     glEnableClientState(GL_VERTEX_ARRAY);
  4709     glMatrixMode(GL_TEXTURE);
  4780     glMatrixMode(GL_TEXTURE);
  4710     glLoadIdentity();
  4781     glLoadIdentity();
  4711 
  4782 
  4712     // position texture screen coordinates
  4783     // position texture screen coordinates
  4713     pos[0] = (GLshort)iViewRect.iTl.iX;
  4784     pos[0] = (GLshort)iViewRect.iTl.iX - iPositionRelativeToScreen.iX;
  4714     pos[1] = (GLshort)iViewRect.Height() + (height - iViewRect.iBr.iY);
  4785     pos[1] = (GLshort)iViewRect.Height() + (height - iViewRect.iBr.iY);
  4715     pos[2] = pos[0];
  4786     pos[2] = pos[0];
  4716     pos[3] = (GLshort)height - iViewRect.iBr.iY;
  4787     pos[3] = (GLshort)height - iViewRect.iBr.iY;
  4717     pos[4] = (GLshort)iViewRect.iBr.iX;
  4788     pos[4] = (GLshort)iViewRect.iBr.iX - iPositionRelativeToScreen.iX;
  4718     pos[5] = pos[1];
  4789     pos[5] = pos[1];
  4719     pos[6] = pos[4];
  4790     pos[6] = pos[4];
  4720     pos[7] = pos[3];
  4791     pos[7] = pos[3];
  4721 
  4792 
  4722     glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
  4793     glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);