MINIGUI and other embedded Linux graphics and graphical user interface systems

zhaozj2021-02-16  59

Wei Yongming (YMWei@miniGui.org)

Freelance writer November 2001

In order to make the reader have a more comprehensive understanding of the graphics and graphical user interfaces that can be used in embedded Linux, this article will introduce the readers to the common graphics and graphical user interface systems in the embedded Linux system, and as "Based on Linux and MiniGUI The last article of the Embedded System Software Development Guide series. This article first outlines the basic facilities in the Linux graphics, and then describes some advanced graphics libraries that can be used in embedded Linux systems and graphical user interface support systems, and probably compare the advantages and disadvantages of these systems. I hope to help the development of embedded Linux systems.

1 The infrastructure in the Linux graphics This section first describes the infrastructure common in the Linux graphics field to the reader. The reason why the infrastructure is called the infrastructure because these systems (or "libraries), generally used as the basic function library of other advanced graphics or graphics applications. These systems (or "libraries) include: X Window, Svgalib, FrameBuffer, and more.

1.1 x Window Lifting the graphics on Linux, many people first think of X WINDOW. This system is a desktop graphics system in which the status is in the current class UNIX system. Undoubtedly, x window is successful as a graphic environment, which is running on a large number of applications including CAD modeling tools and office suits. However, it must be seen that due to the reason why X Window is on the system interface, its support capabilities for games and multimedia are limited. The user runs a VCD player on X WINDOW, or when running some large three-dimensional games, the same hardware configuration is often found, but it cannot obtain the same graphics effect as the Windows operating system - even if the accelerated X Server is used. It is not satisfactory. In addition, large applications (such as Mozilla browsers) are running at Running on X WINDOW, which is also quite unable to be satisfactory. Of course, there are problems with Linux kernels in process schedules, as well as the reason for x window.

X WINDOW provides DGA (Direct Graphics Access) extension to meet the requirements of graphics acceleration, with this extension, the application can directly access the frame buffer of the display card in full screen mode and can provide Support for some acceleration functions.

Tiny-X is a small implementation of XServer in an embedded system, which is developed by the Keith Packard of Xfree86 Core Team. Its goal is to run in a small memory system environment. Typical TINY-X Server size running on the X86 CPU is close to (less than) 1MB.

1.2 SvgalibSvgalib is the earliest non-x graphics support library in the Linux system. This library has been developed from the initial support of standard VGA compatible chips, has been developed to support for old-fashioned SVGA chips and support for today's popular high-grade video chips. It provides users with an interface on the console, allowing users to easily obtain graphics support on the PC compatible system. But the system has the following deficiencies:

The interface is messy. Svgalib has been developed from the initial VGALIB, and many interfaces have retained the old system, and these interfaces cannot meet the graphics capabilities of the new display chip. Failed to hide hardware details. Many operations cannot automatically use the accelerated capacity support of the display chip. Poor portability. Svgalib is currently only running on the X86 platform, and the support capabilities of other platforms are poor (except Alpha platform). Slowly develop, may be substituted by other graphics libraries. Svgalib acts as an old graphics support library, and the current application ranges less and smaller, especially after the Linux kernel adds FrameBuffer drive support, there is a sign of replacing other graphics libraries. Poor support for applications. Svaglib acts as a graphics library, support for advanced graphics, such as straight lines and curves, etc., but it is not satisfactory. Although svgalib has many shortcomings, SvGalib is often used by other graphics libraries to initialize the display mode of a particular chip, and obtain linear display memory (ie, frame buffers) that map to process address space, while other interfaces are very small. . In addition, the interface included in the svgalib, such as the keyboard, mouse, and joysticks, are rarely used by other applications. Therefore, SvGalib's use is less and less, and the author does not recommend the user to use this graphic library. Of course, if the user's display card only supports standard VGA mode, SvGalib is still a better choice.

1.3 FrameBufferFrameBuffer is a driver interface that appears in the 2.2.xx kernel. This interface will display the device as a frame buffer. The user can see it as an image of the memory. After mapping it to the process address space, the write operation can be directly read and write, and the write operation can immediately react on the screen. The device file of the driver is generally / DEV / FB0, / DEV / FB1, and the like. For example, suppose now the current display mode is 1024x768-8 color, you can empty the screen by the following command:

$ DD IF = / dev / zero of = / dev / fb0 BS = 1024 count = 768

