~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): Didier Roche
  • Date: 2011-06-22 17:16:16 UTC
  • mto: This revision was merged to the branch mainline in revision 33.
  • Revision ID: james.westby@ubuntu.com-20110622171616-49405ntrtnxfcpjj
Tags: upstream-1.0.2
ImportĀ upstreamĀ versionĀ 1.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
 
72
72
    _dnd_area                   = NULL;
73
73
 
74
 
    if (GetWindowThread ()->GetWindow ().HasFrameBufferSupport ())
 
74
    if (GetWindowThread()->GetWindow().HasFrameBufferSupport())
75
75
    {
76
 
      m_FrameBufferObject = GetGpuDevice ()->CreateFrameBufferObject ();
 
76
      m_FrameBufferObject = GetGraphicsDisplay()->GetGpuDevice()->CreateFrameBufferObject ();
77
77
      // Do not leave the Fbo binded. Deactivate it.
78
78
      m_FrameBufferObject->Deactivate ();
79
79
    }
80
80
 
81
81
    // At this stage, the size of the window may not be known yet.
82
82
    // FormatRenderTargets will be called the first time runtime gets into WindowThread::ExecutionLoop
83
 
    m_MainColorRT = GetGpuDevice()->CreateSystemCapableDeviceTexture (2, 2, 1, BITFMT_R8G8B8A8);
84
 
    m_MainDepthRT = GetGpuDevice()->CreateSystemCapableDeviceTexture (2, 2, 1, BITFMT_D24S8);
 
83
    m_MainColorRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture (2, 2, 1, BITFMT_R8G8B8A8);
 
84
    m_MainDepthRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture (2, 2, 1, BITFMT_D24S8);
85
85
 
86
86
    m_MenuList = new std::list<MenuPage*>;
87
87
    m_PopupRemoved = false;
168
168
      // Don't size the texture to the dimension of the window yet. this will be done later.
169
169
      if (GetWindowThread ()->GetWindow().HasFrameBufferSupport() )
170
170
      {
171
 
        rt.color_rt = GetGpuDevice()->CreateSystemCapableDeviceTexture (2, 2, 1, BITFMT_R8G8B8A8);
172
 
        rt.depth_rt = GetGpuDevice()->CreateSystemCapableDeviceTexture (2, 2, 1, BITFMT_D24S8);
 
171
        rt.color_rt = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture (2, 2, 1, BITFMT_R8G8B8A8);
 
172
        rt.depth_rt = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture (2, 2, 1, BITFMT_D24S8);
173
173
      }
174
174
 
175
175
      _window_to_texture_map.insert ( std::map< BaseWindow*, RenderTargetTextures >::value_type ( window, rt) );
865
865
          if (!GetWindowThread ()->IsEmbeddedWindow() )
866
866
            RenderMainWindowComposition (true, true);
867
867
 
868
 
          if (1 /*GetGpuDevice()->GetGraphicsBoardVendor() != BOARD_INTEL*/)
 
868
          if (1 /*GetGraphicsDisplay()->GetGpuDevice()->GetGraphicsBoardVendor() != BOARD_INTEL*/)
869
869
          {
870
870
            RenderTopViews (true, _view_window_list, false, true);
871
871
            RenderTopViews (true, _modal_view_window_list, true, true);
882
882
          if (!GetWindowThread ()->IsEmbeddedWindow() )
883
883
            RenderMainWindowComposition (false, true);
884
884
 
885
 
          if (1 /*GetGpuDevice()->GetGraphicsBoardVendor() != BOARD_INTEL*/)
 
885
          if (1 /*GetGraphicsDisplay()->GetGpuDevice()->GetGraphicsBoardVendor() != BOARD_INTEL*/)
886
886
          {
887
887
            RenderTopViews (false, _view_window_list, false, true);
888
888
            RenderTopViews (false, _modal_view_window_list, true, true);
897
897
          if (!GetWindowThread ()->IsEmbeddedWindow() )
898
898
            RenderMainWindowComposition (false, true);
899
899
 
900
 
          if (1 /*GetGpuDevice()->GetGraphicsBoardVendor() != BOARD_INTEL*/)
 
900
          if (1 /*GetGraphicsDisplay()->GetGpuDevice()->GetGraphicsBoardVendor() != BOARD_INTEL*/)
901
901
          {
902
902
            RenderTopViews (false, _view_window_list, false, true);
903
903
            RenderTopViews (false, _modal_view_window_list, true, true);
982
982
      SetProcessingTopView (NULL);
983
983
    }
984
984
 
985
 
//     GetThreadGraphicsContext()->SetContext (0, 0,
 
985
//     GetGraphicsDisplay()->GetGraphicsEngine()->SetContext (0, 0,
986
986
//                                             GetWindowThread ()->GetGraphicsEngine().GetWindowWidth(),
987
987
//                                             GetWindowThread ()->GetGraphicsEngine().GetWindowHeight() );
988
988
  }
1009
1009
      SetProcessingTopView (NULL);
1010
1010
    }
