Repository: xbmc/xbmc
File: xbmc/cores/RetroPlayer/rendering/VideoRenderers/RPBaseRenderer.cpp (C++)

Code before:

  // Get screen parameters
  float screenWidth;
  float screenHeight;
  float screenPixelRatio;
  GetScreenDimensions(screenWidth, screenHeight, screenPixelRatio);
  CRect viewRect = m_context.GetViewWindow();
  CRect destRect;
  float pixelRatio = 1.0f;
  float zoomAmount = 1.0f;
  m_sourceRect.x1 = 0.0f;
  m_sourceRect.y1 = 0.0f;
  m_sourceRect.x2 = static_cast<float>(sourceWidth);
  m_sourceRect.y2 = static_cast<float>(sourceHeight);
  if (scaleMode == SCALINGMETHOD::DISPLAY && stretchMode == STRETCHMODE::Original && bhw_filter)
  {
    RESOLUTION_INFO m_gameRes=m_context.GetResInfo();
    m_gameRes.Overscan.left = 0;
    m_gameRes.Overscan.top = 0;
    m_gameRes.Overscan.right = sourceWidth;
    m_gameRes.Overscan.bottom = sourceHeight;
    m_gameRes.iWidth = sourceWidth;
    m_gameRes.iHeight = sourceHeight;
    m_gameRes.iScreenWidth = sourceWidth;
    m_gameRes.iScreenHeight = sourceHeight;
    CServiceBroker::GetWinSystem()->SetFullScreen(true,  m_gameRes, false);

    screenWidth = sourceWidth;
    screenHeight = sourceHeight;
    screenPixelRatio = 1.0;
    viewRect.x1 =0;
    viewRect.y1 =0;
    viewRect.x2 =sourceWidth;
    viewRect.y2 =sourceHeight;
    CRenderUtils::CalculateStretchMode(stretchMode, rotationDegCCW, sourceWidth, sourceHeight,
                                       screenWidth, screenHeight, pixelRatio, zoomAmount);
    CRenderUtils::CalcNormalRenderRect(viewRect, sourceAspectRatio * pixelRatio, zoomAmount,destRect);
    if (!(m_context.IsFullScreenVideo() || m_context.IsCalibrating()))
      CRenderUtils::ClipRect(viewRect, m_sourceRect, destRect);
    m_rotatedDestCoords = CRenderUtils::ReorderDrawPoints(destRect, rotationDegCCW);
  }
  else
  {
    // Calculate pixel ratio and zoom amount
    CRenderUtils::CalculateStretchMode(stretchMode, rotationDegCCW, sourceWidth, sourceHeight,
                                       screenWidth, screenHeight, pixelRatio, zoomAmount);

    // Calculate destination dimensions
    CRect destRect;
    CRenderUtils::CalcNormalRenderRect(viewRect, sourceAspectRatio * pixelRatio, zoomAmount,
                                       destRect);

Review comment (suggestion):
Is it safe to set the system to fullscreen 60 times per second? A function named `ManageRenderArea()` which does just geometry calculations shouldn't call into an external system or have non-render-geometry related side effects.

Code after:
  if (scaleMode == SCALINGMETHOD::NEAREST && stretchMode == STRETCHMODE::Original &&
      m_context.DisplayHardwareScalingEnabled())
  {
    screenWidth = sourceWidth;
    screenHeight = sourceHeight;
    screenPixelRatio = 1.0;
  }
  else
  {
    GetScreenDimensions(screenWidth, screenHeight, screenPixelRatio);
  }

  // Entire target rendering area for the video (including black bars)
  const CRect viewRect = m_context.GetViewWindow();

  // Calculate pixel ratio and zoom amount
  float pixelRatio = 1.0f;
  float zoomAmount = 1.0f;
  CRenderUtils::CalculateStretchMode(stretchMode, rotationDegCCW, sourceWidth, sourceHeight,
                                     screenWidth, screenHeight, pixelRatio, zoomAmount);

  // Calculate destination dimensions
  CRect destRect;
  CRenderUtils::CalcNormalRenderRect(viewRect, sourceAspectRatio * pixelRatio, zoomAmount,
                                     destRect);

  m_sourceRect.x1 = 0.0f;
  m_sourceRect.y1 = 0.0f;
  m_sourceRect.x2 = static_cast<float>(sourceWidth);
  m_sourceRect.y2 = static_cast<float>(sourceHeight);

  // Clip as needed
  if (!(m_context.IsFullScreenVideo() || m_context.IsCalibrating()))
    CRenderUtils::ClipRect(viewRect, m_sourceRect, destRect);

  // Adapt the drawing rect points if we have to rotate
  m_rotatedDestCoords = CRenderUtils::ReorderDrawPoints(destRect, rotationDegCCW);
}

void CRPBaseRenderer::MarkDirty()
{
  // CServiceBroker::GetGUI()->GetWindowManager().MarkDirty(m_dimensions); //! @todo
}

void CRPBaseRenderer::PreRender(bool clear)
{
  if (!m_bConfigured)
    return;

  // Clear screen
  if (clear)