16 #include "ui_display_brs.h"
17 #if defined UI_DISPLAY_BRS && UI_DISPLAY_BRS == UI_DISPLAY_BRS_SINGLE
23 #include "ui_rect_collection.h"
33 #if defined UI_DISPLAY_BRS_DRAWING_BUFFER_COUNT && UI_DISPLAY_BRS_DRAWING_BUFFER_COUNT != 1
34 #error "This strategy uses always the same back buffer."
41 #ifndef UI_DISPLAY_BRS_FLUSH_SINGLE_RECTANGLE
54 static ui_rect_t flush_bounds = {
72 DRAWING_Status LLUI_DISPLAY_IMPL_newDrawingRegion(MICROUI_GraphicsContext* gc, ui_rect_t* region,
bool drawing_now) {
75 LOG_REGION(UI_LOG_BRS_NewDrawing, region);
77 #ifndef UI_DISPLAY_BRS_FLUSH_SINGLE_RECTANGLE
79 ui_rect_t* previous = UI_RECT_COLLECTION_get_last(&dirty_regions);
80 if ((NULL == previous) || !UI_RECT_contains_rect(previous, region)){
84 if (!UI_RECT_COLLECTION_is_full(&dirty_regions)) {
89 LLTRACE_record_event_void(LLUI_EVENT_group, LLUI_EVENT_offset + UI_LOG_BRS_ClearList);
90 UI_RECT_COLLECTION_clear(&dirty_regions);
91 new_region = UI_RECT_new_xyxy(0, 0, gc->image.width - 1, gc->image.height - 1);
93 LOG_REGION(UI_LOG_BRS_AddRegion, &new_region);
94 UI_RECT_COLLECTION_add_rect(&dirty_regions, new_region);
99 flush_bounds.x1 = MIN(flush_bounds.x1, region->x1);
100 flush_bounds.y1 = MIN(flush_bounds.y1, region->y1);
101 flush_bounds.x2 = MAX(flush_bounds.x2, region->x2);
102 flush_bounds.y2 = MAX(flush_bounds.y2, region->y2);
114 DRAWING_Status LLUI_DISPLAY_IMPL_refresh(MICROUI_GraphicsContext* gc, uint8_t flushIdentifier) {
116 #ifndef UI_DISPLAY_BRS_FLUSH_SINGLE_RECTANGLE
118 size_t size = UI_RECT_COLLECTION_get_length(&dirty_regions);
120 ui_rect_t* rect = &dirty_regions.data[0];
121 LLTRACE_record_event_u32x6(LLUI_EVENT_group, LLUI_EVENT_offset + UI_LOG_BRS_FlushSingle, flushIdentifier, (uint32_t)LLUI_DISPLAY_getBufferAddress(&gc->image), rect->x1, rect->y1, rect->x2, rect->y2);
124 LLTRACE_record_event_u32x3(LLUI_EVENT_group, LLUI_EVENT_offset + UI_LOG_BRS_FlushMulti, flushIdentifier, (uint32_t)LLUI_DISPLAY_getBufferAddress(&gc->image), size);
127 LLUI_DISPLAY_IMPL_flush(gc, flushIdentifier, dirty_regions.data, UI_RECT_COLLECTION_get_length(&dirty_regions));
128 UI_RECT_COLLECTION_clear(&dirty_regions);
132 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);
135 LLUI_DISPLAY_IMPL_flush(gc, flushIdentifier, &flush_bounds, 1);
138 flush_bounds.x1 = INT16_MAX;
139 flush_bounds.y1 = INT16_MAX;