2 * FreeRDP: A Remote Desktop Protocol Client
5 * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 #include <freerdp/api.h>
22 #include <freerdp/graphics.h>
23 #include <freerdp/codec/bitmap.h>
27 #ifdef WITH_DEBUG_ORDERS
29 static const char* const PRIMARY_DRAWING_ORDER_STRINGS[] =
58 #define PRIMARY_DRAWING_ORDER_COUNT (sizeof(PRIMARY_DRAWING_ORDER_STRINGS) / sizeof(PRIMARY_DRAWING_ORDER_STRINGS[0]))
60 static const char* const SECONDARY_DRAWING_ORDER_STRINGS[] =
64 "Cache Bitmap (Compressed)",
67 "Cache Bitmap V2 (Compressed)",
73 #define SECONDARY_DRAWING_ORDER_COUNT (sizeof(SECONDARY_DRAWING_ORDER_STRINGS) / sizeof(SECONDARY_DRAWING_ORDER_STRINGS[0]))
75 static const char* const ALTSEC_DRAWING_ORDER_STRINGS[] =
78 "Create Offscreen Bitmap",
79 "Stream Bitmap First",
81 "Create NineGrid Bitmap",
85 "Draw GDI+ Cache First",
86 "Draw GDI+ Cache Next",
87 "Draw GDI+ Cache End",
89 "Desktop Composition",
93 #define ALTSEC_DRAWING_ORDER_COUNT (sizeof(ALTSEC_DRAWING_ORDER_STRINGS) / sizeof(ALTSEC_DRAWING_ORDER_STRINGS[0]))
95 #endif /* WITH_DEBUG_ORDERS */
97 static const uint8 PRIMARY_DRAWING_ORDER_FIELD_BYTES[] =
99 DSTBLT_ORDER_FIELD_BYTES,
100 PATBLT_ORDER_FIELD_BYTES,
101 SCRBLT_ORDER_FIELD_BYTES,
103 DRAW_NINE_GRID_ORDER_FIELD_BYTES,
104 MULTI_DRAW_NINE_GRID_ORDER_FIELD_BYTES,
105 LINE_TO_ORDER_FIELD_BYTES,
106 OPAQUE_RECT_ORDER_FIELD_BYTES,
107 SAVE_BITMAP_ORDER_FIELD_BYTES,
109 MEMBLT_ORDER_FIELD_BYTES,
110 MEM3BLT_ORDER_FIELD_BYTES,
111 MULTI_DSTBLT_ORDER_FIELD_BYTES,
112 MULTI_PATBLT_ORDER_FIELD_BYTES,
113 MULTI_SCRBLT_ORDER_FIELD_BYTES,
114 MULTI_OPAQUE_RECT_ORDER_FIELD_BYTES,
115 FAST_INDEX_ORDER_FIELD_BYTES,
116 POLYGON_SC_ORDER_FIELD_BYTES,
117 POLYGON_CB_ORDER_FIELD_BYTES,
118 POLYLINE_ORDER_FIELD_BYTES,
120 FAST_GLYPH_ORDER_FIELD_BYTES,
121 ELLIPSE_SC_ORDER_FIELD_BYTES,
122 ELLIPSE_CB_ORDER_FIELD_BYTES,
123 GLYPH_INDEX_ORDER_FIELD_BYTES
126 static const uint8 CBR2_BPP[] =
128 0, 0, 0, 8, 16, 24, 32
131 static const uint8 CBR23_BPP[] =
133 0, 0, 0, 8, 16, 24, 32
136 static const uint8 BMF_BPP[] =
138 0, 1, 0, 8, 16, 24, 32
141 INLINE void update_read_coord(STREAM* s, sint32* coord, boolean delta)
148 stream_read_uint8(s, lsi8);
153 stream_read_uint16(s, lsi16);
158 INLINE void update_read_color(STREAM* s, uint32* color)
162 stream_read_uint8(s, byte);
164 stream_read_uint8(s, byte);
165 *color |= (byte << 8);
166 stream_read_uint8(s, byte);
167 *color |= (byte << 16);
170 INLINE void update_read_colorref(STREAM* s, uint32* color)
174 stream_read_uint8(s, byte);
176 stream_read_uint8(s, byte);
177 *color |= (byte << 8);
178 stream_read_uint8(s, byte);
179 *color |= (byte << 16);
180 stream_seek_uint8(s);
183 INLINE void update_read_color_quad(STREAM* s, uint32* color)
187 stream_read_uint8(s, byte);
188 *color = (byte << 16);
189 stream_read_uint8(s, byte);
190 *color |= (byte << 8);
191 stream_read_uint8(s, byte);
193 stream_seek_uint8(s);
196 INLINE void update_read_2byte_unsigned(STREAM* s, uint32* value)
200 stream_read_uint8(s, byte);
204 *value = (byte & 0x7F) << 8;
205 stream_read_uint8(s, byte);
210 *value = (byte & 0x7F);
214 INLINE void update_read_2byte_signed(STREAM* s, sint32* value)
219 stream_read_uint8(s, byte);
221 negative = (byte & 0x40) ? true : false;
223 *value = (byte & 0x3F);
227 stream_read_uint8(s, byte);
228 *value = (*value << 8) | byte;
235 INLINE void update_read_4byte_unsigned(STREAM* s, uint32* value)
240 stream_read_uint8(s, byte);
242 count = (byte & 0xC0) >> 6;
247 *value = (byte & 0x3F);
251 *value = (byte & 0x3F) << 8;
252 stream_read_uint8(s, byte);
257 *value = (byte & 0x3F) << 16;
258 stream_read_uint8(s, byte);
259 *value |= (byte << 8);
260 stream_read_uint8(s, byte);
265 *value = (byte & 0x3F) << 24;
266 stream_read_uint8(s, byte);
267 *value |= (byte << 16);
268 stream_read_uint8(s, byte);
269 *value |= (byte << 8);
270 stream_read_uint8(s, byte);
279 INLINE void update_read_delta(STREAM* s, sint32* value)
283 stream_read_uint8(s, byte);
286 *value = (byte | ~0x3F);
288 *value = (byte & 0x3F);
292 stream_read_uint8(s, byte);
293 *value = (*value << 8) | byte;
297 INLINE void update_read_glyph_delta(STREAM* s, uint16* value)
301 stream_read_uint8(s, byte);
304 stream_read_uint16(s, *value);
306 *value = (byte & 0x3F);
309 INLINE void update_seek_glyph_delta(STREAM* s)
313 stream_read_uint8(s, byte);
316 stream_seek_uint8(s);
319 INLINE void update_read_brush(STREAM* s, rdpBrush* brush, uint8 fieldFlags)
321 if (fieldFlags & ORDER_FIELD_01)
322 stream_read_uint8(s, brush->x);
324 if (fieldFlags & ORDER_FIELD_02)
325 stream_read_uint8(s, brush->y);
327 if (fieldFlags & ORDER_FIELD_03)
328 stream_read_uint8(s, brush->style);
330 if (fieldFlags & ORDER_FIELD_04)
331 stream_read_uint8(s, brush->hatch);
333 if (brush->style & CACHED_BRUSH)
335 brush->index = brush->hatch;
337 brush->bpp = BMF_BPP[brush->style & 0x0F];
343 if (fieldFlags & ORDER_FIELD_05)
345 brush->data = (uint8*) brush->p8x8;
346 stream_read_uint8(s, brush->data[7]);
347 stream_read_uint8(s, brush->data[6]);
348 stream_read_uint8(s, brush->data[5]);
349 stream_read_uint8(s, brush->data[4]);
350 stream_read_uint8(s, brush->data[3]);
351 stream_read_uint8(s, brush->data[2]);
352 stream_read_uint8(s, brush->data[1]);
353 brush->data[0] = brush->hatch;
357 INLINE void update_read_delta_rects(STREAM* s, DELTA_RECT* rectangles, int number)
367 zeroBitsSize = ((number + 1) / 2);
369 stream_get_mark(s, zeroBits);
370 stream_seek(s, zeroBitsSize);
372 memset(rectangles, 0, sizeof(DELTA_RECT) * (number + 1));
374 for (i = 1; i < number + 1; i++)
376 if ((i - 1) % 2 == 0)
377 flags = zeroBits[(i - 1) / 2];
380 update_read_delta(s, &rectangles[i].left);
383 update_read_delta(s, &rectangles[i].top);
386 update_read_delta(s, &rectangles[i].width);
388 rectangles[i].width = rectangles[i - 1].width;
391 update_read_delta(s, &rectangles[i].height);
393 rectangles[i].height = rectangles[i - 1].height;
395 rectangles[i].left = rectangles[i].left + rectangles[i - 1].left;
396 rectangles[i].top = rectangles[i].top + rectangles[i - 1].top;
402 INLINE void update_read_delta_points(STREAM* s, DELTA_POINT* points, int number, sint16 x, sint16 y)
409 zeroBitsSize = ((number + 3) / 4);
411 stream_get_mark(s, zeroBits);
412 stream_seek(s, zeroBitsSize);
414 memset(points, 0, sizeof(DELTA_POINT) * number);
416 for (i = 0; i < number; i++)
419 flags = zeroBits[i / 4];
422 update_read_delta(s, &points[i].x);
425 update_read_delta(s, &points[i].y);
431 /* Primary Drawing Orders */
433 void update_read_dstblt_order(STREAM* s, ORDER_INFO* orderInfo, DSTBLT_ORDER* dstblt)
435 if (orderInfo->fieldFlags & ORDER_FIELD_01)
436 update_read_coord(s, &dstblt->nLeftRect, orderInfo->deltaCoordinates);
438 if (orderInfo->fieldFlags & ORDER_FIELD_02)
439 update_read_coord(s, &dstblt->nTopRect, orderInfo->deltaCoordinates);
441 if (orderInfo->fieldFlags & ORDER_FIELD_03)
442 update_read_coord(s, &dstblt->nWidth, orderInfo->deltaCoordinates);
444 if (orderInfo->fieldFlags & ORDER_FIELD_04)
445 update_read_coord(s, &dstblt->nHeight, orderInfo->deltaCoordinates);
447 if (orderInfo->fieldFlags & ORDER_FIELD_05)
448 stream_read_uint8(s, dstblt->bRop);
451 void update_read_patblt_order(STREAM* s, ORDER_INFO* orderInfo, PATBLT_ORDER* patblt)
453 if (orderInfo->fieldFlags & ORDER_FIELD_01)
454 update_read_coord(s, &patblt->nLeftRect, orderInfo->deltaCoordinates);
456 if (orderInfo->fieldFlags & ORDER_FIELD_02)
457 update_read_coord(s, &patblt->nTopRect, orderInfo->deltaCoordinates);
459 if (orderInfo->fieldFlags & ORDER_FIELD_03)
460 update_read_coord(s, &patblt->nWidth, orderInfo->deltaCoordinates);
462 if (orderInfo->fieldFlags & ORDER_FIELD_04)
463 update_read_coord(s, &patblt->nHeight, orderInfo->deltaCoordinates);
465 if (orderInfo->fieldFlags & ORDER_FIELD_05)
466 stream_read_uint8(s, patblt->bRop);
468 if (orderInfo->fieldFlags & ORDER_FIELD_06)
469 update_read_color(s, &patblt->backColor);
471 if (orderInfo->fieldFlags & ORDER_FIELD_07)
472 update_read_color(s, &patblt->foreColor);
474 update_read_brush(s, &patblt->brush, orderInfo->fieldFlags >> 7);
477 void update_read_scrblt_order(STREAM* s, ORDER_INFO* orderInfo, SCRBLT_ORDER* scrblt)
479 if (orderInfo->fieldFlags & ORDER_FIELD_01)
480 update_read_coord(s, &scrblt->nLeftRect, orderInfo->deltaCoordinates);
482 if (orderInfo->fieldFlags & ORDER_FIELD_02)
483 update_read_coord(s, &scrblt->nTopRect, orderInfo->deltaCoordinates);
485 if (orderInfo->fieldFlags & ORDER_FIELD_03)
486 update_read_coord(s, &scrblt->nWidth, orderInfo->deltaCoordinates);
488 if (orderInfo->fieldFlags & ORDER_FIELD_04)
489 update_read_coord(s, &scrblt->nHeight, orderInfo->deltaCoordinates);
491 if (orderInfo->fieldFlags & ORDER_FIELD_05)
492 stream_read_uint8(s, scrblt->bRop);
494 if (orderInfo->fieldFlags & ORDER_FIELD_06)
495 update_read_coord(s, &scrblt->nXSrc, orderInfo->deltaCoordinates);
497 if (orderInfo->fieldFlags & ORDER_FIELD_07)
498 update_read_coord(s, &scrblt->nYSrc, orderInfo->deltaCoordinates);
501 void update_read_opaque_rect_order(STREAM* s, ORDER_INFO* orderInfo, OPAQUE_RECT_ORDER* opaque_rect)
505 if (orderInfo->fieldFlags & ORDER_FIELD_01)
506 update_read_coord(s, &opaque_rect->nLeftRect, orderInfo->deltaCoordinates);
508 if (orderInfo->fieldFlags & ORDER_FIELD_02)
509 update_read_coord(s, &opaque_rect->nTopRect, orderInfo->deltaCoordinates);
511 if (orderInfo->fieldFlags & ORDER_FIELD_03)
512 update_read_coord(s, &opaque_rect->nWidth, orderInfo->deltaCoordinates);
514 if (orderInfo->fieldFlags & ORDER_FIELD_04)
515 update_read_coord(s, &opaque_rect->nHeight, orderInfo->deltaCoordinates);
517 if (orderInfo->fieldFlags & ORDER_FIELD_05)
519 stream_read_uint8(s, byte);
520 opaque_rect->color = (opaque_rect->color & 0xFFFFFF00) | byte;
523 if (orderInfo->fieldFlags & ORDER_FIELD_06)
525 stream_read_uint8(s, byte);
526 opaque_rect->color = (opaque_rect->color & 0xFFFF00FF) | (byte << 8);
529 if (orderInfo->fieldFlags & ORDER_FIELD_07)
531 stream_read_uint8(s, byte);
532 opaque_rect->color = (opaque_rect->color & 0xFF00FFFF) | (byte << 16);
536 void update_read_draw_nine_grid_order(STREAM* s, ORDER_INFO* orderInfo, DRAW_NINE_GRID_ORDER* draw_nine_grid)
538 if (orderInfo->fieldFlags & ORDER_FIELD_01)
539 update_read_coord(s, &draw_nine_grid->srcLeft, orderInfo->deltaCoordinates);
541 if (orderInfo->fieldFlags & ORDER_FIELD_02)
542 update_read_coord(s, &draw_nine_grid->srcTop, orderInfo->deltaCoordinates);
544 if (orderInfo->fieldFlags & ORDER_FIELD_03)
545 update_read_coord(s, &draw_nine_grid->srcRight, orderInfo->deltaCoordinates);
547 if (orderInfo->fieldFlags & ORDER_FIELD_04)
548 update_read_coord(s, &draw_nine_grid->srcBottom, orderInfo->deltaCoordinates);
550 if (orderInfo->fieldFlags & ORDER_FIELD_05)
551 stream_read_uint16(s, draw_nine_grid->bitmapId);
554 void update_read_multi_dstblt_order(STREAM* s, ORDER_INFO* orderInfo, MULTI_DSTBLT_ORDER* multi_dstblt)
556 if (orderInfo->fieldFlags & ORDER_FIELD_01)
557 update_read_coord(s, &multi_dstblt->nLeftRect, orderInfo->deltaCoordinates);
559 if (orderInfo->fieldFlags & ORDER_FIELD_02)
560 update_read_coord(s, &multi_dstblt->nTopRect, orderInfo->deltaCoordinates);
562 if (orderInfo->fieldFlags & ORDER_FIELD_03)
563 update_read_coord(s, &multi_dstblt->nWidth, orderInfo->deltaCoordinates);
565 if (orderInfo->fieldFlags & ORDER_FIELD_04)
566 update_read_coord(s, &multi_dstblt->nHeight, orderInfo->deltaCoordinates);
568 if (orderInfo->fieldFlags & ORDER_FIELD_05)
569 stream_read_uint8(s, multi_dstblt->bRop);
571 if (orderInfo->fieldFlags & ORDER_FIELD_06)
572 stream_read_uint8(s, multi_dstblt->numRectangles);
574 if (orderInfo->fieldFlags & ORDER_FIELD_07)
576 stream_read_uint16(s, multi_dstblt->cbData);
577 update_read_delta_rects(s, multi_dstblt->rectangles, multi_dstblt->numRectangles);
581 void update_read_multi_patblt_order(STREAM* s, ORDER_INFO* orderInfo, MULTI_PATBLT_ORDER* multi_patblt)
583 if (orderInfo->fieldFlags & ORDER_FIELD_01)
584 update_read_coord(s, &multi_patblt->nLeftRect, orderInfo->deltaCoordinates);
586 if (orderInfo->fieldFlags & ORDER_FIELD_02)
587 update_read_coord(s, &multi_patblt->nTopRect, orderInfo->deltaCoordinates);
589 if (orderInfo->fieldFlags & ORDER_FIELD_03)
590 update_read_coord(s, &multi_patblt->nWidth, orderInfo->deltaCoordinates);
592 if (orderInfo->fieldFlags & ORDER_FIELD_04)
593 update_read_coord(s, &multi_patblt->nHeight, orderInfo->deltaCoordinates);
595 if (orderInfo->fieldFlags & ORDER_FIELD_05)
596 stream_read_uint8(s, multi_patblt->bRop);
598 if (orderInfo->fieldFlags & ORDER_FIELD_06)
599 update_read_color(s, &multi_patblt->backColor);
601 if (orderInfo->fieldFlags & ORDER_FIELD_07)
602 update_read_color(s, &multi_patblt->foreColor);
604 update_read_brush(s, &multi_patblt->brush, orderInfo->fieldFlags >> 7);
606 if (orderInfo->fieldFlags & ORDER_FIELD_13)
607 stream_read_uint8(s, multi_patblt->numRectangles);
609 if (orderInfo->fieldFlags & ORDER_FIELD_14)
611 stream_read_uint16(s, multi_patblt->cbData);
612 update_read_delta_rects(s, multi_patblt->rectangles, multi_patblt->numRectangles);
616 void update_read_multi_scrblt_order(STREAM* s, ORDER_INFO* orderInfo, MULTI_SCRBLT_ORDER* multi_scrblt)
618 if (orderInfo->fieldFlags & ORDER_FIELD_01)
619 update_read_coord(s, &multi_scrblt->nLeftRect, orderInfo->deltaCoordinates);
621 if (orderInfo->fieldFlags & ORDER_FIELD_02)
622 update_read_coord(s, &multi_scrblt->nTopRect, orderInfo->deltaCoordinates);
624 if (orderInfo->fieldFlags & ORDER_FIELD_03)
625 update_read_coord(s, &multi_scrblt->nWidth, orderInfo->deltaCoordinates);
627 if (orderInfo->fieldFlags & ORDER_FIELD_04)
628 update_read_coord(s, &multi_scrblt->nHeight, orderInfo->deltaCoordinates);
630 if (orderInfo->fieldFlags & ORDER_FIELD_05)
631 stream_read_uint8(s, multi_scrblt->bRop);
633 if (orderInfo->fieldFlags & ORDER_FIELD_06)
634 update_read_coord(s, &multi_scrblt->nXSrc, orderInfo->deltaCoordinates);
636 if (orderInfo->fieldFlags & ORDER_FIELD_07)
637 update_read_coord(s, &multi_scrblt->nYSrc, orderInfo->deltaCoordinates);
639 if (orderInfo->fieldFlags & ORDER_FIELD_08)
640 stream_read_uint8(s, multi_scrblt->numRectangles);
642 if (orderInfo->fieldFlags & ORDER_FIELD_09)
644 stream_read_uint16(s, multi_scrblt->cbData);
645 update_read_delta_rects(s, multi_scrblt->rectangles, multi_scrblt->numRectangles);
649 void update_read_multi_opaque_rect_order(STREAM* s, ORDER_INFO* orderInfo, MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect)
653 if (orderInfo->fieldFlags & ORDER_FIELD_01)
654 update_read_coord(s, &multi_opaque_rect->nLeftRect, orderInfo->deltaCoordinates);
656 if (orderInfo->fieldFlags & ORDER_FIELD_02)
657 update_read_coord(s, &multi_opaque_rect->nTopRect, orderInfo->deltaCoordinates);
659 if (orderInfo->fieldFlags & ORDER_FIELD_03)
660 update_read_coord(s, &multi_opaque_rect->nWidth, orderInfo->deltaCoordinates);
662 if (orderInfo->fieldFlags & ORDER_FIELD_04)
663 update_read_coord(s, &multi_opaque_rect->nHeight, orderInfo->deltaCoordinates);
665 if (orderInfo->fieldFlags & ORDER_FIELD_05)
667 stream_read_uint8(s, byte);
668 multi_opaque_rect->color = (multi_opaque_rect->color & 0xFFFFFF00) | byte;
671 if (orderInfo->fieldFlags & ORDER_FIELD_06)
673 stream_read_uint8(s, byte);
674 multi_opaque_rect->color = (multi_opaque_rect->color & 0xFFFF00FF) | (byte << 8);
677 if (orderInfo->fieldFlags & ORDER_FIELD_07)
679 stream_read_uint8(s, byte);
680 multi_opaque_rect->color = (multi_opaque_rect->color & 0xFF00FFFF) | (byte << 16);
683 if (orderInfo->fieldFlags & ORDER_FIELD_08)
684 stream_read_uint8(s, multi_opaque_rect->numRectangles);
686 if (orderInfo->fieldFlags & ORDER_FIELD_09)
688 stream_read_uint16(s, multi_opaque_rect->cbData);
689 update_read_delta_rects(s, multi_opaque_rect->rectangles, multi_opaque_rect->numRectangles);
693 void update_read_multi_draw_nine_grid_order(STREAM* s, ORDER_INFO* orderInfo, MULTI_DRAW_NINE_GRID_ORDER* multi_draw_nine_grid)
695 if (orderInfo->fieldFlags & ORDER_FIELD_01)
696 update_read_coord(s, &multi_draw_nine_grid->srcLeft, orderInfo->deltaCoordinates);
698 if (orderInfo->fieldFlags & ORDER_FIELD_02)
699 update_read_coord(s, &multi_draw_nine_grid->srcTop, orderInfo->deltaCoordinates);
701 if (orderInfo->fieldFlags & ORDER_FIELD_03)
702 update_read_coord(s, &multi_draw_nine_grid->srcRight, orderInfo->deltaCoordinates);
704 if (orderInfo->fieldFlags & ORDER_FIELD_04)
705 update_read_coord(s, &multi_draw_nine_grid->srcBottom, orderInfo->deltaCoordinates);
707 if (orderInfo->fieldFlags & ORDER_FIELD_05)
708 stream_read_uint16(s, multi_draw_nine_grid->bitmapId);
710 if (orderInfo->fieldFlags & ORDER_FIELD_06)
711 stream_read_uint8(s, multi_draw_nine_grid->nDeltaEntries);
713 if (orderInfo->fieldFlags & ORDER_FIELD_07)
715 stream_read_uint16(s, multi_draw_nine_grid->cbData);
716 stream_seek(s, multi_draw_nine_grid->cbData);
720 void update_read_line_to_order(STREAM* s, ORDER_INFO* orderInfo, LINE_TO_ORDER* line_to)
722 if (orderInfo->fieldFlags & ORDER_FIELD_01)
723 stream_read_uint16(s, line_to->backMode);
725 if (orderInfo->fieldFlags & ORDER_FIELD_02)
726 update_read_coord(s, &line_to->nXStart, orderInfo->deltaCoordinates);
728 if (orderInfo->fieldFlags & ORDER_FIELD_03)
729 update_read_coord(s, &line_to->nYStart, orderInfo->deltaCoordinates);
731 if (orderInfo->fieldFlags & ORDER_FIELD_04)
732 update_read_coord(s, &line_to->nXEnd, orderInfo->deltaCoordinates);
734 if (orderInfo->fieldFlags & ORDER_FIELD_05)
735 update_read_coord(s, &line_to->nYEnd, orderInfo->deltaCoordinates);
737 if (orderInfo->fieldFlags & ORDER_FIELD_06)
738 update_read_color(s, &line_to->backColor);
740 if (orderInfo->fieldFlags & ORDER_FIELD_07)
741 stream_read_uint8(s, line_to->bRop2);
743 if (orderInfo->fieldFlags & ORDER_FIELD_08)
744 stream_read_uint8(s, line_to->penStyle);
746 if (orderInfo->fieldFlags & ORDER_FIELD_09)
747 stream_read_uint8(s, line_to->penWidth);
749 if (orderInfo->fieldFlags & ORDER_FIELD_10)
750 update_read_color(s, &line_to->penColor);
753 void update_read_polyline_order(STREAM* s, ORDER_INFO* orderInfo, POLYLINE_ORDER* polyline)
755 if (orderInfo->fieldFlags & ORDER_FIELD_01)
756 update_read_coord(s, &polyline->xStart, orderInfo->deltaCoordinates);
758 if (orderInfo->fieldFlags & ORDER_FIELD_02)
759 update_read_coord(s, &polyline->yStart, orderInfo->deltaCoordinates);
761 if (orderInfo->fieldFlags & ORDER_FIELD_03)
762 stream_read_uint8(s, polyline->bRop2);
764 if (orderInfo->fieldFlags & ORDER_FIELD_04)
765 stream_seek_uint16(s);
767 if (orderInfo->fieldFlags & ORDER_FIELD_05)
768 update_read_color(s, &polyline->penColor);
770 if (orderInfo->fieldFlags & ORDER_FIELD_06)
771 stream_read_uint8(s, polyline->numPoints);
773 if (orderInfo->fieldFlags & ORDER_FIELD_07)
775 stream_read_uint8(s, polyline->cbData);
777 if (polyline->points == NULL)
778 polyline->points = (DELTA_POINT*) xmalloc(sizeof(DELTA_POINT) * polyline->numPoints);
780 polyline->points = (DELTA_POINT*) xrealloc(polyline->points, sizeof(DELTA_POINT) * polyline->numPoints);
782 update_read_delta_points(s, polyline->points, polyline->numPoints, polyline->xStart, polyline->yStart);
786 void update_read_memblt_order(STREAM* s, ORDER_INFO* orderInfo, MEMBLT_ORDER* memblt)
788 if (orderInfo->fieldFlags & ORDER_FIELD_01)
789 stream_read_uint16(s, memblt->cacheId);
791 if (orderInfo->fieldFlags & ORDER_FIELD_02)
792 update_read_coord(s, &memblt->nLeftRect, orderInfo->deltaCoordinates);
794 if (orderInfo->fieldFlags & ORDER_FIELD_03)
795 update_read_coord(s, &memblt->nTopRect, orderInfo->deltaCoordinates);
797 if (orderInfo->fieldFlags & ORDER_FIELD_04)
798 update_read_coord(s, &memblt->nWidth, orderInfo->deltaCoordinates);
800 if (orderInfo->fieldFlags & ORDER_FIELD_05)
801 update_read_coord(s, &memblt->nHeight, orderInfo->deltaCoordinates);
803 if (orderInfo->fieldFlags & ORDER_FIELD_06)
804 stream_read_uint8(s, memblt->bRop);
806 if (orderInfo->fieldFlags & ORDER_FIELD_07)
807 update_read_coord(s, &memblt->nXSrc, orderInfo->deltaCoordinates);
809 if (orderInfo->fieldFlags & ORDER_FIELD_08)
810 update_read_coord(s, &memblt->nYSrc, orderInfo->deltaCoordinates);
812 if (orderInfo->fieldFlags & ORDER_FIELD_09)
813 stream_read_uint16(s, memblt->cacheIndex);
815 memblt->colorIndex = (memblt->cacheId >> 8);
816 memblt->cacheId = (memblt->cacheId & 0xFF);
819 void update_read_mem3blt_order(STREAM* s, ORDER_INFO* orderInfo, MEM3BLT_ORDER* mem3blt)
821 if (orderInfo->fieldFlags & ORDER_FIELD_01)
822 stream_read_uint16(s, mem3blt->cacheId);
824 if (orderInfo->fieldFlags & ORDER_FIELD_02)
825 update_read_coord(s, &mem3blt->nLeftRect, orderInfo->deltaCoordinates);
827 if (orderInfo->fieldFlags & ORDER_FIELD_03)
828 update_read_coord(s, &mem3blt->nTopRect, orderInfo->deltaCoordinates);
830 if (orderInfo->fieldFlags & ORDER_FIELD_04)
831 update_read_coord(s, &mem3blt->nWidth, orderInfo->deltaCoordinates);
833 if (orderInfo->fieldFlags & ORDER_FIELD_05)
834 update_read_coord(s, &mem3blt->nHeight, orderInfo->deltaCoordinates);
836 if (orderInfo->fieldFlags & ORDER_FIELD_06)
837 stream_read_uint8(s, mem3blt->bRop);
839 if (orderInfo->fieldFlags & ORDER_FIELD_07)
840 update_read_coord(s, &mem3blt->nXSrc, orderInfo->deltaCoordinates);
842 if (orderInfo->fieldFlags & ORDER_FIELD_08)
843 update_read_coord(s, &mem3blt->nYSrc, orderInfo->deltaCoordinates);
845 if (orderInfo->fieldFlags & ORDER_FIELD_09)
846 update_read_color(s, &mem3blt->backColor);
848 if (orderInfo->fieldFlags & ORDER_FIELD_10)
849 update_read_color(s, &mem3blt->foreColor);
851 update_read_brush(s, &mem3blt->brush, orderInfo->fieldFlags >> 10);
853 if (orderInfo->fieldFlags & ORDER_FIELD_16)
854 stream_read_uint16(s, mem3blt->cacheIndex);
856 mem3blt->colorIndex = (mem3blt->cacheId >> 8);
857 mem3blt->cacheId = (mem3blt->cacheId & 0xFF);
860 void update_read_save_bitmap_order(STREAM* s, ORDER_INFO* orderInfo, SAVE_BITMAP_ORDER* save_bitmap)
862 if (orderInfo->fieldFlags & ORDER_FIELD_01)
863 stream_read_uint32(s, save_bitmap->savedBitmapPosition);
865 if (orderInfo->fieldFlags & ORDER_FIELD_02)
866 update_read_coord(s, &save_bitmap->nLeftRect, orderInfo->deltaCoordinates);
868 if (orderInfo->fieldFlags & ORDER_FIELD_03)
869 update_read_coord(s, &save_bitmap->nTopRect, orderInfo->deltaCoordinates);
871 if (orderInfo->fieldFlags & ORDER_FIELD_04)
872 update_read_coord(s, &save_bitmap->nRightRect, orderInfo->deltaCoordinates);
874 if (orderInfo->fieldFlags & ORDER_FIELD_05)
875 update_read_coord(s, &save_bitmap->nBottomRect, orderInfo->deltaCoordinates);
877 if (orderInfo->fieldFlags & ORDER_FIELD_06)
878 stream_read_uint8(s, save_bitmap->operation);
881 void update_read_glyph_index_order(STREAM* s, ORDER_INFO* orderInfo, GLYPH_INDEX_ORDER* glyph_index)
883 if (orderInfo->fieldFlags & ORDER_FIELD_01)
884 stream_read_uint8(s, glyph_index->cacheId);
886 if (orderInfo->fieldFlags & ORDER_FIELD_02)
887 stream_read_uint8(s, glyph_index->flAccel);
889 if (orderInfo->fieldFlags & ORDER_FIELD_03)
890 stream_read_uint8(s, glyph_index->ulCharInc);
892 if (orderInfo->fieldFlags & ORDER_FIELD_04)
893 stream_read_uint8(s, glyph_index->fOpRedundant);
895 if (orderInfo->fieldFlags & ORDER_FIELD_05)
896 update_read_color(s, &glyph_index->backColor);
898 if (orderInfo->fieldFlags & ORDER_FIELD_06)
899 update_read_color(s, &glyph_index->foreColor);
901 if (orderInfo->fieldFlags & ORDER_FIELD_07)
902 stream_read_uint16(s, glyph_index->bkLeft);
904 if (orderInfo->fieldFlags & ORDER_FIELD_08)
905 stream_read_uint16(s, glyph_index->bkTop);
907 if (orderInfo->fieldFlags & ORDER_FIELD_09)
908 stream_read_uint16(s, glyph_index->bkRight);
910 if (orderInfo->fieldFlags & ORDER_FIELD_10)
911 stream_read_uint16(s, glyph_index->bkBottom);
913 if (orderInfo->fieldFlags & ORDER_FIELD_11)
914 stream_read_uint16(s, glyph_index->opLeft);
916 if (orderInfo->fieldFlags & ORDER_FIELD_12)
917 stream_read_uint16(s, glyph_index->opTop);
919 if (orderInfo->fieldFlags & ORDER_FIELD_13)
920 stream_read_uint16(s, glyph_index->opRight);
922 if (orderInfo->fieldFlags & ORDER_FIELD_14)
923 stream_read_uint16(s, glyph_index->opBottom);
925 update_read_brush(s, &glyph_index->brush, orderInfo->fieldFlags >> 14);
927 if (orderInfo->fieldFlags & ORDER_FIELD_20)
928 stream_read_uint16(s, glyph_index->x);
930 if (orderInfo->fieldFlags & ORDER_FIELD_21)
931 stream_read_uint16(s, glyph_index->y);
933 if (orderInfo->fieldFlags & ORDER_FIELD_22)
935 stream_read_uint8(s, glyph_index->cbData);
936 memcpy(glyph_index->data, s->p, glyph_index->cbData);
937 stream_seek(s, glyph_index->cbData);
941 void update_read_fast_index_order(STREAM* s, ORDER_INFO* orderInfo, FAST_INDEX_ORDER* fast_index)
943 if (orderInfo->fieldFlags & ORDER_FIELD_01)
944 stream_read_uint8(s, fast_index->cacheId);
946 if (orderInfo->fieldFlags & ORDER_FIELD_02)
948 stream_read_uint8(s, fast_index->ulCharInc);
949 stream_read_uint8(s, fast_index->flAccel);
952 if (orderInfo->fieldFlags & ORDER_FIELD_03)
953 update_read_color(s, &fast_index->backColor);
955 if (orderInfo->fieldFlags & ORDER_FIELD_04)
956 update_read_color(s, &fast_index->foreColor);
958 if (orderInfo->fieldFlags & ORDER_FIELD_05)
959 update_read_coord(s, &fast_index->bkLeft, orderInfo->deltaCoordinates);
961 if (orderInfo->fieldFlags & ORDER_FIELD_06)
962 update_read_coord(s, &fast_index->bkTop, orderInfo->deltaCoordinates);
964 if (orderInfo->fieldFlags & ORDER_FIELD_07)
965 update_read_coord(s, &fast_index->bkRight, orderInfo->deltaCoordinates);
967 if (orderInfo->fieldFlags & ORDER_FIELD_08)
968 update_read_coord(s, &fast_index->bkBottom, orderInfo->deltaCoordinates);
970 if (orderInfo->fieldFlags & ORDER_FIELD_09)
971 update_read_coord(s, &fast_index->opLeft, orderInfo->deltaCoordinates);
973 if (orderInfo->fieldFlags & ORDER_FIELD_10)
974 update_read_coord(s, &fast_index->opTop, orderInfo->deltaCoordinates);
976 if (orderInfo->fieldFlags & ORDER_FIELD_11)
977 update_read_coord(s, &fast_index->opRight, orderInfo->deltaCoordinates);
979 if (orderInfo->fieldFlags & ORDER_FIELD_12)
980 update_read_coord(s, &fast_index->opBottom, orderInfo->deltaCoordinates);
982 if (orderInfo->fieldFlags & ORDER_FIELD_13)
983 update_read_coord(s, &fast_index->x, orderInfo->deltaCoordinates);
985 if (orderInfo->fieldFlags & ORDER_FIELD_14)
986 update_read_coord(s, &fast_index->y, orderInfo->deltaCoordinates);
988 if (orderInfo->fieldFlags & ORDER_FIELD_15)
990 stream_read_uint8(s, fast_index->cbData);
991 memcpy(fast_index->data, s->p, fast_index->cbData);
992 stream_seek(s, fast_index->cbData);
996 void update_read_fast_glyph_order(STREAM* s, ORDER_INFO* orderInfo, FAST_GLYPH_ORDER* fast_glyph)
998 GLYPH_DATA_V2* glyph;
1001 if (orderInfo->fieldFlags & ORDER_FIELD_01)
1002 stream_read_uint8(s, fast_glyph->cacheId);
1004 if (orderInfo->fieldFlags & ORDER_FIELD_02)
1006 stream_read_uint8(s, fast_glyph->ulCharInc);
1007 stream_read_uint8(s, fast_glyph->flAccel);
1010 if (orderInfo->fieldFlags & ORDER_FIELD_03)
1011 update_read_color(s, &fast_glyph->backColor);
1013 if (orderInfo->fieldFlags & ORDER_FIELD_04)
1014 update_read_color(s, &fast_glyph->foreColor);
1016 if (orderInfo->fieldFlags & ORDER_FIELD_05)
1017 update_read_coord(s, &fast_glyph->bkLeft, orderInfo->deltaCoordinates);
1019 if (orderInfo->fieldFlags & ORDER_FIELD_06)
1020 update_read_coord(s, &fast_glyph->bkTop, orderInfo->deltaCoordinates);
1022 if (orderInfo->fieldFlags & ORDER_FIELD_07)
1023 update_read_coord(s, &fast_glyph->bkRight, orderInfo->deltaCoordinates);
1025 if (orderInfo->fieldFlags & ORDER_FIELD_08)
1026 update_read_coord(s, &fast_glyph->bkBottom, orderInfo->deltaCoordinates);
1028 if (orderInfo->fieldFlags & ORDER_FIELD_09)
1029 update_read_coord(s, &fast_glyph->opLeft, orderInfo->deltaCoordinates);
1031 if (orderInfo->fieldFlags & ORDER_FIELD_10)
1032 update_read_coord(s, &fast_glyph->opTop, orderInfo->deltaCoordinates);
1034 if (orderInfo->fieldFlags & ORDER_FIELD_11)
1035 update_read_coord(s, &fast_glyph->opRight, orderInfo->deltaCoordinates);
1037 if (orderInfo->fieldFlags & ORDER_FIELD_12)
1038 update_read_coord(s, &fast_glyph->opBottom, orderInfo->deltaCoordinates);
1040 if (orderInfo->fieldFlags & ORDER_FIELD_13)
1041 update_read_coord(s, &fast_glyph->x, orderInfo->deltaCoordinates);
1043 if (orderInfo->fieldFlags & ORDER_FIELD_14)
1044 update_read_coord(s, &fast_glyph->y, orderInfo->deltaCoordinates);
1046 if (orderInfo->fieldFlags & ORDER_FIELD_15)
1048 stream_read_uint8(s, fast_glyph->cbData);
1049 memcpy(fast_glyph->data, s->p, fast_glyph->cbData);
1052 if ((fast_glyph->cbData > 1) && (fast_glyph->glyph_data == NULL))
1054 /* parse optional glyph data */
1055 glyph = (GLYPH_DATA_V2*) xmalloc(sizeof(GLYPH_DATA_V2));
1056 glyph->cacheIndex = fast_glyph->data[0];
1057 update_read_2byte_signed(s, &glyph->x);
1058 update_read_2byte_signed(s, &glyph->y);
1059 update_read_2byte_unsigned(s, &glyph->cx);
1060 update_read_2byte_unsigned(s, &glyph->cy);
1061 glyph->cb = ((glyph->cx + 7) / 8) * glyph->cy;
1062 glyph->cb += ((glyph->cb % 4) > 0) ? 4 - (glyph->cb % 4) : 0;
1063 glyph->aj = (uint8*) xmalloc(glyph->cb);
1064 stream_read(s, glyph->aj, glyph->cb);
1065 fast_glyph->glyph_data = glyph;
1067 s->p = phold + fast_glyph->cbData;
1071 void update_read_polygon_sc_order(STREAM* s, ORDER_INFO* orderInfo, POLYGON_SC_ORDER* polygon_sc)
1073 if (orderInfo->fieldFlags & ORDER_FIELD_01)
1074 update_read_coord(s, &polygon_sc->xStart, orderInfo->deltaCoordinates);
1076 if (orderInfo->fieldFlags & ORDER_FIELD_02)
1077 update_read_coord(s, &polygon_sc->yStart, orderInfo->deltaCoordinates);
1079 if (orderInfo->fieldFlags & ORDER_FIELD_03)
1080 stream_read_uint8(s, polygon_sc->bRop2);
1082 if (orderInfo->fieldFlags & ORDER_FIELD_04)
1083 stream_read_uint8(s, polygon_sc->fillMode);
1085 if (orderInfo->fieldFlags & ORDER_FIELD_05)
1086 update_read_color(s, &polygon_sc->brushColor);
1088 if (orderInfo->fieldFlags & ORDER_FIELD_06)
1089 stream_read_uint8(s, polygon_sc->nDeltaEntries);
1091 if (orderInfo->fieldFlags & ORDER_FIELD_07)
1093 stream_read_uint8(s, polygon_sc->cbData);
1094 stream_seek(s, polygon_sc->cbData);
1098 void update_read_polygon_cb_order(STREAM* s, ORDER_INFO* orderInfo, POLYGON_CB_ORDER* polygon_cb)
1100 if (orderInfo->fieldFlags & ORDER_FIELD_01)
1101 update_read_coord(s, &polygon_cb->xStart, orderInfo->deltaCoordinates);
1103 if (orderInfo->fieldFlags & ORDER_FIELD_02)
1104 update_read_coord(s, &polygon_cb->yStart, orderInfo->deltaCoordinates);
1106 if (orderInfo->fieldFlags & ORDER_FIELD_03)
1107 stream_read_uint8(s, polygon_cb->bRop2);
1109 if (orderInfo->fieldFlags & ORDER_FIELD_04)
1110 stream_read_uint8(s, polygon_cb->fillMode);
1112 if (orderInfo->fieldFlags & ORDER_FIELD_05)
1113 update_read_color(s, &polygon_cb->backColor);
1115 if (orderInfo->fieldFlags & ORDER_FIELD_06)
1116 update_read_color(s, &polygon_cb->foreColor);
1118 update_read_brush(s, &polygon_cb->brush, orderInfo->fieldFlags >> 6);
1120 if (orderInfo->fieldFlags & ORDER_FIELD_12)
1121 stream_read_uint8(s, polygon_cb->nDeltaEntries);
1123 if (orderInfo->fieldFlags & ORDER_FIELD_13)
1125 stream_read_uint8(s, polygon_cb->cbData);
1126 stream_seek(s, polygon_cb->cbData);
1130 void update_read_ellipse_sc_order(STREAM* s, ORDER_INFO* orderInfo, ELLIPSE_SC_ORDER* ellipse_sc)
1132 if (orderInfo->fieldFlags & ORDER_FIELD_01)
1133 update_read_coord(s, &ellipse_sc->leftRect, orderInfo->deltaCoordinates);
1135 if (orderInfo->fieldFlags & ORDER_FIELD_02)
1136 update_read_coord(s, &ellipse_sc->topRect, orderInfo->deltaCoordinates);
1138 if (orderInfo->fieldFlags & ORDER_FIELD_03)
1139 update_read_coord(s, &ellipse_sc->rightRect, orderInfo->deltaCoordinates);
1141 if (orderInfo->fieldFlags & ORDER_FIELD_04)
1142 update_read_coord(s, &ellipse_sc->bottomRect, orderInfo->deltaCoordinates);
1144 if (orderInfo->fieldFlags & ORDER_FIELD_05)
1145 stream_read_uint8(s, ellipse_sc->bRop2);
1147 if (orderInfo->fieldFlags & ORDER_FIELD_06)
1148 stream_read_uint8(s, ellipse_sc->fillMode);
1150 if (orderInfo->fieldFlags & ORDER_FIELD_07)
1151 update_read_color(s, &ellipse_sc->color);
1154 void update_read_ellipse_cb_order(STREAM* s, ORDER_INFO* orderInfo, ELLIPSE_CB_ORDER* ellipse_cb)
1156 if (orderInfo->fieldFlags & ORDER_FIELD_01)
1157 update_read_coord(s, &ellipse_cb->leftRect, orderInfo->deltaCoordinates);
1159 if (orderInfo->fieldFlags & ORDER_FIELD_02)
1160 update_read_coord(s, &ellipse_cb->topRect, orderInfo->deltaCoordinates);
1162 if (orderInfo->fieldFlags & ORDER_FIELD_03)
1163 update_read_coord(s, &ellipse_cb->rightRect, orderInfo->deltaCoordinates);
1165 if (orderInfo->fieldFlags & ORDER_FIELD_04)
1166 update_read_coord(s, &ellipse_cb->bottomRect, orderInfo->deltaCoordinates);
1168 if (orderInfo->fieldFlags & ORDER_FIELD_05)
1169 stream_read_uint8(s, ellipse_cb->bRop2);
1171 if (orderInfo->fieldFlags & ORDER_FIELD_06)
1172 stream_read_uint8(s, ellipse_cb->fillMode);
1174 if (orderInfo->fieldFlags & ORDER_FIELD_07)
1175 update_read_color(s, &ellipse_cb->backColor);
1177 if (orderInfo->fieldFlags & ORDER_FIELD_08)
1178 update_read_color(s, &ellipse_cb->foreColor);
1180 update_read_brush(s, &ellipse_cb->brush, orderInfo->fieldFlags >> 8);
1183 /* Secondary Drawing Orders */
1185 void update_read_cache_bitmap_order(STREAM* s, CACHE_BITMAP_ORDER* cache_bitmap_order, boolean compressed, uint16 flags)
1187 stream_read_uint8(s, cache_bitmap_order->cacheId); /* cacheId (1 byte) */
1188 stream_seek_uint8(s); /* pad1Octet (1 byte) */
1189 stream_read_uint8(s, cache_bitmap_order->bitmapWidth); /* bitmapWidth (1 byte) */
1190 stream_read_uint8(s, cache_bitmap_order->bitmapHeight); /* bitmapHeight (1 byte) */
1191 stream_read_uint8(s, cache_bitmap_order->bitmapBpp); /* bitmapBpp (1 byte) */
1192 stream_read_uint16(s, cache_bitmap_order->bitmapLength); /* bitmapLength (2 bytes) */
1193 stream_read_uint16(s, cache_bitmap_order->cacheIndex); /* cacheIndex (2 bytes) */
1197 if ((flags & NO_BITMAP_COMPRESSION_HDR) == 0)
1199 uint8* bitmapComprHdr = (uint8*) &(cache_bitmap_order->bitmapComprHdr);
1200 stream_read(s, bitmapComprHdr, 8); /* bitmapComprHdr (8 bytes) */
1201 cache_bitmap_order->bitmapLength -= 8;
1203 stream_get_mark(s, cache_bitmap_order->bitmapDataStream);
1204 stream_seek(s, cache_bitmap_order->bitmapLength);
1208 stream_get_mark(s, cache_bitmap_order->bitmapDataStream);
1209 stream_seek(s, cache_bitmap_order->bitmapLength); /* bitmapDataStream */
1211 cache_bitmap_order->compressed = compressed;
1214 void update_read_cache_bitmap_v2_order(STREAM* s, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2_order, boolean compressed, uint16 flags)
1216 uint8 bitsPerPixelId;
1218 cache_bitmap_v2_order->cacheId = flags & 0x0003;
1219 cache_bitmap_v2_order->flags = (flags & 0xFF80) >> 7;
1221 bitsPerPixelId = (flags & 0x0078) >> 3;
1222 cache_bitmap_v2_order->bitmapBpp = CBR2_BPP[bitsPerPixelId];
1224 if (cache_bitmap_v2_order->flags & CBR2_PERSISTENT_KEY_PRESENT)
1226 stream_read_uint32(s, cache_bitmap_v2_order->key1); /* key1 (4 bytes) */
1227 stream_read_uint32(s, cache_bitmap_v2_order->key2); /* key2 (4 bytes) */
1230 if (cache_bitmap_v2_order->flags & CBR2_HEIGHT_SAME_AS_WIDTH)
1232 update_read_2byte_unsigned(s, &cache_bitmap_v2_order->bitmapWidth); /* bitmapWidth */
1233 cache_bitmap_v2_order->bitmapHeight = cache_bitmap_v2_order->bitmapWidth;
1237 update_read_2byte_unsigned(s, &cache_bitmap_v2_order->bitmapWidth); /* bitmapWidth */
1238 update_read_2byte_unsigned(s, &cache_bitmap_v2_order->bitmapHeight); /* bitmapHeight */
1241 update_read_4byte_unsigned(s, &cache_bitmap_v2_order->bitmapLength); /* bitmapLength */
1242 update_read_2byte_unsigned(s, &cache_bitmap_v2_order->cacheIndex); /* cacheIndex */
1244 if (cache_bitmap_v2_order->flags & CBR2_DO_NOT_CACHE)
1245 cache_bitmap_v2_order->cacheIndex = BITMAP_CACHE_WAITING_LIST_INDEX;
1249 if (!(cache_bitmap_v2_order->flags & CBR2_NO_BITMAP_COMPRESSION_HDR))
1251 stream_read_uint16(s, cache_bitmap_v2_order->cbCompFirstRowSize); /* cbCompFirstRowSize (2 bytes) */
1252 stream_read_uint16(s, cache_bitmap_v2_order->cbCompMainBodySize); /* cbCompMainBodySize (2 bytes) */
1253 stream_read_uint16(s, cache_bitmap_v2_order->cbScanWidth); /* cbScanWidth (2 bytes) */
1254 stream_read_uint16(s, cache_bitmap_v2_order->cbUncompressedSize); /* cbUncompressedSize (2 bytes) */
1255 cache_bitmap_v2_order->bitmapLength = cache_bitmap_v2_order->cbCompMainBodySize;
1258 stream_get_mark(s, cache_bitmap_v2_order->bitmapDataStream);
1259 stream_seek(s, cache_bitmap_v2_order->bitmapLength);
1263 stream_get_mark(s, cache_bitmap_v2_order->bitmapDataStream);
1264 stream_seek(s, cache_bitmap_v2_order->bitmapLength);
1266 cache_bitmap_v2_order->compressed = compressed;
1269 void update_read_cache_bitmap_v3_order(STREAM* s, CACHE_BITMAP_V3_ORDER* cache_bitmap_v3_order, boolean compressed, uint16 flags)
1271 uint8 bitsPerPixelId;
1272 BITMAP_DATA_EX* bitmapData;
1274 cache_bitmap_v3_order->cacheId = flags & 0x00000003;
1275 cache_bitmap_v3_order->flags = (flags & 0x0000FF80) >> 7;
1277 bitsPerPixelId = (flags & 0x00000078) >> 3;
1278 cache_bitmap_v3_order->bpp = CBR23_BPP[bitsPerPixelId];
1280 stream_read_uint16(s, cache_bitmap_v3_order->cacheIndex); /* cacheIndex (2 bytes) */
1281 stream_read_uint32(s, cache_bitmap_v3_order->key1); /* key1 (4 bytes) */
1282 stream_read_uint32(s, cache_bitmap_v3_order->key2); /* key2 (4 bytes) */
1284 bitmapData = &cache_bitmap_v3_order->bitmapData;
1286 stream_read_uint8(s, bitmapData->bpp);
1287 stream_seek_uint8(s); /* reserved1 (1 byte) */
1288 stream_seek_uint8(s); /* reserved2 (1 byte) */
1289 stream_read_uint8(s, bitmapData->codecID); /* codecID (1 byte) */
1290 stream_read_uint16(s, bitmapData->width); /* width (2 bytes) */
1291 stream_read_uint16(s, bitmapData->height); /* height (2 bytes) */
1292 stream_read_uint32(s, bitmapData->length); /* length (4 bytes) */
1294 if (bitmapData->data == NULL)
1295 bitmapData->data = (uint8*) xmalloc(bitmapData->length);
1297 bitmapData->data = (uint8*) xrealloc(bitmapData->data, bitmapData->length);
1299 stream_read(s, bitmapData->data, bitmapData->length);
1302 void update_read_cache_color_table_order(STREAM* s, CACHE_COLOR_TABLE_ORDER* cache_color_table_order, uint16 flags)
1307 stream_read_uint8(s, cache_color_table_order->cacheIndex); /* cacheIndex (1 byte) */
1308 stream_read_uint8(s, cache_color_table_order->numberColors); /* numberColors (2 bytes) */
1310 colorTable = cache_color_table_order->colorTable;
1312 if (colorTable == NULL)
1313 colorTable = (uint32*) xmalloc(cache_color_table_order->numberColors * 4);
1315 colorTable = (uint32*) xrealloc(colorTable, cache_color_table_order->numberColors * 4);
1317 for (i = 0; i < (int) cache_color_table_order->numberColors; i++)
1319 update_read_color_quad(s, &colorTable[i]);
1322 cache_color_table_order->colorTable = colorTable;
1325 void update_read_cache_glyph_order(STREAM* s, CACHE_GLYPH_ORDER* cache_glyph_order, uint16 flags)
1331 stream_read_uint8(s, cache_glyph_order->cacheId); /* cacheId (1 byte) */
1332 stream_read_uint8(s, cache_glyph_order->cGlyphs); /* cGlyphs (1 byte) */
1334 for (i = 0; i < (int) cache_glyph_order->cGlyphs; i++)
1336 if (cache_glyph_order->glyphData[i] == NULL)
1338 cache_glyph_order->glyphData[i] = (GLYPH_DATA*) xmalloc(sizeof(GLYPH_DATA));
1340 glyph = cache_glyph_order->glyphData[i];
1342 stream_read_uint16(s, glyph->cacheIndex);
1343 stream_read_uint16(s, lsi16);
1345 stream_read_uint16(s, lsi16);
1347 stream_read_uint16(s, glyph->cx);
1348 stream_read_uint16(s, glyph->cy);
1350 glyph->cb = ((glyph->cx + 7) / 8) * glyph->cy;
1351 glyph->cb += ((glyph->cb % 4) > 0) ? 4 - (glyph->cb % 4) : 0;
1353 glyph->aj = (uint8*) xmalloc(glyph->cb);
1355 stream_read(s, glyph->aj, glyph->cb);
1358 if (flags & CG_GLYPH_UNICODE_PRESENT)
1359 stream_seek(s, cache_glyph_order->cGlyphs * 2);
1362 void update_read_cache_glyph_v2_order(STREAM* s, CACHE_GLYPH_V2_ORDER* cache_glyph_v2_order, uint16 flags)
1365 GLYPH_DATA_V2* glyph;
1367 cache_glyph_v2_order->cacheId = (flags & 0x000F);
1368 cache_glyph_v2_order->flags = (flags & 0x00F0) >> 4;
1369 cache_glyph_v2_order->cGlyphs = (flags & 0xFF00) >> 8;
1371 for (i = 0; i < (int) cache_glyph_v2_order->cGlyphs; i++)
1373 if (cache_glyph_v2_order->glyphData[i] == NULL)
1375 cache_glyph_v2_order->glyphData[i] = (GLYPH_DATA_V2*) xmalloc(sizeof(GLYPH_DATA_V2));
1377 glyph = cache_glyph_v2_order->glyphData[i];
1379 stream_read_uint8(s, glyph->cacheIndex);
1380 update_read_2byte_signed(s, &glyph->x);
1381 update_read_2byte_signed(s, &glyph->y);
1382 update_read_2byte_unsigned(s, &glyph->cx);
1383 update_read_2byte_unsigned(s, &glyph->cy);
1385 glyph->cb = ((glyph->cx + 7) / 8) * glyph->cy;
1386 glyph->cb += ((glyph->cb % 4) > 0) ? 4 - (glyph->cb % 4) : 0;
1388 glyph->aj = (uint8*) xmalloc(glyph->cb);
1390 stream_read(s, glyph->aj, glyph->cb);
1393 if (flags & CG_GLYPH_UNICODE_PRESENT)
1394 stream_seek(s, cache_glyph_v2_order->cGlyphs * 2);
1397 void update_decompress_brush(STREAM* s, uint8* output, uint8 bpp)
1405 palette = s->p + 16;
1406 bytesPerPixel = ((bpp + 1) / 8);
1408 for (y = 7; y >= 0; y--)
1410 for (x = 0; x < 8; x++)
1413 stream_read_uint8(s, byte);
1415 index = ((byte >> ((3 - (x % 4)) * 2)) & 0x03);
1417 for (k = 0; k < bytesPerPixel; k++)
1419 output[((y * 8 + x) * bytesPerPixel) + k] = palette[(index * bytesPerPixel) + k];
1425 void update_read_cache_brush_order(STREAM* s, CACHE_BRUSH_ORDER* cache_brush_order, uint16 flags)
1429 uint8 iBitmapFormat;
1430 boolean compressed = false;
1432 stream_read_uint8(s, cache_brush_order->index); /* cacheEntry (1 byte) */
1434 stream_read_uint8(s, iBitmapFormat); /* iBitmapFormat (1 byte) */
1435 cache_brush_order->bpp = BMF_BPP[iBitmapFormat];
1437 stream_read_uint8(s, cache_brush_order->cx); /* cx (1 byte) */
1438 stream_read_uint8(s, cache_brush_order->cy); /* cy (1 byte) */
1439 stream_read_uint8(s, cache_brush_order->style); /* style (1 byte) */
1440 stream_read_uint8(s, cache_brush_order->length); /* iBytes (1 byte) */
1442 if ((cache_brush_order->cx == 8) && (cache_brush_order->cy == 8))
1444 size = (cache_brush_order->bpp == 1) ? 8 : 8 * 8 * cache_brush_order->bpp;
1446 cache_brush_order->data = (uint8*) xmalloc(size);
1448 if (cache_brush_order->bpp == 1)
1450 if (cache_brush_order->length != 8)
1452 printf("incompatible 1bpp brush of length:%d\n", cache_brush_order->length);
1456 /* rows are encoded in reverse order */
1458 for (i = 7; i >= 0; i--)
1460 stream_read_uint8(s, cache_brush_order->data[i]);
1465 if ((iBitmapFormat == BMF_8BPP) && (cache_brush_order->length == 20))
1467 else if ((iBitmapFormat == BMF_16BPP) && (cache_brush_order->length == 24))
1469 else if ((iBitmapFormat == BMF_32BPP) && (cache_brush_order->length == 32))
1472 if (compressed != false)
1474 /* compressed brush */
1475 update_decompress_brush(s, cache_brush_order->data, cache_brush_order->bpp);
1479 /* uncompressed brush */
1480 int scanline = (cache_brush_order->bpp / 8) * 8;
1482 for (i = 7; i >= 0; i--)
1484 stream_read(s, &cache_brush_order->data[i * scanline], scanline);
1491 /* Alternate Secondary Drawing Orders */
1493 void update_read_create_offscreen_bitmap_order(STREAM* s, CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap)
1496 boolean deleteListPresent;
1497 OFFSCREEN_DELETE_LIST* deleteList;
1499 stream_read_uint16(s, flags); /* flags (2 bytes) */
1500 create_offscreen_bitmap->id = flags & 0x7FFF;
1501 deleteListPresent = (flags & 0x8000) ? true : false;
1503 stream_read_uint16(s, create_offscreen_bitmap->cx); /* cx (2 bytes) */
1504 stream_read_uint16(s, create_offscreen_bitmap->cy); /* cy (2 bytes) */
1506 deleteList = &(create_offscreen_bitmap->deleteList);
1507 if (deleteListPresent)
1511 stream_read_uint16(s, deleteList->cIndices);
1513 if (deleteList->cIndices > deleteList->sIndices)
1515 deleteList->sIndices = deleteList->cIndices;
1516 deleteList->indices = xrealloc(deleteList->indices, deleteList->sIndices * 2);
1519 for (i = 0; i < (int) deleteList->cIndices; i++)
1521 stream_read_uint16(s, deleteList->indices[i]);
1526 deleteList->cIndices = 0;
1530 void update_read_switch_surface_order(STREAM* s, SWITCH_SURFACE_ORDER* switch_surface)
1532 stream_read_uint16(s, switch_surface->bitmapId); /* bitmapId (2 bytes) */
1535 void update_read_create_nine_grid_bitmap_order(STREAM* s, CREATE_NINE_GRID_BITMAP_ORDER* create_nine_grid_bitmap)
1537 NINE_GRID_BITMAP_INFO* nineGridInfo;
1539 stream_read_uint8(s, create_nine_grid_bitmap->bitmapBpp); /* bitmapBpp (1 byte) */
1540 stream_read_uint16(s, create_nine_grid_bitmap->bitmapId); /* bitmapId (2 bytes) */
1542 nineGridInfo = &(create_nine_grid_bitmap->nineGridInfo);
1543 stream_read_uint32(s, nineGridInfo->flFlags); /* flFlags (4 bytes) */
1544 stream_read_uint16(s, nineGridInfo->ulLeftWidth); /* ulLeftWidth (2 bytes) */
1545 stream_read_uint16(s, nineGridInfo->ulRightWidth); /* ulRightWidth (2 bytes) */
1546 stream_read_uint16(s, nineGridInfo->ulTopHeight); /* ulTopHeight (2 bytes) */
1547 stream_read_uint16(s, nineGridInfo->ulBottomHeight); /* ulBottomHeight (2 bytes) */
1548 update_read_colorref(s, &nineGridInfo->crTransparent); /* crTransparent (4 bytes) */
1551 void update_read_frame_marker_order(STREAM* s, FRAME_MARKER_ORDER* frame_marker)
1553 stream_read_uint32(s, frame_marker->action); /* action (4 bytes) */
1556 void update_read_stream_bitmap_first_order(STREAM* s, STREAM_BITMAP_FIRST_ORDER* stream_bitmap_first)
1558 stream_read_uint8(s, stream_bitmap_first->bitmapFlags); /* bitmapFlags (1 byte) */
1559 stream_read_uint8(s, stream_bitmap_first->bitmapBpp); /* bitmapBpp (1 byte) */
1560 stream_read_uint16(s, stream_bitmap_first->bitmapType); /* bitmapType (2 bytes) */
1561 stream_read_uint16(s, stream_bitmap_first->bitmapWidth); /* bitmapWidth (2 bytes) */
1562 stream_read_uint16(s, stream_bitmap_first->bitmapHeight); /* bitmapHeigth (2 bytes) */
1564 if (stream_bitmap_first->bitmapFlags & STREAM_BITMAP_V2)
1565 stream_read_uint32(s, stream_bitmap_first->bitmapSize); /* bitmapSize (4 bytes) */
1567 stream_read_uint16(s, stream_bitmap_first->bitmapSize); /* bitmapSize (2 bytes) */
1569 stream_read_uint16(s, stream_bitmap_first->bitmapBlockSize); /* bitmapBlockSize (2 bytes) */
1570 stream_seek(s, stream_bitmap_first->bitmapBlockSize); /* bitmapBlock */
1573 void update_read_stream_bitmap_next_order(STREAM* s, STREAM_BITMAP_FIRST_ORDER* stream_bitmap_next)
1575 stream_read_uint8(s, stream_bitmap_next->bitmapFlags); /* bitmapFlags (1 byte) */
1576 stream_read_uint16(s, stream_bitmap_next->bitmapType); /* bitmapType (2 bytes) */
1577 stream_read_uint16(s, stream_bitmap_next->bitmapBlockSize); /* bitmapBlockSize (2 bytes) */
1578 stream_seek(s, stream_bitmap_next->bitmapBlockSize); /* bitmapBlock */
1581 void update_read_draw_gdiplus_first_order(STREAM* s, DRAW_GDIPLUS_FIRST_ORDER* draw_gdiplus_first)
1583 stream_seek_uint8(s); /* pad1Octet (1 byte) */
1584 stream_read_uint16(s, draw_gdiplus_first->cbSize); /* cbSize (2 bytes) */
1585 stream_read_uint32(s, draw_gdiplus_first->cbTotalSize); /* cbTotalSize (4 bytes) */
1586 stream_read_uint32(s, draw_gdiplus_first->cbTotalEmfSize); /* cbTotalEmfSize (4 bytes) */
1587 stream_seek(s, draw_gdiplus_first->cbSize); /* emfRecords */
1590 void update_read_draw_gdiplus_next_order(STREAM* s, DRAW_GDIPLUS_NEXT_ORDER* draw_gdiplus_next)
1592 stream_seek_uint8(s); /* pad1Octet (1 byte) */
1593 stream_read_uint16(s, draw_gdiplus_next->cbSize); /* cbSize (2 bytes) */
1594 stream_seek(s, draw_gdiplus_next->cbSize); /* emfRecords */
1597 void update_read_draw_gdiplus_end_order(STREAM* s, DRAW_GDIPLUS_END_ORDER* draw_gdiplus_end)
1599 stream_seek_uint8(s); /* pad1Octet (1 byte) */
1600 stream_read_uint16(s, draw_gdiplus_end->cbSize); /* cbSize (2 bytes) */
1601 stream_read_uint32(s, draw_gdiplus_end->cbTotalSize); /* cbTotalSize (4 bytes) */
1602 stream_read_uint32(s, draw_gdiplus_end->cbTotalEmfSize); /* cbTotalEmfSize (4 bytes) */
1603 stream_seek(s, draw_gdiplus_end->cbSize); /* emfRecords */
1606 void update_read_draw_gdiplus_cache_first_order(STREAM* s, DRAW_GDIPLUS_CACHE_FIRST_ORDER* draw_gdiplus_cache_first)
1608 stream_read_uint8(s, draw_gdiplus_cache_first->flags); /* flags (1 byte) */
1609 stream_read_uint16(s, draw_gdiplus_cache_first->cacheType); /* cacheType (2 bytes) */
1610 stream_read_uint16(s, draw_gdiplus_cache_first->cacheIndex); /* cacheIndex (2 bytes) */
1611 stream_read_uint16(s, draw_gdiplus_cache_first->cbSize); /* cbSize (2 bytes) */
1612 stream_read_uint32(s, draw_gdiplus_cache_first->cbTotalSize); /* cbTotalSize (4 bytes) */
1613 stream_seek(s, draw_gdiplus_cache_first->cbSize); /* emfRecords */
1616 void update_read_draw_gdiplus_cache_next_order(STREAM* s, DRAW_GDIPLUS_CACHE_NEXT_ORDER* draw_gdiplus_cache_next)
1618 stream_read_uint8(s, draw_gdiplus_cache_next->flags); /* flags (1 byte) */
1619 stream_read_uint16(s, draw_gdiplus_cache_next->cacheType); /* cacheType (2 bytes) */
1620 stream_read_uint16(s, draw_gdiplus_cache_next->cacheIndex); /* cacheIndex (2 bytes) */
1621 stream_read_uint16(s, draw_gdiplus_cache_next->cbSize); /* cbSize (2 bytes) */
1622 stream_seek(s, draw_gdiplus_cache_next->cbSize); /* emfRecords */
1625 void update_read_draw_gdiplus_cache_end_order(STREAM* s, DRAW_GDIPLUS_CACHE_END_ORDER* draw_gdiplus_cache_end)
1627 stream_read_uint8(s, draw_gdiplus_cache_end->flags); /* flags (1 byte) */
1628 stream_read_uint16(s, draw_gdiplus_cache_end->cacheType); /* cacheType (2 bytes) */
1629 stream_read_uint16(s, draw_gdiplus_cache_end->cacheIndex); /* cacheIndex (2 bytes) */
1630 stream_read_uint16(s, draw_gdiplus_cache_end->cbSize); /* cbSize (2 bytes) */
1631 stream_read_uint32(s, draw_gdiplus_cache_end->cbTotalSize); /* cbTotalSize (4 bytes) */
1632 stream_seek(s, draw_gdiplus_cache_end->cbSize); /* emfRecords */
1635 void update_read_field_flags(STREAM* s, uint32* fieldFlags, uint8 flags, uint8 fieldBytes)
1640 if (flags & ORDER_ZERO_FIELD_BYTE_BIT0)
1643 if (flags & ORDER_ZERO_FIELD_BYTE_BIT1)
1652 for (i = 0; i < fieldBytes; i++)
1654 stream_read_uint8(s, byte);
1655 *fieldFlags |= byte << (i * 8);
1659 void update_read_bounds(STREAM* s, rdpBounds* bounds)
1663 stream_read_uint8(s, flags); /* field flags */
1665 if (flags & BOUND_LEFT)
1666 update_read_coord(s, &bounds->left, false);
1667 else if (flags & BOUND_DELTA_LEFT)
1668 update_read_coord(s, &bounds->left, true);
1670 if (flags & BOUND_TOP)
1671 update_read_coord(s, &bounds->top, false);
1672 else if (flags & BOUND_DELTA_TOP)
1673 update_read_coord(s, &bounds->top, true);
1675 if (flags & BOUND_RIGHT)
1676 update_read_coord(s, &bounds->right, false);
1677 else if (flags & BOUND_DELTA_RIGHT)
1678 update_read_coord(s, &bounds->right, true);
1680 if (flags & BOUND_BOTTOM)
1681 update_read_coord(s, &bounds->bottom, false);
1682 else if (flags & BOUND_DELTA_BOTTOM)
1683 update_read_coord(s, &bounds->bottom, true);
1686 void update_recv_primary_order(rdpUpdate* update, STREAM* s, uint8 flags)
1688 ORDER_INFO* orderInfo;
1689 rdpContext* context = update->context;
1690 rdpPrimaryUpdate* primary = update->primary;
1692 orderInfo = &(primary->order_info);
1694 if (flags & ORDER_TYPE_CHANGE)
1695 stream_read_uint8(s, orderInfo->orderType); /* orderType (1 byte) */
1697 update_read_field_flags(s, &(orderInfo->fieldFlags), flags,
1698 PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo->orderType]);
1700 if (flags & ORDER_BOUNDS)
1702 if (!(flags & ORDER_ZERO_BOUNDS_DELTAS))
1703 update_read_bounds(s, &orderInfo->bounds);
1705 IFCALL(update->SetBounds, context, &orderInfo->bounds);
1708 orderInfo->deltaCoordinates = (flags & ORDER_DELTA_COORDINATES) ? true : false;
1710 #ifdef WITH_DEBUG_ORDERS
1711 if (orderInfo->orderType < PRIMARY_DRAWING_ORDER_COUNT)
1712 printf("%s Primary Drawing Order (0x%02X)\n", PRIMARY_DRAWING_ORDER_STRINGS[orderInfo->orderType], orderInfo->orderType);
1714 printf("Unknown Primary Drawing Order (0x%02X)\n", orderInfo->orderType);
1717 switch (orderInfo->orderType)
1719 case ORDER_TYPE_DSTBLT:
1720 update_read_dstblt_order(s, orderInfo, &(primary->dstblt));
1721 IFCALL(primary->DstBlt, context, &primary->dstblt);
1724 case ORDER_TYPE_PATBLT:
1725 update_read_patblt_order(s, orderInfo, &(primary->patblt));
1726 IFCALL(primary->PatBlt, context, &primary->patblt);
1729 case ORDER_TYPE_SCRBLT:
1730 update_read_scrblt_order(s, orderInfo, &(primary->scrblt));
1731 IFCALL(primary->ScrBlt, context, &primary->scrblt);
1734 case ORDER_TYPE_OPAQUE_RECT:
1735 update_read_opaque_rect_order(s, orderInfo, &(primary->opaque_rect));
1736 IFCALL(primary->OpaqueRect, context, &primary->opaque_rect);
1739 case ORDER_TYPE_DRAW_NINE_GRID:
1740 update_read_draw_nine_grid_order(s, orderInfo, &(primary->draw_nine_grid));
1741 IFCALL(primary->DrawNineGrid, context, &primary->draw_nine_grid);
1744 case ORDER_TYPE_MULTI_DSTBLT:
1745 update_read_multi_dstblt_order(s, orderInfo, &(primary->multi_dstblt));
1746 IFCALL(primary->MultiDstBlt, context, &primary->multi_dstblt);
1749 case ORDER_TYPE_MULTI_PATBLT:
1750 update_read_multi_patblt_order(s, orderInfo, &(primary->multi_patblt));
1751 IFCALL(primary->MultiPatBlt, context, &primary->multi_patblt);
1754 case ORDER_TYPE_MULTI_SCRBLT:
1755 update_read_multi_scrblt_order(s, orderInfo, &(primary->multi_scrblt));
1756 IFCALL(primary->MultiScrBlt, context, &primary->multi_scrblt);
1759 case ORDER_TYPE_MULTI_OPAQUE_RECT:
1760 update_read_multi_opaque_rect_order(s, orderInfo, &(primary->multi_opaque_rect));
1761 IFCALL(primary->MultiOpaqueRect, context, &primary->multi_opaque_rect);
1764 case ORDER_TYPE_MULTI_DRAW_NINE_GRID:
1765 update_read_multi_draw_nine_grid_order(s, orderInfo, &(primary->multi_draw_nine_grid));
1766 IFCALL(primary->MultiDrawNineGrid, context, &primary->multi_draw_nine_grid);
1769 case ORDER_TYPE_LINE_TO:
1770 update_read_line_to_order(s, orderInfo, &(primary->line_to));
1771 IFCALL(primary->LineTo, context, &primary->line_to);
1774 case ORDER_TYPE_POLYLINE:
1775 update_read_polyline_order(s, orderInfo, &(primary->polyline));
1776 IFCALL(primary->Polyline, context, &primary->polyline);
1779 case ORDER_TYPE_MEMBLT:
1780 update_read_memblt_order(s, orderInfo, &(primary->memblt));
1781 IFCALL(primary->MemBlt, context, &primary->memblt);
1784 case ORDER_TYPE_MEM3BLT:
1785 update_read_mem3blt_order(s, orderInfo, &(primary->mem3blt));
1786 IFCALL(primary->Mem3Blt, context, &primary->mem3blt);
1789 case ORDER_TYPE_SAVE_BITMAP:
1790 update_read_save_bitmap_order(s, orderInfo, &(primary->save_bitmap));
1791 IFCALL(primary->SaveBitmap, context, &primary->save_bitmap);
1794 case ORDER_TYPE_GLYPH_INDEX:
1795 update_read_glyph_index_order(s, orderInfo, &(primary->glyph_index));
1796 IFCALL(primary->GlyphIndex, context, &primary->glyph_index);
1799 case ORDER_TYPE_FAST_INDEX:
1800 update_read_fast_index_order(s, orderInfo, &(primary->fast_index));
1801 IFCALL(primary->FastIndex, context, &primary->fast_index);
1804 case ORDER_TYPE_FAST_GLYPH:
1805 update_read_fast_glyph_order(s, orderInfo, &(primary->fast_glyph));
1806 IFCALL(primary->FastGlyph, context, &primary->fast_glyph);
1809 case ORDER_TYPE_POLYGON_SC:
1810 update_read_polygon_sc_order(s, orderInfo, &(primary->polygon_sc));
1811 IFCALL(primary->PolygonSC, context, &primary->polygon_sc);
1814 case ORDER_TYPE_POLYGON_CB:
1815 update_read_polygon_cb_order(s, orderInfo, &(primary->polygon_cb));
1816 IFCALL(primary->PolygonCB, context, &primary->polygon_cb);
1819 case ORDER_TYPE_ELLIPSE_SC:
1820 update_read_ellipse_sc_order(s, orderInfo, &(primary->ellipse_sc));
1821 IFCALL(primary->EllipseSC, context, &primary->ellipse_sc);
1824 case ORDER_TYPE_ELLIPSE_CB:
1825 update_read_ellipse_cb_order(s, orderInfo, &(primary->ellipse_cb));
1826 IFCALL(primary->EllipseCB, context, &primary->ellipse_cb);
1833 if (flags & ORDER_BOUNDS)
1835 IFCALL(update->SetBounds, context, NULL);
1839 void update_recv_secondary_order(rdpUpdate* update, STREAM* s, uint8 flags)
1845 rdpContext* context = update->context;
1846 rdpSecondaryUpdate* secondary = update->secondary;
1848 stream_read_uint16(s, orderLength); /* orderLength (2 bytes) */
1849 stream_read_uint16(s, extraFlags); /* extraFlags (2 bytes) */
1850 stream_read_uint8(s, orderType); /* orderType (1 byte) */
1852 next = s->p + ((sint16) orderLength) + 7;
1854 #ifdef WITH_DEBUG_ORDERS
1855 if (orderType < SECONDARY_DRAWING_ORDER_COUNT)
1856 printf("%s Secondary Drawing Order (0x%02X)\n", SECONDARY_DRAWING_ORDER_STRINGS[orderType], orderType);
1858 printf("Unknown Secondary Drawing Order (0x%02X)\n", orderType);
1863 case ORDER_TYPE_BITMAP_UNCOMPRESSED:
1864 update_read_cache_bitmap_order(s, &(secondary->cache_bitmap_order), false, extraFlags);
1865 IFCALL(secondary->CacheBitmap, context, &(secondary->cache_bitmap_order));
1868 case ORDER_TYPE_CACHE_BITMAP_COMPRESSED:
1869 update_read_cache_bitmap_order(s, &(secondary->cache_bitmap_order), true, extraFlags);
1870 IFCALL(secondary->CacheBitmap, context, &(secondary->cache_bitmap_order));
1873 case ORDER_TYPE_BITMAP_UNCOMPRESSED_V2:
1874 update_read_cache_bitmap_v2_order(s, &(secondary->cache_bitmap_v2_order), false, extraFlags);
1875 IFCALL(secondary->CacheBitmapV2, context, &(secondary->cache_bitmap_v2_order));
1878 case ORDER_TYPE_BITMAP_COMPRESSED_V2:
1879 update_read_cache_bitmap_v2_order(s, &(secondary->cache_bitmap_v2_order), true, extraFlags);
1880 IFCALL(secondary->CacheBitmapV2, context, &(secondary->cache_bitmap_v2_order));
1883 case ORDER_TYPE_BITMAP_COMPRESSED_V3:
1884 update_read_cache_bitmap_v3_order(s, &(secondary->cache_bitmap_v3_order), true, extraFlags);
1885 IFCALL(secondary->CacheBitmapV3, context, &(secondary->cache_bitmap_v3_order));
1888 case ORDER_TYPE_CACHE_COLOR_TABLE:
1889 update_read_cache_color_table_order(s, &(secondary->cache_color_table_order), extraFlags);
1890 IFCALL(secondary->CacheColorTable, context, &(secondary->cache_color_table_order));
1893 case ORDER_TYPE_CACHE_GLYPH:
1894 if (secondary->glyph_v2)
1896 update_read_cache_glyph_v2_order(s, &(secondary->cache_glyph_v2_order), extraFlags);
1897 IFCALL(secondary->CacheGlyphV2, context, &(secondary->cache_glyph_v2_order));
1901 update_read_cache_glyph_order(s, &(secondary->cache_glyph_order), extraFlags);
1902 IFCALL(secondary->CacheGlyph, context, &(secondary->cache_glyph_order));
1906 case ORDER_TYPE_CACHE_BRUSH:
1907 update_read_cache_brush_order(s, &(secondary->cache_brush_order), extraFlags);
1908 IFCALL(secondary->CacheBrush, context, &(secondary->cache_brush_order));
1918 void update_recv_altsec_order(rdpUpdate* update, STREAM* s, uint8 flags)
1921 rdpContext* context = update->context;
1922 rdpAltSecUpdate* altsec = update->altsec;
1924 orderType = flags >>= 2; /* orderType is in higher 6 bits of flags field */
1926 #ifdef WITH_DEBUG_ORDERS
1927 if (orderType < ALTSEC_DRAWING_ORDER_COUNT)
1928 printf("%s Alternate Secondary Drawing Order (0x%02X)\n", ALTSEC_DRAWING_ORDER_STRINGS[orderType], orderType);
1930 printf("Unknown Alternate Secondary Drawing Order: 0x%02X\n", orderType);
1935 case ORDER_TYPE_CREATE_OFFSCREEN_BITMAP:
1936 update_read_create_offscreen_bitmap_order(s, &(altsec->create_offscreen_bitmap));
1937 IFCALL(altsec->CreateOffscreenBitmap, context, &(altsec->create_offscreen_bitmap));
1940 case ORDER_TYPE_SWITCH_SURFACE:
1941 update_read_switch_surface_order(s, &(altsec->switch_surface));
1942 IFCALL(altsec->SwitchSurface, context, &(altsec->switch_surface));
1945 case ORDER_TYPE_CREATE_NINE_GRID_BITMAP:
1946 update_read_create_nine_grid_bitmap_order(s, &(altsec->create_nine_grid_bitmap));
1947 IFCALL(altsec->CreateNineGridBitmap, context, &(altsec->create_nine_grid_bitmap));
1950 case ORDER_TYPE_FRAME_MARKER:
1951 update_read_frame_marker_order(s, &(altsec->frame_marker));
1952 IFCALL(altsec->FrameMarker, context, &(altsec->frame_marker));
1955 case ORDER_TYPE_STREAM_BITMAP_FIRST:
1956 update_read_stream_bitmap_first_order(s, &(altsec->stream_bitmap_first));
1957 IFCALL(altsec->StreamBitmapFirst, context, &(altsec->stream_bitmap_first));
1960 case ORDER_TYPE_STREAM_BITMAP_NEXT:
1961 update_read_stream_bitmap_next_order(s, &(altsec->stream_bitmap_next));
1962 IFCALL(altsec->StreamBitmapNext, context, &(altsec->stream_bitmap_next));
1965 case ORDER_TYPE_GDIPLUS_FIRST:
1966 update_read_draw_gdiplus_first_order(s, &(altsec->draw_gdiplus_first));
1967 IFCALL(altsec->DrawGdiPlusFirst, context, &(altsec->draw_gdiplus_first));
1970 case ORDER_TYPE_GDIPLUS_NEXT:
1971 update_read_draw_gdiplus_next_order(s, &(altsec->draw_gdiplus_next));
1972 IFCALL(altsec->DrawGdiPlusNext, context, &(altsec->draw_gdiplus_next));
1975 case ORDER_TYPE_GDIPLUS_END:
1976 update_read_draw_gdiplus_end_order(s, &(altsec->draw_gdiplus_end));
1977 IFCALL(altsec->DrawGdiPlusEnd, context, &(altsec->draw_gdiplus_end));
1980 case ORDER_TYPE_GDIPLUS_CACHE_FIRST:
1981 update_read_draw_gdiplus_cache_first_order(s, &(altsec->draw_gdiplus_cache_first));
1982 IFCALL(altsec->DrawGdiPlusCacheFirst, context, &(altsec->draw_gdiplus_cache_first));
1985 case ORDER_TYPE_GDIPLUS_CACHE_NEXT:
1986 update_read_draw_gdiplus_cache_next_order(s, &(altsec->draw_gdiplus_cache_next));
1987 IFCALL(altsec->DrawGdiPlusCacheNext, context, &(altsec->draw_gdiplus_cache_next));
1990 case ORDER_TYPE_GDIPLUS_CACHE_END:
1991 update_read_draw_gdiplus_cache_end_order(s, &(altsec->draw_gdiplus_cache_end));
1992 IFCALL(altsec->DrawGdiPlusCacheEnd, context, &(altsec->draw_gdiplus_cache_end));
1995 case ORDER_TYPE_WINDOW:
1996 update_recv_altsec_window_order(update, s);
1999 case ORDER_TYPE_COMPDESK_FIRST:
2007 void update_recv_order(rdpUpdate* update, STREAM* s)
2011 stream_read_uint8(s, controlFlags); /* controlFlags (1 byte) */
2013 if (!(controlFlags & ORDER_STANDARD))
2014 update_recv_altsec_order(update, s, controlFlags);
2015 else if (controlFlags & ORDER_SECONDARY)
2016 update_recv_secondary_order(update, s, controlFlags);
2018 update_recv_primary_order(update, s, controlFlags);