Пример #1
0
void CGraphicContext::SetVideoResolution(RESOLUTION res, bool forceUpdate)
{
  RESOLUTION lastRes = m_Resolution;

  // If the user asked us to guess, go with desktop
  if (res == RES_AUTORES || !IsValidResolution(res))
  {
    res = RES_DESKTOP;
  }

  // If we are switching to the same resolution and same window/full-screen, no need to do anything
  if (!forceUpdate && res == lastRes && m_bFullScreenRoot == g_advancedSettings.m_fullScreen)
  {
    return;
  }

  //only pause when switching monitor resolution/refreshrate,
  //not when switching between fullscreen and windowed or when resizing the window
  if ((res != RES_DESKTOP && res != RES_WINDOW) || (lastRes != RES_DESKTOP && lastRes != RES_WINDOW))
  {
    //pause the player during the refreshrate change
    int delay = CSettings::Get().GetInt("videoplayer.pauseafterrefreshchange");
    if (delay > 0 && CSettings::Get().GetInt("videoplayer.adjustrefreshrate") != ADJUST_REFRESHRATE_OFF && g_application.m_pPlayer->IsPlayingVideo() && !g_application.m_pPlayer->IsPausedPlayback())
    {
      g_application.m_pPlayer->Pause();
      ThreadMessage msg = {TMSG_MEDIA_UNPAUSE};
      CDelayedMessage* pauseMessage = new CDelayedMessage(msg, delay * 100);
      pauseMessage->Create(true);
    }
  }

  if (res >= RES_DESKTOP)
  {
    g_advancedSettings.m_fullScreen = true;
    m_bFullScreenRoot = true;
  }
  else
  {
    g_advancedSettings.m_fullScreen = false;
    m_bFullScreenRoot = false;
  }

  Lock();

  RESOLUTION_INFO info_org  = CDisplaySettings::Get().GetResolutionInfo(res);
  RESOLUTION_INFO info_last = CDisplaySettings::Get().GetResolutionInfo(lastRes);

  RENDER_STEREO_MODE stereo_mode = m_stereoMode;

  // if the new mode is an actual stereo mode, switch to that
  // if the old mode was an actual stereo mode, switch to no 3d mode
  if (info_org.dwFlags & D3DPRESENTFLAG_MODE3DTB)
    stereo_mode = RENDER_STEREO_MODE_SPLIT_HORIZONTAL;
  else if (info_org.dwFlags & D3DPRESENTFLAG_MODE3DSBS)
    stereo_mode = RENDER_STEREO_MODE_SPLIT_VERTICAL;
  else if ((info_last.dwFlags & D3DPRESENTFLAG_MODE3DSBS) != 0
        || (info_last.dwFlags & D3DPRESENTFLAG_MODE3DTB)  != 0)
    stereo_mode = RENDER_STEREO_MODE_OFF;

  if(stereo_mode != m_stereoMode)
  {
    m_stereoView     = RENDER_STEREO_VIEW_OFF;
    m_stereoMode     = stereo_mode;
    m_nextStereoMode = stereo_mode;
    CSettings::Get().SetInt("videoscreen.stereoscopicmode", (int)m_stereoMode);
  }

  RESOLUTION_INFO info_mod = GetResInfo(res);

  m_iScreenWidth  = info_mod.iWidth;
  m_iScreenHeight = info_mod.iHeight;
  m_iScreenId     = info_mod.iScreen;
  m_scissors.SetRect(0, 0, (float)m_iScreenWidth, (float)m_iScreenHeight);
  m_Resolution    = res;

  //tell the videoreferenceclock that we're about to change the refreshrate
  g_VideoReferenceClock.RefreshChanged();

  if (g_advancedSettings.m_fullScreen)
  {
#if defined (TARGET_DARWIN) || defined (TARGET_WINDOWS)
    bool blankOtherDisplays = CSettings::Get().GetBool("videoscreen.blankdisplays");
    g_Windowing.SetFullScreen(true,  info_org, blankOtherDisplays);
#else
    g_Windowing.SetFullScreen(true,  info_org, false);
#endif
  }
  else if (lastRes >= RES_DESKTOP )
    g_Windowing.SetFullScreen(false, info_org, false);
  else
    g_Windowing.ResizeWindow(info_org.iWidth, info_org.iHeight, -1, -1);

  // make sure all stereo stuff are correctly setup
  SetStereoView(RENDER_STEREO_VIEW_OFF);

  // update anyone that relies on sizing information
  g_renderManager.Recover();
  g_Mouse.SetResolution(info_org.iWidth, info_org.iHeight, 1, 1);
  g_windowManager.SendMessage(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_WINDOW_RESIZE);

  Unlock();
}
Пример #2
0
void CGraphicContext::SetVideoResolutionInternal(RESOLUTION res, bool forceUpdate)
{
  RESOLUTION lastRes = m_Resolution;

  // If the user asked us to guess, go with desktop
  if (res == RES_AUTORES || !IsValidResolution(res))
  {
    res = RES_DESKTOP;
  }

  // If we are switching to the same resolution and same window/full-screen, no need to do anything
  if (!forceUpdate && res == lastRes && m_bFullScreenRoot == g_advancedSettings.m_fullScreen)
  {
    return;
  }

  //only pause when switching monitor resolution/refreshrate,
  //not when switching between fullscreen and windowed or when resizing the window
  if ((res != RES_DESKTOP && res != RES_WINDOW) || (lastRes != RES_DESKTOP && lastRes != RES_WINDOW))
  {
    //pause the player during the refreshrate change
    int delay = CSettings::GetInstance().GetInt(CSettings::SETTING_VIDEOPLAYER_PAUSEAFTERREFRESHCHANGE);
    if (delay > 0 && CSettings::GetInstance().GetInt(CSettings::SETTING_VIDEOPLAYER_ADJUSTREFRESHRATE) != ADJUST_REFRESHRATE_OFF && g_application.m_pPlayer->IsPlayingVideo() && !g_application.m_pPlayer->IsPausedPlayback())
    {
      g_application.m_pPlayer->Pause();
      KODI::MESSAGING::ThreadMessage msg{TMSG_MEDIA_UNPAUSE};
      CDelayedMessage* pauseMessage = new CDelayedMessage(msg, delay * 100);
      pauseMessage->Create(true);
    }
  }

  if (res >= RES_DESKTOP)
  {
    g_advancedSettings.m_fullScreen = true;
    m_bFullScreenRoot = true;
  }
  else
  {
    g_advancedSettings.m_fullScreen = false;
    m_bFullScreenRoot = false;
  }

  Lock();

  RESOLUTION_INFO info_org  = CDisplaySettings::GetInstance().GetResolutionInfo(res);

  RESOLUTION_INFO info_mod = GetResInfo(res);

  m_iScreenWidth  = info_mod.iWidth;
  m_iScreenHeight = info_mod.iHeight;
  m_iScreenId     = info_mod.iScreen;
  m_scissors.SetRect(0, 0, (float)m_iScreenWidth, (float)m_iScreenHeight);
  m_Resolution    = res;
  m_fFPSOverride = 0 ;

  if (g_advancedSettings.m_fullScreen)
  {
#if defined (TARGET_DARWIN) || defined (TARGET_WINDOWS)
    bool blankOtherDisplays = CSettings::GetInstance().GetBool(CSettings::SETTING_VIDEOSCREEN_BLANKDISPLAYS);
    g_Windowing.SetFullScreen(true,  info_org, blankOtherDisplays);
#else
    g_Windowing.SetFullScreen(true,  info_org, false);
#endif
  }
  else if (lastRes >= RES_DESKTOP )
    g_Windowing.SetFullScreen(false, info_org, false);
  else
    g_Windowing.ResizeWindow(info_org.iWidth, info_org.iHeight, -1, -1);

  //tell the videoreferenceclock that we changed the refreshrate
  g_VideoReferenceClock.RefreshChanged();

  // make sure all stereo stuff are correctly setup
  SetStereoView(RENDER_STEREO_VIEW_OFF);

  // update anyone that relies on sizing information
  CInputManager::GetInstance().SetMouseResolution(info_org.iWidth, info_org.iHeight, 1, 1);
  g_windowManager.SendMessage(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_WINDOW_RESIZE);

  Unlock();
}
Пример #3
0
void CGraphicContext::SetVideoResolution(RESOLUTION res, bool forceUpdate)
{
  RESOLUTION lastRes = m_Resolution;

  // If the user asked us to guess, go with desktop
  if (res == RES_AUTORES || !IsValidResolution(res))
  {
    res = RES_DESKTOP;
  }

  // If we are switching to the same resolution and same window/full-screen, no need to do anything
  if (!forceUpdate && res == lastRes && m_bFullScreenRoot == g_advancedSettings.m_fullScreen)
  {
    return;
  }

  //only pause when switching monitor resolution/refreshrate,
  //not when switching between fullscreen and windowed or when resizing the window
  if ((res != RES_DESKTOP && res != RES_WINDOW) || (lastRes != RES_DESKTOP && lastRes != RES_WINDOW))
  {
    //pause the player during the refreshrate change
    int delay = CSettings::Get().GetInt("videoplayer.pauseafterrefreshchange");
    if (delay > 0 && CSettings::Get().GetInt("videoplayer.adjustrefreshrate") != ADJUST_REFRESHRATE_OFF && g_application.IsPlayingVideo() && !g_application.IsPaused())
    {
      g_application.m_pPlayer->Pause();
      ThreadMessage msg = {TMSG_MEDIA_UNPAUSE};
      CDelayedMessage* pauseMessage = new CDelayedMessage(msg, delay * 100);
      pauseMessage->Create(true);
    }
  }

  if (res >= RES_DESKTOP)
  {
    g_advancedSettings.m_fullScreen = true;
    m_bFullScreenRoot = true;
  }
  else
  {
    g_advancedSettings.m_fullScreen = false;
    m_bFullScreenRoot = false;
  }

  Lock();

  m_iScreenWidth  = CDisplaySettings::Get().GetResolutionInfo(res).iWidth;
  m_iScreenHeight = CDisplaySettings::Get().GetResolutionInfo(res).iHeight;
  m_iScreenId     = CDisplaySettings::Get().GetResolutionInfo(res).iScreen;
  m_scissors.SetRect(0, 0, (float)m_iScreenWidth, (float)m_iScreenHeight);
  m_Resolution    = res;

  //tell the videoreferenceclock that we're about to change the refreshrate
  g_VideoReferenceClock.RefreshChanged();

  if (g_advancedSettings.m_fullScreen)
  {
#if defined (TARGET_DARWIN) || defined (_WIN32)
    bool blankOtherDisplays = CSettings::Get().GetBool("videoscreen.blankdisplays");
    g_Windowing.SetFullScreen(true,  CDisplaySettings::Get().GetResolutionInfo(res), blankOtherDisplays);
#else
    g_Windowing.SetFullScreen(true,  CDisplaySettings::Get().GetResolutionInfo(res), false);
#endif
  }
  else if (lastRes >= RES_DESKTOP )
    g_Windowing.SetFullScreen(false, CDisplaySettings::Get().GetResolutionInfo(res), false);
  else
    g_Windowing.ResizeWindow(m_iScreenWidth, m_iScreenHeight, -1, -1);

  // update anyone that relies on sizing information
  g_renderManager.Recover();
  g_Mouse.SetResolution(m_iScreenWidth, m_iScreenHeight, 1, 1);
  g_windowManager.SendMessage(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_WINDOW_RESIZE);

  Unlock();
}
Пример #4
0
void CGraphicContext::SetVideoResolution(RESOLUTION res, bool forceUpdate)
{
  RESOLUTION lastRes = m_Resolution;

  // If the user asked us to guess, go with desktop
  if (res == RES_AUTORES || !IsValidResolution(res))
  {
    res = RES_DESKTOP;
  }

  // If we are switching to the same resolution and same window/full-screen, no need to do anything
  if (!forceUpdate && res == lastRes && m_bFullScreenRoot == g_advancedSettings.m_fullScreen)
  {
    return;
  }

  //pause the player during the refreshrate change
  int delay = g_guiSettings.GetInt("videoplayer.pauseafterrefreshchange");
  if (delay > 0 && g_guiSettings.GetBool("videoplayer.adjustrefreshrate") && g_application.IsPlayingVideo() && !g_application.IsPaused())
  {
    g_application.m_pPlayer->Pause();
    ThreadMessage msg = {TMSG_MEDIA_UNPAUSE};
    CDelayedMessage* pauseMessage = new CDelayedMessage(msg, delay * 500);
    pauseMessage->Create(true);
  }

  if (res >= RES_DESKTOP)
  {
    g_advancedSettings.m_fullScreen = true;
    m_bFullScreenRoot = true;
  }
  else
  {
    g_advancedSettings.m_fullScreen = false;
    m_bFullScreenRoot = false;
  }

  Lock();

  m_iScreenWidth  = g_settings.m_ResInfo[res].iWidth;
  m_iScreenHeight = g_settings.m_ResInfo[res].iHeight;
  m_iScreenId     = g_settings.m_ResInfo[res].iScreen;
  m_Resolution    = res;

  //tell the videoreferenceclock that we're about to change the refreshrate
  g_VideoReferenceClock.RefreshChanged();

  if (g_advancedSettings.m_fullScreen)
  {
#if defined (__APPLE__) || defined (_WIN32)
    bool blankOtherDisplays = g_guiSettings.GetBool("videoscreen.blankdisplays");
    g_Windowing.SetFullScreen(true,  g_settings.m_ResInfo[res], blankOtherDisplays);
#else
    g_Windowing.SetFullScreen(true,  g_settings.m_ResInfo[res], false);
#endif
  }
  else if (lastRes >= RES_DESKTOP )
    g_Windowing.SetFullScreen(false, g_settings.m_ResInfo[res], false);
  else
    g_Windowing.ResizeWindow(m_iScreenWidth, m_iScreenHeight, -1, -1);

  // update anyone that relies on sizing information
  g_renderManager.Recover();
  g_Mouse.SetResolution(m_iScreenWidth, m_iScreenHeight, 1, 1);
  g_windowManager.SendMessage(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_WINDOW_RESIZE);

  Unlock();
}