1011
1011
 
1012
 
    //GetThreadGraphicsContext()->SetContext (0, 0, buffer_width, buffer_height);
 
1012
    //GetGraphicsDisplay()->GetGraphicsEngine()->SetContext (0, 0, buffer_width, buffer_height);
1013
1013
  }
1014
1014
 
1015
1015
  void WindowCompositor::DrawTooltip (bool force_draw)
1035
1035
        //SetProcessingTopView(NULL);
1036
1036
    }
1037
1037
 
1038
 
    //GetThreadGraphicsContext()->SetContext (0, 0, buffer_width, buffer_height);
 
1038
    //GetGraphicsDisplay()->GetGraphicsEngine()->SetContext (0, 0, buffer_width, buffer_height);
1039
1039
  }
1040
1040
 
1041
1041
  void WindowCompositor::RenderTopViewContent (BaseWindow *window, bool force_draw)
1083
1083
 
1084
1084
            if ( (rt.color_rt->GetWidth() != buffer_width) || (rt.color_rt->GetHeight() != buffer_height) )
1085
1085
            {
1086
 
              rt.color_rt = GetGpuDevice()->CreateSystemCapableDeviceTexture (buffer_width, buffer_height, 1, BITFMT_R8G8B8A8);
1087
 
              rt.depth_rt = GetGpuDevice()->CreateSystemCapableDeviceTexture (buffer_width, buffer_height, 1, BITFMT_D24S8);
 
1086
              rt.color_rt = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture (buffer_width, buffer_height, 1, BITFMT_R8G8B8A8);
 
1087
              rt.depth_rt = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture (buffer_width, buffer_height, 1, BITFMT_D24S8);
1088
1088
            }
1089
1089
 
1090
1090
            m_FrameBufferObject->FormatFrameBufferObject (buffer_width, buffer_height, BITFMT_R8G8B8A8);
1262
1262
 
1263
1263
      if ( (!m_MainColorRT.IsValid() ) || (!m_MainDepthRT.IsValid() ) || (m_MainColorRT->GetWidth() != buffer_width) || (m_MainColorRT->GetHeight() != buffer_height) )
1264
1264
      {
1265
 
        m_MainColorRT = GetGpuDevice()->CreateSystemCapableDeviceTexture (buffer_width, buffer_height, 1, BITFMT_R8G8B8A8);
1266
 
        m_MainDepthRT = GetGpuDevice()->CreateSystemCapableDeviceTexture (buffer_width, buffer_height, 1, BITFMT_D24S8);
 
1265
        m_MainColorRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture (buffer_width, buffer_height, 1, BITFMT_R8G8B8A8);
 
1266
        m_MainDepthRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture (buffer_width, buffer_height, 1, BITFMT_D24S8);
1267
1267
      }
1268
1268
 
1269
1269
      m_FrameBufferObject->FormatFrameBufferObject (buffer_width, buffer_height, BITFMT_R8G8B8A8);
1340
1340
 
1341
1341
    if ( (!m_MainColorRT.IsValid() ) || (m_MainColorRT->GetWidth() != buffer_width) || (m_MainColorRT->GetHeight() != buffer_height) )
1342
1342
    {
1343
 
      m_MainColorRT = GetGpuDevice()->CreateSystemCapableDeviceTexture (buffer_width, buffer_height, 1, BITFMT_R8G8B8A8);
 
1343
      m_MainColorRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture (buffer_width, buffer_height, 1, BITFMT_R8G8B8A8);
1344
1344
    }
