From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1NF5Gk-0005DH-OA for mharc-grub-devel@gnu.org; Mon, 30 Nov 2009 07:22:18 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NF5Gi-0005Cd-02 for grub-devel@gnu.org; Mon, 30 Nov 2009 07:22:16 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NF5Gc-0005C3-FU for grub-devel@gnu.org; Mon, 30 Nov 2009 07:22:14 -0500 Received: from [199.232.76.173] (port=50613 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NF5Gc-0005Bt-C4 for grub-devel@gnu.org; Mon, 30 Nov 2009 07:22:10 -0500 Received: from mail-ew0-f215.google.com ([209.85.219.215]:64792) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NF5Gc-0007Fi-2p for grub-devel@gnu.org; Mon, 30 Nov 2009 07:22:10 -0500 Received: by ewy7 with SMTP id 7so4306328ewy.8 for ; Mon, 30 Nov 2009 04:22:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:x-enigmail-version:content-type; bh=eVIVXj018W4gh0clnsLJHP2Q9GkOWdlr+pA8kA05YN8=; b=EpKJwqYv9BICG7CWOb0DcBqFhNK7qIpP4VhtXlUV7UAfjn0n6z0kyGjaTsNrzYTP0k AawDlIk7DEqBqs/r3/GWAfGhV0hNNAHC7aM/MJ5qN5S/bhvx5OxwV+qIPsOUyPPt7NyO +nrTgJPzbpnO41x07yWEoJbIolJitnDdmIZVU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :x-enigmail-version:content-type; b=CVpVadPsUqKMGwre3VnC6tm9haSvek4R9+6NCe7QUv1akJUwWCFkl5aaDLWxs/m44A /ErDomWJtpJGf9VkJ6vq7UfnXxGQd9tHe7sQ7zfmtyw8bktLF+1ucXCqPSLxcnrJSXnZ +YlekBAPVaZsVac1Ao+s4nu+EYSmBwB3orpMw= Received: by 10.213.99.134 with SMTP id u6mr4505931ebn.66.1259583727342; Mon, 30 Nov 2009 04:22:07 -0800 (PST) Received: from debian.bg45.phnet (gprs15.swisscom-mobile.ch [193.247.250.15]) by mx.google.com with ESMTPS id 13sm2503505ewy.13.2009.11.30.04.22.06 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 30 Nov 2009 04:22:06 -0800 (PST) Message-ID: <4B13B8E1.3090508@gmail.com> Date: Mon, 30 Nov 2009 13:21:53 +0100 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20091109) MIME-Version: 1.0 To: The development of GRUB 2 X-Enigmail-Version: 0.95.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="------------enig8E9847DDAE73A6ACFA22640E" X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [PATCH] speed up scrolling by agglomerating one-line scrolls X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Nov 2009 12:22:16 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig8E9847DDAE73A6ACFA22640E Content-Type: multipart/mixed; boundary="------------060102000000050009000406" This is a multi-part message in MIME format. --------------060102000000050009000406 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Available in experimental --=20 Regards Vladimir '=CF=86-coder/phcoder' Serbinenko --------------060102000000050009000406 Content-Type: text/x-diff; name="gfxtermscroll.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="gfxtermscroll.diff" =3D=3D=3D added file 'ChangeLog.gfxtermscroll' --- ChangeLog.gfxtermscroll 1970-01-01 00:00:00 +0000 +++ ChangeLog.gfxtermscroll 2009-11-30 11:52:39 +0000 @@ -0,0 +1,18 @@ +2009-11-30 Vladimir Serbinenko + + Agglomerate scrolling in gfxterm. + + * term/gfxterm.c (grub_virtual_screen): New member 'total_screen'. + (grub_virtual_screen_setup): Initialise 'total_screen'. + (write_char): Split to ... + (paint_char): ... this ... + (write_char): ... and this. + (paint_char): Handle delayed scrolling. + (draw_cursor): Likewise. + (scroll_up): Split to ... + (real_scroll): ... this ... + (scroll_up): ... and this. + (real_scroll): Handle multi-line scroll and draw below-the-bottom + characters. + (grub_gfxterm_refresh): Call real_scroll. + =3D=3D=3D modified file 'term/gfxterm.c' --- term/gfxterm.c 2009-11-20 13:30:58 +0000 +++ term/gfxterm.c 2009-11-30 11:51:20 +0000 @@ -102,6 +102,8 @@ /* Text buffer for virtual screen. Contains (columns * rows) number of entries. */ struct grub_colored_char *text_buffer; + + int total_scroll; }; =20 struct grub_gfxterm_window @@ -225,6 +227,7 @@ virtual_screen.cursor_x =3D 0; virtual_screen.cursor_y =3D 0; virtual_screen.cursor_state =3D 1; + virtual_screen.total_scroll =3D 0; =20 /* Calculate size of text buffer. */ virtual_screen.columns =3D virtual_screen.width / virtual_screen.norma= l_char_width; @@ -586,8 +589,8 @@ redraw_screen_rect (x, y, width, height); } =20 -static void -write_char (void) +static inline void +paint_char (unsigned cx, unsigned cy) { struct grub_colored_char *p; struct grub_font_glyph *glyph; @@ -599,10 +602,12 @@ unsigned int height; unsigned int width; =20 + if (cy + virtual_screen.total_scroll >=3D virtual_screen.rows) + return; + /* Find out active character. */ p =3D (virtual_screen.text_buffer - + virtual_screen.cursor_x - + (virtual_screen.cursor_y * virtual_screen.columns)); + + cx + (cy * virtual_screen.columns)); =20 p -=3D p->index; =20 @@ -616,8 +621,8 @@ color =3D p->fg_color; bgcolor =3D p->bg_color; =20 - x =3D virtual_screen.cursor_x * virtual_screen.normal_char_width; - y =3D virtual_screen.cursor_y * virtual_screen.normal_char_height; + x =3D cx * virtual_screen.normal_char_width; + y =3D (cy + virtual_screen.total_scroll) * virtual_screen.normal_char_= height; =20 /* Render glyph to text layer. */ grub_video_set_active_render_target (text_layer); @@ -630,64 +635,58 @@ width, height); } =20 -static void +static inline void +write_char (void) +{ + paint_char (virtual_screen.cursor_x, virtual_screen.cursor_y); +} + +static inline void draw_cursor (int show) { + unsigned int x; + unsigned int y; + unsigned int width; + unsigned int height; + grub_video_color_t color; + =20 write_char (); =20 - if (show) - { - unsigned int x; - unsigned int y; - unsigned int width; - unsigned int height; - grub_video_color_t color; - - /* Determine cursor properties and position on text layer. */ - x =3D virtual_screen.cursor_x * virtual_screen.normal_char_width; - width =3D virtual_screen.normal_char_width; - color =3D virtual_screen.fg_color; - y =3D (virtual_screen.cursor_y * virtual_screen.normal_char_height= - + grub_font_get_ascent (virtual_screen.font)); - height =3D 2; - - /* Render cursor to text layer. */ - grub_video_set_active_render_target (text_layer); - grub_video_fill_rect (color, x, y, width, height); - grub_video_set_active_render_target (render_target); - - /* Mark cursor to be redrawn. */ - dirty_region_add (virtual_screen.offset_x + x, - virtual_screen.offset_y + y, - width, height); - } + if (!show) + return; + + if (virtual_screen.cursor_y + virtual_screen.total_scroll + >=3D virtual_screen.rows) + return; + + /* Determine cursor properties and position on text layer. */ + x =3D virtual_screen.cursor_x * virtual_screen.normal_char_width; + width =3D virtual_screen.normal_char_width; + color =3D virtual_screen.fg_color; + y =3D ((virtual_screen.cursor_y + virtual_screen.total_scroll) + * virtual_screen.normal_char_height + + grub_font_get_ascent (virtual_screen.font)); + height =3D 2; + =20 + /* Render cursor to text layer. */ + grub_video_set_active_render_target (text_layer); + grub_video_fill_rect (color, x, y, width, height); + grub_video_set_active_render_target (render_target); + =20 + /* Mark cursor to be redrawn. */ + dirty_region_add (virtual_screen.offset_x + x, + virtual_screen.offset_y + y, + width, height); } =20 static void -scroll_up (void) +real_scroll (void) { - unsigned int i; + unsigned int i, j, was_scroll; grub_video_color_t color; =20 - /* If we don't have background bitmap, remove cursor. */ - if (!bitmap) - { - /* Remove cursor. */ - draw_cursor (0); - } - - /* Scroll text buffer with one line to up. */ - grub_memmove (virtual_screen.text_buffer, - virtual_screen.text_buffer + virtual_screen.columns, - sizeof (*virtual_screen.text_buffer) - * virtual_screen.columns - * (virtual_screen.rows - 1)); - - /* Clear last line in text buffer. */ - for (i =3D virtual_screen.columns * (virtual_screen.rows - 1); - i < virtual_screen.columns * virtual_screen.rows; - i++) - clear_char (&(virtual_screen.text_buffer[i])); + if (!virtual_screen.total_scroll) + return; =20 /* If we have bitmap, re-draw screen, otherwise scroll physical screen= too. */ if (bitmap) @@ -695,7 +694,8 @@ /* Scroll physical screen. */ grub_video_set_active_render_target (text_layer); color =3D virtual_screen.bg_color; - grub_video_scroll (color, 0, -virtual_screen.normal_char_height); + grub_video_scroll (color, 0, -virtual_screen.normal_char_height + * virtual_screen.total_scroll); =20 /* Mark virtual screen to be redrawn. */ dirty_region_add_virtualscreen (); @@ -704,6 +704,9 @@ { grub_video_rect_t saved_view; =20 + /* Remove cursor. */ + draw_cursor (0); + grub_video_set_active_render_target (render_target); /* Save viewport and set it to our window. */ grub_video_get_viewport ((unsigned *) &saved_view.x,=20 @@ -723,13 +726,15 @@ virtual_screen.offset_x, virtual_screen.offset_y, virtual_screen.width, - virtual_screen.normal_char_height); + virtual_screen.normal_char_height + * virtual_screen.total_scroll); =20 grub_video_set_active_render_target (render_target); dirty_region_redraw (); =20 /* Scroll physical screen. */ - grub_video_scroll (color, 0, -virtual_screen.normal_char_height); + grub_video_scroll (color, 0, -virtual_screen.normal_char_height + * virtual_screen.total_scroll); =20 if (i) grub_video_swap_buffers (); @@ -739,23 +744,55 @@ /* Scroll physical screen. */ grub_video_set_active_render_target (text_layer); color =3D virtual_screen.bg_color; - grub_video_scroll (color, 0, -virtual_screen.normal_char_height); + grub_video_scroll (color, 0, -virtual_screen.normal_char_height + * virtual_screen.total_scroll); =20 /* Restore saved viewport. */ grub_video_set_viewport (saved_view.x, saved_view.y, saved_view.width, saved_view.height); grub_video_set_active_render_target (render_target); =20 - /* Draw cursor if visible. */ - if (virtual_screen.cursor_state) - draw_cursor (1); } =20 + /* Draw cursor if visible. */ + if (virtual_screen.cursor_state) + draw_cursor (1); + + was_scroll =3D virtual_screen.total_scroll; + virtual_screen.total_scroll =3D 0; + + /* Draw shadow part. */ + for (i =3D virtual_screen.rows - was_scroll; + i < virtual_screen.rows; i++) + for (j =3D 0; j < virtual_screen.columns; j++) + paint_char (j, i); + if (repaint_callback) repaint_callback (window.x, window.y, window.width, window.height); } =20 static void +scroll_up (void) +{ + unsigned int i; + + /* Scroll text buffer with one line to up. */ + grub_memmove (virtual_screen.text_buffer, + virtual_screen.text_buffer + virtual_screen.columns, + sizeof (*virtual_screen.text_buffer) + * virtual_screen.columns + * (virtual_screen.rows - 1)); + + /* Clear last line in text buffer. */ + for (i =3D virtual_screen.columns * (virtual_screen.rows - 1); + i < virtual_screen.columns * virtual_screen.rows; + i++) + clear_char (&(virtual_screen.text_buffer[i])); + + virtual_screen.total_scroll++; +} + +static void grub_gfxterm_putchar (grub_uint32_t c) { if (c =3D=3D '\a') @@ -1023,6 +1060,8 @@ static void grub_gfxterm_refresh (void) { + real_scroll (); + /* Redraw only changed regions. */ dirty_region_redraw (); =20 --------------060102000000050009000406-- --------------enig8E9847DDAE73A6ACFA22640E Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iF4EAREKAAYFAksTuOkACgkQNak7dOguQgluLQD+PlMAO8qDkGR5OsXXmLNQfp6S wfKd6W8ErY78UMVv+y8A/R2nFKD5qzVt9ddB3zyv1h5AP44NWFXSa+9g+EXmdfcB =2OX7 -----END PGP SIGNATURE----- --------------enig8E9847DDAE73A6ACFA22640E--