Graphics Subsystem

Overview

The graphics subsystem mainly includes user interface (UI) components, layout, animator, font, input event, window management, rendering and drawing modules. It builds an application framework based on the LiteOS to develop applications on Internet of Things (IoT) devices with small hardware resources.

Module description:

  • Components: provides application components, including the UIView, UIViewGoup, UIButton, UILabel, UILabelButton, UIList, and UISlider.
  • Layout: lays out components, including Flexlayout, GridLayout, and ListLayout.
  • Animator: defines functions for customizing animators.
  • Fonts: defines functions related to fonts.
  • Event: processes basic events, including click, press, drag, and long press.
  • Tasks: manages tasks.
  • Input: processes input events.
  • Display: processes display events.
  • Render: renders and draws components.
  • Draw2d: draws lines, rectangles, circles, arcs, images, and texts, and connects to platforms and devices with software rendering and hardware acceleration capabilities.
  • Surface: applies for and releases shared memory.
  • Window: manages windows, including creating, showing, hiding a window, and combining windows.
  • Adapter: connects to underlying interfaces of the adaptation layer.

Directory Structure

Table 1 Source code directory structure of the graphics subsystem

Directory

Description

config

Configuration files

frameworks/surface

Shared memory

frameworks/ui

UI module, which defines functions related to UI components, animators and fonts

hals

Hardware abstraction layer (HAL) logic

interfaces/ui

Header files of open APIs related to the UI module

interfaces/utils

Header files of utils for the graphics subsystem

services/ims

Input event management, including processing and distributing input events such as click and press

services/wms

Window management, including creating, managing, and combining windows

utils

Public library of the graphics subsystem

Constraints

  • Language version

    • C++ 11 or later
  • The specifications of the application framework vary depending on the System-on-a-Chip (SoC) and underlying OS capabilities.

    • Cortex-M RAM and ROM:

      • RAM: greater than 100 KB (recommended)
      • ROM: greater than 300 KB
    • Cortex-A RAM/ROM:

      • RAM: greater than 1 MB (recommended)
      • ROM: greater than 1 MB

Adding a UI Component

All components inherit from the base class UIView and share common attributes and styles. UI components are classified into common and container ones. You can add child components for a container component, but not for a common component.

Store new header files in the interfaces/ui/components directory and .cpp files in the frameworks/ui/src/components directory. Override OnDraw function to draw this UI component. Add the new file to the frameworks/ui/BUILD.gn directory and it will be compiled to libui.so during building.

Repositories Involved

graphic_utils

graphic_wms

graphic_surface

graphic_ui