1345
1345
 
1346
1346
    // Setup the Composition Render Target
1369
1369
    texxform.vscale = 1.0f;
1370
1370
    texxform.uwrap = TEXWRAP_REPEAT;
1371
1371
    texxform.vwrap = TEXWRAP_REPEAT;
1372
 
    GetWindowThread ()->GetGraphicsEngine().QRP_1Tex (x, y, TexWidth, TexHeight, HWTexture, texxform, Colors::White);
 
1372
    GetWindowThread ()->GetGraphicsEngine().QRP_1Tex (x, y, TexWidth, TexHeight, HWTexture, texxform, color::White);
1373
1373
  }
1374
1374
 
1375
1375
  void WindowCompositor::SetCompositionRT()
1380
1380
 
1381
1381
    if ( (!m_CompositionRT.IsValid() ) || (m_CompositionRT->GetWidth() != buffer_width) || (m_CompositionRT->GetHeight() != buffer_height) )
1382
1382
    {
1383
 
      m_CompositionRT = GetGpuDevice()->CreateSystemCapableDeviceTexture (buffer_width, buffer_height, 1, BITFMT_R8G8B8A8);
 
1383
      m_CompositionRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture (buffer_width, buffer_height, 1, BITFMT_R8G8B8A8);
1384
1384
    }
1385
1385
 
1386
1386
    // Setup the Composition Render Target
1409
1409
    texxform.vscale = 1.0f;
1410
1410
    texxform.uwrap = TEXWRAP_REPEAT;
1411
1411
    texxform.vwrap = TEXWRAP_REPEAT;
1412
 
    GetWindowThread ()->GetGraphicsEngine().QRP_1Tex (x, y, TexWidth, TexHeight, HWTexture, texxform, Colors::White);
 
1412
    GetWindowThread ()->GetGraphicsEngine().QRP_1Tex (x, y, TexWidth, TexHeight, HWTexture, texxform, color::White);
1413
1413
  }
1414
1414
 
1415
1415
  void WindowCompositor::PresentBufferToScreen (ObjectPtr<IOpenGLBaseTexture> HWTexture, int x, int y, bool RenderToMainTexture, bool BluredBackground, float opacity)
1435
1435
    }
1436
1436
    else
1437
1437
    {
1438
 
      GetGpuDevice()->DeactivateFrameBuffer();
 
1438
      GetGraphicsDisplay()->GetGpuDevice()->DeactivateFrameBuffer();
1439
1439
    }
1440
1440
 
1441
1441
    GetWindowThread()->GetGraphicsEngine().EmptyClippingRegion();
1458
1458
        GetWindowThread ()->GetGraphicsEngine().GetRenderStates().SetBlend (true, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1459
1459
      }
1460
1460
 
1461
 
      GetThreadGraphicsContext()->QRP_1Tex (x, y, src_width, src_height, HWTexture, texxform0, Color (1.0f, 1.0f, 1.0f, opacity));
 
1461
      GetGraphicsDisplay()->GetGraphicsEngine()->QRP_1Tex (x, y, src_width, src_height, HWTexture, texxform0, Color (1.0f, 1.0f, 1.0f, opacity));
1462
1462
      GetWindowThread ()->GetGraphicsEngine().GetRenderStates().SetBlend (false);
1463
1463
    }
1464
1464
  }
1624
1624
    Geometry geo = m_TooltipArea->GetGeometry();
1625
1625
    geo.OffsetPosition(_tooltip_window->GetBaseX(), _tooltip_window->GetBaseY());
1626
1626
 
1627
 
    return geo.IsPointInside(x, y);    
 
1627
    return geo.IsPointInside(x, y);
1628
1628
  }
1629
1629
 
1630
1630
  bool WindowCompositor::IsTooltipActive()
1639
1639
 
1640
1640
    if (area == 0)
1641
1641
    {
1642
 
      _event_root.Set (0, 0);
 
1642
      _event_root = Point(0, 0);
1643
1643
    }
1644
1644
    else
1645
1645
    {
1649
1649
 
1650
1650
    if (area)
1651
1651
      SetFocusAreaWindow (GetProcessingTopView ());
1652
 
    else 
 
1652
    else
1653
1653
      SetFocusAreaWindow (NULL);
1654
1654
  }
