15 #include "ui_display_brs.h"
16 #if defined UI_FEATURE_BRS && UI_FEATURE_BRS == UI_FEATURE_BRS_SINGLE
22 #include "ui_rect_collection.h"
32 #if defined UI_FEATURE_BRS_DRAWING_BUFFER_COUNT && UI_FEATURE_BRS_DRAWING_BUFFER_COUNT != 1
33 #error "This strategy uses always the same back buffer."
40 #ifndef UI_FEATURE_BRS_FLUSH_SINGLE_RECTANGLE
53 static ui_rect_t flush_bounds = {
71 DRAWING_Status LLUI_DISPLAY_IMPL_newDrawingRegion(MICROUI_GraphicsContext *gc, ui_rect_t *region,
bool drawing_now) {
74 #ifndef UI_FEATURE_BRS_FLUSH_SINGLE_RECTANGLE
76 ui_rect_t *previous = UI_RECT_COLLECTION_get_last(&dirty_regions);
77 if ((NULL == previous) || !UI_RECT_contains_rect(previous, region)) {
81 if (!UI_RECT_COLLECTION_is_full(&dirty_regions)) {
85 UI_RECT_COLLECTION_clear(&dirty_regions);
86 new_region = UI_RECT_new_xyxy(0, 0, gc->image.width - 1, gc->image.height - 1);
88 UI_RECT_COLLECTION_add_rect(&dirty_regions, new_region);
93 flush_bounds.x1 = MIN(flush_bounds.x1, region->x1);
94 flush_bounds.y1 = MIN(flush_bounds.y1, region->y1);
95 flush_bounds.x2 = MAX(flush_bounds.x2, region->x2);
96 flush_bounds.y2 = MAX(flush_bounds.y2, region->y2);
108 DRAWING_Status LLUI_DISPLAY_IMPL_refresh(MICROUI_GraphicsContext *gc, uint8_t flushIdentifier) {
109 #ifndef UI_FEATURE_BRS_FLUSH_SINGLE_RECTANGLE
111 size_t size = UI_RECT_COLLECTION_get_length(&dirty_regions);
113 ui_rect_t *rect = &dirty_regions.data[0];
114 UI_LOG_START(BRS_FlushSingle, flushIdentifier, UI_LOG_BUFFER(&gc->image), rect->x1, rect->y1, UI_RECT_get_width(rect),
115 UI_RECT_get_height(rect));
117 UI_LOG_START(BRS_FlushMulti, flushIdentifier, UI_LOG_BUFFER(&gc->image), size);
120 LLUI_DISPLAY_IMPL_flush(gc, flushIdentifier, dirty_regions.data, UI_RECT_COLLECTION_get_length(&dirty_regions));
121 UI_RECT_COLLECTION_clear(&dirty_regions);
125 UI_LOG_START(BRS_FlushSingle, flushIdentifier, UI_LOG_BUFFER(&gc->image), flush_bounds.x1, flush_bounds.y1,
126 UI_RECT_get_width(&flush_bounds), UI_RECT_get_height(&flush_bounds));
129 LLUI_DISPLAY_IMPL_flush(gc, flushIdentifier, &flush_bounds, 1);
132 flush_bounds.x1 = INT16_MAX;
133 flush_bounds.y1 = INT16_MAX;