Ejemplo n.º 1
0
static void osd_channellist_nownext_title(struct osd_t* osd)
{
  uint32_t row_space_y = 50;
  uint32_t x = nownext_win_x + PADDING_X;
  uint32_t y = nownext_win_y + PADDING_Y + row_space_y;
  uint32_t w = nownext_win_w - 2 * PADDING_X; 
  uint32_t h = nownext_win_h - 2 * PADDING_Y;
  uint32_t color;
  uint32_t bg_color = COLOR_BACKGROUND;
  uint32_t date_y = nownext_win_y + PADDING_Y;
  struct tm start_time;
  struct tm stop_time;
  struct event_t* event;
  char str[128];
  int i;
  int update_all;

  update_all = osd->model_now_next.event[0] != osd->model_now_next_current.event[0];
  if (update_all) {
    // clear window
    graphics_resource_fill(osd->img, x - 2, date_y - 5, w + 5, h + 20, COLOR_BACKGROUND);
  }
  
  /* Fixa scroll i nn window. Och endast uppdatera ändringar!! */
  
  for (i = 0; i < 11; i++) {  
    if (osd->model_now_next.event[i] > 0) {
      event = event_copy(osd->model_now_next.event[i], osd->model_now_next.server);
      if (event != NULL) {
        if (osd->model_now_next.selectedIndex == i) {
          color = COLOR_SELECTED_TEXT;
          if (osd->model_channellist.active == 0) {
            bg_color = COLOR_SELECTED_BACKGROUND; 
          }
        }
        else {
          color = COLOR_TEXT;
          bg_color = COLOR_BACKGROUND;
        }  
        
        if(update_all || i == osd->model_now_next.selectedIndex || i == osd->model_now_next_current.selectedIndex) { 
          localtime_r((time_t*)&event->start, &start_time);
          localtime_r((time_t*)&event->stop, &stop_time);
          snprintf(str, sizeof(str),"%02d:%02d - %02d:%02d %s", start_time.tm_hour,start_time.tm_min,stop_time.tm_hour,stop_time.tm_min, event->title);      
          osd_text(osd, x, y, w, row_space_y, color, bg_color, str);
          printf("Now: %s\n", str);
          
          if (i == osd->model_now_next.selectedIndex) {
            graphics_resource_fill(osd->img, x - 2, date_y - 5, w + 5, row_space_y, COLOR_BACKGROUND);
            snprintf(str, sizeof(str),"%s %d", day_str[start_time.tm_wday], start_time.tm_mday);      
            osd_text(osd, x, date_y, w, row_space_y, COLOR_SELECTED_TEXT, COLOR_BACKGROUND, str);            
          }  
        }  
        y += row_space_y;
      }
    }  
  }
}
Ejemplo n.º 2
0
void osd_draw_window(struct osd_t* osd, int x, int y, int width, int height)
{
   graphics_resource_fill(osd->img, x, y, width, height, GRAPHICS_RGBA32(0,0,0,0xC0));

   graphics_resource_fill(osd->img, x, y, width, 2, GRAPHICS_RGBA32(0xff,0xff,0xff,0xa0));
   graphics_resource_fill(osd->img, x, y+height-2, width, 2, GRAPHICS_RGBA32(0xff,0xff,0xff,0xa0));
   graphics_resource_fill(osd->img, x, y, 2, height, GRAPHICS_RGBA32(0xff,0xff,0xff,0xa0));
   graphics_resource_fill(osd->img, x+width-2, y, 2, height, GRAPHICS_RGBA32(0xff,0xff,0xff,0xa0));
}
Ejemplo n.º 3
0
void osd_init(struct osd_t* osd)
{
  uint32_t display_width, display_height;
  char str[2] = { 0, 0 };
  uint32_t width, height;
  int n;
  int s;

  s = gx_graphics_init(tiresias_pcfont, sizeof(tiresias_pcfont));
  assert(s == 0);

  s = graphics_get_display_size(0, &display_width, &display_height);
  osd->display_width = display_width;
  osd->display_height = display_height;

  printf("osd_init: %d %d\n", display_width, display_height);
  
  assert(s == 0);
  //fprintf(stderr,"Display width=%d, height=%d\n",display_width,display_height);

  /* The main OSD image */
  s = gx_create_window(SCREEN, display_width, display_height, GRAPHICS_RESOURCE_RGBA32, &osd->img);
  assert(s == 0);
  graphics_resource_fill(osd->img, 0, 0, display_width, display_height, GRAPHICS_RGBA32(0,0,0,0));

  graphics_display_resource(osd->img, 0, OSD_LAYER, 0, 0, GRAPHICS_RESOURCE_WIDTH, GRAPHICS_RESOURCE_HEIGHT, VC_DISPMAN_ROT0, 1);

  /* A full-screen black image to either remove any left-over console text (BG_LAYER) or to hide the video (FG_LAYER) */
  s = gx_create_window(SCREEN, display_width, display_height, GRAPHICS_RESOURCE_RGBA32, &osd->img_blank);
  assert(s == 0);
  graphics_resource_fill(osd->img_blank, 0, 0, display_width, display_height, GRAPHICS_RGBA32(0,0,0,255));

  graphics_display_resource(osd->img_blank, 0, BG_LAYER, 0, 0, GRAPHICS_RESOURCE_WIDTH, GRAPHICS_RESOURCE_HEIGHT, VC_DISPMAN_ROT0, 1);

  osd->video_blanked = 0;
  osd->osd_cleartime = 0.0;
  osd->last_now = time(NULL);
  
  pthread_mutex_init(&osd->osd_mutex,NULL);
   
  // cache font widths since graphics_resource_text_dimensions_ext is kind of slow
  for (n = 32; n < 256; n++) {
    str[0] = n;
    graphics_resource_text_dimensions_ext(osd->img, str, 1, &width, &height, 40); 
    fontWidth[n] = (uint8_t)width;
  }
    
  (void)s; // remove compiler warning
}
Ejemplo n.º 4
0
void osd_alert(struct osd_t* osd, char* text)
{
  uint32_t text_length;
  uint32_t width,height;
  uint32_t y_offset;
  uint32_t x_offset;
  uint32_t text_size = 40;

  pthread_mutex_lock(&osd->osd_mutex);

  /* TODO: Only clear alert area */
  graphics_resource_fill(osd->img, 0, 0, osd->display_width, osd->display_height, GRAPHICS_RGBA32(0,0,0,0));

  if (text) {
    fprintf(stderr,"[OSD ALERT]: %s\n",text);
    text_length = strlen(text);
    graphics_resource_text_dimensions_ext(osd->img, text, text_length, &width, &height, text_size);

    x_offset = ((1920 - width) / 2);
    y_offset = (1080 - height) / 2;

    osd_draw_window(osd,x_offset,y_offset,width+100,height+50);

    graphics_resource_render_text_ext(osd->img, x_offset+50, y_offset+25,
                                          width,
                                          height,
                                          GRAPHICS_RGBA32(0xff,0xff,0xff,0xff), /* fg */
                                          GRAPHICS_RGBA32(0,0,0,0x80), /* bg */
                                          text, text_length, text_size);
  }

  graphics_update_displayed_resource(osd->img, 0, 0, 0, 0);

  pthread_mutex_unlock(&osd->osd_mutex);
}
Ejemplo n.º 5
0
int main(void)
{
   GRAPHICS_RESOURCE_HANDLE img;
   uint32_t width, height;
   int LAYER=1;
   bcm_host_init();
   int s;

   s = gx_graphics_init(".");
   assert(s == 0);

   s = graphics_get_display_size(0, &width, &height);
   assert(s == 0);

   s = gx_create_window(0, width, height, GRAPHICS_RESOURCE_RGBA32, &img);
   assert(s == 0);

   // transparent before display to avoid screen flash
   graphics_resource_fill(img, 0, 0, width, height, GRAPHICS_RGBA32(0,0,0,0x00));

   graphics_display_resource(img, 0, LAYER, 0, 0, GRAPHICS_RESOURCE_WIDTH, GRAPHICS_RESOURCE_HEIGHT, VC_DISPMAN_ROT0, 1);

   uint32_t text_size = 10;
   while (1) {
      const char *text = "The quick brown fox jumps over the lazy dog";
      uint32_t y_offset = height-60+text_size/2;
      graphics_resource_fill(img, 0, 0, width, height, GRAPHICS_RGBA32(0,0,0,0x00));
      // blue, at the top (y=40)
      graphics_resource_fill(img, 0, 40, width, 1, GRAPHICS_RGBA32(0,0,0xff,0xff));

      // green, at the bottom (y=height-40)
      graphics_resource_fill(img, 0, height-40, width, 1, GRAPHICS_RGBA32(0,0xff,0,0xff));

      // draw the subtitle text
      render_subtitle(img, text, 0, text_size,  y_offset);
      graphics_update_displayed_resource(img, 0, 0, 0, 0);
      text_size += 1;
      if (text_size > 50)
         text_size = 10;
   }

   graphics_display_resource(img, 0, LAYER, 0, 0, GRAPHICS_RESOURCE_WIDTH, GRAPHICS_RESOURCE_HEIGHT, VC_DISPMAN_ROT0, 0);
   graphics_delete_resource(img);

   return 0;
}
Ejemplo n.º 6
0
void osd_clear_newchannel(struct osd_t* osd)
{
  /* TODO: Only clear channel area */

  pthread_mutex_lock(&osd->osd_mutex);
  graphics_resource_fill(osd->img, 0, 0, osd->display_width, osd->display_height, GRAPHICS_RGBA32(0,0,0,0));
  graphics_update_displayed_resource(osd->img, 0, 0, 0, 0);
  pthread_mutex_unlock(&osd->osd_mutex);

  fprintf(stderr,"Clearing OSD...\n");
}
Ejemplo n.º 7
0
void osd_clear(struct osd_t* osd)
{
  pthread_mutex_lock(&osd->osd_mutex);
  graphics_resource_fill(osd->img, 0, 0, osd->display_width, osd->display_height, GRAPHICS_RGBA32(0,0,0,0));
  graphics_update_displayed_resource(osd->img, 0, 0, 0, 0);
  pthread_mutex_unlock(&osd->osd_mutex);

  fprintf(stderr,"Clearing OSD...\n");

  osd->osd_state = OSD_NONE;
  osd->osd_cleartime = 0;
}
Ejemplo n.º 8
0
static void osd_channellist_event_info(struct osd_t* osd)
{
  uint32_t x = eventinfo_win_x + PADDING_X;
  uint32_t y = eventinfo_win_y + PADDING_Y;
  uint32_t w = eventinfo_win_w - 2 * PADDING_X; 
  uint32_t h = eventinfo_win_h - 2 * PADDING_Y;
  struct event_t* event;
  uint32_t event_id;
  
  // clear window
  graphics_resource_fill(osd->img, x - 2, y - 5, w + 5, h + 20, COLOR_BACKGROUND);

  event_id = osd->model_now_next.event[osd->model_now_next.selectedIndex];
  if (event_id > 0) {
    event = event_copy(event_id, osd->model_now_next.server);
    if (event != NULL) {
//      printf("eventinfo: %s\n", event->title);
//      printf("eventinfo: %s\n", event->description);
      osd_text(osd, x, y, w, 50, COLOR_SELECTED_TEXT, COLOR_BACKGROUND, event->title);
      osd_paragraph(osd, event->description, 40, x, y + 50, w, h - 50);
    }
  }   
}