1655
1655
 
1770
1770
    nuxAssert (buffer_width >= 1);
1771
1771
    nuxAssert (buffer_height >= 1);
1772
1772
 
1773
 
    m_MainColorRT = GetGpuDevice()->CreateSystemCapableDeviceTexture (buffer_width, buffer_height, 1, BITFMT_R8G8B8A8);
1774
 
    m_CompositionRT = GetGpuDevice()->CreateSystemCapableDeviceTexture (buffer_width, buffer_height, 1, BITFMT_R8G8B8A8);
1775
 
    m_MainDepthRT = GetGpuDevice()->CreateSystemCapableDeviceTexture (buffer_width, buffer_height, 1, BITFMT_D24S8);
 
1773
    m_MainColorRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture (buffer_width, buffer_height, 1, BITFMT_R8G8B8A8);
 
1774
    m_CompositionRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture (buffer_width, buffer_height, 1, BITFMT_R8G8B8A8);
 
1775
    m_MainDepthRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture (buffer_width, buffer_height, 1, BITFMT_D24S8);
1776
1776
 
1777
1777
    // Clear the buffer the first time...
1778
1778
    m_FrameBufferObject->FormatFrameBufferObject (buffer_width, buffer_height, BITFMT_R8G8B8A8);
1790
1790
    CHECKGL ( glClearStencil (0) );
1791
1791
    CHECKGL ( glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT) );
1792
1792
 
1793
 
//     m_BlurTexture   = GetGpuDevice()->CreateSystemCapableDeviceTexture (Max (buffer_width, 1), Max (buffer_height, 1), 1, BITFMT_R8G8B8A8);
1794
 
//     m_FullSceneMip0 = GetGpuDevice()->CreateSystemCapableDeviceTexture (Max (buffer_width / 2, 1), Max (buffer_height / 2, 1), 1, BITFMT_R8G8B8A8);
1795
 
//     m_FullSceneMip1 = GetGpuDevice()->CreateSystemCapableDeviceTexture (Max (buffer_width / 4, 1), Max (buffer_height / 4, 1), 1, BITFMT_R8G8B8A8);
1796
 
//     m_FullSceneMip2 = GetGpuDevice()->CreateSystemCapableDeviceTexture (Max (buffer_width / 8, 1), Max (buffer_height / 8, 1), 1, BITFMT_R8G8B8A8);
 
1793
//     m_BlurTexture   = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture (Max (buffer_width, 1), Max (buffer_height, 1), 1, BITFMT_R8G8B8A8);
 
1794
//     m_FullSceneMip0 = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture (Max (buffer_width / 2, 1), Max (buffer_height / 2, 1), 1, BITFMT_R8G8B8A8);
 
1795
//     m_FullSceneMip1 = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture (Max (buffer_width / 4, 1), Max (buffer_height / 4, 1), 1, BITFMT_R8G8B8A8);
 
1796
//     m_FullSceneMip2 = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture (Max (buffer_width / 8, 1), Max (buffer_height / 8, 1), 1, BITFMT_R8G8B8A8);
1797
1797
  }
1798
1798
 
1799
1799
  void WindowCompositor::RestoreRenderingSurface ()
1814
1814
 
1815
1815
      if ((rt.color_rt->GetWidth () != buffer_width) || (rt.color_rt->GetHeight () != buffer_height))
1816
1816
      {
1817
 
        rt.color_rt = GetGpuDevice ()->CreateSystemCapableDeviceTexture (buffer_width, buffer_height, 1, BITFMT_R8G8B8A8);
1818
 
        rt.depth_rt = GetGpuDevice ()->CreateSystemCapableDeviceTexture (buffer_width, buffer_height, 1, BITFMT_D24S8);
 
1817
        rt.color_rt = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture (buffer_width, buffer_height, 1, BITFMT_R8G8B8A8);
 
1818
        rt.depth_rt = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture (buffer_width, buffer_height, 1, BITFMT_D24S8);
1819
1819
      }
1820
1820
 
1821
1821
      m_FrameBufferObject->FormatFrameBufferObject (buffer_width, buffer_height, BITFMT_R8G8B8A8);