/[rdesktop]/sourceforge.net/trunk/rdesktop/xwin.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/xwin.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 315 by jsorg71, Wed Feb 5 14:16:33 2003 UTC revision 316 by jsorg71, Sun Feb 9 17:17:37 2003 UTC
# Line 71  typedef struct Line 71  typedef struct
71  }  }
72  PropMotifWmHints;  PropMotifWmHints;
73    
74    typedef struct
75    {
76            uint32 red;
77            uint32 green;
78            uint32 blue;
79    }
80    PixelColour;
81    
82  #define FILL_RECTANGLE(x,y,cx,cy)\  #define FILL_RECTANGLE(x,y,cx,cy)\
83  { \  { \
# Line 137  mwm_hide_decorations(void) Line 144  mwm_hide_decorations(void)
144                          (unsigned char *) &motif_hints, PROP_MOTIF_WM_HINTS_ELEMENTS);                          (unsigned char *) &motif_hints, PROP_MOTIF_WM_HINTS_ELEMENTS);
145  }  }
146    
147  uint32  PixelColour
148  colour16to24(uint32 colour)  split_colour15(uint32 colour)
149  {  {
150          int r;          PixelColour rv;
151          int g;          rv.red = (colour & 0x7c00) >> 10;
152          int b;          rv.red = (rv.red * 0xff) / 0x1f;
153          r = (colour & 0xf800) >> 11;          rv.green = (colour & 0x03e0) >> 5;
154          r = (r * 0xff) / 0x1f;          rv.green = (rv.green * 0xff) / 0x1f;
155          g = (colour & 0x07e0) >> 5;          rv.blue = (colour & 0x1f);
156          g = (g * 0xff) / 0x3f;          rv.blue = (rv.blue * 0xff) / 0x1f;
157          b = (colour & 0x001f);          return rv;
         b = (b * 0xff) / 0x1f;  
         return (r << 16) | (g << 8) | b;  
158  }  }
159    
160  uint32  PixelColour
161  colour16to32(uint32 colour)  split_colour16(uint32 colour)
162  {  {
163          return colour16to24(colour);          PixelColour rv;
164            rv.red = (colour & 0xf800) >> 11;
165            rv.red = (rv.red * 0xff) / 0x1f;
166            rv.green = (colour & 0x07e0) >> 5;
167            rv.green = (rv.green * 0xff) / 0x3f;
168            rv.blue = (colour & 0x001f);
169            rv.blue = (rv.blue * 0xff) / 0x1f;
170            return rv;
171  }  }
172    
173  uint32  PixelColour
174  colour24to32(uint32 colour)  split_colour24(uint32 colour)
175  {  {
176          return colour;          PixelColour rv;
177            rv.blue = (colour & 0xff0000) >> 16;
178            rv.green = (colour & 0xff00) >> 8;
179            rv.red = (colour & 0xff);
180            return rv;
181    }
182    
183    uint32 make_colour16(PixelColour pc)
184    {
185            pc.red = (pc.red * 0x1f) / 0xff;
186            pc.green = (pc.green * 0x3f) / 0xff;
187            pc.blue = (pc.blue * 0x1f) / 0xff;
188            return (pc.red << 11) | (pc.green << 5) | pc.blue;
189    }
190    
191    uint32 make_colour24(PixelColour pc)
192    {
193            return (pc.red << 16) | (pc.green << 8) | pc.blue;
194    }
195    
196    uint32 make_colour32(PixelColour pc)
197    {
198            return (pc.red << 16) | (pc.green << 8) | pc.blue;
199  }  }
200    
201  #define BSWAP16(x) { x = (((x & 0xff) << 8) | (x >> 8)); }  #define BSWAP16(x) { x = (((x & 0xff) << 8) | (x >> 8)); }
# Line 174  translate_colour(uint32 colour) Line 208  translate_colour(uint32 colour)
208  {  {
209          switch (server_bpp)          switch (server_bpp)
210          {          {
211                    case 15:
212                            switch (bpp)
213                            {
214                                    case 16:
215                                            colour = make_colour16(split_colour15(colour));
216                                            break;
217                                    case 24:
218                                            colour = make_colour24(split_colour15(colour));
219                                            break;
220                                    case 32:
221                                            colour = make_colour32(split_colour15(colour));
222                                            break;
223                            }
224                            break;
225                  case 16:                  case 16:
226                          switch (bpp)                          switch (bpp)
227                          {                          {
228                                  case 16:                                  case 16:
229                                          break;                                          break;
230                                  case 24:                                  case 24:
231                                          colour = colour16to24(colour);                                          colour = make_colour24(split_colour16(colour));
232                                          break;                                          break;
233                                  case 32:                                  case 32:
234                                          colour = colour16to32(colour);                                          colour = make_colour32(split_colour16(colour));
235                                          break;                                          break;
236                          }                          }
237                          break;                          break;
238                  case 24:                  case 24:
239                          switch (bpp)                          switch (bpp)
240                          {                          {
241                                    case 16:
242                                            colour = make_colour16(split_colour24(colour));
243                                            break;
244                                  case 24:                                  case 24:
245                                          break;                                          break;
246                                  case 32:                                  case 32:
247                                          colour = colour24to32(colour);                                          colour = make_colour32(split_colour24(colour));
248                                          break;                                          break;
249                          }                          }
250                          break;                          break;
# Line 233  translate8to16(uint8 * data, uint16 * ou Line 284  translate8to16(uint8 * data, uint16 * ou
284                  *(out++) = (uint16) colmap[*(data++)];                  *(out++) = (uint16) colmap[*(data++)];
285  }  }
286    
287    /* little endian - conversion happens when colourmap is built */
288  static void  static void
289  translate16to16(uint16 * data, uint16 * out, uint16 * end)  translate8to24(uint8 * data, uint8 * out, uint8 * end)
290    {
291            uint32 value;
292    
293            while (out < end)
294            {
295                    value = colmap[*(data++)];
296                    *(out++) = value;
297                    *(out++) = value >> 8;
298                    *(out++) = value >> 16;
299            }
300    }
301    
302    static void
303    translate8to32(uint8 * data, uint32 * out, uint32 * end)
304  {  {
305          while (out < end)          while (out < end)
306                  *(out++) = (uint16) translate_colour(*(data++));                  *(out++) = colmap[*(data++)];
307  }  }
308    
309  /* little endian - conversion happens when colourmap is built */  /* todo the remaining translate function might need some big endian check ?? */
310    
311  static void  static void
312  translate8to24(uint8 * data, uint8 * out, uint8 * end)  translate15to16(uint16 * data, uint16 * out, uint16 * end)
313    {
314            while (out < end)
315                    *(out++) = (uint16) make_colour16(split_colour15(*(data++)));
316    }
317    
318    static void
319    translate15to24(uint16 * data, uint8 * out, uint8 * end)
320  {  {
321          uint32 value;          uint32 value;
322    
323          while (out < end)          while (out < end)
324          {          {
325                  value = colmap[*(data++)];                  value = make_colour24(split_colour15(*(data++)));
326                  *(out++) = value;                  *(out++) = value;
327                  *(out++) = value >> 8;                  *(out++) = value >> 8;
328                  *(out++) = value >> 16;                  *(out++) = value >> 16;
# Line 256  translate8to24(uint8 * data, uint8 * out Line 330  translate8to24(uint8 * data, uint8 * out
330  }  }
331    
332  static void  static void
333    translate15to32(uint16 * data, uint32 * out, uint32 * end)
334    {
335            while (out < end)
336                    *(out++) = make_colour32(split_colour15(*(data++)));
337    }
338    
339    static void
340    translate16to16(uint16 * data, uint16 * out, uint16 * end)
341    {
342            while (out < end)
343                    *(out++) = (uint16) (*(data++));
344    }
345    
346    
347    static void
348  translate16to24(uint16 * data, uint8 * out, uint8 * end)  translate16to24(uint16 * data, uint8 * out, uint8 * end)
349  {  {
350          uint32 value;          uint32 value;
351    
352          while (out < end)          while (out < end)
353          {          {
354                  value = translate_colour(*(data++));                  value = make_colour24(split_colour16(*(data++)));
355                  *(out++) = value;                  *(out++) = value;
356                  *(out++) = value >> 8;                  *(out++) = value >> 8;
357                  *(out++) = value >> 16;                  *(out++) = value >> 16;
# Line 270  translate16to24(uint16 * data, uint8 * o Line 359  translate16to24(uint16 * data, uint8 * o
359  }  }
360    
361  static void  static void
362  translate8to32(uint8 * data, uint32 * out, uint32 * end)  translate16to32(uint16 * data, uint32 * out, uint32 * end)
363  {  {
364          while (out < end)          while (out < end)
365                  *(out++) = colmap[*(data++)];                  *(out++) = make_colour32(split_colour16(*(data++)));
366  }  }
367    
368  static void  static void
369  translate16to32(uint16 * data, uint32 * out, uint32 * end)  translate24to16(uint8 * data, uint16 * out, uint16 * end)
370  {  {
371            uint32 pixel = 0;
372          while (out < end)          while (out < end)
373                  *(out++) = translate_colour(*(data++));          {
374                    pixel = *(data++) << 16;
375                    pixel |= *(data++) << 8;
376                    pixel |= *(data++);
377                    *(out++) = (uint16) make_colour16(split_colour24(pixel));
378            }
379    }
380    
381    static void
382    translate24to24(uint8 * data, uint8 * out, uint8 * end)
383    {
384            while (out < end)
385            {
386                    *(out++) = (*(data++));
387            }
388    }
389    
390    static void
391    translate24to32(uint8 * data, uint32 * out, uint32 * end)
392    {
393            uint32 pixel = 0;
394            while (out < end)
395            {
396                    memcpy(&pixel, data, 3);
397                    data += 3;
398                    *(out++) = pixel;
399            }
400  }  }
401    
402  static uint8 *  static uint8 *
# Line 290  translate_image(int width, int height, u Line 406  translate_image(int width, int height, u
406          uint8 *out = xmalloc(size);          uint8 *out = xmalloc(size);
407          uint8 *end = out + size;          uint8 *end = out + size;
408    
409          if (server_bpp == 16)          switch (server_bpp)
         {  
                 if (bpp == 16)  
                         translate16to16((uint16 *) data, (uint16 *) out, (uint16 *) end);  
                 else if (bpp == 24)  
                         translate16to24((uint16 *) data, out, end); /* todo, check this one */  
                 else if (bpp == 32)  
                         translate16to32((uint16 *) data, (uint32 *) out, (uint32 *) end);  
                 return out;  
         }  
         /* todo needs server_bpp == 24 */  
         switch (bpp)  
410          {          {
411                  case 8:                  case 24:
412                          translate8to8(data, out, end);                          switch (bpp)
413                            {
414                                    case 32:
415                                            translate24to32(data, (uint32 *) out, (uint32 *) end);
416                                            break;
417                                    case 24:
418                                            translate24to24(data, out, end);
419                                            break;
420                                    case 16:
421                                            translate24to16(data, (uint16 *) out, (uint16 *) end);
422                                            break;
423                            }
424                          break;                          break;
   
425                  case 16:                  case 16:
426                          translate8to16(data, (uint16 *) out, (uint16 *) end);                          switch (bpp)
427                            {
428                                    case 32:
429                                            translate16to32((uint16 *) data, (uint32 *) out, (uint32 *) end);
430                                            break;
431                                    case 24:
432                                            translate16to24((uint16 *) data, out, end);
433                                            break;
434                                    case 16:
435                                            translate16to16((uint16 *) data, (uint16 *) out, (uint16 *) end);
436                                            break;
437                            }
438                          break;                          break;
439                    case 15:
440                  case 24:                          switch (bpp)
441                          translate8to24(data, out, end);                          {
442                                    case 32:
443                                            translate15to32((uint16 *) data, (uint32 *) out, (uint32 *) end);
444                                            break;
445                                    case 24:
446                                            translate15to24((uint16 *) data, out, end);
447                                            break;
448                                    case 16:
449                                            translate15to16((uint16 *) data, (uint16 *) out, (uint16 *) end);
450                                            break;
451                            }
452                          break;                          break;
453                    case 8:
454                  case 32:                          switch (bpp)
455                          translate8to32(data, (uint32 *) out, (uint32 *) end);                          {
456                                    case 8:
457                                            translate8to8(data, out, end);
458                                            break;
459                                    case 16:
460                                            translate8to16(data, (uint16 *) out, (uint16 *) end);
461                                            break;
462                                    case 24:
463                                            translate8to24(data, out, end);
464                                            break;
465                                    case 32:
466                                            translate8to32(data, (uint32 *) out, (uint32 *) end);
467                                            break;
468                            }
469                          break;                          break;
470          }          }
   
471          return out;          return out;
472  }  }
473    
# Line 448  ui_init(void) Line 596  ui_init(void)
596                  IM = XOpenIM(display, NULL, NULL, NULL);                  IM = XOpenIM(display, NULL, NULL, NULL);
597    
598          xkeymap_init();          xkeymap_init();
599    
600            /* todo take this out when high colour is done */
601            printf("server bpp %d client bpp %d depth %d\n", server_bpp, bpp, depth);
602    
603          return True;          return True;
604  }  }
605    

Legend:
Removed from v.315  
changed lines
  Added in v.316

  ViewVC Help
Powered by ViewVC 1.1.26