2 #define grub_video_render_target grub_video_fbrender_target
4 #include <grub/video.h>
5 #include <grub/video_fb.h>
11 struct grub_video_mode_info mode_info
;
12 struct grub_video_render_target
*render_target
;
16 void (*grub_video_capture_refresh_cb
) (void);
19 grub_video_capture_swap_buffers (void)
21 if (grub_video_capture_refresh_cb
)
22 grub_video_capture_refresh_cb ();
27 grub_video_capture_set_active_render_target (struct grub_video_render_target
*target
)
29 if (target
== GRUB_VIDEO_RENDER_TARGET_DISPLAY
)
30 target
= framebuffer
.render_target
;
32 return grub_video_fb_set_active_render_target (target
);
36 grub_video_capture_fini (void)
41 static struct grub_video_adapter grub_video_capture_adapter
=
43 .name
= "Render capture",
46 .id
= GRUB_VIDEO_ADAPTER_CAPTURE
,
48 .fini
= grub_video_capture_fini
,
49 .get_info
= grub_video_fb_get_info
,
50 .get_info_and_fini
= 0,
51 .set_palette
= grub_video_fb_set_palette
,
52 .get_palette
= grub_video_fb_get_palette
,
53 .set_viewport
= grub_video_fb_set_viewport
,
54 .get_viewport
= grub_video_fb_get_viewport
,
55 .set_region
= grub_video_fb_set_region
,
56 .get_region
= grub_video_fb_get_region
,
57 .set_area_status
= grub_video_fb_set_area_status
,
58 .get_area_status
= grub_video_fb_get_area_status
,
59 .map_color
= grub_video_fb_map_color
,
60 .map_rgb
= grub_video_fb_map_rgb
,
61 .map_rgba
= grub_video_fb_map_rgba
,
62 .unmap_color
= grub_video_fb_unmap_color
,
63 .fill_rect
= grub_video_fb_fill_rect
,
64 .blit_bitmap
= grub_video_fb_blit_bitmap
,
65 .blit_render_target
= grub_video_fb_blit_render_target
,
66 .scroll
= grub_video_fb_scroll
,
67 .swap_buffers
= grub_video_capture_swap_buffers
,
68 .create_render_target
= grub_video_fb_create_render_target
,
69 .delete_render_target
= grub_video_fb_delete_render_target
,
70 .set_active_render_target
= grub_video_capture_set_active_render_target
,
71 .get_active_render_target
= grub_video_fb_get_active_render_target
,
76 static struct grub_video_adapter
*saved
;
77 static struct grub_video_mode_info saved_mode_info
;
80 grub_video_capture_start (const struct grub_video_mode_info
*mode_info
,
81 struct grub_video_palette_data
*palette
,
82 unsigned int palette_size
)
85 grub_memset (&framebuffer
, 0, sizeof (framebuffer
));
87 grub_video_fb_init ();
89 framebuffer
.mode_info
= *mode_info
;
90 framebuffer
.mode_info
.blit_format
= grub_video_get_blit_format (&framebuffer
.mode_info
);
92 framebuffer
.ptr
= grub_malloc (framebuffer
.mode_info
.height
* framebuffer
.mode_info
.pitch
);
96 err
= grub_video_fb_create_render_target_from_pointer (&framebuffer
.render_target
,
97 &framebuffer
.mode_info
,
101 err
= grub_video_fb_set_active_render_target (framebuffer
.render_target
);
104 err
= grub_video_fb_set_palette (0, palette_size
, palette
);
108 saved
= grub_video_adapter_active
;
111 grub_video_get_info (&saved_mode_info
);
115 grub_video_adapter_active
= &grub_video_capture_adapter
;
117 return GRUB_ERR_NONE
;
121 grub_video_capture_get_framebuffer (void)
123 return framebuffer
.ptr
;
127 grub_video_capture_end (void)
129 grub_video_fb_delete_render_target (framebuffer
.render_target
);
130 grub_free (framebuffer
.ptr
);
131 grub_video_fb_fini ();
132 grub_video_adapter_active
= saved
;
138 saved
->setup (saved_mode_info
.width
, saved_mode_info
.height
, 0, 0);