mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-29 18:48:09 +08:00
merge screen rotate patch
This commit is contained in:
parent
608aaab917
commit
38c0cca6cc
@ -1,4 +1,7 @@
|
||||
# 最新动态
|
||||
* 2019/10/11
|
||||
* 合并君正提供的屏幕旋转补丁(感谢君正提供补丁,感谢智明在各个平台验证)。
|
||||
|
||||
* 2019/10/10
|
||||
* 修改canvas draw image repeatx/repeaty的问题(感谢俊杰提供补丁)。
|
||||
* canvas增加repeat\_y\_inverse图片绘制方式。
|
||||
|
@ -304,9 +304,6 @@ ret_t tk_set_lcd_orientation(lcd_orientation_t orientation) {
|
||||
main_loop_t* loop = main_loop();
|
||||
system_info_t* info = system_info();
|
||||
return_value_if_fail(loop != NULL && info != NULL, RET_OK);
|
||||
assert(orientation == LCD_ORIENTATION_90 || orientation == LCD_ORIENTATION_0);
|
||||
return_value_if_fail(orientation == LCD_ORIENTATION_90 || orientation == LCD_ORIENTATION_0,
|
||||
RET_NOT_IMPL);
|
||||
|
||||
if (info->lcd_orientation != orientation) {
|
||||
orientation_event_t e;
|
||||
|
@ -80,6 +80,16 @@ ret_t pointer_event_rotate(pointer_event_t* evt, system_info_t* info) {
|
||||
evt->x = info->lcd_h - y - 1;
|
||||
break;
|
||||
}
|
||||
case LCD_ORIENTATION_180: {
|
||||
evt->y = info->lcd_h - y - 1;
|
||||
evt->x = info->lcd_w - x - 1;
|
||||
break;
|
||||
}
|
||||
case LCD_ORIENTATION_270: {
|
||||
evt->y = info->lcd_w - x - 1;
|
||||
evt->x = y;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -12,26 +12,79 @@ static ret_t rotate_image(bitmap_t* dst, bitmap_t* src, rect_t* src_r, lcd_orien
|
||||
uint32_t dst_line_length = bitmap_get_line_length(dst);
|
||||
uint32_t src_line_length = bitmap_get_line_length(src);
|
||||
|
||||
dx = src_r->y;
|
||||
dy = src->w - src_r->x - src_r->w;
|
||||
switch (o) {
|
||||
case LCD_ORIENTATION_90: {
|
||||
dx = src_r->y;
|
||||
dy = src->w - src_r->x - src_r->w;
|
||||
break;
|
||||
}
|
||||
case LCD_ORIENTATION_180: {
|
||||
dy = src->h - src_r->y - 1;
|
||||
dx = src->w - src_r->x - 1;
|
||||
break;
|
||||
}
|
||||
case LCD_ORIENTATION_270: {
|
||||
dx = src->h - src_r->y;
|
||||
dy = src_r->x;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
dst_p = (pixel_dst_t*)(dst->data + dy * dst_line_length + dx * fb_bpp);
|
||||
src_p = (pixel_dst_t*)(src->data + src_r->y * src_line_length + src_r->x * img_bpp);
|
||||
|
||||
w = src_r->w;
|
||||
h = src_r->h;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
pixel_dst_t* s = src_p + w - 1;
|
||||
pixel_dst_t* d = dst_p;
|
||||
switch (o) {
|
||||
case LCD_ORIENTATION_90:{
|
||||
for (i = 0; i < h; i++) {
|
||||
pixel_dst_t* s = src_p + w - 1;
|
||||
pixel_dst_t* d = dst_p;
|
||||
|
||||
for (k = 0; k < w; k++) {
|
||||
*d = *s--;
|
||||
d = (pixel_dst_t*)(((char*)d) + dst_line_length);
|
||||
for (k = 0; k < w; k++) {
|
||||
*d = *s--;
|
||||
d = (pixel_dst_t*)(((char*)d) + dst_line_length);
|
||||
}
|
||||
|
||||
dst_p++;
|
||||
src_p = (pixel_dst_t*)(((char*)src_p) + src_line_length);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LCD_ORIENTATION_180: {
|
||||
for (i = 0; i < h; i++) {
|
||||
pixel_dst_t* s = src_p;
|
||||
pixel_dst_t* d = dst_p;
|
||||
|
||||
for (k = 0; k < w; k++) {
|
||||
*d = *s++;
|
||||
d--;
|
||||
}
|
||||
dst_p = (pixel_dst_t*)(((char*)dst_p) - dst_line_length);
|
||||
src_p = (pixel_dst_t*)(((char*)src_p) + src_line_length);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LCD_ORIENTATION_270: {
|
||||
for (i = 0; i < h; i++) {
|
||||
pixel_dst_t* s = src_p;
|
||||
pixel_dst_t* d = dst_p;
|
||||
|
||||
for (k = 0; k < w; k++) {
|
||||
*d = *s++;
|
||||
d = (pixel_dst_t*)(((char*)d) + dst_line_length);
|
||||
}
|
||||
|
||||
dst_p--;
|
||||
src_p = (pixel_dst_t*)(((char*)src_p) + src_line_length);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
dst_p++;
|
||||
src_p = (pixel_dst_t*)(((char*)src_p) + src_line_length);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
@ -153,10 +153,8 @@ ret_t soft_fill_rect(bitmap_t* dst, rect_t* dst_r, color_t c) {
|
||||
}
|
||||
|
||||
ret_t soft_rotate_image(bitmap_t* dst, bitmap_t* src, rect_t* src_r, lcd_orientation_t o) {
|
||||
return_value_if_fail(o == LCD_ORIENTATION_90, RET_NOT_IMPL);
|
||||
return_value_if_fail(dst != NULL && src != NULL && src_r != NULL, RET_BAD_PARAMS);
|
||||
return_value_if_fail(dst->format == src->format, RET_BAD_PARAMS);
|
||||
return_value_if_fail(dst->w == src->h && dst->h == src->w, RET_BAD_PARAMS);
|
||||
|
||||
switch (dst->format) {
|
||||
case BITMAP_FMT_RGB565: {
|
||||
|
@ -34,12 +34,6 @@ 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 !defined(LINUX)
|
||||
if (lcd->draw_mode == LCD_DRAW_ANIMATION && mem->online_fb && !lcd_is_swappable(lcd)) {
|
||||
fbuff = mem->online_fb;
|
||||
}
|
||||
#endif /*LINUX*/
|
||||
|
||||
if (fb != NULL) {
|
||||
bitmap_init(fb, lcd->w, lcd->h, mem->format, fbuff);
|
||||
bitmap_set_line_length(fb, lcd_mem_get_line_length(mem));
|
||||
@ -204,36 +198,15 @@ static ret_t lcd_mem_draw_image_matrix(lcd_t* lcd, draw_image_info_t* info) {
|
||||
static ret_t lcd_mem_draw_image(lcd_t* lcd, bitmap_t* img, rect_t* src, rect_t* dst) {
|
||||
bitmap_t fb;
|
||||
ret_t ret = RET_OK;
|
||||
system_info_t* info = system_info();
|
||||
lcd_orientation_t o = info->lcd_orientation;
|
||||
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) {
|
||||
rect_t r;
|
||||
xy_t dx = 0;
|
||||
xy_t dy = 0;
|
||||
|
||||
if (o == LCD_ORIENTATION_90 && lcd->draw_mode == LCD_DRAW_ANIMATION) {
|
||||
fb.w = lcd->h;
|
||||
fb.h = lcd->w;
|
||||
fb.line_length = fb.w * bitmap_get_bpp_of_format(LCD_FORMAT);
|
||||
|
||||
r.w = src->h;
|
||||
r.h = src->w;
|
||||
r.x = src->y;
|
||||
r.y = img->h - src->x - src->w;
|
||||
|
||||
dx = dst->y;
|
||||
dy = fb.h - dst->x - dst->w;
|
||||
} else {
|
||||
r = *src;
|
||||
dx = dst->x;
|
||||
dy = dst->y;
|
||||
}
|
||||
|
||||
rect_t r = *src;
|
||||
xy_t dx = dst->x;
|
||||
xy_t dy = dst->y;
|
||||
ret = image_copy(&fb, img, &r, dx, dy);
|
||||
} else {
|
||||
ret = image_blend(&fb, img, dst, src, lcd->global_alpha);
|
||||
@ -262,24 +235,14 @@ static vgcanvas_t* lcd_mem_get_vgcanvas(lcd_t* lcd) {
|
||||
|
||||
static ret_t lcd_mem_take_snapshot(lcd_t* lcd, bitmap_t* img, bool_t auto_rotate) {
|
||||
bitmap_t fb;
|
||||
lcd_orientation_t orientation = system_info()->lcd_orientation;
|
||||
|
||||
lcd_mem_init_drawing_fb(lcd, &fb);
|
||||
if (auto_rotate && orientation == LCD_ORIENTATION_90) {
|
||||
rect_t r = rect_init(0, 0, fb.w, fb.h);
|
||||
return_value_if_fail(bitmap_init(img, fb.h, fb.w, (bitmap_format_t)(fb.format), NULL) == RET_OK,
|
||||
RET_OOM);
|
||||
|
||||
img->flags = BITMAP_FLAG_OPAQUE;
|
||||
return image_rotate(img, &fb, &r, orientation);
|
||||
} else {
|
||||
rect_t r = rect_init(0, 0, fb.w, fb.h);
|
||||
return_value_if_fail(bitmap_init(img, fb.w, fb.h, (bitmap_format_t)(fb.format), NULL) == RET_OK,
|
||||
RET_OOM);
|
||||
rect_t r = rect_init(0, 0, fb.w, fb.h);
|
||||
return_value_if_fail(bitmap_init(img, fb.w, fb.h, (bitmap_format_t)(fb.format), NULL) == RET_OK,
|
||||
RET_OOM);
|
||||
|
||||
img->flags = BITMAP_FLAG_OPAQUE;
|
||||
return image_copy(img, &fb, &r, 0, 0);
|
||||
}
|
||||
img->flags = BITMAP_FLAG_OPAQUE;
|
||||
return image_copy(img, &fb, &r, 0, 0);
|
||||
}
|
||||
|
||||
static ret_t lcd_mem_flush(lcd_t* lcd) {
|
||||
@ -289,9 +252,6 @@ static ret_t lcd_mem_flush(lcd_t* lcd) {
|
||||
system_info_t* info = system_info();
|
||||
lcd_orientation_t o = info->lcd_orientation;
|
||||
|
||||
assert(o == LCD_ORIENTATION_0 || o == LCD_ORIENTATION_90);
|
||||
return_value_if_fail(o == LCD_ORIENTATION_0 || o == LCD_ORIENTATION_90, RET_NOT_IMPL);
|
||||
|
||||
lcd_mem_init_drawing_fb(lcd, &offline_fb);
|
||||
lcd_mem_init_online_fb(lcd, &online_fb, o);
|
||||
|
||||
@ -310,11 +270,6 @@ static ret_t lcd_mem_end_frame(lcd_t* lcd) {
|
||||
if (lcd_is_swappable(lcd)) {
|
||||
lcd_swap(lcd);
|
||||
} else {
|
||||
#if !defined(LINUX)
|
||||
if (lcd->draw_mode == LCD_DRAW_ANIMATION) {
|
||||
return RET_OK;
|
||||
}
|
||||
#endif /*LINUX*/
|
||||
lcd_flush(lcd);
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,8 @@ static ret_t native_window_raw_move(native_window_t* win, xy_t x, xy_t y) {
|
||||
}
|
||||
|
||||
static ret_t native_window_raw_resize(native_window_t* win, wh_t w, wh_t h) {
|
||||
win->rect.w = w;
|
||||
win->rect.h = h;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
@ -180,9 +180,7 @@ static ret_t window_animator_paint_system_bar(window_animator_t* wa) {
|
||||
rect_t dst = rect_init(system_bar->x, system_bar->y, system_bar->w, system_bar->h);
|
||||
canvas_draw_image(wa->canvas, &(wa->prev_img), rect_scale(&src, wa->ratio), &dst);
|
||||
#else
|
||||
if (!(wa->canvas->lcd->support_dirty_rect)) {
|
||||
widget_paint(system_bar, wa->canvas);
|
||||
}
|
||||
widget_paint(system_bar, wa->canvas);
|
||||
#endif /*AWTK_WEB*/
|
||||
}
|
||||
|
||||
|
@ -840,8 +840,8 @@ static ret_t window_manager_default_on_event(widget_t* widget, event_t* e) {
|
||||
wh_t w = wm->lcd_w;
|
||||
wh_t h = wm->lcd_h;
|
||||
if (orientation == LCD_ORIENTATION_90 || orientation == LCD_ORIENTATION_270) {
|
||||
w = wm->lcd_w;
|
||||
h = wm->lcd_h;
|
||||
w = wm->lcd_h;
|
||||
h = wm->lcd_w;
|
||||
}
|
||||
|
||||
lcd_resize(lcd, w, h, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user