microui  4.0.0
microui
ui_display_brs_legacy.c
1 
2 /*
3  * Copyright 2023-2024 MicroEJ Corp. All rights reserved.
4  * Use of this source code is governed by a BSD-style license that can be found with this software.
5  */
6 
7 /*
8  * @file
9  * @brief This file implements all the LLUI_DISPLAY_impl.h functions relating to the
10  * display buffer strategy (BRS) "legacy"
11  * @see UI_DISPLAY_BRS_LEGACY comment
12  * @author MicroEJ Developer Team
13  * @version 4.0.0
14  */
15 
16 #include "ui_display_brs.h"
17 #if defined UI_DISPLAY_BRS && UI_DISPLAY_BRS == UI_DISPLAY_BRS_LEGACY
18 
19 // --------------------------------------------------------------------------------
20 // Private fields
21 // --------------------------------------------------------------------------------
22 
23 static ui_rect_t flush_bounds = {
24  .x1 = INT16_MAX,
25  .y1 = INT16_MAX,
26  .x2 = 0,
27  .y2 = 0,
28 };
29 
30 // --------------------------------------------------------------------------------
31 // LLUI_DISPLAY_impl.h API
32 // --------------------------------------------------------------------------------
33 
34 // See the header file for the function documentation
35 DRAWING_Status LLUI_DISPLAY_IMPL_newDrawingRegion(MICROUI_GraphicsContext* gc, ui_rect_t* region, bool drawing_now) {
36  (void)gc;
37  (void)drawing_now;
38  flush_bounds.x1 = MIN(flush_bounds.x1, region->x1);
39  flush_bounds.y1 = MIN(flush_bounds.y1, region->y1);
40  flush_bounds.x2 = MAX(flush_bounds.x2, region->x2);
41  flush_bounds.y2 = MAX(flush_bounds.y2, region->y2);
42  return DRAWING_DONE;
43 }
44 
45 DRAWING_Status LLUI_DISPLAY_IMPL_refresh(MICROUI_GraphicsContext* gc, uint8_t flushIdentifier) {
46 
47  LLTRACE_record_event_u32x6(LLUI_EVENT_group, LLUI_EVENT_offset + UI_LOG_BRS_FlushSingle, flushIdentifier, (uint32_t)LLUI_DISPLAY_getBufferAddress(&gc->image), flush_bounds.x1, flush_bounds.y1, flush_bounds.x2, flush_bounds.y2);
48 
49  LLUI_DISPLAY_IMPL_flush(gc, flushIdentifier, &flush_bounds, 1);
50 
51  // reset flush bounds to no flush again if there is no drawing until next flush
52  flush_bounds.x1 = INT16_MAX;
53  flush_bounds.y1 = INT16_MAX;
54  flush_bounds.x2 = 0;
55  flush_bounds.y2 = 0;
56 
57  return DRAWING_DONE;
58 }
59 
60 // --------------------------------------------------------------------------------
61 // EOF
62 // --------------------------------------------------------------------------------
63 
64 #endif // UI_DISPLAY_BRS_LEGACY