Fixed some bugs in the Nano-X video driver
authorSam Lantinga <slouken@libsdl.org>
Sat, 30 Aug 2003 09:06:37 +0000
changeset 699d3b2e93629eb
parent 698 31d9be995d5c
child 700 c35edafc84d1
Fixed some bugs in the Nano-X video driver
src/video/nanox/SDL_nximage.c
src/video/nanox/SDL_nxvideo.c
     1.1 --- a/src/video/nanox/SDL_nximage.c	Sat Aug 30 06:27:01 2003 +0000
     1.2 +++ b/src/video/nanox/SDL_nximage.c	Sat Aug 30 09:06:37 2003 +0000
     1.3 @@ -49,55 +49,73 @@
     1.4          w = rects [i].w, h = rects [i].h ;
     1.5          src = SDL_Image + y * yinc + x * xinc ;
     1.6  #ifdef ENABLE_NANOX_DIRECT_FB
     1.7 -	if (Clientfb) {
     1.8 -	    if (currently_fullscreen)
     1.9 -	        dest = fbinfo.winpixels + (((y+OffsetY) * fbinfo.pitch) +
    1.10 -		    ((x+OffsetX) * fbinfo.bytespp));
    1.11 -	    else
    1.12 -	        dest = fbinfo.winpixels + ((y * fbinfo.pitch) + (x * fbinfo.bytespp));
    1.13 -	    destinc = fbinfo.pitch;
    1.14 -	} else {
    1.15 +        if (Clientfb) {
    1.16 +            if (currently_fullscreen)
    1.17 +                dest = fbinfo.winpixels + (((y+OffsetY) * fbinfo.pitch) +
    1.18 +                    ((x+OffsetX) * fbinfo.bytespp));
    1.19 +            else
    1.20 +                dest = fbinfo.winpixels + ((y * fbinfo.pitch) + (x * fbinfo.bytespp));
    1.21 +            destinc = fbinfo.pitch;
    1.22 +        }
    1.23 +        else
    1.24  #endif
    1.25 +        {
    1.26              dest = Image_buff ;
    1.27              destinc = w * xinc ;
    1.28 -#ifdef ENABLE_NANOX_DIRECT_FB
    1.29 -	}
    1.30 -#endif
    1.31 -	rowinc = w * xinc;
    1.32 +        }
    1.33 +        rowinc = w * xinc;
    1.34  
    1.35          // apply GammaRamp table
    1.36          if ((pixel_type == MWPF_TRUECOLOR0888 || pixel_type == MWPF_TRUECOLOR888)
    1.37 -	  && GammaRamp_R && GammaRamp_G && GammaRamp_B) {
    1.38 -            Uint8 * ptr ;
    1.39 +          && GammaRamp_R && GammaRamp_G && GammaRamp_B) {
    1.40 +            Uint8 * ptrsrc ;
    1.41 +            Uint8 * ptrdst ;
    1.42              int   k ;
    1.43  
    1.44 -            for (j = h; j > 0; -- j, src += yinc) {
    1.45 -                ptr = src - 1 ;
    1.46 +            for (j = h; j > 0; -- j, src += yinc, dest += destinc) {
    1.47 +                ptrsrc = src ;
    1.48 +                ptrdst = dest ;
    1.49                  for (k = w; k > 0; -- k) {
    1.50 -		    if (pixel_type == MWPF_TRUECOLOR0888)
    1.51 -                        ptr += 2 ;
    1.52 -                    else
    1.53 -                        ++ ptr ;
    1.54 -                    (* ptr) = GammaRamp_B [(* ptr)] ;
    1.55 -                    ++ ptr ;
    1.56 -                    (* ptr) = GammaRamp_G [(* ptr)] ;
    1.57 -                    ++ ptr ;
    1.58 -                    (* ptr) = GammaRamp_R [(* ptr)] ;
    1.59 +                    *ptrdst++ = GammaRamp_B [*ptrsrc++] >> 8;
    1.60 +                    *ptrdst++ = GammaRamp_G [*ptrsrc++] >> 8;
    1.61 +                    *ptrdst++ = GammaRamp_R [*ptrsrc++] >> 8;
    1.62 +                    *ptrdst++ = 0;
    1.63 +                    ++ptrsrc;
    1.64                  }
    1.65              }
    1.66 -            src = SDL_Image + y * yinc + x * xinc ;
    1.67          }
    1.68 +#if 0 /* This is needed for microwindows 0.90 or older */
    1.69 +        else if (pixel_type == MWPF_TRUECOLOR0888 || pixel_type == MWPF_TRUECOLOR888) {
    1.70 +            Uint8 * ptrsrc ;
    1.71 +            Uint8 * ptrdst ;
    1.72 +            int   k ;
    1.73  
    1.74 -        for (j = h; j > 0; -- j, src += yinc, dest += destinc)
    1.75 -            memcpy (dest, src, rowinc) ;
    1.76 -	if (!Clientfb) {
    1.77 +            for (j = h; j > 0; -- j, src += yinc, dest += destinc) {
    1.78 +                ptrsrc = src ;
    1.79 +                ptrdst = dest ;
    1.80 +                for (k = w; k > 0; -- k) {
    1.81 +                    *ptrdst++ = *ptrsrc++;
    1.82 +                    *ptrdst++ = *ptrsrc++;
    1.83 +                    *ptrdst++ = *ptrsrc++;
    1.84 +                    *ptrdst++ = 0;
    1.85 +                    ++ptrsrc;
    1.86 +                }
    1.87 +            }
    1.88 +        }
    1.89 +#endif
    1.90 +        else
    1.91 +        {
    1.92 +            for (j = h; j > 0; -- j, src += yinc, dest += destinc)
    1.93 +                memcpy (dest, src, rowinc) ;
    1.94 +        }
    1.95 +        if (!Clientfb) {
    1.96              if (currently_fullscreen) {
    1.97                  GrArea (FSwindow, SDL_GC, x + OffsetX, y + OffsetY, w, h, Image_buff, 
    1.98                      pixel_type) ;
    1.99              } else {
   1.100                  GrArea (SDL_Window, SDL_GC, x, y, w, h, Image_buff, pixel_type) ;
   1.101              }
   1.102 -	}
   1.103 +        }
   1.104      }
   1.105      GrFlush();
   1.106  
   1.107 @@ -183,33 +201,33 @@
   1.108          char *src, *dest = NULL;
   1.109          int xinc, yinc, rowinc;
   1.110  
   1.111 -	GrGetWindowFBInfo(SDL_Window, &fbinfo);
   1.112 +        GrGetWindowFBInfo(SDL_Window, &fbinfo);
   1.113  
   1.114 -	xinc = this -> screen -> format -> BytesPerPixel ; 
   1.115 -	yinc = this -> screen -> pitch ;           
   1.116 +        xinc = this -> screen -> format -> BytesPerPixel ; 
   1.117 +        yinc = this -> screen -> pitch ;           
   1.118  
   1.119 -	src = SDL_Image;
   1.120 -	if (currently_fullscreen)
   1.121 -	    dest = fbinfo.winpixels + ((OffsetY * fbinfo.pitch) +
   1.122 -	        (OffsetX * fbinfo.bytespp));
   1.123 -	else
   1.124 -	    dest = fbinfo.winpixels;
   1.125 -	rowinc = xinc * this -> screen -> w;
   1.126 +        src = SDL_Image;
   1.127 +        if (currently_fullscreen)
   1.128 +            dest = fbinfo.winpixels + ((OffsetY * fbinfo.pitch) +
   1.129 +                (OffsetX * fbinfo.bytespp));
   1.130 +        else
   1.131 +            dest = fbinfo.winpixels;
   1.132 +        rowinc = xinc * this -> screen -> w;
   1.133  
   1.134 -	for (j = this -> screen -> h; j > 0; -- j, src += yinc, dest += fbinfo.pitch)
   1.135 -	    memcpy (dest, src, rowinc) ;
   1.136 -    } else {
   1.137 +        for (j = this -> screen -> h; j > 0; -- j, src += yinc, dest += fbinfo.pitch)
   1.138 +            memcpy (dest, src, rowinc) ;
   1.139 +    }
   1.140 +    else
   1.141  #endif
   1.142 +    {
   1.143          if (currently_fullscreen) {
   1.144              GrArea (FSwindow, SDL_GC, OffsetX, OffsetY, this -> screen -> w, 
   1.145                  this -> screen -> h, SDL_Image, pixel_type) ;
   1.146 -	} else {
   1.147 +        } else {
   1.148              GrArea (SDL_Window, SDL_GC, 0, 0, this -> screen -> w, 
   1.149                  this -> screen -> h, SDL_Image, pixel_type) ;
   1.150 -	}
   1.151 -#ifdef ENABLE_NANOX_DIRECT_FB
   1.152 +        }
   1.153      }
   1.154 -#endif
   1.155      GrFlush();
   1.156  
   1.157      Dprintf ("leave NX_RefreshDisplay\n") ;
     2.1 --- a/src/video/nanox/SDL_nxvideo.c	Sat Aug 30 06:27:01 2003 +0000
     2.2 +++ b/src/video/nanox/SDL_nxvideo.c	Sat Aug 30 09:06:37 2003 +0000
     2.3 @@ -506,6 +506,7 @@
     2.4          GammaRamp_G [i] = green [i] ;
     2.5          GammaRamp_B [i] = blue  [i] ;
     2.6      }
     2.7 +    SDL_UpdateRect(this->screen, 0, 0, 0, 0);
     2.8  
     2.9      Dprintf ("leave NX_SetGammaRamp\n") ;   
    2.10      return 0 ;