Graphics

The Graphics subsystem mainly consists of user interface (UI) components, layout, animator, font, input event, window management, and rendering and drawing modules. It is an application framework that can be built on the LiteOS to develop OpenHarmony applications for Internet of Things (IoT) devices with limited hardware resources or on the standard OS to develop OpenHarmony applications for standard- and large-system devices (for example, tablet and lite smart devices).

1.1 Mini System

Introduction

The Graphics subsystem mainly consists of user interface (UI) components, layout, animator, font, input event, window management, and rendering and drawing modules. It is an application framework that can be built on the LiteOS to develop OpenHarmony applications for Internet of Things (IoT) devices with limited hardware resources.

Figure 1 Graphics subsystem architecture

The related modules are described as follows:

  • View: provides application components, including UIView, UIViewGoup, UIButton, UILabel, UILabelButton, UIList, and UISlider.
  • Animator: defines functions for customizing animators.
  • Layout: lays out components, including Flexlayout, GridLayout, and ListLayout.
  • Transform: rotates, translates, or scales images.
  • Event: processes basic events, including click, press, drag, and long press events.
  • Rendering engine: performs rendering and drawing operations.
  • 2D graphics library: draws 2D graphical elements including lines, rectangles, circles, arcs, images, and texts. Functions of this module include software drawing and hardware acceleration capability interconnection.
  • Multi-language: processes the line feed and shaping of texts in different languages.
  • Image library: parses and operates images of different types and formats, such as PNG, JPEG, ARGB8888, and ARGB565.
  • WindowManager: manages windows, including creating, showing, hiding a window, and combining windows.
  • InputManager: processes input events.

Directory Structure

/foundation/graphic
├── surface  # Shared memory
├── ui       # UI module, including UI components, animations, and fonts.
├── utils    # Basic graphics library and hardware adaptation layer
└── wms      # Window and input event management

Constraints

  • The Graphics subsystem does not support multi-thread concurrent operations. You are advised to perform related operations in UI threads.
  • The utils/interfaces/innerkits/graphic_config.h file provides the configuration information about macro switches that can be used to enable or disable graphics features. You need to configure these switches before compilation. Note that some switches are configured depending on the platform.

Usage

For details, see the README and test directory of each repository.

Repositories Involved

Graphics subsystem

graphic_surface

graphic_ui

graphic_wms

graphic_utils

1.2 Standard System

Introduction

The Graphics subsystem provides graphics APIs and window management capabilities, which can be invoked by using Java or JS APIs. It is applicable to all devices that run the standard system.

The following figure shows the architecture of the Graphics subsystem.

  • Surface

    Provides APIs for managing the graphics buffer and the efficient and convenient rotation buffer.

  • Vsync

    Provides APIs for managing registration and response of all vertical sync signals.

  • WindowManager

    Provides APIs for creating and managing windows.

  • WaylandProtocols

    Provides the communication protocols between the window manager and synthesizer.

  • Compositor

    Implements synthesis of layers.

  • Renderer

    Functions as the back-end rendering module of the synthesizer.

  • Wayland protocols

    Provides Wayland inter-process communication protocols.

  • Shell

    Provides multi-window capabilities.

  • Input Manger

    Functions as the multimodal input module that receives input events.

Directory Structure

foundation/graphic/standard/
├── frameworks              # Framework code
│   ├── bootanimation       # BootAnimation code
│   ├── surface             # Surface code
│   ├── vsync               # Vsync code
│   └── wm                  # WindowManager code
├── interfaces              # External APIs
│   ├── innerkits           # Native APIs
│   └── kits                # JS APIs and NAPIs
└── utils                   # Utilities

Constraints

Language version: C++ 11 or later

Compilation and Building

The dependent APIs include the following:

  • graphic_standard:libwms_client
  • graphic_standard:libsurface
  • graphic_standard:libvsync_client

Usage

For details, see the README and test directory of each repository.

Repositories Involved

Graphics subsystem

graphic_standard

ace_ace_engine

aafwk_standard

multimedia_media_standard

multimedia_camera_standard