|
From: Ian P. <piu...@us...> - 2004-04-02 01:23:09
|
Update of /cvsroot/squeak/squeak/platforms/unix/vm-display-fbdev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24684 Modified Files: sqUnixFBDevFramebuffer.c Log Message: Always use accessors for fb struct. Fix problem when xres * bytesPerPixel != scan line pitch. Index: sqUnixFBDevFramebuffer.c =================================================================== RCS file: /cvsroot/squeak/squeak/platforms/unix/vm-display-fbdev/sqUnixFBDevFramebuffer.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sqUnixFBDevFramebuffer.c 22 Aug 2003 17:07:15 -0000 1.3 --- sqUnixFBDevFramebuffer.c 2 Apr 2004 01:11:05 -0000 1.4 *************** *** 3,7 **** * Author: Ian Piumarta <ian...@in...> * ! * Last edited: 2003-08-21 15:00:23 by piumarta on felina.inria.fr */ --- 3,7 ---- * Author: Ian Piumarta <ian...@in...> * ! * Last edited: 2003-10-31 13:32:59 by piumarta on emilia.inria.fr */ *************** *** 71,74 **** --- 71,75 ---- struct fb_var_screeninfo var; struct fb_fix_screeninfo fix; + long int pitch; int bpp; fb_copyBits_t copyBits; *************** *** 110,113 **** --- 111,115 ---- static inline int fb_width(_self) { return self->var.xres; } + static inline int fb_pitch(_self) { return self->pitch; } static inline int fb_height(_self) { return self->var.yres; } static inline int fb_depth(_self) { return self->var.bits_per_pixel; } *************** *** 116,120 **** static inline unsigned long fb_getPixel_32(_self, int x, int y) { ! return ((x >= 0) && (y >= 0) && (x < self->var.xres) && (y < self->var.yres)) ? *((unsigned long *)(self->addr + (x + self->var.xoffset) * (32 / 8) --- 118,122 ---- static inline unsigned long fb_getPixel_32(_self, int x, int y) { ! return ((x >= 0) && (y >= 0) && (x < fb_width(self)) && (y < fb_height(self))) ? *((unsigned long *)(self->addr + (x + self->var.xoffset) * (32 / 8) *************** *** 125,129 **** static inline void fb_putPixel_32(_self, int x, int y, unsigned long pix) { ! if ((x >= 0) && (y >= 0) && (x < self->var.xres) && (y < self->var.yres)) { *((unsigned long *)(self->addr --- 127,131 ---- static inline void fb_putPixel_32(_self, int x, int y, unsigned long pix) { ! if ((x >= 0) && (y >= 0) && (x < fb_width(self)) && (y < fb_height(self))) { *((unsigned long *)(self->addr *************** *** 137,141 **** static inline unsigned long fb_getPixel_16(_self, int x, int y) { ! return ((x >= 0) && (y >= 0) && (x < self->var.xres) && (y < self->var.yres)) ? *((unsigned short *)(self->addr + (x + self->var.xoffset) * (16 / 8) --- 139,143 ---- static inline unsigned long fb_getPixel_16(_self, int x, int y) { ! return ((x >= 0) && (y >= 0) && (x < fb_width(self)) && (y < fb_height(self))) ? *((unsigned short *)(self->addr + (x + self->var.xoffset) * (16 / 8) *************** *** 146,150 **** static inline void fb_putPixel_16(_self, int x, int y, unsigned long pix) { ! if ((x >= 0) && (y >= 0) && (x < self->var.xres) && (y < self->var.yres)) { *((unsigned short *)(self->addr --- 148,152 ---- static inline void fb_putPixel_16(_self, int x, int y, unsigned long pix) { ! if ((x >= 0) && (y >= 0) && (x < fb_width(self)) && (y < fb_height(self))) { *((unsigned short *)(self->addr *************** *** 158,162 **** static inline unsigned long fb_getPixel_8(_self, int x, int y) { ! return ((x >= 0) && (y >= 0) && (x < self->var.xres) && (y < self->var.yres)) ? *((unsigned char *)(self->addr + (x + self->var.xoffset) --- 160,164 ---- static inline unsigned long fb_getPixel_8(_self, int x, int y) { ! return ((x >= 0) && (y >= 0) && (x < fb_width(self)) && (y < fb_height(self))) ? *((unsigned char *)(self->addr + (x + self->var.xoffset) *************** *** 168,172 **** static inline void fb_putPixel_8(_self, int x, int y, unsigned long pix) { ! if ((x >= 0) && (y >= 0) && (x < self->var.xres) && (y < self->var.yres)) { *((unsigned char *)(self->addr --- 170,174 ---- static inline void fb_putPixel_8(_self, int x, int y, unsigned long pix) { ! if ((x >= 0) && (y >= 0) && (x < fb_width(self)) && (y < fb_height(self))) { *((unsigned char *)(self->addr *************** *** 284,289 **** { hideCursor(self); ! self->cursorPosition.x= max(0, min(self->cursorPosition.x + dx, self->var.xres - 1)); ! self->cursorPosition.y= max(0, min(self->cursorPosition.y + dy, self->var.yres - 1)); showCursor(self); } --- 286,291 ---- { hideCursor(self); ! self->cursorPosition.x= max(0, min(self->cursorPosition.x + dx, fb_width(self) - 1)); ! self->cursorPosition.y= max(0, min(self->cursorPosition.y + dy, fb_height(self) - 1)); showCursor(self); } *************** *** 296,302 **** for (y= t; y < b; ++y) { ! int offset= (l + (y * self->var.xres)) * 4; ! unsigned long *in= (unsigned long *)(bits + offset); ! unsigned long *out= (unsigned long *)(self->addr + offset); for (x= l; x < r; x += 1, in += 1, out += 1) { --- 298,303 ---- for (y= t; y < b; ++y) { ! unsigned long *in= (unsigned long *)(bits + ((l + (y * fb_width(self))) * 4)); ! unsigned long *out= (unsigned long *)(self->addr + ((l + (y * fb_pitch(self))) * 4)); for (x= l; x < r; x += 1, in += 1, out += 1) { *************** *** 323,329 **** for (y= t; y < b; ++y) { ! int offset= (l + (y * self->var.xres)) * 2; ! unsigned short *in= (unsigned short *)(bits + offset); ! unsigned short *out= (unsigned short *)(self->addr + offset); for (x= l; x < r; x += 2, in += 2, out += 2) { --- 324,329 ---- for (y= t; y < b; ++y) { ! unsigned short *in= (unsigned short *)(bits + ((l + (y * fb_width(self))) * 2)); ! unsigned short *out= (unsigned short *)(self->addr + ((l + (y * fb_pitch(self))) * 2)); for (x= l; x < r; x += 2, in += 2, out += 2) { *************** *** 347,353 **** for (y= t; y < b; ++y) { ! int offset= (l + (y * self->var.xres)) * 2; ! unsigned short *in= (unsigned short *)(bits + offset); ! unsigned short *out= (unsigned short *)(self->addr + offset); for (x= l; x < r; x += 2, in += 2, out += 2) { --- 347,352 ---- for (y= t; y < b; ++y) { ! unsigned short *in= (unsigned short *)(bits + ((l + (y * fb_width(self))) * 2)); ! unsigned short *out= (unsigned short *)(self->addr + ((l + (y * fb_pitch(self))) * 2)); for (x= l; x < r; x += 2, in += 2, out += 2) { *************** *** 370,376 **** for (y= t; y < b; ++y) { ! int offset= (l + (y * self->var.xres)); ! unsigned char *in= (unsigned char *)(bits + offset); ! unsigned char *out= (unsigned char *)(self->addr + offset); for (x= l; x < r; x += 4, in += 4, out += 4) { --- 369,374 ---- for (y= t; y < b; ++y) { ! unsigned char *in= (unsigned char *)(bits + ((l + (y * fb_pitch(self))))); ! unsigned char *out= (unsigned char *)(self->addr + ((l + (y * fb_pitch(self))))); for (x= l; x < r; x += 4, in += 4, out += 4) { *************** *** 511,517 **** self->var.yoffset= 0; self->var.activate= FB_ACTIVATE_NOW; ! if (ioctl(self->fd, FBIOPAN_DISPLAY, &self->var)) perror("FBIOPAN_DISPLAY"); ! dprintf("%s: %dx%dx%d+%x+%x (%dx%d) %s, rgb %d+%d %d+%d %d+%d pitch %d\n", self->fbName, self->var.xres, self->var.yres, self->var.bits_per_pixel, self->var.xoffset, self->var.yoffset, self->var.xres_virtual, self->var.yres_virtual, --- 509,518 ---- self->var.yoffset= 0; self->var.activate= FB_ACTIVATE_NOW; ! ioctl(self->fd, FBIOPAN_DISPLAY, &self->var); ! self->size= fb_height(self) * self->fix.line_length; ! self->pitch= self->fix.line_length / self->var.bits_per_pixel * 8; ! ! dprintf("%s: %dx%dx%d+%x+%x (%dx%d) %s, rgb %d+%d %d+%d %d+%d pitch %d(%d)\n", self->fbName, self->var.xres, self->var.yres, self->var.bits_per_pixel, self->var.xoffset, self->var.yoffset, self->var.xres_virtual, self->var.yres_virtual, *************** *** 520,526 **** self->var.green.offset, self->var.green.length, self->var.blue .offset, self->var.blue .length, ! self->fix.line_length); ! ! self->size= self->var.yres * self->fix.line_length; if (self->var.bits_per_pixel == 8) --- 521,525 ---- self->var.green.offset, self->var.green.length, self->var.blue .offset, self->var.blue .length, ! self->fix.line_length, self->pitch); if (self->var.bits_per_pixel == 8) *************** *** 634,639 **** assert(self->kb); kb_initGraphics(self->kb); ! for (y= 0; y < self->var.yres; ++y) ! for (x= 0; x < self->var.xres; ++x) self->putPixel(self, x, y, self->whitePixel); } --- 633,638 ---- assert(self->kb); kb_initGraphics(self->kb); ! for (y= 0; y < fb_height(self); ++y) ! for (x= 0; x < fb_width(self); ++x) self->putPixel(self, x, y, self->whitePixel); } *************** *** 645,650 **** { int x, y; ! for (y= 0; y < self->var.yres; ++y) ! for (x= 0; x < self->var.xres; ++x) self->putPixel(self, x, y, 0); } --- 644,649 ---- { int x, y; ! for (y= 0; y < fb_height(self); ++y) ! for (x= 0; x < fb_width(self); ++x) self->putPixel(self, x, y, 0); } *************** *** 656,661 **** static void fb_initCursor(_self) { ! self->cursorPosition.x= self->var.xres / 2; ! self->cursorPosition.y= self->var.yres / 2; } --- 655,660 ---- static void fb_initCursor(_self) { ! self->cursorPosition.x= fb_width(self) / 2; ! self->cursorPosition.y= fb_height(self) / 2; } |