2006-07-29 Vesa Jaaskelainen <chaac@nic.fi>
* include/grub/bitmap.h: New file. * include/grub/i386/pc/vbeutil.h: Likewise. * video/bitmap.c: Likewise. * video/readers/tga.c: Likewise. * video/i386/pc/vbeutil.c: Likewise. * commands/videotest.c: Code cleanup and updated to reflect to new video API. * term/gfxterm.c: Likewise. * video/video.c: Likewise. * conf/i386-pc.rmk (pkgdata_MODULES): Added tga.mod and bitmap.mod. (vbe_mod_SOURCES): Added video/i386/pc/vbeutil.c. (bitmap_mod_SOURCES): New entry. (bitmap_mod_CFLAGS): Likewise. (bitmap_mod_LDFLAGS): Likewise. (tga_mod_SOURCES): Likewise. (tga_mod_CFLAGS): Likewise. (tga_mod_LDFLAGS): Likewise. * include/grub/video.h (grub_video_blit_operators): New enum type. (grub_video_render_target): Changed as forward declaration and moved actual definition to be video driver specific. (grub_video_adapter.blit_bitmap): Added blitting operator. (grub_video_adapter.blit_render_target): Likewise. (grub_video_blit_bitmap): Likewise. (grub_video_blit_render_target): Likewise. * include/grub/i386/pc/vbe.h (grub_video_render_target): Added driver specific render target definition. (grub_video_vbe_map_rgba): Added driver internal helper. (grub_video_vbe_unmap_color): Updated to use grub_video_i386_vbeblit_info. (grub_video_vbe_get_video_ptr): Likewise. * include/grub/i386/pc/vbeblit.h (grub_video_i386_vbeblit_R8G8B8A8_R8G8B8A8): Updated to use grub_video_i386_vbeblit_info. (grub_video_i386_vbeblit_R8G8B8_R8G8B8A8): Likewise. (grub_video_i386_vbeblit_index_R8G8B8A8): Likewise. (grub_video_i386_vbeblit_R8G8B8A8_R8G8B8): Likewise. (grub_video_i386_vbeblit_R8G8B8_R8G8B8): Likewise. (grub_video_i386_vbeblit_index_R8G8B8): Likewise. (grub_video_i386_vbeblit_index_index): Likewise. (grub_video_i386_vbeblit_R8G8B8X8_R8G8B8X8): New blitter function. (grub_video_i386_vbeblit_R8G8B8_R8G8B8X8): Likewise. (grub_video_i386_vbeblit_index_R8G8B8X8): Likewise. (grub_video_i386_vbeblit_blend): Added generic blitter for blend operator. (grub_video_i386_vbeblit_replace): Added generic blitter for replace operator. * video/i386/pc/vbeblit.c: Updated to reflect changes on include/grub/i386/pc/vbeblit.h. * include/grub/i386/pc/vbefill.h (grub_video_i386_vbefill_R8G8B8A8): Updated to use grub_video_i386_vbeblit_info. (grub_video_i386_vbefill_R8G8B8): Likewise. (grub_video_i386_vbefill_index): Likewise. (grub_video_i386_vbefill): Added generic filler. * video/i386/pc/vbefill.c: Updated to reflect changes on include/grub/i386/pc/vbefill.h. * video/i386/pc/vbe.c (grub_video_vbe_get_video_ptr): Updated to use grub_video_i386_vbeblit_info. (grub_video_vbe_unmap_color): Likewise. (grub_video_vbe_blit_glyph): Likewise. (grub_video_vbe_scroll): Likewise. (grub_video_vbe_draw_pixel): Removed function. (grub_video_vbe_get_pixel): Likewise. (grub_video_vbe_fill_rect): Moved all blitters to vbefill.c and updated code to use it. (common_blitter): Added common blitter for render target and bitmap. (grub_video_vbe_blit_bitmap): Updated to use common_blitter. (grub_video_vbe_blit_render_target): Likewise.
This commit is contained in:
parent
bc8c036d11
commit
ad2a06edba
18 changed files with 2084 additions and 572 deletions
85
ChangeLog
85
ChangeLog
|
@ -1,3 +1,88 @@
|
||||||
|
2006-07-29 Vesa Jaaskelainen <chaac@nic.fi>
|
||||||
|
|
||||||
|
* include/grub/bitmap.h: New file.
|
||||||
|
|
||||||
|
* include/grub/i386/pc/vbeutil.h: Likewise.
|
||||||
|
|
||||||
|
* video/bitmap.c: Likewise.
|
||||||
|
|
||||||
|
* video/readers/tga.c: Likewise.
|
||||||
|
|
||||||
|
* video/i386/pc/vbeutil.c: Likewise.
|
||||||
|
|
||||||
|
* commands/videotest.c: Code cleanup and updated to reflect to new
|
||||||
|
video API.
|
||||||
|
|
||||||
|
* term/gfxterm.c: Likewise.
|
||||||
|
|
||||||
|
* video/video.c: Likewise.
|
||||||
|
|
||||||
|
* conf/i386-pc.rmk (pkgdata_MODULES): Added tga.mod and bitmap.mod.
|
||||||
|
(vbe_mod_SOURCES): Added video/i386/pc/vbeutil.c.
|
||||||
|
(bitmap_mod_SOURCES): New entry.
|
||||||
|
(bitmap_mod_CFLAGS): Likewise.
|
||||||
|
(bitmap_mod_LDFLAGS): Likewise.
|
||||||
|
(tga_mod_SOURCES): Likewise.
|
||||||
|
(tga_mod_CFLAGS): Likewise.
|
||||||
|
(tga_mod_LDFLAGS): Likewise.
|
||||||
|
|
||||||
|
* include/grub/video.h (grub_video_blit_operators): New enum type.
|
||||||
|
(grub_video_render_target): Changed as forward declaration and moved
|
||||||
|
actual definition to be video driver specific.
|
||||||
|
(grub_video_adapter.blit_bitmap): Added blitting operator.
|
||||||
|
(grub_video_adapter.blit_render_target): Likewise.
|
||||||
|
(grub_video_blit_bitmap): Likewise.
|
||||||
|
(grub_video_blit_render_target): Likewise.
|
||||||
|
|
||||||
|
* include/grub/i386/pc/vbe.h (grub_video_render_target): Added
|
||||||
|
driver specific render target definition.
|
||||||
|
(grub_video_vbe_map_rgba): Added driver internal helper.
|
||||||
|
(grub_video_vbe_unmap_color): Updated to use
|
||||||
|
grub_video_i386_vbeblit_info.
|
||||||
|
(grub_video_vbe_get_video_ptr): Likewise.
|
||||||
|
|
||||||
|
* include/grub/i386/pc/vbeblit.h
|
||||||
|
(grub_video_i386_vbeblit_R8G8B8A8_R8G8B8A8): Updated to use
|
||||||
|
grub_video_i386_vbeblit_info.
|
||||||
|
(grub_video_i386_vbeblit_R8G8B8_R8G8B8A8): Likewise.
|
||||||
|
(grub_video_i386_vbeblit_index_R8G8B8A8): Likewise.
|
||||||
|
(grub_video_i386_vbeblit_R8G8B8A8_R8G8B8): Likewise.
|
||||||
|
(grub_video_i386_vbeblit_R8G8B8_R8G8B8): Likewise.
|
||||||
|
(grub_video_i386_vbeblit_index_R8G8B8): Likewise.
|
||||||
|
(grub_video_i386_vbeblit_index_index): Likewise.
|
||||||
|
(grub_video_i386_vbeblit_R8G8B8X8_R8G8B8X8): New blitter function.
|
||||||
|
(grub_video_i386_vbeblit_R8G8B8_R8G8B8X8): Likewise.
|
||||||
|
(grub_video_i386_vbeblit_index_R8G8B8X8): Likewise.
|
||||||
|
(grub_video_i386_vbeblit_blend): Added generic blitter for blend
|
||||||
|
operator.
|
||||||
|
(grub_video_i386_vbeblit_replace): Added generic blitter for replace
|
||||||
|
operator.
|
||||||
|
|
||||||
|
* video/i386/pc/vbeblit.c: Updated to reflect changes on
|
||||||
|
include/grub/i386/pc/vbeblit.h.
|
||||||
|
|
||||||
|
* include/grub/i386/pc/vbefill.h (grub_video_i386_vbefill_R8G8B8A8):
|
||||||
|
Updated to use grub_video_i386_vbeblit_info.
|
||||||
|
(grub_video_i386_vbefill_R8G8B8): Likewise.
|
||||||
|
(grub_video_i386_vbefill_index): Likewise.
|
||||||
|
(grub_video_i386_vbefill): Added generic filler.
|
||||||
|
|
||||||
|
* video/i386/pc/vbefill.c: Updated to reflect changes on
|
||||||
|
include/grub/i386/pc/vbefill.h.
|
||||||
|
|
||||||
|
* video/i386/pc/vbe.c (grub_video_vbe_get_video_ptr): Updated to use
|
||||||
|
grub_video_i386_vbeblit_info.
|
||||||
|
(grub_video_vbe_unmap_color): Likewise.
|
||||||
|
(grub_video_vbe_blit_glyph): Likewise.
|
||||||
|
(grub_video_vbe_scroll): Likewise.
|
||||||
|
(grub_video_vbe_draw_pixel): Removed function.
|
||||||
|
(grub_video_vbe_get_pixel): Likewise.
|
||||||
|
(grub_video_vbe_fill_rect): Moved all blitters to vbefill.c and
|
||||||
|
updated code to use it.
|
||||||
|
(common_blitter): Added common blitter for render target and bitmap.
|
||||||
|
(grub_video_vbe_blit_bitmap): Updated to use common_blitter.
|
||||||
|
(grub_video_vbe_blit_render_target): Likewise.
|
||||||
|
|
||||||
2006-07-30 Johan Rydberg <jrydberg@gnu.org>
|
2006-07-30 Johan Rydberg <jrydberg@gnu.org>
|
||||||
|
|
||||||
* kern/efi/efi.c (grub_efi_set_text_mode): Assume console already
|
* kern/efi/efi.c (grub_efi_set_text_mode): Assume console already
|
||||||
|
|
|
@ -98,7 +98,8 @@ grub_cmd_videotest (struct grub_arg_list *state __attribute__ ((unused)),
|
||||||
{
|
{
|
||||||
color = grub_video_map_rgb (i, 33, 77);
|
color = grub_video_map_rgb (i, 33, 77);
|
||||||
grub_video_fill_rect (color, 0, 0, width, height);
|
grub_video_fill_rect (color, 0, 0, width, height);
|
||||||
grub_video_blit_render_target (text_layer, 0, 0, 0, 0, width, height);
|
grub_video_blit_render_target (text_layer, GRUB_VIDEO_BLIT_BLEND, 0, 0,
|
||||||
|
0, 0, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_getkey ();
|
grub_getkey ();
|
||||||
|
|
141
conf/i386-pc.mk
141
conf/i386-pc.mk
|
@ -1336,7 +1336,7 @@ grub-install: util/i386/pc/grub-install.in config.status
|
||||||
pkgdata_MODULES = _chain.mod _linux.mod linux.mod normal.mod \
|
pkgdata_MODULES = _chain.mod _linux.mod linux.mod normal.mod \
|
||||||
_multiboot.mod chain.mod multiboot.mod reboot.mod halt.mod \
|
_multiboot.mod chain.mod multiboot.mod reboot.mod halt.mod \
|
||||||
vbe.mod vbetest.mod vbeinfo.mod video.mod gfxterm.mod \
|
vbe.mod vbetest.mod vbeinfo.mod video.mod gfxterm.mod \
|
||||||
videotest.mod play.mod
|
videotest.mod play.mod bitmap.mod tga.mod
|
||||||
|
|
||||||
# For _chain.mod.
|
# For _chain.mod.
|
||||||
_chain_mod_SOURCES = loader/i386/pc/chainloader.c
|
_chain_mod_SOURCES = loader/i386/pc/chainloader.c
|
||||||
|
@ -2101,13 +2101,13 @@ multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
# For vbe.mod.
|
# For vbe.mod.
|
||||||
vbe_mod_SOURCES = video/i386/pc/vbe.c video/i386/pc/vbeblit.c \
|
vbe_mod_SOURCES = video/i386/pc/vbe.c video/i386/pc/vbeblit.c \
|
||||||
video/i386/pc/vbefill.c
|
video/i386/pc/vbefill.c video/i386/pc/vbeutil.c
|
||||||
CLEANFILES += vbe.mod mod-vbe.o mod-vbe.c pre-vbe.o vbe_mod-video_i386_pc_vbe.o vbe_mod-video_i386_pc_vbeblit.o vbe_mod-video_i386_pc_vbefill.o und-vbe.lst
|
CLEANFILES += vbe.mod mod-vbe.o mod-vbe.c pre-vbe.o vbe_mod-video_i386_pc_vbe.o vbe_mod-video_i386_pc_vbeblit.o vbe_mod-video_i386_pc_vbefill.o vbe_mod-video_i386_pc_vbeutil.o und-vbe.lst
|
||||||
ifneq ($(vbe_mod_EXPORTS),no)
|
ifneq ($(vbe_mod_EXPORTS),no)
|
||||||
CLEANFILES += def-vbe.lst
|
CLEANFILES += def-vbe.lst
|
||||||
DEFSYMFILES += def-vbe.lst
|
DEFSYMFILES += def-vbe.lst
|
||||||
endif
|
endif
|
||||||
MOSTLYCLEANFILES += vbe_mod-video_i386_pc_vbe.d vbe_mod-video_i386_pc_vbeblit.d vbe_mod-video_i386_pc_vbefill.d
|
MOSTLYCLEANFILES += vbe_mod-video_i386_pc_vbe.d vbe_mod-video_i386_pc_vbeblit.d vbe_mod-video_i386_pc_vbefill.d vbe_mod-video_i386_pc_vbeutil.d
|
||||||
UNDSYMFILES += und-vbe.lst
|
UNDSYMFILES += und-vbe.lst
|
||||||
|
|
||||||
vbe.mod: pre-vbe.o mod-vbe.o
|
vbe.mod: pre-vbe.o mod-vbe.o
|
||||||
|
@ -2115,7 +2115,7 @@ vbe.mod: pre-vbe.o mod-vbe.o
|
||||||
$(TARGET_CC) $(vbe_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ $^
|
$(TARGET_CC) $(vbe_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ $^
|
||||||
$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
|
$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
|
||||||
|
|
||||||
pre-vbe.o: vbe_mod-video_i386_pc_vbe.o vbe_mod-video_i386_pc_vbeblit.o vbe_mod-video_i386_pc_vbefill.o
|
pre-vbe.o: vbe_mod-video_i386_pc_vbe.o vbe_mod-video_i386_pc_vbeblit.o vbe_mod-video_i386_pc_vbefill.o vbe_mod-video_i386_pc_vbeutil.o
|
||||||
-rm -f $@
|
-rm -f $@
|
||||||
$(TARGET_CC) $(vbe_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ $^
|
$(TARGET_CC) $(vbe_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ $^
|
||||||
|
|
||||||
|
@ -2191,6 +2191,25 @@ fs-vbe_mod-video_i386_pc_vbefill.lst: video/i386/pc/vbefill.c genfslist.sh
|
||||||
set -e; $(TARGET_CC) -Ivideo/i386/pc -I$(srcdir)/video/i386/pc $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(vbe_mod_CFLAGS) -E $< | sh $(srcdir)/genfslist.sh vbe > $@ || (rm -f $@; exit 1)
|
set -e; $(TARGET_CC) -Ivideo/i386/pc -I$(srcdir)/video/i386/pc $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(vbe_mod_CFLAGS) -E $< | sh $(srcdir)/genfslist.sh vbe > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
|
||||||
|
vbe_mod-video_i386_pc_vbeutil.o: video/i386/pc/vbeutil.c
|
||||||
|
$(TARGET_CC) -Ivideo/i386/pc -I$(srcdir)/video/i386/pc $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(vbe_mod_CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
vbe_mod-video_i386_pc_vbeutil.d: video/i386/pc/vbeutil.c
|
||||||
|
set -e; $(TARGET_CC) -Ivideo/i386/pc -I$(srcdir)/video/i386/pc $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(vbe_mod_CFLAGS) -M $< | sed 's,vbeutil\.o[ :]*,vbe_mod-video_i386_pc_vbeutil.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
|
||||||
|
|
||||||
|
-include vbe_mod-video_i386_pc_vbeutil.d
|
||||||
|
|
||||||
|
CLEANFILES += cmd-vbe_mod-video_i386_pc_vbeutil.lst fs-vbe_mod-video_i386_pc_vbeutil.lst
|
||||||
|
COMMANDFILES += cmd-vbe_mod-video_i386_pc_vbeutil.lst
|
||||||
|
FSFILES += fs-vbe_mod-video_i386_pc_vbeutil.lst
|
||||||
|
|
||||||
|
cmd-vbe_mod-video_i386_pc_vbeutil.lst: video/i386/pc/vbeutil.c gencmdlist.sh
|
||||||
|
set -e; $(TARGET_CC) -Ivideo/i386/pc -I$(srcdir)/video/i386/pc $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(vbe_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh vbe > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
fs-vbe_mod-video_i386_pc_vbeutil.lst: video/i386/pc/vbeutil.c genfslist.sh
|
||||||
|
set -e; $(TARGET_CC) -Ivideo/i386/pc -I$(srcdir)/video/i386/pc $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(vbe_mod_CFLAGS) -E $< | sh $(srcdir)/genfslist.sh vbe > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
|
||||||
vbe_mod_CFLAGS = $(COMMON_CFLAGS)
|
vbe_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
vbe_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
vbe_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
@ -2530,4 +2549,116 @@ fs-videotest_mod-commands_videotest.lst: commands/videotest.c genfslist.sh
|
||||||
videotest_mod_CFLAGS = $(COMMON_CFLAGS)
|
videotest_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
videotest_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
videotest_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For bitmap.mod
|
||||||
|
bitmap_mod_SOURCES = video/bitmap.c
|
||||||
|
CLEANFILES += bitmap.mod mod-bitmap.o mod-bitmap.c pre-bitmap.o bitmap_mod-video_bitmap.o und-bitmap.lst
|
||||||
|
ifneq ($(bitmap_mod_EXPORTS),no)
|
||||||
|
CLEANFILES += def-bitmap.lst
|
||||||
|
DEFSYMFILES += def-bitmap.lst
|
||||||
|
endif
|
||||||
|
MOSTLYCLEANFILES += bitmap_mod-video_bitmap.d
|
||||||
|
UNDSYMFILES += und-bitmap.lst
|
||||||
|
|
||||||
|
bitmap.mod: pre-bitmap.o mod-bitmap.o
|
||||||
|
-rm -f $@
|
||||||
|
$(TARGET_CC) $(bitmap_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ $^
|
||||||
|
$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
|
||||||
|
|
||||||
|
pre-bitmap.o: bitmap_mod-video_bitmap.o
|
||||||
|
-rm -f $@
|
||||||
|
$(TARGET_CC) $(bitmap_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ $^
|
||||||
|
|
||||||
|
mod-bitmap.o: mod-bitmap.c
|
||||||
|
$(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(bitmap_mod_CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
mod-bitmap.c: moddep.lst genmodsrc.sh
|
||||||
|
sh $(srcdir)/genmodsrc.sh 'bitmap' $< > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
ifneq ($(bitmap_mod_EXPORTS),no)
|
||||||
|
def-bitmap.lst: pre-bitmap.o
|
||||||
|
$(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 bitmap/' > $@
|
||||||
|
endif
|
||||||
|
|
||||||
|
und-bitmap.lst: pre-bitmap.o
|
||||||
|
echo 'bitmap' > $@
|
||||||
|
$(NM) -u -P -p $< | cut -f1 -d' ' >> $@
|
||||||
|
|
||||||
|
bitmap_mod-video_bitmap.o: video/bitmap.c
|
||||||
|
$(TARGET_CC) -Ivideo -I$(srcdir)/video $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(bitmap_mod_CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
bitmap_mod-video_bitmap.d: video/bitmap.c
|
||||||
|
set -e; $(TARGET_CC) -Ivideo -I$(srcdir)/video $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(bitmap_mod_CFLAGS) -M $< | sed 's,bitmap\.o[ :]*,bitmap_mod-video_bitmap.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
|
||||||
|
|
||||||
|
-include bitmap_mod-video_bitmap.d
|
||||||
|
|
||||||
|
CLEANFILES += cmd-bitmap_mod-video_bitmap.lst fs-bitmap_mod-video_bitmap.lst
|
||||||
|
COMMANDFILES += cmd-bitmap_mod-video_bitmap.lst
|
||||||
|
FSFILES += fs-bitmap_mod-video_bitmap.lst
|
||||||
|
|
||||||
|
cmd-bitmap_mod-video_bitmap.lst: video/bitmap.c gencmdlist.sh
|
||||||
|
set -e; $(TARGET_CC) -Ivideo -I$(srcdir)/video $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(bitmap_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh bitmap > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
fs-bitmap_mod-video_bitmap.lst: video/bitmap.c genfslist.sh
|
||||||
|
set -e; $(TARGET_CC) -Ivideo -I$(srcdir)/video $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(bitmap_mod_CFLAGS) -E $< | sh $(srcdir)/genfslist.sh bitmap > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
|
||||||
|
bitmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
bitmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For tga.mod
|
||||||
|
tga_mod_SOURCES = video/readers/tga.c
|
||||||
|
CLEANFILES += tga.mod mod-tga.o mod-tga.c pre-tga.o tga_mod-video_readers_tga.o und-tga.lst
|
||||||
|
ifneq ($(tga_mod_EXPORTS),no)
|
||||||
|
CLEANFILES += def-tga.lst
|
||||||
|
DEFSYMFILES += def-tga.lst
|
||||||
|
endif
|
||||||
|
MOSTLYCLEANFILES += tga_mod-video_readers_tga.d
|
||||||
|
UNDSYMFILES += und-tga.lst
|
||||||
|
|
||||||
|
tga.mod: pre-tga.o mod-tga.o
|
||||||
|
-rm -f $@
|
||||||
|
$(TARGET_CC) $(tga_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ $^
|
||||||
|
$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
|
||||||
|
|
||||||
|
pre-tga.o: tga_mod-video_readers_tga.o
|
||||||
|
-rm -f $@
|
||||||
|
$(TARGET_CC) $(tga_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ $^
|
||||||
|
|
||||||
|
mod-tga.o: mod-tga.c
|
||||||
|
$(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(tga_mod_CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
mod-tga.c: moddep.lst genmodsrc.sh
|
||||||
|
sh $(srcdir)/genmodsrc.sh 'tga' $< > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
ifneq ($(tga_mod_EXPORTS),no)
|
||||||
|
def-tga.lst: pre-tga.o
|
||||||
|
$(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 tga/' > $@
|
||||||
|
endif
|
||||||
|
|
||||||
|
und-tga.lst: pre-tga.o
|
||||||
|
echo 'tga' > $@
|
||||||
|
$(NM) -u -P -p $< | cut -f1 -d' ' >> $@
|
||||||
|
|
||||||
|
tga_mod-video_readers_tga.o: video/readers/tga.c
|
||||||
|
$(TARGET_CC) -Ivideo/readers -I$(srcdir)/video/readers $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(tga_mod_CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
tga_mod-video_readers_tga.d: video/readers/tga.c
|
||||||
|
set -e; $(TARGET_CC) -Ivideo/readers -I$(srcdir)/video/readers $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(tga_mod_CFLAGS) -M $< | sed 's,tga\.o[ :]*,tga_mod-video_readers_tga.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
|
||||||
|
|
||||||
|
-include tga_mod-video_readers_tga.d
|
||||||
|
|
||||||
|
CLEANFILES += cmd-tga_mod-video_readers_tga.lst fs-tga_mod-video_readers_tga.lst
|
||||||
|
COMMANDFILES += cmd-tga_mod-video_readers_tga.lst
|
||||||
|
FSFILES += fs-tga_mod-video_readers_tga.lst
|
||||||
|
|
||||||
|
cmd-tga_mod-video_readers_tga.lst: video/readers/tga.c gencmdlist.sh
|
||||||
|
set -e; $(TARGET_CC) -Ivideo/readers -I$(srcdir)/video/readers $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(tga_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh tga > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
fs-tga_mod-video_readers_tga.lst: video/readers/tga.c genfslist.sh
|
||||||
|
set -e; $(TARGET_CC) -Ivideo/readers -I$(srcdir)/video/readers $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(tga_mod_CFLAGS) -E $< | sh $(srcdir)/genfslist.sh tga > $@ || (rm -f $@; exit 1)
|
||||||
|
|
||||||
|
|
||||||
|
tga_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
tga_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
include $(srcdir)/conf/common.mk
|
include $(srcdir)/conf/common.mk
|
||||||
|
|
|
@ -112,7 +112,7 @@ grub_install_SOURCES = util/i386/pc/grub-install.in
|
||||||
pkgdata_MODULES = _chain.mod _linux.mod linux.mod normal.mod \
|
pkgdata_MODULES = _chain.mod _linux.mod linux.mod normal.mod \
|
||||||
_multiboot.mod chain.mod multiboot.mod reboot.mod halt.mod \
|
_multiboot.mod chain.mod multiboot.mod reboot.mod halt.mod \
|
||||||
vbe.mod vbetest.mod vbeinfo.mod video.mod gfxterm.mod \
|
vbe.mod vbetest.mod vbeinfo.mod video.mod gfxterm.mod \
|
||||||
videotest.mod play.mod
|
videotest.mod play.mod bitmap.mod tga.mod
|
||||||
|
|
||||||
# For _chain.mod.
|
# For _chain.mod.
|
||||||
_chain_mod_SOURCES = loader/i386/pc/chainloader.c
|
_chain_mod_SOURCES = loader/i386/pc/chainloader.c
|
||||||
|
@ -171,7 +171,7 @@ multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
# For vbe.mod.
|
# For vbe.mod.
|
||||||
vbe_mod_SOURCES = video/i386/pc/vbe.c video/i386/pc/vbeblit.c \
|
vbe_mod_SOURCES = video/i386/pc/vbe.c video/i386/pc/vbeblit.c \
|
||||||
video/i386/pc/vbefill.c
|
video/i386/pc/vbefill.c video/i386/pc/vbeutil.c
|
||||||
vbe_mod_CFLAGS = $(COMMON_CFLAGS)
|
vbe_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
vbe_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
vbe_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
@ -205,4 +205,14 @@ videotest_mod_SOURCES = commands/videotest.c
|
||||||
videotest_mod_CFLAGS = $(COMMON_CFLAGS)
|
videotest_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
videotest_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
videotest_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For bitmap.mod
|
||||||
|
bitmap_mod_SOURCES = video/bitmap.c
|
||||||
|
bitmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
bitmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For tga.mod
|
||||||
|
tga_mod_SOURCES = video/readers/tga.c
|
||||||
|
tga_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
tga_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
include $(srcdir)/conf/common.mk
|
include $(srcdir)/conf/common.mk
|
||||||
|
|
71
include/grub/bitmap.h
Normal file
71
include/grub/bitmap.h
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2006 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* GRUB is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with GRUB; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GRUB_BITMAP_HEADER
|
||||||
|
#define GRUB_BITMAP_HEADER 1
|
||||||
|
|
||||||
|
#include <grub/err.h>
|
||||||
|
#include <grub/symbol.h>
|
||||||
|
#include <grub/types.h>
|
||||||
|
#include <grub/video.h>
|
||||||
|
|
||||||
|
struct grub_video_bitmap
|
||||||
|
{
|
||||||
|
/* Bitmap format description. */
|
||||||
|
struct grub_video_mode_info mode_info;
|
||||||
|
|
||||||
|
/* Pointer to bitmap data formatted according to mode_info. */
|
||||||
|
void *data;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct grub_video_bitmap_reader
|
||||||
|
{
|
||||||
|
/* File extension for this bitmap type (including dot). */
|
||||||
|
const char *extension;
|
||||||
|
|
||||||
|
/* Reader function to load bitmap. */
|
||||||
|
grub_err_t (*reader) (struct grub_video_bitmap **bitmap,
|
||||||
|
const char *filename);
|
||||||
|
|
||||||
|
/* Next reader. */
|
||||||
|
struct grub_video_bitmap_reader *next;
|
||||||
|
};
|
||||||
|
typedef struct grub_video_bitmap_reader *grub_video_bitmap_reader_t;
|
||||||
|
|
||||||
|
void grub_video_bitmap_reader_register (grub_video_bitmap_reader_t reader);
|
||||||
|
void grub_video_bitmap_reader_unregister (grub_video_bitmap_reader_t reader);
|
||||||
|
|
||||||
|
grub_err_t grub_video_bitmap_create (struct grub_video_bitmap **bitmap,
|
||||||
|
unsigned int width, unsigned int height,
|
||||||
|
enum grub_video_blit_format blit_format);
|
||||||
|
|
||||||
|
grub_err_t grub_video_bitmap_destroy (struct grub_video_bitmap *bitmap);
|
||||||
|
|
||||||
|
grub_err_t grub_video_bitmap_load (struct grub_video_bitmap **bitmap,
|
||||||
|
const char *filename);
|
||||||
|
|
||||||
|
unsigned int grub_video_bitmap_get_width (struct grub_video_bitmap *bitmap);
|
||||||
|
unsigned int grub_video_bitmap_get_height (struct grub_video_bitmap *bitmap);
|
||||||
|
|
||||||
|
void grub_video_bitmap_get_mode_info (struct grub_video_bitmap *bitmap,
|
||||||
|
struct grub_video_mode_info *mode_info);
|
||||||
|
|
||||||
|
void *grub_video_bitmap_get_data (struct grub_video_bitmap *bitmap);
|
||||||
|
|
||||||
|
#endif /* ! GRUB_BITMAP_HEADER */
|
|
@ -205,13 +205,43 @@ grub_err_t grub_vbe_get_video_mode_info (grub_uint32_t mode,
|
||||||
struct grub_vbe_mode_info_block *mode_info);
|
struct grub_vbe_mode_info_block *mode_info);
|
||||||
|
|
||||||
/* VBE module internal prototypes (should not be used from elsewhere). */
|
/* VBE module internal prototypes (should not be used from elsewhere). */
|
||||||
grub_uint8_t * grub_video_vbe_get_video_ptr (struct grub_video_render_target *source,
|
struct grub_video_i386_vbeblit_info;
|
||||||
|
|
||||||
|
struct grub_video_render_target
|
||||||
|
{
|
||||||
|
/* Copy of the screen's mode info structure, except that width, height and
|
||||||
|
mode_type has been re-adjusted to requested render target settings. */
|
||||||
|
struct grub_video_mode_info mode_info;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
unsigned int x;
|
||||||
|
unsigned int y;
|
||||||
|
unsigned int width;
|
||||||
|
unsigned int height;
|
||||||
|
} viewport;
|
||||||
|
|
||||||
|
/* Indicates wether the data has been allocated by us and must be freed
|
||||||
|
when render target is destroyed. */
|
||||||
|
int is_allocated;
|
||||||
|
|
||||||
|
/* Pointer to data. Can either be in video card memory or in local host's
|
||||||
|
memory. */
|
||||||
|
void *data;
|
||||||
|
};
|
||||||
|
|
||||||
|
grub_uint8_t * grub_video_vbe_get_video_ptr (struct grub_video_i386_vbeblit_info *source,
|
||||||
grub_uint32_t x, grub_uint32_t y);
|
grub_uint32_t x, grub_uint32_t y);
|
||||||
|
|
||||||
grub_video_color_t grub_video_vbe_map_rgb (grub_uint8_t red, grub_uint8_t green,
|
grub_video_color_t grub_video_vbe_map_rgb (grub_uint8_t red, grub_uint8_t green,
|
||||||
grub_uint8_t blue);
|
grub_uint8_t blue);
|
||||||
|
|
||||||
void grub_video_vbe_unmap_color (struct grub_video_render_target * source,
|
grub_video_color_t grub_video_vbe_map_rgba (grub_uint8_t red,
|
||||||
|
grub_uint8_t green,
|
||||||
|
grub_uint8_t blue,
|
||||||
|
grub_uint8_t alpha);
|
||||||
|
|
||||||
|
void grub_video_vbe_unmap_color (struct grub_video_i386_vbeblit_info *source,
|
||||||
grub_video_color_t color, grub_uint8_t *red,
|
grub_video_color_t color, grub_uint8_t *red,
|
||||||
grub_uint8_t *green, grub_uint8_t *blue,
|
grub_uint8_t *green, grub_uint8_t *blue,
|
||||||
grub_uint8_t *alpha);
|
grub_uint8_t *alpha);
|
||||||
|
|
|
@ -20,46 +20,80 @@
|
||||||
#ifndef GRUB_VBEBLIT_MACHINE_HEADER
|
#ifndef GRUB_VBEBLIT_MACHINE_HEADER
|
||||||
#define GRUB_VBEBLIT_MACHINE_HEADER 1
|
#define GRUB_VBEBLIT_MACHINE_HEADER 1
|
||||||
|
|
||||||
|
/* NOTE: This header is private header for vbe driver and should not be used
|
||||||
|
in other parts of the code. */
|
||||||
|
|
||||||
|
struct grub_video_i386_vbeblit_info;
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_video_i386_vbeblit_R8G8B8A8_R8G8B8A8 (struct grub_video_render_target *dst,
|
grub_video_i386_vbeblit_R8G8B8A8_R8G8B8A8 (struct grub_video_i386_vbeblit_info *dst,
|
||||||
struct grub_video_render_target *src,
|
struct grub_video_i386_vbeblit_info *src,
|
||||||
int x, int y, int width, int height,
|
int x, int y, int width, int height,
|
||||||
int offset_x, int offset_y);
|
int offset_x, int offset_y);
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_video_i386_vbeblit_R8G8B8_R8G8B8A8 (struct grub_video_render_target *dst,
|
grub_video_i386_vbeblit_R8G8B8X8_R8G8B8X8 (struct grub_video_i386_vbeblit_info *dst,
|
||||||
struct grub_video_render_target *src,
|
struct grub_video_i386_vbeblit_info *src,
|
||||||
int x, int y, int width, int height,
|
int x, int y, int width, int height,
|
||||||
int offset_x, int offset_y);
|
int offset_x, int offset_y);
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_video_i386_vbeblit_index_R8G8B8A8 (struct grub_video_render_target *dst,
|
grub_video_i386_vbeblit_R8G8B8_R8G8B8A8 (struct grub_video_i386_vbeblit_info *dst,
|
||||||
struct grub_video_render_target *src,
|
struct grub_video_i386_vbeblit_info *src,
|
||||||
int x, int y, int width, int height,
|
|
||||||
int offset_x, int offset_y);
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
grub_video_i386_vbeblit_R8G8B8A8_R8G8B8 (struct grub_video_render_target *dst,
|
|
||||||
struct grub_video_render_target *src,
|
|
||||||
int x, int y, int width, int height,
|
int x, int y, int width, int height,
|
||||||
int offset_x, int offset_y);
|
int offset_x, int offset_y);
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_video_i386_vbeblit_R8G8B8_R8G8B8 (struct grub_video_render_target *dst,
|
grub_video_i386_vbeblit_R8G8B8_R8G8B8X8 (struct grub_video_i386_vbeblit_info *dst,
|
||||||
struct grub_video_render_target *src,
|
struct grub_video_i386_vbeblit_info *src,
|
||||||
int x, int y, int width, int height,
|
int x, int y, int width, int height,
|
||||||
int offset_x, int offset_y);
|
int offset_x, int offset_y);
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_video_i386_vbeblit_index_R8G8B8 (struct grub_video_render_target *dst,
|
grub_video_i386_vbeblit_index_R8G8B8A8 (struct grub_video_i386_vbeblit_info *dst,
|
||||||
struct grub_video_render_target *src,
|
struct grub_video_i386_vbeblit_info *src,
|
||||||
int x, int y, int width, int height,
|
int x, int y, int width, int height,
|
||||||
int offset_x, int offset_y);
|
int offset_x, int offset_y);
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_video_i386_vbeblit_index_index (struct grub_video_render_target *dst,
|
grub_video_i386_vbeblit_index_R8G8B8X8 (struct grub_video_i386_vbeblit_info *dst,
|
||||||
struct grub_video_render_target *src,
|
struct grub_video_i386_vbeblit_info *src,
|
||||||
|
int x, int y, int width, int height,
|
||||||
|
int offset_x, int offset_y);
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_video_i386_vbeblit_R8G8B8A8_R8G8B8 (struct grub_video_i386_vbeblit_info *dst,
|
||||||
|
struct grub_video_i386_vbeblit_info *src,
|
||||||
|
int x, int y, int width, int height,
|
||||||
|
int offset_x, int offset_y);
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_video_i386_vbeblit_R8G8B8_R8G8B8 (struct grub_video_i386_vbeblit_info *dst,
|
||||||
|
struct grub_video_i386_vbeblit_info *src,
|
||||||
|
int x, int y, int width, int height,
|
||||||
|
int offset_x, int offset_y);
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_video_i386_vbeblit_index_R8G8B8 (struct grub_video_i386_vbeblit_info *dst,
|
||||||
|
struct grub_video_i386_vbeblit_info *src,
|
||||||
|
int x, int y, int width, int height,
|
||||||
|
int offset_x, int offset_y);
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_video_i386_vbeblit_index_index (struct grub_video_i386_vbeblit_info *dst,
|
||||||
|
struct grub_video_i386_vbeblit_info *src,
|
||||||
|
int x, int y, int width, int height,
|
||||||
|
int offset_x, int offset_y);
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_video_i386_vbeblit_blend (struct grub_video_i386_vbeblit_info *dst,
|
||||||
|
struct grub_video_i386_vbeblit_info *src,
|
||||||
|
int x, int y, int width, int height,
|
||||||
|
int offset_x, int offset_y);
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_video_i386_vbeblit_replace (struct grub_video_i386_vbeblit_info *dst,
|
||||||
|
struct grub_video_i386_vbeblit_info *src,
|
||||||
int x, int y, int width, int height,
|
int x, int y, int width, int height,
|
||||||
int offset_x, int offset_y);
|
int offset_x, int offset_y);
|
||||||
|
|
||||||
|
|
|
@ -20,20 +20,28 @@
|
||||||
#ifndef GRUB_VBEFILL_MACHINE_HEADER
|
#ifndef GRUB_VBEFILL_MACHINE_HEADER
|
||||||
#define GRUB_VBEFILL_MACHINE_HEADER 1
|
#define GRUB_VBEFILL_MACHINE_HEADER 1
|
||||||
|
|
||||||
#include <grub/video.h>
|
/* NOTE: This header is private header for vbe driver and should not be used
|
||||||
|
in other parts of the code. */
|
||||||
|
|
||||||
|
struct grub_video_i386_vbeblit_info;
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_video_i386_vbefill_R8G8B8A8 (struct grub_video_render_target *dst,
|
grub_video_i386_vbefill_R8G8B8A8 (struct grub_video_i386_vbeblit_info *dst,
|
||||||
grub_video_color_t color, int x, int y,
|
grub_video_color_t color, int x, int y,
|
||||||
int width, int height);
|
int width, int height);
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_video_i386_vbefill_R8G8B8 (struct grub_video_render_target *dst,
|
grub_video_i386_vbefill_R8G8B8 (struct grub_video_i386_vbeblit_info *dst,
|
||||||
grub_video_color_t color, int x, int y,
|
grub_video_color_t color, int x, int y,
|
||||||
int width, int height);
|
int width, int height);
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_video_i386_vbefill_index (struct grub_video_render_target *dst,
|
grub_video_i386_vbefill_index (struct grub_video_i386_vbeblit_info *dst,
|
||||||
|
grub_video_color_t color, int x, int y,
|
||||||
|
int width, int height);
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_video_i386_vbefill (struct grub_video_i386_vbeblit_info *dst,
|
||||||
grub_video_color_t color, int x, int y,
|
grub_video_color_t color, int x, int y,
|
||||||
int width, int height);
|
int width, int height);
|
||||||
|
|
||||||
|
|
44
include/grub/i386/pc/vbeutil.h
Normal file
44
include/grub/i386/pc/vbeutil.h
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2006 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* NOTE: This header is private header for vbe driver and should not be used
|
||||||
|
in other parts of the code. */
|
||||||
|
|
||||||
|
#ifndef GRUB_VBEUTIL_MACHINE_HEADER
|
||||||
|
#define GRUB_VBEUTIL_MACHINE_HEADER 1
|
||||||
|
|
||||||
|
#include <grub/types.h>
|
||||||
|
#include <grub/video.h>
|
||||||
|
|
||||||
|
struct grub_video_i386_vbeblit_info
|
||||||
|
{
|
||||||
|
struct grub_video_mode_info *mode_info;
|
||||||
|
void *data;
|
||||||
|
};
|
||||||
|
|
||||||
|
grub_uint8_t *get_data_ptr (struct grub_video_i386_vbeblit_info *source,
|
||||||
|
unsigned int x, unsigned int y);
|
||||||
|
|
||||||
|
grub_video_color_t get_pixel (struct grub_video_i386_vbeblit_info *source,
|
||||||
|
unsigned int x, unsigned int y);
|
||||||
|
|
||||||
|
void set_pixel (struct grub_video_i386_vbeblit_info *source,
|
||||||
|
unsigned int x, unsigned int y, grub_video_color_t color);
|
||||||
|
|
||||||
|
#endif /* ! GRUB_VBEUTIL_MACHINE_HEADER */
|
|
@ -23,10 +23,18 @@
|
||||||
#include <grub/err.h>
|
#include <grub/err.h>
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
|
|
||||||
|
/* Video color in hardware dependant format. Users should not assume any
|
||||||
|
specific coding format. */
|
||||||
typedef grub_uint32_t grub_video_color_t;
|
typedef grub_uint32_t grub_video_color_t;
|
||||||
|
|
||||||
|
/* This structure is driver specific and should not be accessed directly by
|
||||||
|
outside code. */
|
||||||
struct grub_video_render_target;
|
struct grub_video_render_target;
|
||||||
|
|
||||||
|
/* Forward declarations for used data structures. */
|
||||||
|
struct grub_font_glyph;
|
||||||
|
struct grub_video_bitmap;
|
||||||
|
|
||||||
/* Defines used to describe video mode or rendering target. */
|
/* Defines used to describe video mode or rendering target. */
|
||||||
#define GRUB_VIDEO_MODE_TYPE_ALPHA 0x00000008
|
#define GRUB_VIDEO_MODE_TYPE_ALPHA 0x00000008
|
||||||
#define GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED 0x00000004
|
#define GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED 0x00000004
|
||||||
|
@ -60,6 +68,15 @@ enum grub_video_blit_format
|
||||||
GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR
|
GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Define blitting operators. */
|
||||||
|
enum grub_video_blit_operators
|
||||||
|
{
|
||||||
|
/* Replace target bitmap data with source. */
|
||||||
|
GRUB_VIDEO_BLIT_REPLACE,
|
||||||
|
/* Blend target and source based on source's alpha value. */
|
||||||
|
GRUB_VIDEO_BLIT_BLEND
|
||||||
|
};
|
||||||
|
|
||||||
struct grub_video_mode_info
|
struct grub_video_mode_info
|
||||||
{
|
{
|
||||||
/* Width of the screen. */
|
/* Width of the screen. */
|
||||||
|
@ -113,29 +130,6 @@ struct grub_video_mode_info
|
||||||
unsigned int reserved_field_pos;
|
unsigned int reserved_field_pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct grub_video_render_target
|
|
||||||
{
|
|
||||||
/* Copy of the screen's mode info structure, except that width, height and
|
|
||||||
mode_type has been re-adjusted to requested render target settings. */
|
|
||||||
struct grub_video_mode_info mode_info;
|
|
||||||
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned int x;
|
|
||||||
unsigned int y;
|
|
||||||
unsigned int width;
|
|
||||||
unsigned int height;
|
|
||||||
} viewport;
|
|
||||||
|
|
||||||
/* Indicates wether the data has been allocated by us and must be freed
|
|
||||||
when render target is destroyed. */
|
|
||||||
int is_allocated;
|
|
||||||
|
|
||||||
/* Pointer to data. Can either be in video card memory or in local host's
|
|
||||||
memory. */
|
|
||||||
void *data;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct grub_video_palette_data
|
struct grub_video_palette_data
|
||||||
{
|
{
|
||||||
grub_uint8_t r; /* Red color value (0-255). */
|
grub_uint8_t r; /* Red color value (0-255). */
|
||||||
|
@ -144,9 +138,6 @@ struct grub_video_palette_data
|
||||||
grub_uint8_t a; /* Reserved bits value (0-255). */
|
grub_uint8_t a; /* Reserved bits value (0-255). */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct grub_font_glyph;
|
|
||||||
struct grub_video_bitmap;
|
|
||||||
|
|
||||||
struct grub_video_adapter
|
struct grub_video_adapter
|
||||||
{
|
{
|
||||||
/* The video adapter name. */
|
/* The video adapter name. */
|
||||||
|
@ -190,10 +181,12 @@ struct grub_video_adapter
|
||||||
grub_video_color_t color, int x, int y);
|
grub_video_color_t color, int x, int y);
|
||||||
|
|
||||||
grub_err_t (*blit_bitmap) (struct grub_video_bitmap *bitmap,
|
grub_err_t (*blit_bitmap) (struct grub_video_bitmap *bitmap,
|
||||||
|
enum grub_video_blit_operators oper,
|
||||||
int x, int y, int offset_x, int offset_y,
|
int x, int y, int offset_x, int offset_y,
|
||||||
unsigned int width, unsigned int height);
|
unsigned int width, unsigned int height);
|
||||||
|
|
||||||
grub_err_t (*blit_render_target) (struct grub_video_render_target *source,
|
grub_err_t (*blit_render_target) (struct grub_video_render_target *source,
|
||||||
|
enum grub_video_blit_operators oper,
|
||||||
int x, int y, int offset_x, int offset_y,
|
int x, int y, int offset_x, int offset_y,
|
||||||
unsigned int width, unsigned int height);
|
unsigned int width, unsigned int height);
|
||||||
|
|
||||||
|
@ -254,10 +247,12 @@ grub_err_t grub_video_blit_glyph (struct grub_font_glyph *glyph,
|
||||||
grub_video_color_t color, int x, int y);
|
grub_video_color_t color, int x, int y);
|
||||||
|
|
||||||
grub_err_t grub_video_blit_bitmap (struct grub_video_bitmap *bitmap,
|
grub_err_t grub_video_blit_bitmap (struct grub_video_bitmap *bitmap,
|
||||||
|
enum grub_video_blit_operators oper,
|
||||||
int x, int y, int offset_x, int offset_y,
|
int x, int y, int offset_x, int offset_y,
|
||||||
unsigned int width, unsigned int height);
|
unsigned int width, unsigned int height);
|
||||||
|
|
||||||
grub_err_t grub_video_blit_render_target (struct grub_video_render_target *source,
|
grub_err_t grub_video_blit_render_target (struct grub_video_render_target *source,
|
||||||
|
enum grub_video_blit_operators oper,
|
||||||
int x, int y,
|
int x, int y,
|
||||||
int offset_x, int offset_y,
|
int offset_x, int offset_y,
|
||||||
unsigned int width,
|
unsigned int width,
|
||||||
|
|
|
@ -362,7 +362,7 @@ redraw_screen_rect (unsigned int x, unsigned int y,
|
||||||
grub_video_fill_rect (color, x, y, width, height);
|
grub_video_fill_rect (color, x, y, width, height);
|
||||||
|
|
||||||
/* Render text layer. */
|
/* Render text layer. */
|
||||||
grub_video_blit_render_target (text_layer, x, y,
|
grub_video_blit_render_target (text_layer, GRUB_VIDEO_BLIT_BLEND, x, y,
|
||||||
x - virtual_screen.offset_x,
|
x - virtual_screen.offset_x,
|
||||||
y - virtual_screen.offset_y,
|
y - virtual_screen.offset_y,
|
||||||
width, height);
|
width, height);
|
||||||
|
|
257
video/bitmap.c
Normal file
257
video/bitmap.c
Normal file
|
@ -0,0 +1,257 @@
|
||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2006 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <grub/video.h>
|
||||||
|
#include <grub/bitmap.h>
|
||||||
|
#include <grub/types.h>
|
||||||
|
#include <grub/dl.h>
|
||||||
|
#include <grub/mm.h>
|
||||||
|
#include <grub/misc.h>
|
||||||
|
|
||||||
|
/* List of bitmap readers registered to system. */
|
||||||
|
static grub_video_bitmap_reader_t bitmap_readers_list;
|
||||||
|
|
||||||
|
/* Register bitmap reader. */
|
||||||
|
void
|
||||||
|
grub_video_bitmap_reader_register (grub_video_bitmap_reader_t reader)
|
||||||
|
{
|
||||||
|
reader->next = bitmap_readers_list;
|
||||||
|
bitmap_readers_list = reader;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Unregister bitmap reader. */
|
||||||
|
void
|
||||||
|
grub_video_bitmap_reader_unregister (grub_video_bitmap_reader_t reader)
|
||||||
|
{
|
||||||
|
grub_video_bitmap_reader_t *p, q;
|
||||||
|
|
||||||
|
for (p = &bitmap_readers_list, q = *p; q; p = &(q->next), q = q->next)
|
||||||
|
if (q == reader)
|
||||||
|
{
|
||||||
|
*p = q->next;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Creates new bitmap, saves created bitmap on success to *bitmap. */
|
||||||
|
grub_err_t
|
||||||
|
grub_video_bitmap_create (struct grub_video_bitmap **bitmap,
|
||||||
|
unsigned int width, unsigned int height,
|
||||||
|
enum grub_video_blit_format blit_format)
|
||||||
|
{
|
||||||
|
struct grub_video_mode_info *mode_info;
|
||||||
|
unsigned int size;
|
||||||
|
|
||||||
|
if (!bitmap)
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid argument.");
|
||||||
|
|
||||||
|
*bitmap = 0;
|
||||||
|
|
||||||
|
if (width == 0 || height == 0)
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid argument.");
|
||||||
|
|
||||||
|
*bitmap = (struct grub_video_bitmap *)grub_malloc (sizeof (struct grub_video_bitmap));
|
||||||
|
if (! *bitmap)
|
||||||
|
return grub_errno;
|
||||||
|
|
||||||
|
mode_info = &((*bitmap)->mode_info);
|
||||||
|
|
||||||
|
/* Populate mode_info. */
|
||||||
|
mode_info->width = width;
|
||||||
|
mode_info->height = height;
|
||||||
|
mode_info->blit_format = blit_format;
|
||||||
|
|
||||||
|
switch (blit_format)
|
||||||
|
{
|
||||||
|
case GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8:
|
||||||
|
mode_info->mode_type = GRUB_VIDEO_MODE_TYPE_RGB
|
||||||
|
| GRUB_VIDEO_MODE_TYPE_ALPHA;
|
||||||
|
mode_info->bpp = 32;
|
||||||
|
mode_info->bytes_per_pixel = 4;
|
||||||
|
mode_info->number_of_colors = 256;
|
||||||
|
mode_info->red_mask_size = 8;
|
||||||
|
mode_info->red_field_pos = 0;
|
||||||
|
mode_info->green_mask_size = 8;
|
||||||
|
mode_info->green_field_pos = 8;
|
||||||
|
mode_info->blue_mask_size = 8;
|
||||||
|
mode_info->blue_field_pos = 16;
|
||||||
|
mode_info->reserved_mask_size = 8;
|
||||||
|
mode_info->reserved_field_pos = 24;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GRUB_VIDEO_BLIT_FORMAT_R8G8B8:
|
||||||
|
mode_info->mode_type = GRUB_VIDEO_MODE_TYPE_RGB;
|
||||||
|
mode_info->bpp = 24;
|
||||||
|
mode_info->bytes_per_pixel = 3;
|
||||||
|
mode_info->number_of_colors = 256;
|
||||||
|
mode_info->red_mask_size = 8;
|
||||||
|
mode_info->red_field_pos = 0;
|
||||||
|
mode_info->green_mask_size = 8;
|
||||||
|
mode_info->green_field_pos = 8;
|
||||||
|
mode_info->blue_mask_size = 8;
|
||||||
|
mode_info->blue_field_pos = 16;
|
||||||
|
mode_info->reserved_mask_size = 0;
|
||||||
|
mode_info->reserved_field_pos = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR:
|
||||||
|
mode_info->mode_type = GRUB_VIDEO_MODE_TYPE_INDEX_COLOR;
|
||||||
|
mode_info->bpp = 8;
|
||||||
|
mode_info->bytes_per_pixel = 1;
|
||||||
|
mode_info->number_of_colors = 256;
|
||||||
|
mode_info->red_mask_size = 0;
|
||||||
|
mode_info->red_field_pos = 0;
|
||||||
|
mode_info->green_mask_size = 0;
|
||||||
|
mode_info->green_field_pos = 0;
|
||||||
|
mode_info->blue_mask_size = 0;
|
||||||
|
mode_info->blue_field_pos = 0;
|
||||||
|
mode_info->reserved_mask_size = 0;
|
||||||
|
mode_info->reserved_field_pos = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
grub_free (*bitmap);
|
||||||
|
*bitmap = 0;
|
||||||
|
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||||
|
"Unsupported bitmap format");
|
||||||
|
}
|
||||||
|
|
||||||
|
mode_info->pitch = width * mode_info->bytes_per_pixel;
|
||||||
|
|
||||||
|
/* Calculate size needed for the data. */
|
||||||
|
size = (width * mode_info->bytes_per_pixel) * height;
|
||||||
|
|
||||||
|
(*bitmap)->data = grub_malloc (size);
|
||||||
|
if (! (*bitmap)->data)
|
||||||
|
{
|
||||||
|
grub_free (*bitmap);
|
||||||
|
*bitmap = 0;
|
||||||
|
|
||||||
|
return grub_errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clear bitmap. */
|
||||||
|
grub_memset ((*bitmap)->data, 0, size);
|
||||||
|
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Frees all resources allocated by bitmap. */
|
||||||
|
grub_err_t
|
||||||
|
grub_video_bitmap_destroy (struct grub_video_bitmap *bitmap)
|
||||||
|
{
|
||||||
|
if (! bitmap)
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
|
||||||
|
grub_free (bitmap->data);
|
||||||
|
grub_free (bitmap);
|
||||||
|
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Match extension to filename. */
|
||||||
|
static int
|
||||||
|
match_extension (const char *filename, const char *ext)
|
||||||
|
{
|
||||||
|
int pos;
|
||||||
|
int ext_len;
|
||||||
|
|
||||||
|
pos = grub_strlen (filename);
|
||||||
|
ext_len = grub_strlen (ext);
|
||||||
|
|
||||||
|
if (! pos || ! ext_len || ext_len > pos)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
pos -= ext_len;
|
||||||
|
|
||||||
|
return grub_strcmp (filename + pos, ext) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Loads bitmap using registered bitmap readers. */
|
||||||
|
grub_err_t
|
||||||
|
grub_video_bitmap_load (struct grub_video_bitmap **bitmap,
|
||||||
|
const char *filename)
|
||||||
|
{
|
||||||
|
grub_video_bitmap_reader_t reader = bitmap_readers_list;
|
||||||
|
|
||||||
|
if (!bitmap)
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid argument.");
|
||||||
|
|
||||||
|
*bitmap = 0;
|
||||||
|
|
||||||
|
while (reader)
|
||||||
|
{
|
||||||
|
if (match_extension (filename, reader->extension))
|
||||||
|
return reader->reader (bitmap, filename);
|
||||||
|
|
||||||
|
reader = reader->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
return grub_error(GRUB_ERR_BAD_FILE_TYPE, "unsupported bitmap format");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return bitmap width. */
|
||||||
|
unsigned int
|
||||||
|
grub_video_bitmap_get_width (struct grub_video_bitmap *bitmap)
|
||||||
|
{
|
||||||
|
if (!bitmap)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return bitmap->mode_info.width;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return bitmap height. */
|
||||||
|
unsigned int
|
||||||
|
grub_video_bitmap_get_height (struct grub_video_bitmap *bitmap)
|
||||||
|
{
|
||||||
|
if (!bitmap)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return bitmap->mode_info.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return mode info for bitmap. */
|
||||||
|
void grub_video_bitmap_get_mode_info (struct grub_video_bitmap *bitmap,
|
||||||
|
struct grub_video_mode_info *mode_info)
|
||||||
|
{
|
||||||
|
if (!bitmap)
|
||||||
|
return;
|
||||||
|
|
||||||
|
*mode_info = bitmap->mode_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return pointer to bitmap's raw data. */
|
||||||
|
void *grub_video_bitmap_get_data (struct grub_video_bitmap *bitmap)
|
||||||
|
{
|
||||||
|
if (!bitmap)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return bitmap->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialize bitmap module. */
|
||||||
|
GRUB_MOD_INIT(video_bitmap)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Finalize bitmap module. */
|
||||||
|
GRUB_MOD_FINI(video_bitmap)
|
||||||
|
{
|
||||||
|
}
|
|
@ -22,12 +22,14 @@
|
||||||
#include <grub/machine/vbe.h>
|
#include <grub/machine/vbe.h>
|
||||||
#include <grub/machine/vbeblit.h>
|
#include <grub/machine/vbeblit.h>
|
||||||
#include <grub/machine/vbefill.h>
|
#include <grub/machine/vbefill.h>
|
||||||
|
#include <grub/machine/vbeutil.h>
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
#include <grub/dl.h>
|
#include <grub/dl.h>
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/font.h>
|
#include <grub/font.h>
|
||||||
#include <grub/mm.h>
|
#include <grub/mm.h>
|
||||||
#include <grub/video.h>
|
#include <grub/video.h>
|
||||||
|
#include <grub/bitmap.h>
|
||||||
|
|
||||||
/* Specify "standard" VGA palette, some video cards may
|
/* Specify "standard" VGA palette, some video cards may
|
||||||
need this and this will also be used when using RGB modes. */
|
need this and this will also be used when using RGB modes. */
|
||||||
|
@ -75,10 +77,6 @@ static grub_uint32_t initial_mode;
|
||||||
static grub_uint32_t mode_in_use = 0x55aa;
|
static grub_uint32_t mode_in_use = 0x55aa;
|
||||||
static grub_uint16_t *mode_list;
|
static grub_uint16_t *mode_list;
|
||||||
|
|
||||||
static grub_video_color_t
|
|
||||||
grub_video_vbe_map_rgba (grub_uint8_t red, grub_uint8_t green,
|
|
||||||
grub_uint8_t blue, grub_uint8_t alpha);
|
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
real2pm (grub_vbe_farptr_t ptr)
|
real2pm (grub_vbe_farptr_t ptr)
|
||||||
{
|
{
|
||||||
|
@ -299,35 +297,35 @@ grub_vbe_get_video_mode_info (grub_uint32_t mode,
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_uint8_t *
|
grub_uint8_t *
|
||||||
grub_video_vbe_get_video_ptr (struct grub_video_render_target *source,
|
grub_video_vbe_get_video_ptr (struct grub_video_i386_vbeblit_info *source,
|
||||||
grub_uint32_t x, grub_uint32_t y)
|
grub_uint32_t x, grub_uint32_t y)
|
||||||
{
|
{
|
||||||
grub_uint8_t *ptr = 0;
|
grub_uint8_t *ptr = 0;
|
||||||
|
|
||||||
switch (source->mode_info.bpp)
|
switch (source->mode_info->bpp)
|
||||||
{
|
{
|
||||||
case 32:
|
case 32:
|
||||||
ptr = (grub_uint8_t *)source->data
|
ptr = (grub_uint8_t *)source->data
|
||||||
+ y * source->mode_info.pitch
|
+ y * source->mode_info->pitch
|
||||||
+ x * 4;
|
+ x * 4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 24:
|
case 24:
|
||||||
ptr = (grub_uint8_t *)source->data
|
ptr = (grub_uint8_t *)source->data
|
||||||
+ y * source->mode_info.pitch
|
+ y * source->mode_info->pitch
|
||||||
+ x * 3;
|
+ x * 3;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 16:
|
case 16:
|
||||||
case 15:
|
case 15:
|
||||||
ptr = (grub_uint8_t *)source->data
|
ptr = (grub_uint8_t *)source->data
|
||||||
+ y * source->mode_info.pitch
|
+ y * source->mode_info->pitch
|
||||||
+ x * 2;
|
+ x * 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
ptr = (grub_uint8_t *)source->data
|
ptr = (grub_uint8_t *)source->data
|
||||||
+ y * source->mode_info.pitch
|
+ y * source->mode_info->pitch
|
||||||
+ x;
|
+ x;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -335,112 +333,6 @@ grub_video_vbe_get_video_ptr (struct grub_video_render_target *source,
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
grub_video_vbe_draw_pixel (grub_uint32_t x, grub_uint32_t y,
|
|
||||||
grub_video_color_t color)
|
|
||||||
{
|
|
||||||
if (x >= render_target->mode_info.width)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (y >= render_target->mode_info.height)
|
|
||||||
return;
|
|
||||||
|
|
||||||
switch (render_target->mode_info.bpp)
|
|
||||||
{
|
|
||||||
case 32:
|
|
||||||
{
|
|
||||||
grub_uint32_t *ptr;
|
|
||||||
|
|
||||||
ptr = (grub_uint32_t *)grub_video_vbe_get_video_ptr (render_target,
|
|
||||||
x, y);
|
|
||||||
|
|
||||||
*ptr = color;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 24:
|
|
||||||
{
|
|
||||||
grub_uint8_t *ptr;
|
|
||||||
grub_uint8_t *ptr2 = (grub_uint8_t *) &color;
|
|
||||||
|
|
||||||
ptr = grub_video_vbe_get_video_ptr (render_target, x, y);
|
|
||||||
|
|
||||||
ptr[0] = ptr2[0];
|
|
||||||
ptr[1] = ptr2[1];
|
|
||||||
ptr[2] = ptr2[2];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 16:
|
|
||||||
case 15:
|
|
||||||
{
|
|
||||||
grub_uint16_t *ptr;
|
|
||||||
|
|
||||||
ptr = (grub_uint16_t *)grub_video_vbe_get_video_ptr (render_target,
|
|
||||||
x, y);
|
|
||||||
|
|
||||||
*ptr = (grub_uint16_t) (color & 0xFFFF);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 8:
|
|
||||||
{
|
|
||||||
grub_uint8_t *ptr;
|
|
||||||
|
|
||||||
ptr = (grub_uint8_t *)grub_video_vbe_get_video_ptr (render_target,
|
|
||||||
x, y);
|
|
||||||
|
|
||||||
*ptr = (grub_uint8_t) (color & 0xFF);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static grub_video_color_t
|
|
||||||
grub_video_vbe_get_pixel (struct grub_video_render_target *source,
|
|
||||||
grub_uint32_t x, grub_uint32_t y)
|
|
||||||
{
|
|
||||||
grub_video_color_t color = 0;
|
|
||||||
|
|
||||||
if (x >= source->mode_info.width)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (y >= source->mode_info.height)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
switch (source->mode_info.bpp)
|
|
||||||
{
|
|
||||||
case 32:
|
|
||||||
color = *(grub_uint32_t *)grub_video_vbe_get_video_ptr (source, x, y);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 24:
|
|
||||||
{
|
|
||||||
grub_uint8_t *ptr;
|
|
||||||
ptr = grub_video_vbe_get_video_ptr (source, x, y);
|
|
||||||
color = ptr[0] | (ptr[1] << 8) | (ptr[2] << 16);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 16:
|
|
||||||
case 15:
|
|
||||||
color = *(grub_uint16_t *)grub_video_vbe_get_video_ptr (source, x, y);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 8:
|
|
||||||
color = *(grub_uint8_t *)grub_video_vbe_get_video_ptr (source, x, y);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
grub_video_vbe_init (void)
|
grub_video_vbe_init (void)
|
||||||
{
|
{
|
||||||
|
@ -836,7 +728,7 @@ grub_video_vbe_map_rgb (grub_uint8_t red, grub_uint8_t green,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_video_color_t
|
grub_video_color_t
|
||||||
grub_video_vbe_map_rgba (grub_uint8_t red, grub_uint8_t green,
|
grub_video_vbe_map_rgba (grub_uint8_t red, grub_uint8_t green,
|
||||||
grub_uint8_t blue, grub_uint8_t alpha)
|
grub_uint8_t blue, grub_uint8_t alpha)
|
||||||
{
|
{
|
||||||
|
@ -864,12 +756,15 @@ grub_video_vbe_map_rgba (grub_uint8_t red, grub_uint8_t green,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_video_vbe_unmap_color (struct grub_video_render_target * source,
|
grub_video_vbe_unmap_color (struct grub_video_i386_vbeblit_info * source,
|
||||||
grub_video_color_t color,
|
grub_video_color_t color,
|
||||||
grub_uint8_t *red, grub_uint8_t *green,
|
grub_uint8_t *red, grub_uint8_t *green,
|
||||||
grub_uint8_t *blue, grub_uint8_t *alpha)
|
grub_uint8_t *blue, grub_uint8_t *alpha)
|
||||||
{
|
{
|
||||||
if ((source->mode_info.mode_type
|
struct grub_video_mode_info *mode_info;
|
||||||
|
mode_info = source->mode_info;
|
||||||
|
|
||||||
|
if ((mode_info->mode_type
|
||||||
& GRUB_VIDEO_MODE_TYPE_INDEX_COLOR) != 0)
|
& GRUB_VIDEO_MODE_TYPE_INDEX_COLOR) != 0)
|
||||||
{
|
{
|
||||||
/* If we have out of bounds color, return trasnparent black. */
|
/* If we have out of bounds color, return trasnparent black. */
|
||||||
|
@ -893,33 +788,33 @@ grub_video_vbe_unmap_color (struct grub_video_render_target * source,
|
||||||
grub_uint32_t tmp;
|
grub_uint32_t tmp;
|
||||||
|
|
||||||
/* Get red component. */
|
/* Get red component. */
|
||||||
tmp = color >> source->mode_info.red_field_pos;
|
tmp = color >> mode_info->red_field_pos;
|
||||||
tmp &= (1 << source->mode_info.red_mask_size) - 1;
|
tmp &= (1 << mode_info->red_mask_size) - 1;
|
||||||
tmp <<= 8 - source->mode_info.red_mask_size;
|
tmp <<= 8 - mode_info->red_mask_size;
|
||||||
tmp |= (1 << (8 - source->mode_info.red_mask_size)) - 1;
|
tmp |= (1 << (8 - mode_info->red_mask_size)) - 1;
|
||||||
*red = tmp & 0xFF;
|
*red = tmp & 0xFF;
|
||||||
|
|
||||||
/* Get green component. */
|
/* Get green component. */
|
||||||
tmp = color >> source->mode_info.green_field_pos;
|
tmp = color >> mode_info->green_field_pos;
|
||||||
tmp &= (1 << source->mode_info.green_mask_size) - 1;
|
tmp &= (1 << mode_info->green_mask_size) - 1;
|
||||||
tmp <<= 8 - source->mode_info.green_mask_size;
|
tmp <<= 8 - mode_info->green_mask_size;
|
||||||
tmp |= (1 << (8 - source->mode_info.green_mask_size)) - 1;
|
tmp |= (1 << (8 - mode_info->green_mask_size)) - 1;
|
||||||
*green = tmp & 0xFF;
|
*green = tmp & 0xFF;
|
||||||
|
|
||||||
/* Get blue component. */
|
/* Get blue component. */
|
||||||
tmp = color >> source->mode_info.blue_field_pos;
|
tmp = color >> mode_info->blue_field_pos;
|
||||||
tmp &= (1 << source->mode_info.blue_mask_size) - 1;
|
tmp &= (1 << mode_info->blue_mask_size) - 1;
|
||||||
tmp <<= 8 - source->mode_info.blue_mask_size;
|
tmp <<= 8 - mode_info->blue_mask_size;
|
||||||
tmp |= (1 << (8 - source->mode_info.blue_mask_size)) - 1;
|
tmp |= (1 << (8 - mode_info->blue_mask_size)) - 1;
|
||||||
*blue = tmp & 0xFF;
|
*blue = tmp & 0xFF;
|
||||||
|
|
||||||
/* Get alpha component. */
|
/* Get alpha component. */
|
||||||
if (source->mode_info.reserved_mask_size > 0)
|
if (source->mode_info->reserved_mask_size > 0)
|
||||||
{
|
{
|
||||||
tmp = color >> source->mode_info.reserved_field_pos;
|
tmp = color >> mode_info->reserved_field_pos;
|
||||||
tmp &= (1 << source->mode_info.reserved_mask_size) - 1;
|
tmp &= (1 << mode_info->reserved_mask_size) - 1;
|
||||||
tmp <<= 8 - source->mode_info.reserved_mask_size;
|
tmp <<= 8 - mode_info->reserved_mask_size;
|
||||||
tmp |= (1 << (8 - source->mode_info.reserved_mask_size)) - 1;
|
tmp |= (1 << (8 - mode_info->reserved_mask_size)) - 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
/* If there is no alpha component, assume it opaque. */
|
/* If there is no alpha component, assume it opaque. */
|
||||||
|
@ -933,7 +828,7 @@ static grub_err_t
|
||||||
grub_video_vbe_fill_rect (grub_video_color_t color, int x, int y,
|
grub_video_vbe_fill_rect (grub_video_color_t color, int x, int y,
|
||||||
unsigned int width, unsigned int height)
|
unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
unsigned int i, j;
|
struct grub_video_i386_vbeblit_info target;
|
||||||
|
|
||||||
/* Make sure there is something to do. */
|
/* Make sure there is something to do. */
|
||||||
if ((x >= (int)render_target->viewport.width) || (x + (int)width < 0))
|
if ((x >= (int)render_target->viewport.width) || (x + (int)width < 0))
|
||||||
|
@ -962,40 +857,44 @@ grub_video_vbe_fill_rect (grub_video_color_t color, int x, int y,
|
||||||
x += render_target->viewport.x;
|
x += render_target->viewport.x;
|
||||||
y += render_target->viewport.y;
|
y += render_target->viewport.y;
|
||||||
|
|
||||||
|
/* Use vbeblit_info to encapsulate rendering. */
|
||||||
|
target.mode_info = &render_target->mode_info;
|
||||||
|
target.data = render_target->data;
|
||||||
|
|
||||||
/* Try to figure out more optimized version. */
|
/* Try to figure out more optimized version. */
|
||||||
if (render_target->mode_info.blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8)
|
if (target.mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8)
|
||||||
{
|
{
|
||||||
grub_video_i386_vbefill_R8G8B8A8 (render_target, color, x, y,
|
grub_video_i386_vbefill_R8G8B8A8 (&target, color, x, y,
|
||||||
width, height);
|
width, height);
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (render_target->mode_info.blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8)
|
if (target.mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8)
|
||||||
{
|
{
|
||||||
grub_video_i386_vbefill_R8G8B8 (render_target, color, x, y,
|
grub_video_i386_vbefill_R8G8B8 (&target, color, x, y,
|
||||||
width, height);
|
width, height);
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (render_target->mode_info.blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
|
if (target.mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
|
||||||
{
|
{
|
||||||
grub_video_i386_vbefill_index (render_target, color, x, y,
|
grub_video_i386_vbefill_index (&target, color, x, y,
|
||||||
width, height);
|
width, height);
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Use backup method to fill area. */
|
/* No optimized version found, use default (slow) filler. */
|
||||||
for (j = 0; j < height; j++)
|
grub_video_i386_vbefill (&target, color, x, y, width, height);
|
||||||
for (i = 0; i < width; i++)
|
|
||||||
grub_video_vbe_draw_pixel (x+i, y+j, color);
|
|
||||||
|
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove this method and replace with bitmap based glyphs
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
grub_video_vbe_blit_glyph (struct grub_font_glyph * glyph,
|
grub_video_vbe_blit_glyph (struct grub_font_glyph * glyph,
|
||||||
grub_video_color_t color, int x, int y)
|
grub_video_color_t color, int x, int y)
|
||||||
{
|
{
|
||||||
|
struct grub_video_i386_vbeblit_info target;
|
||||||
unsigned int width;
|
unsigned int width;
|
||||||
unsigned int charwidth;
|
unsigned int charwidth;
|
||||||
unsigned int height;
|
unsigned int height;
|
||||||
|
@ -1045,29 +944,204 @@ grub_video_vbe_blit_glyph (struct grub_font_glyph * glyph,
|
||||||
x += render_target->viewport.x;
|
x += render_target->viewport.x;
|
||||||
y += render_target->viewport.y;
|
y += render_target->viewport.y;
|
||||||
|
|
||||||
|
/* Use vbeblit_info to encapsulate rendering. */
|
||||||
|
target.mode_info = &render_target->mode_info;
|
||||||
|
target.data = render_target->data;
|
||||||
|
|
||||||
/* Draw glyph. */
|
/* Draw glyph. */
|
||||||
for (j = 0; j < height; j++)
|
for (j = 0; j < height; j++)
|
||||||
for (i = 0; i < width; i++)
|
for (i = 0; i < width; i++)
|
||||||
if ((glyph->bitmap[((i + x_offset) / 8)
|
if ((glyph->bitmap[((i + x_offset) / 8)
|
||||||
+ (j + y_offset) * (charwidth / 8)]
|
+ (j + y_offset) * (charwidth / 8)]
|
||||||
& (1 << ((charwidth - (i + x_offset) - 1) % 8))))
|
& (1 << ((charwidth - (i + x_offset) - 1) % 8))))
|
||||||
grub_video_vbe_draw_pixel (x+i, y+j, color);
|
set_pixel (&target, x+i, y+j, color);
|
||||||
|
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* NOTE: This function assumes that given coordiantes are within bounds of
|
||||||
|
handled data. */
|
||||||
|
static void
|
||||||
|
common_blitter (struct grub_video_i386_vbeblit_info *target,
|
||||||
|
struct grub_video_i386_vbeblit_info *source,
|
||||||
|
enum grub_video_blit_operators oper, int x, int y,
|
||||||
|
unsigned int width, unsigned int height,
|
||||||
|
int offset_x, int offset_y)
|
||||||
|
{
|
||||||
|
if (oper == GRUB_VIDEO_BLIT_REPLACE)
|
||||||
|
{
|
||||||
|
/* Try to figure out more optimized version for replace operator. */
|
||||||
|
if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8)
|
||||||
|
{
|
||||||
|
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8)
|
||||||
|
{
|
||||||
|
grub_video_i386_vbeblit_R8G8B8X8_R8G8B8X8 (target, source,
|
||||||
|
x, y, width, height,
|
||||||
|
offset_x, offset_y);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8)
|
||||||
|
{
|
||||||
|
grub_video_i386_vbeblit_R8G8B8_R8G8B8X8 (target, source,
|
||||||
|
x, y, width, height,
|
||||||
|
offset_x, offset_y);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
|
||||||
|
{
|
||||||
|
grub_video_i386_vbeblit_index_R8G8B8X8 (target, source,
|
||||||
|
x, y, width, height,
|
||||||
|
offset_x, offset_y);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8)
|
||||||
|
{
|
||||||
|
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8)
|
||||||
|
{
|
||||||
|
grub_video_i386_vbeblit_R8G8B8A8_R8G8B8 (target, source,
|
||||||
|
x, y, width, height,
|
||||||
|
offset_x, offset_y);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8)
|
||||||
|
{
|
||||||
|
grub_video_i386_vbeblit_R8G8B8_R8G8B8 (target, source,
|
||||||
|
x, y, width, height,
|
||||||
|
offset_x, offset_y);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
|
||||||
|
{
|
||||||
|
grub_video_i386_vbeblit_index_R8G8B8 (target, source,
|
||||||
|
x, y, width, height,
|
||||||
|
offset_x, offset_y);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
|
||||||
|
{
|
||||||
|
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
|
||||||
|
{
|
||||||
|
grub_video_i386_vbeblit_index_index (target, source,
|
||||||
|
x, y, width, height,
|
||||||
|
offset_x, offset_y);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* No optimized replace operator found, use default (slow) blitter. */
|
||||||
|
grub_video_i386_vbeblit_replace (target, source, x, y, width, height,
|
||||||
|
offset_x, offset_y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Try to figure out more optimized blend operator. */
|
||||||
|
if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8)
|
||||||
|
{
|
||||||
|
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8)
|
||||||
|
{
|
||||||
|
grub_video_i386_vbeblit_R8G8B8A8_R8G8B8A8 (target, source,
|
||||||
|
x, y, width, height,
|
||||||
|
offset_x, offset_y);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8)
|
||||||
|
{
|
||||||
|
grub_video_i386_vbeblit_R8G8B8_R8G8B8A8 (target, source,
|
||||||
|
x, y, width, height,
|
||||||
|
offset_x, offset_y);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
|
||||||
|
{
|
||||||
|
grub_video_i386_vbeblit_index_R8G8B8A8 (target, source,
|
||||||
|
x, y, width, height,
|
||||||
|
offset_x, offset_y);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8)
|
||||||
|
{
|
||||||
|
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8)
|
||||||
|
{
|
||||||
|
grub_video_i386_vbeblit_R8G8B8A8_R8G8B8 (target, source,
|
||||||
|
x, y, width, height,
|
||||||
|
offset_x, offset_y);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8)
|
||||||
|
{
|
||||||
|
grub_video_i386_vbeblit_R8G8B8_R8G8B8 (target, source,
|
||||||
|
x, y, width, height,
|
||||||
|
offset_x, offset_y);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
|
||||||
|
{
|
||||||
|
grub_video_i386_vbeblit_index_R8G8B8 (target, source,
|
||||||
|
x, y, width, height,
|
||||||
|
offset_x, offset_y);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
|
||||||
|
{
|
||||||
|
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
|
||||||
|
{
|
||||||
|
grub_video_i386_vbeblit_index_index (target, source,
|
||||||
|
x, y, width, height,
|
||||||
|
offset_x, offset_y);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* No optimized blend operation found, use default (slow) blitter. */
|
||||||
|
grub_video_i386_vbeblit_blend (target, source, x, y, width, height,
|
||||||
|
offset_x, offset_y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
grub_video_vbe_blit_bitmap (struct grub_video_bitmap *bitmap,
|
grub_video_vbe_blit_bitmap (struct grub_video_bitmap *bitmap,
|
||||||
int x, int y, int offset_x, int offset_y,
|
enum grub_video_blit_operators oper, int x, int y,
|
||||||
|
int offset_x, int offset_y,
|
||||||
unsigned int width, unsigned int height)
|
unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
|
struct grub_video_i386_vbeblit_info source;
|
||||||
|
struct grub_video_i386_vbeblit_info target;
|
||||||
|
|
||||||
/* Make sure there is something to do. */
|
/* Make sure there is something to do. */
|
||||||
|
if ((width == 0) || (height == 0))
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
if ((x >= (int)render_target->viewport.width) || (x + (int)width < 0))
|
if ((x >= (int)render_target->viewport.width) || (x + (int)width < 0))
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
if ((y >= (int)render_target->viewport.height) || (y + (int)height < 0))
|
if ((y >= (int)render_target->viewport.height) || (y + (int)height < 0))
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
|
if ((x + (int)bitmap->mode_info.width) < 0)
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
if ((y + (int)bitmap->mode_info.height) < 0)
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
if ((offset_x >= (int)bitmap->mode_info.width)
|
||||||
|
|| (offset_x + (int)width < 0))
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
if ((offset_y >= (int)bitmap->mode_info.height)
|
||||||
|
|| (offset_y + (int)height < 0))
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
|
||||||
/* Do not allow drawing out of viewport. */
|
/* If we have negative coordinates, optimize drawing to minimum. */
|
||||||
if (offset_x < 0)
|
if (offset_x < 0)
|
||||||
{
|
{
|
||||||
width += offset_x;
|
width += offset_x;
|
||||||
|
@ -1085,39 +1159,60 @@ grub_video_vbe_blit_bitmap (struct grub_video_bitmap * bitmap,
|
||||||
if (x < 0)
|
if (x < 0)
|
||||||
{
|
{
|
||||||
width += x;
|
width += x;
|
||||||
offset_x += (unsigned int)-x;
|
offset_x -= x;
|
||||||
x = 0;
|
x = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (y < 0)
|
if (y < 0)
|
||||||
{
|
{
|
||||||
height += y;
|
height += y;
|
||||||
offset_y += (unsigned int)-y;
|
offset_y -= y;
|
||||||
y = 0;
|
y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Do not allow drawing out of viewport. */
|
||||||
if ((x + width) > render_target->viewport.width)
|
if ((x + width) > render_target->viewport.width)
|
||||||
width = render_target->viewport.width - x;
|
width = render_target->viewport.width - x;
|
||||||
if ((y + height) > render_target->viewport.height)
|
if ((y + height) > render_target->viewport.height)
|
||||||
height = render_target->viewport.height - y;
|
height = render_target->viewport.height - y;
|
||||||
|
|
||||||
/* TODO: Limit drawing to bitmap dimensions. */
|
if ((offset_x + width) > bitmap->mode_info.width)
|
||||||
|
width = bitmap->mode_info.width - offset_x;
|
||||||
|
if ((offset_y + height) > bitmap->mode_info.height)
|
||||||
|
height = bitmap->mode_info.height - offset_y;
|
||||||
|
|
||||||
|
/* Limit drawing to source render target dimensions. */
|
||||||
|
if (width > bitmap->mode_info.width)
|
||||||
|
width = bitmap->mode_info.width;
|
||||||
|
|
||||||
|
if (height > bitmap->mode_info.height)
|
||||||
|
height = bitmap->mode_info.height;
|
||||||
|
|
||||||
/* Add viewport offset. */
|
/* Add viewport offset. */
|
||||||
x += render_target->viewport.x;
|
x += render_target->viewport.x;
|
||||||
y += render_target->viewport.y;
|
y += render_target->viewport.y;
|
||||||
|
|
||||||
/* TODO: Render bitmap. */
|
/* Use vbeblit_info to encapsulate rendering. */
|
||||||
|
source.mode_info = &bitmap->mode_info;
|
||||||
|
source.data = bitmap->data;
|
||||||
|
target.mode_info = &render_target->mode_info;
|
||||||
|
target.data = render_target->data;
|
||||||
|
|
||||||
|
/* Do actual blitting. */
|
||||||
|
common_blitter (&target, &source, oper, x, y, width, height,
|
||||||
|
offset_x, offset_y);
|
||||||
|
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
grub_video_vbe_blit_render_target (struct grub_video_render_target *source,
|
grub_video_vbe_blit_render_target (struct grub_video_render_target *source,
|
||||||
|
enum grub_video_blit_operators oper,
|
||||||
int x, int y, int offset_x, int offset_y,
|
int x, int y, int offset_x, int offset_y,
|
||||||
unsigned int width, unsigned int height)
|
unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
struct grub_video_i386_vbeblit_info source_info;
|
||||||
unsigned int j;
|
struct grub_video_i386_vbeblit_info target_info;
|
||||||
|
|
||||||
/* Make sure there is something to do. */
|
/* Make sure there is something to do. */
|
||||||
if ((width == 0) || (height == 0))
|
if ((width == 0) || (height == 0))
|
||||||
|
@ -1155,14 +1250,14 @@ grub_video_vbe_blit_render_target (struct grub_video_render_target *source,
|
||||||
if (x < 0)
|
if (x < 0)
|
||||||
{
|
{
|
||||||
width += x;
|
width += x;
|
||||||
offset_x += (unsigned int)-x;
|
offset_x -= x;
|
||||||
x = 0;
|
x = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (y < 0)
|
if (y < 0)
|
||||||
{
|
{
|
||||||
height += y;
|
height += y;
|
||||||
offset_y += (unsigned int)-y;
|
offset_y -= y;
|
||||||
y = 0;
|
y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1188,122 +1283,15 @@ grub_video_vbe_blit_render_target (struct grub_video_render_target *source,
|
||||||
x += render_target->viewport.x;
|
x += render_target->viewport.x;
|
||||||
y += render_target->viewport.y;
|
y += render_target->viewport.y;
|
||||||
|
|
||||||
/* Try to figure out more optimized version. */
|
/* Use vbeblit_info to encapsulate rendering. */
|
||||||
if (source->mode_info.blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8)
|
source_info.mode_info = &source->mode_info;
|
||||||
{
|
source_info.data = source->data;
|
||||||
if (render_target->mode_info.blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8)
|
target_info.mode_info = &render_target->mode_info;
|
||||||
{
|
target_info.data = render_target->data;
|
||||||
grub_video_i386_vbeblit_R8G8B8A8_R8G8B8A8 (render_target, source,
|
|
||||||
x, y, width, height,
|
/* Do actual blitting. */
|
||||||
|
common_blitter (&target_info, &source_info, oper, x, y, width, height,
|
||||||
offset_x, offset_y);
|
offset_x, offset_y);
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (render_target->mode_info.blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8)
|
|
||||||
{
|
|
||||||
grub_video_i386_vbeblit_R8G8B8_R8G8B8A8 (render_target, source,
|
|
||||||
x, y, width, height,
|
|
||||||
offset_x, offset_y);
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (render_target->mode_info.blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
|
|
||||||
{
|
|
||||||
grub_video_i386_vbeblit_index_R8G8B8A8 (render_target, source,
|
|
||||||
x, y, width, height,
|
|
||||||
offset_x, offset_y);
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (source->mode_info.blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8)
|
|
||||||
{
|
|
||||||
if (render_target->mode_info.blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8)
|
|
||||||
{
|
|
||||||
grub_video_i386_vbeblit_R8G8B8A8_R8G8B8 (render_target, source,
|
|
||||||
x, y, width, height,
|
|
||||||
offset_x, offset_y);
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (render_target->mode_info.blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8)
|
|
||||||
{
|
|
||||||
grub_video_i386_vbeblit_R8G8B8_R8G8B8 (render_target, source,
|
|
||||||
x, y, width, height,
|
|
||||||
offset_x, offset_y);
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (render_target->mode_info.blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
|
|
||||||
{
|
|
||||||
grub_video_i386_vbeblit_index_R8G8B8 (render_target, source,
|
|
||||||
x, y, width, height,
|
|
||||||
offset_x, offset_y);
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (source->mode_info.blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
|
|
||||||
{
|
|
||||||
if (render_target->mode_info.blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
|
|
||||||
{
|
|
||||||
grub_video_i386_vbeblit_index_index (render_target, source,
|
|
||||||
x, y, width, height,
|
|
||||||
offset_x, offset_y);
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Use backup method to render. */
|
|
||||||
for (j = 0; j < height; j++)
|
|
||||||
{
|
|
||||||
for (i = 0; i < width; i++)
|
|
||||||
{
|
|
||||||
grub_uint8_t src_red;
|
|
||||||
grub_uint8_t src_green;
|
|
||||||
grub_uint8_t src_blue;
|
|
||||||
grub_uint8_t src_alpha;
|
|
||||||
grub_uint8_t dst_red;
|
|
||||||
grub_uint8_t dst_green;
|
|
||||||
grub_uint8_t dst_blue;
|
|
||||||
grub_uint8_t dst_alpha;
|
|
||||||
grub_video_color_t src_color;
|
|
||||||
grub_video_color_t dst_color;
|
|
||||||
|
|
||||||
src_color = grub_video_vbe_get_pixel (source, i + offset_x, j + offset_y);
|
|
||||||
grub_video_vbe_unmap_color (source, src_color, &src_red, &src_green,
|
|
||||||
&src_blue, &src_alpha);
|
|
||||||
|
|
||||||
if (src_alpha == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (src_alpha == 255)
|
|
||||||
{
|
|
||||||
dst_color = grub_video_vbe_map_rgba (src_red, src_green,
|
|
||||||
src_blue, src_alpha);
|
|
||||||
grub_video_vbe_draw_pixel (x + i, y + j, dst_color);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
dst_color = grub_video_vbe_get_pixel (render_target, x + i, y + j);
|
|
||||||
|
|
||||||
grub_video_vbe_unmap_color (render_target, dst_color, &dst_red,
|
|
||||||
&dst_green, &dst_blue, &dst_alpha);
|
|
||||||
|
|
||||||
dst_red = (((src_red * src_alpha)
|
|
||||||
+ (dst_red * (255 - src_alpha))) / 255);
|
|
||||||
dst_green = (((src_green * src_alpha)
|
|
||||||
+ (dst_green * (255 - src_alpha))) / 255);
|
|
||||||
dst_blue = (((src_blue * src_alpha)
|
|
||||||
+ (dst_blue * (255 - src_alpha))) / 255);
|
|
||||||
|
|
||||||
dst_alpha = src_alpha;
|
|
||||||
dst_color = grub_video_vbe_map_rgba (dst_red, dst_green, dst_blue,
|
|
||||||
dst_alpha);
|
|
||||||
|
|
||||||
grub_video_vbe_draw_pixel (x + i, y + j, dst_color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
@ -1352,16 +1340,20 @@ grub_video_vbe_scroll (grub_video_color_t color, int dx, int dy)
|
||||||
&& (grub_abs (dy) < render_target->viewport.height))
|
&& (grub_abs (dy) < render_target->viewport.height))
|
||||||
{
|
{
|
||||||
/* 3. Move data in render target. */
|
/* 3. Move data in render target. */
|
||||||
|
struct grub_video_i386_vbeblit_info target;
|
||||||
grub_uint8_t *src;
|
grub_uint8_t *src;
|
||||||
grub_uint8_t *dst;
|
grub_uint8_t *dst;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
|
target.mode_info = &render_target->mode_info;
|
||||||
|
target.data = render_target->data;
|
||||||
|
|
||||||
for (j = 0; j < height; j++)
|
for (j = 0; j < height; j++)
|
||||||
{
|
{
|
||||||
dst = grub_video_vbe_get_video_ptr (render_target, dst_x, dst_y + j);
|
dst = grub_video_vbe_get_video_ptr (&target, dst_x, dst_y + j);
|
||||||
src = grub_video_vbe_get_video_ptr (render_target, src_x, src_y + j);
|
src = grub_video_vbe_get_video_ptr (&target, src_x, src_y + j);
|
||||||
grub_memmove (dst, src,
|
grub_memmove (dst, src,
|
||||||
width * render_target->mode_info.bytes_per_pixel);
|
width * target.mode_info->bytes_per_pixel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,20 +17,27 @@
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <grub/err.h>
|
/* SPECIAL NOTES!
|
||||||
#include <grub/machine/memory.h>
|
|
||||||
|
Please note following when reading the code below:
|
||||||
|
|
||||||
|
- In this driver we assume that every memory can be accessed by same memory
|
||||||
|
bus. If there are different address spaces do not use this code as a base
|
||||||
|
code for other archs.
|
||||||
|
|
||||||
|
- Every function in this code assumes that bounds checking has been done in
|
||||||
|
previous phase and they are opted out in here. */
|
||||||
|
|
||||||
#include <grub/machine/vbe.h>
|
#include <grub/machine/vbe.h>
|
||||||
#include <grub/machine/vbeblit.h>
|
#include <grub/machine/vbeblit.h>
|
||||||
#include <grub/types.h>
|
#include <grub/machine/vbeutil.h>
|
||||||
#include <grub/dl.h>
|
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/font.h>
|
#include <grub/types.h>
|
||||||
#include <grub/mm.h>
|
|
||||||
#include <grub/video.h>
|
#include <grub/video.h>
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_video_i386_vbeblit_R8G8B8A8_R8G8B8A8 (struct grub_video_render_target *dst,
|
grub_video_i386_vbeblit_R8G8B8A8_R8G8B8A8 (struct grub_video_i386_vbeblit_info *dst,
|
||||||
struct grub_video_render_target *src,
|
struct grub_video_i386_vbeblit_info *src,
|
||||||
int x, int y, int width, int height,
|
int x, int y, int width, int height,
|
||||||
int offset_x, int offset_y)
|
int offset_x, int offset_y)
|
||||||
{
|
{
|
||||||
|
@ -52,10 +59,8 @@ grub_video_i386_vbeblit_R8G8B8A8_R8G8B8A8 (struct grub_video_render_target *dst,
|
||||||
|
|
||||||
for (j = 0; j < height; j++)
|
for (j = 0; j < height; j++)
|
||||||
{
|
{
|
||||||
srcptr = (grub_uint32_t *)grub_video_vbe_get_video_ptr (src, offset_x,
|
srcptr = (grub_uint32_t *)get_data_ptr (src, offset_x, j + offset_y);
|
||||||
j + offset_y);
|
dstptr = (grub_uint32_t *)get_data_ptr (dst, x, y + j);
|
||||||
|
|
||||||
dstptr = (grub_uint32_t *)grub_video_vbe_get_video_ptr (dst, x, y + j);
|
|
||||||
|
|
||||||
for (i = 0; i < width; i++)
|
for (i = 0; i < width; i++)
|
||||||
{
|
{
|
||||||
|
@ -97,8 +102,33 @@ grub_video_i386_vbeblit_R8G8B8A8_R8G8B8A8 (struct grub_video_render_target *dst,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_video_i386_vbeblit_R8G8B8_R8G8B8A8 (struct grub_video_render_target *dst,
|
grub_video_i386_vbeblit_R8G8B8X8_R8G8B8X8 (struct grub_video_i386_vbeblit_info *dst,
|
||||||
struct grub_video_render_target *src,
|
struct grub_video_i386_vbeblit_info *src,
|
||||||
|
int x, int y, int width, int height,
|
||||||
|
int offset_x, int offset_y)
|
||||||
|
{
|
||||||
|
int j;
|
||||||
|
grub_uint32_t *srcptr;
|
||||||
|
grub_uint32_t *dstptr;
|
||||||
|
int pitch;
|
||||||
|
|
||||||
|
pitch = src->mode_info->bytes_per_pixel;
|
||||||
|
|
||||||
|
/* We do not need to worry about data being out of bounds
|
||||||
|
as we assume that everything has been checked before. */
|
||||||
|
|
||||||
|
for (j = 0; j < height; j++)
|
||||||
|
{
|
||||||
|
srcptr = (grub_uint32_t *)get_data_ptr (src, offset_x, j + offset_y);
|
||||||
|
dstptr = (grub_uint32_t *)get_data_ptr (dst, x, y + j);
|
||||||
|
|
||||||
|
grub_memmove (dstptr, srcptr, width * pitch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_video_i386_vbeblit_R8G8B8_R8G8B8A8 (struct grub_video_i386_vbeblit_info *dst,
|
||||||
|
struct grub_video_i386_vbeblit_info *src,
|
||||||
int x, int y, int width, int height,
|
int x, int y, int width, int height,
|
||||||
int offset_x, int offset_y)
|
int offset_x, int offset_y)
|
||||||
{
|
{
|
||||||
|
@ -120,10 +150,8 @@ grub_video_i386_vbeblit_R8G8B8_R8G8B8A8 (struct grub_video_render_target *dst,
|
||||||
|
|
||||||
for (j = 0; j < height; j++)
|
for (j = 0; j < height; j++)
|
||||||
{
|
{
|
||||||
srcptr = (grub_uint32_t *)grub_video_vbe_get_video_ptr (src, offset_x,
|
srcptr = (grub_uint32_t *)get_data_ptr (src, offset_x, j + offset_y);
|
||||||
j + offset_y);
|
dstptr = (grub_uint8_t *)get_data_ptr (dst, x, y + j);
|
||||||
|
|
||||||
dstptr = (grub_uint8_t *)grub_video_vbe_get_video_ptr (dst, x, y + j);
|
|
||||||
|
|
||||||
for (i = 0; i < width; i++)
|
for (i = 0; i < width; i++)
|
||||||
{
|
{
|
||||||
|
@ -166,8 +194,46 @@ grub_video_i386_vbeblit_R8G8B8_R8G8B8A8 (struct grub_video_render_target *dst,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_video_i386_vbeblit_index_R8G8B8A8 (struct grub_video_render_target *dst,
|
grub_video_i386_vbeblit_R8G8B8_R8G8B8X8 (struct grub_video_i386_vbeblit_info *dst,
|
||||||
struct grub_video_render_target *src,
|
struct grub_video_i386_vbeblit_info *src,
|
||||||
|
int x, int y, int width, int height,
|
||||||
|
int offset_x, int offset_y)
|
||||||
|
{
|
||||||
|
grub_uint32_t color;
|
||||||
|
int i;
|
||||||
|
int j;
|
||||||
|
grub_uint32_t *srcptr;
|
||||||
|
grub_uint8_t *dstptr;
|
||||||
|
unsigned int sr;
|
||||||
|
unsigned int sg;
|
||||||
|
unsigned int sb;
|
||||||
|
|
||||||
|
/* We do not need to worry about data being out of bounds
|
||||||
|
as we assume that everything has been checked before. */
|
||||||
|
|
||||||
|
for (j = 0; j < height; j++)
|
||||||
|
{
|
||||||
|
srcptr = (grub_uint32_t *)get_data_ptr (src, offset_x, j + offset_y);
|
||||||
|
dstptr = (grub_uint8_t *)get_data_ptr (dst, x, y + j);
|
||||||
|
|
||||||
|
for (i = 0; i < width; i++)
|
||||||
|
{
|
||||||
|
color = *srcptr++;
|
||||||
|
|
||||||
|
sr = (color >> 0) & 0xFF;
|
||||||
|
sg = (color >> 8) & 0xFF;
|
||||||
|
sb = (color >> 16) & 0xFF;
|
||||||
|
|
||||||
|
*dstptr++ = sr;
|
||||||
|
*dstptr++ = sg;
|
||||||
|
*dstptr++ = sb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_video_i386_vbeblit_index_R8G8B8A8 (struct grub_video_i386_vbeblit_info *dst,
|
||||||
|
struct grub_video_i386_vbeblit_info *src,
|
||||||
int x, int y, int width, int height,
|
int x, int y, int width, int height,
|
||||||
int offset_x, int offset_y)
|
int offset_x, int offset_y)
|
||||||
{
|
{
|
||||||
|
@ -190,10 +256,8 @@ grub_video_i386_vbeblit_index_R8G8B8A8 (struct grub_video_render_target *dst,
|
||||||
|
|
||||||
for (j = 0; j < height; j++)
|
for (j = 0; j < height; j++)
|
||||||
{
|
{
|
||||||
srcptr = (grub_uint32_t *)grub_video_vbe_get_video_ptr (src, offset_x,
|
srcptr = (grub_uint32_t *)get_data_ptr (src, offset_x, j + offset_y);
|
||||||
j + offset_y);
|
dstptr = (grub_uint8_t *)get_data_ptr (dst, x, y + j);
|
||||||
|
|
||||||
dstptr = (grub_uint8_t *)grub_video_vbe_get_video_ptr (dst, x, y + j);
|
|
||||||
|
|
||||||
for (i = 0; i < width; i++)
|
for (i = 0; i < width; i++)
|
||||||
{
|
{
|
||||||
|
@ -232,8 +296,45 @@ grub_video_i386_vbeblit_index_R8G8B8A8 (struct grub_video_render_target *dst,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_video_i386_vbeblit_R8G8B8A8_R8G8B8 (struct grub_video_render_target *dst,
|
grub_video_i386_vbeblit_index_R8G8B8X8 (struct grub_video_i386_vbeblit_info *dst,
|
||||||
struct grub_video_render_target *src,
|
struct grub_video_i386_vbeblit_info *src,
|
||||||
|
int x, int y, int width, int height,
|
||||||
|
int offset_x, int offset_y)
|
||||||
|
{
|
||||||
|
grub_uint32_t color;
|
||||||
|
int i;
|
||||||
|
int j;
|
||||||
|
grub_uint32_t *srcptr;
|
||||||
|
grub_uint8_t *dstptr;
|
||||||
|
unsigned int sr;
|
||||||
|
unsigned int sg;
|
||||||
|
unsigned int sb;
|
||||||
|
|
||||||
|
/* We do not need to worry about data being out of bounds
|
||||||
|
as we assume that everything has been checked before. */
|
||||||
|
|
||||||
|
for (j = 0; j < height; j++)
|
||||||
|
{
|
||||||
|
srcptr = (grub_uint32_t *)get_data_ptr (src, offset_x, j + offset_y);
|
||||||
|
dstptr = (grub_uint8_t *)get_data_ptr (dst, x, y + j);
|
||||||
|
|
||||||
|
for (i = 0; i < width; i++)
|
||||||
|
{
|
||||||
|
color = *srcptr++;
|
||||||
|
|
||||||
|
sr = (color >> 0) & 0xFF;
|
||||||
|
sg = (color >> 8) & 0xFF;
|
||||||
|
sb = (color >> 16) & 0xFF;
|
||||||
|
|
||||||
|
color = grub_video_vbe_map_rgb(sr, sg, sb);
|
||||||
|
*dstptr++ = color & 0xFF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_video_i386_vbeblit_R8G8B8A8_R8G8B8 (struct grub_video_i386_vbeblit_info *dst,
|
||||||
|
struct grub_video_i386_vbeblit_info *src,
|
||||||
int x, int y, int width, int height,
|
int x, int y, int width, int height,
|
||||||
int offset_x, int offset_y)
|
int offset_x, int offset_y)
|
||||||
{
|
{
|
||||||
|
@ -251,10 +352,8 @@ grub_video_i386_vbeblit_R8G8B8A8_R8G8B8 (struct grub_video_render_target *dst,
|
||||||
|
|
||||||
for (j = 0; j < height; j++)
|
for (j = 0; j < height; j++)
|
||||||
{
|
{
|
||||||
srcptr = (grub_uint8_t *)grub_video_vbe_get_video_ptr (src, offset_x,
|
srcptr = (grub_uint8_t *)get_data_ptr (src, offset_x, j + offset_y);
|
||||||
j + offset_y);
|
dstptr = (grub_uint32_t *)get_data_ptr (dst, x, y + j);
|
||||||
|
|
||||||
dstptr = (grub_uint32_t *)grub_video_vbe_get_video_ptr (dst, x, y + j);
|
|
||||||
|
|
||||||
for (i = 0; i < width; i++)
|
for (i = 0; i < width; i++)
|
||||||
{
|
{
|
||||||
|
@ -270,41 +369,33 @@ grub_video_i386_vbeblit_R8G8B8A8_R8G8B8 (struct grub_video_render_target *dst,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_video_i386_vbeblit_R8G8B8_R8G8B8 (struct grub_video_render_target *dst,
|
grub_video_i386_vbeblit_R8G8B8_R8G8B8 (struct grub_video_i386_vbeblit_info *dst,
|
||||||
struct grub_video_render_target *src,
|
struct grub_video_i386_vbeblit_info *src,
|
||||||
int x, int y, int width, int height,
|
int x, int y, int width, int height,
|
||||||
int offset_x, int offset_y)
|
int offset_x, int offset_y)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
int j;
|
int j;
|
||||||
grub_uint8_t *srcptr;
|
grub_uint8_t *srcptr;
|
||||||
grub_uint8_t *dstptr;
|
grub_uint8_t *dstptr;
|
||||||
|
int pitch;
|
||||||
|
|
||||||
|
pitch = src->mode_info->bytes_per_pixel;
|
||||||
|
|
||||||
/* We do not need to worry about data being out of bounds
|
/* We do not need to worry about data being out of bounds
|
||||||
as we assume that everything has been checked before. */
|
as we assume that everything has been checked before. */
|
||||||
|
|
||||||
for (j = 0; j < height; j++)
|
for (j = 0; j < height; j++)
|
||||||
{
|
{
|
||||||
srcptr = (grub_uint8_t *)grub_video_vbe_get_video_ptr (src,
|
srcptr = (grub_uint8_t *)get_data_ptr (src, offset_x, j + offset_y);
|
||||||
offset_x,
|
dstptr = (grub_uint8_t *)get_data_ptr (dst, x, y + j);
|
||||||
j + offset_y);
|
|
||||||
|
|
||||||
dstptr = (grub_uint8_t *)grub_video_vbe_get_video_ptr (dst,
|
grub_memmove (dstptr, srcptr, width * pitch);
|
||||||
x,
|
|
||||||
y + j);
|
|
||||||
|
|
||||||
for (i = 0; i < width; i++)
|
|
||||||
{
|
|
||||||
*dstptr ++ = *srcptr++;
|
|
||||||
*dstptr ++ = *srcptr++;
|
|
||||||
*dstptr ++ = *srcptr++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_video_i386_vbeblit_index_R8G8B8 (struct grub_video_render_target *dst,
|
grub_video_i386_vbeblit_index_R8G8B8 (struct grub_video_i386_vbeblit_info *dst,
|
||||||
struct grub_video_render_target *src,
|
struct grub_video_i386_vbeblit_info *src,
|
||||||
int x, int y, int width, int height,
|
int x, int y, int width, int height,
|
||||||
int offset_x, int offset_y)
|
int offset_x, int offset_y)
|
||||||
{
|
{
|
||||||
|
@ -322,10 +413,8 @@ grub_video_i386_vbeblit_index_R8G8B8 (struct grub_video_render_target *dst,
|
||||||
|
|
||||||
for (j = 0; j < height; j++)
|
for (j = 0; j < height; j++)
|
||||||
{
|
{
|
||||||
srcptr = (grub_uint8_t *)grub_video_vbe_get_video_ptr (src, offset_x,
|
srcptr = (grub_uint8_t *)get_data_ptr (src, offset_x, j + offset_y);
|
||||||
j + offset_y);
|
dstptr = (grub_uint8_t *)get_data_ptr (dst, x, y + j);
|
||||||
|
|
||||||
dstptr = (grub_uint8_t *)grub_video_vbe_get_video_ptr (dst, x, y + j);
|
|
||||||
|
|
||||||
for (i = 0; i < width; i++)
|
for (i = 0; i < width; i++)
|
||||||
{
|
{
|
||||||
|
@ -341,27 +430,122 @@ grub_video_i386_vbeblit_index_R8G8B8 (struct grub_video_render_target *dst,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_video_i386_vbeblit_index_index (struct grub_video_render_target *dst,
|
grub_video_i386_vbeblit_index_index (struct grub_video_i386_vbeblit_info *dst,
|
||||||
struct grub_video_render_target *src,
|
struct grub_video_i386_vbeblit_info *src,
|
||||||
int x, int y, int width, int height,
|
int x, int y, int width, int height,
|
||||||
int offset_x, int offset_y)
|
int offset_x, int offset_y)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
int j;
|
int j;
|
||||||
grub_uint8_t *srcptr;
|
grub_uint8_t *srcptr;
|
||||||
grub_uint8_t *dstptr;
|
grub_uint8_t *dstptr;
|
||||||
|
int pitch;
|
||||||
|
|
||||||
|
pitch = src->mode_info->bytes_per_pixel;
|
||||||
|
|
||||||
/* We do not need to worry about data being out of bounds
|
/* We do not need to worry about data being out of bounds
|
||||||
as we assume that everything has been checked before. */
|
as we assume that everything has been checked before. */
|
||||||
|
|
||||||
for (j = 0; j < height; j++)
|
for (j = 0; j < height; j++)
|
||||||
{
|
{
|
||||||
srcptr = (grub_uint8_t *)grub_video_vbe_get_video_ptr (src, offset_x,
|
srcptr = (grub_uint8_t *)get_data_ptr (src, offset_x, j + offset_y);
|
||||||
j + offset_y);
|
dstptr = (grub_uint8_t *)get_data_ptr (dst, x, y + j);
|
||||||
|
|
||||||
dstptr = (grub_uint8_t *)grub_video_vbe_get_video_ptr (dst, x, y + j);
|
grub_memmove (dstptr, srcptr, width * pitch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_video_i386_vbeblit_blend (struct grub_video_i386_vbeblit_info *dst,
|
||||||
|
struct grub_video_i386_vbeblit_info *src,
|
||||||
|
int x, int y, int width, int height,
|
||||||
|
int offset_x, int offset_y)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int j;
|
||||||
|
|
||||||
|
/* We do not need to worry about data being out of bounds
|
||||||
|
as we assume that everything has been checked before. */
|
||||||
|
|
||||||
|
for (j = 0; j < height; j++)
|
||||||
|
{
|
||||||
for (i = 0; i < width; i++)
|
for (i = 0; i < width; i++)
|
||||||
*dstptr++ = *srcptr++;
|
{
|
||||||
|
grub_uint8_t src_red;
|
||||||
|
grub_uint8_t src_green;
|
||||||
|
grub_uint8_t src_blue;
|
||||||
|
grub_uint8_t src_alpha;
|
||||||
|
grub_uint8_t dst_red;
|
||||||
|
grub_uint8_t dst_green;
|
||||||
|
grub_uint8_t dst_blue;
|
||||||
|
grub_uint8_t dst_alpha;
|
||||||
|
grub_video_color_t src_color;
|
||||||
|
grub_video_color_t dst_color;
|
||||||
|
|
||||||
|
src_color = get_pixel (src, i + offset_x, j + offset_y);
|
||||||
|
grub_video_vbe_unmap_color (src, src_color, &src_red, &src_green,
|
||||||
|
&src_blue, &src_alpha);
|
||||||
|
|
||||||
|
if (src_alpha == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (src_alpha == 255)
|
||||||
|
{
|
||||||
|
dst_color = grub_video_vbe_map_rgba (src_red, src_green,
|
||||||
|
src_blue, src_alpha);
|
||||||
|
set_pixel (dst, x + i, y + j, dst_color);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
dst_color = get_pixel (dst, x + i, y + j);
|
||||||
|
|
||||||
|
grub_video_vbe_unmap_color (dst, dst_color, &dst_red,
|
||||||
|
&dst_green, &dst_blue, &dst_alpha);
|
||||||
|
|
||||||
|
dst_red = (((src_red * src_alpha)
|
||||||
|
+ (dst_red * (255 - src_alpha))) / 255);
|
||||||
|
dst_green = (((src_green * src_alpha)
|
||||||
|
+ (dst_green * (255 - src_alpha))) / 255);
|
||||||
|
dst_blue = (((src_blue * src_alpha)
|
||||||
|
+ (dst_blue * (255 - src_alpha))) / 255);
|
||||||
|
|
||||||
|
dst_alpha = src_alpha;
|
||||||
|
dst_color = grub_video_vbe_map_rgba (dst_red, dst_green, dst_blue,
|
||||||
|
dst_alpha);
|
||||||
|
|
||||||
|
set_pixel (dst, x + i, y + j, dst_color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_video_i386_vbeblit_replace (struct grub_video_i386_vbeblit_info *dst,
|
||||||
|
struct grub_video_i386_vbeblit_info *src,
|
||||||
|
int x, int y, int width, int height,
|
||||||
|
int offset_x, int offset_y)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int j;
|
||||||
|
grub_uint8_t src_red;
|
||||||
|
grub_uint8_t src_green;
|
||||||
|
grub_uint8_t src_blue;
|
||||||
|
grub_uint8_t src_alpha;
|
||||||
|
grub_video_color_t src_color;
|
||||||
|
grub_video_color_t dst_color;
|
||||||
|
|
||||||
|
/* We do not need to worry about data being out of bounds
|
||||||
|
as we assume that everything has been checked before. */
|
||||||
|
|
||||||
|
for (j = 0; j < height; j++)
|
||||||
|
{
|
||||||
|
for (i = 0; i < width; i++)
|
||||||
|
{
|
||||||
|
src_color = get_pixel (src, i + offset_x, j + offset_y);
|
||||||
|
grub_video_vbe_unmap_color (src, src_color, &src_red, &src_green,
|
||||||
|
&src_blue, &src_alpha);
|
||||||
|
|
||||||
|
dst_color = grub_video_vbe_map_rgba (src_red, src_green,
|
||||||
|
src_blue, src_alpha);
|
||||||
|
set_pixel (dst, x + i, y + j, dst_color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,19 +17,25 @@
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <grub/err.h>
|
/* SPECIAL NOTES!
|
||||||
#include <grub/machine/memory.h>
|
|
||||||
|
Please note following when reading the code below:
|
||||||
|
|
||||||
|
- In this driver we assume that every memory can be accessed by same memory
|
||||||
|
bus. If there are different address spaces do not use this code as a base
|
||||||
|
code for other archs.
|
||||||
|
|
||||||
|
- Every function in this code assumes that bounds checking has been done in
|
||||||
|
previous phase and they are opted out in here. */
|
||||||
|
|
||||||
#include <grub/machine/vbe.h>
|
#include <grub/machine/vbe.h>
|
||||||
#include <grub/machine/vbefill.h>
|
#include <grub/machine/vbefill.h>
|
||||||
|
#include <grub/machine/vbeutil.h>
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
#include <grub/dl.h>
|
|
||||||
#include <grub/misc.h>
|
|
||||||
#include <grub/font.h>
|
|
||||||
#include <grub/mm.h>
|
|
||||||
#include <grub/video.h>
|
#include <grub/video.h>
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_video_i386_vbefill_R8G8B8A8 (struct grub_video_render_target *dst,
|
grub_video_i386_vbefill_R8G8B8A8 (struct grub_video_i386_vbeblit_info *dst,
|
||||||
grub_video_color_t color, int x, int y,
|
grub_video_color_t color, int x, int y,
|
||||||
int width, int height)
|
int width, int height)
|
||||||
{
|
{
|
||||||
|
@ -50,7 +56,7 @@ grub_video_i386_vbefill_R8G8B8A8 (struct grub_video_render_target *dst,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_video_i386_vbefill_R8G8B8 (struct grub_video_render_target *dst,
|
grub_video_i386_vbefill_R8G8B8 (struct grub_video_i386_vbeblit_info *dst,
|
||||||
grub_video_color_t color, int x, int y,
|
grub_video_color_t color, int x, int y,
|
||||||
int width, int height)
|
int width, int height)
|
||||||
{
|
{
|
||||||
|
@ -78,7 +84,7 @@ grub_video_i386_vbefill_R8G8B8 (struct grub_video_render_target *dst,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_video_i386_vbefill_index (struct grub_video_render_target *dst,
|
grub_video_i386_vbefill_index (struct grub_video_i386_vbeblit_info *dst,
|
||||||
grub_video_color_t color, int x, int y,
|
grub_video_color_t color, int x, int y,
|
||||||
int width, int height)
|
int width, int height)
|
||||||
{
|
{
|
||||||
|
@ -98,3 +104,19 @@ grub_video_i386_vbefill_index (struct grub_video_render_target *dst,
|
||||||
*dstptr++ = fill;
|
*dstptr++ = fill;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_video_i386_vbefill (struct grub_video_i386_vbeblit_info *dst,
|
||||||
|
grub_video_color_t color, int x, int y,
|
||||||
|
int width, int height)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int j;
|
||||||
|
|
||||||
|
/* We do not need to worry about data being out of bounds
|
||||||
|
as we assume that everything has been checked before. */
|
||||||
|
|
||||||
|
for (j = 0; j < height; j++)
|
||||||
|
for (i = 0; i < width; i++)
|
||||||
|
set_pixel (dst, x+i, y+j, color);
|
||||||
|
}
|
||||||
|
|
150
video/i386/pc/vbeutil.c
Normal file
150
video/i386/pc/vbeutil.c
Normal file
|
@ -0,0 +1,150 @@
|
||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2006 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <grub/machine/vbeutil.h>
|
||||||
|
#include <grub/types.h>
|
||||||
|
#include <grub/video.h>
|
||||||
|
|
||||||
|
grub_uint8_t *
|
||||||
|
get_data_ptr (struct grub_video_i386_vbeblit_info *source,
|
||||||
|
unsigned int x, unsigned int y)
|
||||||
|
{
|
||||||
|
grub_uint8_t *ptr = 0;
|
||||||
|
|
||||||
|
switch (source->mode_info->bpp)
|
||||||
|
{
|
||||||
|
case 32:
|
||||||
|
ptr = (grub_uint8_t *)source->data
|
||||||
|
+ y * source->mode_info->pitch
|
||||||
|
+ x * 4;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 24:
|
||||||
|
ptr = (grub_uint8_t *)source->data
|
||||||
|
+ y * source->mode_info->pitch
|
||||||
|
+ x * 3;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 16:
|
||||||
|
case 15:
|
||||||
|
ptr = (grub_uint8_t *)source->data
|
||||||
|
+ y * source->mode_info->pitch
|
||||||
|
+ x * 2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 8:
|
||||||
|
ptr = (grub_uint8_t *)source->data
|
||||||
|
+ y * source->mode_info->pitch
|
||||||
|
+ x;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_video_color_t
|
||||||
|
get_pixel (struct grub_video_i386_vbeblit_info *source,
|
||||||
|
unsigned int x, unsigned int y)
|
||||||
|
{
|
||||||
|
grub_video_color_t color = 0;
|
||||||
|
|
||||||
|
switch (source->mode_info->bpp)
|
||||||
|
{
|
||||||
|
case 32:
|
||||||
|
color = *(grub_uint32_t *)get_data_ptr (source, x, y);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 24:
|
||||||
|
{
|
||||||
|
grub_uint8_t *ptr;
|
||||||
|
ptr = get_data_ptr (source, x, y);
|
||||||
|
color = ptr[0] | (ptr[1] << 8) | (ptr[2] << 16);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 16:
|
||||||
|
case 15:
|
||||||
|
color = *(grub_uint16_t *)get_data_ptr (source, x, y);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 8:
|
||||||
|
color = *(grub_uint8_t *)get_data_ptr (source, x, y);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
set_pixel (struct grub_video_i386_vbeblit_info *source,
|
||||||
|
unsigned int x, unsigned int y, grub_video_color_t color)
|
||||||
|
{
|
||||||
|
switch (source->mode_info->bpp)
|
||||||
|
{
|
||||||
|
case 32:
|
||||||
|
{
|
||||||
|
grub_uint32_t *ptr;
|
||||||
|
|
||||||
|
ptr = (grub_uint32_t *)get_data_ptr (source, x, y);
|
||||||
|
|
||||||
|
*ptr = color;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 24:
|
||||||
|
{
|
||||||
|
grub_uint8_t *ptr;
|
||||||
|
grub_uint8_t *colorptr = (grub_uint8_t *)&color;
|
||||||
|
|
||||||
|
ptr = get_data_ptr (source, x, y);
|
||||||
|
|
||||||
|
ptr[0] = colorptr[0];
|
||||||
|
ptr[1] = colorptr[1];
|
||||||
|
ptr[2] = colorptr[2];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 16:
|
||||||
|
case 15:
|
||||||
|
{
|
||||||
|
grub_uint16_t *ptr;
|
||||||
|
|
||||||
|
ptr = (grub_uint16_t *)get_data_ptr (source, x, y);
|
||||||
|
|
||||||
|
*ptr = (grub_uint16_t) (color & 0xFFFF);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 8:
|
||||||
|
{
|
||||||
|
grub_uint8_t *ptr;
|
||||||
|
|
||||||
|
ptr = (grub_uint8_t *)get_data_ptr (source, x, y);
|
||||||
|
|
||||||
|
*ptr = (grub_uint8_t) (color & 0xFF);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
496
video/readers/tga.c
Normal file
496
video/readers/tga.c
Normal file
|
@ -0,0 +1,496 @@
|
||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2006 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <grub/bitmap.h>
|
||||||
|
#include <grub/types.h>
|
||||||
|
#include <grub/normal.h>
|
||||||
|
#include <grub/dl.h>
|
||||||
|
#include <grub/mm.h>
|
||||||
|
#include <grub/misc.h>
|
||||||
|
#include <grub/arg.h>
|
||||||
|
#include <grub/file.h>
|
||||||
|
|
||||||
|
/* Uncomment following define to enable TGA debug. */
|
||||||
|
//#define TGA_DEBUG
|
||||||
|
|
||||||
|
#if defined(TGA_DEBUG)
|
||||||
|
#define dump_int_field(x) grub_printf( #x " = %d (0x%04x)\n", x, x);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
GRUB_TGA_IMAGE_TYPE_NONE = 0,
|
||||||
|
GRUB_TGA_IMAGE_TYPE_UNCOMPRESSED_INDEXCOLOR = 1,
|
||||||
|
GRUB_TGA_IMAGE_TYPE_UNCOMPRESSED_TRUECOLOR = 2,
|
||||||
|
GRUB_TGA_IMAGE_TYPE_UNCOMPRESSED_BLACK_AND_WHITE = 3,
|
||||||
|
GRUB_TGA_IMAGE_TYPE_RLE_INDEXCOLOR = 9,
|
||||||
|
GRUB_TGA_IMAGE_TYPE_RLE_TRUECOLOR = 10,
|
||||||
|
GRUB_TGA_IMAGE_TYPE_RLE_BLACK_AND_WHITE = 11,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
GRUB_TGA_COLOR_MAP_TYPE_NONE = 0,
|
||||||
|
GRUB_TGA_COLOR_MAP_TYPE_INCLUDED = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
GRUB_TGA_IMAGE_ORIGIN_RIGHT = 0x10,
|
||||||
|
GRUB_TGA_IMAGE_ORIGIN_TOP = 0x20
|
||||||
|
};
|
||||||
|
|
||||||
|
struct grub_tga_header
|
||||||
|
{
|
||||||
|
grub_uint8_t id_length;
|
||||||
|
grub_uint8_t color_map_type;
|
||||||
|
grub_uint8_t image_type;
|
||||||
|
|
||||||
|
/* Color Map Specification. */
|
||||||
|
grub_uint16_t color_map_first_index;
|
||||||
|
grub_uint16_t color_map_length;
|
||||||
|
grub_uint8_t color_map_bpp;
|
||||||
|
|
||||||
|
/* Image Specification. */
|
||||||
|
grub_uint16_t image_x_origin;
|
||||||
|
grub_uint16_t image_y_origin;
|
||||||
|
grub_uint16_t image_width;
|
||||||
|
grub_uint16_t image_height;
|
||||||
|
grub_uint8_t image_bpp;
|
||||||
|
grub_uint8_t image_descriptor;
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
tga_load_truecolor_rle_R8G8B8 (struct grub_video_bitmap *bitmap,
|
||||||
|
struct grub_tga_header *header,
|
||||||
|
grub_file_t file)
|
||||||
|
{
|
||||||
|
unsigned int x;
|
||||||
|
unsigned int y;
|
||||||
|
grub_uint8_t type;
|
||||||
|
grub_uint8_t *ptr;
|
||||||
|
grub_uint8_t tmp[4]; /* Size should be max_bpp / 8. */
|
||||||
|
grub_uint8_t bytes_per_pixel;
|
||||||
|
|
||||||
|
bytes_per_pixel = header->image_bpp / 8;
|
||||||
|
|
||||||
|
for (y = 0; y < header->image_height; y++)
|
||||||
|
{
|
||||||
|
ptr = bitmap->data;
|
||||||
|
if ((header->image_descriptor & GRUB_TGA_IMAGE_ORIGIN_TOP) != 0)
|
||||||
|
ptr += y * bitmap->mode_info.pitch;
|
||||||
|
else
|
||||||
|
ptr += (header->image_height - 1 - y) * bitmap->mode_info.pitch;
|
||||||
|
|
||||||
|
for (x = 0; x < header->image_width;)
|
||||||
|
{
|
||||||
|
if (grub_file_read (file, (char *)&type, sizeof (type)) != sizeof(type))
|
||||||
|
return grub_errno;
|
||||||
|
|
||||||
|
if (type & 0x80)
|
||||||
|
{
|
||||||
|
/* RLE-encoded packet. */
|
||||||
|
type &= 0x7f;
|
||||||
|
type++;
|
||||||
|
|
||||||
|
if (grub_file_read (file, (char *)&tmp[0], bytes_per_pixel)
|
||||||
|
!= bytes_per_pixel)
|
||||||
|
return grub_errno;
|
||||||
|
|
||||||
|
while (type)
|
||||||
|
{
|
||||||
|
if (x < header->image_width)
|
||||||
|
{
|
||||||
|
ptr[0] = tmp[2];
|
||||||
|
ptr[1] = tmp[1];
|
||||||
|
ptr[2] = tmp[0];
|
||||||
|
ptr += 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
type--;
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* RAW-encoded packet. */
|
||||||
|
type++;
|
||||||
|
|
||||||
|
while (type)
|
||||||
|
{
|
||||||
|
if (grub_file_read (file, (char *)&tmp[0], bytes_per_pixel)
|
||||||
|
!= bytes_per_pixel)
|
||||||
|
return grub_errno;
|
||||||
|
|
||||||
|
if (x < header->image_width)
|
||||||
|
{
|
||||||
|
ptr[0] = tmp[2];
|
||||||
|
ptr[1] = tmp[1];
|
||||||
|
ptr[2] = tmp[0];
|
||||||
|
ptr += 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
type--;
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
tga_load_truecolor_rle_R8G8B8A8 (struct grub_video_bitmap *bitmap,
|
||||||
|
struct grub_tga_header *header,
|
||||||
|
grub_file_t file)
|
||||||
|
{
|
||||||
|
unsigned int x;
|
||||||
|
unsigned int y;
|
||||||
|
grub_uint8_t type;
|
||||||
|
grub_uint8_t *ptr;
|
||||||
|
grub_uint8_t tmp[4]; /* Size should be max_bpp / 8. */
|
||||||
|
grub_uint8_t bytes_per_pixel;
|
||||||
|
|
||||||
|
bytes_per_pixel = header->image_bpp / 8;
|
||||||
|
|
||||||
|
for (y = 0; y < header->image_height; y++)
|
||||||
|
{
|
||||||
|
ptr = bitmap->data;
|
||||||
|
if ((header->image_descriptor & GRUB_TGA_IMAGE_ORIGIN_TOP) != 0)
|
||||||
|
ptr += y * bitmap->mode_info.pitch;
|
||||||
|
else
|
||||||
|
ptr += (header->image_height - 1 - y) * bitmap->mode_info.pitch;
|
||||||
|
|
||||||
|
for (x = 0; x < header->image_width;)
|
||||||
|
{
|
||||||
|
if (grub_file_read (file, (char *)&type, sizeof (type)) != sizeof(type))
|
||||||
|
return grub_errno;
|
||||||
|
|
||||||
|
if (type & 0x80)
|
||||||
|
{
|
||||||
|
/* RLE-encoded packet. */
|
||||||
|
type &= 0x7f;
|
||||||
|
type++;
|
||||||
|
|
||||||
|
if (grub_file_read (file, (char *)&tmp[0], bytes_per_pixel)
|
||||||
|
!= bytes_per_pixel)
|
||||||
|
return grub_errno;
|
||||||
|
|
||||||
|
while (type)
|
||||||
|
{
|
||||||
|
if (x < header->image_width)
|
||||||
|
{
|
||||||
|
ptr[0] = tmp[2];
|
||||||
|
ptr[1] = tmp[1];
|
||||||
|
ptr[2] = tmp[0];
|
||||||
|
ptr[3] = tmp[3];
|
||||||
|
ptr += 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
type--;
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* RAW-encoded packet. */
|
||||||
|
type++;
|
||||||
|
|
||||||
|
while (type)
|
||||||
|
{
|
||||||
|
if (grub_file_read (file, (char *)&tmp[0], bytes_per_pixel)
|
||||||
|
!= bytes_per_pixel)
|
||||||
|
return grub_errno;
|
||||||
|
|
||||||
|
if (x < header->image_width)
|
||||||
|
{
|
||||||
|
ptr[0] = tmp[2];
|
||||||
|
ptr[1] = tmp[1];
|
||||||
|
ptr[2] = tmp[0];
|
||||||
|
ptr[3] = tmp[3];
|
||||||
|
ptr += 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
type--;
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
tga_load_truecolor_R8G8B8 (struct grub_video_bitmap *bitmap,
|
||||||
|
struct grub_tga_header *header,
|
||||||
|
grub_file_t file)
|
||||||
|
{
|
||||||
|
unsigned int x;
|
||||||
|
unsigned int y;
|
||||||
|
grub_uint8_t *ptr;
|
||||||
|
grub_uint8_t tmp[4]; /* Size should be max_bpp / 8. */
|
||||||
|
grub_uint8_t bytes_per_pixel;
|
||||||
|
|
||||||
|
bytes_per_pixel = header->image_bpp / 8;
|
||||||
|
|
||||||
|
for (y = 0; y < header->image_height; y++)
|
||||||
|
{
|
||||||
|
ptr = bitmap->data;
|
||||||
|
if ((header->image_descriptor & GRUB_TGA_IMAGE_ORIGIN_TOP) != 0)
|
||||||
|
ptr += y * bitmap->mode_info.pitch;
|
||||||
|
else
|
||||||
|
ptr += (header->image_height - 1 - y) * bitmap->mode_info.pitch;
|
||||||
|
|
||||||
|
for (x = 0; x < header->image_width; x++)
|
||||||
|
{
|
||||||
|
if (grub_file_read (file, (char *)&tmp[0], bytes_per_pixel)
|
||||||
|
!= bytes_per_pixel)
|
||||||
|
return grub_errno;
|
||||||
|
|
||||||
|
ptr[0] = tmp[2];
|
||||||
|
ptr[1] = tmp[1];
|
||||||
|
ptr[2] = tmp[0];
|
||||||
|
|
||||||
|
ptr += 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
tga_load_truecolor_R8G8B8A8 (struct grub_video_bitmap *bitmap,
|
||||||
|
struct grub_tga_header *header,
|
||||||
|
grub_file_t file)
|
||||||
|
{
|
||||||
|
unsigned int x;
|
||||||
|
unsigned int y;
|
||||||
|
grub_uint8_t *ptr;
|
||||||
|
grub_uint8_t tmp[4]; /* Size should be max_bpp / 8. */
|
||||||
|
grub_uint8_t bytes_per_pixel;
|
||||||
|
|
||||||
|
bytes_per_pixel = header->image_bpp / 8;
|
||||||
|
|
||||||
|
for (y = 0; y < header->image_height; y++)
|
||||||
|
{
|
||||||
|
ptr = bitmap->data;
|
||||||
|
if ((header->image_descriptor & GRUB_TGA_IMAGE_ORIGIN_TOP) != 0)
|
||||||
|
ptr += y * bitmap->mode_info.pitch;
|
||||||
|
else
|
||||||
|
ptr += (header->image_height - 1 - y) * bitmap->mode_info.pitch;
|
||||||
|
|
||||||
|
for (x = 0; x < header->image_width; x++)
|
||||||
|
{
|
||||||
|
if (grub_file_read (file, (char *)&tmp[0], bytes_per_pixel)
|
||||||
|
!= bytes_per_pixel)
|
||||||
|
return grub_errno;
|
||||||
|
|
||||||
|
ptr[0] = tmp[2];
|
||||||
|
ptr[1] = tmp[1];
|
||||||
|
ptr[2] = tmp[0];
|
||||||
|
ptr[3] = tmp[3];
|
||||||
|
|
||||||
|
ptr += 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_video_reader_tga (struct grub_video_bitmap **bitmap,
|
||||||
|
const char *filename)
|
||||||
|
{
|
||||||
|
grub_file_t file;
|
||||||
|
grub_ssize_t pos;
|
||||||
|
struct grub_tga_header header;
|
||||||
|
int has_alpha;
|
||||||
|
|
||||||
|
file = grub_file_open (filename);
|
||||||
|
if (! file)
|
||||||
|
return grub_errno;
|
||||||
|
|
||||||
|
/* TGA Specification states that we SHOULD start by reading
|
||||||
|
ID from end of file, but we really don't care about that as we are
|
||||||
|
not going to support developer area & extensions at this point. */
|
||||||
|
|
||||||
|
/* Read TGA header from begining of file. */
|
||||||
|
if (grub_file_read (file, (char*)&header, sizeof (header))
|
||||||
|
!= sizeof (header))
|
||||||
|
{
|
||||||
|
grub_file_close (file);
|
||||||
|
return grub_errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Skip ID field. */
|
||||||
|
pos = grub_file_tell (file);
|
||||||
|
pos += header.id_length;
|
||||||
|
grub_file_seek (file, pos);
|
||||||
|
if (grub_errno != GRUB_ERR_NONE)
|
||||||
|
{
|
||||||
|
grub_file_close (file);
|
||||||
|
return grub_errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(TGA_DEBUG)
|
||||||
|
grub_printf("tga: header\n");
|
||||||
|
dump_int_field(header.id_length);
|
||||||
|
dump_int_field(header.color_map_type);
|
||||||
|
dump_int_field(header.image_type);
|
||||||
|
dump_int_field(header.color_map_first_index);
|
||||||
|
dump_int_field(header.color_map_length);
|
||||||
|
dump_int_field(header.color_map_bpp);
|
||||||
|
dump_int_field(header.image_x_origin);
|
||||||
|
dump_int_field(header.image_y_origin);
|
||||||
|
dump_int_field(header.image_width);
|
||||||
|
dump_int_field(header.image_height);
|
||||||
|
dump_int_field(header.image_bpp);
|
||||||
|
dump_int_field(header.image_descriptor);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Check that bitmap encoding is supported. */
|
||||||
|
switch (header.image_type)
|
||||||
|
{
|
||||||
|
case GRUB_TGA_IMAGE_TYPE_UNCOMPRESSED_TRUECOLOR:
|
||||||
|
case GRUB_TGA_IMAGE_TYPE_RLE_TRUECOLOR:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
grub_file_close (file);
|
||||||
|
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
|
||||||
|
"Unsupported bitmap format (unknown encoding).");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check that bitmap depth is supported. */
|
||||||
|
switch (header.image_bpp)
|
||||||
|
{
|
||||||
|
case 24:
|
||||||
|
has_alpha = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 32:
|
||||||
|
has_alpha = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
grub_file_close (file);
|
||||||
|
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
|
||||||
|
"Unsupported bitmap format (bpp=%d).",
|
||||||
|
header.image_bpp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allocate bitmap. If there is alpha information store it too. */
|
||||||
|
if (has_alpha)
|
||||||
|
{
|
||||||
|
grub_video_bitmap_create (bitmap, header.image_width,
|
||||||
|
header.image_height,
|
||||||
|
GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8);
|
||||||
|
if (grub_errno != GRUB_ERR_NONE)
|
||||||
|
{
|
||||||
|
grub_file_close (file);
|
||||||
|
return grub_errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Load bitmap data. */
|
||||||
|
switch (header.image_type)
|
||||||
|
{
|
||||||
|
case GRUB_TGA_IMAGE_TYPE_UNCOMPRESSED_TRUECOLOR:
|
||||||
|
tga_load_truecolor_R8G8B8A8 (*bitmap, &header, file);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GRUB_TGA_IMAGE_TYPE_RLE_TRUECOLOR:
|
||||||
|
tga_load_truecolor_rle_R8G8B8A8 (*bitmap, &header, file);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
grub_video_bitmap_create (bitmap, header.image_width,
|
||||||
|
header.image_height,
|
||||||
|
GRUB_VIDEO_BLIT_FORMAT_R8G8B8);
|
||||||
|
if (grub_errno != GRUB_ERR_NONE)
|
||||||
|
{
|
||||||
|
grub_file_close (file);
|
||||||
|
return grub_errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Load bitmap data. */
|
||||||
|
switch (header.image_type)
|
||||||
|
{
|
||||||
|
case GRUB_TGA_IMAGE_TYPE_UNCOMPRESSED_TRUECOLOR:
|
||||||
|
tga_load_truecolor_R8G8B8 (*bitmap, &header, file);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GRUB_TGA_IMAGE_TYPE_RLE_TRUECOLOR:
|
||||||
|
tga_load_truecolor_rle_R8G8B8 (*bitmap, &header, file);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If there were loading proble, destroy bitmap. */
|
||||||
|
if (grub_errno != GRUB_ERR_NONE)
|
||||||
|
{
|
||||||
|
grub_video_bitmap_destroy (*bitmap);
|
||||||
|
*bitmap = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_file_close (file);
|
||||||
|
return grub_errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(TGA_DEBUG)
|
||||||
|
static grub_err_t
|
||||||
|
grub_cmd_tgatest (struct grub_arg_list *state __attribute__ ((unused)),
|
||||||
|
int argc, char **args)
|
||||||
|
{
|
||||||
|
struct grub_video_bitmap *bitmap = 0;
|
||||||
|
|
||||||
|
if (argc != 1)
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required");
|
||||||
|
|
||||||
|
grub_video_reader_tga (&bitmap, args[0]);
|
||||||
|
if (grub_errno != GRUB_ERR_NONE)
|
||||||
|
return grub_errno;
|
||||||
|
|
||||||
|
grub_video_bitmap_destroy (bitmap);
|
||||||
|
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static struct grub_video_bitmap_reader tga_reader = {
|
||||||
|
.extension = ".tga",
|
||||||
|
.reader = grub_video_reader_tga,
|
||||||
|
.next = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
GRUB_MOD_INIT(video_reader_tga)
|
||||||
|
{
|
||||||
|
grub_video_bitmap_reader_register (&tga_reader);
|
||||||
|
#if defined(TGA_DEBUG)
|
||||||
|
grub_register_command ("tgatest", grub_cmd_tgatest, GRUB_COMMAND_FLAG_BOTH,
|
||||||
|
"tgatest FILE", "Tests loading of TGA bitmap.", 0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
GRUB_MOD_FINI(video_reader_tga)
|
||||||
|
{
|
||||||
|
#if defined(TGA_DEBUG)
|
||||||
|
grub_unregister_command ("tgatest");
|
||||||
|
#endif
|
||||||
|
grub_video_bitmap_reader_unregister (&tga_reader);
|
||||||
|
}
|
|
@ -82,7 +82,7 @@ grub_video_setup (unsigned int width, unsigned int height,
|
||||||
/* Loop thru all possible video adapter trying to find requested mode. */
|
/* Loop thru all possible video adapter trying to find requested mode. */
|
||||||
for (p = grub_video_adapter_list; p; p = p->next)
|
for (p = grub_video_adapter_list; p; p = p->next)
|
||||||
{
|
{
|
||||||
/* Try to initialize adapter, if can't skip to next. */
|
/* Try to initialize adapter, if it fails, skip to next adapter. */
|
||||||
p->init ();
|
p->init ();
|
||||||
if (grub_errno != GRUB_ERR_NONE)
|
if (grub_errno != GRUB_ERR_NONE)
|
||||||
{
|
{
|
||||||
|
@ -142,7 +142,7 @@ grub_video_get_info (struct grub_video_mode_info *mode_info)
|
||||||
enum grub_video_blit_format
|
enum grub_video_blit_format
|
||||||
grub_video_get_blit_format (struct grub_video_mode_info *mode_info)
|
grub_video_get_blit_format (struct grub_video_mode_info *mode_info)
|
||||||
{
|
{
|
||||||
/* Check if we have any knwon 32 bit modes. */
|
/* Check if we have any known 32 bit modes. */
|
||||||
if (mode_info->bpp == 32)
|
if (mode_info->bpp == 32)
|
||||||
{
|
{
|
||||||
if ((mode_info->red_mask_size == 8)
|
if ((mode_info->red_mask_size == 8)
|
||||||
|
@ -286,13 +286,14 @@ grub_video_blit_glyph (struct grub_font_glyph *glyph,
|
||||||
/* Blit bitmap to screen. */
|
/* Blit bitmap to screen. */
|
||||||
grub_err_t
|
grub_err_t
|
||||||
grub_video_blit_bitmap (struct grub_video_bitmap *bitmap,
|
grub_video_blit_bitmap (struct grub_video_bitmap *bitmap,
|
||||||
|
enum grub_video_blit_operators oper,
|
||||||
int x, int y, int offset_x, int offset_y,
|
int x, int y, int offset_x, int offset_y,
|
||||||
unsigned int width, unsigned int height)
|
unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
if (! grub_video_adapter_active)
|
if (! grub_video_adapter_active)
|
||||||
return grub_error (GRUB_ERR_BAD_DEVICE, "No video mode activated");
|
return grub_error (GRUB_ERR_BAD_DEVICE, "No video mode activated");
|
||||||
|
|
||||||
return grub_video_adapter_active->blit_bitmap (bitmap, x, y,
|
return grub_video_adapter_active->blit_bitmap (bitmap, oper, x, y,
|
||||||
offset_x, offset_y,
|
offset_x, offset_y,
|
||||||
width, height);
|
width, height);
|
||||||
}
|
}
|
||||||
|
@ -300,13 +301,14 @@ grub_video_blit_bitmap (struct grub_video_bitmap *bitmap,
|
||||||
/* Blit render target to active render target. */
|
/* Blit render target to active render target. */
|
||||||
grub_err_t
|
grub_err_t
|
||||||
grub_video_blit_render_target (struct grub_video_render_target *target,
|
grub_video_blit_render_target (struct grub_video_render_target *target,
|
||||||
|
enum grub_video_blit_operators oper,
|
||||||
int x, int y, int offset_x, int offset_y,
|
int x, int y, int offset_x, int offset_y,
|
||||||
unsigned int width, unsigned int height)
|
unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
if (! grub_video_adapter_active)
|
if (! grub_video_adapter_active)
|
||||||
return grub_error (GRUB_ERR_BAD_DEVICE, "No video mode activated");
|
return grub_error (GRUB_ERR_BAD_DEVICE, "No video mode activated");
|
||||||
|
|
||||||
return grub_video_adapter_active->blit_render_target (target, x, y,
|
return grub_video_adapter_active->blit_render_target (target, oper, x, y,
|
||||||
offset_x, offset_y,
|
offset_x, offset_y,
|
||||||
width, height);
|
width, height);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue