Merge remote branch 'origin/master' into pipe-video
[mesa.git] / src / gallium / auxiliary / rbug / rbug_context.c
1 /*
2 * Copyright 2009 VMware, Inc.
3 * All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * on the rights to use, copy, modify, merge, publish, distribute, sub
9 * license, and/or sell copies of the Software, and to permit persons to whom
10 * the Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22 * USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 /*
26 * This file holds the function implementation for one of the rbug extensions.
27 * Prototypes and declerations of functions and structs is in the same folder
28 * in the header file matching this file's name.
29 *
30 * The functions starting rbug_send_* encodes a call to the write format and
31 * sends that to the supplied connection, while functions starting with
32 * rbug_demarshal_* demarshal data in the wire protocol.
33 *
34 * Functions ending with _reply are replies to requests.
35 */
36
37 #include "rbug_internal.h"
38 #include "rbug/rbug_context.h"
39
40 int rbug_send_context_list(struct rbug_connection *__con,
41 uint32_t *__serial)
42 {
43 uint32_t __len = 0;
44 uint32_t __pos = 0;
45 uint8_t *__data = NULL;
46 int __ret = 0;
47
48 LEN(8); /* header */
49
50 /* align */
51 PAD(__len, 8);
52
53 __data = (uint8_t*)MALLOC(__len);
54 if (!__data)
55 return -ENOMEM;
56
57 WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_LIST));
58 WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
59
60 /* final pad */
61 PAD(__pos, 8);
62
63 if (__pos != __len) {
64 __ret = -EINVAL;
65 } else {
66 rbug_connection_send_start(__con, RBUG_OP_CONTEXT_LIST, __len);
67 rbug_connection_write(__con, __data, __len);
68 __ret = rbug_connection_send_finish(__con, __serial);
69 }
70
71 FREE(__data);
72 return __ret;
73 }
74
75 int rbug_send_context_info(struct rbug_connection *__con,
76 rbug_context_t context,
77 uint32_t *__serial)
78 {
79 uint32_t __len = 0;
80 uint32_t __pos = 0;
81 uint8_t *__data = NULL;
82 int __ret = 0;
83
84 LEN(8); /* header */
85 LEN(8); /* context */
86
87 /* align */
88 PAD(__len, 8);
89
90 __data = (uint8_t*)MALLOC(__len);
91 if (!__data)
92 return -ENOMEM;
93
94 WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_INFO));
95 WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
96 WRITE(8, rbug_context_t, context); /* context */
97
98 /* final pad */
99 PAD(__pos, 8);
100
101 if (__pos != __len) {
102 __ret = -EINVAL;
103 } else {
104 rbug_connection_send_start(__con, RBUG_OP_CONTEXT_INFO, __len);
105 rbug_connection_write(__con, __data, __len);
106 __ret = rbug_connection_send_finish(__con, __serial);
107 }
108
109 FREE(__data);
110 return __ret;
111 }
112
113 int rbug_send_context_draw_block(struct rbug_connection *__con,
114 rbug_context_t context,
115 rbug_block_t block,
116 uint32_t *__serial)
117 {
118 uint32_t __len = 0;
119 uint32_t __pos = 0;
120 uint8_t *__data = NULL;
121 int __ret = 0;
122
123 LEN(8); /* header */
124 LEN(8); /* context */
125 LEN(4); /* block */
126
127 /* align */
128 PAD(__len, 8);
129
130 __data = (uint8_t*)MALLOC(__len);
131 if (!__data)
132 return -ENOMEM;
133
134 WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_BLOCK));
135 WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
136 WRITE(8, rbug_context_t, context); /* context */
137 WRITE(4, rbug_block_t, block); /* block */
138
139 /* final pad */
140 PAD(__pos, 8);
141
142 if (__pos != __len) {
143 __ret = -EINVAL;
144 } else {
145 rbug_connection_send_start(__con, RBUG_OP_CONTEXT_DRAW_BLOCK, __len);
146 rbug_connection_write(__con, __data, __len);
147 __ret = rbug_connection_send_finish(__con, __serial);
148 }
149
150 FREE(__data);
151 return __ret;
152 }
153
154 int rbug_send_context_draw_step(struct rbug_connection *__con,
155 rbug_context_t context,
156 rbug_block_t step,
157 uint32_t *__serial)
158 {
159 uint32_t __len = 0;
160 uint32_t __pos = 0;
161 uint8_t *__data = NULL;
162 int __ret = 0;
163
164 LEN(8); /* header */
165 LEN(8); /* context */
166 LEN(4); /* step */
167
168 /* align */
169 PAD(__len, 8);
170
171 __data = (uint8_t*)MALLOC(__len);
172 if (!__data)
173 return -ENOMEM;
174
175 WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_STEP));
176 WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
177 WRITE(8, rbug_context_t, context); /* context */
178 WRITE(4, rbug_block_t, step); /* step */
179
180 /* final pad */
181 PAD(__pos, 8);
182
183 if (__pos != __len) {
184 __ret = -EINVAL;
185 } else {
186 rbug_connection_send_start(__con, RBUG_OP_CONTEXT_DRAW_STEP, __len);
187 rbug_connection_write(__con, __data, __len);
188 __ret = rbug_connection_send_finish(__con, __serial);
189 }
190
191 FREE(__data);
192 return __ret;
193 }
194
195 int rbug_send_context_draw_unblock(struct rbug_connection *__con,
196 rbug_context_t context,
197 rbug_block_t unblock,
198 uint32_t *__serial)
199 {
200 uint32_t __len = 0;
201 uint32_t __pos = 0;
202 uint8_t *__data = NULL;
203 int __ret = 0;
204
205 LEN(8); /* header */
206 LEN(8); /* context */
207 LEN(4); /* unblock */
208
209 /* align */
210 PAD(__len, 8);
211
212 __data = (uint8_t*)MALLOC(__len);
213 if (!__data)
214 return -ENOMEM;
215
216 WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_UNBLOCK));
217 WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
218 WRITE(8, rbug_context_t, context); /* context */
219 WRITE(4, rbug_block_t, unblock); /* unblock */
220
221 /* final pad */
222 PAD(__pos, 8);
223
224 if (__pos != __len) {
225 __ret = -EINVAL;
226 } else {
227 rbug_connection_send_start(__con, RBUG_OP_CONTEXT_DRAW_UNBLOCK, __len);
228 rbug_connection_write(__con, __data, __len);
229 __ret = rbug_connection_send_finish(__con, __serial);
230 }
231
232 FREE(__data);
233 return __ret;
234 }
235
236 int rbug_send_context_draw_rule(struct rbug_connection *__con,
237 rbug_context_t context,
238 rbug_shader_t vertex,
239 rbug_shader_t fragment,
240 rbug_texture_t texture,
241 rbug_texture_t surface,
242 rbug_block_t block,
243 uint32_t *__serial)
244 {
245 uint32_t __len = 0;
246 uint32_t __pos = 0;
247 uint8_t *__data = NULL;
248 int __ret = 0;
249
250 LEN(8); /* header */
251 LEN(8); /* context */
252 LEN(8); /* vertex */
253 LEN(8); /* fragment */
254 LEN(8); /* texture */
255 LEN(8); /* surface */
256 LEN(4); /* block */
257
258 /* align */
259 PAD(__len, 8);
260
261 __data = (uint8_t*)MALLOC(__len);
262 if (!__data)
263 return -ENOMEM;
264
265 WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_RULE));
266 WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
267 WRITE(8, rbug_context_t, context); /* context */
268 WRITE(8, rbug_shader_t, vertex); /* vertex */
269 WRITE(8, rbug_shader_t, fragment); /* fragment */
270 WRITE(8, rbug_texture_t, texture); /* texture */
271 WRITE(8, rbug_texture_t, surface); /* surface */
272 WRITE(4, rbug_block_t, block); /* block */
273
274 /* final pad */
275 PAD(__pos, 8);
276
277 if (__pos != __len) {
278 __ret = -EINVAL;
279 } else {
280 rbug_connection_send_start(__con, RBUG_OP_CONTEXT_DRAW_RULE, __len);
281 rbug_connection_write(__con, __data, __len);
282 __ret = rbug_connection_send_finish(__con, __serial);
283 }
284
285 FREE(__data);
286 return __ret;
287 }
288
289 int rbug_send_context_flush(struct rbug_connection *__con,
290 rbug_context_t context,
291 uint32_t *__serial)
292 {
293 uint32_t __len = 0;
294 uint32_t __pos = 0;
295 uint8_t *__data = NULL;
296 int __ret = 0;
297
298 LEN(8); /* header */
299 LEN(8); /* context */
300
301 /* align */
302 PAD(__len, 8);
303
304 __data = (uint8_t*)MALLOC(__len);
305 if (!__data)
306 return -ENOMEM;
307
308 WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_FLUSH));
309 WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
310 WRITE(8, rbug_context_t, context); /* context */
311
312 /* final pad */
313 PAD(__pos, 8);
314
315 if (__pos != __len) {
316 __ret = -EINVAL;
317 } else {
318 rbug_connection_send_start(__con, RBUG_OP_CONTEXT_FLUSH, __len);
319 rbug_connection_write(__con, __data, __len);
320 __ret = rbug_connection_send_finish(__con, __serial);
321 }
322
323 FREE(__data);
324 return __ret;
325 }
326
327 int rbug_send_context_list_reply(struct rbug_connection *__con,
328 uint32_t serial,
329 rbug_context_t *contexts,
330 uint32_t contexts_len,
331 uint32_t *__serial)
332 {
333 uint32_t __len = 0;
334 uint32_t __pos = 0;
335 uint8_t *__data = NULL;
336 int __ret = 0;
337
338 LEN(8); /* header */
339 LEN(4); /* serial */
340 LEN_ARRAY(8, contexts); /* contexts */
341
342 /* align */
343 PAD(__len, 8);
344
345 __data = (uint8_t*)MALLOC(__len);
346 if (!__data)
347 return -ENOMEM;
348
349 WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_LIST_REPLY));
350 WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
351 WRITE(4, uint32_t, serial); /* serial */
352 WRITE_ARRAY(8, rbug_context_t, contexts); /* contexts */
353
354 /* final pad */
355 PAD(__pos, 8);
356
357 if (__pos != __len) {
358 __ret = -EINVAL;
359 } else {
360 rbug_connection_send_start(__con, RBUG_OP_CONTEXT_LIST_REPLY, __len);
361 rbug_connection_write(__con, __data, __len);
362 __ret = rbug_connection_send_finish(__con, __serial);
363 }
364
365 FREE(__data);
366 return __ret;
367 }
368
369 int rbug_send_context_info_reply(struct rbug_connection *__con,
370 uint32_t serial,
371 rbug_shader_t vertex,
372 rbug_shader_t fragment,
373 rbug_texture_t *texs,
374 uint32_t texs_len,
375 rbug_texture_t *cbufs,
376 uint32_t cbufs_len,
377 rbug_texture_t zsbuf,
378 rbug_block_t blocker,
379 rbug_block_t blocked,
380 uint32_t *__serial)
381 {
382 uint32_t __len = 0;
383 uint32_t __pos = 0;
384 uint8_t *__data = NULL;
385 int __ret = 0;
386
387 LEN(8); /* header */
388 LEN(4); /* serial */
389 LEN(8); /* vertex */
390 LEN(8); /* fragment */
391 LEN_ARRAY(8, texs); /* texs */
392 LEN_ARRAY(8, cbufs); /* cbufs */
393 LEN(8); /* zsbuf */
394 LEN(4); /* blocker */
395 LEN(4); /* blocked */
396
397 /* align */
398 PAD(__len, 8);
399
400 __data = (uint8_t*)MALLOC(__len);
401 if (!__data)
402 return -ENOMEM;
403
404 WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_INFO_REPLY));
405 WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
406 WRITE(4, uint32_t, serial); /* serial */
407 WRITE(8, rbug_shader_t, vertex); /* vertex */
408 WRITE(8, rbug_shader_t, fragment); /* fragment */
409 WRITE_ARRAY(8, rbug_texture_t, texs); /* texs */
410 WRITE_ARRAY(8, rbug_texture_t, cbufs); /* cbufs */
411 WRITE(8, rbug_texture_t, zsbuf); /* zsbuf */
412 WRITE(4, rbug_block_t, blocker); /* blocker */
413 WRITE(4, rbug_block_t, blocked); /* blocked */
414
415 /* final pad */
416 PAD(__pos, 8);
417
418 if (__pos != __len) {
419 __ret = -EINVAL;
420 } else {
421 rbug_connection_send_start(__con, RBUG_OP_CONTEXT_INFO_REPLY, __len);
422 rbug_connection_write(__con, __data, __len);
423 __ret = rbug_connection_send_finish(__con, __serial);
424 }
425
426 FREE(__data);
427 return __ret;
428 }
429
430 int rbug_send_context_draw_blocked(struct rbug_connection *__con,
431 rbug_context_t context,
432 rbug_block_t block,
433 uint32_t *__serial)
434 {
435 uint32_t __len = 0;
436 uint32_t __pos = 0;
437 uint8_t *__data = NULL;
438 int __ret = 0;
439
440 LEN(8); /* header */
441 LEN(8); /* context */
442 LEN(4); /* block */
443
444 /* align */
445 PAD(__len, 8);
446
447 __data = (uint8_t*)MALLOC(__len);
448 if (!__data)
449 return -ENOMEM;
450
451 WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_BLOCKED));
452 WRITE(4, uint32_t, ((uint32_t)(__len / 4)));
453 WRITE(8, rbug_context_t, context); /* context */
454 WRITE(4, rbug_block_t, block); /* block */
455
456 /* final pad */
457 PAD(__pos, 8);
458
459 if (__pos != __len) {
460 __ret = -EINVAL;
461 } else {
462 rbug_connection_send_start(__con, RBUG_OP_CONTEXT_DRAW_BLOCKED, __len);
463 rbug_connection_write(__con, __data, __len);
464 __ret = rbug_connection_send_finish(__con, __serial);
465 }
466
467 FREE(__data);
468 return __ret;
469 }
470
471 struct rbug_proto_context_list * rbug_demarshal_context_list(struct rbug_proto_header *header)
472 {
473 uint32_t len = 0;
474 uint32_t pos = 0;
475 uint8_t *data = NULL;
476 struct rbug_proto_context_list *ret;
477
478 if (!header)
479 return NULL;
480 if (header->opcode != (int32_t)RBUG_OP_CONTEXT_LIST)
481 return NULL;
482
483 pos = 0;
484 len = header->length * 4;
485 data = (uint8_t*)&header[1];
486 ret = MALLOC(sizeof(*ret));
487 if (!ret)
488 return NULL;
489
490 ret->header.__message = header;
491 ret->header.opcode = header->opcode;
492
493
494 return ret;
495 }
496
497 struct rbug_proto_context_info * rbug_demarshal_context_info(struct rbug_proto_header *header)
498 {
499 uint32_t len = 0;
500 uint32_t pos = 0;
501 uint8_t *data = NULL;
502 struct rbug_proto_context_info *ret;
503
504 if (!header)
505 return NULL;
506 if (header->opcode != (int32_t)RBUG_OP_CONTEXT_INFO)
507 return NULL;
508
509 pos = 0;
510 len = header->length * 4;
511 data = (uint8_t*)&header[1];
512 ret = MALLOC(sizeof(*ret));
513 if (!ret)
514 return NULL;
515
516 ret->header.__message = header;
517 ret->header.opcode = header->opcode;
518
519 READ(8, rbug_context_t, context); /* context */
520
521 return ret;
522 }
523
524 struct rbug_proto_context_draw_block * rbug_demarshal_context_draw_block(struct rbug_proto_header *header)
525 {
526 uint32_t len = 0;
527 uint32_t pos = 0;
528 uint8_t *data = NULL;
529 struct rbug_proto_context_draw_block *ret;
530
531 if (!header)
532 return NULL;
533 if (header->opcode != (int32_t)RBUG_OP_CONTEXT_DRAW_BLOCK)
534 return NULL;
535
536 pos = 0;
537 len = header->length * 4;
538 data = (uint8_t*)&header[1];
539 ret = MALLOC(sizeof(*ret));
540 if (!ret)
541 return NULL;
542
543 ret->header.__message = header;
544 ret->header.opcode = header->opcode;
545
546 READ(8, rbug_context_t, context); /* context */
547 READ(4, rbug_block_t, block); /* block */
548
549 return ret;
550 }
551
552 struct rbug_proto_context_draw_step * rbug_demarshal_context_draw_step(struct rbug_proto_header *header)
553 {
554 uint32_t len = 0;
555 uint32_t pos = 0;
556 uint8_t *data = NULL;
557 struct rbug_proto_context_draw_step *ret;
558
559 if (!header)
560 return NULL;
561 if (header->opcode != (int32_t)RBUG_OP_CONTEXT_DRAW_STEP)
562 return NULL;
563
564 pos = 0;
565 len = header->length * 4;
566 data = (uint8_t*)&header[1];
567 ret = MALLOC(sizeof(*ret));
568 if (!ret)
569 return NULL;
570
571 ret->header.__message = header;
572 ret->header.opcode = header->opcode;
573
574 READ(8, rbug_context_t, context); /* context */
575 READ(4, rbug_block_t, step); /* step */
576
577 return ret;
578 }
579
580 struct rbug_proto_context_draw_unblock * rbug_demarshal_context_draw_unblock(struct rbug_proto_header *header)
581 {
582 uint32_t len = 0;
583 uint32_t pos = 0;
584 uint8_t *data = NULL;
585 struct rbug_proto_context_draw_unblock *ret;
586
587 if (!header)
588 return NULL;
589 if (header->opcode != (int32_t)RBUG_OP_CONTEXT_DRAW_UNBLOCK)
590 return NULL;
591
592 pos = 0;
593 len = header->length * 4;
594 data = (uint8_t*)&header[1];
595 ret = MALLOC(sizeof(*ret));
596 if (!ret)
597 return NULL;
598
599 ret->header.__message = header;
600 ret->header.opcode = header->opcode;
601
602 READ(8, rbug_context_t, context); /* context */
603 READ(4, rbug_block_t, unblock); /* unblock */
604
605 return ret;
606 }
607
608 struct rbug_proto_context_draw_rule * rbug_demarshal_context_draw_rule(struct rbug_proto_header *header)
609 {
610 uint32_t len = 0;
611 uint32_t pos = 0;
612 uint8_t *data = NULL;
613 struct rbug_proto_context_draw_rule *ret;
614
615 if (!header)
616 return NULL;
617 if (header->opcode != (int32_t)RBUG_OP_CONTEXT_DRAW_RULE)
618 return NULL;
619
620 pos = 0;
621 len = header->length * 4;
622 data = (uint8_t*)&header[1];
623 ret = MALLOC(sizeof(*ret));
624 if (!ret)
625 return NULL;
626
627 ret->header.__message = header;
628 ret->header.opcode = header->opcode;
629
630 READ(8, rbug_context_t, context); /* context */
631 READ(8, rbug_shader_t, vertex); /* vertex */
632 READ(8, rbug_shader_t, fragment); /* fragment */
633 READ(8, rbug_texture_t, texture); /* texture */
634 READ(8, rbug_texture_t, surface); /* surface */
635 READ(4, rbug_block_t, block); /* block */
636
637 return ret;
638 }
639
640 struct rbug_proto_context_flush * rbug_demarshal_context_flush(struct rbug_proto_header *header)
641 {
642 uint32_t len = 0;
643 uint32_t pos = 0;
644 uint8_t *data = NULL;
645 struct rbug_proto_context_flush *ret;
646
647 if (!header)
648 return NULL;
649 if (header->opcode != (int32_t)RBUG_OP_CONTEXT_FLUSH)
650 return NULL;
651
652 pos = 0;
653 len = header->length * 4;
654 data = (uint8_t*)&header[1];
655 ret = MALLOC(sizeof(*ret));
656 if (!ret)
657 return NULL;
658
659 ret->header.__message = header;
660 ret->header.opcode = header->opcode;
661
662 READ(8, rbug_context_t, context); /* context */
663
664 return ret;
665 }
666
667 struct rbug_proto_context_list_reply * rbug_demarshal_context_list_reply(struct rbug_proto_header *header)
668 {
669 uint32_t len = 0;
670 uint32_t pos = 0;
671 uint8_t *data = NULL;
672 struct rbug_proto_context_list_reply *ret;
673
674 if (!header)
675 return NULL;
676 if (header->opcode != (int32_t)RBUG_OP_CONTEXT_LIST_REPLY)
677 return NULL;
678
679 pos = 0;
680 len = header->length * 4;
681 data = (uint8_t*)&header[1];
682 ret = MALLOC(sizeof(*ret));
683 if (!ret)
684 return NULL;
685
686 ret->header.__message = header;
687 ret->header.opcode = header->opcode;
688
689 READ(4, uint32_t, serial); /* serial */
690 READ_ARRAY(8, rbug_context_t, contexts); /* contexts */
691
692 return ret;
693 }
694
695 struct rbug_proto_context_info_reply * rbug_demarshal_context_info_reply(struct rbug_proto_header *header)
696 {
697 uint32_t len = 0;
698 uint32_t pos = 0;
699 uint8_t *data = NULL;
700 struct rbug_proto_context_info_reply *ret;
701
702 if (!header)
703 return NULL;
704 if (header->opcode != (int32_t)RBUG_OP_CONTEXT_INFO_REPLY)
705 return NULL;
706
707 pos = 0;
708 len = header->length * 4;
709 data = (uint8_t*)&header[1];
710 ret = MALLOC(sizeof(*ret));
711 if (!ret)
712 return NULL;
713
714 ret->header.__message = header;
715 ret->header.opcode = header->opcode;
716
717 READ(4, uint32_t, serial); /* serial */
718 READ(8, rbug_shader_t, vertex); /* vertex */
719 READ(8, rbug_shader_t, fragment); /* fragment */
720 READ_ARRAY(8, rbug_texture_t, texs); /* texs */
721 READ_ARRAY(8, rbug_texture_t, cbufs); /* cbufs */
722 READ(8, rbug_texture_t, zsbuf); /* zsbuf */
723 READ(4, rbug_block_t, blocker); /* blocker */
724 READ(4, rbug_block_t, blocked); /* blocked */
725
726 return ret;
727 }
728
729 struct rbug_proto_context_draw_blocked * rbug_demarshal_context_draw_blocked(struct rbug_proto_header *header)
730 {
731 uint32_t len = 0;
732 uint32_t pos = 0;
733 uint8_t *data = NULL;
734 struct rbug_proto_context_draw_blocked *ret;
735
736 if (!header)
737 return NULL;
738 if (header->opcode != (int32_t)RBUG_OP_CONTEXT_DRAW_BLOCKED)
739 return NULL;
740
741 pos = 0;
742 len = header->length * 4;
743 data = (uint8_t*)&header[1];
744 ret = MALLOC(sizeof(*ret));
745 if (!ret)
746 return NULL;
747
748 ret->header.__message = header;
749 ret->header.opcode = header->opcode;
750
751 READ(8, rbug_context_t, context); /* context */
752 READ(4, rbug_block_t, block); /* block */
753
754 return ret;
755 }