/[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 697 by astrand, Tue May 11 13:45:57 2004 UTC revision 788 by astrand, Thu Oct 21 08:43:22 2004 UTC
# Line 47  extern uint32 g_embed_wnd; Line 47  extern uint32 g_embed_wnd;
47  BOOL g_enable_compose = False;  BOOL g_enable_compose = False;
48  BOOL g_Unobscured;              /* used for screenblt */  BOOL g_Unobscured;              /* used for screenblt */
49  static GC g_gc = NULL;  static GC g_gc = NULL;
50    static GC g_create_bitmap_gc = NULL;
51    static GC g_create_glyph_gc = NULL;
52  static Visual *g_visual;  static Visual *g_visual;
53  static int g_depth;  static int g_depth;
54  static int g_bpp;  static int g_bpp;
# Line 172  static PixelColour Line 174  static PixelColour
174  split_colour15(uint32 colour)  split_colour15(uint32 colour)
175  {  {
176          PixelColour rv;          PixelColour rv;
177          rv.red = (colour & 0x7c00) >> 7;          rv.red = ((colour >> 7) & 0xf8) | ((colour >> 12) & 0x7);
178          rv.green = (colour & 0x03e0) >> 2;          rv.green = ((colour >> 2) & 0xf8) | ((colour >> 8) & 0x7);
179          rv.blue = (colour & 0x001f) << 3;          rv.blue = ((colour << 3) & 0xf8) | ((colour >> 2) & 0x7);
180          return rv;          return rv;
181  }  }
182    
# Line 182  static PixelColour Line 184  static PixelColour
184  split_colour16(uint32 colour)  split_colour16(uint32 colour)
185  {  {
186          PixelColour rv;          PixelColour rv;
187          rv.red = (colour & 0xf800) >> 8;          rv.red = ((colour >> 8) & 0xf8) | ((colour >> 13) & 0x7);
188          rv.green = (colour & 0x07e0) >> 3;          rv.green = ((colour >> 3) & 0xfc) | ((colour >> 9) & 0x3);
189          rv.blue = (colour & 0x001f) << 3;          rv.blue = ((colour << 3) & 0xf8) | ((colour >> 2) & 0x7);
190          return rv;          return rv;
191  }  }
192    
# Line 230  translate_colour(uint32 colour) Line 232  translate_colour(uint32 colour)
232          return make_colour(pc);          return make_colour(pc);
233  }  }
234    
235    /* indent is confused by UNROLL8 */
236    /* *INDENT-OFF* */
237    
238    /* repeat and unroll, similar to bitmap.c */
239    /* potentialy any of the following translate */
240    /* functions can use repeat but just doing */
241    /* the most common ones */
242    
243  #define UNROLL8(stm) { stm stm stm stm stm stm stm stm }  #define UNROLL8(stm) { stm stm stm stm stm stm stm stm }
244  #define REPEAT(stm) \  /* 2 byte output repeat */
245    #define REPEAT2(stm) \
246    { \
247            while (out <= end - 8 * 2) \
248                    UNROLL8(stm) \
249            while (out < end) \
250                    { stm } \
251    }
252    /* 4 byte output repeat */
253    #define REPEAT4(stm) \
254  { \  { \
255          while (out <= end - 8 * 4) \          while (out <= end - 8 * 4) \
256                  UNROLL8(stm) \                  UNROLL8(stm) \
# Line 252  translate8to16(uint8 * data, uint8 * out Line 271  translate8to16(uint8 * data, uint8 * out
271          uint16 value;          uint16 value;
272    
273          if (g_arch_match)          if (g_arch_match)
274                  REPEAT(*((uint16 *) out) = g_colmap[*(data++)]; out += 2;          {
275                    REPEAT2
276                    (
277                            *((uint16 *) out) = g_colmap[*(data++)];
278                            out += 2;
279                  )                  )
280          else          }
281  if (g_xserver_be)          else if (g_xserver_be)
 {  
         while (out < end)  
282          {          {
283                  value = (uint16) g_colmap[*(data++)];                  while (out < end)
284                  *(out++) = value >> 8;                  {
285                  *(out++) = value;                          value = (uint16) g_colmap[*(data++)];
286                            *(out++) = value >> 8;
287                            *(out++) = value;
288                    }
289          }          }
290  }          else
 else  
 {  
         while (out < end)  
291          {          {
292                  value = (uint16) g_colmap[*(data++)];                  while (out < end)
293                  *(out++) = value;                  {
294                  *(out++) = value >> 8;                          value = (uint16) g_colmap[*(data++)];
295                            *(out++) = value;
296                            *(out++) = value >> 8;
297                    }
298          }          }
299  }  }
 }  
