Hello I tried looking at the overflow but i seriously have no idea what are all these regions the gfx_region_update_* gets.
There is some scn_x and scn_y but these do not seem to be the screen coordinates of the region. If I could tell for what region I am doing the update (that is the x,y,width,height of the region in screen coordinates) I could set the viewport accordingly so that the content does not overflow. At the very least the patch replicates the same breakage in much fewer lines of code. Thanks Michal
diff --git a/menu/gfx_region.c b/menu/gfx_region.c index 8812da7..39dcc1d 100644 --- a/menu/gfx_region.c +++ b/menu/gfx_region.c @@ -27,8 +27,8 @@ #define DEFAULT_VIDEO_MODE "auto" -static int screen_width; -static int screen_height; +static unsigned screen_width; +static unsigned screen_height; static grub_err_t grub_gfx_region_init (void) @@ -36,6 +36,7 @@ grub_gfx_region_init (void) const char *modevar; struct grub_video_mode_info mode_info; grub_err_t err; + unsigned size = -1; /*FIXME int_max? */ modevar = grub_env_get ("gfxmode"); if (! modevar || *modevar == 0) @@ -61,8 +62,8 @@ grub_gfx_region_init (void) if (err) return err; - screen_width = mode_info.width; - screen_height = mode_info.height; + grub_video_set_viewport(0, 0, size, size); /* Set maximum viewport. */ + grub_video_get_viewport(&size, &size, &screen_width, &screen_height); return grub_errno; } @@ -140,7 +141,8 @@ static void grub_gfx_region_update_rect (struct grub_menu_region_rect *rect, int width, int height, int scn_x, int scn_y) { - grub_video_fill_rect (rect->color, scn_x, scn_y, width, height); + grub_video_set_viewport(scn_x, scn_y, width, height); + grub_video_fill_rect (rect->color, 0, 0, width, height); } static void @@ -148,60 +150,11 @@ grub_gfx_region_update_text (struct grub_menu_region_text *text, int x, int y, int width, int height, int scn_x, int scn_y) { - int left_x, base_y; - grub_uint32_t code; - const grub_uint8_t *ptr; - struct grub_video_bitmap glyph_bitmap; - - scn_x -= x; - scn_y -= y; - - glyph_bitmap.mode_info.mode_type = - (1 << GRUB_VIDEO_MODE_TYPE_DEPTH_POS) - | GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP; - glyph_bitmap.mode_info.blit_format = GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED; - glyph_bitmap.mode_info.bpp = 1; - glyph_bitmap.mode_info.bytes_per_pixel = 0; - glyph_bitmap.mode_info.number_of_colors = 2; - glyph_bitmap.mode_info.bg_red = 0; - glyph_bitmap.mode_info.bg_green = 0; - glyph_bitmap.mode_info.bg_blue = 0; - glyph_bitmap.mode_info.bg_alpha = 0; - grub_video_unmap_color(text->color, - &glyph_bitmap.mode_info.fg_red, - &glyph_bitmap.mode_info.fg_green, - &glyph_bitmap.mode_info.fg_blue, - &glyph_bitmap.mode_info.fg_alpha); + int base_y; + grub_video_set_viewport(scn_x, scn_y, width, height); base_y = grub_font_get_ascent (text->font); - for (ptr = (const grub_uint8_t *) text->text, left_x = 0; - grub_utf8_to_ucs4 (&code, 1, ptr, -1, &ptr) > 0; ) - { - struct grub_font_glyph *glyph; - int x1, y1, w1, h1, ox, oy; - - glyph = grub_font_get_glyph_with_fallback (text->font, code); - x1 = left_x + glyph->offset_x; - y1 = base_y - glyph->offset_y - glyph->height; - ox = x1; - oy = y1; - w1 = glyph->width; - h1 = glyph->height; - - if (grub_menu_region_check_rect (&x1, &y1, &w1, &h1, - x, y, width, height)) - { - glyph_bitmap.mode_info.pitch = glyph->width; - glyph_bitmap.mode_info.width = glyph->width; - glyph_bitmap.mode_info.height = glyph->height; - glyph_bitmap.data = glyph->bitmap; - grub_video_blit_bitmap (&glyph_bitmap, GRUB_VIDEO_BLIT_BLEND, - scn_x + x1, scn_y + y1, - x1 - ox, y1 - oy, w1, h1); - } - - left_x += glyph->device_width; - } + grub_font_draw_string(text->text, text->font, text->color, -x, -y + base_y); } static void @@ -209,8 +162,9 @@ grub_gfx_region_update_bitmap (struct grub_menu_region_bitmap *bitmap, int x, int y, int width, int height, int scn_x, int scn_y) { + grub_video_set_viewport(scn_x, scn_y, width, height); grub_video_blit_bitmap (bitmap->bitmap, GRUB_VIDEO_BLIT_REPLACE, - scn_x, scn_y, x, y, width, height); + 0, 0, x, y, width, height); } static struct grub_menu_region grub_gfx_region =
_______________________________________________ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel