microui  14.5.5
microui
Functions
ui_display_brs.h File Reference

Provides some implementations of the LLUI_DISPLAY_impl.h functions relating to the display buffer strategy (BRS). More...

#include <LLUI_DISPLAY_impl.h>
#include "ui_util.h"
#include "ui_configuration.h"
#include "ui_trace.h"

Go to the source code of this file.

Functions

DRAWING_Status UI_DISPLAY_BRS_restore (MICROUI_GraphicsContext *gc, MICROUI_Image *old_back_buffer, ui_rect_t *rect)
 Restores (copies) the given rectangular region from old back buffer to the graphics context's current buffer (the destination buffer can be retrieved thanks LLUI_DISPLAY_getBufferAddress(&gc->image)). More...
 

Detailed Description

Provides some implementations of the LLUI_DISPLAY_impl.h functions relating to the display buffer strategy (BRS).

A BRS

Several BRS are available in ui_configuration.h (the implementation has to select one of them).

Author
MicroEJ Developer Team
Version
14.5.5

Definition in file ui_display_brs.h.

Function Documentation

◆ UI_DISPLAY_BRS_restore()

DRAWING_Status UI_DISPLAY_BRS_restore ( MICROUI_GraphicsContext *  gc,
MICROUI_Image *  old_back_buffer,
ui_rect_t *  rect 
)

Restores (copies) the given rectangular region from old back buffer to the graphics context's current buffer (the destination buffer can be retrieved thanks LLUI_DISPLAY_getBufferAddress(&gc->image)).

When the copy is synchronous (immediate), the implementation has to return DRAWING_DONE. When the copy is asynchronous (performed by a DMA for instance), the the implementation has to return DRAWING_RUNNING. As the end of the asynchronous copy, the implementation has to call LLUI_DISPLAY_notifyAsynchronousDrawingEnd() to unlock the caller of this function.

The implementation of this function is optional; a weak function provides a simple implementation using memcpy().

Parameters
[in]gcthe MicroUI GraphicsContext that targets the current back buffer
[in]old_back_buffera MicroUI Image that symbolizes (targets) the old back buffer.
[in]rectthe rectangular region to copy from old back buffer to new back buffer.
Returns
the drawing status.

Definition at line 33 of file ui_display_brs.c.

34  {
35  DRAWING_Status ret;
36  uint32_t bpp = LLUI_DISPLAY_getImageBPP(old_back_buffer);
37  uint32_t width = UI_RECT_get_width(rect);
38  uint32_t height = UI_RECT_get_height(rect);
39 
40  if (8u > bpp) {
41  // this weak function is not designed to target this kind of buffer
42  // -> let the standard function copyImage() performing the job
43  ret = UI_DRAWING_copyImage(gc, old_back_buffer, rect->x1, rect->y1, width, height, rect->x1, rect->y1);
44  } else {
45  uint8_t *dst = LLUI_DISPLAY_getBufferAddress(&gc->image);
46  uint8_t *src = LLUI_DISPLAY_getBufferAddress(old_back_buffer);
47  uint32_t stride = LLUI_DISPLAY_getStrideInBytes(&gc->image);
48 
49  dst += rect->y1 * stride;
50  src += rect->y1 * stride;
51 
52  if ((0 == rect->x1) && (old_back_buffer->width == width)) {
53  // a simple memcpy is required!
54  (void)memcpy(dst, src, stride * height);
55  } else {
56  // have to perform one memcpy per line
57  dst += rect->x1 * bpp / 8u;
58  src += rect->x1 * bpp / 8u;
59  uint32_t size = width * bpp / 8u;
60 
61  for (uint32_t y = 0; y < height; y++) {
62  (void)memcpy(dst, src, size);
63  dst += stride;
64  src += stride;
65  }
66  }
67 
68  // the memcpy() above draws in the back buffer with the CPU, so it is notified like any other
69  // software drawing: on a VEE port whose buffers sit in a cached memory, the next drawing may be a
70  // GPU one and it has to flush the cache first. The bpp < 8 branch above needs no notification:
71  // UI_DRAWING_copyImage() notifies by itself when it falls back to software.
72  LLUI_DISPLAY_IMPL_notifyDrawingSoft(gc);
73 
74  ret = DRAWING_DONE;
75  }
76  return ret;
77 }