/[rdesktop]/sourceforge.net/trunk/rdesktop/orders.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/orders.c

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

revision 12 by matty, Tue Aug 15 12:01:01 2000 UTC revision 24 by matty, Sat Jan 6 03:12:10 2001 UTC
# Line 59  static void rdp_in_coord(STREAM s, uint1 Line 59  static void rdp_in_coord(STREAM s, uint1
59          if (delta)          if (delta)
60          {          {
61                  in_uint8(s, change);                  in_uint8(s, change);
62                  *coord += (char)change;                  *coord += (char) change;
63          }          }
64          else          else
65          {          {
# Line 142  static BOOL rdp_parse_brush(STREAM s, BR Line 142  static BOOL rdp_parse_brush(STREAM s, BR
142    
143  /* Process a destination blt order */  /* Process a destination blt order */
144  static void process_destblt(STREAM s, DESTBLT_ORDER *os,  static void process_destblt(STREAM s, DESTBLT_ORDER *os,
145                                  uint32 present, BOOL delta)                              uint32 present, BOOL delta)
146  {  {
147          if (present & 0x01)          if (present & 0x01)
148                  rdp_in_coord(s, &os->x, delta);                  rdp_in_coord(s, &os->x, delta);
# Line 167  static void process_destblt(STREAM s, DE Line 167  static void process_destblt(STREAM s, DE
167    
168  /* Process a pattern blt order */  /* Process a pattern blt order */
169  static void process_patblt(STREAM s, PATBLT_ORDER *os,  static void process_patblt(STREAM s, PATBLT_ORDER *os,
170                                  uint32 present, BOOL delta)                             uint32 present, BOOL delta)
171  {  {
172          if (present & 0x0001)          if (present & 0x0001)
173                  rdp_in_coord(s, &os->x, delta);                  rdp_in_coord(s, &os->x, delta);
# Line 197  static void process_patblt(STREAM s, PAT Line 197  static void process_patblt(STREAM s, PAT
197                os->brush.style, os->bgcolour, os->fgcolour);                os->brush.style, os->bgcolour, os->fgcolour);
198    
199          ui_patblt(ROP2_P(os->opcode), os->x, os->y, os->cx, os->cy,          ui_patblt(ROP2_P(os->opcode), os->x, os->y, os->cx, os->cy,
200                                  &os->brush, os->bgcolour, os->fgcolour);                    &os->brush, os->bgcolour, os->fgcolour);
201  }  }
202    
203  /* Process a screen blt order */  /* Process a screen blt order */
204  static void process_screenblt(STREAM s, SCREENBLT_ORDER *os,  static void process_screenblt(STREAM s, SCREENBLT_ORDER *os,
205                                          uint32 present, BOOL delta)                                uint32 present, BOOL delta)
206  {  {
207          if (present & 0x0001)          if (present & 0x0001)
208                  rdp_in_coord(s, &os->x, delta);                  rdp_in_coord(s, &os->x, delta);
# Line 229  static void process_screenblt(STREAM s, Line 229  static void process_screenblt(STREAM s,
229                os->opcode, os->x, os->y, os->cx, os->cy, os->srcx, os->srcy);                os->opcode, os->x, os->y, os->cx, os->cy, os->srcx, os->srcy);
230    
231          ui_screenblt(ROP2_S(os->opcode), os->x, os->y, os->cx, os->cy,          ui_screenblt(ROP2_S(os->opcode), os->x, os->y, os->cx, os->cy,
232                                  os->srcx, os->srcy);                       os->srcx, os->srcy);
233  }  }
234    
235  /* Process a line order */  /* Process a line order */
# Line 268  static void process_line(STREAM s, LINE_ Line 268  static void process_line(STREAM s, LINE_
268                  return;                  return;
269          }          }
270    
271          ui_line(os->opcode-1, os->startx, os->starty,          ui_line(os->opcode - 1, os->startx, os->starty,
272                          os->endx, os->endy, &os->pen);                  os->endx, os->endy, &os->pen);
273  }  }
274    
275  /* Process an opaque rectangle order */  /* Process an opaque rectangle order */
# Line 298  static void process_rect(STREAM s, RECT_ Line 298  static void process_rect(STREAM s, RECT_
298    
299  /* Process a desktop save order */  /* Process a desktop save order */
300  static void process_desksave(STREAM s, DESKSAVE_ORDER *os,  static void process_desksave(STREAM s, DESKSAVE_ORDER *os,
301                                  uint32 present, BOOL delta)                               uint32 present, BOOL delta)
302  {  {
303          int width, height;          int width, height;
304    
# Line 330  static void process_desksave(STREAM s, D Line 330  static void process_desksave(STREAM s, D
330          if (os->action == 0)          if (os->action == 0)
331                  ui_desktop_save(os->offset, os->left, os->top, width, height);                  ui_desktop_save(os->offset, os->left, os->top, width, height);
332          else          else
333                  ui_desktop_restore(os->offset, os->left, os->top, width, height);                  ui_desktop_restore(os->offset, os->left, os->top, width,
334                                       height);
335  }  }
336    
337  /* Process a memory blt order */  /* Process a memory blt order */
338  static void process_memblt(STREAM s, MEMBLT_ORDER *os,  static void process_memblt(STREAM s, MEMBLT_ORDER *os,
339                                  uint32 present, BOOL delta)                             uint32 present, BOOL delta)
340  {  {
341          HBITMAP bitmap;          HBITMAP bitmap;
342    
# Line 378  static void process_memblt(STREAM s, MEM Line 379  static void process_memblt(STREAM s, MEM
379                  return;                  return;
380    
381          ui_memblt(ROP2_S(os->opcode), os->x, os->y, os->cx, os->cy,          ui_memblt(ROP2_S(os->opcode), os->x, os->y, os->cx, os->cy,
382                          bitmap, os->srcx, os->srcy);                    bitmap, os->srcx, os->srcy);
383  }  }
384    
385  /* Process a 3-way blt order */  /* Process a 3-way blt order */
386  static void process_triblt(STREAM s, TRIBLT_ORDER *os,  static void process_triblt(STREAM s, TRIBLT_ORDER *os,
387                                  uint32 present, BOOL delta)                             uint32 present, BOOL delta)
388  {  {
389          HBITMAP bitmap;          HBITMAP bitmap;
390    
# Line 428  static void process_triblt(STREAM s, TRI Line 429  static void process_triblt(STREAM s, TRI
429          if (present & 0x010000)          if (present & 0x010000)
430                  in_uint16_le(s, os->unknown);                  in_uint16_le(s, os->unknown);
431    
432          DEBUG("TRIBLT(op=0x%x,x=%d,y=%d,cx=%d,cy=%d,id=%d,idx=%d,bs=%d,bg=0x%x,fg=0x%x)\n",          DEBUG
433                os->opcode, os->x, os->y, os->cx, os->cy, os->cache_id,                  ("TRIBLT(op=0x%x,x=%d,y=%d,cx=%d,cy=%d,id=%d,idx=%d,bs=%d,bg=0x%x,fg=0x%x)\n",
434                os->cache_idx, os->brush.style, os->bgcolour, os->fgcolour);                   os->opcode, os->x, os->y, os->cx, os->cy, os->cache_id,
435                     os->cache_idx, os->brush.style, os->bgcolour, os->fgcolour);
436    
437          bitmap = cache_get_bitmap(os->cache_id, os->cache_idx);          bitmap = cache_get_bitmap(os->cache_id, os->cache_idx);
438          if (bitmap == NULL)          if (bitmap == NULL)
439                  return;                  return;
440    
441          ui_triblt(os->opcode, os->x, os->y, os->cx, os->cy,          ui_triblt(os->opcode, os->x, os->y, os->cx, os->cy,
442                          bitmap, os->srcx, os->srcy,                    bitmap, os->srcx, os->srcy,
443                          &os->brush, os->bgcolour, os->fgcolour);                    &os->brush, os->bgcolour, os->fgcolour);
444    }
445    
446    /* Parse a delta co-ordinate in polyline order form */
447    static int parse_delta(uint8 *buffer, int *offset)
448    {
449            int value = buffer[(*offset)++];
450            int two_byte = value & 0x80;
451    
452            if (value & 0x40)       /* sign bit */
453                    value |= ~0x3f;
454            else
455                    value &= 0x3f;
456    
457            if (two_byte)
458                    value = (value << 8) | buffer[(*offset)++];
459    
460            return value;
461    }
462    
463    /* Process a polyline order */
464    static void process_polyline(STREAM s, POLYLINE_ORDER *os,
465                                 uint32 present, BOOL delta)
466    {
467            int index, line, data;
468            int x, y, xfrom, yfrom;
469            uint8 flags = 0;
470            PEN pen;
471    
472            if (present & 0x01)
473                    rdp_in_coord(s, &os->x, delta);
474    
475            if (present & 0x02)
476                    rdp_in_coord(s, &os->y, delta);
477    
478            if (present & 0x04)
479                    in_uint8(s, os->flags);
480    
481            if (present & 0x10)
482                    rdp_in_colour(s, &os->fgcolour);
483    
484            if (present & 0x20)
485                    in_uint8(s, os->lines);
486    
487            if (present & 0x40)
488            {
489                    in_uint8(s, os->datasize);
490                    in_uint8a(s, os->data, os->datasize);
491            }
492    
493            DEBUG("POLYLINE(x=%d,y=%d,fl=0x%x,fg=0x%x,n=%d,sz=%d)\n",
494                  os->x, os->y, os->flags, os->fgcolour, os->lines, os->datasize);
495    
496            DEBUG("Data: ");
497    
498            for (index = 0; index < os->datasize; index++)
499                    DEBUG("%02x ", os->data[index]);
500    
501            DEBUG("\n");
502    
503            x = os->x;
504            y = os->y;
505            pen.style = pen.width = 0;
506            pen.colour = os->fgcolour;
507    
508            index = 0;
509            data = ((os->lines - 1) / 4) + 1;
510            for (line = 0; (line < os->lines) && (data < os->datasize); line++)
511            {
512                    xfrom = x;
513                    yfrom = y;
514    
515                    if (line % 4 == 0)
516                            flags = os->data[index++];
517    
518                    if ((flags & 0xc0) == 0)
519                            flags |= 0xc0;  /* none = both */
520    
521                    if (flags & 0x40)
522                            x += parse_delta(os->data, &data);
523    
524                    if (flags & 0x80)
525                            y += parse_delta(os->data, &data);
526    
527                    ui_line(ROP2_COPY, xfrom, yfrom, x, y, &pen);
528    
529                    flags <<= 2;
530            }
531  }  }
532    
533  /* Process a text order */  /* Process a text order */
534  static void process_text2(STREAM s, TEXT2_ORDER *os, uint32 present, BOOL delta)  static void process_text2(STREAM s, TEXT2_ORDER *os, uint32 present,
535                              BOOL delta)
536  {  {
537          DATABLOB *entry;          DATABLOB *entry;
538          int i;          int i;
# Line 501  static void process_text2(STREAM s, TEXT Line 591  static void process_text2(STREAM s, TEXT
591                  in_uint8a(s, os->text, os->length);                  in_uint8a(s, os->text, os->length);
592          }          }
593    
594          DEBUG("TEXT2(x=%d,y=%d,cl=%d,ct=%d,cr=%d,cb=%d,bl=%d,bt=%d,bb=%d,br=%d,fg=0x%x,bg=0x%x,font=%d,fl=0x%x,mix=%d,unk=0x%x,n=%d)\n",          DEBUG
595                  os->x, os->y, os->clipleft, os->cliptop, os->clipright,                  ("TEXT2(x=%d,y=%d,cl=%d,ct=%d,cr=%d,cb=%d,bl=%d,bt=%d,bb=%d,br=%d,fg=0x%x,bg=0x%x,font=%d,fl=0x%x,mix=%d,unk=0x%x,n=%d)\n",
596                  os->clipbottom, os->boxleft, os->boxtop, os->boxright,                   os->x, os->y, os->clipleft, os->cliptop, os->clipright,
597                  os->boxbottom, os->fgcolour, os->bgcolour, os->font,                   os->clipbottom, os->boxleft, os->boxtop, os->boxright,
598                  os->flags, os->mixmode, os->unknown, os->length);                   os->boxbottom, os->fgcolour, os->bgcolour, os->font,
599                     os->flags, os->mixmode, os->unknown, os->length);
600    
601          DEBUG("Text: ");          DEBUG("Text: ");
602    
# Line 515  static void process_text2(STREAM s, TEXT Line 606  static void process_text2(STREAM s, TEXT
606          DEBUG("\n");          DEBUG("\n");
607    
608          /* Process special cache strings */          /* Process special cache strings */
609          if ((os->length == 2) && (os->text[0] == 0xfe))          if ((os->length >= 2) && (os->text[0] == 0xfe))
610          {          {
611                  entry = cache_get_text(os->text[1]);                  entry = cache_get_text(os->text[1]);
612    
613                  if (entry == NULL)                  if (entry == NULL)
614                          return;                          return;
615                    
616                  memcpy(os->text, entry->data, entry->size);                  memcpy(os->text, entry->data, entry->size);
617                  os->length = entry->size;                  os->length = entry->size;
618          }          }
619          else if ((os->length >= 3) && (os->text[os->length-3] == 0xff))          else if ((os->length >= 3) && (os->text[os->length - 3] == 0xff))
620          {          {
621                  os->length -= 3;                  os->length -= 3;
622                  cache_put_text(os->text[os->length+1], os->text, os->length);                  cache_put_text(os->text[os->length + 1], os->text,
623                                   os->length);
624          }          }
625    
626          ui_draw_text(os->font, os->flags, os->mixmode,          ui_draw_text(os->font, os->flags, os->mixmode, os->x, os->y,
627                          os->x, os->y, os->boxleft, os->boxtop,                       os->clipleft, os->cliptop,
628                          os->boxright - os->boxleft,                       os->clipright - os->clipleft,
629                          os->boxbottom - os->boxtop,                       os->clipbottom - os->cliptop,
630                          os->bgcolour, os->fgcolour, os->text, os->length);                       os->boxleft, os->boxtop,
631                         os->boxright - os->boxleft,
632                         os->boxbottom - os->boxtop,
633                         os->bgcolour, os->fgcolour, os->text, os->length);
634  }  }
635    
636  /* Process a raw bitmap cache order */  /* Process a raw bitmap cache order */
# Line 547  static void process_raw_bmpcache(STREAM Line 642  static void process_raw_bmpcache(STREAM
642          uint8 *data;          uint8 *data;
643    
644          in_uint8(s, cache_id);          in_uint8(s, cache_id);
645          in_uint8s(s, 1); /* pad */          in_uint8s(s, 1);        /* pad */
646          in_uint8(s, width);          in_uint8(s, width);
647          in_uint8(s, height);          in_uint8(s, height);
648          in_uint8(s, bpp);          in_uint8(s, bpp);
# Line 571  static void process_bmpcache(STREAM s) Line 666  static void process_bmpcache(STREAM s)
666          uint8 *data, *bmpdata;          uint8 *data, *bmpdata;
667    
668          in_uint8(s, cache_id);          in_uint8(s, cache_id);
669          in_uint8s(s, 1); /* pad */          in_uint8s(s, 1);        /* pad */
670          in_uint8(s, width);          in_uint8(s, width);
671          in_uint8(s, height);          in_uint8(s, height);
672          in_uint8(s, bpp);          in_uint8(s, bpp);
673          in_uint8s(s, 2); /* bufsize */          in_uint8s(s, 2);        /* bufsize */
674          in_uint16_le(s, cache_idx);          in_uint16_le(s, cache_idx);
675          in_uint8s(s, 2); /* pad */          in_uint8s(s, 2);        /* pad */
676          in_uint16_le(s, size);          in_uint16_le(s, size);
677          in_uint8s(s, 4); /* row_size, final_size */          in_uint8s(s, 4);        /* row_size, final_size */
678          in_uint8p(s, data, size);          in_uint8p(s, data, size);
679    
680          DEBUG("BMPCACHE(cx=%d,cy=%d,id=%d,idx=%d)\n",          DEBUG("BMPCACHE(cx=%d,cy=%d,id=%d,idx=%d)\n",
# Line 616  static void process_colcache(STREAM s) Line 711  static void process_colcache(STREAM s)
711                  in_uint8(s, entry->blue);                  in_uint8(s, entry->blue);
712                  in_uint8(s, entry->green);                  in_uint8(s, entry->green);
713                  in_uint8(s, entry->red);                  in_uint8(s, entry->red);
714                  in_uint8s(s, 1); /* pad */                  in_uint8s(s, 1);        /* pad */
715          }          }
716    
717          DEBUG("COLCACHE(id=%d,n=%d)\n", cache_id, map.ncolours);          DEBUG("COLCACHE(id=%d,n=%d)\n", cache_id, map.ncolours);
# Line 632  static void process_fontcache(STREAM s) Line 727  static void process_fontcache(STREAM s)
727  {  {
728          HGLYPH bitmap;          HGLYPH bitmap;
729          uint8 font, nglyphs;          uint8 font, nglyphs;
730          uint16 character, baseline, width, height;          uint16 character, offset, baseline, width, height;
731          uint8 *data, *rev_data, in, out;          int i, datasize;
732          int i, j, datasize;          uint8 *data;
733    
734          in_uint8(s, font);          in_uint8(s, font);
735          in_uint8(s, nglyphs);          in_uint8(s, nglyphs);
# Line 644  static void process_fontcache(STREAM s) Line 739  static void process_fontcache(STREAM s)
739          for (i = 0; i < nglyphs; i++)          for (i = 0; i < nglyphs; i++)
740          {          {
741                  in_uint16_le(s, character);                  in_uint16_le(s, character);
742                  in_uint8s(s, 2); /* unknown */                  in_uint16_le(s, offset);
743                  in_uint16_le(s, baseline);                  in_uint16_le(s, baseline);
744                  in_uint16_le(s, width);                  in_uint16_le(s, width);
745                  in_uint16_le(s, height);                  in_uint16_le(s, height);
# Line 652  static void process_fontcache(STREAM s) Line 747  static void process_fontcache(STREAM s)
747                  datasize = (height * ((width + 7) / 8) + 3) & ~3;                  datasize = (height * ((width + 7) / 8) + 3) & ~3;
748                  in_uint8p(s, data, datasize);                  in_uint8p(s, data, datasize);
749    
750                  /* Need to reverse bit order */                  bitmap = ui_create_glyph(width, height, data);
751                  rev_data = xmalloc(datasize);                  cache_put_font(font, character, offset, baseline,
752                                   width, height, bitmap);
                 for (j = 0; j < datasize; j++)  
                 {  
                         in = data[j];  
                         out = 0;  
                         if (in & 1) out |= 128;  
                         if (in & 2) out |= 64;  
                         if (in & 4) out |= 32;  
                         if (in & 8) out |= 16;  
                         if (in & 16) out |= 8;  
                         if (in & 32) out |= 4;  
                         if (in & 64) out |= 2;  
                         if (in & 128) out |= 1;  
                         rev_data[j] = out;  
                 }  
   
                 bitmap = ui_create_glyph(width, height, rev_data);  
                 xfree(rev_data);  
   
                 cache_put_font(font, character, baseline, width, height, bitmap);  
753          }          }
754  }  }
755    
# Line 685  static void process_secondary_order(STRE Line 761  static void process_secondary_order(STRE
761          uint8 *next_order;          uint8 *next_order;
762    
763          in_uint16_le(s, length);          in_uint16_le(s, length);
764          in_uint8s(s, 2); /* flags */          in_uint8s(s, 2);        /* flags */
765          in_uint8(s, type);          in_uint8(s, type);
766    
767          next_order = s->p + length + 7;          next_order = s->p + length + 7;
# Line 725  void process_orders(STREAM s) Line 801  void process_orders(STREAM s)
801          int size, processed = 0;          int size, processed = 0;
802          BOOL delta;          BOOL delta;
803    
804          in_uint8s(s, 2); /* pad */          in_uint8s(s, 2);        /* pad */
805          in_uint16_le(s, num_orders);          in_uint16_le(s, num_orders);
806          in_uint8s(s, 2); /* pad */          in_uint8s(s, 2);        /* pad */
807    
808          while (processed < num_orders)          while (processed < num_orders)
809          {          {
# Line 775  void process_orders(STREAM s) Line 851  void process_orders(STREAM s)
851                                          rdp_parse_bounds(s, &os->bounds);                                          rdp_parse_bounds(s, &os->bounds);
852    
853                                  ui_set_clip(os->bounds.left,                                  ui_set_clip(os->bounds.left,
854                                          os->bounds.top,                                              os->bounds.top,
855                                          os->bounds.right - os->bounds.left + 1,                                              os->bounds.right -
856                                          os->bounds.bottom - os->bounds.top + 1);                                              os->bounds.left + 1,
857                                                os->bounds.bottom -
858                                                os->bounds.top + 1);
859                          }                          }
860    
861                          delta = order_flags & RDP_ORDER_DELTA;                          delta = order_flags & RDP_ORDER_DELTA;
# Line 801  void process_orders(STREAM s) Line 879  void process_orders(STREAM s)
879    
880                                  case RDP_ORDER_LINE:                                  case RDP_ORDER_LINE:
881                                          process_line(s, &os->line,                                          process_line(s, &os->line,
882                                                          present, delta);                                                       present, delta);
883                                          break;                                          break;
884    
885                                  case RDP_ORDER_RECT:                                  case RDP_ORDER_RECT:
# Line 824  void process_orders(STREAM s) Line 902  void process_orders(STREAM s)
902                                                         present, delta);                                                         present, delta);
903                                          break;                                          break;
904    
905                                    case RDP_ORDER_POLYLINE:
906                                            process_polyline(s, &os->polyline,
907                                                             present, delta);
908                                            break;
909    
910                                  case RDP_ORDER_TEXT2:                                  case RDP_ORDER_TEXT2:
911                                          process_text2(s, &os->text2,                                          process_text2(s, &os->text2,
912                                                        present, delta);                                                        present, delta);
# Line 842  void process_orders(STREAM s) Line 925  void process_orders(STREAM s)
925          }          }
926    
927          if (s->p != next_packet)          if (s->p != next_packet)
928                  WARN("%d bytes remaining\n", (int)(next_packet - s->p));                  WARN("%d bytes remaining\n", (int) (next_packet - s->p));
929  }  }
930    
931  /* Reset order state */  /* Reset order state */
# Line 850  void reset_order_state() Line 933  void reset_order_state()
933  {  {
934          memset(&order_state, 0, sizeof(order_state));          memset(&order_state, 0, sizeof(order_state));
935  }  }
   

Legend:
Removed from v.12  
changed lines
  Added in v.24

  ViewVC Help
Powered by ViewVC 1.1.26