nuttx/Documentation/os/graphics/index.rst
Vinicius May f6ecf80ebb Documentation: brand new layout for NuttX documentation.
The documentation grew one page at a time, so the tree follows the
history of who wrote what and not the shape of NuttX. Scheduling is
spread over three places, a driver page can sit above the subsystem
that owns it, and the front page lists everything at the same level.
That is a lot to face when all you want to know is where the scheduler
lives.

This change files every page under the code it describes. It is a move,
not a rewrite: outside the ten pages named below, every page keeps the
text that is already in master, and no page's text is deleted.

What it does:

* Groups the table of contents into nine chapters.
* Moves the OS subsystems under os/: scheduling, memory, drivers,
  filesystem, networking, IPC, interrupts, libs, time.
* Renames the platform pages to the names the source tree uses, and
  derives their tags from the tree instead of by hand.
* Splits guides/ by subject.
* Adds Documentation/redirects.py, with a rule for every page that left
  its old path, so old URLs keep working. The redirect page also carries
  a link's #anchor across to the new page.

Ten pages have text that is new or rewritten. Nine of them are the
landing page of a chapter, which has to exist for the new structure:

    index                  the front page
    os/index               OS Design
    os/scheduling/index    Scheduling
    os/interrupts/index    Interrupts
    os/ipc/index           IPC
    os/time/index          Time and timers
    about/index            About
    developing/index       Developing NuttX
    ReleaseNotes/index     Release notes

The tenth is os/libs/libbuiltin, the only page here with technical
content: libs/libbuiltin/ had no page at all. Five SVG diagrams come
with these pages, hand-written XML with no editor metadata.

Nothing outside Documentation/ is touched.

How it was checked:

* Sphinx builds with -W: no warnings, and no document left outside a
  toctree.
* A script, offered in the PR, proves the narrow claim this rests on.
  For every page outside the ten named above it erases what a move
  touches -- link target, path, tag line, toctree block, table border --
  from the whole old text and the whole new text, and requires the two
  to be byte for byte identical. It also requires every sentence of a
  deleted page to turn up somewhere, and every page that left its old
  path to have a redirect, from a URL that existed, to where its content
  went. It exits non-zero and names the page if any of that is not true,
  and it tests added pages too, so forgetting to declare one cannot make
  it pass.
* An independent audit checked 133 factual claims on these ten pages
  against the tree, one shell command per claim: 130 confirmed, 1
  refuted and fixed here, 2 not checkable.
* tools/checkpatch.sh is clean over the range.

The diff is large because moving a page changes every link that points
to it. Most of it is pure renames, and board pages that gained one tag
line.

Assisted-by: Claude:claude-opus-5
2026-10-08 01:40:54 +08:00

178 lines
7.3 KiB
ReStructuredText

