CARPLAY版本整理
This commit is contained in:
11
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/README.md
Normal file
11
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/README.md
Normal file
@ -0,0 +1,11 @@
|
||||
# LCD显示的实现
|
||||
|
||||
目前支持3类不同的LCD实现。
|
||||
|
||||
* 基于寄存器实现:lcd\_reg.inc
|
||||
* 基于framebuffer实现:lcd\_mem.inc
|
||||
* 基于vgcanvas实现(有GPU时才启用):lcd\_vgcanvas.inc
|
||||
|
||||
> lcd\_mem\*.c/.h均由gen.sh根据template下的模板自动生成。支持新的格式可以修改gen.sh,并运行gen.sh。
|
||||
|
||||
> gen.sh是bash脚本,Windows下可在git bash下运行。
|
@ -0,0 +1,222 @@
|
||||
/**
|
||||
* File: fragment_frame_buffer
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: fragment_frame_buffer
|
||||
*
|
||||
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* this program is distributed in the hope that it will be useful,
|
||||
* but without any warranty; without even the implied warranty of
|
||||
* merchantability or fitness for a particular purpose. see the
|
||||
* license file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* history:
|
||||
* ================================================================
|
||||
* 2019-08-16 li xianjing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
#include "tkc/utils.h"
|
||||
|
||||
typedef struct _fragment_frame_buffer_t {
|
||||
uint32_t x;
|
||||
uint32_t y;
|
||||
uint32_t w;
|
||||
uint32_t h;
|
||||
pixel_t* data;
|
||||
uint32_t pixels_nr;
|
||||
|
||||
rect_t win;
|
||||
int32_t cursor_x;
|
||||
int32_t cursor_y;
|
||||
} fragment_frame_buffer_t;
|
||||
|
||||
static fragment_frame_buffer_t* fragment_frame_buffer_init(fragment_frame_buffer_t* ffb,
|
||||
pixel_t* data, uint32_t pixels_nr) {
|
||||
return_value_if_fail(ffb != NULL && data != NULL, NULL);
|
||||
|
||||
memset(ffb, 0x00, sizeof(fragment_frame_buffer_t));
|
||||
|
||||
ffb->data = data;
|
||||
ffb->pixels_nr = pixels_nr;
|
||||
|
||||
return ffb;
|
||||
}
|
||||
|
||||
static fragment_frame_buffer_t* fragment_frame_buffer_begin_frame(fragment_frame_buffer_t* ffb,
|
||||
const rect_t* r) {
|
||||
uint32_t nr = 0;
|
||||
return_value_if_fail(ffb != NULL && r != NULL, NULL);
|
||||
|
||||
nr = r->w * r->h;
|
||||
|
||||
if (nr > ffb->pixels_nr) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ffb->x = r->x;
|
||||
ffb->y = r->y;
|
||||
ffb->w = r->w;
|
||||
ffb->h = r->h;
|
||||
|
||||
return ffb;
|
||||
}
|
||||
|
||||
static inline ret_t fragment_frame_buffer_set_pixel(fragment_frame_buffer_t* ffb, uint32_t x,
|
||||
uint32_t y, pixel_t pixel) {
|
||||
uint32_t dx = x - ffb->x;
|
||||
uint32_t dy = y - ffb->y;
|
||||
pixel_t* p = ffb->data + dy * ffb->w + dx;
|
||||
|
||||
return_value_if_fail((x >= ffb->x && y >= ffb->y), RET_BAD_PARAMS);
|
||||
return_value_if_fail((x < (ffb->x + ffb->w) && y < (ffb->y + ffb->h)), RET_BAD_PARAMS);
|
||||
|
||||
*p = pixel;
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static inline ret_t fragment_frame_buffer_set_pixel_fill(fragment_frame_buffer_t* ffb, uint32_t x,
|
||||
uint32_t y, uint32_t size, pixel_t pixel) {
|
||||
uint32_t dx = x - ffb->x;
|
||||
uint32_t dy = y - ffb->y;
|
||||
pixel_t* p = ffb->data + dy * ffb->w + dx;
|
||||
|
||||
return_value_if_fail((ffb->w * ffb->h) >= size, RET_BAD_PARAMS);
|
||||
return_value_if_fail((x >= ffb->x && y >= ffb->y), RET_BAD_PARAMS);
|
||||
return_value_if_fail((x < (ffb->x + ffb->w) && y < (ffb->y + ffb->h)), RET_BAD_PARAMS);
|
||||
|
||||
if (LCD_FORMAT == BITMAP_FMT_RGBA8888 || LCD_FORMAT == BITMAP_FMT_ABGR8888 ||
|
||||
LCD_FORMAT == BITMAP_FMT_BGRA8888 || LCD_FORMAT == BITMAP_FMT_ARGB8888) {
|
||||
tk_memset32((uint32_t*)p, (uint32_t)pixel, size);
|
||||
} else if (LCD_FORMAT == BITMAP_FMT_RGB565 || LCD_FORMAT == BITMAP_FMT_BGR565) {
|
||||
tk_memset16((uint16_t*)p, (uint16_t)pixel, size);
|
||||
} else {
|
||||
assert("no support lcd type fill");
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static inline ret_t fragment_frame_buffer_copy_pixel(fragment_frame_buffer_t* ffb, uint32_t x,
|
||||
uint32_t y, uint32_t size,
|
||||
pixel_t* image_data) {
|
||||
uint32_t dx = x - ffb->x;
|
||||
uint32_t dy = y - ffb->y;
|
||||
pixel_t* p = ffb->data + dy * ffb->w + dx;
|
||||
|
||||
return_value_if_fail((ffb->w * ffb->h) >= size, RET_BAD_PARAMS);
|
||||
return_value_if_fail((x >= ffb->x && y >= ffb->y), RET_BAD_PARAMS);
|
||||
return_value_if_fail((x < (ffb->x + ffb->w) && y < (ffb->y + ffb->h)), RET_BAD_PARAMS);
|
||||
if (LCD_FORMAT == BITMAP_FMT_RGBA8888 || LCD_FORMAT == BITMAP_FMT_ABGR8888 ||
|
||||
LCD_FORMAT == BITMAP_FMT_BGRA8888 || LCD_FORMAT == BITMAP_FMT_ARGB8888) {
|
||||
tk_memcpy32((uint32_t*)image_data, (uint32_t*)p, size);
|
||||
} else if (LCD_FORMAT == BITMAP_FMT_RGB565 || LCD_FORMAT == BITMAP_FMT_BGR565) {
|
||||
tk_memcpy16((uint16_t*)image_data, (uint16_t*)p, size);
|
||||
} else {
|
||||
assert("no support image type");
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static inline pixel_t fragment_frame_buffer_get_pixel(fragment_frame_buffer_t* ffb, uint32_t x,
|
||||
uint32_t y) {
|
||||
uint32_t dx = x - ffb->x;
|
||||
uint32_t dy = y - ffb->y;
|
||||
pixel_t* p = ffb->data + dy * ffb->w + dx;
|
||||
|
||||
assert(x >= ffb->x && y >= ffb->y && x < (ffb->x + ffb->w) && y < (ffb->y + ffb->h));
|
||||
|
||||
return *p;
|
||||
}
|
||||
|
||||
static inline ret_t fragment_frame_buffer_end_frame(fragment_frame_buffer_t* ffb) {
|
||||
uint32_t i = 0;
|
||||
pixel_t* p = ffb->data;
|
||||
uint32_t nr = ffb->w * ffb->h;
|
||||
|
||||
set_window_func(ffb->x, ffb->y, ffb->x + ffb->w - 1, ffb->y + ffb->h - 1);
|
||||
for (i = 0; i < nr; i++, p++) {
|
||||
write_data_func(*p);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static inline ret_t fragment_frame_buffer_set_window(fragment_frame_buffer_t* ffb, uint32_t x,
|
||||
uint32_t y, uint32_t w, uint32_t h) {
|
||||
ffb->win.x = x;
|
||||
ffb->win.y = y;
|
||||
ffb->win.w = w;
|
||||
ffb->win.h = h;
|
||||
ffb->cursor_x = 0;
|
||||
ffb->cursor_y = 0;
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static inline ret_t fragment_frame_buffer_image_copy(fragment_frame_buffer_t* ffb, bitmap_t* img,
|
||||
const rect_t* src, const rect_t* dst) {
|
||||
uint32_t i = 0;
|
||||
uint32_t x = ffb->win.x + ffb->cursor_x;
|
||||
uint32_t y = ffb->win.y + ffb->cursor_y;
|
||||
pixel_t* data = NULL;
|
||||
pixel_t* src_p = NULL;
|
||||
|
||||
return_value_if_fail(src->w == dst->w && src->h == dst->h, RET_BAD_PARAMS);
|
||||
|
||||
data = (pixel_t*)bitmap_lock_buffer_for_read(img);
|
||||
src_p = data + img->w * src->y + src->x;
|
||||
|
||||
for (i = 0; i < (uint32_t)dst->h; i++) {
|
||||
fragment_frame_buffer_copy_pixel(ffb, x, y + i, img->w, src_p);
|
||||
src_p += img->w;
|
||||
}
|
||||
|
||||
ffb->cursor_x += (src->w * src->h);
|
||||
assert(ffb->cursor_y < ffb->win.h);
|
||||
if (ffb->cursor_x >= ffb->win.w) {
|
||||
ffb->cursor_y += (ffb->cursor_x / ffb->win.w);
|
||||
ffb->cursor_x = ffb->cursor_x % ffb->win.w;
|
||||
}
|
||||
bitmap_unlock_buffer(img);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static inline ret_t fragment_frame_buffer_write_data_fill(fragment_frame_buffer_t* ffb,
|
||||
pixel_t pixel, uint32_t size) {
|
||||
uint32_t i = 0;
|
||||
uint32_t x = ffb->win.x + ffb->cursor_x;
|
||||
uint32_t y = ffb->win.y + ffb->cursor_y;
|
||||
|
||||
for (i = 0; i < (uint32_t)ffb->win.h; i++) {
|
||||
fragment_frame_buffer_set_pixel_fill(ffb, x, y + i, ffb->win.w, pixel);
|
||||
}
|
||||
|
||||
ffb->cursor_x += size;
|
||||
assert(ffb->cursor_y < ffb->win.h);
|
||||
if (ffb->cursor_x >= ffb->win.w) {
|
||||
ffb->cursor_y += (ffb->cursor_x / ffb->win.w);
|
||||
ffb->cursor_x = ffb->cursor_x % ffb->win.w;
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static inline ret_t fragment_frame_buffer_write_data(fragment_frame_buffer_t* ffb, pixel_t pixel) {
|
||||
uint32_t x = ffb->win.x + ffb->cursor_x;
|
||||
uint32_t y = ffb->win.y + ffb->cursor_y;
|
||||
ret_t ret = fragment_frame_buffer_set_pixel(ffb, x, y, pixel);
|
||||
|
||||
ffb->cursor_x++;
|
||||
assert(ffb->cursor_y < ffb->win.h);
|
||||
if (ffb->cursor_x >= ffb->win.w) {
|
||||
ffb->cursor_x = 0;
|
||||
ffb->cursor_y++;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
23
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/gen.sh
Normal file
23
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/gen.sh
Normal file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
DATE=`date "+%Y-%m-%d"`
|
||||
|
||||
function gen() {
|
||||
fmt=$1
|
||||
FMT=`echo $fmt | tr a-z A-Z`
|
||||
echo "generating $fmt $FMT $DATE"
|
||||
|
||||
sed -e "s/{fmt}/$fmt/" -e "s/{FMT}/$FMT/" -e "s/{date}/$DATE/" template/lcd_mem_h.tmpl > lcd_mem_$fmt.h
|
||||
sed -e "s/{fmt}/$fmt/" -e "s/{FMT}/$FMT/" -e "s/{date}/$DATE/" template/lcd_mem_c.tmpl > lcd_mem_$fmt.c
|
||||
}
|
||||
|
||||
if [ "$1" == "" ]; then
|
||||
FMT="rgb565 bgr565 rgb888 bgr888 bgra8888 rgba8888"
|
||||
else
|
||||
FMT="$1"
|
||||
fi
|
||||
#supproted formats: rgb565 bgr565 rgb888 bgr888 rgba8888 abgr8888 bgra8888 argb8888
|
||||
for fmt in ${FMT}
|
||||
do
|
||||
gen $fmt
|
||||
done
|
191
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem.h
Normal file
191
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem.h
Normal file
@ -0,0 +1,191 @@
|
||||
/**
|
||||
* File: lcd_mem.h
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: memory implemented lcd interface
|
||||
*
|
||||
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* this program is distributed in the hope that it will be useful,
|
||||
* but without any warranty; without even the implied warranty of
|
||||
* merchantability or fitness for a particular purpose. see the
|
||||
* license file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* history:
|
||||
* ================================================================
|
||||
* 2018-01-13 li xianjing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TK_LCD_MEM_H
|
||||
#define TK_LCD_MEM_H
|
||||
|
||||
#include "tkc/mem.h"
|
||||
#include "base/lcd.h"
|
||||
#include "base/graphic_buffer.h"
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
typedef ret_t (*lcd_mem_wait_vbi_t)(void* ctx);
|
||||
|
||||
typedef struct _lcd_mem_t {
|
||||
lcd_t base;
|
||||
uint8_t* offline_fb;
|
||||
uint8_t* online_fb;
|
||||
uint8_t* next_fb;
|
||||
vgcanvas_t* vgcanvas;
|
||||
|
||||
uint32_t online_line_length;
|
||||
uint32_t line_length;
|
||||
bitmap_format_t format;
|
||||
bool_t own_offline_fb;
|
||||
|
||||
graphic_buffer_t* online_gb;
|
||||
graphic_buffer_t* offline_gb;
|
||||
|
||||
lcd_fb_dirty_rects_t fb_dirty_rects_list;
|
||||
|
||||
/*VBI: vertical blank interrupt。用于2fb等待当前显示完成,以便把下一帧的数据从offline fb拷贝到online fb,从而避免因为同时访问online fb数据造成闪烁。*/
|
||||
lcd_mem_wait_vbi_t wait_vbi;
|
||||
void* wait_vbi_ctx;
|
||||
} lcd_mem_t;
|
||||
|
||||
#define lcd_mem_set_line_length(lcd, value) lcd_set_line_length(lcd, value);
|
||||
|
||||
/**
|
||||
* @method lcd_resize
|
||||
* 设置等待VBI事件到来的回调函数。
|
||||
* > VBI: vertical blank interrupt。用于2fb等待当前显示完成,以便把下一帧的数据从offline fb拷贝到online fb,从而避免因为同时访问online fb数据造成闪烁。
|
||||
* @export none
|
||||
* @param {lcd_t*} lcd lcd对象。
|
||||
* @param {lcd_mem_wait_vbi_t} wait_vbi 回调函数。
|
||||
* @param {void*} ctx 回调函数的上下文。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
static inline ret_t lcd_mem_set_wait_vbi(lcd_t* lcd, lcd_mem_wait_vbi_t wait_vbi, void* ctx) {
|
||||
lcd_mem_t* mem = ((lcd_mem_t*)lcd);
|
||||
return_value_if_fail(mem != NULL, RET_BAD_PARAMS);
|
||||
|
||||
mem->wait_vbi = wait_vbi;
|
||||
mem->wait_vbi_ctx = ctx;
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method lcd_mem_deinit
|
||||
* 清除 lcd_mem 对象中的数据
|
||||
* @export none
|
||||
* @param {lcd_mem_t*} mem lcd_mem 对象。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
static inline ret_t lcd_mem_deinit(lcd_mem_t* mem) {
|
||||
return_value_if_fail(mem != NULL && mem->base.begin_frame != NULL, RET_BAD_PARAMS);
|
||||
|
||||
lcd_fb_dirty_rects_deinit(&(mem->fb_dirty_rects_list));
|
||||
if (mem->vgcanvas != NULL) {
|
||||
vgcanvas_destroy(mem->vgcanvas);
|
||||
mem->vgcanvas = NULL;
|
||||
}
|
||||
|
||||
if (mem->own_offline_fb) {
|
||||
TKMEM_FREE(mem->offline_fb);
|
||||
}
|
||||
|
||||
graphic_buffer_destroy(mem->online_gb);
|
||||
graphic_buffer_destroy(mem->offline_gb);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method lcd_mem_set_offline_fb
|
||||
* 设置 lcd_mem 对象中的 offline_fb
|
||||
* @export none
|
||||
* @param {lcd_mem_t*} mem lcd_mem 对象。
|
||||
* @param {uint8_t*} offline_fb offline_fb 地址。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
static inline ret_t lcd_mem_set_offline_fb(lcd_mem_t* lcd, uint8_t* offline_fb) {
|
||||
return_value_if_fail(lcd != NULL, RET_BAD_PARAMS);
|
||||
lcd->offline_fb = offline_fb;
|
||||
return lcd_fb_dirty_rects_add_fb_info(&(lcd->fb_dirty_rects_list), offline_fb);
|
||||
}
|
||||
|
||||
/**
|
||||
* @method lcd_mem_get_offline_fb
|
||||
* 获取 lcd_mem 对象中的 offline_fb
|
||||
* @export none
|
||||
* @param {lcd_mem_t*} mem lcd_mem 对象。
|
||||
*
|
||||
* @return {uint8_t*} 返回 offline_fb 地址。
|
||||
*/
|
||||
static inline uint8_t* lcd_mem_get_offline_fb(lcd_mem_t* lcd) {
|
||||
return_value_if_fail(lcd != NULL, NULL);
|
||||
return lcd->offline_fb;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method lcd_mem_set_online_fb
|
||||
* 设置 lcd_mem 对象中的 online_fb
|
||||
* @export none
|
||||
* @param {lcd_mem_t*} mem lcd_mem 对象。
|
||||
* @param {uint8_t*} online_fb online_fb 地址。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
static inline ret_t lcd_mem_set_online_fb(lcd_mem_t* lcd, uint8_t* online_fb) {
|
||||
return_value_if_fail(lcd != NULL, RET_BAD_PARAMS);
|
||||
lcd->online_fb = online_fb;
|
||||
return lcd_fb_dirty_rects_add_fb_info(&(lcd->fb_dirty_rects_list), online_fb);
|
||||
}
|
||||
|
||||
/**
|
||||
* @method lcd_mem_get_online_fb
|
||||
* 获取 lcd_mem 对象中的 online_fb
|
||||
* @export none
|
||||
* @param {lcd_mem_t*} mem lcd_mem 对象。
|
||||
*
|
||||
* @return {uint8_t*} 返回 online_fb 地址。
|
||||
*/
|
||||
static inline uint8_t* lcd_mem_get_online_fb(lcd_mem_t* lcd) {
|
||||
return_value_if_fail(lcd != NULL, NULL);
|
||||
return lcd->online_fb;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method lcd_mem_set_next_fb
|
||||
* 设置 lcd_mem 对象中的 next_fb
|
||||
* @export none
|
||||
* @param {lcd_mem_t*} mem lcd_mem 对象。
|
||||
* @param {uint8_t*} next_fb next_fb 地址。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
static inline ret_t lcd_mem_set_next_fb(lcd_mem_t* lcd, uint8_t* next_fb) {
|
||||
return_value_if_fail(lcd != NULL, RET_BAD_PARAMS);
|
||||
lcd->next_fb = next_fb;
|
||||
return lcd_fb_dirty_rects_add_fb_info(&(lcd->fb_dirty_rects_list), next_fb);
|
||||
}
|
||||
|
||||
/**
|
||||
* @method lcd_mem_get_next_fb
|
||||
* 获取 lcd_mem 对象中的 next_fb
|
||||
* @export none
|
||||
* @param {lcd_mem_t*} mem lcd_mem 对象。
|
||||
*
|
||||
* @return {uint8_t*} 返回 next_fb 地址。
|
||||
*/
|
||||
static inline uint8_t* lcd_mem_get_next_fb(lcd_mem_t* lcd) {
|
||||
return_value_if_fail(lcd != NULL, NULL);
|
||||
return lcd->next_fb;
|
||||
}
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /*TK_LCD_MEM_H*/
|
527
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem.inc
Normal file
527
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem.inc
Normal file
@ -0,0 +1,527 @@
|
||||
/**
|
||||
* File: lcd_mem.c
|
||||
* Author: Li XianJing <xianjimli@hotmail.com>
|
||||
* Brief: mem implemented lcd interface
|
||||
*
|
||||
* Copyright (c) 2018 - 2020 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* License file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* History:
|
||||
* ================================================================
|
||||
* 2018-01-13 Li XianJing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
#include "tkc/mem.h"
|
||||
#include "tkc/darray.h"
|
||||
#include "lcd/lcd_mem.h"
|
||||
#include "base/vgcanvas.h"
|
||||
#include "blend/image_g2d.h"
|
||||
#include "base/system_info.h"
|
||||
|
||||
static uint32_t lcd_mem_get_line_length(lcd_mem_t* mem) {
|
||||
uint32_t bpp = bitmap_get_bpp_of_format(LCD_FORMAT);
|
||||
return tk_max(mem->base.w * bpp, mem->line_length);
|
||||
}
|
||||
|
||||
static pixel_t* lcd_mem_init_drawing_fb(lcd_t* lcd, bitmap_t* fb) {
|
||||
lcd_mem_t* mem = (lcd_mem_t*)lcd;
|
||||
uint8_t* fbuff = mem->offline_fb;
|
||||
|
||||
if (fb != NULL) {
|
||||
memset(fb, 0x00, sizeof(bitmap_t));
|
||||
|
||||
fb->w = lcd->w;
|
||||
fb->h = lcd->h;
|
||||
fb->buffer = mem->offline_gb;
|
||||
fb->format = mem->format;
|
||||
graphic_buffer_attach(mem->offline_gb, mem->offline_fb, fb->w, fb->h);
|
||||
bitmap_set_line_length(fb, lcd_mem_get_line_length(mem));
|
||||
}
|
||||
|
||||
return (pixel_t*)fbuff;
|
||||
}
|
||||
|
||||
static bitmap_t* lcd_mem_init_online_fb(lcd_t* lcd, bitmap_t* fb, lcd_orientation_t o) {
|
||||
uint32_t w = 0;
|
||||
uint32_t h = 0;
|
||||
lcd_mem_t* mem = (lcd_mem_t*)lcd;
|
||||
uint32_t bpp = bitmap_get_bpp_of_format(LCD_FORMAT);
|
||||
|
||||
if (o == LCD_ORIENTATION_0 || o == LCD_ORIENTATION_180) {
|
||||
w = lcd->w;
|
||||
h = lcd->h;
|
||||
} else {
|
||||
h = lcd->w;
|
||||
w = lcd->h;
|
||||
}
|
||||
|
||||
memset(fb, 0x00, sizeof(bitmap_t));
|
||||
fb->w = w;
|
||||
fb->h = h;
|
||||
fb->buffer = mem->online_gb;
|
||||
fb->format = mem->format;
|
||||
graphic_buffer_attach(mem->online_gb, mem->online_fb, w, h);
|
||||
bitmap_set_line_length(fb, tk_max(fb->w * bpp, mem->online_line_length));
|
||||
|
||||
return fb;
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_begin_frame(lcd_t* lcd, const dirty_rects_t* dirty_rects) {
|
||||
bitmap_t fb;
|
||||
lcd_mem_t* mem = (lcd_mem_t*)lcd;
|
||||
lcd_fb_dirty_rects_update_all_fb_dirty_rects(&(mem->fb_dirty_rects_list), dirty_rects);
|
||||
|
||||
#if WITH_LCD_CLEAR_ALPHA
|
||||
lcd_mem_init_drawing_fb(lcd, &fb);
|
||||
|
||||
if (lcd->draw_mode == LCD_DRAW_OFFLINE || dirty_rects == NULL) {
|
||||
rect_t r = rect_init(0, 0, lcd->w, lcd->h);
|
||||
return image_clear(&fb, &r, color_init(0x0, 0x0, 0x0, 0x0));
|
||||
} else {
|
||||
if (dirty_rects->disable_multiple) {
|
||||
return image_clear(&fb, (const rect_t*)&(dirty_rects->max), color_init(0x0, 0x0, 0x0, 0x0));
|
||||
} else {
|
||||
int32_t i = 0;
|
||||
for (i = 0; i < dirty_rects->nr; i++) {
|
||||
const rect_t* iter = dirty_rects->rects + i;
|
||||
image_clear(&fb, iter, color_init(0x0, 0x0, 0x0, 0x0));
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
}
|
||||
#else
|
||||
(void)fb;
|
||||
return RET_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_fill_rect_with_color(lcd_t* lcd, xy_t x, xy_t y, wh_t w, wh_t h, color_t c) {
|
||||
bitmap_t fb;
|
||||
rect_t r = rect_init(x, y, w, h);
|
||||
c.rgba.a = (c.rgba.a * lcd->global_alpha) / 0xff;
|
||||
|
||||
lcd_mem_init_drawing_fb(lcd, &fb);
|
||||
return image_fill(&fb, &r, c);
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_fill_rect(lcd_t* lcd, xy_t x, xy_t y, wh_t w, wh_t h) {
|
||||
return lcd_mem_fill_rect_with_color(lcd, x, y, w, h, lcd->fill_color);
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_clear_rect(lcd_t* lcd, xy_t x, xy_t y, wh_t w, wh_t h) {
|
||||
bitmap_t fb;
|
||||
rect_t r = rect_init(x, y, w, h);
|
||||
color_t c = lcd->fill_color;
|
||||
c.rgba.a = (c.rgba.a * lcd->global_alpha) / 0xff;
|
||||
|
||||
lcd_mem_init_drawing_fb(lcd, &fb);
|
||||
return image_clear(&fb, &r, c);
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_draw_hline(lcd_t* lcd, xy_t x, xy_t y, wh_t w) {
|
||||
return lcd_mem_fill_rect_with_color(lcd, x, y, w, 1, lcd->stroke_color);
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_draw_vline(lcd_t* lcd, xy_t x, xy_t y, wh_t h) {
|
||||
wh_t i = 0;
|
||||
color_t c = lcd->stroke_color;
|
||||
uint8_t a = (c.rgba.a * lcd->global_alpha) / 0xff;
|
||||
uint32_t line_length = lcd_mem_get_line_length((lcd_mem_t*)lcd);
|
||||
uint8_t* fbuff = (uint8_t*)lcd_mem_init_drawing_fb(lcd, NULL);
|
||||
pixel_t* p = (pixel_t*)(fbuff + y * line_length) + x;
|
||||
|
||||
if (a >= TK_OPACITY_ALPHA) {
|
||||
pixel_t pixel = color_to_pixel(c);
|
||||
for (i = 0; i < h; i++) {
|
||||
*p = pixel;
|
||||
p = (pixel_t*)(((char*)p) + line_length);
|
||||
}
|
||||
} else if (a >= TK_TRANSPARENT_ALPHA) {
|
||||
c.rgba.a = a;
|
||||
for (i = 0; i < h; i++) {
|
||||
*p = blend_pixel(*p, c);
|
||||
p = (pixel_t*)(((char*)p) + line_length);
|
||||
}
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_draw_points(lcd_t* lcd, point_t* points, uint32_t nr) {
|
||||
wh_t i = 0;
|
||||
color_t c = lcd->stroke_color;
|
||||
pixel_t pixel = color_to_pixel(c);
|
||||
uint8_t a = (c.rgba.a * lcd->global_alpha) / 0xff;
|
||||
uint32_t line_length = lcd_mem_get_line_length((lcd_mem_t*)lcd);
|
||||
uint8_t* fbuff = (uint8_t*)lcd_mem_init_drawing_fb(lcd, NULL);
|
||||
|
||||
for (i = 0; i < nr; i++) {
|
||||
point_t* point = points + i;
|
||||
pixel_t* p = (pixel_t*)(fbuff + point->y * line_length) + point->x;
|
||||
|
||||
if (a >= TK_OPACITY_ALPHA) {
|
||||
*p = pixel;
|
||||
} else if (a >= TK_TRANSPARENT_ALPHA) {
|
||||
*p = blend_pixel(*p, c);
|
||||
}
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static color_t lcd_mem_get_point_color(lcd_t* lcd, xy_t x, xy_t y) {
|
||||
color_t c;
|
||||
uint32_t line_length = lcd_mem_get_line_length((lcd_mem_t*)lcd);
|
||||
uint8_t* fbuff = (uint8_t*)lcd_mem_init_drawing_fb(lcd, NULL);
|
||||
|
||||
pixel_t p = *((pixel_t*)(fbuff + y * line_length) + x);
|
||||
rgba_t rgba = pixel_to_rgba(p);
|
||||
c.rgba = rgba;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_draw_glyph(lcd_t* lcd, glyph_t* glyph, const rect_t* src, xy_t x, xy_t y) {
|
||||
wh_t i = 0;
|
||||
wh_t j = 0;
|
||||
wh_t sx = src->x;
|
||||
wh_t sy = src->y;
|
||||
wh_t sw = src->w;
|
||||
wh_t sh = src->h;
|
||||
wh_t w = lcd->w;
|
||||
color_t color = lcd->text_color;
|
||||
uint8_t color_alpha = color.rgba.a;
|
||||
uint8_t global_alpha = lcd->global_alpha;
|
||||
uint32_t line_length = lcd_mem_get_line_length((lcd_mem_t*)lcd);
|
||||
uint8_t* fbuff = (uint8_t*)lcd_mem_init_drawing_fb(lcd, NULL);
|
||||
const uint8_t* src_p = glyph->data + glyph->w * sy + sx;
|
||||
pixel_t pixel = color_to_pixel(color);
|
||||
|
||||
for (j = 0; j < sh; j++) {
|
||||
pixel_t* dst_p = (pixel_t*)(fbuff + (y + j) * line_length) + x;
|
||||
const uint8_t* s = src_p;
|
||||
pixel_t* d = dst_p;
|
||||
|
||||
for (i = 0; i < sw; i++, d++, s++) {
|
||||
uint8_t a = global_alpha > TK_OPACITY_ALPHA ? *s : ((*s * global_alpha) >> 8);
|
||||
a = (a * color_alpha) >> 8;
|
||||
if (a >= TK_OPACITY_ALPHA) {
|
||||
*d = pixel;
|
||||
} else if (a >= TK_TRANSPARENT_ALPHA) {
|
||||
color.rgba.a = a;
|
||||
*d = blend_pixel(*d, color);
|
||||
}
|
||||
}
|
||||
src_p += glyph->w;
|
||||
dst_p += w;
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_draw_image_matrix(lcd_t* lcd, draw_image_info_t* info) {
|
||||
matrix_t* m = &(info->matrix);
|
||||
const rect_t* s = &(info->src);
|
||||
const rect_t* d = &(info->dst);
|
||||
vgcanvas_t* canvas = lcd_get_vgcanvas(lcd);
|
||||
|
||||
if (canvas != NULL) {
|
||||
rect_t r = info->clip;
|
||||
vgcanvas_save(canvas);
|
||||
vgcanvas_clip_rect(canvas, r.x, r.y, r.w, r.h);
|
||||
vgcanvas_set_transform(canvas, m->a0, m->a1, m->a2, m->a3, m->a4, m->a5);
|
||||
vgcanvas_draw_image(canvas, info->img, s->x, s->y, s->w, s->h, d->x, d->y, d->w, d->h);
|
||||
vgcanvas_restore(canvas);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
return RET_NOT_IMPL;
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_draw_image(lcd_t* lcd, bitmap_t* img, const rectf_t* src, const rectf_t* dst) {
|
||||
bitmap_t fb;
|
||||
ret_t ret = RET_OK;
|
||||
bool_t is_opaque = (img->flags & BITMAP_FLAG_OPAQUE || img->format == BITMAP_FMT_RGB565);
|
||||
|
||||
lcd_mem_init_drawing_fb(lcd, &fb);
|
||||
|
||||
if (img->format == fb.format && is_opaque && src->w == dst->w && src->h == dst->h &&
|
||||
lcd->global_alpha >= TK_OPACITY_ALPHA) {
|
||||
xy_t dx = (xy_t)(dst->x);
|
||||
xy_t dy = (xy_t)(dst->y);
|
||||
rect_t r = rect_from_rectf(src);
|
||||
ret = image_copy(&fb, img, &r, dx, dy);
|
||||
} else {
|
||||
ret = image_blend(&fb, img, dst, src, lcd->global_alpha);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static vgcanvas_t* lcd_mem_get_vgcanvas(lcd_t* lcd) {
|
||||
uint32_t w = lcd->w;
|
||||
uint32_t h = lcd->h;
|
||||
lcd_mem_t* mem = (lcd_mem_t*)lcd;
|
||||
bitmap_format_t format = mem->format;
|
||||
uint32_t line_length = lcd_mem_get_line_length(mem);
|
||||
uint32_t* fbdata = (uint32_t*)lcd_mem_init_drawing_fb(lcd, NULL);
|
||||
|
||||
if (mem->vgcanvas == NULL) {
|
||||
mem->vgcanvas = vgcanvas_create(w, h, line_length, format, fbdata);
|
||||
if (mem->vgcanvas)
|
||||
vgcanvas_clip_rect(mem->vgcanvas, 0, 0, w, h);
|
||||
} else {
|
||||
vgcanvas_reinit(mem->vgcanvas, w, h, line_length, format, fbdata);
|
||||
}
|
||||
|
||||
return mem->vgcanvas;
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_get_dirty_rect(lcd_t* lcd, rect_t* r) {
|
||||
lcd_mem_t* mem = (lcd_mem_t*)lcd;
|
||||
uint8_t* offline_fb = lcd_mem_get_offline_fb(mem);
|
||||
const dirty_rects_t* dirty_rects = lcd_fb_dirty_rects_get_dirty_rects_by_fb(&(mem->fb_dirty_rects_list), offline_fb);
|
||||
if (dirty_rects != NULL) {
|
||||
r->x = dirty_rects->max.x;
|
||||
r->y = dirty_rects->max.y;
|
||||
r->w = dirty_rects->max.w;
|
||||
r->h = dirty_rects->max.h;
|
||||
} else {
|
||||
r->x = 0;
|
||||
r->y = 0;
|
||||
r->w = lcd->w;
|
||||
r->h = lcd->h;
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static const dirty_rects_t* lcd_mem_get_dirty_rects(lcd_t* lcd) {
|
||||
lcd_mem_t* mem = (lcd_mem_t*)lcd;
|
||||
uint8_t* offline_fb = lcd_mem_get_offline_fb(mem);
|
||||
return lcd_fb_dirty_rects_get_dirty_rects_by_fb(&(mem->fb_dirty_rects_list), offline_fb);
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_flush(lcd_t* lcd) {
|
||||
bitmap_t online_fb;
|
||||
bitmap_t offline_fb;
|
||||
const dirty_rects_t* dirty_rects;
|
||||
lcd_mem_t* mem = (lcd_mem_t*)lcd;
|
||||
system_info_t* info = system_info();
|
||||
uint8_t* fb = lcd_mem_get_offline_fb(mem);
|
||||
lcd_orientation_t o = info->lcd_orientation;
|
||||
|
||||
lcd_mem_init_drawing_fb(lcd, &offline_fb);
|
||||
lcd_mem_init_online_fb(lcd, &online_fb, o);
|
||||
|
||||
if (mem->wait_vbi != NULL) {
|
||||
mem->wait_vbi(mem->wait_vbi_ctx);
|
||||
}
|
||||
|
||||
dirty_rects = lcd_fb_dirty_rects_get_dirty_rects_by_fb(&(mem->fb_dirty_rects_list), fb);
|
||||
if (dirty_rects != NULL && dirty_rects->nr > 0) {
|
||||
if (dirty_rects->disable_multiple) {
|
||||
const rect_t* dr = (const rect_t*)&(dirty_rects->max);
|
||||
if (o == LCD_ORIENTATION_0) {
|
||||
image_copy(&online_fb, &offline_fb, dr, dr->x, dr->y);
|
||||
} else {
|
||||
image_rotate(&online_fb, &offline_fb, dr, o);
|
||||
}
|
||||
} else {
|
||||
uint32_t i = 0;
|
||||
for (i = 0; i < dirty_rects->nr; i++) {
|
||||
const rect_t* dr = (const rect_t*)dirty_rects->rects + i;
|
||||
if (o == LCD_ORIENTATION_0) {
|
||||
image_copy(&online_fb, &offline_fb, dr, dr->x, dr->y);
|
||||
} else {
|
||||
image_rotate(&online_fb, &offline_fb, dr, o);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_end_frame(lcd_t* lcd) {
|
||||
lcd_mem_t* mem = (lcd_mem_t*)lcd;
|
||||
uint8_t* offline_fb = lcd_mem_get_offline_fb(mem);
|
||||
if (lcd->draw_mode != LCD_DRAW_OFFLINE) {
|
||||
if (lcd_is_swappable(lcd)) {
|
||||
lcd_swap(lcd);
|
||||
} else {
|
||||
lcd_flush(lcd);
|
||||
}
|
||||
|
||||
lcd_sync(lcd);
|
||||
}
|
||||
|
||||
lcd_fb_dirty_rects_reset_dirty_rects_by_fb(&(mem->fb_dirty_rects_list), offline_fb);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_destroy(lcd_t* lcd) {
|
||||
lcd_mem_t* mem = (lcd_mem_t*)lcd;
|
||||
return_value_if_fail(lcd->begin_frame != NULL, RET_BAD_PARAMS);
|
||||
|
||||
return_value_if_fail(lcd_mem_deinit(mem) == RET_OK, RET_BAD_PARAMS);
|
||||
|
||||
memset(lcd, 0x00, sizeof(lcd_mem_t));
|
||||
TKMEM_FREE(lcd);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_resize(lcd_t* lcd, wh_t w, wh_t h, uint32_t line_length) {
|
||||
lcd_mem_t* mem = (lcd_mem_t*)lcd;
|
||||
uint32_t bpp = bitmap_get_bpp_of_format(LCD_FORMAT);
|
||||
|
||||
lcd->w = w;
|
||||
lcd->h = h;
|
||||
mem->line_length = tk_max(mem->base.w * bpp, line_length);
|
||||
if (mem->vgcanvas != NULL) {
|
||||
vgcanvas_clip_rect(mem->vgcanvas, 0, 0, w, h);
|
||||
}
|
||||
lcd_fb_dirty_rects_reinit(&(mem->fb_dirty_rects_list), w, h);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_set_orientation(lcd_t* lcd, lcd_orientation_t old_orientation, lcd_orientation_t new_orientation) {
|
||||
if (tk_is_swap_size_by_orientation(old_orientation, new_orientation)) {
|
||||
return lcd_mem_resize(lcd, lcd->h, lcd->w, 0);
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static bitmap_format_t lcd_mem_get_desired_bitmap_format(lcd_t* lcd) {
|
||||
lcd_mem_t* mem = (lcd_mem_t*)lcd;
|
||||
|
||||
return mem->format;
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_set_line_length_impl(lcd_t* lcd, uint32_t line_length) {
|
||||
lcd_mem_t* mem = ((lcd_mem_t*)lcd);
|
||||
return_value_if_fail(mem != NULL, RET_BAD_PARAMS);
|
||||
mem->line_length = line_length;
|
||||
mem->online_line_length = line_length;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_set_vgcanvas(lcd_t* lcd, vgcanvas_t* vgcanvas) {
|
||||
lcd_mem_t* mem = ((lcd_mem_t*)lcd);
|
||||
return_value_if_fail(mem != NULL, RET_BAD_PARAMS);
|
||||
mem->vgcanvas = vgcanvas;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static lcd_t* lcd_mem_init(lcd_mem_t* lcd, wh_t w, wh_t h, bool_t alloc) {
|
||||
lcd_t* base = NULL;
|
||||
system_info_t* info = system_info();
|
||||
uint32_t bpp = bitmap_get_bpp_of_format(LCD_FORMAT);
|
||||
|
||||
return_value_if_fail(lcd != NULL, NULL);
|
||||
base = &(lcd->base);
|
||||
|
||||
lcd_fb_dirty_rects_init(&(lcd->fb_dirty_rects_list), w, h);
|
||||
|
||||
if (alloc) {
|
||||
uint8_t* offline_fb = (uint8_t*)TKMEM_ALLOC(w * h * sizeof(pixel_t));
|
||||
ret_t ret = lcd_mem_set_offline_fb(lcd, offline_fb);
|
||||
if (ret != RET_OK && offline_fb != NULL) {
|
||||
TKMEM_FREE(offline_fb);
|
||||
}
|
||||
return_value_if_fail(lcd->offline_fb != NULL && ret == RET_OK, NULL);
|
||||
}
|
||||
|
||||
lcd->own_offline_fb = alloc;
|
||||
|
||||
base->begin_frame = lcd_mem_begin_frame;
|
||||
base->draw_vline = lcd_mem_draw_vline;
|
||||
base->draw_hline = lcd_mem_draw_hline;
|
||||
base->fill_rect = lcd_mem_fill_rect;
|
||||
base->clear_rect = lcd_mem_clear_rect;
|
||||
base->draw_image = lcd_mem_draw_image;
|
||||
base->draw_image_matrix = lcd_mem_draw_image_matrix;
|
||||
base->draw_glyph = lcd_mem_draw_glyph;
|
||||
base->draw_points = lcd_mem_draw_points;
|
||||
base->get_point_color = lcd_mem_get_point_color;
|
||||
base->get_vgcanvas = lcd_mem_get_vgcanvas;
|
||||
base->get_desired_bitmap_format = lcd_mem_get_desired_bitmap_format;
|
||||
base->end_frame = lcd_mem_end_frame;
|
||||
base->destroy = lcd_mem_destroy;
|
||||
base->resize = lcd_mem_resize;
|
||||
base->flush = lcd_mem_flush;
|
||||
base->set_vgcanvas = lcd_mem_set_vgcanvas;
|
||||
base->set_line_length = lcd_mem_set_line_length_impl;
|
||||
base->get_dirty_rect = lcd_mem_get_dirty_rect;
|
||||
base->get_dirty_rects = lcd_mem_get_dirty_rects;
|
||||
base->set_orientation = lcd_mem_set_orientation;
|
||||
|
||||
base->w = w;
|
||||
base->h = h;
|
||||
base->ratio = 1;
|
||||
base->global_alpha = 0xff;
|
||||
base->type = LCD_FRAMEBUFFER;
|
||||
base->support_dirty_rect = TRUE;
|
||||
|
||||
lcd->format = LCD_FORMAT;
|
||||
lcd->line_length = w * bpp;
|
||||
lcd->online_line_length = lcd->line_length;
|
||||
lcd->online_gb = graphic_buffer_create_with_data(NULL, w, h, LCD_FORMAT);
|
||||
lcd->offline_gb = graphic_buffer_create_with_data(NULL, w, h, LCD_FORMAT);
|
||||
|
||||
system_info_set_lcd_w(info, base->w);
|
||||
system_info_set_lcd_h(info, base->h);
|
||||
system_info_set_lcd_type(info, base->type);
|
||||
system_info_set_device_pixel_ratio(info, 1);
|
||||
|
||||
return base;
|
||||
}
|
||||
|
||||
static lcd_t* lcd_mem_create(wh_t w, wh_t h, bool_t alloc) {
|
||||
lcd_mem_t* lcd = TKMEM_ZALLOC(lcd_mem_t);
|
||||
return_value_if_fail(lcd != NULL, NULL);
|
||||
return lcd_mem_init(lcd, w, h, alloc);
|
||||
}
|
||||
|
||||
static lcd_t* lcd_mem_create_double_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb) {
|
||||
lcd_t* lcd = lcd_mem_create(w, h, FALSE);
|
||||
lcd_mem_t* mem = (lcd_mem_t*)lcd;
|
||||
|
||||
lcd_mem_set_online_fb(mem, online_fb);
|
||||
lcd_mem_set_offline_fb(mem, offline_fb);
|
||||
|
||||
return lcd;
|
||||
}
|
||||
|
||||
static lcd_t* lcd_mem_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb,
|
||||
uint8_t* next_fb) {
|
||||
lcd_t* lcd = lcd_mem_create(w, h, FALSE);
|
||||
lcd_mem_t* mem = (lcd_mem_t*)lcd;
|
||||
|
||||
lcd_mem_set_next_fb(mem, next_fb);
|
||||
lcd_mem_set_online_fb(mem, online_fb);
|
||||
lcd_mem_set_offline_fb(mem, offline_fb);
|
||||
|
||||
return lcd;
|
||||
}
|
||||
|
||||
static lcd_t* lcd_mem_create_single_fb(wh_t w, wh_t h, uint8_t* fbuff) {
|
||||
lcd_t* lcd = lcd_mem_create(w, h, FALSE);
|
||||
lcd_mem_t* mem = (lcd_mem_t*)lcd;
|
||||
|
||||
lcd_mem_set_offline_fb(mem, fbuff);
|
||||
mem->online_fb = NULL;
|
||||
lcd->flush = NULL;
|
||||
|
||||
return lcd;
|
||||
}
|
56
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_bgr565.c
Normal file
56
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_bgr565.c
Normal file
@ -0,0 +1,56 @@
|
||||
/**
|
||||
* File: lcd_mem_bgr565.c
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: bgr565 mem lcd.
|
||||
*
|
||||
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* License file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* History:
|
||||
* ================================================================
|
||||
* 2021-07-08 Generated by gen.sh(DONT MODIFY IT)
|
||||
*
|
||||
*/
|
||||
|
||||
#define LCD_FORMAT BITMAP_FMT_BGR565
|
||||
|
||||
#include "tkc/mem.h"
|
||||
#include "base/pixel.h"
|
||||
#include "lcd/lcd_mem.h"
|
||||
|
||||
#define pixel_t pixel_bgr565_t
|
||||
#define pixel_bpp pixel_bgr565_BPP
|
||||
#define pixel_to_rgba pixel_bgr565_to_rgba
|
||||
#define pixel_from_rgb pixel_bgr565_from_rgb
|
||||
#define pixel_from_rgba pixel_bgr565_from_rgba
|
||||
|
||||
#include "blend/pixel_ops.inc"
|
||||
#include "lcd/lcd_mem.inc"
|
||||
|
||||
lcd_t* lcd_mem_bgr565_init(lcd_mem_t* lcd, wh_t w, wh_t h, bool_t alloc) {
|
||||
return lcd_mem_init(lcd, w, h, alloc);
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_bgr565_create(wh_t w, wh_t h, bool_t alloc) {
|
||||
return lcd_mem_create(w, h, alloc);
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_bgr565_create_single_fb(wh_t w, wh_t h, uint8_t* fbuff) {
|
||||
return lcd_mem_create_single_fb(w, h, fbuff);
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_bgr565_create_double_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb) {
|
||||
return lcd_mem_create_double_fb(w, h, online_fb, offline_fb);
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_bgr565_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb,
|
||||
uint8_t* next_fb) {
|
||||
return lcd_mem_create_three_fb(w, h, online_fb, offline_fb, next_fb);
|
||||
}
|
107
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_bgr565.h
Normal file
107
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_bgr565.h
Normal file
@ -0,0 +1,107 @@
|
||||
/**
|
||||
* File: lcd_mem_bgr565.h
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: bgr565 mem lcd.
|
||||
*
|
||||
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* this program is distributed in the hope that it will be useful,
|
||||
* but without any warranty; without even the implied warranty of
|
||||
* merchantability or fitness for a particular purpose. see the
|
||||
* license file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* history:
|
||||
* ================================================================
|
||||
* 2021-07-08 Generated by gen.sh(DONT MODIFY IT)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TK_LCD_MEM_BGR565_H
|
||||
#define TK_LCD_MEM_BGR565_H
|
||||
|
||||
#include "lcd/lcd_mem.h"
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
/**
|
||||
* @class lcd_mem_bgr565_t
|
||||
* @parent lcd_t
|
||||
* @annotation ["fake"]
|
||||
*/
|
||||
|
||||
/**
|
||||
* @method lcd_mem_bgr565_create
|
||||
*
|
||||
* 创建lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {bool_t} alloc 是否分配内存。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_bgr565_create(wh_t w, wh_t h, bool_t alloc);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_bgr565_create_single_fb
|
||||
*
|
||||
* 创建single fb lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {uint8_t*} fbuff 帧率缓冲区。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_bgr565_create_single_fb(wh_t w, wh_t h, uint8_t* fbuff);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_bgr565_create_double_fb
|
||||
*
|
||||
* 创建double fb lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {uint8_t*} online_fb 在线帧率缓冲区。
|
||||
* @param {uint8_t*} offline_fb 离线帧率缓冲区。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_bgr565_create_double_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_bgr565_create_three_fb
|
||||
*
|
||||
* 创建three fb lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {uint8_t*} online_fb 在线帧率缓冲区。
|
||||
* @param {uint8_t*} offline_fb 离线帧率缓冲区。
|
||||
* @param {uint8_t*} next_fb 待显示的帧率缓冲区。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_bgr565_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb,
|
||||
uint8_t* next_fb);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_bgr565_init
|
||||
*
|
||||
* 创建lcd对象。
|
||||
*
|
||||
* @param {lcd_mem_t*} lcd 对象。
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {bool_t} alloc 是否分配内存。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_bgr565_init(lcd_mem_t* lcd, wh_t w, wh_t h, bool_t alloc);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /*TK_LCD_MEM_BGR565_H*/
|
56
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_bgr888.c
Normal file
56
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_bgr888.c
Normal file
@ -0,0 +1,56 @@
|
||||
/**
|
||||
* File: lcd_mem_bgr888.c
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: bgr888 mem lcd.
|
||||
*
|
||||
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* License file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* History:
|
||||
* ================================================================
|
||||
* 2021-07-08 Generated by gen.sh(DONT MODIFY IT)
|
||||
*
|
||||
*/
|
||||
|
||||
#define LCD_FORMAT BITMAP_FMT_BGR888
|
||||
|
||||
#include "tkc/mem.h"
|
||||
#include "base/pixel.h"
|
||||
#include "lcd/lcd_mem.h"
|
||||
|
||||
#define pixel_t pixel_bgr888_t
|
||||
#define pixel_bpp pixel_bgr888_BPP
|
||||
#define pixel_to_rgba pixel_bgr888_to_rgba
|
||||
#define pixel_from_rgb pixel_bgr888_from_rgb
|
||||
#define pixel_from_rgba pixel_bgr888_from_rgba
|
||||
|
||||
#include "blend/pixel_ops.inc"
|
||||
#include "lcd/lcd_mem.inc"
|
||||
|
||||
lcd_t* lcd_mem_bgr888_init(lcd_mem_t* lcd, wh_t w, wh_t h, bool_t alloc) {
|
||||
return lcd_mem_init(lcd, w, h, alloc);
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_bgr888_create(wh_t w, wh_t h, bool_t alloc) {
|
||||
return lcd_mem_create(w, h, alloc);
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_bgr888_create_single_fb(wh_t w, wh_t h, uint8_t* fbuff) {
|
||||
return lcd_mem_create_single_fb(w, h, fbuff);
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_bgr888_create_double_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb) {
|
||||
return lcd_mem_create_double_fb(w, h, online_fb, offline_fb);
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_bgr888_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb,
|
||||
uint8_t* next_fb) {
|
||||
return lcd_mem_create_three_fb(w, h, online_fb, offline_fb, next_fb);
|
||||
}
|
107
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_bgr888.h
Normal file
107
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_bgr888.h
Normal file
@ -0,0 +1,107 @@
|
||||
/**
|
||||
* File: lcd_mem_bgr888.h
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: bgr888 mem lcd.
|
||||
*
|
||||
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* this program is distributed in the hope that it will be useful,
|
||||
* but without any warranty; without even the implied warranty of
|
||||
* merchantability or fitness for a particular purpose. see the
|
||||
* license file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* history:
|
||||
* ================================================================
|
||||
* 2021-07-08 Generated by gen.sh(DONT MODIFY IT)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TK_LCD_MEM_BGR888_H
|
||||
#define TK_LCD_MEM_BGR888_H
|
||||
|
||||
#include "lcd/lcd_mem.h"
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
/**
|
||||
* @class lcd_mem_bgr888_t
|
||||
* @parent lcd_t
|
||||
* @annotation ["fake"]
|
||||
*/
|
||||
|
||||
/**
|
||||
* @method lcd_mem_bgr888_create
|
||||
*
|
||||
* 创建lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {bool_t} alloc 是否分配内存。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_bgr888_create(wh_t w, wh_t h, bool_t alloc);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_bgr888_create_single_fb
|
||||
*
|
||||
* 创建single fb lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {uint8_t*} fbuff 帧率缓冲区。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_bgr888_create_single_fb(wh_t w, wh_t h, uint8_t* fbuff);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_bgr888_create_double_fb
|
||||
*
|
||||
* 创建double fb lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {uint8_t*} online_fb 在线帧率缓冲区。
|
||||
* @param {uint8_t*} offline_fb 离线帧率缓冲区。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_bgr888_create_double_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_bgr888_create_three_fb
|
||||
*
|
||||
* 创建three fb lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {uint8_t*} online_fb 在线帧率缓冲区。
|
||||
* @param {uint8_t*} offline_fb 离线帧率缓冲区。
|
||||
* @param {uint8_t*} next_fb 待显示的帧率缓冲区。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_bgr888_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb,
|
||||
uint8_t* next_fb);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_bgr888_init
|
||||
*
|
||||
* 创建lcd对象。
|
||||
*
|
||||
* @param {lcd_mem_t*} lcd 对象。
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {bool_t} alloc 是否分配内存。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_bgr888_init(lcd_mem_t* lcd, wh_t w, wh_t h, bool_t alloc);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /*TK_LCD_MEM_BGR888_H*/
|
56
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_bgra8888.c
Normal file
56
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_bgra8888.c
Normal file
@ -0,0 +1,56 @@
|
||||
/**
|
||||
* File: lcd_mem_bgra8888.c
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: bgra8888 mem lcd.
|
||||
*
|
||||
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* License file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* History:
|
||||
* ================================================================
|
||||
* 2021-07-08 Generated by gen.sh(DONT MODIFY IT)
|
||||
*
|
||||
*/
|
||||
|
||||
#define LCD_FORMAT BITMAP_FMT_BGRA8888
|
||||
|
||||
#include "tkc/mem.h"
|
||||
#include "base/pixel.h"
|
||||
#include "lcd/lcd_mem.h"
|
||||
|
||||
#define pixel_t pixel_bgra8888_t
|
||||
#define pixel_bpp pixel_bgra8888_BPP
|
||||
#define pixel_to_rgba pixel_bgra8888_to_rgba
|
||||
#define pixel_from_rgb pixel_bgra8888_from_rgb
|
||||
#define pixel_from_rgba pixel_bgra8888_from_rgba
|
||||
|
||||
#include "blend/pixel_ops.inc"
|
||||
#include "lcd/lcd_mem.inc"
|
||||
|
||||
lcd_t* lcd_mem_bgra8888_init(lcd_mem_t* lcd, wh_t w, wh_t h, bool_t alloc) {
|
||||
return lcd_mem_init(lcd, w, h, alloc);
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_bgra8888_create(wh_t w, wh_t h, bool_t alloc) {
|
||||
return lcd_mem_create(w, h, alloc);
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_bgra8888_create_single_fb(wh_t w, wh_t h, uint8_t* fbuff) {
|
||||
return lcd_mem_create_single_fb(w, h, fbuff);
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_bgra8888_create_double_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb) {
|
||||
return lcd_mem_create_double_fb(w, h, online_fb, offline_fb);
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_bgra8888_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb,
|
||||
uint8_t* next_fb) {
|
||||
return lcd_mem_create_three_fb(w, h, online_fb, offline_fb, next_fb);
|
||||
}
|
107
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_bgra8888.h
Normal file
107
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_bgra8888.h
Normal file
@ -0,0 +1,107 @@
|
||||
/**
|
||||
* File: lcd_mem_bgra8888.h
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: bgra8888 mem lcd.
|
||||
*
|
||||
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* this program is distributed in the hope that it will be useful,
|
||||
* but without any warranty; without even the implied warranty of
|
||||
* merchantability or fitness for a particular purpose. see the
|
||||
* license file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* history:
|
||||
* ================================================================
|
||||
* 2021-07-08 Generated by gen.sh(DONT MODIFY IT)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TK_LCD_MEM_BGRA8888_H
|
||||
#define TK_LCD_MEM_BGRA8888_H
|
||||
|
||||
#include "lcd/lcd_mem.h"
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
/**
|
||||
* @class lcd_mem_bgra8888_t
|
||||
* @parent lcd_t
|
||||
* @annotation ["fake"]
|
||||
*/
|
||||
|
||||
/**
|
||||
* @method lcd_mem_bgra8888_create
|
||||
*
|
||||
* 创建lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {bool_t} alloc 是否分配内存。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_bgra8888_create(wh_t w, wh_t h, bool_t alloc);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_bgra8888_create_single_fb
|
||||
*
|
||||
* 创建single fb lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {uint8_t*} fbuff 帧率缓冲区。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_bgra8888_create_single_fb(wh_t w, wh_t h, uint8_t* fbuff);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_bgra8888_create_double_fb
|
||||
*
|
||||
* 创建double fb lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {uint8_t*} online_fb 在线帧率缓冲区。
|
||||
* @param {uint8_t*} offline_fb 离线帧率缓冲区。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_bgra8888_create_double_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_bgra8888_create_three_fb
|
||||
*
|
||||
* 创建three fb lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {uint8_t*} online_fb 在线帧率缓冲区。
|
||||
* @param {uint8_t*} offline_fb 离线帧率缓冲区。
|
||||
* @param {uint8_t*} next_fb 待显示的帧率缓冲区。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_bgra8888_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb,
|
||||
uint8_t* next_fb);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_bgra8888_init
|
||||
*
|
||||
* 创建lcd对象。
|
||||
*
|
||||
* @param {lcd_mem_t*} lcd 对象。
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {bool_t} alloc 是否分配内存。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_bgra8888_init(lcd_mem_t* lcd, wh_t w, wh_t h, bool_t alloc);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /*TK_LCD_MEM_BGRA8888_H*/
|
65
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_fragment.h
Normal file
65
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_fragment.h
Normal file
@ -0,0 +1,65 @@
|
||||
/**
|
||||
* File: lcd_mem_fragment.h
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: mem fragment based implemented lcd interface
|
||||
*
|
||||
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* this program is distributed in the hope that it will be useful,
|
||||
* but without any warranty; without even the implied warranty of
|
||||
* merchantability or fitness for a particular purpose. see the
|
||||
* license file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* history:
|
||||
* ================================================================
|
||||
* 2019-11-14 li xianjing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LCD_MEM_FRAGMENT_H
|
||||
#define LCD_MEM_FRAGMENT_H
|
||||
|
||||
#include "base/lcd.h"
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
/**
|
||||
* @class lcd_mem_fragment_t
|
||||
* @parent lcd_t
|
||||
* 片段的LCD。
|
||||
*
|
||||
* 在一些低端平台没有足够的内存提供一个完整的framebuffer,此时我们用一小块内存模拟framebuffer,
|
||||
* 每次只画屏幕上一小块。这样可以有些避免屏幕闪烁的问题。
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @method lcd_mem_fragment_create
|
||||
* @export none
|
||||
* 创建lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_fragment_create(wh_t w, wh_t h);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_fragment_get_buff
|
||||
* @export none
|
||||
*
|
||||
* 获取framebuffer的地址。
|
||||
*
|
||||
* @param {lcd_t*} lcd lcd对象。
|
||||
*
|
||||
* @return {uint8_t*} 返回framebuffer的地址。
|
||||
*/
|
||||
uint8_t* lcd_mem_fragment_get_buff(lcd_t* lcd);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /*LCD_MEM_FRAGMENT_H*/
|
385
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_fragment.inc
Normal file
385
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_fragment.inc
Normal file
@ -0,0 +1,385 @@
|
||||
/**
|
||||
* File: lcd_mem_fragment.h
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: mem fragment based implemented lcd interface
|
||||
*
|
||||
* Copyright (c) 2018 - 2020 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* this program is distributed in the hope that it will be useful,
|
||||
* but without any warranty; without even the implied warranty of
|
||||
* merchantability or fitness for a particular purpose. see the
|
||||
* license file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* history:
|
||||
* ================================================================
|
||||
* 2019-11-14 li xianjing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
#include "tkc/mem.h"
|
||||
#include "tkc/darray.h"
|
||||
#include "base/vgcanvas.h"
|
||||
#include "blend/image_g2d.h"
|
||||
#include "base/system_info.h"
|
||||
|
||||
#include "base/lcd.h"
|
||||
#include "base/bitmap.h"
|
||||
|
||||
typedef struct _lcd_mem_fragment_t {
|
||||
lcd_t base;
|
||||
|
||||
xy_t x;
|
||||
xy_t y;
|
||||
wh_t w;
|
||||
wh_t h;
|
||||
|
||||
rect_t dirty_rect;
|
||||
|
||||
bitmap_t fb;
|
||||
graphic_buffer_t* gb;
|
||||
pixel_t buff[FRAGMENT_FRAME_BUFFER_SIZE];
|
||||
} lcd_mem_fragment_t;
|
||||
|
||||
static ret_t lcd_mem_fragment_begin_frame(lcd_t* lcd, const dirty_rects_t* dirty_rects) {
|
||||
lcd_mem_fragment_t* mem = (lcd_mem_fragment_t*)lcd;
|
||||
uint32_t bpp = bitmap_get_bpp_of_format(LCD_FORMAT);
|
||||
|
||||
mem->x = dirty_rects->max.x;
|
||||
mem->y = dirty_rects->max.y;
|
||||
|
||||
mem->fb.buffer = mem->gb;
|
||||
mem->fb.w = dirty_rects->max.w;
|
||||
mem->fb.h = dirty_rects->max.h;
|
||||
mem->fb.format = LCD_FORMAT;
|
||||
mem->fb.flags = BITMAP_FLAG_OPAQUE;
|
||||
mem->fb.line_length = dirty_rects->max.w * bpp;
|
||||
graphic_buffer_attach(mem->gb, mem->buff, mem->fb.w, mem->fb.h);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_fragment_fill_rect_with_color(lcd_t* lcd, xy_t x, xy_t y, wh_t w, wh_t h,
|
||||
color_t c) {
|
||||
lcd_mem_fragment_t* mem = (lcd_mem_fragment_t*)lcd;
|
||||
|
||||
bitmap_t* fb = &(mem->fb);
|
||||
uint32_t dx = x - mem->x;
|
||||
uint32_t dy = y - mem->y;
|
||||
rect_t r = rect_init(dx, dy, w, h);
|
||||
|
||||
c.rgba.a = (c.rgba.a * lcd->global_alpha) / 0xff;
|
||||
|
||||
return image_fill(fb, &r, c);
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_fragment_fill_rect(lcd_t* lcd, xy_t x, xy_t y, wh_t w, wh_t h) {
|
||||
lcd_mem_fragment_t* mem = (lcd_mem_fragment_t*)lcd;
|
||||
assert(x >= mem->x && y >= mem->y);
|
||||
assert(w <= mem->fb.w && h <= mem->fb.h);
|
||||
|
||||
return lcd_mem_fragment_fill_rect_with_color(lcd, x, y, w, h, lcd->fill_color);
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_fragment_clear_rect(lcd_t* lcd, xy_t x, xy_t y, wh_t w, wh_t h) {
|
||||
lcd_mem_fragment_t* mem = (lcd_mem_fragment_t*)lcd;
|
||||
|
||||
bitmap_t* fb = &(mem->fb);
|
||||
uint32_t dx = x - mem->x;
|
||||
uint32_t dy = y - mem->y;
|
||||
color_t c = lcd->fill_color;
|
||||
rect_t r = rect_init(dx, dy, w, h);
|
||||
|
||||
assert(x >= mem->x && y >= mem->y);
|
||||
assert(w <= mem->fb.w && h <= mem->fb.h);
|
||||
|
||||
c.rgba.a = (c.rgba.a * lcd->global_alpha) / 0xff;
|
||||
|
||||
return image_clear(fb, &r, c);
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_fragment_draw_hline(lcd_t* lcd, xy_t x, xy_t y, wh_t w) {
|
||||
lcd_mem_fragment_t* mem = (lcd_mem_fragment_t*)lcd;
|
||||
assert(x >= mem->x && y >= mem->y);
|
||||
assert(w <= mem->fb.w);
|
||||
|
||||
return lcd_mem_fragment_fill_rect_with_color(lcd, x, y, w, 1, lcd->stroke_color);
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_fragment_draw_vline(lcd_t* lcd, xy_t x, xy_t y, wh_t h) {
|
||||
lcd_mem_fragment_t* mem = (lcd_mem_fragment_t*)lcd;
|
||||
|
||||
wh_t i = 0;
|
||||
uint32_t dx = x - mem->x;
|
||||
uint32_t dy = y - mem->y;
|
||||
color_t c = lcd->stroke_color;
|
||||
uint8_t* fbuff = (uint8_t*)(mem->buff);
|
||||
uint32_t line_length = mem->fb.line_length;
|
||||
uint8_t a = (c.rgba.a * lcd->global_alpha) / 0xff;
|
||||
pixel_t* p = (pixel_t*)(fbuff + dy * line_length) + dx;
|
||||
|
||||
assert(x >= mem->x && y >= mem->y);
|
||||
assert(h <= mem->fb.h);
|
||||
|
||||
if (a >= TK_OPACITY_ALPHA) {
|
||||
pixel_t pixel = color_to_pixel(c);
|
||||
for (i = 0; i < h; i++) {
|
||||
*p = pixel;
|
||||
p = (pixel_t*)(((char*)p) + line_length);
|
||||
}
|
||||
} else if (a >= TK_TRANSPARENT_ALPHA) {
|
||||
c.rgba.a = a;
|
||||
for (i = 0; i < h; i++) {
|
||||
*p = blend_pixel(*p, c);
|
||||
p = (pixel_t*)(((char*)p) + line_length);
|
||||
}
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_fragment_draw_points(lcd_t* lcd, point_t* points, uint32_t nr) {
|
||||
lcd_mem_fragment_t* mem = (lcd_mem_fragment_t*)lcd;
|
||||
|
||||
wh_t i = 0;
|
||||
color_t c = lcd->stroke_color;
|
||||
pixel_t pixel = color_to_pixel(c);
|
||||
uint8_t* fbuff = (uint8_t*)(mem->buff);
|
||||
uint32_t line_length = mem->fb.line_length;
|
||||
uint8_t a = (c.rgba.a * lcd->global_alpha) / 0xff;
|
||||
|
||||
for (i = 0; i < nr; i++) {
|
||||
point_t* point = points + i;
|
||||
uint32_t x = point->x - mem->x;
|
||||
uint32_t y = point->y - mem->y;
|
||||
pixel_t* p = (pixel_t*)(fbuff + y * line_length) + x;
|
||||
|
||||
if (a >= TK_OPACITY_ALPHA) {
|
||||
*p = pixel;
|
||||
} else if (a >= TK_TRANSPARENT_ALPHA) {
|
||||
*p = blend_pixel(*p, c);
|
||||
}
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static color_t lcd_mem_fragment_get_point_color(lcd_t* lcd, xy_t x, xy_t y) {
|
||||
lcd_mem_fragment_t* mem = (lcd_mem_fragment_t*)lcd;
|
||||
uint8_t* fbuff = (uint8_t*)(mem->buff);
|
||||
uint32_t line_length = mem->fb.line_length;
|
||||
uint32_t dx = x - mem->x;
|
||||
uint32_t dy = y - mem->y;
|
||||
pixel_t p = *((pixel_t*)(fbuff + dy * line_length) + dx);
|
||||
color_t c = pixel_to_rgba(p);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_fragment_draw_glyph(lcd_t* lcd, glyph_t* glyph, const rect_t* src, xy_t x, xy_t y) {
|
||||
lcd_mem_fragment_t* mem = (lcd_mem_fragment_t*)lcd;
|
||||
|
||||
wh_t i = 0;
|
||||
wh_t j = 0;
|
||||
wh_t sx = src->x;
|
||||
wh_t sy = src->y;
|
||||
wh_t sw = src->w;
|
||||
wh_t sh = src->h;
|
||||
wh_t w = lcd->w;
|
||||
color_t color = lcd->text_color;
|
||||
uint8_t global_alpha = lcd->global_alpha;
|
||||
uint32_t line_length = mem->fb.line_length;
|
||||
uint8_t* fbuff = (uint8_t*)(mem->buff);
|
||||
const uint8_t* src_p = glyph->data + glyph->w * sy + sx;
|
||||
pixel_t pixel = color_to_pixel(color);
|
||||
int32_t dx = x - mem->x;
|
||||
int32_t dy = y - mem->y;
|
||||
|
||||
assert(x >= mem->x && y >= mem->y);
|
||||
|
||||
for (j = 0; j < sh; j++) {
|
||||
pixel_t* dst_p = (pixel_t*)(fbuff + (dy + j) * line_length) + dx;
|
||||
const uint8_t* s = src_p;
|
||||
pixel_t* d = dst_p;
|
||||
|
||||
for (i = 0; i < sw; i++, d++, s++) {
|
||||
uint8_t a = global_alpha > TK_OPACITY_ALPHA ? *s : ((*s * global_alpha) >> 8);
|
||||
|
||||
if (a >= TK_OPACITY_ALPHA) {
|
||||
*d = pixel;
|
||||
} else if (a >= TK_TRANSPARENT_ALPHA) {
|
||||
color.rgba.a = a;
|
||||
*d = blend_pixel(*d, color);
|
||||
}
|
||||
}
|
||||
src_p += glyph->w;
|
||||
dst_p += w;
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_fragment_draw_image(lcd_t* lcd, bitmap_t* img, const rectf_t* src, const rectf_t* dst) {
|
||||
lcd_mem_fragment_t* mem = (lcd_mem_fragment_t*)lcd;
|
||||
|
||||
ret_t ret = RET_OK;
|
||||
bitmap_t* fb = &(mem->fb);
|
||||
int32_t x = dst->x - mem->x;
|
||||
int32_t y = dst->y - mem->y;
|
||||
rectf_t d = rectf_init(x, y, dst->w, dst->h);
|
||||
bool_t is_opaque = (img->flags & BITMAP_FLAG_OPAQUE || img->format == BITMAP_FMT_RGB565) &&
|
||||
lcd->global_alpha >= TK_OPACITY_ALPHA;
|
||||
|
||||
assert(dst->x >= mem->x && dst->y >= mem->y);
|
||||
assert(dst->w <= mem->fb.w && dst->h <= mem->fb.h);
|
||||
|
||||
if (img->format == fb->format && is_opaque && src->w == dst->w && src->h == dst->h) {
|
||||
rect_t s = rect_from_rectf(src);
|
||||
ret = image_copy(fb, img, &s, x, y);
|
||||
} else {
|
||||
ret = image_blend(fb, img, &d, src, lcd->global_alpha);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_fragment_flush(lcd_t* lcd) {
|
||||
lcd_mem_fragment_t* mem = (lcd_mem_fragment_t*)lcd;
|
||||
|
||||
int32_t x = mem->x;
|
||||
int32_t y = mem->y;
|
||||
uint32_t w = mem->fb.w;
|
||||
uint32_t h = mem->fb.h;
|
||||
pixel_t* p = mem->buff;
|
||||
|
||||
#ifdef lcd_draw_bitmap_impl
|
||||
lcd_draw_bitmap_impl(x, y, w, h, p);
|
||||
#else
|
||||
uint32_t nr = w * h;
|
||||
set_window_func(x, y, x + w - 1, y + h - 1);
|
||||
while (nr-- > 0) {
|
||||
write_data_func(*p++);
|
||||
}
|
||||
#endif
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_fragment_end_frame(lcd_t* lcd) {
|
||||
return lcd_flush(lcd);
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_fragment_destroy(lcd_t* lcd) {
|
||||
lcd_mem_fragment_t* mem = (lcd_mem_fragment_t*)lcd;
|
||||
|
||||
graphic_buffer_destroy(mem->gb);
|
||||
TKMEM_FREE(lcd);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_fragment_resize(lcd_t* lcd, wh_t w, wh_t h, uint32_t line_length) {
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_fragment_set_orientation(lcd_t* lcd, lcd_orientation_t old_orientation, lcd_orientation_t new_orientation) {
|
||||
if (tk_is_swap_size_by_orientation(old_orientation, new_orientation)) {
|
||||
return lcd_mem_fragment_resize(lcd, lcd->h, lcd->w, 0);
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
||||
static bitmap_format_t lcd_mem_fragment_get_desired_bitmap_format(lcd_t* lcd) {
|
||||
return LCD_FORMAT;
|
||||
}
|
||||
|
||||
static lcd_mem_fragment_t s_lcd_mem_fragment;
|
||||
|
||||
uint8_t* lcd_mem_fragment_get_buff(lcd_t* lcd) {
|
||||
lcd_mem_fragment_t* mem = (lcd_mem_fragment_t*)lcd;
|
||||
return_value_if_fail(lcd != NULL && mem != NULL, NULL);
|
||||
|
||||
return (uint8_t*)mem->buff;
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_fragment_set_clip_rect(lcd_t* lcd, const rect_t* r) {
|
||||
rect_t dirty_r;
|
||||
rect_t r_fix = rect_init(0, 0, 0, 0);
|
||||
lcd_mem_fragment_t* mem = (lcd_mem_fragment_t*)lcd;
|
||||
return_value_if_fail(mem != NULL && r != NULL, RET_BAD_PARAMS);
|
||||
lcd_get_dirty_rect(lcd, &dirty_r);
|
||||
mem->dirty_rect = rect_intersect(r, &dirty_r);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static bool_t lcd_mem_fragment_is_rect_in_clip_rect(lcd_t* lcd, xy_t left, xy_t top, xy_t right, xy_t bottom) {
|
||||
lcd_mem_fragment_t* mem = (lcd_mem_fragment_t*)lcd;
|
||||
xy_t clip_left, clip_top, clip_right, clip_bottom;
|
||||
return_value_if_fail(mem != NULL, FALSE);
|
||||
clip_left = mem->dirty_rect.x;
|
||||
clip_top = mem->dirty_rect.y;
|
||||
clip_right = mem->dirty_rect.x + mem->dirty_rect.w - 1;
|
||||
clip_bottom = mem->dirty_rect.y + mem->dirty_rect.h - 1;
|
||||
|
||||
if (left > clip_right || right < clip_left || top > clip_bottom || bottom < clip_top) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_fragment_get_clip_rect(lcd_t* lcd, rect_t* rect) {
|
||||
lcd_mem_fragment_t* mem = (lcd_mem_fragment_t*)lcd;
|
||||
return_value_if_fail(mem != NULL, RET_BAD_PARAMS);
|
||||
rect->x = mem->dirty_rect.x;
|
||||
rect->y = mem->dirty_rect.y;
|
||||
rect->w = mem->dirty_rect.w;
|
||||
rect->h = mem->dirty_rect.h;
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_fragment_create(wh_t w, wh_t h) {
|
||||
lcd_mem_fragment_t* mem = &s_lcd_mem_fragment;
|
||||
lcd_t* base = (lcd_t*)mem;
|
||||
system_info_t* info = system_info();
|
||||
|
||||
base->begin_frame = lcd_mem_fragment_begin_frame;
|
||||
base->set_clip_rect = lcd_mem_fragment_set_clip_rect;
|
||||
base->get_clip_rect = lcd_mem_fragment_get_clip_rect;
|
||||
base->is_rect_in_clip_rect = lcd_mem_fragment_is_rect_in_clip_rect;
|
||||
base->draw_vline = lcd_mem_fragment_draw_vline;
|
||||
base->draw_hline = lcd_mem_fragment_draw_hline;
|
||||
base->fill_rect = lcd_mem_fragment_fill_rect;
|
||||
base->clear_rect = lcd_mem_fragment_clear_rect;
|
||||
base->draw_image = lcd_mem_fragment_draw_image;
|
||||
base->draw_glyph = lcd_mem_fragment_draw_glyph;
|
||||
base->draw_points = lcd_mem_fragment_draw_points;
|
||||
base->get_point_color = lcd_mem_fragment_get_point_color;
|
||||
base->get_desired_bitmap_format = lcd_mem_fragment_get_desired_bitmap_format;
|
||||
base->end_frame = lcd_mem_fragment_end_frame;
|
||||
base->destroy = lcd_mem_fragment_destroy;
|
||||
base->resize = lcd_mem_fragment_resize;
|
||||
base->flush = lcd_mem_fragment_flush;
|
||||
base->set_orientation = lcd_mem_fragment_set_orientation;
|
||||
|
||||
base->w = w;
|
||||
base->h = h;
|
||||
base->ratio = 1;
|
||||
base->global_alpha = 0xff;
|
||||
base->type = LCD_FRAMEBUFFER;
|
||||
base->support_dirty_rect = TRUE;
|
||||
|
||||
system_info_set_lcd_w(info, base->w);
|
||||
system_info_set_lcd_h(info, base->h);
|
||||
system_info_set_lcd_type(info, base->type);
|
||||
system_info_set_device_pixel_ratio(info, 1);
|
||||
|
||||
memset(&(mem->fb), 0x00, sizeof(bitmap_t));
|
||||
mem->gb = graphic_buffer_create_with_data((uint8_t*)(mem->buff), w, h, BITMAP_FMT_NONE);
|
||||
|
||||
return base;
|
||||
}
|
56
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_rgb565.c
Normal file
56
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_rgb565.c
Normal file
@ -0,0 +1,56 @@
|
||||
/**
|
||||
* File: lcd_mem_rgb565.c
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: rgb565 mem lcd.
|
||||
*
|
||||
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* License file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* History:
|
||||
* ================================================================
|
||||
* 2021-07-08 Generated by gen.sh(DONT MODIFY IT)
|
||||
*
|
||||
*/
|
||||
|
||||
#define LCD_FORMAT BITMAP_FMT_RGB565
|
||||
|
||||
#include "tkc/mem.h"
|
||||
#include "base/pixel.h"
|
||||
#include "lcd/lcd_mem.h"
|
||||
|
||||
#define pixel_t pixel_rgb565_t
|
||||
#define pixel_bpp pixel_rgb565_BPP
|
||||
#define pixel_to_rgba pixel_rgb565_to_rgba
|
||||
#define pixel_from_rgb pixel_rgb565_from_rgb
|
||||
#define pixel_from_rgba pixel_rgb565_from_rgba
|
||||
|
||||
#include "blend/pixel_ops.inc"
|
||||
#include "lcd/lcd_mem.inc"
|
||||
|
||||
lcd_t* lcd_mem_rgb565_init(lcd_mem_t* lcd, wh_t w, wh_t h, bool_t alloc) {
|
||||
return lcd_mem_init(lcd, w, h, alloc);
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_rgb565_create(wh_t w, wh_t h, bool_t alloc) {
|
||||
return lcd_mem_create(w, h, alloc);
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_rgb565_create_single_fb(wh_t w, wh_t h, uint8_t* fbuff) {
|
||||
return lcd_mem_create_single_fb(w, h, fbuff);
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_rgb565_create_double_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb) {
|
||||
return lcd_mem_create_double_fb(w, h, online_fb, offline_fb);
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_rgb565_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb,
|
||||
uint8_t* next_fb) {
|
||||
return lcd_mem_create_three_fb(w, h, online_fb, offline_fb, next_fb);
|
||||
}
|
107
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_rgb565.h
Normal file
107
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_rgb565.h
Normal file
@ -0,0 +1,107 @@
|
||||
/**
|
||||
* File: lcd_mem_rgb565.h
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: rgb565 mem lcd.
|
||||
*
|
||||
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* this program is distributed in the hope that it will be useful,
|
||||
* but without any warranty; without even the implied warranty of
|
||||
* merchantability or fitness for a particular purpose. see the
|
||||
* license file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* history:
|
||||
* ================================================================
|
||||
* 2021-07-08 Generated by gen.sh(DONT MODIFY IT)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TK_LCD_MEM_RGB565_H
|
||||
#define TK_LCD_MEM_RGB565_H
|
||||
|
||||
#include "lcd/lcd_mem.h"
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
/**
|
||||
* @class lcd_mem_rgb565_t
|
||||
* @parent lcd_t
|
||||
* @annotation ["fake"]
|
||||
*/
|
||||
|
||||
/**
|
||||
* @method lcd_mem_rgb565_create
|
||||
*
|
||||
* 创建lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {bool_t} alloc 是否分配内存。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_rgb565_create(wh_t w, wh_t h, bool_t alloc);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_rgb565_create_single_fb
|
||||
*
|
||||
* 创建single fb lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {uint8_t*} fbuff 帧率缓冲区。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_rgb565_create_single_fb(wh_t w, wh_t h, uint8_t* fbuff);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_rgb565_create_double_fb
|
||||
*
|
||||
* 创建double fb lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {uint8_t*} online_fb 在线帧率缓冲区。
|
||||
* @param {uint8_t*} offline_fb 离线帧率缓冲区。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_rgb565_create_double_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_rgb565_create_three_fb
|
||||
*
|
||||
* 创建three fb lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {uint8_t*} online_fb 在线帧率缓冲区。
|
||||
* @param {uint8_t*} offline_fb 离线帧率缓冲区。
|
||||
* @param {uint8_t*} next_fb 待显示的帧率缓冲区。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_rgb565_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb,
|
||||
uint8_t* next_fb);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_rgb565_init
|
||||
*
|
||||
* 创建lcd对象。
|
||||
*
|
||||
* @param {lcd_mem_t*} lcd 对象。
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {bool_t} alloc 是否分配内存。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_rgb565_init(lcd_mem_t* lcd, wh_t w, wh_t h, bool_t alloc);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /*TK_LCD_MEM_RGB565_H*/
|
56
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_rgb888.c
Normal file
56
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_rgb888.c
Normal file
@ -0,0 +1,56 @@
|
||||
/**
|
||||
* File: lcd_mem_rgb888.c
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: rgb888 mem lcd.
|
||||
*
|
||||
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* License file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* History:
|
||||
* ================================================================
|
||||
* 2021-07-08 Generated by gen.sh(DONT MODIFY IT)
|
||||
*
|
||||
*/
|
||||
|
||||
#define LCD_FORMAT BITMAP_FMT_RGB888
|
||||
|
||||
#include "tkc/mem.h"
|
||||
#include "base/pixel.h"
|
||||
#include "lcd/lcd_mem.h"
|
||||
|
||||
#define pixel_t pixel_rgb888_t
|
||||
#define pixel_bpp pixel_rgb888_BPP
|
||||
#define pixel_to_rgba pixel_rgb888_to_rgba
|
||||
#define pixel_from_rgb pixel_rgb888_from_rgb
|
||||
#define pixel_from_rgba pixel_rgb888_from_rgba
|
||||
|
||||
#include "blend/pixel_ops.inc"
|
||||
#include "lcd/lcd_mem.inc"
|
||||
|
||||
lcd_t* lcd_mem_rgb888_init(lcd_mem_t* lcd, wh_t w, wh_t h, bool_t alloc) {
|
||||
return lcd_mem_init(lcd, w, h, alloc);
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_rgb888_create(wh_t w, wh_t h, bool_t alloc) {
|
||||
return lcd_mem_create(w, h, alloc);
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_rgb888_create_single_fb(wh_t w, wh_t h, uint8_t* fbuff) {
|
||||
return lcd_mem_create_single_fb(w, h, fbuff);
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_rgb888_create_double_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb) {
|
||||
return lcd_mem_create_double_fb(w, h, online_fb, offline_fb);
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_rgb888_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb,
|
||||
uint8_t* next_fb) {
|
||||
return lcd_mem_create_three_fb(w, h, online_fb, offline_fb, next_fb);
|
||||
}
|
107
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_rgb888.h
Normal file
107
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_rgb888.h
Normal file
@ -0,0 +1,107 @@
|
||||
/**
|
||||
* File: lcd_mem_rgb888.h
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: rgb888 mem lcd.
|
||||
*
|
||||
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* this program is distributed in the hope that it will be useful,
|
||||
* but without any warranty; without even the implied warranty of
|
||||
* merchantability or fitness for a particular purpose. see the
|
||||
* license file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* history:
|
||||
* ================================================================
|
||||
* 2021-07-08 Generated by gen.sh(DONT MODIFY IT)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TK_LCD_MEM_RGB888_H
|
||||
#define TK_LCD_MEM_RGB888_H
|
||||
|
||||
#include "lcd/lcd_mem.h"
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
/**
|
||||
* @class lcd_mem_rgb888_t
|
||||
* @parent lcd_t
|
||||
* @annotation ["fake"]
|
||||
*/
|
||||
|
||||
/**
|
||||
* @method lcd_mem_rgb888_create
|
||||
*
|
||||
* 创建lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {bool_t} alloc 是否分配内存。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_rgb888_create(wh_t w, wh_t h, bool_t alloc);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_rgb888_create_single_fb
|
||||
*
|
||||
* 创建single fb lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {uint8_t*} fbuff 帧率缓冲区。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_rgb888_create_single_fb(wh_t w, wh_t h, uint8_t* fbuff);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_rgb888_create_double_fb
|
||||
*
|
||||
* 创建double fb lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {uint8_t*} online_fb 在线帧率缓冲区。
|
||||
* @param {uint8_t*} offline_fb 离线帧率缓冲区。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_rgb888_create_double_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_rgb888_create_three_fb
|
||||
*
|
||||
* 创建three fb lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {uint8_t*} online_fb 在线帧率缓冲区。
|
||||
* @param {uint8_t*} offline_fb 离线帧率缓冲区。
|
||||
* @param {uint8_t*} next_fb 待显示的帧率缓冲区。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_rgb888_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb,
|
||||
uint8_t* next_fb);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_rgb888_init
|
||||
*
|
||||
* 创建lcd对象。
|
||||
*
|
||||
* @param {lcd_mem_t*} lcd 对象。
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {bool_t} alloc 是否分配内存。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_rgb888_init(lcd_mem_t* lcd, wh_t w, wh_t h, bool_t alloc);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /*TK_LCD_MEM_RGB888_H*/
|
56
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_rgba8888.c
Normal file
56
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_rgba8888.c
Normal file
@ -0,0 +1,56 @@
|
||||
/**
|
||||
* File: lcd_mem_rgba8888.c
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: rgba8888 mem lcd.
|
||||
*
|
||||
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* License file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* History:
|
||||
* ================================================================
|
||||
* 2021-07-08 Generated by gen.sh(DONT MODIFY IT)
|
||||
*
|
||||
*/
|
||||
|
||||
#define LCD_FORMAT BITMAP_FMT_RGBA8888
|
||||
|
||||
#include "tkc/mem.h"
|
||||
#include "base/pixel.h"
|
||||
#include "lcd/lcd_mem.h"
|
||||
|
||||
#define pixel_t pixel_rgba8888_t
|
||||
#define pixel_bpp pixel_rgba8888_BPP
|
||||
#define pixel_to_rgba pixel_rgba8888_to_rgba
|
||||
#define pixel_from_rgb pixel_rgba8888_from_rgb
|
||||
#define pixel_from_rgba pixel_rgba8888_from_rgba
|
||||
|
||||
#include "blend/pixel_ops.inc"
|
||||
#include "lcd/lcd_mem.inc"
|
||||
|
||||
lcd_t* lcd_mem_rgba8888_init(lcd_mem_t* lcd, wh_t w, wh_t h, bool_t alloc) {
|
||||
return lcd_mem_init(lcd, w, h, alloc);
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_rgba8888_create(wh_t w, wh_t h, bool_t alloc) {
|
||||
return lcd_mem_create(w, h, alloc);
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_rgba8888_create_single_fb(wh_t w, wh_t h, uint8_t* fbuff) {
|
||||
return lcd_mem_create_single_fb(w, h, fbuff);
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_rgba8888_create_double_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb) {
|
||||
return lcd_mem_create_double_fb(w, h, online_fb, offline_fb);
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_rgba8888_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb,
|
||||
uint8_t* next_fb) {
|
||||
return lcd_mem_create_three_fb(w, h, online_fb, offline_fb, next_fb);
|
||||
}
|
107
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_rgba8888.h
Normal file
107
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_rgba8888.h
Normal file
@ -0,0 +1,107 @@
|
||||
/**
|
||||
* File: lcd_mem_rgba8888.h
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: rgba8888 mem lcd.
|
||||
*
|
||||
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* this program is distributed in the hope that it will be useful,
|
||||
* but without any warranty; without even the implied warranty of
|
||||
* merchantability or fitness for a particular purpose. see the
|
||||
* license file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* history:
|
||||
* ================================================================
|
||||
* 2021-07-08 Generated by gen.sh(DONT MODIFY IT)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TK_LCD_MEM_RGBA8888_H
|
||||
#define TK_LCD_MEM_RGBA8888_H
|
||||
|
||||
#include "lcd/lcd_mem.h"
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
/**
|
||||
* @class lcd_mem_rgba8888_t
|
||||
* @parent lcd_t
|
||||
* @annotation ["fake"]
|
||||
*/
|
||||
|
||||
/**
|
||||
* @method lcd_mem_rgba8888_create
|
||||
*
|
||||
* 创建lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {bool_t} alloc 是否分配内存。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_rgba8888_create(wh_t w, wh_t h, bool_t alloc);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_rgba8888_create_single_fb
|
||||
*
|
||||
* 创建single fb lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {uint8_t*} fbuff 帧率缓冲区。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_rgba8888_create_single_fb(wh_t w, wh_t h, uint8_t* fbuff);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_rgba8888_create_double_fb
|
||||
*
|
||||
* 创建double fb lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {uint8_t*} online_fb 在线帧率缓冲区。
|
||||
* @param {uint8_t*} offline_fb 离线帧率缓冲区。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_rgba8888_create_double_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_rgba8888_create_three_fb
|
||||
*
|
||||
* 创建three fb lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {uint8_t*} online_fb 在线帧率缓冲区。
|
||||
* @param {uint8_t*} offline_fb 离线帧率缓冲区。
|
||||
* @param {uint8_t*} next_fb 待显示的帧率缓冲区。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_rgba8888_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb,
|
||||
uint8_t* next_fb);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_rgba8888_init
|
||||
*
|
||||
* 创建lcd对象。
|
||||
*
|
||||
* @param {lcd_mem_t*} lcd 对象。
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {bool_t} alloc 是否分配内存。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_rgba8888_init(lcd_mem_t* lcd, wh_t w, wh_t h, bool_t alloc);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /*TK_LCD_MEM_RGBA8888_H*/
|
127
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_special.c
Normal file
127
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_special.c
Normal file
@ -0,0 +1,127 @@
|
||||
/**
|
||||
* File: lcd_mem_special.c
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: lcd_mem_special
|
||||
*
|
||||
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* License file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* History:
|
||||
* ================================================================
|
||||
* 2019-06-17 Li XianJing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
#include "tkc/mem.h"
|
||||
#include "lcd/lcd_mem_special.h"
|
||||
#include "lcd/lcd_mem_rgb565.h"
|
||||
#include "lcd/lcd_mem_bgr565.h"
|
||||
#include "lcd/lcd_mem_rgba8888.h"
|
||||
#include "lcd/lcd_mem_bgra8888.h"
|
||||
#include "lcd/lcd_mem_bgr888.h"
|
||||
#include "lcd/lcd_mem_rgb888.h"
|
||||
|
||||
static ret_t lcd_mem_special_resize(lcd_t* lcd, wh_t w, wh_t h, uint32_t line_length);
|
||||
|
||||
static ret_t lcd_mem_special_flush(lcd_t* lcd) {
|
||||
lcd_mem_special_t* special = (lcd_mem_special_t*)lcd;
|
||||
|
||||
if (special->on_flush != NULL) {
|
||||
special->on_flush(lcd);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_special_destroy(lcd_t* lcd) {
|
||||
lcd_mem_special_t* special = (lcd_mem_special_t*)lcd;
|
||||
|
||||
lcd_mem_deinit((lcd_mem_t*)lcd);
|
||||
if (special->on_destroy != NULL) {
|
||||
special->on_destroy(lcd);
|
||||
}
|
||||
|
||||
memset(special, 0x00, sizeof(lcd_mem_special_t));
|
||||
TKMEM_FREE(special);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static lcd_t* lcd_mem_special_init_lcd_mem(lcd_t* lcd_mem, wh_t w, wh_t h, bitmap_format_t fmt) {
|
||||
lcd_t* lcd = NULL;
|
||||
switch (fmt) {
|
||||
case BITMAP_FMT_RGBA8888: {
|
||||
lcd = lcd_mem_rgba8888_init((lcd_mem_t*)lcd_mem, w, h, TRUE);
|
||||
break;
|
||||
}
|
||||
case BITMAP_FMT_BGRA8888: {
|
||||
lcd = lcd_mem_bgra8888_init((lcd_mem_t*)lcd_mem, w, h, TRUE);
|
||||
break;
|
||||
}
|
||||
case BITMAP_FMT_BGR888: {
|
||||
lcd = lcd_mem_bgr888_init((lcd_mem_t*)lcd_mem, w, h, TRUE);
|
||||
break;
|
||||
}
|
||||
case BITMAP_FMT_RGB888: {
|
||||
lcd = lcd_mem_rgb888_init((lcd_mem_t*)lcd_mem, w, h, TRUE);
|
||||
break;
|
||||
}
|
||||
case BITMAP_FMT_BGR565: {
|
||||
lcd = lcd_mem_bgr565_init((lcd_mem_t*)lcd_mem, w, h, TRUE);
|
||||
break;
|
||||
}
|
||||
case BITMAP_FMT_RGB565: {
|
||||
lcd = lcd_mem_rgb565_init((lcd_mem_t*)lcd_mem, w, h, TRUE);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
log_debug("not supported: w=%d h=%d fmt=%d\n", w, h, fmt);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (lcd != NULL) {
|
||||
lcd->flush = lcd_mem_special_flush;
|
||||
lcd->resize = lcd_mem_special_resize;
|
||||
lcd->destroy = lcd_mem_special_destroy;
|
||||
}
|
||||
return lcd;
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_special_resize(lcd_t* lcd, wh_t w, wh_t h, uint32_t line_length) {
|
||||
lcd_mem_special_t* special = (lcd_mem_special_t*)lcd;
|
||||
return_value_if_fail(special != NULL, RET_BAD_PARAMS);
|
||||
|
||||
lcd_mem_deinit((lcd_mem_t*)lcd);
|
||||
lcd_mem_special_init_lcd_mem(lcd, w, h, special->format);
|
||||
|
||||
if (special->on_resize != NULL) {
|
||||
special->on_resize(lcd, w, h, line_length);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_special_create(wh_t w, wh_t h, bitmap_format_t fmt, lcd_flush_t on_flush,
|
||||
lcd_resize_t on_resize, lcd_destroy_t on_destroy, void* ctx) {
|
||||
lcd_t* lcd = NULL;
|
||||
lcd_mem_special_t* special = TKMEM_ZALLOC(lcd_mem_special_t);
|
||||
return_value_if_fail(special != NULL, NULL);
|
||||
|
||||
memset(special, 0x00, sizeof(lcd_mem_special_t));
|
||||
|
||||
special->ctx = ctx;
|
||||
special->format = fmt;
|
||||
special->on_flush = on_flush;
|
||||
special->on_resize = on_resize;
|
||||
special->on_destroy = on_destroy;
|
||||
lcd = lcd_mem_special_init_lcd_mem((lcd_t*)special, w, h, fmt);
|
||||
return_value_if_fail(lcd != NULL, NULL);
|
||||
return lcd;
|
||||
}
|
73
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_special.h
Normal file
73
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mem_special.h
Normal file
@ -0,0 +1,73 @@
|
||||
/**
|
||||
* File: lcd_mem_special.h
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: lcd_mem_special
|
||||
*
|
||||
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* License file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* History:
|
||||
* ================================================================
|
||||
* 2019-06-17 Li XianJing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LCD_MEM_SPECIAL_H
|
||||
#define LCD_MEM_SPECIAL_H
|
||||
|
||||
#include "base/lcd.h"
|
||||
#include "lcd/lcd_mem.h"
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
/**
|
||||
* @class lcd_mem_special_t
|
||||
* @parent lcd_t
|
||||
* 特殊的LCD。
|
||||
*
|
||||
* 通过重载flush函数来提交GUI绘制的结果到硬件。适用于:
|
||||
*
|
||||
* * lcd 硬件不支持framebuffer,如SPI接口的屏。
|
||||
* * lcd 硬件支持framebuffer,但是其格式特殊,AWTK目前不支持。可以用flush进行格式转换。
|
||||
*
|
||||
*
|
||||
*/
|
||||
typedef struct _lcd_mem_special_t {
|
||||
lcd_mem_t base;
|
||||
bitmap_format_t format;
|
||||
|
||||
/*custom info*/
|
||||
void* ctx;
|
||||
lcd_flush_t on_flush;
|
||||
lcd_resize_t on_resize;
|
||||
lcd_destroy_t on_destroy;
|
||||
} lcd_mem_special_t;
|
||||
|
||||
/**
|
||||
* @method lcd_mem_special_create
|
||||
*
|
||||
* 创建lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {bitmap_format_t} format 离线lcd的格式。一般用 BITMAP_FMT_BGR565 或 BITMAP_FMT_RGBA8888。
|
||||
* @param {lcd_flush_t} flush 回调函数,用于刷新GUI数据到实际的LCD。
|
||||
* @param {lcd_resize_t} on_resize 用于调整LCD的大小。一般用NULL即可。
|
||||
* @param {lcd_destroy_t} on_destroy lcd销毁时的回调函数。
|
||||
* @param {void*} ctx 回调函数的上下文。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_special_create(wh_t w, wh_t h, bitmap_format_t fmt, lcd_flush_t on_flush,
|
||||
lcd_resize_t on_resize, lcd_destroy_t on_destroy, void* ctx);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /*LCD_MEM_SPECIAL_H*/
|
239
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mono.c
Normal file
239
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mono.c
Normal file
@ -0,0 +1,239 @@
|
||||
/**
|
||||
* File: lcd_mono.h
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: mono lcd
|
||||
*
|
||||
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* this program is distributed in the hope that it will be useful,
|
||||
* but without any warranty; without even the implied warranty of
|
||||
* merchantability or fitness for a particular purpose. see the
|
||||
* license file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* history:
|
||||
* ================================================================
|
||||
* 2019-08-10 li xianjing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
#include "tkc/mem.h"
|
||||
#include "base/pixel.h"
|
||||
#include "lcd/lcd_mono.h"
|
||||
#include "base/system_info.h"
|
||||
|
||||
#ifdef WITH_LCD_MONO
|
||||
#include "lcd/lcd_sdl2_mono.h"
|
||||
#endif
|
||||
|
||||
#undef color_to_pixel
|
||||
typedef uint8_t pixel_t;
|
||||
#define color_to_pixel(c) color_to_mono(c)
|
||||
#define color_from_pixel(p) color_from_mono(p)
|
||||
|
||||
static ret_t inline lcd_mono_set_pixel(lcd_t* lcd, uint16_t x, uint16_t y, bool_t pixel) {
|
||||
lcd_mono_t* mono = (lcd_mono_t*)(lcd);
|
||||
|
||||
return bitmap_mono_set_pixel(mono->data, lcd->w, lcd->h, x, y, pixel);
|
||||
}
|
||||
|
||||
static color_t lcd_mono_get_point_color(lcd_t* lcd, xy_t x, xy_t y) {
|
||||
color_t c;
|
||||
lcd_mono_t* mono = (lcd_mono_t*)(lcd);
|
||||
pixel_t pixel = bitmap_mono_get_pixel(mono->data, lcd->w, lcd->h, x, y);
|
||||
|
||||
c = color_from_pixel(pixel);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
static ret_t lcd_mono_begin_frame(lcd_t* lcd, const dirty_rects_t* dirty_rects) {
|
||||
const rect_t* dirty_rect = dirty_rects != NULL ? &(dirty_rects->max) : NULL;
|
||||
|
||||
if (dirty_rect != NULL) {
|
||||
lcd->dirty_rect = *dirty_rect;
|
||||
} else {
|
||||
lcd->dirty_rect = rect_init(0, 0, lcd->w, lcd->h);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_mono_draw_hline(lcd_t* lcd, xy_t x, xy_t y, wh_t w) {
|
||||
wh_t i = 0;
|
||||
pixel_t pixel = color_to_pixel(lcd->stroke_color);
|
||||
|
||||
for (i = 0; i < w; i++) {
|
||||
lcd_mono_set_pixel(lcd, x + i, y, pixel);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_mono_draw_vline(lcd_t* lcd, xy_t x, xy_t y, wh_t h) {
|
||||
wh_t i = 0;
|
||||
pixel_t pixel = color_to_pixel(lcd->stroke_color);
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
lcd_mono_set_pixel(lcd, x, y + i, pixel);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_mono_draw_points(lcd_t* lcd, point_t* points, uint32_t nr) {
|
||||
wh_t i = 0;
|
||||
pixel_t pixel = color_to_pixel(lcd->stroke_color);
|
||||
|
||||
for (i = 0; i < nr; i++) {
|
||||
point_t* point = points + i;
|
||||
lcd_mono_set_pixel(lcd, point->x, point->y, pixel);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_mono_fill_rect(lcd_t* lcd, xy_t x, xy_t y, wh_t w, wh_t h) {
|
||||
uint32_t i = 0;
|
||||
uint32_t j = 0;
|
||||
pixel_t pixel = color_to_pixel(lcd->fill_color);
|
||||
|
||||
for (j = 0; j < h; j++) {
|
||||
for (i = 0; i < w; i++) {
|
||||
lcd_mono_set_pixel(lcd, x + i, y + j, pixel);
|
||||
}
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_mono_draw_data(lcd_t* lcd, const uint8_t* buff, uint32_t w, uint32_t h,
|
||||
const rect_t* src, xy_t x, xy_t y, bool_t revert_pixel) {
|
||||
wh_t i = 0;
|
||||
wh_t j = 0;
|
||||
wh_t sx = src->x;
|
||||
wh_t sy = src->y;
|
||||
wh_t sw = src->w;
|
||||
wh_t sh = src->h;
|
||||
|
||||
for (j = 0; j < sh; j++) {
|
||||
for (i = 0; i < sw; i++) {
|
||||
pixel_t pixel = bitmap_mono_get_pixel(buff, w, h, sx + i, sy + j);
|
||||
if (revert_pixel) {
|
||||
pixel = !pixel;
|
||||
}
|
||||
lcd_mono_set_pixel(lcd, x + i, y + j, pixel);
|
||||
}
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_mono_draw_glyph(lcd_t* lcd, glyph_t* glyph, const rect_t* src, xy_t x, xy_t y) {
|
||||
pixel_t pixel = color_to_pixel(lcd->text_color);
|
||||
|
||||
return lcd_mono_draw_data(lcd, glyph->data, glyph->w, glyph->h, src, x, y, !pixel);
|
||||
}
|
||||
|
||||
static ret_t lcd_mono_draw_image_mono(lcd_t* lcd, bitmap_t* img, const rectf_t* src,
|
||||
const rectf_t* dst) {
|
||||
ret_t ret = RET_OK;
|
||||
const uint8_t* data = NULL;
|
||||
rect_t tmp_src = rect_from_rectf(src);
|
||||
return_value_if_fail(src->w == dst->w && src->h == dst->h, RET_OK);
|
||||
|
||||
data = bitmap_lock_buffer_for_read(img);
|
||||
ret = lcd_mono_draw_data(lcd, data, img->w, img->h, (const rect_t*)(&tmp_src), (xy_t)(dst->x),
|
||||
(xy_t)(dst->y), FALSE);
|
||||
bitmap_unlock_buffer(img);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ret_t lcd_mono_draw_image(lcd_t* lcd, bitmap_t* img, const rectf_t* src,
|
||||
const rectf_t* dst) {
|
||||
return_value_if_fail(img->format == BITMAP_FMT_MONO, RET_NOT_IMPL);
|
||||
return_value_if_fail(src->w == dst->w && src->h == dst->h, RET_NOT_IMPL);
|
||||
|
||||
return lcd_mono_draw_image_mono(lcd, img, src, dst);
|
||||
}
|
||||
|
||||
static ret_t lcd_mono_end_frame(lcd_t* lcd) {
|
||||
if (lcd->flush != NULL) {
|
||||
lcd->flush(lcd);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
#ifdef WITH_LCD_MONO
|
||||
static ret_t lcd_mono_resize(lcd_t* lcd, wh_t w, wh_t h, uint32_t line_length) {
|
||||
lcd_mono_t* mono = (lcd_mono_t*)(lcd);
|
||||
return_value_if_fail(mono != NULL, RET_BAD_PARAMS);
|
||||
|
||||
return lcd_sdl2_mono_reinit(lcd, w, h, line_length);
|
||||
}
|
||||
|
||||
static ret_t lcd_mono_set_orientation(lcd_t* lcd, lcd_orientation_t old_orientation,
|
||||
lcd_orientation_t new_orientation) {
|
||||
if (tk_is_swap_size_by_orientation(old_orientation, new_orientation)) {
|
||||
return lcd_mono_resize(lcd, lcd->h, lcd->w, 0);
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static ret_t lcd_mono_destroy(lcd_t* lcd) {
|
||||
lcd_mono_t* mono = (lcd_mono_t*)(lcd);
|
||||
if (mono->on_destroy) {
|
||||
mono->on_destroy(lcd);
|
||||
}
|
||||
TKMEM_FREE(mono->data);
|
||||
TKMEM_FREE(lcd);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
lcd_t* lcd_mono_create(wh_t w, wh_t h, lcd_flush_t flush, lcd_destroy_t on_destroy, void* ctx) {
|
||||
lcd_mono_t* mono = TKMEM_ZALLOC(lcd_mono_t);
|
||||
system_info_t* info = system_info();
|
||||
lcd_t* lcd = (lcd_t*)mono;
|
||||
return_value_if_fail(lcd != NULL, NULL);
|
||||
|
||||
lcd->w = w;
|
||||
lcd->h = h;
|
||||
lcd->ratio = 1;
|
||||
lcd->type = LCD_MONO;
|
||||
mono->data = bitmap_mono_create_data(w, h);
|
||||
mono->on_destroy = on_destroy;
|
||||
mono->ctx = ctx;
|
||||
|
||||
ENSURE(mono->data != NULL);
|
||||
|
||||
system_info_set_lcd_w(info, lcd->w);
|
||||
system_info_set_lcd_h(info, lcd->h);
|
||||
system_info_set_lcd_type(info, lcd->type);
|
||||
system_info_set_device_pixel_ratio(info, 1);
|
||||
|
||||
#ifdef WITH_LCD_MONO
|
||||
lcd->resize = lcd_mono_resize;
|
||||
lcd->set_orientation = lcd_mono_set_orientation;
|
||||
#endif
|
||||
lcd->begin_frame = lcd_mono_begin_frame;
|
||||
lcd->draw_vline = lcd_mono_draw_vline;
|
||||
lcd->draw_hline = lcd_mono_draw_hline;
|
||||
lcd->fill_rect = lcd_mono_fill_rect;
|
||||
lcd->draw_image = lcd_mono_draw_image;
|
||||
lcd->draw_glyph = lcd_mono_draw_glyph;
|
||||
lcd->draw_points = lcd_mono_draw_points;
|
||||
lcd->get_point_color = lcd_mono_get_point_color;
|
||||
lcd->end_frame = lcd_mono_end_frame;
|
||||
lcd->destroy = lcd_mono_destroy;
|
||||
lcd->support_dirty_rect = TRUE;
|
||||
lcd->flush = flush;
|
||||
|
||||
return lcd;
|
||||
}
|
83
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mono.h
Normal file
83
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_mono.h
Normal file
@ -0,0 +1,83 @@
|
||||
/**
|
||||
* File: lcd_mono.h
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: mono lcd
|
||||
*
|
||||
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* this program is distributed in the hope that it will be useful,
|
||||
* but without any warranty; without even the implied warranty of
|
||||
* merchantability or fitness for a particular purpose. see the
|
||||
* license file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* history:
|
||||
* ================================================================
|
||||
* 2019-08-10 li xianjing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LCD_MONO_H
|
||||
#define LCD_MONO_H
|
||||
|
||||
#include "base/lcd.h"
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
/**
|
||||
* @class lcd_mono_t
|
||||
* @parent lcd_t
|
||||
*
|
||||
* 单色LCD。
|
||||
*
|
||||
* lcd\_mono是一个特殊的Framebuffer,它用一个比特来表示一个pixel。
|
||||
*
|
||||
* lcd\_mono只是负责硬件无关的逻辑处理,调用者需要在创建时提供一个flush回调函数,
|
||||
* 在flush函数中把脏矩形中的数据刷新到硬件中。
|
||||
*
|
||||
*/
|
||||
typedef struct _lcd_mono_t {
|
||||
lcd_t lcd;
|
||||
|
||||
/**
|
||||
* @property {uint8_t*} data
|
||||
* @annotation ["readable"]
|
||||
* Framebuffer首地址。
|
||||
*/
|
||||
uint8_t* data;
|
||||
|
||||
/**
|
||||
* @property {void*} ctx
|
||||
* @annotation ["private"]
|
||||
* flush/on_destroy回调函数的上下文信息。
|
||||
*/
|
||||
void* ctx;
|
||||
|
||||
/**
|
||||
* @property {lcd_destroy_t} on_destroy
|
||||
* @annotation ["private"]
|
||||
* lcd销毁时的回调函数。
|
||||
*/
|
||||
lcd_destroy_t on_destroy;
|
||||
} lcd_mono_t;
|
||||
|
||||
/**
|
||||
* @method lcd_mono_create
|
||||
* 创建单色LCD对象。
|
||||
*
|
||||
* @annotation ["constructor"]
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {lcd_flush_t} flush 用于刷新数据到硬件的回调函数。
|
||||
* @param {lcd_destroy_t} on_destroy 销毁lcd时的回调函数。
|
||||
* @param {void*} ctx flush/on_destroy回调函数的上下文。
|
||||
*
|
||||
* @return {lcd_t*} lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mono_create(wh_t w, wh_t h, lcd_flush_t flush, lcd_destroy_t on_destroy, void* ctx);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /*LCD_MONO_H*/
|
37
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_nanovg.c
Normal file
37
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_nanovg.c
Normal file
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* File: lcd.c
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: lcd interface
|
||||
*
|
||||
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* License file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* History:
|
||||
* ================================================================
|
||||
* 2018-04-11 Li XianJing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
#include "base/lcd.h"
|
||||
#include "base/vgcanvas.h"
|
||||
#include "lcd/lcd_nanovg.h"
|
||||
#include "lcd_vgcanvas.inc"
|
||||
|
||||
lcd_t* lcd_nanovg_init(native_window_t* window) {
|
||||
vgcanvas_t* vg = NULL;
|
||||
native_window_info_t info;
|
||||
return_value_if_fail(window != NULL, NULL);
|
||||
return_value_if_fail(native_window_get_info(window, &info) == RET_OK, NULL);
|
||||
|
||||
vg = vgcanvas_create(info.w, info.h, 0, 0, window);
|
||||
return_value_if_fail(vg != NULL, NULL);
|
||||
|
||||
return lcd_vgcanvas_init(info.w, info.h, vg);
|
||||
}
|
34
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_nanovg.h
Normal file
34
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_nanovg.h
Normal file
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* File: lcd_nanovg.h
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: nanovg implemented lcd interface
|
||||
*
|
||||
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* License file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* History:
|
||||
* ================================================================
|
||||
* 2018-04-11 Li XianJing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LCD_NANOVG_H
|
||||
#define LCD_NANOVG_H
|
||||
|
||||
#include "base/lcd.h"
|
||||
#include "base/native_window.h"
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
lcd_t* lcd_nanovg_init(native_window_t* window);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /*LCD_NANOVG_H*/
|
33
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_reg.h
Normal file
33
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_reg.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* File: lcd_reg.h
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: register based implemented lcd interface/
|
||||
*
|
||||
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* this program is distributed in the hope that it will be useful,
|
||||
* but without any warranty; without even the implied warranty of
|
||||
* merchantability or fitness for a particular purpose. see the
|
||||
* license file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* history:
|
||||
* ================================================================
|
||||
* 2018-02-16 li xianjing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LCD_REG_H
|
||||
#define LCD_REG_H
|
||||
|
||||
#include "base/lcd.h"
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
lcd_t* lcd_reg_create(wh_t w, wh_t h);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /*LCD_REG_H*/
|
322
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_reg.inc
Normal file
322
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_reg.inc
Normal file
@ -0,0 +1,322 @@
|
||||
/**
|
||||
* File: lcd_reg.c
|
||||
* Author: Li XianJing <xianjimli@hotmail.com>
|
||||
* Brief: register based implemented lcd interface
|
||||
*
|
||||
* Copyright (c) 2018 - 2020 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* License file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* History:
|
||||
* ================================================================
|
||||
* 2018-02-16 Li XianJing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
#include "awtk_config.h"
|
||||
#include "base/system_info.h"
|
||||
|
||||
#ifndef FRAGMENT_FRAME_BUFFER_SIZE
|
||||
typedef struct _lcd_reg_t {
|
||||
lcd_t lcd;
|
||||
} lcd_reg_t;
|
||||
|
||||
static inline ret_t lcd_reg_set_window(lcd_t* lcd, int sx, int sy, int ex, int ey) {
|
||||
set_window_func(sx, sy, ex, ey);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static inline ret_t lcd_reg_write_data(lcd_t* lcd, pixel_t data) {
|
||||
write_data_func(data);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static inline ret_t lcd_reg_write_data_fill(lcd_t* lcd, pixel_t data, wh_t w, wh_t h) {
|
||||
uint32_t i = 0;
|
||||
uint32_t size = w * h;
|
||||
|
||||
for (i = 0; i < size; i++) {
|
||||
write_data_func(data);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_reg_begin_frame(lcd_t* lcd, const dirty_rects_t* dirty_rects) {
|
||||
lcd->dirty_rect = *dirty_rect;
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_reg_draw_hline(lcd_t* lcd, xy_t x, xy_t y, wh_t w) {
|
||||
wh_t i = 0;
|
||||
pixel_t color = color_to_pixel(lcd->stroke_color);
|
||||
|
||||
lcd_reg_set_window(lcd, x, y, x + w, y);
|
||||
for (i = 0; i < w; i++) {
|
||||
lcd_reg_write_data(lcd, color);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_reg_draw_vline(lcd_t* lcd, xy_t x, xy_t y, wh_t h) {
|
||||
wh_t i = 0;
|
||||
pixel_t color = color_to_pixel(lcd->stroke_color);
|
||||
|
||||
lcd_reg_set_window(lcd, x, y, x, y + h);
|
||||
for (i = 0; i < h; i++) {
|
||||
lcd_reg_write_data(lcd, color);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_reg_draw_points(lcd_t* lcd, point_t* points, uint32_t nr) {
|
||||
wh_t i = 0;
|
||||
pixel_t color = color_to_pixel(lcd->stroke_color);
|
||||
|
||||
for (i = 0; i < nr; i++) {
|
||||
point_t* point = points + i;
|
||||
lcd_reg_set_window(lcd, point->x, point->y, point->x, point->y);
|
||||
lcd_reg_write_data(lcd, color);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_reg_fill_rect(lcd_t* lcd, xy_t x, xy_t y, wh_t w, wh_t h) {
|
||||
uint32_t i = 0;
|
||||
uint32_t size = w * h;
|
||||
pixel_t color = color_to_pixel(lcd->fill_color);
|
||||
|
||||
lcd_reg_set_window(lcd, x, y, x + w - 1, y + h - 1);
|
||||
for (i = 0; i < size; i++) {
|
||||
write_data_func(color);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_reg_draw_glyph(lcd_t* lcd, glyph_t* glyph, const rect_t* src, xy_t x, xy_t y) {
|
||||
wh_t i = 0;
|
||||
wh_t j = 0;
|
||||
wh_t sx = src->x;
|
||||
wh_t sy = src->y;
|
||||
wh_t sw = src->w;
|
||||
wh_t sh = src->h;
|
||||
color_t text_color = lcd->text_color;
|
||||
color_t fill_color = lcd->fill_color;
|
||||
const uint8_t* src_p = glyph->data + glyph->w * sy + sx;
|
||||
pixel_t fill_pixel = color_to_pixel(fill_color);
|
||||
pixel_t text_pixel = color_to_pixel(text_color);
|
||||
lcd_reg_set_window(lcd, x, y, x + sw - 1, y + sh - 1);
|
||||
for (j = 0; j < sh; j++) {
|
||||
for (i = 0; i < sw; i++) {
|
||||
uint8_t a = src_p[i];
|
||||
|
||||
if (a >= TK_OPACITY_ALPHA) {
|
||||
lcd_reg_write_data(lcd, text_pixel);
|
||||
} else if (a >= TK_TRANSPARENT_ALPHA) {
|
||||
pixel_t color = blend_color(fill_color, text_color, a);
|
||||
lcd_reg_write_data(lcd, color);
|
||||
} else {
|
||||
lcd_reg_write_data(lcd, fill_pixel);
|
||||
}
|
||||
}
|
||||
src_p += glyph->w;
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_reg_draw_image_bgr565(lcd_t* lcd, bitmap_t* img, const rect_t* src, const rect_t* dst) {
|
||||
wh_t i = 0;
|
||||
wh_t j = 0;
|
||||
xy_t x = dst->x;
|
||||
xy_t y = dst->y;
|
||||
wh_t dw = dst->w;
|
||||
wh_t dh = dst->h;
|
||||
const uint16_t* data = (uint16_t*)bitmap_lock_buffer_for_read(img);
|
||||
|
||||
return_value_if_fail(data != NULL, RET_BAD_PARAMS);
|
||||
lcd_reg_set_window(lcd, x, y, x + dw - 1, y + dh - 1);
|
||||
if (src->w == dst->w && src->h == dst->h) {
|
||||
const pixel_t* src_p = data + img->w * src->y + src->x;
|
||||
for (j = 0; j < dst->h; j++) {
|
||||
for (i = 0; i < dst->w; i++) {
|
||||
write_data_func(src_p[i]);
|
||||
}
|
||||
src_p += img->w;
|
||||
}
|
||||
} else {
|
||||
xy_t sx = src->x;
|
||||
xy_t sy = src->y;
|
||||
wh_t sw = src->w;
|
||||
wh_t sh = src->h;
|
||||
wh_t iw = img->w;
|
||||
xy_t r = dst->x + dst->w;
|
||||
xy_t b = dst->y + dst->h;
|
||||
uint32_t scale_x = (((sw) << 16) / dw);
|
||||
uint32_t scale_y = (((sh) << 16) / dh);
|
||||
|
||||
for (j = 0, y = dst->y; y < b; j++, y++) {
|
||||
const uint16_t* src_p = data + iw * (sy + ((j * scale_y) >> 16)) + sx;
|
||||
for (i = 0, x = dst->x; x < r; i++, x++) {
|
||||
uint32_t s = (i * scale_x) >> 16;
|
||||
lcd_reg_write_data(lcd, src_p[s]);
|
||||
}
|
||||
}
|
||||
}
|
||||
bitmap_unlock_buffer(img);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_reg_draw_image_8888(lcd_t* lcd, bitmap_t* img, const rect_t* src, const rect_t* dst) {
|
||||
wh_t i = 0;
|
||||
wh_t j = 0;
|
||||
uint8_t a = 0;
|
||||
xy_t x = dst->x;
|
||||
xy_t y = dst->y;
|
||||
wh_t dw = dst->w;
|
||||
wh_t dh = dst->h;
|
||||
color_t src_color;
|
||||
uint32_t format = img->format;
|
||||
color_t fill_color = lcd->fill_color;
|
||||
pixel_t fill_pixel = color_to_pixel(fill_color);
|
||||
const color_t* data = (color_t*)bitmap_lock_buffer_for_read(img);
|
||||
|
||||
return_value_if_fail(data != NULL, RET_BAD_PARAMS);
|
||||
lcd_reg_set_window(lcd, x, y, x + dw - 1, y + dh - 1);
|
||||
if (src->w == dst->w && src->h == dst->h) {
|
||||
const color_t* src_p = data + img->w * src->y + src->x;
|
||||
|
||||
for (j = 0; j < dh; j++) {
|
||||
for (i = 0; i < dw; i++) {
|
||||
src_color = src_p[i];
|
||||
if (format == BITMAP_FMT_BGRA8888) {
|
||||
uint8_t r = src_color.rgba.r;
|
||||
src_color.rgba.r = src_color.rgba.b;
|
||||
src_color.rgba.b = r;
|
||||
}
|
||||
a = src_color.rgba.a;
|
||||
|
||||
if (a >= TK_OPACITY_ALPHA) {
|
||||
lcd_reg_write_data(lcd, color_to_pixel(src_color));
|
||||
} else if (a >= TK_TRANSPARENT_ALPHA) {
|
||||
lcd_reg_write_data(lcd, blend_color(fill_color, src_color, a));
|
||||
} else {
|
||||
lcd_reg_write_data(lcd, fill_pixel);
|
||||
}
|
||||
}
|
||||
src_p += img->w;
|
||||
}
|
||||
} else {
|
||||
xy_t sx = src->x;
|
||||
xy_t sy = src->y;
|
||||
wh_t sw = src->w;
|
||||
wh_t sh = src->h;
|
||||
wh_t iw = img->w;
|
||||
xy_t r = dst->x + dst->w;
|
||||
xy_t b = dst->y + dst->h;
|
||||
uint32_t scale_x = (((sw) << 16) / dw);
|
||||
uint32_t scale_y = (((sh) << 16) / dh);
|
||||
|
||||
for (j = 0, y = dst->y; y < b; j++, y++) {
|
||||
const color_t* src_p = data + iw * (sy + ((j * scale_y) >> 16)) + sx;
|
||||
for (i = 0, x = dst->x; x < r; i++, x++) {
|
||||
uint32_t s = (i * scale_x) >> 16;
|
||||
src_color = src_p[s];
|
||||
if (format == BITMAP_FMT_BGRA8888) {
|
||||
uint8_t r = src_color.rgba.r;
|
||||
src_color.rgba.r = src_color.rgba.b;
|
||||
src_color.rgba.b = r;
|
||||
}
|
||||
a = src_color.rgba.a;
|
||||
|
||||
if (a >= TK_OPACITY_ALPHA) {
|
||||
lcd_reg_write_data(lcd, color_to_pixel(src_color));
|
||||
} else if (a >= TK_TRANSPARENT_ALPHA) {
|
||||
lcd_reg_write_data(lcd, blend_color(fill_color, src_color, a));
|
||||
} else {
|
||||
lcd_reg_write_data(lcd, fill_pixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
bitmap_unlock_buffer(img);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_reg_draw_image(lcd_t* lcd, bitmap_t* img, const rect_t* src, const rect_t* dst) {
|
||||
if (img->format == BITMAP_FMT_BGR565) {
|
||||
return lcd_reg_draw_image_bgr565(lcd, img, src, dst);
|
||||
} else if (img->format == BITMAP_FMT_RGBA8888 || img->format == BITMAP_FMT_BGRA8888) {
|
||||
return lcd_reg_draw_image_8888(lcd, img, src, dst);
|
||||
} else {
|
||||
assert(!"not supported format");
|
||||
return RET_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
static ret_t lcd_reg_end_frame(lcd_t* lcd) {
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_reg_destroy(lcd_t* lcd) {
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static bitmap_format_t lcd_reg_get_desired_bitmap_format(lcd_t* lcd) {
|
||||
return LCD_FORMAT;
|
||||
}
|
||||
|
||||
lcd_t* lcd_reg_create(wh_t w, wh_t h) {
|
||||
static lcd_reg_t reg;
|
||||
|
||||
lcd_t* lcd = (lcd_t*)(®);
|
||||
uint32_t size = sizeof(reg);
|
||||
system_info_t* info = system_info();
|
||||
return_value_if_fail(lcd != NULL, NULL);
|
||||
|
||||
memset(®, 0x00, size);
|
||||
|
||||
lcd->w = w;
|
||||
lcd->h = h;
|
||||
lcd->ratio = 1;
|
||||
lcd->type = LCD_REGISTER;
|
||||
|
||||
system_info_set_lcd_w(info, lcd->w);
|
||||
system_info_set_lcd_h(info, lcd->h);
|
||||
system_info_set_lcd_type(info, lcd->type);
|
||||
system_info_set_device_pixel_ratio(info, 1);
|
||||
|
||||
lcd->begin_frame = lcd_reg_begin_frame;
|
||||
lcd->draw_vline = lcd_reg_draw_vline;
|
||||
lcd->draw_hline = lcd_reg_draw_hline;
|
||||
lcd->fill_rect = lcd_reg_fill_rect;
|
||||
lcd->draw_image = lcd_reg_draw_image;
|
||||
lcd->draw_glyph = lcd_reg_draw_glyph;
|
||||
lcd->draw_points = lcd_reg_draw_points;
|
||||
lcd->end_frame = lcd_reg_end_frame;
|
||||
lcd->destroy = lcd_reg_destroy;
|
||||
lcd->support_dirty_rect = TRUE;
|
||||
lcd->get_desired_bitmap_format = lcd_reg_get_desired_bitmap_format;
|
||||
|
||||
return lcd;
|
||||
}
|
||||
#else
|
||||
#include "lcd/lcd_mem_fragment.inc"
|
||||
lcd_t* lcd_reg_create(wh_t w, wh_t h) {
|
||||
return lcd_mem_fragment_create(w, h);
|
||||
}
|
||||
#endif /*FRAGMENT_FRAME_BUFFER_SIZE*/
|
170
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_sdl2.c
Normal file
170
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_sdl2.c
Normal file
@ -0,0 +1,170 @@
|
||||
/**
|
||||
* File: lcd_sdl2.c
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: sdl2 implemented lcd interface/
|
||||
*
|
||||
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* License file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* History:
|
||||
* ================================================================
|
||||
* 2018-01-13 Li XianJing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
#include "tkc/mem.h"
|
||||
#include "lcd/lcd_sdl2.h"
|
||||
#include "blend/image_g2d.h"
|
||||
#include "base/system_info.h"
|
||||
#include "lcd/lcd_mem_special.h"
|
||||
|
||||
typedef struct _special_info_t {
|
||||
SDL_Renderer* render;
|
||||
SDL_Texture* texture;
|
||||
bitmap_format_t format;
|
||||
} special_info_t;
|
||||
|
||||
static special_info_t* special_info_create(SDL_Renderer* render) {
|
||||
special_info_t* info = TKMEM_ZALLOC(special_info_t);
|
||||
return_value_if_fail(info != NULL, NULL);
|
||||
|
||||
info->render = render;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
static ret_t special_info_create_texture(special_info_t* info, wh_t w, wh_t h) {
|
||||
int flags = SDL_TEXTUREACCESS_STREAMING;
|
||||
|
||||
#ifdef WITH_FB_BGRA8888
|
||||
/*SDL ABGR is rgba from low address to high address*/
|
||||
info->format = BITMAP_FMT_BGRA8888;
|
||||
info->texture = SDL_CreateTexture(info->render, SDL_PIXELFORMAT_ARGB8888, flags, w, h);
|
||||
log_debug("WITH_FB_BGRA8888\n");
|
||||
#else
|
||||
/*SDL ABGR is rgba from low address to high address*/
|
||||
info->format = BITMAP_FMT_BGR565;
|
||||
info->texture = SDL_CreateTexture(info->render, SDL_PIXELFORMAT_RGB565, flags, w, h);
|
||||
log_debug("WITH_FB_BGR565\n");
|
||||
#endif
|
||||
return info->texture != NULL ? RET_OK : RET_FAIL;
|
||||
}
|
||||
|
||||
static ret_t special_info_destroy(special_info_t* info) {
|
||||
return_value_if_fail(info != NULL, RET_BAD_PARAMS);
|
||||
|
||||
SDL_DestroyTexture(info->texture);
|
||||
TKMEM_FREE(info);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_sdl2_flush(lcd_t* lcd) {
|
||||
bitmap_t src;
|
||||
bitmap_t dst;
|
||||
int pitch = 0;
|
||||
void* addr = NULL;
|
||||
const dirty_rects_t* dirty_rects;
|
||||
lcd_mem_t* lcd_mem = (lcd_mem_t*)lcd;
|
||||
lcd_mem_special_t* special = (lcd_mem_special_t*)lcd;
|
||||
special_info_t* info = (special_info_t*)(special->ctx);
|
||||
uint8_t* offline_fb = lcd_mem_get_offline_fb(lcd_mem);
|
||||
lcd_orientation_t o = system_info()->lcd_orientation;
|
||||
|
||||
memset(&src, 0x00, sizeof(src));
|
||||
memset(&dst, 0x00, sizeof(dst));
|
||||
|
||||
dirty_rects =
|
||||
lcd_fb_dirty_rects_get_dirty_rects_by_fb(&(lcd_mem->fb_dirty_rects_list), offline_fb);
|
||||
if (dirty_rects != NULL && dirty_rects->nr > 0) {
|
||||
SDL_Rect sr = {0, 0, lcd->w, lcd->h};
|
||||
if (o == LCD_ORIENTATION_90 || o == LCD_ORIENTATION_270) {
|
||||
sr.w = lcd->h;
|
||||
sr.h = lcd->w;
|
||||
}
|
||||
|
||||
SDL_LockTexture(info->texture, NULL, (void**)&(addr), &pitch);
|
||||
bitmap_init(&dst, sr.w, sr.h, special->format, addr);
|
||||
bitmap_set_line_length(&dst, pitch);
|
||||
bitmap_init(&src, lcd->w, lcd->h, special->format, offline_fb);
|
||||
if (dirty_rects->disable_multiple) {
|
||||
const rect_t* dr = (const rect_t*)&(dirty_rects->max);
|
||||
if (o == LCD_ORIENTATION_0) {
|
||||
image_copy(&dst, &src, dr, dr->x, dr->y);
|
||||
} else {
|
||||
image_rotate(&dst, &src, dr, o);
|
||||
}
|
||||
} else {
|
||||
uint32_t i = 0;
|
||||
for (i = 0; i < dirty_rects->nr; i++) {
|
||||
const rect_t* dr = (const rect_t*)dirty_rects->rects + i;
|
||||
if (o == LCD_ORIENTATION_0) {
|
||||
image_copy(&dst, &src, dr, dr->x, dr->y);
|
||||
} else {
|
||||
image_rotate(&dst, &src, dr, o);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SDL_UnlockTexture(info->texture);
|
||||
|
||||
SDL_RenderCopy(info->render, info->texture, &sr, &sr);
|
||||
|
||||
if (src.buffer != NULL) {
|
||||
graphic_buffer_destroy(src.buffer);
|
||||
}
|
||||
if (dst.buffer != NULL) {
|
||||
graphic_buffer_destroy(dst.buffer);
|
||||
}
|
||||
}
|
||||
|
||||
if (lcd->draw_mode != LCD_DRAW_OFFLINE) {
|
||||
SDL_RenderPresent(info->render);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_sdl2_resize(lcd_t* lcd, wh_t w, wh_t h, uint32_t line_length) {
|
||||
lcd_mem_special_t* special = (lcd_mem_special_t*)lcd;
|
||||
special_info_t* info = (special_info_t*)(special->ctx);
|
||||
|
||||
SDL_DestroyTexture(info->texture);
|
||||
|
||||
info->texture = NULL;
|
||||
special_info_create_texture(info, w, h);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_sdl2_destroy(lcd_t* lcd) {
|
||||
lcd_mem_special_t* special = (lcd_mem_special_t*)lcd;
|
||||
|
||||
special_info_destroy((special_info_t*)(special->ctx));
|
||||
special->ctx = NULL;
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
lcd_t* lcd_sdl2_init(SDL_Renderer* render) {
|
||||
int w = 0;
|
||||
int h = 0;
|
||||
special_info_t* info = NULL;
|
||||
return_value_if_fail(render != NULL, NULL);
|
||||
|
||||
SDL_GetRendererOutputSize(render, &w, &h);
|
||||
info = special_info_create(render);
|
||||
return_value_if_fail(info != NULL, NULL);
|
||||
|
||||
ENSURE(special_info_create_texture(info, w, h) == RET_OK);
|
||||
|
||||
return lcd_mem_special_create(w, h, info->format, lcd_sdl2_flush, lcd_sdl2_resize,
|
||||
lcd_sdl2_destroy, info);
|
||||
}
|
34
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_sdl2.h
Normal file
34
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_sdl2.h
Normal file
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* File: lcd_sdl2.h
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: sdl2 implemented lcd interface/
|
||||
*
|
||||
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* License file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* History:
|
||||
* ================================================================
|
||||
* 2018-01-13 Li XianJing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LCD_SDL_H
|
||||
#define LCD_SDL_H
|
||||
|
||||
#include "base/lcd.h"
|
||||
#include <SDL.h>
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
lcd_t* lcd_sdl2_init(SDL_Renderer* render);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /*LCD_SDL_H*/
|
148
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_sdl2_mono.c
Normal file
148
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_sdl2_mono.c
Normal file
@ -0,0 +1,148 @@
|
||||
/**
|
||||
* File: lcd_sdl2_mono.c
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: sdl2 implemented lcd interface/
|
||||
*
|
||||
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* License file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* History:
|
||||
* ================================================================
|
||||
* 2018-01-13 Li XianJing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
#include "tkc/mem.h"
|
||||
#include "lcd/lcd_mono.h"
|
||||
#include "lcd/lcd_sdl2_mono.h"
|
||||
|
||||
typedef struct _mono_info_t {
|
||||
SDL_Renderer* render;
|
||||
SDL_Texture* texture;
|
||||
} mono_info_t;
|
||||
|
||||
static mono_info_t* mono_info_create(SDL_Renderer* render) {
|
||||
mono_info_t* info = TKMEM_ZALLOC(mono_info_t);
|
||||
return_value_if_fail(info != NULL, NULL);
|
||||
|
||||
info->render = render;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
static ret_t mono_info_create_texture(mono_info_t* info, wh_t w, wh_t h) {
|
||||
int flags = SDL_TEXTUREACCESS_STREAMING;
|
||||
|
||||
/*SDL ABGR is rgba from low address to high address*/
|
||||
info->texture = SDL_CreateTexture(info->render, SDL_PIXELFORMAT_ARGB8888, flags, w, h);
|
||||
log_debug("WITH_FB_BGRA8888\n");
|
||||
|
||||
return info->texture != NULL ? RET_OK : RET_FAIL;
|
||||
}
|
||||
|
||||
static ret_t mono_info_destroy(mono_info_t* info) {
|
||||
return_value_if_fail(info != NULL, RET_BAD_PARAMS);
|
||||
|
||||
SDL_DestroyTexture(info->texture);
|
||||
TKMEM_FREE(info);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_sdl2_mono_flush(lcd_t* lcd) {
|
||||
rect_t dr;
|
||||
bitmap_t src;
|
||||
bitmap_t dst;
|
||||
int pitch = 0;
|
||||
void* addr = NULL;
|
||||
lcd_mono_t* mono = (lcd_mono_t*)(lcd);
|
||||
const rect_t* fps_r = &(lcd->fps_rect);
|
||||
mono_info_t* info = (mono_info_t*)(mono->ctx);
|
||||
|
||||
lcd_get_dirty_rect(lcd, &dr);
|
||||
memset(&src, 0x00, sizeof(src));
|
||||
memset(&dst, 0x00, sizeof(dst));
|
||||
|
||||
if ((dr.w > 0 && dr.h > 0) || (fps_r->w > 0 && fps_r->h > 0)) {
|
||||
uint32_t j = 0;
|
||||
uint32_t i = 0;
|
||||
uint8_t* p = NULL;
|
||||
SDL_Rect sr = {0, 0, lcd->w, lcd->h};
|
||||
|
||||
SDL_LockTexture(info->texture, NULL, (void**)&(addr), &pitch);
|
||||
bitmap_init(&dst, lcd->w, lcd->h, BITMAP_FMT_BGRA8888, addr);
|
||||
|
||||
for (j = 0; j < lcd->h; j++) {
|
||||
for (i = 0; i < lcd->w; i++) {
|
||||
bool_t pixel = bitmap_mono_get_pixel(mono->data, lcd->w, lcd->h, i, j);
|
||||
p = ((uint8_t*)addr) + j * pitch + i * 4;
|
||||
if (pixel) {
|
||||
p[0] = 0xff;
|
||||
p[1] = 0xff;
|
||||
p[2] = 0xff;
|
||||
p[3] = 0xff;
|
||||
} else {
|
||||
p[0] = 0;
|
||||
p[1] = 0;
|
||||
p[2] = 0;
|
||||
p[3] = 0xff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SDL_UnlockTexture(info->texture);
|
||||
|
||||
SDL_RenderCopy(info->render, info->texture, &sr, &sr);
|
||||
}
|
||||
|
||||
if (lcd->draw_mode != LCD_DRAW_OFFLINE) {
|
||||
SDL_RenderPresent(info->render);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_sdl2_mono_destroy(lcd_t* lcd) {
|
||||
lcd_mono_t* mono = (lcd_mono_t*)lcd;
|
||||
|
||||
mono_info_destroy((mono_info_t*)(mono->ctx));
|
||||
mono->ctx = NULL;
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
ret_t lcd_sdl2_mono_reinit(lcd_t* lcd, wh_t w, wh_t h, uint32_t line_length) {
|
||||
mono_info_t* info = NULL;
|
||||
lcd_mono_t* mono = (lcd_mono_t*)(lcd);
|
||||
return_value_if_fail(mono != NULL, RET_BAD_PARAMS);
|
||||
|
||||
info = (mono_info_t*)(mono->ctx);
|
||||
return_value_if_fail(info != NULL, RET_BAD_PARAMS);
|
||||
(void)line_length;
|
||||
|
||||
SDL_DestroyTexture(info->texture);
|
||||
|
||||
return mono_info_create_texture(info, w, h);
|
||||
}
|
||||
|
||||
lcd_t* lcd_sdl2_mono_init(SDL_Renderer* render) {
|
||||
int w = 0;
|
||||
int h = 0;
|
||||
mono_info_t* info = NULL;
|
||||
return_value_if_fail(render != NULL, NULL);
|
||||
|
||||
SDL_GetRendererOutputSize(render, &w, &h);
|
||||
info = mono_info_create(render);
|
||||
return_value_if_fail(info != NULL, NULL);
|
||||
|
||||
ENSURE(mono_info_create_texture(info, w, h) == RET_OK);
|
||||
|
||||
return lcd_mono_create(w, h, lcd_sdl2_mono_flush, lcd_sdl2_mono_destroy, info);
|
||||
}
|
36
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_sdl2_mono.h
Normal file
36
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_sdl2_mono.h
Normal file
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* File: lcd_sdl2_mono.h
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: mono lcd on sdl2
|
||||
*
|
||||
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* License file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* History:
|
||||
* ================================================================
|
||||
* 2010-08-13 Li XianJing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LCD_SDL_MONO_H
|
||||
#define LCD_SDL_MONO_H
|
||||
|
||||
#include <SDL.h>
|
||||
#include "base/lcd.h"
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
lcd_t* lcd_sdl2_mono_init(SDL_Renderer* render);
|
||||
|
||||
ret_t lcd_sdl2_mono_reinit(lcd_t* lcd, wh_t w, wh_t h, uint32_t line_length);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /*LCD_SDL_MONO_H*/
|
399
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_vgcanvas.inc
Normal file
399
MXC_A27-PCB4.5-270T/lib/awtk/awtk/src/lcd/lcd_vgcanvas.inc
Normal file
@ -0,0 +1,399 @@
|
||||
/**
|
||||
* File: lcd.c
|
||||
* Author: Li XianJing <xianjimli@hotmail.com>
|
||||
* Brief: vgcanvasi implemented lcd_t
|
||||
*
|
||||
* Copyright (c) 2018 - 2020 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* License file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* History:
|
||||
* ================================================================
|
||||
* 2018-04-11 Li XianJing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
#include "base/lcd.h"
|
||||
#include "tkc/mem.h"
|
||||
#include "tkc/utf8.h"
|
||||
#include "tkc/str.h"
|
||||
#include "base/vgcanvas.h"
|
||||
#include "base/system_info.h"
|
||||
|
||||
typedef struct _lcd_vgcanvas_t {
|
||||
lcd_t base;
|
||||
|
||||
vgcanvas_t* canvas;
|
||||
str_t temp_text;
|
||||
} lcd_vgcanvas_t;
|
||||
|
||||
#define LCD(lcd) ((lcd_vgcanvas_t*)lcd)
|
||||
|
||||
static ret_t lcd_vgcanvas_resize(lcd_t* lcd, wh_t w, wh_t h, uint32_t line_length) {
|
||||
lcd->w = w;
|
||||
lcd->h = h;
|
||||
LCD(lcd)->canvas->w = w;
|
||||
LCD(lcd)->canvas->h = h;
|
||||
LCD(lcd)->canvas->dirty_rect.w = w;
|
||||
LCD(lcd)->canvas->dirty_rect.h = h;
|
||||
(void)line_length;
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_vgcanvas_set_orientation(lcd_t* lcd, lcd_orientation_t old_orientation, lcd_orientation_t new_orientation) {
|
||||
if (tk_is_swap_size_by_orientation(old_orientation, new_orientation)) {
|
||||
return lcd_vgcanvas_resize(lcd, lcd->h, lcd->w, 0);
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_vgcanvas_set_font_name(lcd_t* lcd, const char* name) {
|
||||
return vgcanvas_set_font(LCD(lcd)->canvas, name);
|
||||
}
|
||||
|
||||
static ret_t lcd_vgcanvas_set_font_size(lcd_t* lcd, uint32_t size) {
|
||||
return vgcanvas_set_font_size(LCD(lcd)->canvas, size);
|
||||
}
|
||||
|
||||
static ret_t lcd_vgcanvas_begin_frame(lcd_t* lcd, const dirty_rects_t* dirty_rects) {
|
||||
return vgcanvas_begin_frame(LCD(lcd)->canvas, dirty_rects);
|
||||
}
|
||||
|
||||
static ret_t lcd_vgcanvas_set_clip_rect(lcd_t* lcd, const rect_t* r) {
|
||||
return vgcanvas_clip_rect(LCD(lcd)->canvas, r->x, r->y, r->w, r->h);
|
||||
}
|
||||
|
||||
static bool_t lcd_vgcanvas_is_rect_in_clip_rect(lcd_t* lcd, xy_t left, xy_t top, xy_t right, xy_t bottom) {
|
||||
vgcanvas_t* canvas = LCD(lcd)->canvas;
|
||||
return vgcanvas_is_rectf_in_clip_rect(canvas, (float_t)left, (float_t)top, (float_t)right, (float_t)bottom);
|
||||
}
|
||||
|
||||
static ret_t lcd_vgcanvas_get_clip_rect(lcd_t* lcd, rect_t* r) {
|
||||
vgcanvas_t* canvas = LCD(lcd)->canvas;
|
||||
*r = rect_from_rectf(vgcanvas_get_clip_rect(canvas));
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
||||
#ifdef DIRTY_RECTS_CLIP_SUPPORT
|
||||
static ret_t lcd_vgcanvas_set_clip_dirty_rects (lcd_t* lcd, const dirty_rects_t* dirty_rects) {
|
||||
return vgcanvas_clip_dirty_rects(LCD(lcd)->canvas, dirty_rects);
|
||||
}
|
||||
#endif
|
||||
|
||||
static ret_t lcd_vgcanvas_set_global_alpha(lcd_t* lcd, uint8_t alpha) {
|
||||
return vgcanvas_set_global_alpha(LCD(lcd)->canvas, (float_t)alpha / 255.0);
|
||||
}
|
||||
|
||||
static ret_t lcd_vgcanvas_draw_vline_with_color(lcd_t* lcd, xy_t x, xy_t y, wh_t h, color_t stroke_color) {
|
||||
vgcanvas_t* canvas = LCD(lcd)->canvas;
|
||||
|
||||
vgcanvas_save(canvas);
|
||||
vgcanvas_begin_path(canvas);
|
||||
vgcanvas_set_antialias(canvas, FALSE);
|
||||
vgcanvas_translate(canvas, 0.5f, 0.0f);
|
||||
vgcanvas_move_to(canvas, x, y);
|
||||
vgcanvas_line_to(canvas, x, y + h);
|
||||
vgcanvas_set_line_width(canvas, 1);
|
||||
vgcanvas_set_stroke_color(canvas, stroke_color);
|
||||
vgcanvas_stroke(canvas);
|
||||
vgcanvas_set_antialias(canvas, TRUE);
|
||||
vgcanvas_begin_path(canvas);
|
||||
vgcanvas_restore(canvas);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_vgcanvas_draw_vline(lcd_t* lcd, xy_t x, xy_t y, wh_t h) {
|
||||
return lcd_vgcanvas_draw_vline_with_color(lcd, x, y, h, lcd->stroke_color);
|
||||
}
|
||||
|
||||
static ret_t lcd_vgcanvas_draw_hline_with_color(lcd_t* lcd, xy_t x, xy_t y, wh_t w, color_t stroke_color) {
|
||||
vgcanvas_t* canvas = LCD(lcd)->canvas;
|
||||
|
||||
vgcanvas_save(canvas);
|
||||
vgcanvas_begin_path(canvas);
|
||||
vgcanvas_set_antialias(canvas, FALSE);
|
||||
vgcanvas_translate(canvas, 0.0f, 0.5f);
|
||||
vgcanvas_move_to(canvas, x, y);
|
||||
vgcanvas_line_to(canvas, x + w, y);
|
||||
vgcanvas_set_line_width(canvas, 1);
|
||||
vgcanvas_set_stroke_color(canvas, stroke_color);
|
||||
vgcanvas_stroke(canvas);
|
||||
vgcanvas_set_antialias(canvas, TRUE);
|
||||
vgcanvas_begin_path(canvas);
|
||||
vgcanvas_restore(canvas);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_vgcanvas_draw_hline(lcd_t* lcd, xy_t x, xy_t y, wh_t w) {
|
||||
return lcd_vgcanvas_draw_hline_with_color(lcd, x, y, w, lcd->stroke_color);
|
||||
}
|
||||
|
||||
static ret_t lcd_vgcanvas_fill_rect(lcd_t* lcd, xy_t x, xy_t y, wh_t w, wh_t h) {
|
||||
vgcanvas_t* canvas = LCD(lcd)->canvas;
|
||||
|
||||
if (w > 1 && h > 1) {
|
||||
vgcanvas_save(canvas);
|
||||
#ifdef WITH_VGCANVAS
|
||||
vgcanvas_begin_path(canvas);
|
||||
// 20211130 加入下一条语句避免demoui gif出现白色竖线
|
||||
vgcanvas_set_antialias(canvas, FALSE);
|
||||
vgcanvas_set_fill_color(canvas, lcd->fill_color);
|
||||
vgcanvas_clear_rect(canvas, x, y, w, h, lcd->fill_color);
|
||||
vgcanvas_set_antialias(canvas, TRUE);
|
||||
#else
|
||||
vgcanvas_begin_path(canvas);
|
||||
vgcanvas_set_antialias(canvas, FALSE);
|
||||
vgcanvas_rect(canvas, x, y, w, h);
|
||||
vgcanvas_set_fill_color(canvas, lcd->fill_color);
|
||||
vgcanvas_fill(canvas);
|
||||
vgcanvas_set_antialias(canvas, TRUE);
|
||||
#endif
|
||||
vgcanvas_begin_path(canvas);
|
||||
vgcanvas_restore(canvas);
|
||||
} else if (w <= 1) {
|
||||
lcd_vgcanvas_draw_vline_with_color(lcd, x, y, h, lcd->fill_color);
|
||||
} else if (h <= 1) {
|
||||
lcd_vgcanvas_draw_hline_with_color(lcd, x, y, w, lcd->fill_color);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_vgcanvas_clear_rect(lcd_t* lcd, xy_t x, xy_t y, wh_t w, wh_t h) {
|
||||
vgcanvas_t* canvas = LCD(lcd)->canvas;
|
||||
|
||||
vgcanvas_save(canvas);
|
||||
vgcanvas_clear_rect(canvas, x, y, w, h, lcd->fill_color);
|
||||
vgcanvas_restore(canvas);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_vgcanvas_stroke_rect(lcd_t* lcd, xy_t x, xy_t y, wh_t w, wh_t h) {
|
||||
float_t offset_1 = 1.0f / lcd->ratio;
|
||||
float_t offset_5 = 0.5f / lcd->ratio;
|
||||
vgcanvas_t* canvas = LCD(lcd)->canvas;
|
||||
|
||||
vgcanvas_begin_path(canvas);
|
||||
vgcanvas_rect(canvas, x + offset_5, y + offset_5, w - offset_1, h - offset_1);
|
||||
vgcanvas_set_line_width(canvas, 1);
|
||||
vgcanvas_set_stroke_color(canvas, lcd->stroke_color);
|
||||
vgcanvas_stroke(canvas);
|
||||
vgcanvas_begin_path(canvas);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_vgcanvas_draw_points(lcd_t* lcd, point_t* points, uint32_t nr) {
|
||||
uint32_t i = 0;
|
||||
float_t offset = 0.5f * lcd->ratio;
|
||||
vgcanvas_t* canvas = LCD(lcd)->canvas;
|
||||
vgcanvas_set_stroke_color(canvas, lcd->stroke_color);
|
||||
vgcanvas_set_line_width(canvas, 1);
|
||||
for (i = 0; i < nr; i++) {
|
||||
float x = points[i].x;
|
||||
float y = points[i].y;
|
||||
|
||||
x += offset;
|
||||
|
||||
vgcanvas_begin_path(canvas);
|
||||
vgcanvas_move_to(canvas, x, y + offset);
|
||||
vgcanvas_line_to(canvas, x, y);
|
||||
vgcanvas_stroke(canvas);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t lcd_vgcanvas_draw_image(lcd_t* lcd, bitmap_t* img, const rectf_t* src, const rectf_t* dst) {
|
||||
float_t sx = src->x;
|
||||
float_t sy = src->y;
|
||||
float_t sw = src->w;
|
||||
float_t sh = src->h;
|
||||
float_t dx = dst->x;
|
||||
float_t dy = dst->y;
|
||||
float_t dw = dst->w;
|
||||
float_t dh = dst->h;
|
||||
ret_t ret = RET_OK;
|
||||
vgcanvas_t* canvas = LCD(lcd)->canvas;
|
||||
|
||||
vgcanvas_save(canvas);
|
||||
vgcanvas_set_antialias(canvas, FALSE);
|
||||
ret = vgcanvas_draw_image(canvas, img, sx, sy, sw, sh, dx, dy, dw, dh);
|
||||
vgcanvas_set_antialias(canvas, TRUE);
|
||||
vgcanvas_restore(canvas);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ret_t lcd_vgcanvas_draw_image_repeat(lcd_t* lcd, bitmap_t* img, const rect_t* src, const rect_t* dst, wh_t dst_w, wh_t dst_h) {
|
||||
float_t sx = src->x;
|
||||
float_t sy = src->y;
|
||||
float_t sw = src->w;
|
||||
float_t sh = src->h;
|
||||
float_t dx = dst->x;
|
||||
float_t dy = dst->y;
|
||||
float_t dw = dst->w;
|
||||
float_t dh = dst->h;
|
||||
ret_t ret = RET_NOT_IMPL;
|
||||
vgcanvas_t* canvas = LCD(lcd)->canvas;
|
||||
if (canvas != NULL && canvas->vt->draw_image_repeat != NULL) {
|
||||
vgcanvas_save(canvas);
|
||||
vgcanvas_set_antialias(canvas, FALSE);
|
||||
ret = vgcanvas_draw_image_repeat(canvas, img, sx, sy, sw, sh, dx, dy, dw, dh, (float_t)dst_w, (float_t)dst_h);
|
||||
vgcanvas_set_antialias(canvas, TRUE);
|
||||
vgcanvas_restore(canvas);
|
||||
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ret_t lcd_vgcanvas_draw_image_matrix(lcd_t* lcd, draw_image_info_t* info) {
|
||||
matrix_t* m = &(info->matrix);
|
||||
const rect_t* s = &(info->src);
|
||||
const rect_t* d = &(info->dst);
|
||||
vgcanvas_t* canvas = LCD(lcd)->canvas;
|
||||
vgcanvas_save(canvas);
|
||||
vgcanvas_set_transform(canvas, m->a0, m->a1, m->a2, m->a3, m->a4, m->a5);
|
||||
vgcanvas_draw_image(canvas, info->img, s->x, s->y, s->w, s->h, d->x, d->y, d->w, d->h);
|
||||
vgcanvas_restore(canvas);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
float_t lcd_vgcanvas_measure_text(lcd_t* lcd, const wchar_t* str, uint32_t nr) {
|
||||
str_t* text = &(LCD(lcd)->temp_text);
|
||||
vgcanvas_t* canvas = LCD(lcd)->canvas;
|
||||
return_value_if_fail(str_from_wstr_with_len(text, str, nr) == RET_OK, RET_OOM);
|
||||
|
||||
vgcanvas_set_font(canvas, lcd->font_name);
|
||||
vgcanvas_set_font_size(canvas, lcd->font_size);
|
||||
|
||||
return vgcanvas_measure_text(LCD(lcd)->canvas, text->str);
|
||||
}
|
||||
|
||||
static ret_t lcd_vgcanvas_draw_text(lcd_t* lcd, const wchar_t* str, uint32_t nr, xy_t x, xy_t y) {
|
||||
str_t* text = &(LCD(lcd)->temp_text);
|
||||
vgcanvas_t* canvas = LCD(lcd)->canvas;
|
||||
return_value_if_fail(str_from_wstr_with_len(text, str, nr) == RET_OK, RET_OOM);
|
||||
|
||||
vgcanvas_set_font(canvas, lcd->font_name);
|
||||
vgcanvas_set_font_size(canvas, lcd->font_size);
|
||||
vgcanvas_set_fill_color(canvas, lcd->text_color);
|
||||
vgcanvas_set_text_align(canvas, "left");
|
||||
vgcanvas_set_text_baseline(canvas, "top");
|
||||
|
||||
return vgcanvas_fill_text(canvas, text->str, x, y, 0xffff);
|
||||
}
|
||||
|
||||
wh_t lcd_vgcanvas_get_width(lcd_t* lcd) {
|
||||
vgcanvas_t* canvas = LCD(lcd)->canvas;
|
||||
|
||||
return vgcanvas_get_width(canvas);
|
||||
}
|
||||
|
||||
wh_t lcd_vgcanvas_get_height(lcd_t* lcd) {
|
||||
vgcanvas_t* canvas = LCD(lcd)->canvas;
|
||||
|
||||
return vgcanvas_get_height(canvas);
|
||||
}
|
||||
|
||||
static ret_t lcd_vgcanvas_end_frame(lcd_t* lcd) {
|
||||
return vgcanvas_end_frame(LCD(lcd)->canvas);
|
||||
}
|
||||
|
||||
static ret_t lcd_vgcanvas_destroy(lcd_t* lcd) {
|
||||
vgcanvas_t* canvas = LCD(lcd)->canvas;
|
||||
str_reset(&(LCD(lcd)->temp_text));
|
||||
vgcanvas_destroy(canvas);
|
||||
memset(lcd, 0x00, sizeof(lcd_t));
|
||||
TKMEM_FREE(lcd);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static vgcanvas_t* lcd_vgcanvas_get_vgcanvas(lcd_t* lcd) {
|
||||
vgcanvas_t* canvas = LCD(lcd)->canvas;
|
||||
vgcanvas_begin_path(canvas);
|
||||
|
||||
return canvas;
|
||||
}
|
||||
|
||||
static bitmap_format_t lcd_vgcanvas_get_desired_bitmap_format(lcd_t* lcd) {
|
||||
#ifdef WITH_VG_GPU
|
||||
#ifdef WITH_FB_BGR565
|
||||
return BITMAP_FMT_RGB565;
|
||||
#else
|
||||
return BITMAP_FMT_BGRA8888;
|
||||
#endif
|
||||
#else
|
||||
return BITMAP_FMT_RGBA8888;
|
||||
#endif
|
||||
}
|
||||
|
||||
static ret_t lcd_vgcanvas_get_text_metrics(lcd_t* lcd, float_t* ascender,
|
||||
float_t* descender, float_t* lineh) {
|
||||
vgcanvas_t* canvas = LCD(lcd)->canvas;
|
||||
return vgcanvas_get_text_metrics(canvas, ascender, descender, lineh);
|
||||
}
|
||||
|
||||
lcd_t* lcd_vgcanvas_init(wh_t w, wh_t h, vgcanvas_t* canvas) {
|
||||
lcd_vgcanvas_t* lcd = TKMEM_ZALLOC(lcd_vgcanvas_t);
|
||||
lcd_t* base = &(lcd->base);
|
||||
system_info_t* info = system_info();
|
||||
return_value_if_fail(canvas != NULL, NULL);
|
||||
|
||||
base->begin_frame = lcd_vgcanvas_begin_frame;
|
||||
base->set_clip_rect = lcd_vgcanvas_set_clip_rect;
|
||||
base->get_clip_rect = lcd_vgcanvas_get_clip_rect;
|
||||
base->is_rect_in_clip_rect = lcd_vgcanvas_is_rect_in_clip_rect;
|
||||
#ifdef DIRTY_RECTS_CLIP_SUPPORT
|
||||
base->set_clip_dirty_rects = lcd_vgcanvas_set_clip_dirty_rects;
|
||||
#endif
|
||||
base->draw_vline = lcd_vgcanvas_draw_vline;
|
||||
base->draw_hline = lcd_vgcanvas_draw_hline;
|
||||
base->fill_rect = lcd_vgcanvas_fill_rect;
|
||||
base->clear_rect = lcd_vgcanvas_clear_rect;
|
||||
base->stroke_rect = lcd_vgcanvas_stroke_rect;
|
||||
base->draw_image = lcd_vgcanvas_draw_image;
|
||||
base->draw_image_repeat = lcd_vgcanvas_draw_image_repeat;
|
||||
base->draw_image_matrix = lcd_vgcanvas_draw_image_matrix;
|
||||
base->draw_points = lcd_vgcanvas_draw_points;
|
||||
base->draw_text = lcd_vgcanvas_draw_text;
|
||||
base->measure_text = lcd_vgcanvas_measure_text;
|
||||
base->end_frame = lcd_vgcanvas_end_frame;
|
||||
base->get_vgcanvas = lcd_vgcanvas_get_vgcanvas;
|
||||
base->set_font_name = lcd_vgcanvas_set_font_name;
|
||||
base->set_font_size = lcd_vgcanvas_set_font_size;
|
||||
base->set_global_alpha = lcd_vgcanvas_set_global_alpha;
|
||||
base->get_desired_bitmap_format = lcd_vgcanvas_get_desired_bitmap_format;
|
||||
base->resize = lcd_vgcanvas_resize;
|
||||
base->get_width = lcd_vgcanvas_get_width;
|
||||
base->get_height = lcd_vgcanvas_get_height;
|
||||
base->destroy = lcd_vgcanvas_destroy;
|
||||
base->get_text_metrics = lcd_vgcanvas_get_text_metrics;
|
||||
base->set_orientation = lcd_vgcanvas_set_orientation;
|
||||
base->w = (wh_t)w;
|
||||
base->h = (wh_t)h;
|
||||
base->ratio = canvas->ratio;
|
||||
base->type = LCD_VGCANVAS;
|
||||
base->support_dirty_rect = TRUE;
|
||||
|
||||
system_info_set_lcd_w(info, base->w);
|
||||
system_info_set_lcd_h(info, base->h);
|
||||
system_info_set_lcd_type(info, base->type);
|
||||
system_info_set_device_pixel_ratio(info, canvas->ratio);
|
||||
|
||||
str_init(&(lcd->temp_text), 100);
|
||||
lcd->canvas = canvas;
|
||||
|
||||
return base;
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
/**
|
||||
* File: lcd_mem_{fmt}.c
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: {fmt} mem lcd.
|
||||
*
|
||||
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* License file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* History:
|
||||
* ================================================================
|
||||
* {date} Generated by gen.sh(DONT MODIFY IT)
|
||||
*
|
||||
*/
|
||||
|
||||
#define LCD_FORMAT BITMAP_FMT_{FMT}
|
||||
|
||||
#include "tkc/mem.h"
|
||||
#include "base/pixel.h"
|
||||
#include "lcd/lcd_mem.h"
|
||||
|
||||
#define pixel_t pixel_{fmt}_t
|
||||
#define pixel_bpp pixel_{fmt}_BPP
|
||||
#define pixel_to_rgba pixel_{fmt}_to_rgba
|
||||
#define pixel_from_rgb pixel_{fmt}_from_rgb
|
||||
#define pixel_from_rgba pixel_{fmt}_from_rgba
|
||||
|
||||
#include "blend/pixel_ops.inc"
|
||||
#include "lcd/lcd_mem.inc"
|
||||
|
||||
lcd_t* lcd_mem_{fmt}_init(lcd_mem_t* lcd, wh_t w, wh_t h, bool_t alloc) {
|
||||
return lcd_mem_init(lcd, w, h, alloc);
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_{fmt}_create(wh_t w, wh_t h, bool_t alloc) {
|
||||
return lcd_mem_create(w, h, alloc);
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_{fmt}_create_single_fb(wh_t w, wh_t h, uint8_t* fbuff) {
|
||||
return lcd_mem_create_single_fb(w, h, fbuff);
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_{fmt}_create_double_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb) {
|
||||
return lcd_mem_create_double_fb(w, h, online_fb, offline_fb);
|
||||
}
|
||||
|
||||
lcd_t* lcd_mem_{fmt}_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb,
|
||||
uint8_t* next_fb) {
|
||||
return lcd_mem_create_three_fb(w, h, online_fb, offline_fb, next_fb);
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
/**
|
||||
* File: lcd_mem_{fmt}.h
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: {fmt} mem lcd.
|
||||
*
|
||||
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* this program is distributed in the hope that it will be useful,
|
||||
* but without any warranty; without even the implied warranty of
|
||||
* merchantability or fitness for a particular purpose. see the
|
||||
* license file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* history:
|
||||
* ================================================================
|
||||
* {date} Generated by gen.sh(DONT MODIFY IT)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TK_LCD_MEM_{FMT}_H
|
||||
#define TK_LCD_MEM_{FMT}_H
|
||||
|
||||
#include "lcd/lcd_mem.h"
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
/**
|
||||
* @class lcd_mem_{fmt}_t
|
||||
* @parent lcd_t
|
||||
* @annotation ["fake"]
|
||||
*/
|
||||
|
||||
/**
|
||||
* @method lcd_mem_{fmt}_create
|
||||
*
|
||||
* 创建lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {bool_t} alloc 是否分配内存。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_{fmt}_create(wh_t w, wh_t h, bool_t alloc);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_{fmt}_create_single_fb
|
||||
*
|
||||
* 创建single fb lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {uint8_t*} fbuff 帧率缓冲区。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_{fmt}_create_single_fb(wh_t w, wh_t h, uint8_t* fbuff);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_{fmt}_create_double_fb
|
||||
*
|
||||
* 创建double fb lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {uint8_t*} online_fb 在线帧率缓冲区。
|
||||
* @param {uint8_t*} offline_fb 离线帧率缓冲区。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_{fmt}_create_double_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_{fmt}_create_three_fb
|
||||
*
|
||||
* 创建three fb lcd对象。
|
||||
*
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {uint8_t*} online_fb 在线帧率缓冲区。
|
||||
* @param {uint8_t*} offline_fb 离线帧率缓冲区。
|
||||
* @param {uint8_t*} next_fb 待显示的帧率缓冲区。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_{fmt}_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb,
|
||||
uint8_t* next_fb);
|
||||
|
||||
/**
|
||||
* @method lcd_mem_{fmt}_init
|
||||
*
|
||||
* 创建lcd对象。
|
||||
*
|
||||
* @param {lcd_mem_t*} lcd 对象。
|
||||
* @param {wh_t} w 宽度。
|
||||
* @param {wh_t} h 高度。
|
||||
* @param {bool_t} alloc 是否分配内存。
|
||||
*
|
||||
* @return {lcd_t*} 返回lcd对象。
|
||||
*/
|
||||
lcd_t* lcd_mem_{fmt}_init(lcd_mem_t* lcd, wh_t w, wh_t h, bool_t alloc);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /*TK_LCD_MEM_{FMT}_H*/
|
Reference in New Issue
Block a user