Changeset 2ce520c in mainline
- Timestamp:
- 2006-06-16T19:08:14Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d552ab9
- Parents:
- f5e4830
- Location:
- fb
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fb/fb.c
rf5e4830 r2ce520c 61 61 #include "../console/screenbuffer.h" 62 62 #include "ppm.h" 63 64 #include "pointer.xbm" 65 #include "pointer_mask.xbm" 63 66 64 67 #define DEFAULT_BGCOLOR 0xf0f0f0 … … 428 431 if (i == MAX_VIEWPORTS) 429 432 return ELIMIT; 430 431 if (width ==0 || height == 0 ||432 x+width > screen.xres || y+height > screen.yres)433 return EINVAL;434 if (width < FONT_SCANLINES || height < COL_WIDTH)435 return EINVAL;436 433 437 434 viewports[i].x = x; … … 736 733 } 737 734 738 /** Save viewport to pixmap */ 739 static int save_vp_to_pixmap(int vp) 740 { 741 int pm; 742 pixmap_t *pmap; 743 viewport_t *vport = &viewports[vp]; 735 static void copy_vp_to_pixmap(viewport_t *vport, pixmap_t *pmap) 736 { 744 737 int x,y; 745 738 int rowsize; 746 739 int tmp; 740 int width = vport->width; 741 int height = vport->height; 742 743 if (width + vport->x > screen.xres) 744 width = screen.xres - vport->x; 745 if (height + vport->y > screen.yres) 746 height = screen.yres - vport->y; 747 748 rowsize = width * screen.pixelbytes; 749 750 for (y=0;y < height; y++) { 751 tmp = (vport->y + y) * screen.scanline + vport->x * screen.pixelbytes; 752 memcpy(pmap->data + rowsize*y, screen.fbaddress + tmp, rowsize); 753 } 754 } 755 756 /** Save viewport to pixmap */ 757 static int save_vp_to_pixmap(viewport_t *vport) 758 { 759 int pm; 760 pixmap_t *pmap; 747 761 748 762 pm = find_free_pixmap(); … … 757 771 pmap->width = vport->width; 758 772 pmap->height = vport->height; 759 760 rowsize = vport->width * screen.pixelbytes; 761 for (y=0;y < vport->height; y++) { 762 tmp = (vport->y + y) * screen.scanline + vport->x * screen.pixelbytes; 763 memcpy(pmap->data + rowsize*y, screen.fbaddress + tmp, rowsize); 764 } 773 774 copy_vp_to_pixmap(vport, pmap); 775 765 776 return pm; 766 777 } … … 778 789 int tmp, srcrowsize; 779 790 int realwidth, realheight, realrowsize; 791 int width = vport->width; 792 int height = vport->height; 793 794 if (width + vport->x > screen.xres) 795 width = screen.xres - vport->x; 796 if (height + vport->y > screen.yres) 797 height = screen.yres - vport->y; 780 798 781 799 if (!pmap->data) 782 800 return EINVAL; 783 801 784 realwidth = pmap->width <= vport->width ? pmap->width : vport->width;785 realheight = pmap->height <= vport->height ? pmap->height : vport->height;802 realwidth = pmap->width <= width ? pmap->width : width; 803 realheight = pmap->height <= height ? pmap->height : height; 786 804 787 805 srcrowsize = vport->width * screen.pixelbytes; … … 812 830 animations[i].pos = (animations[i].pos+1) % animations[i].animlen; 813 831 } 832 } 833 834 835 static int pointer_x, pointer_y; 836 static int pointer_shown; 837 static int pointer_vport = -1; 838 static int pointer_pixmap = -1; 839 840 static void mouse_show(void) 841 { 842 int i,j; 843 int visibility; 844 int color; 845 int bytepos; 846 847 /* Save image under the cursor */ 848 if (pointer_vport == -1) { 849 pointer_vport = viewport_create(pointer_x, pointer_y, pointer_width, pointer_height); 850 if (pointer_vport < 0) 851 return; 852 } else { 853 viewports[pointer_vport].x = pointer_x; 854 viewports[pointer_vport].y = pointer_y; 855 } 856 857 if (pointer_pixmap == -1) 858 pointer_pixmap = save_vp_to_pixmap(&viewports[pointer_vport]); 859 else 860 copy_vp_to_pixmap(&viewports[pointer_vport], &pixmaps[pointer_pixmap]); 861 862 /* Draw cursor */ 863 for (i=0; i < pointer_height; i++) 864 for (j=0;j < pointer_width; j++) { 865 bytepos = i*((pointer_width-1)/8+1) + j/8; 866 visibility = pointer_mask_bits[bytepos] & (1 << (j % 8)); 867 if (visibility) { 868 color = pointer_bits[bytepos] & (1 << (j % 8)) ? 0 : 0xffffff; 869 if (pointer_x+j < screen.xres && pointer_y+i < screen.yres) 870 putpixel(&viewports[0], pointer_x+j, pointer_y+i, color); 871 } 872 } 873 pointer_shown = 1; 874 } 875 876 static void mouse_hide(void) 877 { 878 /* Restore image under the cursor */ 879 if (pointer_shown) { 880 draw_pixmap(pointer_vport, pointer_pixmap); 881 pointer_shown = 0; 882 } 883 } 884 885 static void mouse_move(unsigned int x, unsigned int y) 886 { 887 mouse_hide(); 888 pointer_x = x; 889 pointer_y = y; 890 mouse_show(); 814 891 } 815 892 … … 932 1009 retval = EINVAL; 933 1010 else 934 retval = save_vp_to_pixmap( nvp);1011 retval = save_vp_to_pixmap(&viewports[nvp]); 935 1012 break; 936 1013 case FB_DROP_PIXMAP: … … 1126 1203 continue; 1127 1204 case FB_POINTER_MOVE: 1128 putpixel(&viewports[0], IPC_GET_ARG1(call), IPC_GET_ARG2(call), 1129 0xd0a080); 1205 mouse_move(IPC_GET_ARG1(call), IPC_GET_ARG2(call)); 1130 1206 break; 1131 1207 default:
Note:
See TracChangeset
for help on using the changeset viewer.