Repository: xbmc/xbmc
File: xbmc/guilib/GUIWindowManager.cpp (C++)

Code before:
  if (pWindow)
    pWindow->RenderEx();

  // We don't call RenderEx for now on dialogs since it is used
  // to trigger non gui video rendering. We can activate it later at any time.
  /*
  vector<CGUIWindow *> &activeDialogs = m_activeDialogs;
  for (iDialog it = activeDialogs.begin(); it != activeDialogs.end(); ++it)
  {
    if ((*it)->IsDialogRunning())
      (*it)->RenderEx();
  }
  */
}

bool CGUIWindowManager::Render()
{
  assert(CServiceBroker::GetAppMessenger()->IsProcessThread());
  CSingleExit lock(CServiceBroker::GetWinSystem()->GetGfxContext());

  int bufferAge = CServiceBroker::GetWinSystem()->GetBufferAge() + 1;
  bool visualizeDirtyRegions =
      CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_guiVisualizeDirtyRegions;
  if (visualizeDirtyRegions)
    bufferAge = 20;
  if (bufferAge)
    m_tracker.CleanMarkedRegions(bufferAge);

  CDirtyRegionList dirtyRegions = m_tracker.GetDirtyRegions();
  CServiceBroker::GetWinSystem()->SetDirtyRegions(dirtyRegions);

  bool hasRendered = false;
  // If we visualize the regions we will always render the entire viewport
  // If the buffer age is zero, the current content is undefined and has to be rendered
  if (visualizeDirtyRegions || bufferAge == 0 ||
      CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_guiAlgorithmDirtyRegions ==
          DIRTYREGION_SOLVER_FILL_VIEWPORT_ALWAYS)
  {
    RenderPass();
    hasRendered = true;
  }
  else if (CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_guiAlgorithmDirtyRegions == DIRTYREGION_SOLVER_FILL_VIEWPORT_ON_CHANGE)
  {
    if (!dirtyRegions.empty())
    {
      RenderPass();
      hasRendered = true;
    }
  }
  else
  {

Review comment (suggestion):
I assume `GetBufferAge()` returns a value `>=0` so this check shouldn't be necessary? If true then the same for the `bufferAge == 0` check below.

Code after:
  if (pWindow)
    pWindow->RenderEx();

  // We don't call RenderEx for now on dialogs since it is used
  // to trigger non gui video rendering. We can activate it later at any time.
  /*
  vector<CGUIWindow *> &activeDialogs = m_activeDialogs;
  for (iDialog it = activeDialogs.begin(); it != activeDialogs.end(); ++it)
  {
    if ((*it)->IsDialogRunning())
      (*it)->RenderEx();
  }
  */
}

bool CGUIWindowManager::Render()
{
  assert(CServiceBroker::GetAppMessenger()->IsProcessThread());
  CSingleExit lock(CServiceBroker::GetWinSystem()->GetGfxContext());

  int bufferAge = CServiceBroker::GetWinSystem()->GetBufferAge();
  bool visualizeDirtyRegions =
      CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_guiVisualizeDirtyRegions;
  if (visualizeDirtyRegions)
    bufferAge = 20;
  if (bufferAge)
    m_tracker.CleanMarkedRegions(bufferAge + 1);
  else
    m_tracker.CleanMarkedRegions(10);

  CDirtyRegionList dirtyRegions = m_tracker.GetDirtyRegions();
  CServiceBroker::GetWinSystem()->SetDirtyRegions(dirtyRegions);

  bool hasRendered = false;
  // If we visualize the regions we will always render the entire viewport
  // If the buffer age is zero, the current content is undefined and has to be rendered
  if (visualizeDirtyRegions || bufferAge == 0 ||
      CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_guiAlgorithmDirtyRegions ==
          DIRTYREGION_SOLVER_FILL_VIEWPORT_ALWAYS)
  {
    RenderPass();
    hasRendered = true;
  }
  else if (CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_guiAlgorithmDirtyRegions == DIRTYREGION_SOLVER_FILL_VIEWPORT_ON_CHANGE)
  {
    if (!dirtyRegions.empty())
    {
      RenderPass();
      hasRendered = true;
    }
  }