Repository: xbmc/xbmc
File: xbmc/rendering/dx/RenderSystemDX.cpp (C++)

Code before:
  }

  if (pRTView)
  {
    const auto outputSize = m_deviceResources->GetOutputSize();
    CRect clRect(0.0f, 0.0f, static_cast<float>(outputSize.Width),
                 static_cast<float>(outputSize.Height));

    // Unlike Direct3D 9, D3D11 ClearRenderTargetView always clears full extent of the resource view.
    // Viewport and scissor settings are not applied. So clear RT by drawing full sized rect with clear color
    if (m_ScissorsEnabled && m_scissor != clRect)
    {
      bool alphaEnabled = m_BlendEnabled;
      if (alphaEnabled)
        SetAlphaBlendEnable(false);

      CGUITextureD3D::DrawQuad(clRect, color);

      if (alphaEnabled)
        SetAlphaBlendEnable(true);
    }
    else
      m_deviceResources->ClearRenderTarget(pRTView, fColor);
  }

  if (CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_guiFrontToBackRendering)
    m_deviceResources->ClearDepthStencil();

  return true;
}

void CRenderSystemDX::CaptureStateBlock()
{
  if (!m_bRenderCreated)
    return;
}

void CRenderSystemDX::ApplyStateBlock()
{
  if (!m_bRenderCreated)
    return;

  auto m_pContext = m_deviceResources->GetD3DContext();

  m_pContext->RSSetState(m_ScissorsEnabled ? m_RSScissorEnable.Get() : m_RSScissorDisable.Get());
  m_pContext->OMSetDepthStencilState(GetDepthStencilState().Get(), 0);
  float factors[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
  m_pContext->OMSetBlendState(m_BlendEnabled ? m_BlendEnableState.Get() : m_BlendDisableState.Get(),
                              factors, 0xFFFFFFFF);

  m_pGUIShader->ApplyStateBlock();

Review comment (performance):
This setting seems should be cached as member variable and initialized only one time somewhere, maybe `InitRenderSystem()`

Code after:
  }

  if (pRTView)
  {
    const auto outputSize = m_deviceResources->GetOutputSize();
    CRect clRect(0.0f, 0.0f, static_cast<float>(outputSize.Width),
                 static_cast<float>(outputSize.Height));

    // Unlike Direct3D 9, D3D11 ClearRenderTargetView always clears full extent of the resource view.
    // Viewport and scissor settings are not applied. So clear RT by drawing full sized rect with clear color
    if (m_ScissorsEnabled && m_scissor != clRect)
    {
      bool alphaEnabled = m_BlendEnabled;
      if (alphaEnabled)
        SetAlphaBlendEnable(false);

      CGUITextureD3D::DrawQuad(clRect, color);

      if (alphaEnabled)
        SetAlphaBlendEnable(true);
    }
    else
      m_deviceResources->ClearRenderTarget(pRTView, fColor);
  }

  if (CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_guiFrontToBackRendering)
    m_deviceResources->ClearDepthStencil();

  return true;
}

void CRenderSystemDX::CaptureStateBlock()
{
  if (!m_bRenderCreated)
    return;
}

void CRenderSystemDX::ApplyStateBlock()
{
  if (!m_bRenderCreated)
    return;

  auto m_pContext = m_deviceResources->GetD3DContext();

  m_pContext->RSSetState(m_ScissorsEnabled ? m_RSScissorEnable.Get() : m_RSScissorDisable.Get());
  m_pContext->OMSetDepthStencilState(GetDepthStencilState(), 0);
  float factors[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
  m_pContext->OMSetBlendState(m_BlendEnabled ? m_BlendEnableState.Get() : m_BlendDisableState.Get(),
                              factors, 0xFFFFFFFF);

  m_pGUIShader->ApplyStateBlock();