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 LOG_REGION(UI_LOG_BRS_NewDrawing, region);
76 #ifndef UI_FEATURE_BRS_FLUSH_SINGLE_RECTANGLE
78 ui_rect_t *previous = UI_RECT_COLLECTION_get_last(&dirty_regions);
79 if ((NULL == previous) || !UI_RECT_contains_rect(previous, region)) {
83 if (!UI_RECT_COLLECTION_is_full(&dirty_regions)) {
87 LLTRACE_record_event_void(LLUI_EVENT_group, LLUI_EVENT_offset + UI_LOG_BRS_ClearList);
88 UI_RECT_COLLECTION_clear(&dirty_regions);
89 new_region = UI_RECT_new_xyxy(0, 0, gc->image.width - 1, gc->image.height - 1);
91 LOG_REGION(UI_LOG_BRS_AddRegion, &new_region);
92 UI_RECT_COLLECTION_add_rect(&dirty_regions, new_region);
97 flush_bounds.x1 = MIN(flush_bounds.x1, region->x1);
98 flush_bounds.y1 = MIN(flush_bounds.y1, region->y1);
99 flush_bounds.x2 = MAX(flush_bounds.x2, region->x2);
100 flush_bounds.y2 = MAX(flush_bounds.y2, region->y2);
112 DRAWING_Status LLUI_DISPLAY_IMPL_refresh(MICROUI_GraphicsContext *gc, uint8_t flushIdentifier) {
113 #ifndef UI_FEATURE_BRS_FLUSH_SINGLE_RECTANGLE
115 size_t size = UI_RECT_COLLECTION_get_length(&dirty_regions);
117 ui_rect_t *rect = &dirty_regions.data[0];
118 LLTRACE_record_event_u32x6(LLUI_EVENT_group, LLUI_EVENT_offset + UI_LOG_BRS_FlushSingle, flushIdentifier,
119 (uint32_t)LLUI_DISPLAY_getBufferAddress(&gc->image), rect->x1, rect->y1, rect->x2,
122 LLTRACE_record_event_u32x3(LLUI_EVENT_group, LLUI_EVENT_offset + UI_LOG_BRS_FlushMulti, flushIdentifier,
123 (uint32_t)LLUI_DISPLAY_getBufferAddress(&gc->image), size);
126 LLUI_DISPLAY_IMPL_flush(gc, flushIdentifier, dirty_regions.data, UI_RECT_COLLECTION_get_length(&dirty_regions));
127 UI_RECT_COLLECTION_clear(&dirty_regions);
131 LLTRACE_record_event_u32x6(LLUI_EVENT_group, LLUI_EVENT_offset + UI_LOG_BRS_FlushSingle, flushIdentifier,
132 (uint32_t)LLUI_DISPLAY_getBufferAddress(&gc->image), flush_bounds.x1, flush_bounds.y1,
133 flush_bounds.x2, flush_bounds.y2);
136 LLUI_DISPLAY_IMPL_flush(gc, flushIdentifier, &flush_bounds, 1);
139 flush_bounds.x1 = INT16_MAX;
140 flush_bounds.y1 = INT16_MAX;