~ubuntu-branches/ubuntu/oneiric/nux/oneiric

« back to all changes in this revision

Viewing changes to Nux/WindowCompositor.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2010-12-17 13:59:57 UTC
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20101217135957-5gvg6fkjxaa252i0
Tags: upstream-0.9.12
ImportĀ upstreamĀ versionĀ 0.9.12

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
    m_PreviousMouseOverArea     = NULL;
67
67
    _always_on_front_window     = NULL;
68
68
    _inside_event_processing    = false;
 
69
    _inside_rendering_cycle     = false;
69
70
    _exclusive_input_area       = NULL;
70
71
    _in_exclusive_input_mode    = false;
71
72
    _pending_exclusive_input_mode_action = false;
280
281
    if (GetMouseFocusArea() && (ievent.e_event != NUX_MOUSE_PRESSED) && (!InExclusiveInputMode ()))
281
282
    {
282
283
      SetCurrentEvent (&ievent);
283
 
      SetCurrentWindow (GetFocusAreaWindow());
 
284
      SetProcessingTopView (GetFocusAreaWindow());
284
285
      ProcessEventOnObject (ievent, GetMouseFocusArea(), 0, 0);
285
286
 
286
287
      if (ievent.e_event == NUX_MOUSE_RELEASED)
323
324
//             }
324
325
//         }
325
326
      SetCurrentEvent (NULL);
326
 
      SetCurrentWindow (NULL);
 
327
      SetProcessingTopView (NULL);
327
328
    }
328
329
    else