300    
301  /* little endian - conversion happens when colourmap is built */  /* little endian - conversion happens when colourmap is built */
302  static void  static void
# Line 309  translate8to32(uint8 * data, uint8 * out Line 332  translate8to32(uint8 * data, uint8 * out
332          uint32 value;          uint32 value;
333    
334          if (g_arch_match)          if (g_arch_match)
335                  REPEAT(*((uint32 *) out) = g_colmap[*(data++)]; out += 4;          {
336                    REPEAT4
337                    (
338                            *((uint32 *) out) = g_colmap[*(data++)];
339                            out += 4;
340                  )                  )
341          else          }
342  if (g_xserver_be)          else if (g_xserver_be)
 {  
         while (out < end)  
343          {          {
344                  value = g_colmap[*(data++)];                  while (out < end)
345                  *(out++) = value >> 24;                  {
346                  *(out++) = value >> 16;                          value = g_colmap[*(data++)];
347                  *(out++) = value >> 8;                          *(out++) = value >> 24;
348                  *(out++) = value;                          *(out++) = value >> 16;
349                            *(out++) = value >> 8;
350                            *(out++) = value;
351                    }
352          }          }
353  }          else
 else  
 {  
         while (out < end)  
354          {          {
355                  value = g_colmap[*(data++)];                  while (out < end)
356                  *(out++) = value;                  {
357                  *(out++) = value >> 8;                          value = g_colmap[*(data++)];
358                  *(out++) = value >> 16;                          *(out++) = value;
359                  *(out++) = value >> 24;                          *(out++) = value >> 8;
360                            *(out++) = value >> 16;
361                            *(out++) = value >> 24;
362                    }
363          }          }
364  }  }
365  }  
366    /* *INDENT-ON* */
367    
368  static void  static void
369  translate15to16(uint16 * data, uint8 * out, uint8 * end)  translate15to16(uint16 * data, uint8 * out, uint8 * end)
# Line 917  BOOL Line 946  BOOL
946  ui_create_window(void)  ui_create_window(void)
947  {  {
948          uint8 null_pointer_mask[1] = { 0x80 };          uint8 null_pointer_mask[1] = { 0x80 };
949          uint8 null_pointer_data[4] = { 0x00, 0x00, 0x00, 0x00 };          uint8 null_pointer_data[24] = { 0x00 };
950    
951          XSetWindowAttributes attribs;          XSetWindowAttributes attribs;
952          XClassHint *classhints;          XClassHint *classhints;
953          XSizeHints *sizehints;          XSizeHints *sizehints;
# Line 942  ui_create_window(void) Line 972  ui_create_window(void)
972          if (g_gc == NULL)          if (g_gc == NULL)
973                  g_gc = XCreateGC(g_display, g_wnd, 0, NULL);                  g_gc = XCreateGC(g_display, g_wnd, 0, NULL);
974    
975            if (g_create_bitmap_gc == NULL)
976                    g_create_bitmap_gc = XCreateGC(g_display, g_wnd, 0, NULL);
977    
978          if ((g_ownbackstore) && (g_backstore == 0))          if ((g_ownbackstore) && (g_backstore == 0))
979          {          {
980                  g_backstore = XCreatePixmap(g_display, g_wnd, g_width, g_height, g_depth);                  g_backstore = XCreatePixmap(g_display, g_wnd, g_width, g_height, g_depth);
# Line 1031  void Line 1064  void
1064  ui_resize_window()  ui_resize_window()
1065  {  {
1066          XSizeHints *sizehints;          XSizeHints *sizehints;
1067            Pixmap bs;
1068    
1069          sizehints = XAllocSizeHints();          sizehints = XAllocSizeHints();
1070          if (sizehints)          if (sizehints)
# Line 1046  ui_resize_window() Line 1080  ui_resize_window()
1080          {          {
1081                  XResizeWindow(g_display, g_wnd, g_width, g_height);                  XResizeWindow(g_display, g_wnd, g_width, g_height);
1082          }          }
1083    
1084            /* create new backstore pixmap */
1085            if (g_backstore != 0)
1086            {
1087                    bs = XCreatePixmap(g_display, g_wnd, g_width, g_height, g_depth);
1088                    XSetForeground(g_display, g_gc, BlackPixelOfScreen(g_screen));
1089                    XFillRectangle(g_display, bs, g_gc, 0, 0, g_width, g_height);
1090                    XCopyArea(g_display, g_backstore, bs, g_gc, 0, 0, g_width, g_height, 0, 0);
1091                    XFreePixmap(g_display, g_backstore);
1092                    g_backstore = bs;
1093            }
1094  }  }
1095    
1096  void  void
# Line 1442  ui_create_bitmap(int width, int height, Line 1487  ui_create_bitmap(int width, int height,
1487          image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0,          image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0,
1488                               (char *) tdata, width, height, bitmap_pad, 0);                               (char *) tdata, width, height, bitmap_pad, 0);
1489    
1490          XPutImage(g_display, bitmap, g_gc, image, 0, 0, 0, 0, width, height);          XPutImage(g_display, bitmap, g_create_bitmap_gc, image, 0, 0, 0, 0, width, height);
1491    
1492          XFree(image);          XFree(image);
1493          if (tdata != data)          if (tdata != data)
# Line 1500  ui_create_glyph(int width, int height, u Line 1545  ui_create_glyph(int width, int height, u
1545          XImage *image;          XImage *image;
1546          Pixmap bitmap;          Pixmap bitmap;
1547          int scanline;          int scanline;
         GC gc;  
1548    
1549          scanline = (width + 7) / 8;          scanline = (width + 7) / 8;
1550    
1551          bitmap = XCreatePixmap(g_display, g_wnd, width, height, 1);          bitmap = XCreatePixmap(g_display, g_wnd, width, height, 1);
1552          gc = XCreateGC(g_display, bitmap, 0, NULL);          if (g_create_glyph_gc == 0)
1553                    g_create_glyph_gc = XCreateGC(g_display, bitmap, 0, NULL);
1554    
1555          image = XCreateImage(g_display, g_visual, 1, ZPixmap, 0, (char *) data,          image = XCreateImage(g_display, g_visual, 1, ZPixmap, 0, (char *) data,
1556                               width, height, 8, scanline);                               width, height, 8, scanline);
# Line 1513  ui_create_glyph(int width, int height, u Line 1558  ui_create_glyph(int width, int height, u
1558          image->bitmap_bit_order = MSBFirst;          image->bitmap_bit_order = MSBFirst;
1559          XInitImage(image);          XInitImage(image);
1560    
1561          XPutImage(g_display, bitmap, gc, image, 0, 0, 0, 0, width, height);          XPutImage(g_display, bitmap, g_create_glyph_gc, image, 0, 0, 0, 0, width, height);
1562    
1563          XFree(image);          XFree(image);
         XFreeGC(g_display, gc);  
1564          return (HGLYPH) bitmap;          return (HGLYPH) bitmap;
1565  }  }
1566    
# Line 2144  ui_desktop_restore(uint32 offset, int x, Line 2188  ui_desktop_restore(uint32 offset, int x,
2188    
2189          XFree(image);          XFree(image);
2190  }  }
2191    
2192    /* these do nothing here but are used in uiports */
2193    void
2194    ui_begin_update(void)
2195    {
2196    }
2197    
2198    void
2199    ui_end_update(void)
2200    {
2201    }

Legend:
Removed from v.697  
changed lines
  Added in v.788

  ViewVC Help
Powered by ViewVC 1.1.26