Esempio n. 1
0
static bool dispmanx_gfx_frame(void *data, const void *frame, unsigned width,
      unsigned height, unsigned pitch, const char *msg)
{
   struct dispmanx_video *_dispvars = data;

   /* Check if neither menu nor core framebuffer is to be displayed. */
   if (!_dispvars->menu_active && !frame)
      return true;

   if (width != _dispvars->width || height != _dispvars->height)
   {
      /* Sanity check. */
      if (width == 0 || height == 0)
         return true;

      RARCH_LOG("video_dispmanx: internal frame resolution changed by core\n");

      if (!dispmanx_setup_scale(_dispvars, width, height, pitch))
      {
         RARCH_ERR("video_dispmanx: frame resolution set failed\n");
         return false;
      }
      dispmanx_blank_console (_dispvars);
   }

   if (_dispvars->menu_active)
   {
      char buf[128];
      video_monitor_get_fps(buf, sizeof(buf), NULL, 0);

      /* Synchronous flipping of the menu buffers. */
      _dispvars->update = vc_dispmanx_update_start(0);
      vc_dispmanx_element_change_source(_dispvars->update, _dispvars->menu_element,
            _dispvars->menu_resources[_dispvars->menu_flip_page]);
      vc_dispmanx_update_submit_sync(_dispvars->update);		
      return true;
   }

   /* Update main game screen: locate free page, blit and flip. */
   dispmanx_update_main(_dispvars, frame);

   return true;
}
static void *dispmanx_gfx_init(const video_info_t *video,
      const input_driver_t **input, void **input_data)
{
   struct dispmanx_video *_dispvars = calloc(1, sizeof(struct dispmanx_video));

   bcm_host_init();
   _dispvars->display = vc_dispmanx_display_open(0 /* LCD */);
   /* If the console framebuffer has active overscan settings, 
    * the user must have overscan_scale=1 in config.txt to have 
    * the same size for both fb console and dispmanx. */
   graphics_get_display_size(_dispvars->display, &_dispvars->dispmanx_width, &_dispvars->dispmanx_height);

   /* Setup surface parameters */
   _dispvars->vc_image_ptr     = 0;
   _dispvars->pageflip_pending = 0;	
   _dispvars->current_page     = NULL;
   _dispvars->menu_active      = false;
  
   /* Initialize the rest of the mutexes and conditions. */
   _dispvars->vsync_condition  = scond_new();
   _dispvars->vsync_cond_mutex = slock_new();
   _dispvars->pending_mutex    = slock_new();

   dispmanx_surface_init(_dispvars,
      video->rgb32 ? 4 : 2, 
      video->rgb32 ? VC_IMAGE_XRGB8888 : VC_IMAGE_RGB565, 
      0   /* layer */, 
      255 /* alpha */, 
      3,  /* numpages */
      &_dispvars->surfaces[MAIN_SURFACE]);

   if (input && input_data)
      *input = NULL;
  
   dispmanx_blank_console(_dispvars);
 
   return _dispvars;
}