docs/src/integration/embedded_linux/nanovg.rst
.. _nanovg_draw_unit:
NanoVG is a lightweight, antialiased 2D vector graphics library built on top of OpenGL/OpenGL ES. The NanoVG draw unit integrates NanoVG as a hardware-accelerated rendering backend for LVGL, providing GPU-accelerated drawing for all standard LVGL widgets and graphics primitives.
Unlike the software renderer, NanoVG leverages the GPU for:
Enable the NanoVG draw unit in lv_conf.h:
.. code-block:: c
/* Enable NanoVG library */
#define LV_USE_NANOVG 1
/* Enable NanoVG draw unit */
#define LV_USE_DRAW_NANOVG 1
/* Select OpenGL backend (choose one):
* - LV_NANOVG_BACKEND_GL2: OpenGL 2.0
* - LV_NANOVG_BACKEND_GL3: OpenGL 3.0+
* - LV_NANOVG_BACKEND_GLES2: OpenGL ES 2.0
* - LV_NANOVG_BACKEND_GLES3: OpenGL ES 3.0+
*/
#define LV_NANOVG_BACKEND LV_NANOVG_BACKEND_GLES2
/* Optional: Adjust cache sizes */
#define LV_NANOVG_IMAGE_CACHE_CNT 32 /* Image texture cache entries */
#define LV_NANOVG_FBO_CACHE_CNT 8 /* Framebuffer object cache entries */
The NanoVG draw unit supports all standard LVGL drawing operations:
.. list-table:: :header-rows: 1 :widths: 30 70
LV_USE_VECTOR_GRAPHIC)NanoVG supports zero-copy texture upload for these LVGL color formats:
.. list-table:: :header-rows: 1 :widths: 25 25 50
LV_COLOR_FORMAT_A8LV_COLOR_FORMAT_ARGB8888LV_COLOR_FORMAT_XRGB8888LV_COLOR_FORMAT_RGB888LV_COLOR_FORMAT_RGB565LV_IMAGE_FLAGS_PREMULTIPLIED for pre-processed imagesglReadPixels for canvas/layer is relatively slow