329
330
    {
404
405
 
405
406
      if (m_ModalWindowList.size () > 0)
406
407
      {
407
 
        SetCurrentWindow ((*m_ModalWindowList.begin ()).GetPointer ());
 
408
        SetProcessingTopView ((*m_ModalWindowList.begin ()).GetPointer ());
408
409
        ret = (*m_ModalWindowList.begin ())->ProcessEvent (ievent, ret, ProcessEventInfo);
409
 
        SetCurrentWindow (NULL);
 
410
        SetProcessingTopView (NULL);
410
411
      }
411
412
      else
412
413
      {
425
426
            // Traverse the window from the top of the visibility stack to the bottom.
426
427
            if ((*it).GetPointer ())
427
428
            {
428
 
              SetCurrentWindow ((*it).GetPointer ());
 
429
              SetProcessingTopView ((*it).GetPointer ());
429
430
              ret = (*it)->ProcessEvent (ievent, ret, ProcessEventInfo);
430
 
              SetCurrentWindow (NULL);
 
431
              SetProcessingTopView (NULL);
431
432
 
432
433
              if ((ret & eMouseEventSolved) && (m_SelectedWindow == 0) && (!InExclusiveInputMode ()))
433
434
              {
714
715
 
715
716
  void WindowCompositor::Draw (bool SizeConfigurationEvent, bool force_draw)
716
717
  {
 
718
    _inside_rendering_cycle = true;
717
719
    if (!GetGraphicsThread()->GetWindow().isWindowMinimized())
718
720
    {
719
721
      //int w, h;
734
736
 
735
737
          if (1 /*GetThreadGLDeviceFactory()->GetGraphicsBoardVendor() != BOARD_INTEL*/)
736
738
          {
737
 
            DrawFloatingWindows (true, m_WindowList, false, true);
738
 
            DrawFloatingWindows (true, m_ModalWindowList, true, true);
 
739
            RenderTopViews (true, m_WindowList, false, true);
 
740
            RenderTopViews (true, m_ModalWindowList, true, true);
739
741
 
740
742
            DrawMenu (true);
741
743
            DrawTooltip (true);
751
753
 
752
754
          if (1 /*GetThreadGLDeviceFactory()->GetGraphicsBoardVendor() != BOARD_INTEL*/)
753
755
          {
754
 
            DrawFloatingWindows (false, m_WindowList, false, true);
755
 
            DrawFloatingWindows (false, m_ModalWindowList, true, true);
 
756
            RenderTopViews (false, m_WindowList, false, true);
 
757
            RenderTopViews (false, m_ModalWindowList, true, true);
756
758
 
757
759
            DrawMenu (true);
758
760
            DrawTooltip (true);
766
768
 
767
769
          if (1 /*GetThreadGLDeviceFactory()->GetGraphicsBoardVendor() != BOARD_INTEL*/)
768
770
          {
769
 
            DrawFloatingWindows (false, m_WindowList, false, true);
770
 
            DrawFloatingWindows (false, m_ModalWindowList, true, true);
 
771
            RenderTopViews (false, m_WindowList, false, true);
 
772
            RenderTopViews (false, m_ModalWindowList, true, true);
771
773
 
772
774
            DrawMenu (true);
773
775
            DrawTooltip (true);
782
784
          GetPainter().PushDrawColorLayer (GetGraphicsThread()->GetGraphicsEngine(), Geometry (0, 0, m_Width, m_Height), Color (0xFF4D4D4D), true);
783
785
          RenderMainWindowComposition (true, false);
784
786
 
785
 
          DrawFloatingWindows (true, m_WindowList, false, false);
786
 
          DrawFloatingWindows (true, m_ModalWindowList, true, false);
 
787
          RenderTopViews (true, m_WindowList, false, false);
 
788
          RenderTopViews (true, m_ModalWindowList, true, false);
787
789
          DrawMenu (true);
788
790
          DrawOverlay (true);
789
791
          DrawTooltip (true);
794
796
          GetPainter().PushDrawColorLayer (GetGraphicsThread()->GetGraphicsEngine(), Geometry (0, 0, m_Width, m_Height), Color (0xFF4D4D4D), true);
795
797
          RenderMainWindowComposition (true, false);
796
798
 
797
 
          DrawFloatingWindows (false, m_WindowList, false, false);
798
 
          DrawFloatingWindows (false, m_ModalWindowList, true, false);
 
799
          RenderTopViews (false, m_WindowList, false, false);
 
800
          RenderTopViews (false, m_ModalWindowList, true, false);
799
801
          DrawMenu (true);
800
802
          DrawOverlay (true);
801
803
          DrawTooltip (true);
804
806
        else
805
807
        {
806
808
          RenderMainWindowComposition (false, false);
807
 
          DrawFloatingWindows (true, m_WindowList, false, false);
808
 
          DrawFloatingWindows (true, m_ModalWindowList, true, false);
 
809
          RenderTopViews (true, m_WindowList, false, false);
 
810
          RenderTopViews (true, m_ModalWindowList, true, false);
809
811
          DrawMenu (true);
810
812
          DrawOverlay (true);
811
813
          DrawTooltip (true);
819
821
 
820
822
      GetGraphicsThread()->GetGraphicsEngine().Pop2DWindow();
821
823
    }
 
824
    _inside_rendering_cycle = false;
822
825
  }
823
826
 
824
827
  void WindowCompositor::DrawMenu (bool force_draw)
848
851
 
849
852
    for (rev_it_menu = m_MenuList->rbegin(); rev_it_menu != m_MenuList->rend( ); rev_it_menu++)
850
853
    {
851
 
      SetCurrentWindow (m_MenuWindow.GetPointer ());
 
854
      SetProcessingTopView (m_MenuWindow.GetPointer ());
852
855
      (*rev_it_menu)->ProcessDraw (GetGraphicsThread()->GetGraphicsEngine(), force_draw);
853
 
      SetCurrentWindow (NULL);
 
856
      SetProcessingTopView (NULL);
854
857
    }
855
858
 
856
859
    GetThreadGraphicsContext()->SetContext (0, 0,
877
880
 
878
881
    if (OverlayDrawingCommand)
879
882
    {
880
 
      SetCurrentWindow (m_OverlayWindow.GetPointer ());
 
883
      SetProcessingTopView (m_OverlayWindow.GetPointer ());
881
884
      OverlayDrawingCommand->OverlayDrawing (GetGraphicsThread()->GetGraphicsEngine() );
882
 
      SetCurrentWindow (NULL);
 
885
      SetProcessingTopView (NULL);
883
886
    }
884
887
 
885
888
    GetThreadGraphicsContext()->SetContext (0, 0, buffer_width, buffer_height);
904
907
 
905
908
    if(m_TooltipText.Size())
906
909
    {
907
 
        //SetCurrentWindow(_tooltip_window);
 
910
        //SetProcessingTopView(_tooltip_window);
908
911
        GetPainter().PaintShape(GetGraphicsThread()->GetGraphicsEngine(), _tooltip_geometry, Color(0xA0000000), eSHAPE_CORNER_ROUND10, true);
909
912
        GetPainter().PaintTextLineStatic(GetGraphicsThread()->GetGraphicsEngine(), GetSysBoldFont(), _tooltip_text_geometry, m_TooltipText, Color(0xFFFFFFFF));
910
 
        //SetCurrentWindow(NULL);
 
913
        //SetProcessingTopView(NULL);
911
914
    }
912
915
 
913
916
    GetThreadGraphicsContext()->SetContext (0, 0, buffer_width, buffer_height);
914
917
  }
915
918
 
916
 
  void WindowCompositor::RenderWindowComposition (BaseWindow *window, bool force_draw)
 
919
  void WindowCompositor::RenderTopViewContent (BaseWindow *window, bool force_draw)
917
920
  {
918
921
    unsigned int window_width, window_height;
919
922
    window_width = GetGraphicsThread()->GetGraphicsEngine().GetWindowWidth();
920
923
    window_height = GetGraphicsThread()->GetGraphicsEngine().GetWindowHeight();
921
924
 
922
925
    GetPainter().EmptyBackgroundStack();
923
 
    SetCurrentWindow (window);
 
926
    SetProcessingTopView (window);
924
927
    window->ProcessDraw (GetGraphicsThread()->GetGraphicsEngine(), force_draw || window->IsRedrawNeeded() );
925
 
    SetCurrentWindow (NULL);
 
928
    SetProcessingTopView (NULL);
926
929
    GetPainter().EmptyBackgroundStack();
927
930
  }
928
931
 
929
 
  void WindowCompositor::DrawFloatingWindows (bool force_draw, std::list< IntrusiveWeakSP<BaseWindow> >& WindowList, bool drawModal, bool UseFBO)
 
932
  void WindowCompositor::RenderTopViews (bool force_draw, std::list< IntrusiveWeakSP<BaseWindow> >& WindowList, bool drawModal, bool use_fbo)
930
933
  {
931
 
    GetGraphicsThread()->GetGraphicsEngine().EmptyClippingRegion();
 
934
    GetGraphicsThread ()->GetGraphicsEngine ().EmptyClippingRegion ();
932
935
    // Raw the windows from back to front;
933
936
    std::list< IntrusiveWeakSP<BaseWindow> >::reverse_iterator rev_it;
934
937
 
935
 
    for (rev_it = WindowList.rbegin(); rev_it != WindowList.rend(); rev_it++)
 
938
    for (rev_it = WindowList.rbegin (); rev_it != WindowList.rend (); rev_it++)
936
939
    {
937
 
      if ( (drawModal == false) && (*rev_it)->IsModal() )
 
940
      if ((drawModal == false) && (*rev_it)->IsModal ())
938
941
        continue;
939
942
 
940
943
      bool WindowNeedRedraw = false;
948
951
        // Based on the areas that requested a rendering inside the BaseWindow, render the BaseWindow or just use its cache. 
949
952
        if(force_draw || window->IsRedrawNeeded() || window->ChildNeedsRedraw ())
950
953
        {
951
 
          if (rt.color_rt.IsValid() /*&& rt.depth_rt.IsValid()*/ && UseFBO)
 
954
          if (rt.color_rt.IsValid() /*&& rt.depth_rt.IsValid()*/ && use_fbo)
952
955
          {
953
956
            t_s32 buffer_width = window->GetBaseWidth();
954
957
            t_s32 buffer_height = window->GetBaseHeight();
986
989
            //GetGraphicsThread()->GetGraphicsEngine().Push2DModelViewMatrix(mat);
987
990
          }
988
991
 
989
 
          RenderWindowComposition (/*fbo,*/ window, force_draw);
 
992
          RenderTopViewContent (/*fbo,*/ window, force_draw);
990
993
        }
991
994
        
992
 
        if (rt.color_rt.IsValid() /*&& rt.depth_rt.IsValid()*/ && UseFBO)
 
995
        if (rt.color_rt.IsValid() /*&& rt.depth_rt.IsValid()*/ && use_fbo)
993
996
        {
994
997
          // GetGraphicsThread()->GetGraphicsEngine().EmptyClippingRegion();
995
998
          m_FrameBufferObject->Deactivate();
1058
1061
      }
1059
1062
    }
1060
1063
 
1061
 
    if (UseFBO)
 
1064
    if (use_fbo)
1062
1065
      m_FrameBufferObject->Deactivate();
1063
1066
  }
1064
1067
 
1463
1466
 
1464
1467
  void WindowCompositor::SetTooltip(InputArea* TooltipArea, const TCHAR *TooltipText, int x, int y)
1465
1468
  {
1466
 
    _tooltip_window = GetCurrentWindow();
 
1469
    _tooltip_window = GetProcessingTopView();
1467
1470
    m_TooltipArea = TooltipArea;
1468
1471
    m_TooltipText = TooltipText;
1469
1472
    m_TooltipX = x;
1540
1543
      m_EventRoot.Set (0, 0);
1541
1544
    }
1542
1545
 
1543
 
    SetFocusAreaWindow (GetCurrentWindow() );
 
1546
    SetFocusAreaWindow (GetProcessingTopView() );
1544
1547
  }
1545
1548
 
1546
1549
  InputArea *WindowCompositor::GetMouseFocusArea()
1777
1780
//   {
1778
1781
//     return m_BlurTexture;
1779
1782
//   }
 
1783
 
 
1784
 
 
1785
  void WindowCompositor::RestoreRenderingSurface ()
 
1786
  {
 
1787
    BaseWindow *top_view = GetProcessingTopView ();
 
1788
 
 
1789
    if (top_view && _inside_rendering_cycle)
 
1790
    {
 
1791
      nuxAssert (top_view->Type ().IsDerivedFromType (BaseWindow::StaticObjectType));
 
1792
 
 
1793
      RenderTargetTextures rt = GetWindowBuffer (top_view);
 
1794
 
 
1795
      int buffer_width = top_view->GetBaseWidth();
 
1796
      int buffer_height = top_view->GetBaseHeight();
 
1797
 
 
1798
      nuxAssert (buffer_width >= 1);
 
1799
      nuxAssert (buffer_height >= 1);
 
1800
 
 
1801
      if ((rt.color_rt->GetWidth () != buffer_width) || (rt.color_rt->GetHeight () != buffer_height))
 
1802
      {
 
1803
        rt.color_rt = GetThreadGLDeviceFactory()->CreateSystemCapableDeviceTexture (buffer_width, buffer_height, 1, BITFMT_R8G8B8A8);
 
1804
        rt.depth_rt = GetThreadGLDeviceFactory()->CreateSystemCapableDeviceTexture (buffer_width, buffer_height, 1, BITFMT_D24S8);
 
1805
      }
 
1806
 
 
1807
      m_FrameBufferObject->FormatFrameBufferObject (buffer_width, buffer_height, BITFMT_R8G8B8A8);
 
1808
      m_FrameBufferObject->SetRenderTarget ( 0, rt.color_rt->GetSurfaceLevel (0) );
 
1809
      m_FrameBufferObject->SetDepthSurface ( rt.depth_rt->GetSurfaceLevel (0) );
 
1810
      m_FrameBufferObject->Activate();
 
1811
 
 
1812
      GetGraphicsThread()->GetGraphicsEngine().SetContext (0, 0, buffer_width, buffer_height);
 
1813
      GetGraphicsThread()->GetGraphicsEngine().SetViewport (0, 0, buffer_width, buffer_height);
 
1814
      GetGraphicsThread()->GetGraphicsEngine().Push2DWindow (buffer_width, buffer_height);
 
1815
      GetGraphicsThread()->GetGraphicsEngine().ApplyClippingRectangle();
 
1816
    }
 
1817
    else
 
1818
    {
 
1819
      int buffer_width = GetGraphicsThread()->GetGraphicsEngine().GetWindowWidth();
 
1820
      int buffer_height = GetGraphicsThread()->GetGraphicsEngine().GetWindowHeight();
 
1821
 
 
1822
      nuxAssert (buffer_width >= 1);
 
1823
      nuxAssert (buffer_height >= 1);
 
1824
      // Restore Main Frame Buffer
 
1825
      m_FrameBufferObject->FormatFrameBufferObject (buffer_width, buffer_height, BITFMT_R8G8B8A8);
 
1826
      m_FrameBufferObject->SetRenderTarget (0, m_CompositionRT->GetSurfaceLevel (0) );
 
1827
      m_FrameBufferObject->SetDepthSurface (IntrusiveSP<IOpenGLSurface> (0));
 
1828
      m_FrameBufferObject->Activate();
 
1829
 
 
1830
      GetGraphicsThread()->GetGraphicsEngine().SetContext (0, 0, buffer_width, buffer_height);
 
1831
      GetGraphicsThread()->GetGraphicsEngine().SetViewport (0, 0, buffer_width, buffer_height);
 
1832
      GetGraphicsThread()->GetGraphicsEngine().Push2DWindow (buffer_width, buffer_height);
 
1833
      GetGraphicsThread()->GetGraphicsEngine().ApplyClippingRectangle();
 
1834
    }
 
1835
  }
 
1836
 
1780
1837
}
1781
1838