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