mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-30 02:58:26 +08:00
lcd nanovg support lcd orientation
This commit is contained in:
parent
c4109fe778
commit
4ae5ebb803
@ -4,6 +4,7 @@
|
||||
* 增加graphic\_buffer,用于管理bitmap的内存。
|
||||
* 完善vgcanvas,兼容JZ\_GPU。
|
||||
* 完善darray,增加darray\_find\_all。
|
||||
* lcd nanovg支持LCD旋转(感谢智明提供补丁)。
|
||||
|
||||
> 如果有支持访问bitmap-\>data的代码,请使用bitmap\_lock\_buffer\_for\_write/read函数。
|
||||
|
||||
|
@ -76,8 +76,13 @@ ret_t pointer_event_rotate(pointer_event_t* evt, system_info_t* info) {
|
||||
|
||||
switch (info->lcd_orientation) {
|
||||
case LCD_ORIENTATION_90: {
|
||||
#if WITH_NANOVG_GPU
|
||||
evt->y = info->lcd_w - x - 1;
|
||||
evt->x = y;
|
||||
#else
|
||||
evt->y = x;
|
||||
evt->x = info->lcd_h - y - 1;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case LCD_ORIENTATION_180: {
|
||||
@ -86,8 +91,13 @@ ret_t pointer_event_rotate(pointer_event_t* evt, system_info_t* info) {
|
||||
break;
|
||||
}
|
||||
case LCD_ORIENTATION_270: {
|
||||
#if WITH_NANOVG_GPU
|
||||
evt->y = x;
|
||||
evt->x = info->lcd_h - y - 1;
|
||||
#else
|
||||
evt->y = info->lcd_w - x - 1;
|
||||
evt->x = y;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -9,13 +9,48 @@ static ret_t vgcanvas_nanovg_reinit(vgcanvas_t* vg, uint32_t w, uint32_t h, uint
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_begin_frame(vgcanvas_t* vgcanvas, rect_t* dirty_rect) {
|
||||
float_t angle = 0.0f;
|
||||
float_t anchor_x = 0.0f;
|
||||
float_t anchor_y = 0.0f;
|
||||
|
||||
system_info_t* info = system_info();
|
||||
vgcanvas_nanovg_t* canvas = (vgcanvas_nanovg_t*)vgcanvas;
|
||||
|
||||
native_window_info_t info;
|
||||
return_value_if_fail(native_window_get_info(canvas->window, &info) == RET_OK, RET_BAD_PARAMS);
|
||||
|
||||
native_window_gl_make_current(canvas->window);
|
||||
nvgBeginFrame(canvas->vg, info.w, info.h, info.ratio);
|
||||
|
||||
nvgBeginFrame(canvas->vg, info->lcd_w, info->lcd_h, info->device_pixel_ratio);
|
||||
|
||||
switch (info->lcd_orientation)
|
||||
{
|
||||
case LCD_ORIENTATION_0:
|
||||
angle = 0.0f;
|
||||
break;
|
||||
case LCD_ORIENTATION_90:
|
||||
angle = TK_D2R(90);
|
||||
break;
|
||||
case LCD_ORIENTATION_180:
|
||||
angle = TK_D2R(180);
|
||||
break;
|
||||
case LCD_ORIENTATION_270:
|
||||
angle = TK_D2R(270);
|
||||
break;
|
||||
}
|
||||
|
||||
anchor_x = info->lcd_w / 2.0f;
|
||||
anchor_y = info->lcd_h / 2.0f;
|
||||
|
||||
nvgSave(canvas->vg);
|
||||
|
||||
if(info->lcd_orientation == LCD_ORIENTATION_90 || info->lcd_orientation == LCD_ORIENTATION_270) {
|
||||
nvgTranslate(canvas->vg, anchor_x, anchor_y);
|
||||
nvgRotate(canvas->vg, angle);
|
||||
nvgTranslate(canvas->vg, -anchor_y, -anchor_x);
|
||||
}
|
||||
else if(info->lcd_orientation == LCD_ORIENTATION_180) {
|
||||
nvgTranslate(canvas->vg, anchor_x, anchor_y);
|
||||
nvgRotate(canvas->vg, angle);
|
||||
nvgTranslate(canvas->vg, -anchor_x, -anchor_y);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
@ -24,6 +59,7 @@ static ret_t vgcanvas_nanovg_end_frame(vgcanvas_t* vgcanvas) {
|
||||
vgcanvas_nanovg_t* canvas = (vgcanvas_nanovg_t*)vgcanvas;
|
||||
NVGcontext* vg = canvas->vg;
|
||||
|
||||
nvgRestore(vg);
|
||||
nvgEndFrame(vg);
|
||||
native_window_swap_buffer(canvas->window);
|
||||
|
||||
|
@ -162,10 +162,8 @@ ret_t window_manager_default_snap_curr_window(widget_t* widget, widget_t* curr_w
|
||||
vg = lcd_get_vgcanvas(c->lcd);
|
||||
ENSURE(vgcanvas_create_fbo(vg, fbo) == RET_OK);
|
||||
ENSURE(vgcanvas_bind_fbo(vg, fbo) == RET_OK);
|
||||
ENSURE(canvas_begin_frame(c, NULL, LCD_DRAW_OFFLINE) == RET_OK);
|
||||
ENSURE(widget_on_paint_background(widget, c) == RET_OK);
|
||||
ENSURE(widget_paint(curr_win, c) == RET_OK);
|
||||
ENSURE(canvas_end_frame(c) == RET_OK);
|
||||
ENSURE(vgcanvas_unbind_fbo(vg, fbo) == RET_OK);
|
||||
fbo_to_img(fbo, img);
|
||||
#else
|
||||
@ -203,7 +201,6 @@ ret_t window_manager_default_snap_prev_window(widget_t* widget, widget_t* prev_w
|
||||
vg = lcd_get_vgcanvas(c->lcd);
|
||||
ENSURE(vgcanvas_create_fbo(vg, fbo) == RET_OK);
|
||||
ENSURE(vgcanvas_bind_fbo(vg, fbo) == RET_OK);
|
||||
ENSURE(canvas_begin_frame(c, NULL, LCD_DRAW_OFFLINE) == RET_OK);
|
||||
ENSURE(widget_on_paint_background(widget, c) == RET_OK);
|
||||
window_manager_paint_system_bar(widget, c);
|
||||
ENSURE(widget_paint(prev_win, c) == RET_OK);
|
||||
@ -211,7 +208,6 @@ ret_t window_manager_default_snap_prev_window(widget_t* widget, widget_t* prev_w
|
||||
if (dialog_highlighter != NULL) {
|
||||
dialog_highlighter_prepare(dialog_highlighter, c);
|
||||
}
|
||||
ENSURE(canvas_end_frame(c) == RET_OK);
|
||||
ENSURE(vgcanvas_unbind_fbo(vg, fbo) == RET_OK);
|
||||
fbo_to_img(fbo, img);
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user