2013-05-02 12:39:03 +00:00
|
|
|
|
|
|
|
#define grub_video_render_target grub_video_fbrender_target
|
|
|
|
|
|
|
|
#include <grub/video.h>
|
|
|
|
#include <grub/video_fb.h>
|
|
|
|
#include <grub/mm.h>
|
fix include loop on MinGW due to libintl.h pulling stdio.h
In file included from ./include/grub/dl.h:23:0,
from grub-core/lib/libgcrypt-grub/cipher/rfc2268.c:3:
./include/grub/list.h:34:18: warning: conflicting types for 'grub_list_push' [en
abled by default]
void EXPORT_FUNC(grub_list_push) (grub_list_t *head, grub_list_t item);
^
./include/grub/symbol.h:68:25: note: in definition of macro 'EXPORT_FUNC'
# define EXPORT_FUNC(x) x
^
In file included from ./include/grub/fs.h:30:0,
from ./include/grub/file.h:25,
from ./grub-core/lib/posix_wrap/stdio.h:23,
from c:\mingw\include\libintl.h:314,
from ./include/grub/i18n.h:33,
from ./include/grub/misc.h:27,
from ./include/grub/list.h:25,
from ./include/grub/dl.h:28,
from grub-core/lib/libgcrypt-grub/cipher/rfc2268.c:3:
./include/grub/partition.h:106:3: note: previous implicit declaration of 'grub_l
ist_push' was here
grub_list_push (GRUB_AS_LIST_P (&grub_partition_map_list),
^
list.h needs just ATTRIBUTE_ERROR from misc.h; split compiler features
into separate file grub/compiler.h and include it instead.
2014-01-18 17:22:57 +00:00
|
|
|
#include <grub/misc.h>
|
2013-05-02 12:39:03 +00:00
|
|
|
|
|
|
|
static struct
|
|
|
|
{
|
|
|
|
struct grub_video_mode_info mode_info;
|
|
|
|
struct grub_video_render_target *render_target;
|
|
|
|
grub_uint8_t *ptr;
|
|
|
|
} framebuffer;
|
|
|
|
|
|
|
|
void (*grub_video_capture_refresh_cb) (void);
|
|
|
|
|
|
|
|
static grub_err_t
|
|
|
|
grub_video_capture_swap_buffers (void)
|
|
|
|
{
|
|
|
|
if (grub_video_capture_refresh_cb)
|
|
|
|
grub_video_capture_refresh_cb ();
|
|
|
|
return GRUB_ERR_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static grub_err_t
|
|
|
|
grub_video_capture_set_active_render_target (struct grub_video_render_target *target)
|
|
|
|
{
|
|
|
|
if (target == GRUB_VIDEO_RENDER_TARGET_DISPLAY)
|
|
|
|
target = framebuffer.render_target;
|
|
|
|
|
|
|
|
return grub_video_fb_set_active_render_target (target);
|
|
|
|
}
|
|
|
|
|
2013-10-03 21:33:58 +00:00
|
|
|
static grub_err_t
|
|
|
|
grub_video_capture_fini (void)
|
|
|
|
{
|
|
|
|
return GRUB_ERR_NONE;
|
|
|
|
}
|
|
|
|
|
2013-05-02 12:39:03 +00:00
|
|
|
static struct grub_video_adapter grub_video_capture_adapter =
|
|
|
|
{
|
|
|
|
.name = "Render capture",
|
|
|
|
|
|
|
|
.prio = 0,
|
|
|
|
.id = GRUB_VIDEO_ADAPTER_CAPTURE,
|
|
|
|
|
2013-10-03 21:33:58 +00:00
|
|
|
.fini = grub_video_capture_fini,
|
2013-05-02 12:39:03 +00:00
|
|
|
.get_info = grub_video_fb_get_info,
|
|
|
|
.get_info_and_fini = 0,
|
|
|
|
.set_palette = grub_video_fb_set_palette,
|
|
|
|
.get_palette = grub_video_fb_get_palette,
|
|
|
|
.set_viewport = grub_video_fb_set_viewport,
|
|
|
|
.get_viewport = grub_video_fb_get_viewport,
|
2013-11-08 11:42:38 +00:00
|
|
|
.set_region = grub_video_fb_set_region,
|
|
|
|
.get_region = grub_video_fb_get_region,
|
|
|
|
.set_area_status = grub_video_fb_set_area_status,
|
|
|
|
.get_area_status = grub_video_fb_get_area_status,
|
2013-05-02 12:39:03 +00:00
|
|
|
.map_color = grub_video_fb_map_color,
|
|
|
|
.map_rgb = grub_video_fb_map_rgb,
|
|
|
|
.map_rgba = grub_video_fb_map_rgba,
|
|
|
|
.unmap_color = grub_video_fb_unmap_color,
|
|
|
|
.fill_rect = grub_video_fb_fill_rect,
|
|
|
|
.blit_bitmap = grub_video_fb_blit_bitmap,
|
|
|
|
.blit_render_target = grub_video_fb_blit_render_target,
|
|
|
|
.scroll = grub_video_fb_scroll,
|
|
|
|
.swap_buffers = grub_video_capture_swap_buffers,
|
|
|
|
.create_render_target = grub_video_fb_create_render_target,
|
|
|
|
.delete_render_target = grub_video_fb_delete_render_target,
|
|
|
|
.set_active_render_target = grub_video_capture_set_active_render_target,
|
|
|
|
.get_active_render_target = grub_video_fb_get_active_render_target,
|
|
|
|
|
|
|
|
.next = 0
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct grub_video_adapter *saved;
|
|
|
|
static struct grub_video_mode_info saved_mode_info;
|
|
|
|
|
|
|
|
grub_err_t
|
|
|
|
grub_video_capture_start (const struct grub_video_mode_info *mode_info,
|
|
|
|
struct grub_video_palette_data *palette,
|
|
|
|
unsigned int palette_size)
|
|
|
|
{
|
|
|
|
grub_err_t err;
|
|
|
|
grub_memset (&framebuffer, 0, sizeof (framebuffer));
|
|
|
|
|
|
|
|
grub_video_fb_init ();
|
|
|
|
|
|
|
|
framebuffer.mode_info = *mode_info;
|
|
|
|
framebuffer.mode_info.blit_format = grub_video_get_blit_format (&framebuffer.mode_info);
|
|
|
|
|
2020-06-15 16:26:01 +00:00
|
|
|
framebuffer.ptr = grub_calloc (framebuffer.mode_info.height, framebuffer.mode_info.pitch);
|
2013-05-02 12:39:03 +00:00
|
|
|
if (!framebuffer.ptr)
|
|
|
|
return grub_errno;
|
|
|
|
|
|
|
|
err = grub_video_fb_create_render_target_from_pointer (&framebuffer.render_target,
|
|
|
|
&framebuffer.mode_info,
|
|
|
|
framebuffer.ptr);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
err = grub_video_fb_set_active_render_target (framebuffer.render_target);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
err = grub_video_fb_set_palette (0, palette_size, palette);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
saved = grub_video_adapter_active;
|
|
|
|
if (saved)
|
|
|
|
{
|
|
|
|
grub_video_get_info (&saved_mode_info);
|
|
|
|
if (saved->fini)
|
|
|
|
saved->fini ();
|
|
|
|
}
|
|
|
|
grub_video_adapter_active = &grub_video_capture_adapter;
|
|
|
|
|
|
|
|
return GRUB_ERR_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *
|
|
|
|
grub_video_capture_get_framebuffer (void)
|
|
|
|
{
|
|
|
|
return framebuffer.ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
grub_video_capture_end (void)
|
|
|
|
{
|
2013-05-04 11:47:10 +00:00
|
|
|
grub_video_fb_delete_render_target (framebuffer.render_target);
|
2013-05-02 12:39:03 +00:00
|
|
|
grub_free (framebuffer.ptr);
|
|
|
|
grub_video_fb_fini ();
|
|
|
|
grub_video_adapter_active = saved;
|
|
|
|
if (saved)
|
|
|
|
{
|
|
|
|
if (saved->init)
|
|
|
|
saved->init ();
|
|
|
|
if (saved->setup)
|
|
|
|
saved->setup (saved_mode_info.width, saved_mode_info.height, 0, 0);
|
|
|
|
}
|
|
|
|
}
|