.. _nxgraphics:
=====================
NX Graphics Subsystem
=====================
This document describes the tiny graphics support included in NuttX. It
includes an overview description of that graphics support, detailed
descriptions of the NuttX graphics APIs, and discussion of code
organization, and OS configuration options.
.. figure:: NuttXScreenShot.jpg
:align: center
**Figure 1**. This screenshot shows the final frame for the NuttX example
at ``apps/examples/nx`` running on the simulated, Linux x86 platform with
simulated framebuffer output to an X window. This picture shows to framed window
with (blank) toolbars. Each window has displayed text as received from the
NX keyboard interface The second window has just been raised to the top of the display.
Objectives
==========
The objective of this development was to provide a tiny windowing system
in the spirit of X, but greatly scaled down and appropriate for most
resource-limited embedded environments. The current NX implementation
supports the general following, high-level features:
- **Virtual Vertical Graphics Space**. Windows that reside in a
virtual, *vertical* space so that it makes sense to talk about one
window being on top of another and obscuring the window below it.
- **Client/Server Model**. A standard client server/model was adopted.
NX may be considered a server and other logic that presents the
windows are NX clients.
- **Multi-User Support**. NX includes *front-end* logic to support a
separate NX server thread that can serve multiple NX client threads.
The NX is a server thread/daemon the serializes graphics operations
from multiple clients.
- **Minimal Graphics Toolset**. The actual implementation of the
graphics operations is performed by common, *back-end* logic. This
back-end supports only a primitive set of graphic and rendering
operations.
- **Device Interface**. NX supports any graphics device either of two
device interfaces:
- Any device with random access video memory using the NuttX
framebuffer driver interface (see ``include/nuttx/video/fb.h``).
- Any LCD-like device than can accept raster line *runs* through a
parallel or serial interface (see ``include/nuttx/lcd/lcd.h``). By
default, NX is configured to use the frame buffer driver unless
``CONFIG_NX_LCDDRIVER`` is defined =y in your NuttX configuration
file.
- **Transparent to NX Client**. The window client on "sees" the
sub-window that is operates in and does not need to be concerned with
the virtual, vertical space (other that to respond to *redraw*
requests from NX when needed).
- **Framed Windows and Toolbars**. NX also adds the capability to
support windows with frames and toolbars on top of the basic
windowing support. These are windows such as those shown in the
`screenshot <#screenshot>`__ above. These framed windows sub-divide
one one window into three relatively independent subwindows: A frame,
the contained window and an (optional) toolbar window.
- **Mouse Support**. NX provides support for a mouse or other X/Y
pointing devices. APIs are provided to allow external devices to give
X/Y position information and mouse button presses to NX. NX will then
provide the mouse input to the relevant window clients via callbacks.
Client windows only receive the mouse input callback if the mouse is
positioned over a visible portion of the client window; X/Y position
is provided to the client in the relative coordinate system of the
client window.
- **Keyboard input**. NX also supports keyboard/keypad devices. APIs
are provided to allow external devices to give keypad information to
NX. NX will then provide the mouse input to the top window on the
display (the window that has the *focus*) via a callback function.
Organization
============
NX is organized into 6 (and perhaps someday 7 or 8) logical modules.
These logical modules also correspond to the directory organization.
That NuttX directory organization is discussed in `Appendix
B <#grapicsdirs>`__ of this document. The logic modules are discussed in
the following sub-paragraphs.
.. figure:: NXOrganization.png
:align: center
NX Graphics Library (``NXGL``)
------------------------------
NXGLIB is a standalone library that contains low-level graphics
utilities and direct framebuffer or LCD rendering logic. NX is built on
top NXGLIB.
NX (``NXSU`` and ``NXMU``)
--------------------------
NX is the tiny NuttX windowing system for raw windows (i.e., simple
regions of graphics memory). NX includes a small-footprint, multi-user
implementation (NXMU as described below). NX can be used without
NxWidgets and without NXTOOLKIT for raw window displays.
:sup:`1`\ NXMU and NXSU are interchangeable other than (1) certain
start-up and initialization APIs (as described below), and (2) timing.
With NXSU, NX APIs execute immediately; with NXMU, NX APIs defer and
serialize the operations and, hence, introduce different timing and
potential race conditions that you would not experience with NXSU.
**NXNULL?** At one time, I also envisioned a *NULL* front-end that did
not support windowing at all but, rather, simply provided the entire
framebuffer or LCD memory as one dumb window. This has the advantage
that the same NX APIs can be used on the one dumb window as for the
other NX windows. This would be in the NuttX spirit of scalability.
However, the same end result can be obtained by using the
```nx_requestbkgd()`` <#nxrequestbkgd>`__ API. It still may be possible
to reduce the footprint in this usage case by developing and even
thinner NXNULL front-end. That is a possible future development.
NX Tool Kit (``NXTK``)
----------------------
NXTK is a s set of C graphics tools that provide higher-level window
drawing operations. This is the module where the framed windows and
toolbar logic is implemented. NXTK is built on top of NX and does not
depend on NxWidgets.
NX Fonts Support (``NXFONTS``)
------------------------------
A set of C graphics tools for present (bitmap) font images. The font
implementation is at a very low level or graphics operation, comparable
to the logic in NXGLIB. NXFONTS does not depend on any NX module other
than some utilities and types from NXGLIB.
NX Widgets (``NxWidgets``)
--------------------------
:ref:`NxWidgets <nxwidgets>` is a higher level, C++, object-oriented
library for object-oriented access to graphical "widgets." NxWidgets is
provided as a separate library in the ``apps/`` repository NxWidgets is
built on top of the core NuttX graphics subsystem, but is part of the
application space rather than part of the core OS graphics subsystems.
Terminal Driver (``NxTerm``)
----------------------------
NxTerm is a write-only character device (not shown) that is built on top
of an NX window. This character device can be used to provide ``stdout``
and ``stderr`` and, hence, can provide the output side of NuttX console.
).
NX Header Files
===============
``include/nuttx/nx/nxglib.h``
Describes the NXGLIB C interfaces
``include/nuttx/nx/nx.h``
Describes the NX C interfaces
``include/nutt/nxtk.h``
Describe the NXTOOLKIT C interfaces
``include/nutt/nxfont.h``
Describe sthe NXFONT C interfaces
.. toctree::
:Caption: User APIs
nxgl.rst
nx.rst
nxtk.rst
nxfonts.rst
nxcursor.rst
nxwm_threading.rst
framebuffer_char_driver.rst
sample.rst
appendix.rst