Beispiel #1
0
void CDebugRenderer::CRenderer::Render(int idx)
{
  std::vector<COverlay*> render;
  std::vector<SElement>& list = m_buffers[idx];
  int posY = 0;
  for (std::vector<SElement>::iterator it = list.begin(); it != list.end(); ++it)
  {
    COverlay* o = nullptr;

    if (it->overlay_dvd)
      o = Convert(it->overlay_dvd, it->pts);

    if (!o)
      continue;

    COverlayText *text = dynamic_cast<COverlayText*>(o);
    if (text)
      text->PrepareRender("arial.ttf", 1, 12, 0, m_font, m_fontBorder);

    o->m_pos = COverlay::POSITION_ABSOLUTE;
    o->m_align = COverlay::ALIGN_SCREEN;
    o->m_x = 10 + o->m_width / 2;
    o->m_y = posY + o->m_height;
    OVERLAY::CRenderer::Render(o, 0);

    posY = o->m_y;
  }

  ReleaseUnused();
}
Beispiel #2
0
void CRenderer::Render(int idx)
{
  CSingleLock lock(m_section);

  std::vector<COverlay*> render;
  std::vector<SElement>& list = m_buffers[idx];
  for(std::vector<SElement>::iterator it = list.begin(); it != list.end(); ++it)
  {
    COverlay* o = NULL;

    if(it->overlay_dvd)
      o = Convert(it->overlay_dvd, it->pts);

    if(!o)
      continue;

    render.push_back(o);
  }

  const std::shared_ptr<CSettings> settings = CServiceBroker::GetSettingsComponent()->GetSettings();

  float total_height = 0.0f;
  float cur_height = 0.0f;
  int subalign = settings->GetInt(CSettings::SETTING_SUBTITLES_ALIGN);
  for (std::vector<COverlay*>::iterator it = render.begin(); it != render.end(); ++it)
  {
    COverlay* o = nullptr;
    COverlayText *text = dynamic_cast<COverlayText*>(*it);
    if (text)
    {
      
      // Compute the color to be used for the overlay background (depending on the opacity)
      UTILS::Color bgcolor = bgcolors[settings->GetInt(CSettings::SETTING_SUBTITLES_BGCOLOR)];
      int bgopacity = settings->GetInt(CSettings::SETTING_SUBTITLES_BGOPACITY);
      if (bgopacity > 0 && bgopacity < 100)
      {
        bgcolor = ColorUtils::ChangeOpacity(bgcolor, bgopacity / 100.0f);
      }
      else if (bgopacity == 0)
      {
        bgcolor = UTILS::COLOR::NONE;
      }
      
      text->PrepareRender(settings->GetString(CSettings::SETTING_SUBTITLES_FONT),
                          settings->GetInt(CSettings::SETTING_SUBTITLES_COLOR),
                          settings->GetInt(CSettings::SETTING_SUBTITLES_HEIGHT),
                          settings->GetInt(CSettings::SETTING_SUBTITLES_STYLE),
                          m_font, m_fontBorder, bgcolor, m_rv);
      o = text;
    }
    else
    {
      o = *it;
      o->PrepareRender();
    }
    total_height += o->m_height;
  }

  for (std::vector<COverlay*>::iterator it = render.begin(); it != render.end(); ++it)
  {
    COverlay* o = *it;

    float adjust_height = 0.0f;

    if (o->m_type == COverlay::TYPE_GUITEXT)
    {
      if(subalign == SUBTITLE_ALIGN_TOP_INSIDE ||
         subalign == SUBTITLE_ALIGN_TOP_OUTSIDE)
      {
        adjust_height = cur_height;
        cur_height += o->m_height;
      }
      else
      {
        total_height -= o->m_height;
        adjust_height = -total_height;
      }
    }

    Render(o, adjust_height);
  }

  ReleaseUnused();
}
Beispiel #3
0
void CRenderer::Render(int idx)
{
  CSingleLock lock(m_section);

  std::vector<COverlay*> render;
  std::vector<SElement>& list = m_buffers[idx];
  for(std::vector<SElement>::iterator it = list.begin(); it != list.end(); ++it)
  {
    COverlay* o = NULL;

    if(it->overlay_dvd)
      o = Convert(it->overlay_dvd, it->pts);

    if(!o)
      continue;
 
    render.push_back(o);
  }

  float total_height = 0.0f;
  float cur_height = 0.0f;
  int subalign = CServiceBroker::GetSettings().GetInt(CSettings::SETTING_SUBTITLES_ALIGN);
  for (std::vector<COverlay*>::iterator it = render.begin(); it != render.end(); ++it)
  {
    COverlay* o = nullptr;
    COverlayText *text = dynamic_cast<COverlayText*>(*it);
    if (text)
    {
      text->PrepareRender(CServiceBroker::GetSettings().GetString(CSettings::SETTING_SUBTITLES_FONT),
                          CServiceBroker::GetSettings().GetInt(CSettings::SETTING_SUBTITLES_COLOR),
                          CServiceBroker::GetSettings().GetInt(CSettings::SETTING_SUBTITLES_HEIGHT),
                          CServiceBroker::GetSettings().GetInt(CSettings::SETTING_SUBTITLES_STYLE),
                          m_font, m_fontBorder);
      o = text;
    }
    else
    {
      o = *it;
      o->PrepareRender();
    }
    total_height += o->m_height;
  }

  for (std::vector<COverlay*>::iterator it = render.begin(); it != render.end(); ++it)
  {
    COverlay* o = *it;

    float adjust_height = 0.0f;

    if (o->m_type == COverlay::TYPE_GUITEXT)
    {
      if(subalign == SUBTITLE_ALIGN_TOP_INSIDE ||
         subalign == SUBTITLE_ALIGN_TOP_OUTSIDE)
      {
        adjust_height = cur_height;
        cur_height += o->m_height;
      }
      else
      {
        total_height -= o->m_height;
        adjust_height = -total_height;
      }
    }

    Render(o, adjust_height);
  }

  ReleaseUnused();
}