fix get_vgcanvas

This commit is contained in:
xianjimli 2018-09-20 17:18:53 +08:00
parent 305a4bf77d
commit dfb59b190d
3 changed files with 18 additions and 0 deletions

View File

@ -161,6 +161,9 @@ bin\demoui
## 最新动态
* 2018/09/20
* 移植nanovg-agge到stm32和aworks。
* 2018/09/12-19
* 基于agge用纯软件实现nanovg的渲染接口去掉对cairo/agg/piccaso的依赖以最少的代码实现vgcanvas的接口。
* 完善vgcanvas-nanovg支持基于OpenGL和纯软件两种实现。

View File

@ -381,12 +381,19 @@ static ret_t lcd_mem_flush(lcd_t* lcd) {
}
static ret_t lcd_mem_end_frame(lcd_t* lcd) {
lcd_mem_t* mem = (lcd_mem_t*)lcd;
if (lcd->draw_mode == LCD_DRAW_OFFLINE) {
return RET_OK;
}
/*FIXME: Handle ROTATE*/
if(mem->vgcanvas) {
vgcanvas_destroy(mem->vgcanvas);
mem->vgcanvas = NULL;
}
if (lcd_is_swappable(lcd)) {
return lcd_swap(lcd);
} else {
@ -400,6 +407,12 @@ static ret_t lcd_mem_end_frame(lcd_t* lcd) {
}
static ret_t lcd_mem_destroy(lcd_t* lcd) {
lcd_mem_t* mem = (lcd_mem_t*)lcd;
if(mem->vgcanvas) {
vgcanvas_destroy(mem->vgcanvas);
mem->vgcanvas = NULL;
}
TKMEM_FREE(lcd);
return RET_OK;

View File

@ -768,6 +768,8 @@ vgcanvas_t* vgcanvas_create(uint32_t w, uint32_t h, bitmap_format_t format, void
nanovg->base.h = h;
nanovg->base.vt = &vt;
nanovg->base.ratio = 1;
nanovg->base.buff = (uint32_t*)data;
nanovg->vg = nvgCreateAGGE(w, h, f, (uint8_t*)data);
return &(nanovg->base);