コード例 #1
0
ファイル: task_screenshot.c プロジェクト: Alcaro/RetroArch
static bool take_screenshot_choice(const char *name_base, bool savestate,
      bool is_paused, bool is_idle, bool has_valid_framebuffer)
{
   size_t old_pitch;
   unsigned old_width, old_height;
   bool ret                    = false;
   void *frame_data            = NULL;
   const void* old_data        = NULL;
   settings_t *settings        = config_get_ptr();
   const char *screenshot_dir  = settings->paths.directory_screenshot;

   /* No way to infer screenshot directory. */
   if (     string_is_empty(screenshot_dir)
         && string_is_empty(name_base))
      return false;

   if (video_driver_supports_viewport_read())
   {
      /* Avoid taking screenshot of GUI overlays. */
      video_driver_set_texture_enable(false, false);
      if (!is_idle)
         video_driver_cached_frame();
#if defined(VITA)
      return take_screenshot_raw(name_base, NULL, savestate, is_idle, is_paused);
#else
      return take_screenshot_viewport(name_base, savestate, is_idle, is_paused);
#endif
   }

   if (!has_valid_framebuffer)
      return take_screenshot_raw(name_base, NULL, savestate, is_idle, is_paused);

   if (!video_driver_supports_read_frame_raw())
      return false;

   video_driver_cached_frame_get(&old_data, &old_width, &old_height,
         &old_pitch);

   frame_data = video_driver_read_frame_raw(
         &old_width, &old_height, &old_pitch);

   video_driver_cached_frame_set(old_data, old_width, old_height,
         old_pitch);

   if (frame_data)
   {
      video_driver_set_cached_frame_ptr(frame_data);
      if (take_screenshot_raw(name_base, frame_data, savestate, is_idle, is_paused))
         ret = true;
   }

   return ret;
}
コード例 #2
0
ファイル: task_screenshot.c プロジェクト: lollo78/RetroArch
static bool take_screenshot_choice(const char *global_name_base)
{
   settings_t *settings = config_get_ptr();

   /* No way to infer screenshot directory. */
   if (string_is_empty(settings->directory.screenshot) && (!*global_name_base))
      return false;

   if (video_driver_supports_viewport_read())
   {
      /* Avoid taking screenshot of GUI overlays. */
      video_driver_set_texture_enable(false, false);
      video_driver_cached_frame_render();
      return take_screenshot_viewport(global_name_base);
   }

   if (!video_driver_cached_frame_has_valid_framebuffer())
      return take_screenshot_raw(global_name_base);

   if (video_driver_supports_read_frame_raw())
   {
      unsigned old_width, old_height;
      size_t old_pitch;
      bool ret             = false;
      void *frame_data     = NULL;
      const void* old_data = NULL;

      video_driver_cached_frame_get(&old_data, &old_width, &old_height,
            &old_pitch);

      frame_data = video_driver_read_frame_raw(
            &old_width, &old_height, &old_pitch);

      video_driver_cached_frame_set(old_data, old_width, old_height,
            old_pitch);

      if (frame_data)
      {
         video_driver_set_cached_frame_ptr(frame_data);
         if (take_screenshot_raw(global_name_base))
            ret = true;
         free(frame_data);
      }

      return ret;
   }

   return false;
}