In the application, the / dev / fb0 device is typically opened by mapping the FrameBuffer device to the process address space, such as the following program, and the address mapping is performed by the MMAP system call, and then clear the screen with MEMSET (here the display The pattern is 1024x768-8 bit color mode, linear memory mode):

INT FB; unsigned char * fb_mem; fb = open ("/ dev / fb0", o_rdwr); fb_mem = mmap (null, 1024 * 768, prot_read | prot_write, map_shared, fb, 0); MEMSET (FB_MEM, 0, 1024 * 768);

FrameBuffer devices also provide several ioctl commands, through these commands, some fixed information (such as display memory size), variable information related to display mode (such as resolution, pixel structure, each scan line) Width), as well as palette information in pseudo-color mode, etc.

With the FrameBuffer device, you can also get the type of acceleration display card supported by the kernel (obtained by fixed information), which is usually related to a particular display chip. For example, in the latest core (2.4.9), accelerated support for the popular display chip to S3, Matrox, NVIDIA, 3DFX, etc. After obtaining the accelerator chip type, the application can map the memory I / O (MEMIO) of the PCI device to the address space of the process. These MEMIOs are generally used to control the registers of the display card. By the operation of these registers, the application can control the acceleration function of a particular graphics card. The PCI device can map their own control registers to the physical memory space, and the access to these control registers will be accessed to physical memory. Therefore, these registers are also referred to as "MEMIO". Once you are mapped to physical memory, Linux's normal process can map these memory I / O to process address spaces through MMAP, so you can access these registers directly.

Of course, because different display chips have different acceleration capabilities, the use and definition of MEMIO is also different. At this time, different types of acceleration functions are required for different types of accelerator chips. For example, most chips provide hardware acceleration support for rectangular fillers, but different chip implementations are different. At this time, different chip types need to be written differently to complete fill rectangles.

Speaking here, the reader may have realized that FrameBuffer is just a device that provides memory and display chip registers from physical memory to process address space. Therefore, for the application, if you want to perform graphic programming on FrameBuffer, you will need to complete many other work. For example, FrameBuffer is like a canvas, what is the paint brush, how to draw, you need to do it yourself.

1.4 LibggilibGGI attempts to establish a general graphical interface, and this abstract interface along with the related input (mouse, keyboard, joystick, etc.), which can be easily running on X Window, Svgalib, FrameBuffer, etc. Buildings on Libggi, you can run on these underlying graphics interfaces without recompilation. But I don't know why, the development of libggi almost stagnant.

2 Advanced Libraries in Linux graphics

2.1 XLIB and other related function libraries When performing graphical programming in the X WINDOW system, you can choose to use the XLIB. XLIB is actually packaged for the underlying X protocol, which can be used through this function library. If your X Server supports DGA, you can access the display device through the DGA extension to access accelerated support. For general users, since XLIB's interface is too random and complex, the general graphics program selection other advanced graphics libraries are based. For example, gtk, qt, etc. These two functions are still some advanced graphical user interface supporting libraries. Due to various reasons, functions such as GTK and Qt are large, and the problem of more system resources is not suitable for use in embedded systems. At this time, you can choose to use FLTK, this is a lightweight graphics function library, but its main function is concentrated on the user interface, providing a relatively rich control set.

2.2 SDLSDL (Simple DirectMedia Layer) is a cross-platform multimedia game support library. It includes support for graphics, sound, joystick, thread, etc., which can be run on many platforms, including X Window, X Window with DGA, Linux FrameBuffer Console, Linux Svgalib, and Windows DirectX, BEOS, etc. . Because SDL is designed for games and multimedia applications, it supports graphics very good, especially advanced graphics capabilities, such as Alpha blend, transparent processing, YUV coverage, GAMMA correction, etc. Moreover, the MESA library that supports OpenGL can be easily loaded in the SDL environment to provide support for two-dimensional and 3D graphics.

It can be said that SDL is the best platform for writing cross-platform games and multimedia applications, but also has been widely used. Refer to http://www.libsdl.org to http://www.libsdl.org.

2.3 AllegroallegRo is a game graphic library designed for X86 platform. The initial Allegro runs in a DOS environment, and currently can run on Linux FrameBuff, Linux Svgalib, X Window and so on. Allegro provides some rich graphics features, including rectangular fills and spline generation, etc., and has better three-dimensional graphics display capabilities. Since many critical code of Allegro is written by assembly, the library has a fast running speed and less resource occupation. However, Allegro also has the following disadvantages:

Poor support for threads. Many functions of Allegro are non-threaded and cannot be used in more than two threads. Insufficient support for hardware acceleration capabilities, not providing interfaces for hardware acceleration in design.

