vt_vga.c (270485) | vt_vga.c (270613) |
---|---|
1/*- 2 * Copyright (c) 2005 Marcel Moolenaar 3 * All rights reserved. 4 * 5 * Copyright (c) 2009 The FreeBSD Foundation 6 * All rights reserved. 7 * 8 * Portions of this software were developed by Ed Schouten --- 17 unchanged lines hidden (view full) --- 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2005 Marcel Moolenaar 3 * All rights reserved. 4 * 5 * Copyright (c) 2009 The FreeBSD Foundation 6 * All rights reserved. 7 * 8 * Portions of this software were developed by Ed Schouten --- 17 unchanged lines hidden (view full) --- 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: head/sys/dev/vt/hw/vga/vt_vga.c 270485 2014-08-24 14:39:33Z dumbbell $"); | 34__FBSDID("$FreeBSD: head/sys/dev/vt/hw/vga/vt_vga.c 270613 2014-08-25 19:06:31Z dumbbell $"); |
35 36#include <sys/param.h> 37#include <sys/kernel.h> 38#include <sys/systm.h> 39 40#include <dev/vt/vt.h> 41#include <dev/vt/hw/vga/vt_vga_reg.h> 42 --- 508 unchanged lines hidden (view full) --- 551 */ 552 553 i = x; 554 used_colors = 0; 555 memset(used_colors_list, 0, sizeof(used_colors_list)); 556 memset(pattern_2colors, 0, sizeof(pattern_2colors)); 557 memset(pattern_ncolors, 0, sizeof(pattern_ncolors)); 558 | 35 36#include <sys/param.h> 37#include <sys/kernel.h> 38#include <sys/systm.h> 39 40#include <dev/vt/vt.h> 41#include <dev/vt/hw/vga/vt_vga_reg.h> 42 --- 508 unchanged lines hidden (view full) --- 551 */ 552 553 i = x; 554 used_colors = 0; 555 memset(used_colors_list, 0, sizeof(used_colors_list)); 556 memset(pattern_2colors, 0, sizeof(pattern_2colors)); 557 memset(pattern_ncolors, 0, sizeof(pattern_ncolors)); 558 |
559 if (i < vw->vw_offset.tp_col) { | 559 if (i < vw->vw_draw_area.tr_begin.tp_col) { |
560 /* 561 * i is in the margin used to center the text area on 562 * the screen. 563 */ 564 | 560 /* 561 * i is in the margin used to center the text area on 562 * the screen. 563 */ 564 |
565 i = vw->vw_offset.tp_col; | 565 i = vw->vw_draw_area.tr_begin.tp_col; |
566 } 567 | 566 } 567 |
568 while (i < x + VT_VGA_PIXELS_BLOCK) { | 568 while (i < x + VT_VGA_PIXELS_BLOCK && 569 i < vw->vw_draw_area.tr_end.tp_col) { |
569 /* 570 * Find which character is drawn on this pixel in the 571 * pixels block. 572 * 573 * While here, record what colors it uses. 574 */ 575 | 570 /* 571 * Find which character is drawn on this pixel in the 572 * pixels block. 573 * 574 * While here, record what colors it uses. 575 */ 576 |
576 col = (i - vw->vw_offset.tp_col) / vf->vf_width; 577 row = (y - vw->vw_offset.tp_row) / vf->vf_height; | 577 col = (i - vw->vw_draw_area.tr_begin.tp_col) / vf->vf_width; 578 row = (y - vw->vw_draw_area.tr_begin.tp_row) / vf->vf_height; |
578 579 c = VTBUF_GET_FIELD(vb, row, col); 580 src = vtfont_lookup(vf, c); 581 582 vt_determine_colors(c, VTBUF_ISCURSOR(vb, row, col), &fg, &bg); 583 if ((used_colors_list[fg] & 0x1) != 0x1) 584 used_colors++; 585 if ((used_colors_list[bg] & 0x2) != 0x2) --- 14 unchanged lines hidden (view full) --- 600 * - the last pixel of the character, or 601 * - the pixel of the character matching the end of 602 * the pixels block 603 * whichever comes first. This position is then 604 * changed to be relative to the start position of the 605 * character. 606 */ 607 | 579 580 c = VTBUF_GET_FIELD(vb, row, col); 581 src = vtfont_lookup(vf, c); 582 583 vt_determine_colors(c, VTBUF_ISCURSOR(vb, row, col), &fg, &bg); 584 if ((used_colors_list[fg] & 0x1) != 0x1) 585 used_colors++; 586 if ((used_colors_list[bg] & 0x2) != 0x2) --- 14 unchanged lines hidden (view full) --- 601 * - the last pixel of the character, or 602 * - the pixel of the character matching the end of 603 * the pixels block 604 * whichever comes first. This position is then 605 * changed to be relative to the start position of the 606 * character. 607 */ 608 |
608 src_x = i - (col * vf->vf_width + vw->vw_offset.tp_col); 609 x_count = min( 610 (col + 1) * vf->vf_width + vw->vw_offset.tp_col, 611 x + VT_VGA_PIXELS_BLOCK); 612 x_count -= col * vf->vf_width + vw->vw_offset.tp_col; | 609 src_x = i - 610 (col * vf->vf_width + vw->vw_draw_area.tr_begin.tp_col); 611 x_count = min(min( 612 (col + 1) * vf->vf_width + 613 vw->vw_draw_area.tr_begin.tp_col, 614 x + VT_VGA_PIXELS_BLOCK), 615 vw->vw_draw_area.tr_end.tp_col); 616 x_count -= col * vf->vf_width + 617 vw->vw_draw_area.tr_begin.tp_col; |
613 x_count -= src_x; 614 615 /* Copy a portion of the character. */ 616 vga_copy_bitmap_portion(pattern_2colors, pattern_ncolors, 617 src, NULL, vf->vf_width, 618 src_x, i % VT_VGA_PIXELS_BLOCK, x_count, 619 0, 0, vf->vf_height, fg, bg, 0); 620 --- 17 unchanged lines hidden (view full) --- 638 drawn_area.tr_end.tp_col = x + VT_VGA_PIXELS_BLOCK; 639 drawn_area.tr_end.tp_row = y + vf->vf_height; 640 if (vd->vd_mshown && vt_is_cursor_in_area(vd, &drawn_area)) { 641 struct vt_mouse_cursor *cursor; 642 unsigned int mx, my; 643 unsigned int dst_x, src_y, dst_y, y_count; 644 645 cursor = vd->vd_mcursor; | 618 x_count -= src_x; 619 620 /* Copy a portion of the character. */ 621 vga_copy_bitmap_portion(pattern_2colors, pattern_ncolors, 622 src, NULL, vf->vf_width, 623 src_x, i % VT_VGA_PIXELS_BLOCK, x_count, 624 0, 0, vf->vf_height, fg, bg, 0); 625 --- 17 unchanged lines hidden (view full) --- 643 drawn_area.tr_end.tp_col = x + VT_VGA_PIXELS_BLOCK; 644 drawn_area.tr_end.tp_row = y + vf->vf_height; 645 if (vd->vd_mshown && vt_is_cursor_in_area(vd, &drawn_area)) { 646 struct vt_mouse_cursor *cursor; 647 unsigned int mx, my; 648 unsigned int dst_x, src_y, dst_y, y_count; 649 650 cursor = vd->vd_mcursor; |
646 mx = vd->vd_mx_drawn + vw->vw_offset.tp_col; 647 my = vd->vd_my_drawn + vw->vw_offset.tp_row; | 651 mx = vd->vd_mx_drawn + vw->vw_draw_area.tr_begin.tp_col; 652 my = vd->vd_my_drawn + vw->vw_draw_area.tr_begin.tp_row; |
648 649 /* Compute the portion of the cursor we want to copy. */ 650 src_x = x > mx ? x - mx : 0; 651 dst_x = mx > x ? mx - x : 0; | 653 654 /* Compute the portion of the cursor we want to copy. */ 655 src_x = x > mx ? x - mx : 0; 656 dst_x = mx > x ? mx - x : 0; |
652 x_count = min( 653 min(cursor->width - src_x, x + VT_VGA_PIXELS_BLOCK - mx), | 657 x_count = min(min(min( 658 cursor->width - src_x, 659 x + VT_VGA_PIXELS_BLOCK - mx), 660 vw->vw_draw_area.tr_end.tp_col - mx), |
654 VT_VGA_PIXELS_BLOCK); 655 656 /* 657 * The cursor isn't aligned on the Y-axis with 658 * characters, so we need to compute the vertical 659 * start/count. 660 */ 661 src_y = y > my ? y - my : 0; --- 58 unchanged lines hidden (view full) --- 720 * alignment. 721 * 722 * For the Y-axis, we need to compute the character's y 723 * coordinate, but we don't need to align it. 724 */ 725 726 col = area->tr_begin.tp_col; 727 row = area->tr_begin.tp_row; | 661 VT_VGA_PIXELS_BLOCK); 662 663 /* 664 * The cursor isn't aligned on the Y-axis with 665 * characters, so we need to compute the vertical 666 * start/count. 667 */ 668 src_y = y > my ? y - my : 0; --- 58 unchanged lines hidden (view full) --- 727 * alignment. 728 * 729 * For the Y-axis, we need to compute the character's y 730 * coordinate, but we don't need to align it. 731 */ 732 733 col = area->tr_begin.tp_col; 734 row = area->tr_begin.tp_row; |
728 x1 = (int)((col * vf->vf_width + vw->vw_offset.tp_col) | 735 x1 = (int)((col * vf->vf_width + vw->vw_draw_area.tr_begin.tp_col) |
729 / VT_VGA_PIXELS_BLOCK) 730 * VT_VGA_PIXELS_BLOCK; | 736 / VT_VGA_PIXELS_BLOCK) 737 * VT_VGA_PIXELS_BLOCK; |
731 y1 = row * vf->vf_height + vw->vw_offset.tp_row; | 738 y1 = row * vf->vf_height + vw->vw_draw_area.tr_begin.tp_row; |
732 733 /* 734 * Compute the bottom right pixel position, again, aligned with 735 * the pixels block size. 736 * 737 * The same rules apply, we just add 1 to base the computation 738 * on the "right border" of the dirty area. 739 */ 740 741 col = area->tr_end.tp_col; 742 row = area->tr_end.tp_row; | 739 740 /* 741 * Compute the bottom right pixel position, again, aligned with 742 * the pixels block size. 743 * 744 * The same rules apply, we just add 1 to base the computation 745 * on the "right border" of the dirty area. 746 */ 747 748 col = area->tr_end.tp_col; 749 row = area->tr_end.tp_row; |
743 x2 = (int)((col * vf->vf_width + vw->vw_offset.tp_col | 750 x2 = (int)((col * vf->vf_width + vw->vw_draw_area.tr_begin.tp_col |
744 + VT_VGA_PIXELS_BLOCK - 1) 745 / VT_VGA_PIXELS_BLOCK) 746 * VT_VGA_PIXELS_BLOCK; | 751 + VT_VGA_PIXELS_BLOCK - 1) 752 / VT_VGA_PIXELS_BLOCK) 753 * VT_VGA_PIXELS_BLOCK; |
747 y2 = row * vf->vf_height + vw->vw_offset.tp_row; | 754 y2 = row * vf->vf_height + vw->vw_draw_area.tr_begin.tp_row; |
748 | 755 |
749 /* 750 * Clip the area to the screen size. 751 * 752 * FIXME: Take vw_offset into account. 753 */ 754 x2 = min(x2, vd->vd_width - 1); 755 y2 = min(y2, vd->vd_height - 1); | 756 /* Clip the area to the screen size. */ 757 x2 = min(x2, vw->vw_draw_area.tr_end.tp_col); 758 y2 = min(y2, vw->vw_draw_area.tr_end.tp_row); |
756 757 /* 758 * Now, we take care of N pixels line at a time (the first for 759 * loop, N = font height), and for these lines, draw one pixels 760 * block at a time (the second for loop), not a character at a 761 * time. 762 * 763 * Therefore, on the X-axis, characters my be drawn partially if --- 399 unchanged lines hidden --- | 759 760 /* 761 * Now, we take care of N pixels line at a time (the first for 762 * loop, N = font height), and for these lines, draw one pixels 763 * block at a time (the second for loop), not a character at a 764 * time. 765 * 766 * Therefore, on the X-axis, characters my be drawn partially if --- 399 unchanged lines hidden --- |