【LittlevGL】看看LVGL8的draw_ctx
调用"lv_disp_drv_init"函数初始化一个显示设备驱动,一个显示设备驱动的结构体内容如下:
typedef struct _lv_disp_drv_t {lv_coord_t hor_res; /**< Horizontal resolution.*/lv_coord_t ver_res; /**< Vertical resolution.*/lv_coord_tphysical_hor_res; /**< Horizontal resolution of the full / physical display. Set to -1 for fullscreen mode.*/lv_coord_tphysical_ver_res; /**< Vertical resolution of the full / physical display. Set to -1 for fullscreen mode.*/lv_coord_toffset_x; /**< Horizontal offset from the full / physical display. Set to 0 for fullscreen mode.*/lv_coord_t offset_y; /**< Vertical offset from the full / physical display. Set to 0 for fullscreen mode.*//** Pointer to a buffer initialized with `lv_disp_draw_buf_init()`.* LVGL will use this buffer(s) to draw the screens contents*/lv_disp_draw_buf_t * draw_buf;uint32_t direct_mode : 1; /**< 1: Use screen-sized buffers and draw to absolute coordinates*/uint32_t full_refresh : 1; /**< 1: Always make the whole screen redrawn*/uint32_t sw_rotate : 1; /**< 1: use software rotation (slower)*/uint32_t antialiasing : 1; /**< 1: anti-aliasing is enabled on this display.*/uint32_t rotated : 2; /**< 1: turn the display by 90 degree. @warning Does not update coordinates for you!*/uint32_t screen_transp : 1; /**Handle if the screen doesn't have a solid (opa == LV_OPA_COVER) background.* Use only if required because it's slower.*/uint32_t dpi : 10; /** DPI (dot per inch) of the display. Default value is `LV_DPI_DEF`.*//** MANDATORY: Write the internal buffer (draw_buf) to the display. 'lv_disp_flush_ready()' has to be* called when finished*/void (*flush_cb)(struct _lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p);/** OPTIONAL: Extend the invalidated areas to match with the display drivers requirements* E.g. round `y` to, 8, 16 ..) on a monochrome display*/void (*rounder_cb)(struct _lv_disp_drv_t * disp_drv, lv_area_t * area);/** OPTIONAL: Set a pixel in a buffer according to the special requirements of the display* Can be used for color format not supported in LittelvGL. E.g. 2 bit -> 4 gray scales* @note Much slower then drawing with supported color formats.*/void (*set_px_cb)(struct _lv_disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,lv_color_t color, lv_opa_t opa);void (*clear_cb)(struct _lv_disp_drv_t * disp_drv, uint8_t * buf, uint32_t size);/** OPTIONAL: Called after every refresh cycle to tell the rendering and flushing time + the* number of flushed pixels*/void (*monitor_cb)(struct _lv_disp_drv_t * disp_drv, uint32_t time, uint32_t px);/** OPTIONAL: Called periodically while lvgl waits for operation to be completed.* For example flushing or GPU* User can execute very simple tasks here or yield the task*/void (*wait_cb)(struct _lv_disp_drv_t * disp_drv);/** OPTIONAL: Called when lvgl needs any CPU cache that affects rendering to be cleaned*/void (*clean_dcache_cb)(struct _lv_disp_drv_t * disp_drv);/** OPTIONAL: called when driver parameters are updated */void (*drv_update_cb)(struct _lv_disp_drv_t * disp_drv);/** On CHROMA_KEYED images this color will be transparent.* `LV_COLOR_CHROMA_KEY` by default. (lv_conf.h)*/lv_color_t color_chroma_key;lv_draw_ctx_t * draw_ctx;void (*draw_ctx_init)(struct _lv_disp_drv_t * disp_drv, lv_draw_ctx_t * draw_ctx);void (*draw_ctx_deinit)(struct _lv_disp_drv_t * disp_drv, lv_draw_ctx_t * draw_ctx);size_t draw_ctx_size;#if LV_USE_USER_DATAvoid * user_data; /**< Custom display driver user data*/
#endif} lv_disp_drv_t;
前面的是一些常规的显示设置和显存写回调函数,后面有一个“draw_ctx”字段,这个是一个”绘制语境“结构体,里面包含了最常用几何图形、图片、字符的绘制函数:
typedef struct _lv_draw_ctx_t {/*** Pointer to a buffer to draw into*/void * buf;/*** The position and size of `buf` (absolute coordinates)*/lv_area_t * buf_area;/*** The current clip area with absolute coordinates, always the same or smaller than `buf_area`*/const lv_area_t * clip_area;void (*draw_rect)(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_rect_dsc_t * dsc, const lv_area_t * coords);void (*draw_arc)(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_arc_dsc_t * dsc, const lv_point_t * center,uint16_t radius, uint16_t start_angle, uint16_t end_angle);void (*draw_img_decoded)(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_img_dsc_t * dsc,const lv_area_t * coords, const uint8_t * map_p, lv_img_cf_t color_format);lv_res_t (*draw_img)(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_img_dsc_t * draw_dsc,const lv_area_t * coords, const void * src);void (*draw_letter)(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_label_dsc_t * dsc, const lv_point_t * pos_p,uint32_t letter);void (*draw_line)(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_line_dsc_t * dsc, const lv_point_t * point1,const lv_point_t * point2);void (*draw_polygon)(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_rect_dsc_t * draw_dsc,const lv_point_t * points, uint16_t point_cnt);/*** Replace the buffer with a rect without decoration like radius or borders*/void (*draw_bg)(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_rect_dsc_t * draw_dsc, const lv_area_t * coords);/*** Wait until all background operations are finished. (E.g. GPU operations)*/void (*wait_for_finish)(struct _lv_draw_ctx_t * draw_ctx);/*** Copy an area from buffer to an other* @param draw_ctx pointer to a draw context* @param dest_buf copy the buffer into this buffer* @param dest_stride the width of the dest_buf in pixels* @param dest_area the destination area* @param src_buf copy from this buffer* @param src_stride the width of src_buf in pixels* @param src_area the source area.** @note dest_area and src_area must have the same width and height* but can have different x and y position.* @note dest_area and src_area must be clipped to the real dimensions of the buffers*/void (*buffer_copy)(struct _lv_draw_ctx_t * draw_ctx, void * dest_buf, lv_coord_t dest_stride,const lv_area_t * dest_area,void * src_buf, lv_coord_t src_stride, const lv_area_t * src_area);
#if LV_USE_USER_DATAvoid * user_data;
#endif} lv_draw_ctx_t;
“draw_ctx”后面还有一个“draw_ctx_init”字段,在"lv_disp_drv_init"函数中,如果没有使用硬件GPU的话,会被默认初始化成“lv_draw_sw_init_ctx”函数,这个函数中会将“draw_ctx”字段中的所有绘制回调函数都初始化成软绘(软件绘制)函数,软绘函数都是使用CPU进行绘制处理,如果有GPU的话,可以使用GPU绘制函数初始化“draw_ctx”。
以“draw_ctx”里的“draw_letter”函数为例,这是字符绘制函数,软绘字符绘制函数为“lv_draw_sw_letter”,在这个函数里面会调用“lv_font_get_glyph_dsc”函数用以获取glyph descriptor(字符描述符),如果获取描述符失败,则会显示一个placeholder(占位符,是一个方框框,如下图),表示这个字符是字库里面没有的字符。否则,就会从字库里面获取字符的点阵数据并绘制。
【LittlevGL】看看LVGL8的draw_ctx相关推荐
- STM32移植LVGL8.0.2超详细的保姆级教程附移植好的工程文件
文章目录 前言 一.什么是LVGL? 二.先看效果 三.移植前准备工作 1.准备原有工程 2.下载LVGL源码 四.开始移植 1.把源码搬运到工程文件夹里 2.把搬运好的代码添加到keil工程 3.动 ...
- LVGL8.2 之 模拟器使用外部中文字体,两种方式
准备工具,LvglFontTool v0.4 能运行LVGL8.2模拟器的codeblocks工程(百问网的LVGL模拟器工程) =================================== ...
- STM32移植LVGL(LittleVGL)
STM32移植LVGL(LittleVGL) 一.什么是LVGL https://lvgl.io/ 这是LVGL的官网, http://lvgl.100ask.org/8.2/intro/index. ...
- LVGL8.1笔记1--显示移植(2022-0515)
LVGL8.1笔记1--显示移植 前言 一.移植前准备 二.LVGL-8.1目录简介 主要用的的内容 examples文件夹内容介绍 src文件夹内容介绍 lv_conf_template.h文件内容 ...
- littlevgl抗锯齿_「VGL」littlevGL:字体与汉字 - seo实验室
VGL 使用各种嵌入式GUI时,总会遇到"汉字显示""字体"这些关卡. 阅读本文前,最好已经了解Uincode,UTF-8,UTF-16,GBK,gb2312相 ...
- LVGL8制作简易时钟
通过这两天对LVGL8的部分控件和样式的学习,自己制作了一个简易时钟,可显示时间,日期,星期,用到的主要有样式,布局等对象,还是通过codeblock来模拟代码的运行,代码如下: typedef st ...
- LVGL8.2学习笔记
LVGL8.2学习笔记 LVGL控件的基础知识 (1) C语言编写的LVGL以结构体的形式实现类似C++ "Class"的思想: (2) 父子对象的默认关系 LVGL基础对象 LV ...
- 【LittlevGL】模拟器
LittlevGL提供的模拟器有很多种: 我使用的是VS版本的模拟器进行测试,github主页:https://github.com/littlevgl/pc_simulator_sdl_visual ...
- Luat 功能开发教程(十六) LittleVGL
目录 LittleVGL 简介 控件API说明 实现流程 示例 image控件 Canvas控件 button控件 Arc控件(加载器) page控件 label控件 Slider控件 switch控 ...
最新文章
- idm 爬取网站 跳转路径_儋州网站案例基本流程,电子元件网络推广,浅析
- PPP协议的CHAP验证
- AttributeError: module ‘cv2.cv2‘ has no attribute ‘xfeatures2d‘解决方法
- MySQL 避免行锁升级为表锁——使用高效的索引
- zookeper安装_ZooKeeper安装和配置
- Android之开发者应该收藏的优秀博客和技术网站
- Java多线程系列(二):线程的五大状态,以及线程之间的通信与协作
- 软件测试常见笔试面试题(一)
- 选择数据分析软件时要注意什么
- Typora入门(中文版)
- 单片机之步进电机速度控制篇(三)
- Docker Desktop 安装使用教程
- ML笔记 - 自然语言处理常用技术
- 屏幕录像专家 共享版 V7.5 安装图解
- Photoshop教程:10秒闪电搞定照片构图
- win10的任务管理器显示所占内存,比实际占用内存小的原因
- Docker Swarm 练习:投票 App
- 还不到4折:赶紧来抢券啊!!!
- jdk8中新增的日期处理类LocalDate,LocalTime,LocalDateTime,ZoneId,ZonedDateTime详解
- mysql 匹配多个字符,【单选题】在MySQL语句中,可以匹配0个到多个字符的通配符是( )
A. * B. % C. ? D. –...
热门文章
- Postman是什么 怎么用
- 手机电路板文件_PCB工程师必看,从图纸到成品,电路板的制作只需这三大流程...
- vue+elementUI完成登陆+注册
- 自媒体创作怎么细分领域?怎么进行选题?
- AutoSAR系列讲解(入门篇)5.1-方法论概述
- 网盘拉新项目的变现玩法解析!
- Codeforces Round #644 (Div. 3) E.Polygon
- UnityWebPlayer使用(3) WinForm中屏蔽右键菜单
- 视频讲解Agora视频通话SDK| 掘金技术征文
- linux selinux策略管理与标签