For further information about Allegro, please refer to http://www.allegro.cc/.

2.4 MESA3DMESA3D is an open source function library compatible with OpenGL specification, which is the only choice for professional 3D graphics support on Linux. MESA3D is also a cross-platform library that can run on platforms such as X Window, X Window with DGA, BEOS, Linux Svgalib.

For further information on MESA3D, please refer to http://www.mesa3d.org/.

2.5 DirectFbDirectfb is a graphic library focusing on Linux FrameBuffer acceleration, and attempts to establish a embedded GUI system compatible with GTK. It provides support for accelerating FrameBuffer drivers in the situation of the loading functions library. Currently, the library is being developed (the latest version 0.9.97), see http://www.directfb.org/.

3 graphical user interface for embedded Linux systems

3.1 Microowindows / Nanoxmicrowindows (http://microwindows.censoft.com) is an open source project, currently developed by the US CENTURY SOFTWARE. The development of the project is very active, and some people have participated in the development and prepare the support of the character sets such as GB2312. But since QT / Embedded is released, the project has become less active and stays at 0.89pre7 version for a long time. It can be said that the MicroWindows project developed in an open source situation is basically stagnant.

MicroWindows is a GUI system based on a typical client / server architecture, which is basically divided into three layers. The bottom layer is a graphic output and a driver for a graphic output and a keyboard, a mouse or touch screen; the intermediate layer provides an abstract interface of the underlying hardware and performs window management; the highest layer provides a API compatible with X Window and Windows CE (Win32 subset). The main feature of the project is to provide a client / server architecture similar to X, and provide relatively complete graphics features, including some advanced features, such as Alpha mix, 3D support, TrueType font support, etc. However, it should be noted that there are many problems with MicroWindows graphics engines, which can be summarized as follows:

No hardware acceleration capabilities. There are many low-efficiency algorithms in the graphics engine, and without any optimization. For example, in a straight line or arc drawing function, there is a problem of inefficient point-by-point judgment cut. The code quality is poor. Since the project lacks a powerful core code maintenance personnel, the code quality is uneven, affecting the overall system stability. This is why MicroWindows stays on 0.89PRE7 for a long time.

MicroWindows is published in the MPL Terms (this Terms are basically similar to the LGPL Terms).

3.2 OpenGuiopengui (http://www.tutok.sk/fastgl/) There is a long time in the Linux system. The initial name is FastGL, only supporting 256 colors of linear memory mode, but other display modes are also supported, and multiple operating system platforms, such as MS-DOS, QNX, and Linux, etc., but currently only support X86 hardware platforms. OpenGUI is also divided into three layers. The lowest layer is a fast graphics engine written by assembly; the intermediate layer provides graphics to draw APIs, including lines, rectangles, arcs, etc., and compatible with BORLAND BGI API. The third layer is written in C , providing a complete GUI object set.

OpenGUI is published in the LGPL terms. OpenGUI is more suitable for real-time systems based on X86 platforms, which is slightly transplantability, and current development is basically stagnant.

3.3 QT / Embeddedqt / Embedded is a QT version of the embedded system published by the famous QT library developer Trolltech (http://www.trolltech.com/). Because QT is the GUI support library used by KDE and other items, there are many QT-based X Window programs that can be easily ported to QT / Embedded versions. Therefore, since QT / Embedded is released in the WTO policy, there is a large number of embedded Linux developers to the QT / Embedded system. For example, some embedded Linux applications developers in Taiwan, Taiwan Province.

However, in the opinion, QT / Embedded has some problems worthy of developers:

Currently, the system is published in two terms, including GPL terms. The GPL terms are used to the function library means that the application needs to follow the GPL terms. Of course, if you want to develop business programs, Trolltech also allows you to adopt another authorization terms. At this time, you must pay the licensing fee to Trolltech. Qt / Embedded is a C function library, although QT / Embedded claims to be cut to a minimum of 630K, but this time the QT / Embedded library has basically lost the value of use. Low program efficiency, large resource consumption also puts higher requirements for hardware running Qt / Embedded. The QT / Embedded library is currently mainly for hand-held information terminals because of the scarcity of hardware accelerated support, it is difficult to apply to embedded systems with higher graphics speed, function and efficiency requirements, such as set-top boxes, game terminals, and the like. The control set of QT / Embedded provides a PC style and is less suitable for many handheld devices. The structure of QT / Embedded is too complicated, it is difficult to carry out the underlying expansion, customization, and transplant, especially the famous MOC file used to implement the Signal / Slot mechanism. Because of the above reasons, the currently seen the QT / Embedded operating environment is almost a summary of Strongar-based IPAQ.

3.4 miniGuiminigui (http://www.miniGui.org) is hosted by the author and is supported by many free software developers (released by the LGPL Terms), and its goal is to provide Linux-based real-time embedded systems. A lightweight graphical user interface support system. The project has begun until the end of 1998, has been more than three years of development. So far, it is already very mature and stable. At present, we have officially released a stable version 1.0.9, and started the development of the new version of the series, that is, MINIGUI VERSION 1.1.x, the official version of this series is about to be released.

In the process of minigui's development, there are many technological innovations worth mentioning, which is because of these technological innovations, so that MiniGUI is more suitable for real-time embedded systems; and MiniGUI's flexibility is very good, it can be applied Among the various high-end or low-end embedded systems in handheld equipment, set-top boxes, game terminals, and the like. These technological innovations include:

Graphic abstract layer. The graphic abstraction layer has no effect on the top API, but it greatly facilitates the transfer, commissioning of the MiniGUI app. At present, three graphics engines, svgalib, libggi, and Native Engine directly Linux FrameBuffer, using libggi, can run the MiniGUI application on X WINDOW, and can be commissioned very conveniently. Abstract layers related to the graphic abstraction layer. MiniGUI has now been proven to be able to run smoothly on embedded systems based on ARM, MIPS, STRONGARM, and POWERPC. Multi-font and multi-character set support. This part is implemented by the logical font (DC) logical font (DC) of the device, whether it is a font type or a character set, can be expanded easily. The application can switch system character sets, such as GB, BIG5, EUCKR, UJIS. When using functions such as DrawText, other character set support can be obtained by specifying fonts. For a window, it is possible to display the text of different languages. This character set of MiniGUI supports unlike traditional multi-character set support implemented by Unicode, this implementation is more suitable for embedded systems. Two different architectures. The initial MiniGUI is running over the PThread library, which is suitable for functional single embedded systems, but there is a shortcoming of the system robustness. In version 0.9.98, we introduced the MiniGui-Lite version. At the same time in improving system robustness, we pass a series of innovative ways to avoid the weakness of traditional C / S structures, providing complex embedded systems. A highly efficient, stable GUI system. In the development of MINIGUI 1.1.0, we refer to the graphic abstraction layer with reference to SDL and Allegro, and enhance the graphics function while enhancing certain features of the MiniGUI-Lite version. These features include:

MiniGUI-Lite support concept. The same layer can accommodate multiple clients that can be displayed simultaneously and are displayed on the screen. New GAL can support hardware acceleration capabilities and fully use the display memory; new GDI interfaces above the new GAL are further enhanced. The new GDI interface can support alpha blending, transparent block transmission, grating operation, YUV coverage, GAMMA correction, and advanced graphics (ellipse, polygon, spline), and the like.

The new version of MiniGUI is enhanced and improved in graphics, which will greatly expand its application, hoping to support multimedia applications, game development on embedded Linux.

Throughout the various graphics system schemes on the embedded Linux system, we found that many graphics systems (such as QT / Embedded and Microowindows), only pay attention to the needs of handheld devices, but do not pay much attention to the needs of other applications, and many others Embedded Linux systems that require graphics are required to require many unique, advanced graphics features, not just graphical user interfaces. To this end, in the next development, we will continue to develop MiniGUI in the following areas:

Provides the implementation of the Java virtual machine AWT component running on MiniGUI. Provides OpenGL implementation on MINIGUI. Provide C packages for class QT control sets. Provide window / control style theme support. Support for vector fonts among miniGui-lite.

4 Summary Summary, the author believes in the field of embedded Linux graphics, there are many problems that have to develop and solve the developers. MiniGUI's new development is also from the understanding of these needs. We also sincerely hope to have more free software developers to join MiniGUI development, develop new embedded Linux graphics systems. About the author Wei Yongming (YMwei@miniGui.org), male, 27 years old, master's degree. One of the most influential free software projects in China - founders and major developers of MINIGUI. There is a "Linux practical tutorial" and "learning Linux and Windows NT", and presided over the translated "Red Hat Linux Mystery", "Linux Programming Collection" and other large amounts of excellent Linux technology works. It is the leader of the Aka Linux programming technology series of Tsinghua University.

转载请注明原文地址:https://www.9cbs.com/read-15542.html

New Post(0)