|
32 | 32 |
|
33 | 33 | UFontManager *ufont_manager; |
34 | 34 |
|
| 35 | +static bool try_pre_ack_render_cmd(Message *message, Context *ctx) |
| 36 | +{ |
| 37 | + GenMessage gen_message; |
| 38 | + if (UNLIKELY(port_parse_gen_message(message->message, |
| 39 | + &gen_message) != GenCallMessage)) { |
| 40 | + return false; |
| 41 | + } |
| 42 | + |
| 43 | + term req = gen_message.req; |
| 44 | + if (UNLIKELY(!term_is_tuple(req) || term_get_tuple_arity(req) < 1)) { |
| 45 | + return false; |
| 46 | + } |
| 47 | + term cmd = term_get_tuple_element(req, 0); |
| 48 | + |
| 49 | + if (cmd != globalcontext_make_atom(ctx->global, "\x6" "update") |
| 50 | + && cmd != globalcontext_make_atom(ctx->global, |
| 51 | + "\xB" "draw_buffer")) { |
| 52 | + return false; |
| 53 | + } |
| 54 | + |
| 55 | + BEGIN_WITH_STACK_HEAP(TUPLE_SIZE(2) + REF_SIZE, heap); |
| 56 | + term return_tuple = term_alloc_tuple(2, &heap); |
| 57 | + term_put_tuple_element(return_tuple, 0, gen_message.ref); |
| 58 | + term_put_tuple_element(return_tuple, 1, OK_ATOM); |
| 59 | + display_message_send(gen_message.pid, return_tuple, ctx->global); |
| 60 | + END_WITH_STACK_HEAP(heap, ctx->global); |
| 61 | + |
| 62 | + return true; |
| 63 | +} |
| 64 | + |
35 | 65 | NativeHandlerResult display_task_consume_mailbox(Context *ctx) |
36 | 66 | { |
37 | 67 | struct DisplayTaskArgs *args = ctx->platform_data; |
38 | 68 |
|
39 | 69 | MailboxMessage *mbox_msg = mailbox_take_message(&ctx->mailbox); |
40 | 70 | Message *msg = CONTAINER_OF(mbox_msg, Message, base); |
41 | 71 |
|
| 72 | + // Pre-ack update / draw_buffer before the enqueue-or-drop |
| 73 | + // dance so the caller doesn't time out if dropped. |
| 74 | + try_pre_ack_render_cmd(msg, ctx); |
| 75 | + |
42 | 76 | // Non-blocking enqueue; drop oldest on overflow. |
43 | 77 | if (xQueueSend(args->messages_queue, &msg, 0) != pdTRUE) { |
44 | 78 |
|
|
0 commit comments