mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-02 03:58:33 +08:00
improve lcd resize
This commit is contained in:
parent
8b383cc7ac
commit
d0e9f61d09
@ -1,5 +1,10 @@
|
|||||||
# 最新动态
|
# 最新动态
|
||||||
|
|
||||||
|
2021/07/02
|
||||||
|
* 修复延迟动画刷新的问题(感谢智明提供补丁)
|
||||||
|
* 修复agge的ras初始化的值不正常的问题(感谢智明提供补丁)
|
||||||
|
* 修复linux-fb无法修改lcd分辨率问题(感谢智明提供补丁)
|
||||||
|
|
||||||
2021/07/01
|
2021/07/01
|
||||||
* 增加rectf\_t。
|
* 增加rectf\_t。
|
||||||
* 完善switch。
|
* 完善switch。
|
||||||
|
@ -326,10 +326,10 @@ ret_t lcd_resize(lcd_t* lcd, wh_t w, wh_t h, uint32_t line_length) {
|
|||||||
lcd->h = h;
|
lcd->h = h;
|
||||||
|
|
||||||
if (lcd->resize != NULL) {
|
if (lcd->resize != NULL) {
|
||||||
lcd->resize(lcd, w, h, line_length);
|
return lcd->resize(lcd, w, h, line_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
return RET_OK;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
wh_t lcd_get_width(lcd_t* lcd) {
|
wh_t lcd_get_width(lcd_t* lcd) {
|
||||||
|
@ -77,18 +77,6 @@ ret_t native_window_invalidate(native_window_t* win, const rect_t* r) {
|
|||||||
return dirty_rects_add(&(win->dirty_rects), r);
|
return dirty_rects_add(&(win->dirty_rects), r);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret_t native_window_on_resized(native_window_t* win, wh_t w, wh_t h) {
|
|
||||||
lcd_t* lcd = NULL;
|
|
||||||
return_value_if_fail(win != NULL, RET_BAD_PARAMS);
|
|
||||||
|
|
||||||
lcd = native_window_get_canvas(win)->lcd;
|
|
||||||
return_value_if_fail(lcd != NULL, RET_BAD_PARAMS);
|
|
||||||
|
|
||||||
lcd_resize(lcd, w, h, 0);
|
|
||||||
|
|
||||||
return RET_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret_t native_window_gl_make_current(native_window_t* win) {
|
ret_t native_window_gl_make_current(native_window_t* win) {
|
||||||
return_value_if_fail(win != NULL && win->vt != NULL, RET_BAD_PARAMS);
|
return_value_if_fail(win != NULL && win->vt != NULL, RET_BAD_PARAMS);
|
||||||
return_value_if_fail(win->vt->gl_make_current != NULL, RET_BAD_PARAMS);
|
return_value_if_fail(win->vt->gl_make_current != NULL, RET_BAD_PARAMS);
|
||||||
|
@ -249,7 +249,6 @@ ret_t native_window_end_frame(native_window_t* win);
|
|||||||
rect_t native_window_calc_dirty_rect(native_window_t* win);
|
rect_t native_window_calc_dirty_rect(native_window_t* win);
|
||||||
ret_t native_window_clear_dirty_rect(native_window_t* win);
|
ret_t native_window_clear_dirty_rect(native_window_t* win);
|
||||||
ret_t native_window_update_last_dirty_rect(native_window_t* win);
|
ret_t native_window_update_last_dirty_rect(native_window_t* win);
|
||||||
ret_t native_window_on_resized(native_window_t* win, wh_t w, wh_t h);
|
|
||||||
|
|
||||||
#define NATIVE_WINDOW(win) ((native_window_t*)(win))
|
#define NATIVE_WINDOW(win) ((native_window_t*)(win))
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "base/widget.h"
|
#include "base/widget.h"
|
||||||
#include "lcd/lcd_nanovg.h"
|
#include "lcd/lcd_nanovg.h"
|
||||||
#include "base/widget_consts.h"
|
#include "base/widget_consts.h"
|
||||||
|
#include "base/window_manager.h"
|
||||||
#include "native_window/native_window_fb_gl.h"
|
#include "native_window/native_window_fb_gl.h"
|
||||||
|
|
||||||
typedef struct _native_window_fb_gl_t {
|
typedef struct _native_window_fb_gl_t {
|
||||||
@ -71,13 +72,44 @@ ret_t native_window_fb_gl_set_destroy_func(native_window_t* win, native_window_d
|
|||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lcd_t* native_window_get_lcd(native_window_t* win) {
|
||||||
|
native_window_fb_gl_t* fb_gl = NATIVE_WINDOW_FB_GL(win);
|
||||||
|
return_value_if_fail(fb_gl != NULL, NULL);
|
||||||
|
return fb_gl->canvas.lcd;
|
||||||
|
}
|
||||||
|
|
||||||
static ret_t native_window_fb_gl_move(native_window_t* win, xy_t x, xy_t y) {
|
static ret_t native_window_fb_gl_move(native_window_t* win, xy_t x, xy_t y) {
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ret_t native_window_fg_gl_on_resized_timer(const timer_info_t* info) {
|
||||||
|
widget_t* wm = window_manager();
|
||||||
|
native_window_t* win = NATIVE_WINDOW(info->ctx);
|
||||||
|
event_t e = event_init(EVT_NATIVE_WINDOW_RESIZED, NULL);
|
||||||
|
window_manager_dispatch_native_window_event(window_manager(), &e, win);
|
||||||
|
widget_set_need_relayout_children(wm);
|
||||||
|
widget_invalidate_force(wm, NULL);
|
||||||
|
|
||||||
|
log_debug("on_resized_idle\n");
|
||||||
|
return RET_REMOVE;
|
||||||
|
}
|
||||||
|
|
||||||
static ret_t native_window_fb_gl_resize(native_window_t* win, wh_t w, wh_t h) {
|
static ret_t native_window_fb_gl_resize(native_window_t* win, wh_t w, wh_t h) {
|
||||||
win->rect.w = w;
|
ret_t ret = RET_OK;
|
||||||
win->rect.h = h;
|
native_window_info_t info;
|
||||||
|
native_window_fb_gl_t* fb_gl = NATIVE_WINDOW_FB_GL(win);
|
||||||
|
native_window_get_info(win, &info);
|
||||||
|
|
||||||
|
fb_gl->w = win->rect.w = w;
|
||||||
|
fb_gl->h = win->rect.h = h;
|
||||||
|
if (system_info()->lcd_orientation == LCD_ORIENTATION_0 && (w != info.w || h != info.h)) {
|
||||||
|
|
||||||
|
ret = lcd_resize(fb_gl->canvas.lcd, w, h, 0);
|
||||||
|
return_value_if_fail(ret == RET_OK, ret);
|
||||||
|
system_info_set_lcd_w(system_info(), w);
|
||||||
|
system_info_set_lcd_h(system_info(), h);
|
||||||
|
timer_add(native_window_fg_gl_on_resized_timer, win, 100);
|
||||||
|
}
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +40,8 @@ ret_t native_window_fb_gl_set_make_current_func(native_window_t* win,
|
|||||||
|
|
||||||
ret_t native_window_fb_gl_set_destroy_func(native_window_t* win, native_window_destroy_t destroy);
|
ret_t native_window_fb_gl_set_destroy_func(native_window_t* win, native_window_destroy_t destroy);
|
||||||
|
|
||||||
|
lcd_t* native_window_get_lcd(native_window_t* win);
|
||||||
|
|
||||||
END_C_DECLS
|
END_C_DECLS
|
||||||
|
|
||||||
#endif /*TK_NATIVE_WINDOW_FB_GL_H*/
|
#endif /*TK_NATIVE_WINDOW_FB_GL_H*/
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "base/widget.h"
|
#include "base/widget.h"
|
||||||
|
#include "base/window_manager.h"
|
||||||
#include "native_window/native_window_raw.h"
|
#include "native_window/native_window_raw.h"
|
||||||
|
|
||||||
typedef struct _native_window_raw_t {
|
typedef struct _native_window_raw_t {
|
||||||
@ -36,13 +37,31 @@ static ret_t native_window_raw_move(native_window_t* win, xy_t x, xy_t y) {
|
|||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ret_t native_window_raw_resize(native_window_t* win, wh_t w, wh_t h) {
|
static ret_t native_window_raw_on_resized_timer(const timer_info_t* info) {
|
||||||
native_window_raw_t* raw = NATIVE_WINDOW_RAW(win);
|
widget_t* wm = window_manager();
|
||||||
lcd_t* lcd = raw->canvas.lcd;
|
native_window_t* win = NATIVE_WINDOW(info->ctx);
|
||||||
|
event_t e = event_init(EVT_NATIVE_WINDOW_RESIZED, NULL);
|
||||||
|
window_manager_dispatch_native_window_event(window_manager(), &e, win);
|
||||||
|
widget_set_need_relayout_children(wm);
|
||||||
|
widget_invalidate_force(wm, NULL);
|
||||||
|
|
||||||
if (lcd != NULL && lcd->resize != NULL) {
|
log_debug("on_resized_idle\n");
|
||||||
ret_t ret = lcd_resize(lcd, w, h, 0);
|
return RET_REMOVE;
|
||||||
return_value_if_fail(ret != RET_OK, ret);
|
}
|
||||||
|
|
||||||
|
static ret_t native_window_raw_resize(native_window_t* win, wh_t w, wh_t h) {
|
||||||
|
ret_t ret = RET_OK;
|
||||||
|
native_window_info_t info;
|
||||||
|
native_window_get_info(win, &info);
|
||||||
|
|
||||||
|
if (system_info()->lcd_orientation == LCD_ORIENTATION_0 && (w != info.w || h != info.h)) {
|
||||||
|
native_window_raw_t* raw = NATIVE_WINDOW_RAW(win);
|
||||||
|
|
||||||
|
ret = lcd_resize(raw->canvas.lcd, w, h, 0);
|
||||||
|
return_value_if_fail(ret == RET_OK, ret);
|
||||||
|
system_info_set_lcd_w(system_info(), w);
|
||||||
|
system_info_set_lcd_h(system_info(), h);
|
||||||
|
timer_add(native_window_raw_on_resized_timer, win, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
win->rect.w = w;
|
win->rect.w = w;
|
||||||
@ -58,13 +77,13 @@ static canvas_t* native_window_raw_get_canvas(native_window_t* win) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static ret_t native_window_raw_get_info(native_window_t* win, native_window_info_t* info) {
|
static ret_t native_window_raw_get_info(native_window_t* win, native_window_info_t* info) {
|
||||||
native_window_raw_t* raw = NATIVE_WINDOW_RAW(win);
|
system_info_t* s_info = system_info();
|
||||||
|
|
||||||
info->x = 0;
|
info->x = 0;
|
||||||
info->y = 0;
|
info->y = 0;
|
||||||
info->ratio = raw->canvas.lcd->ratio;
|
info->w = s_info->lcd_w;
|
||||||
info->w = lcd_get_width(raw->canvas.lcd);
|
info->h = s_info->lcd_h;
|
||||||
info->h = lcd_get_height(raw->canvas.lcd);
|
win->ratio = info->ratio = s_info->device_pixel_ratio;
|
||||||
|
|
||||||
log_debug("ratio=%f %d %d\n", info->ratio, info->w, info->h);
|
log_debug("ratio=%f %d %d\n", info->ratio, info->w, info->h);
|
||||||
|
|
||||||
|
@ -78,6 +78,7 @@ static ret_t native_window_sdl_move(native_window_t* win, xy_t x, xy_t y) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static ret_t native_window_sdl_resize(native_window_t* win, wh_t w, wh_t h) {
|
static ret_t native_window_sdl_resize(native_window_t* win, wh_t w, wh_t h) {
|
||||||
|
ret_t ret = RET_OK;
|
||||||
native_window_info_t info;
|
native_window_info_t info;
|
||||||
native_window_sdl_t* sdl = NATIVE_WINDOW_SDL(win);
|
native_window_sdl_t* sdl = NATIVE_WINDOW_SDL(win);
|
||||||
|
|
||||||
@ -88,16 +89,19 @@ static ret_t native_window_sdl_resize(native_window_t* win, wh_t w, wh_t h) {
|
|||||||
|
|
||||||
#if !defined(ANDROID) && !defined(IOS)
|
#if !defined(ANDROID) && !defined(IOS)
|
||||||
if (system_info()->lcd_orientation == LCD_ORIENTATION_0 && (w != info.w || h != info.h)) {
|
if (system_info()->lcd_orientation == LCD_ORIENTATION_0 && (w != info.w || h != info.h)) {
|
||||||
|
lcd_t* lcd = sdl->canvas.lcd;
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
w = w * win->ratio;
|
w = w * win->ratio;
|
||||||
h = h * win->ratio;
|
h = h * win->ratio;
|
||||||
#endif /*WIN32*/
|
#endif /*WIN32*/
|
||||||
|
|
||||||
SDL_SetWindowSize(sdl->window, w, h);
|
SDL_SetWindowSize(sdl->window, w, h);
|
||||||
|
|
||||||
|
ret = lcd_resize(lcd, w, h, 0);
|
||||||
}
|
}
|
||||||
#endif /*ANDROID*/
|
#endif /*ANDROID*/
|
||||||
|
|
||||||
return RET_OK;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ret_t native_window_sdl_minimize(native_window_t* win) {
|
static ret_t native_window_sdl_minimize(native_window_t* win) {
|
||||||
|
@ -1226,13 +1226,15 @@ static ret_t window_manager_default_layout_child(widget_t* widget, widget_t* win
|
|||||||
}
|
}
|
||||||
|
|
||||||
static ret_t window_manager_default_resize(widget_t* widget, wh_t w, wh_t h) {
|
static ret_t window_manager_default_resize(widget_t* widget, wh_t w, wh_t h) {
|
||||||
|
ret_t ret = RET_OK;
|
||||||
rect_t r = rect_init(0, 0, w, h);
|
rect_t r = rect_init(0, 0, w, h);
|
||||||
window_manager_default_t* wm = WINDOW_MANAGER_DEFAULT(widget);
|
window_manager_default_t* wm = WINDOW_MANAGER_DEFAULT(widget);
|
||||||
return_value_if_fail(wm != NULL, RET_BAD_PARAMS);
|
return_value_if_fail(wm != NULL, RET_BAD_PARAMS);
|
||||||
|
|
||||||
widget_move_resize(widget, 0, 0, w, h);
|
ret = native_window_resize(wm->native_window, w, h, TRUE);
|
||||||
|
return_value_if_fail(ret == RET_OK, ret);
|
||||||
|
|
||||||
native_window_resize(wm->native_window, w, h, TRUE);
|
widget_move_resize(widget, 0, 0, w, h);
|
||||||
native_window_invalidate(wm->native_window, &r);
|
native_window_invalidate(wm->native_window, &r);
|
||||||
native_window_update_last_dirty_rect(wm->native_window);
|
native_window_update_last_dirty_rect(wm->native_window);
|
||||||
|
|
||||||
@ -1366,7 +1368,6 @@ static ret_t window_manager_default_native_window_resized(widget_t* widget, void
|
|||||||
h = w;
|
h = w;
|
||||||
}
|
}
|
||||||
|
|
||||||
native_window_on_resized(nw, w, h);
|
|
||||||
if (widget->w == w && widget->h == h) {
|
if (widget->w == w && widget->h == h) {
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
@ -500,7 +500,6 @@ static ret_t window_manager_native_native_window_resized(widget_t* widget, void*
|
|||||||
}
|
}
|
||||||
|
|
||||||
window_manager_simple_resize(widget, w, h);
|
window_manager_simple_resize(widget, w, h);
|
||||||
native_window_on_resized(nw, w, h);
|
|
||||||
|
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user