diff --git a/3rd/agge/agge/pixel.h b/3rd/agge/agge/pixel.h index 034828ca4..8ef4a91fc 100644 --- a/3rd/agge/agge/pixel.h +++ b/3rd/agge/agge/pixel.h @@ -205,17 +205,38 @@ inline void pixel_blend(pixel24_rgb& t, const pixel32_rgba& s, uint8_t a) { } } +static inline uint8_t pixel_limit_uint8(int tmp) { + if(tmp > 0xff) { + tmp = 0xff; + } else if(tmp < 0) { + tmp = 0; + } + return (uint8_t)tmp; +} + template <> inline void pixel_blend(pixel32_rgba& t, const pixel32_rgba& s, uint8_t a) { if (a > 0xf4) { t.r = s.r; t.g = s.g; - t.b = s.b; + t.b = s.b; + t.a = a; } else if (a > 0x01) { uint8_t m_a = 0xff - a; - t.r = (s.r * a + t.r * m_a) >> 8; - t.g = (s.g * a + t.g * m_a) >> 8; - t.b = (s.b * a + t.b * m_a) >> 8; + if(t.a > 0xf4) { + t.r = (s.r * a + t.r * m_a) >> 8; + t.g = (s.g * a + t.g * m_a) >> 8; + t.b = (s.b * a + t.b * m_a) >> 8; + } else { + uint8_t out_a = pixel_limit_uint8(a + t.a - ((a * t.a) >> 8)); + if(out_a > 0) { + uint8_t d_a = (t.a * (0xff - a)) >> 8; + t.r = (s.r * a + t.r * d_a) / out_a; + t.g = (s.g * a + t.g * d_a) / out_a; + t.b = (s.b * a + t.b * d_a) / out_a; + } + t.a = out_a; + } } } @@ -225,11 +246,23 @@ inline void pixel_blend(pixel32_bgra& t, const pixel32_rgba& s, uint8_t a) { t.r = s.r; t.g = s.g; t.b = s.b; + t.a = a; } else if (a > 0x01) { - uint8_t m_a = 0xff - a; - t.r = (s.r * a + t.r * m_a) >> 8; - t.g = (s.g * a + t.g * m_a) >> 8; - t.b = (s.b * a + t.b * m_a) >> 8; + if(t.a > 0xf4) { + uint8_t m_a = 0xff - a; + t.r = (s.r * a + t.r * m_a) >> 8; + t.g = (s.g * a + t.g * m_a) >> 8; + t.b = (s.b * a + t.b * m_a) >> 8; + } else { + uint8_t out_a = pixel_limit_uint8(a + t.a - ((a * t.a) >> 8)); + if(out_a > 0) { + uint8_t d_a = (t.a * (0xff - a)) >> 8; + t.r = (s.r * a + t.r * d_a) / out_a; + t.g = (s.g * a + t.g * d_a) / out_a; + t.b = (s.b * a + t.b * d_a) / out_a; + } + t.a = out_a; + } } } diff --git a/docs/changes.md b/docs/changes.md index b0e9fe44c..a06022c38 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -3,7 +3,8 @@ * 增加事件录制与重放功能,辅助手动测试和压力测试。 * 完善 text edit(感谢大恒提供补丁)。 * 完善 system settings 和 release 脚本(感谢俊杰提供补丁)。 - + * 支持硬件多层合并(GUI + Camera)(感谢尧燊提供补丁)。 + * 2020/05/14 * 修复 clip view 中 type 的问题(感谢尧燊提供补丁)。 * 修复 file browser up 中的问题(感谢瑞安提供补丁)。 diff --git a/src/base/dialog_highlighter.c b/src/base/dialog_highlighter.c index d4021f19a..08e13c274 100644 --- a/src/base/dialog_highlighter.c +++ b/src/base/dialog_highlighter.c @@ -76,6 +76,14 @@ ret_t dialog_highlighter_set_bg(dialog_highlighter_t* h, bitmap_t* img, framebuf return RET_OK; } +ret_t dialog_highlighter_set_bg_clip_rect(dialog_highlighter_t* h, rect_t* clip_rect) { + return_value_if_fail(h != NULL && h->vt != NULL, RET_BAD_PARAMS); + + h->clip_rect = rect_init(clip_rect->x, clip_rect->y, clip_rect->w, clip_rect->h); + + return RET_OK; +} + ret_t dialog_highlighter_draw(dialog_highlighter_t* h, float_t percent) { return_value_if_fail(h != NULL && h->vt != NULL, RET_BAD_PARAMS); diff --git a/src/base/dialog_highlighter.h b/src/base/dialog_highlighter.h index 52ad1cd69..045b92418 100644 --- a/src/base/dialog_highlighter.h +++ b/src/base/dialog_highlighter.h @@ -86,6 +86,12 @@ struct _dialog_highlighter_t { */ widget_t* dialog; + /** + * @property {rect_t*} clip_rect + * 截图的显示裁减区 + */ + rect_t clip_rect; + /*private*/ framebuffer_object_t fbo; const dialog_highlighter_vtable_t* vt; @@ -113,6 +119,16 @@ dialog_highlighter_t* dialog_highlighter_create(const dialog_highlighter_vtable_ */ ret_t dialog_highlighter_set_bg(dialog_highlighter_t* h, bitmap_t* img, framebuffer_object_t* fbo); +/** + * @method dialog_highlighter_set_bg_clip_rect + * 设置背景图片的显示裁减区。 + * @param {dialog_highlighter_t*} h 对话框高亮策略对象。 + * @param {rect_t*} clip_rect 背景显示裁减区。 + * + * @return {ret_t} 返回RET_OK表示成功,否则表示失败。 + */ +ret_t dialog_highlighter_set_bg_clip_rect(dialog_highlighter_t* h, rect_t* clip_rect); + /** * @method dialog_highlighter_prepare * 初始化。在绘制完背景,在截图前调用。 diff --git a/src/base/pixel.h b/src/base/pixel.h index 1ef97bd04..4c4ee3b84 100644 --- a/src/base/pixel.h +++ b/src/base/pixel.h @@ -24,6 +24,16 @@ #include "tkc/color.h" +static inline uint8_t tk_pixel_limit_uint8(int32_t tmp) { + if(tmp > 0xff) { + tmp = 0xff; + } else if(tmp < 0) { + tmp = 0; + } + return (uint8_t)tmp; +} + + #pragma pack(push, 1) typedef struct _pixel_rgb565_t { uint16_t r : 5; @@ -36,8 +46,18 @@ typedef struct _pixel_rgb565_t { #define pixel_rgb565_format BITMAP_FMT_RGB565 #define pixel_rgb565_to_rgba(p) \ { p.r << 3, p.g << 2, p.b << 3, 0xff } + #define pixel_rgb565_from_rgb(r, g, b) \ { r >> 3, g >> 2, b >> 3 } + +#if WITH_LCD_CLEAR_ALPHA +#define pixel_rgb565_from_rgba(r, g, b, a) \ + { (r * a) >> 11, (g * a) >> 10, (b * a) >> 11 } +#else +#define pixel_rgb565_from_rgba(r, g, b, a) \ + pixel_rgb565_from_rgb(r, g, b) +#endif + static inline void pixel_rgb565_blend_rgba_dark(void* p, uint8_t a) { uint16_t v = *(uint16_t*)p; @@ -65,9 +85,18 @@ typedef struct _pixel_bgr565_t { #define pixel_bgr565_format BITMAP_FMT_BGR565 #define pixel_bgr565_to_rgba(p) \ { p.r << 3, p.g << 2, p.b << 3, 0xff } + #define pixel_bgr565_from_rgb(r, g, b) \ { b >> 3, g >> 2, r >> 3 } +#if WITH_LCD_CLEAR_ALPHA +#define pixel_bgr565_from_rgba(r, g, b, a) \ + { (b * a) >> 11, (g * a) >> 10, (r * a) >> 11 } +#else +#define pixel_bgr565_from_rgba(r, g, b, a) \ + pixel_bgr565_from_rgb(r, g, b) +#endif + static inline void pixel_bgr565_blend_rgba_dark(void* p, uint8_t a) { uint16_t v = *(uint16_t*)p; @@ -105,9 +134,18 @@ typedef struct _pixel_rgb888_t { #define pixel_rgb888_format BITMAP_FMT_RGB888 #define pixel_rgb888_to_rgba(p) \ { p.r, p.g, p.b, 0xff } + #define pixel_rgb888_from_rgb(r, g, b) \ { r, g, b } +#if WITH_LCD_CLEAR_ALPHA +#define pixel_rgb888_from_rgba(r, g, b, a) \ + { (r * a) >> 8, (g * a) >> 8, (b * a) >> 8 } +#else +#define pixel_rgb888_from_rgba(r, g, b, a) \ + pixel_rgb888_from_rgb(r, g, b) +#endif + static inline void pixel_rgb888_blend_rgba_dark(void* pixel, uint8_t a) { uint8_t* p = (uint8_t*)pixel; @@ -136,8 +174,17 @@ typedef struct _pixel_bgr888_t { #define pixel_bgr888_format BITMAP_FMT_BGR888 #define pixel_bgr888_to_rgba(p) \ { p.r, p.g, p.b, 0xff } + #define pixel_bgr888_from_rgb(r, g, b) \ { b, g, r } +#if WITH_LCD_CLEAR_ALPHA +#define pixel_bgr888_from_rgba(r, g, b, a) \ + { (b * a) >> 8, (g * a) >> 8, (r * a) >> 8 } +#else +#define pixel_bgr888_from_rgba(r, g, b, a) \ + pixel_bgr888_from_rgb(r, g, b); +#endif + static inline void pixel_bgr888_blend_rgba_dark(void* pixel, uint8_t a) { uint8_t* p = (uint8_t*)pixel; @@ -174,20 +221,44 @@ typedef struct _pixel_rgba8888_t { static inline void pixel_rgba8888_blend_rgba_dark(void* pixel, uint8_t a) { uint8_t* p = (uint8_t*)pixel; - p[0] = (p[0] * a) >> 8; - p[1] = (p[1] * a) >> 8; - p[2] = (p[2] * a) >> 8; - p[3] = 0xff; + if(p[3] > 0xf4) { + p[0] = (p[0] * a) >> 8; + p[1] = (p[1] * a) >> 8; + p[2] = (p[2] * a) >> 8; + p[3] = 0xff; + } else { + uint8_t out_a = tk_pixel_limit_uint8(p[3] + a - ((p[3] * a) >> 8)); + + if(out_a > 0) { + uint8_t d_a = (p[3] * (0xff - a)) >> 8; + p[0] = (p[0] * d_a) / out_a; + p[1] = (p[1] * d_a) / out_a; + p[2] = (p[2] * d_a) / out_a; + } + p[3] = out_a; + } } static inline void pixel_rgba8888_blend_rgba_premulti(void* pixel, rgba_t rgba) { uint8_t a = rgba.a; uint8_t* p = (uint8_t*)pixel; - p[0] = ((p[0] * a) >> 8) + rgba.r; - p[1] = ((p[1] * a) >> 8) + rgba.g; - p[2] = ((p[2] * a) >> 8) + rgba.b; - p[3] = 0xff; + if(p[3] > 0xf4) { + p[0] = ((p[0] * a) >> 8) + rgba.r; + p[1] = ((p[1] * a) >> 8) + rgba.g; + p[2] = ((p[2] * a) >> 8) + rgba.b; + p[3] = 0xff; + } else { + uint8_t s_a = 0xff - a; + uint8_t out_a = tk_pixel_limit_uint8(p[3] + s_a - ((p[3] * s_a) >> 8)); + if(out_a > 0) { + uint8_t d_a = (p[3] * (0xff - rgba.a)) >> 8; + p[0] = (p[0] * d_a + (rgba.r << 8)) / out_a; + p[1] = (p[1] * d_a + (rgba.g << 8)) / out_a; + p[2] = (p[2] * d_a + (rgba.b << 8)) / out_a; + } + p[3] = out_a; + } } typedef struct _pixel_abgr8888_t { @@ -208,19 +279,45 @@ typedef struct _pixel_abgr8888_t { { a, b, g, r } static inline void pixel_abgr8888_blend_rgba_dark(void* pixel, uint8_t a) { uint8_t* p = (uint8_t*)pixel; - p[0] = 0xff; - p[1] = (p[1] * a) >> 8; - p[2] = (p[2] * a) >> 8; - p[3] = (p[3] * a) >> 8; + + if(p[3] > 0xf4) { + p[0] = 0xff; + p[1] = (p[1] * a) >> 8; + p[2] = (p[2] * a) >> 8; + p[3] = (p[3] * a) >> 8; + } else { + uint8_t s_a = 0xff - a; + uint8_t out_a = tk_pixel_limit_uint8(p[0] + s_a - ((p[0] * s_a) >> 8)); + if(out_a > 0) { + uint8_t d_a = (p[0] * (0xff - a)) >> 8; + p[1] = (p[1] * d_a) / out_a; + p[2] = (p[2] * d_a) / out_a; + p[3] = (p[3] * d_a) / out_a; + } + p[0] = out_a; + } } static inline void pixel_abgr8888_blend_rgba_premulti(void* pixel, rgba_t rgba) { uint8_t a = rgba.a; uint8_t* p = (uint8_t*)pixel; - p[0] = 0xff; - p[1] = ((p[1] * a) >> 8) + rgba.b; - p[2] = ((p[2] * a) >> 8) + rgba.g; - p[3] = ((p[3] * a) >> 8) + rgba.r; + + if(p[3] > 0xf4) { + p[0] = 0xff; + p[1] = ((p[1] * a) >> 8) + rgba.b; + p[2] = ((p[2] * a) >> 8) + rgba.g; + p[3] = ((p[3] * a) >> 8) + rgba.r; + } else { + uint8_t s_a = 0xff - a; + uint8_t out_a = tk_pixel_limit_uint8(p[0] + s_a - ((p[0] * s_a) >> 8)); + if(out_a > 0) { + uint8_t d_a = (p[0] * (0xff - rgba.a)) >> 8; + p[1] = (p[1] * d_a + (rgba.b << 8)) / out_a; + p[2] = (p[2] * d_a + (rgba.g << 8)) / out_a; + p[3] = (p[3] * d_a + (rgba.r << 8)) / out_a; + } + p[0] = out_a; + } } typedef struct _pixel_bgra8888_t { @@ -242,20 +339,44 @@ typedef struct _pixel_bgra8888_t { static inline void pixel_bgra8888_blend_rgba_dark(void* pixel, uint8_t a) { uint8_t* p = (uint8_t*)pixel; - p[0] = (p[0] * a) >> 8; - p[1] = (p[1] * a) >> 8; - p[2] = (p[2] * a) >> 8; - p[3] = 0xff; + if(p[3] > 0xf4) { + p[0] = (p[0] * a) >> 8; + p[1] = (p[1] * a) >> 8; + p[2] = (p[2] * a) >> 8; + p[3] = 0xff; + } else { + uint8_t s_a = 0xff - a; + uint8_t out_a = tk_pixel_limit_uint8(p[3] + s_a - ((p[3] * s_a) >> 8)); + if(out_a > 0) { + uint8_t d_a = (p[3] * (0xff - a)) >> 8; + p[0] = (p[0] * d_a) / out_a; + p[1] = (p[1] * d_a) / out_a; + p[2] = (p[2] * d_a) / out_a; + } + p[3] = out_a; + } } static inline void pixel_bgra8888_blend_rgba_premulti(void* pixel, rgba_t rgba) { uint8_t a = rgba.a; uint8_t* p = (uint8_t*)pixel; - p[0] = ((p[0] * a) >> 8) + rgba.b; - p[1] = ((p[1] * a) >> 8) + rgba.g; - p[2] = ((p[2] * a) >> 8) + rgba.r; - p[3] = 0xff; + if(p[3] > 0xf4) { + p[0] = ((p[0] * a) >> 8) + rgba.b; + p[1] = ((p[1] * a) >> 8) + rgba.g; + p[2] = ((p[2] * a) >> 8) + rgba.r; + p[3] = 0xff; + } else { + uint8_t s_a = 0xff - a; + uint8_t out_a = tk_pixel_limit_uint8(p[3] + s_a - ((p[3] * s_a) >> 8)); + if(out_a > 0) { + uint8_t d_a = (p[3] * (0xff - rgba.a)) >> 8; + p[0] = (p[0] * d_a + (rgba.b << 8)) / out_a; + p[1] = (p[1] * d_a + (rgba.g << 8)) / out_a; + p[2] = (p[2] * d_a + (rgba.r << 8)) / out_a; + } + p[3] = out_a; + } } typedef struct _pixel_argb8888_t { @@ -276,19 +397,45 @@ typedef struct _pixel_argb8888_t { { 0xff, r, g, b } static inline void pixel_argb8888_blend_rgba_dark(void* pixel, uint8_t a) { uint8_t* p = (uint8_t*)pixel; - p[0] = 0xff; - p[1] = (p[1] * a) >> 8; - p[2] = (p[2] * a) >> 8; - p[3] = (p[3] * a) >> 8; + + if(p[3] > 0xf4) { + p[0] = 0xff; + p[1] = (p[1] * a) >> 8; + p[2] = (p[2] * a) >> 8; + p[3] = (p[3] * a) >> 8; + } else { + uint8_t s_a = 0xff - a; + uint8_t out_a = tk_pixel_limit_uint8(p[0] + s_a - ((p[0] *s_a) >> 8)); + if(out_a > 0) { + uint8_t d_a = (p[0] * (0xff - a)) >> 8; + p[1] = (p[1] * d_a) / out_a; + p[2] = (p[2] * d_a) / out_a; + p[3] = (p[3] * d_a) / out_a; + } + p[0] = out_a; + } } static inline void pixel_argb8888_blend_rgba_premulti(void* pixel, rgba_t rgba) { uint8_t a = rgba.a; uint8_t* p = (uint8_t*)pixel; - p[0] = 0xff; - p[1] = ((p[1] * a) >> 8) + rgba.r; - p[2] = ((p[2] * a) >> 8) + rgba.g; - p[3] = ((p[3] * a) >> 8) + rgba.b; + + if(p[3] > 0xf4) { + p[0] = 0xff; + p[1] = ((p[1] * a) >> 8) + rgba.r; + p[2] = ((p[2] * a) >> 8) + rgba.g; + p[3] = ((p[3] * a) >> 8) + rgba.b; + } else { + uint8_t s_a = 0xff - a; + uint8_t out_a = tk_pixel_limit_uint8(p[0] + s_a - ((p[0] * s_a) >> 8)); + if(out_a > 0) { + uint8_t d_a = (p[0] * (0xff - rgba.a)) >> 8; + p[1] = (p[1] * d_a + (rgba.r << 8)) / out_a; + p[2] = (p[2] * d_a + (rgba.g << 8)) / out_a; + p[3] = (p[3] * d_a + (rgba.b << 8)) / out_a; + } + p[0] = out_a; + } } typedef uint8_t pixel_gray_t; diff --git a/src/base/widget.c b/src/base/widget.c index 7512ad8fc..259303263 100644 --- a/src/base/widget.c +++ b/src/base/widget.c @@ -501,7 +501,7 @@ ret_t widget_set_pointer_cursor(widget_t* widget, const char* cursor) { return widget_set_prop_str(wm, WIDGET_PROP_CURSOR, cursor); } -#ifndef WITHOUT_WINDOW_ANIMATORS +#ifndef WITHOUT_WIDGET_ANIMATORS ret_t widget_set_animation(widget_t* widget, const char* animation) { return_value_if_fail(widget != NULL && animation != NULL, RET_BAD_PARAMS); diff --git a/src/blend/blend_image_bgr565_bgr565.c b/src/blend/blend_image_bgr565_bgr565.c index b14428cdd..63259c033 100644 --- a/src/blend/blend_image_bgr565_bgr565.c +++ b/src/blend/blend_image_bgr565_bgr565.c @@ -27,7 +27,8 @@ #define pixel_dst_format pixel_bgr565_format #define pixel_dst_to_rgba pixel_bgr565_to_rgba #define pixel_dst_from_rgb pixel_bgr565_from_rgb -#define pixel_dst_from_rgba(r, g, b, a) pixel_bgr565_from_rgb(r, g, b) +#define pixel_dst_from_rgba pixel_bgr565_from_rgba +//#define pixel_dst_from_rgba(r, g, b, a) pixel_bgr565_from_rgb(r, g, b) #define pixel_src_t pixel_bgr565_t #define pixel_src_format pixel_bgr565_format @@ -35,6 +36,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba static inline void blend_a_bgr565_bgra8888(uint8_t* dst, uint8_t* src, uint8_t a) { diff --git a/src/blend/blend_image_bgr565_bgra8888.c b/src/blend/blend_image_bgr565_bgra8888.c index 1cd1cbb69..8f7bbc854 100644 --- a/src/blend/blend_image_bgr565_bgra8888.c +++ b/src/blend/blend_image_bgr565_bgra8888.c @@ -27,6 +27,7 @@ #define pixel_dst_format pixel_bgr565_format #define pixel_dst_to_rgba pixel_bgr565_to_rgba #define pixel_dst_from_rgb pixel_bgr565_from_rgb +#define pixel_dst_from_rgba pixel_bgr565_from_rgba #define pixel_src_t pixel_bgra8888_t #define pixel_src_format pixel_bgra8888_format @@ -34,6 +35,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba static inline void blend_a_bgr565_bgra8888(uint8_t* dst, uint8_t* src, uint8_t alpha) { diff --git a/src/blend/blend_image_bgr565_rgb565.c b/src/blend/blend_image_bgr565_rgb565.c index c2c00b5e7..357d29089 100755 --- a/src/blend/blend_image_bgr565_rgb565.c +++ b/src/blend/blend_image_bgr565_rgb565.c @@ -27,6 +27,7 @@ #define pixel_dst_format pixel_bgr565_format #define pixel_dst_to_rgba pixel_bgr565_to_rgba #define pixel_dst_from_rgb pixel_bgr565_from_rgb +#define pixel_dst_from_rgba pixel_bgr565_from_rgba #define pixel_src_t pixel_rgb565_t #define pixel_src_format pixel_rgb565_format @@ -34,6 +35,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #include "pixel_ops.inc" diff --git a/src/blend/blend_image_bgr565_rgba8888.c b/src/blend/blend_image_bgr565_rgba8888.c index 63db3c5cf..5f40e0723 100644 --- a/src/blend/blend_image_bgr565_rgba8888.c +++ b/src/blend/blend_image_bgr565_rgba8888.c @@ -27,6 +27,7 @@ #define pixel_dst_format pixel_bgr565_format #define pixel_dst_to_rgba pixel_bgr565_to_rgba #define pixel_dst_from_rgb pixel_bgr565_from_rgb +#define pixel_dst_from_rgba pixel_bgr565_from_rgba #define pixel_src_t pixel_rgba8888_t #define pixel_src_format pixel_rgba8888_format @@ -34,6 +35,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba static inline void blend_a_bgr565_rgba8888(uint8_t* dst, uint8_t* src, uint8_t alpha) { diff --git a/src/blend/blend_image_bgr888_bgr565.c b/src/blend/blend_image_bgr888_bgr565.c index 1b85891e6..7e36195e0 100644 --- a/src/blend/blend_image_bgr888_bgr565.c +++ b/src/blend/blend_image_bgr888_bgr565.c @@ -27,6 +27,7 @@ #define pixel_dst_format pixel_bgr888_format #define pixel_dst_to_rgba pixel_bgr888_to_rgba #define pixel_dst_from_rgb pixel_bgr888_from_rgb +#define pixel_dst_from_rgba pixel_bgr888_from_rgba #define pixel_src_t pixel_bgr565_t #define pixel_src_format pixel_bgr565_format @@ -34,6 +35,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #include "pixel_ops.inc" diff --git a/src/blend/blend_image_bgr888_bgr888.c b/src/blend/blend_image_bgr888_bgr888.c index aebd25585..878e6c132 100755 --- a/src/blend/blend_image_bgr888_bgr888.c +++ b/src/blend/blend_image_bgr888_bgr888.c @@ -27,6 +27,7 @@ #define pixel_dst_format pixel_bgr888_format #define pixel_dst_to_rgba pixel_bgr888_to_rgba #define pixel_dst_from_rgb pixel_bgr888_from_rgb +#define pixel_dst_from_rgba pixel_bgr888_from_rgba #define pixel_src_t pixel_bgr888_t #define pixel_src_format pixel_bgr888_format @@ -34,6 +35,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #include "pixel_ops.inc" diff --git a/src/blend/blend_image_bgr888_bgra8888.c b/src/blend/blend_image_bgr888_bgra8888.c index ef24615b9..14a641e32 100644 --- a/src/blend/blend_image_bgr888_bgra8888.c +++ b/src/blend/blend_image_bgr888_bgra8888.c @@ -27,6 +27,7 @@ #define pixel_dst_format pixel_bgr888_format #define pixel_dst_to_rgba pixel_bgr888_to_rgba #define pixel_dst_from_rgb pixel_bgr888_from_rgb +#define pixel_dst_from_rgba pixel_bgr888_from_rgba #define pixel_src_t pixel_bgra8888_t #define pixel_src_format pixel_bgra8888_format @@ -34,6 +35,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #include "pixel_ops.inc" diff --git a/src/blend/blend_image_bgr888_rgb565.c b/src/blend/blend_image_bgr888_rgb565.c index 76a50c6c8..0c1830ee9 100755 --- a/src/blend/blend_image_bgr888_rgb565.c +++ b/src/blend/blend_image_bgr888_rgb565.c @@ -27,6 +27,7 @@ #define pixel_dst_format pixel_bgr888_format #define pixel_dst_to_rgba pixel_bgr888_to_rgba #define pixel_dst_from_rgb pixel_bgr888_from_rgb +#define pixel_dst_from_rgba pixel_bgr888_from_rgba #define pixel_src_t pixel_rgb565_t #define pixel_src_format pixel_rgb565_format @@ -34,6 +35,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #include "pixel_ops.inc" diff --git a/src/blend/blend_image_bgr888_rgba8888.c b/src/blend/blend_image_bgr888_rgba8888.c index fa2bc15c6..b1f0b260e 100644 --- a/src/blend/blend_image_bgr888_rgba8888.c +++ b/src/blend/blend_image_bgr888_rgba8888.c @@ -27,6 +27,7 @@ #define pixel_dst_format pixel_bgr888_format #define pixel_dst_to_rgba pixel_bgr888_to_rgba #define pixel_dst_from_rgb pixel_bgr888_from_rgb +#define pixel_dst_from_rgba pixel_bgr888_from_rgba #define pixel_src_t pixel_rgba8888_t #define pixel_src_format pixel_rgba8888_format @@ -34,6 +35,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #include "pixel_ops.inc" diff --git a/src/blend/blend_image_bgra8888_bgr565.c b/src/blend/blend_image_bgra8888_bgr565.c index b4f118aef..d27a3ebcb 100644 --- a/src/blend/blend_image_bgra8888_bgr565.c +++ b/src/blend/blend_image_bgra8888_bgr565.c @@ -27,6 +27,7 @@ #define pixel_dst_format pixel_bgra8888_format #define pixel_dst_to_rgba pixel_bgra8888_to_rgba #define pixel_dst_from_rgb pixel_bgra8888_from_rgb +#define pixel_dst_from_rgba pixel_bgra8888_from_rgba #define pixel_src_t pixel_bgr565_t #define pixel_src_format pixel_bgr565_format @@ -34,6 +35,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #include "pixel_ops.inc" diff --git a/src/blend/blend_image_bgra8888_bgra8888.c b/src/blend/blend_image_bgra8888_bgra8888.c index 43f8b79a3..1b1f79dcb 100644 --- a/src/blend/blend_image_bgra8888_bgra8888.c +++ b/src/blend/blend_image_bgra8888_bgra8888.c @@ -27,6 +27,7 @@ #define pixel_dst_format pixel_bgra8888_format #define pixel_dst_to_rgba pixel_bgra8888_to_rgba #define pixel_dst_from_rgb pixel_bgra8888_from_rgb +#define pixel_dst_from_rgba pixel_bgra8888_from_rgba #define pixel_src_t pixel_bgra8888_t #define pixel_src_format pixel_bgra8888_format @@ -34,6 +35,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #include "pixel_ops.inc" diff --git a/src/blend/blend_image_bgra8888_rgb565.c b/src/blend/blend_image_bgra8888_rgb565.c index bd085678d..e09da9d73 100755 --- a/src/blend/blend_image_bgra8888_rgb565.c +++ b/src/blend/blend_image_bgra8888_rgb565.c @@ -27,6 +27,7 @@ #define pixel_dst_format pixel_bgra8888_format #define pixel_dst_to_rgba pixel_bgra8888_to_rgba #define pixel_dst_from_rgb pixel_bgra8888_from_rgb +#define pixel_dst_from_rgba pixel_bgra8888_from_rgba #define pixel_src_t pixel_rgb565_t #define pixel_src_format pixel_rgb565_format @@ -34,6 +35,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #include "pixel_ops.inc" diff --git a/src/blend/blend_image_bgra8888_rgba8888.c b/src/blend/blend_image_bgra8888_rgba8888.c index 5aff6f352..bba86f9d7 100644 --- a/src/blend/blend_image_bgra8888_rgba8888.c +++ b/src/blend/blend_image_bgra8888_rgba8888.c @@ -27,6 +27,7 @@ #define pixel_dst_format pixel_bgra8888_format #define pixel_dst_to_rgba pixel_bgra8888_to_rgba #define pixel_dst_from_rgb pixel_bgra8888_from_rgb +#define pixel_dst_from_rgba pixel_bgra8888_from_rgba #define pixel_src_t pixel_rgba8888_t #define pixel_src_format pixel_rgba8888_format @@ -34,6 +35,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #include "pixel_ops.inc" diff --git a/src/blend/blend_image_rgb565_bgr565.c b/src/blend/blend_image_rgb565_bgr565.c index 0ccd76e92..95926b6e5 100644 --- a/src/blend/blend_image_rgb565_bgr565.c +++ b/src/blend/blend_image_rgb565_bgr565.c @@ -27,6 +27,7 @@ #define pixel_dst_format pixel_rgb565_format #define pixel_dst_to_rgba pixel_rgb565_to_rgba #define pixel_dst_from_rgb pixel_rgb565_from_rgb +#define pixel_dst_from_rgba pixel_rgb565_from_rgba #define pixel_src_t pixel_bgr565_t #define pixel_src_format pixel_bgr565_format @@ -34,6 +35,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #include "pixel_ops.inc" diff --git a/src/blend/blend_image_rgb565_bgra8888.c b/src/blend/blend_image_rgb565_bgra8888.c index b9be7bd51..cda42e182 100644 --- a/src/blend/blend_image_rgb565_bgra8888.c +++ b/src/blend/blend_image_rgb565_bgra8888.c @@ -27,6 +27,7 @@ #define pixel_dst_format pixel_rgb565_format #define pixel_dst_to_rgba pixel_rgb565_to_rgba #define pixel_dst_from_rgb pixel_rgb565_from_rgb +#define pixel_dst_from_rgba pixel_rgb565_from_rgba #define pixel_src_t pixel_bgra8888_t #define pixel_src_format pixel_bgra8888_format @@ -34,6 +35,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #include "pixel_ops.inc" diff --git a/src/blend/blend_image_rgb565_rgb565.c b/src/blend/blend_image_rgb565_rgb565.c index 6d3bab97f..865178cab 100755 --- a/src/blend/blend_image_rgb565_rgb565.c +++ b/src/blend/blend_image_rgb565_rgb565.c @@ -27,6 +27,7 @@ #define pixel_dst_format pixel_rgb565_format #define pixel_dst_to_rgba pixel_rgb565_to_rgba #define pixel_dst_from_rgb pixel_rgb565_from_rgb +#define pixel_dst_from_rgba pixel_rgb565_from_rgba #define pixel_src_t pixel_rgb565_t #define pixel_src_format pixel_rgb565_format @@ -34,6 +35,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #include "pixel_ops.inc" diff --git a/src/blend/blend_image_rgb565_rgba8888.c b/src/blend/blend_image_rgb565_rgba8888.c index 378d578b9..ea8a34a0d 100644 --- a/src/blend/blend_image_rgb565_rgba8888.c +++ b/src/blend/blend_image_rgb565_rgba8888.c @@ -27,6 +27,7 @@ #define pixel_dst_format pixel_rgb565_format #define pixel_dst_to_rgba pixel_rgb565_to_rgba #define pixel_dst_from_rgb pixel_rgb565_from_rgb +#define pixel_dst_from_rgba pixel_rgb565_from_rgba #define pixel_src_t pixel_rgba8888_t #define pixel_src_format pixel_rgba8888_format @@ -34,6 +35,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #include "pixel_ops.inc" diff --git a/src/blend/blend_image_rgb888_bgr565.c b/src/blend/blend_image_rgb888_bgr565.c index c84d78fbb..cb5401ba3 100644 --- a/src/blend/blend_image_rgb888_bgr565.c +++ b/src/blend/blend_image_rgb888_bgr565.c @@ -27,6 +27,7 @@ #define pixel_dst_format pixel_rgb888_format #define pixel_dst_to_rgba pixel_rgb888_to_rgba #define pixel_dst_from_rgb pixel_rgb888_from_rgb +#define pixel_dst_from_rgba pixel_rgb888_from_rgba #define pixel_src_t pixel_bgr565_t #define pixel_src_format pixel_bgr565_format @@ -34,6 +35,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #include "pixel_ops.inc" diff --git a/src/blend/blend_image_rgb888_bgra8888.c b/src/blend/blend_image_rgb888_bgra8888.c index 131d21e9e..4998aaef9 100644 --- a/src/blend/blend_image_rgb888_bgra8888.c +++ b/src/blend/blend_image_rgb888_bgra8888.c @@ -27,6 +27,7 @@ #define pixel_dst_format pixel_rgb888_format #define pixel_dst_to_rgba pixel_rgb888_to_rgba #define pixel_dst_from_rgb pixel_rgb888_from_rgb +#define pixel_dst_from_rgba pixel_rgb888_from_rgba #define pixel_src_t pixel_bgra8888_t #define pixel_src_format pixel_bgra8888_format @@ -34,6 +35,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #include "pixel_ops.inc" diff --git a/src/blend/blend_image_rgb888_rgb565.c b/src/blend/blend_image_rgb888_rgb565.c index a06f6ee49..29a08b97d 100755 --- a/src/blend/blend_image_rgb888_rgb565.c +++ b/src/blend/blend_image_rgb888_rgb565.c @@ -27,6 +27,7 @@ #define pixel_dst_format pixel_rgb888_format #define pixel_dst_to_rgba pixel_rgb888_to_rgba #define pixel_dst_from_rgb pixel_rgb888_from_rgb +#define pixel_dst_from_rgba pixel_rgb888_from_rgba #define pixel_src_t pixel_rgb565_t #define pixel_src_format pixel_rgb565_format @@ -34,6 +35,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #include "pixel_ops.inc" diff --git a/src/blend/blend_image_rgb888_rgb888.c b/src/blend/blend_image_rgb888_rgb888.c index a4ae26ddc..2caa29f26 100755 --- a/src/blend/blend_image_rgb888_rgb888.c +++ b/src/blend/blend_image_rgb888_rgb888.c @@ -27,6 +27,7 @@ #define pixel_dst_format pixel_rgb888_format #define pixel_dst_to_rgba pixel_rgb888_to_rgba #define pixel_dst_from_rgb pixel_rgb888_from_rgb +#define pixel_dst_from_rgba pixel_rgb888_from_rgba #define pixel_src_t pixel_rgb888_t #define pixel_src_format pixel_rgb888_format @@ -34,6 +35,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #include "pixel_ops.inc" diff --git a/src/blend/blend_image_rgb888_rgba8888.c b/src/blend/blend_image_rgb888_rgba8888.c index 1b97832c5..b25cda691 100644 --- a/src/blend/blend_image_rgb888_rgba8888.c +++ b/src/blend/blend_image_rgb888_rgba8888.c @@ -27,6 +27,7 @@ #define pixel_dst_format pixel_rgb888_format #define pixel_dst_to_rgba pixel_rgb888_to_rgba #define pixel_dst_from_rgb pixel_rgb888_from_rgb +#define pixel_dst_from_rgba pixel_rgb888_from_rgba #define pixel_src_t pixel_rgba8888_t #define pixel_src_format pixel_rgba8888_format @@ -34,6 +35,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #include "pixel_ops.inc" diff --git a/src/blend/blend_image_rgba8888_bgr565.c b/src/blend/blend_image_rgba8888_bgr565.c index 550ef89e7..8a56676de 100644 --- a/src/blend/blend_image_rgba8888_bgr565.c +++ b/src/blend/blend_image_rgba8888_bgr565.c @@ -27,6 +27,7 @@ #define pixel_dst_format pixel_rgba8888_format #define pixel_dst_to_rgba pixel_rgba8888_to_rgba #define pixel_dst_from_rgb pixel_rgba8888_from_rgb +#define pixel_dst_from_rgba pixel_rgba8888_from_rgba #define pixel_src_t pixel_bgr565_t #define pixel_src_format pixel_bgr565_format @@ -34,6 +35,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #include "pixel_ops.inc" diff --git a/src/blend/blend_image_rgba8888_bgra8888.c b/src/blend/blend_image_rgba8888_bgra8888.c index a2c388843..db0d34966 100644 --- a/src/blend/blend_image_rgba8888_bgra8888.c +++ b/src/blend/blend_image_rgba8888_bgra8888.c @@ -27,6 +27,7 @@ #define pixel_dst_format pixel_rgba8888_format #define pixel_dst_to_rgba pixel_rgba8888_to_rgba #define pixel_dst_from_rgb pixel_rgba8888_from_rgb +#define pixel_dst_from_rgba pixel_rgba8888_from_rgba #define pixel_src_t pixel_bgra8888_t #define pixel_src_format pixel_bgra8888_format @@ -34,6 +35,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #include "pixel_ops.inc" diff --git a/src/blend/blend_image_rgba8888_rgb565.c b/src/blend/blend_image_rgba8888_rgb565.c index 2b6f3697d..6dc2f0b8a 100755 --- a/src/blend/blend_image_rgba8888_rgb565.c +++ b/src/blend/blend_image_rgba8888_rgb565.c @@ -27,6 +27,7 @@ #define pixel_dst_format pixel_rgba8888_format #define pixel_dst_to_rgba pixel_rgba8888_to_rgba #define pixel_dst_from_rgb pixel_rgba8888_from_rgb +#define pixel_dst_from_rgba pixel_rgba8888_from_rgba #define pixel_src_t pixel_rgb565_t #define pixel_src_format pixel_rgb565_format @@ -34,6 +35,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #include "pixel_ops.inc" diff --git a/src/blend/blend_image_rgba8888_rgba8888.c b/src/blend/blend_image_rgba8888_rgba8888.c index 7bae2ab7a..bc7f9adc6 100644 --- a/src/blend/blend_image_rgba8888_rgba8888.c +++ b/src/blend/blend_image_rgba8888_rgba8888.c @@ -27,6 +27,7 @@ #define pixel_dst_format pixel_rgba8888_format #define pixel_dst_to_rgba pixel_rgba8888_to_rgba #define pixel_dst_from_rgb pixel_rgba8888_from_rgb +#define pixel_dst_from_rgba pixel_rgba8888_from_rgba #define pixel_src_t pixel_rgba8888_t #define pixel_src_format pixel_rgba8888_format @@ -34,6 +35,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #include "pixel_ops.inc" diff --git a/src/blend/fill_image.inc b/src/blend/fill_image.inc index 2d814355a..a6baf4b65 100644 --- a/src/blend/fill_image.inc +++ b/src/blend/fill_image.inc @@ -11,7 +11,7 @@ static ret_t clear_image(bitmap_t* dst, rect_t* dst_r, color_t c) { pixel_dst_t data = pixel_dst_from_rgba(c.rgba.r, c.rgba.g, c.rgba.b, c.rgba.a); dst_data = bitmap_lock_buffer_for_write(dst); - return_value_if_fail(dst_data != NULL, RET_BAD_PARAMS); + return_value_if_fail(dst_data != NULL && dst_r->w > 0 && dst_r->h > 0, RET_BAD_PARAMS); if (dst->w == dst_r->w && (dst->w * bpp) == line_length && dst->h == dst_r->h) { uint32_t size = w * h; @@ -50,7 +50,7 @@ static ret_t fill_image(bitmap_t* dst, rect_t* dst_r, color_t c) { uint32_t a = c.rgba.a; if (a > 0xf8) { - clear_image(dst, dst_r, c); + return clear_image(dst, dst_r, c); } else { int x = 0; int y = 0; @@ -70,7 +70,7 @@ static ret_t fill_image(bitmap_t* dst, rect_t* dst_r, color_t c) { rgba.a = minus_a; dst_data = bitmap_lock_buffer_for_write(dst); - return_value_if_fail(dst_data != NULL, RET_BAD_PARAMS); + return_value_if_fail(dst_data != NULL && dst_r->w > 0 && dst_r->h > 0, RET_BAD_PARAMS); for (y = 0; y < h; y++) { p = (pixel_dst_t*)(dst_data + (dst_r->y + y) * line_length + dst_r->x * bpp); diff --git a/src/blend/fill_image_abgr8888.c b/src/blend/fill_image_abgr8888.c index 2cc2ba132..b60d59eeb 100644 --- a/src/blend/fill_image_abgr8888.c +++ b/src/blend/fill_image_abgr8888.c @@ -31,6 +31,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #define pixel_blend_rgba_dark pixel_abgr8888_blend_rgba_dark diff --git a/src/blend/fill_image_argb8888.c b/src/blend/fill_image_argb8888.c index edbb17f29..c04555b88 100644 --- a/src/blend/fill_image_argb8888.c +++ b/src/blend/fill_image_argb8888.c @@ -31,6 +31,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #define pixel_blend_rgba_dark pixel_argb8888_blend_rgba_dark diff --git a/src/blend/fill_image_bgr565.c b/src/blend/fill_image_bgr565.c index b7f91591c..3336d28c4 100644 --- a/src/blend/fill_image_bgr565.c +++ b/src/blend/fill_image_bgr565.c @@ -27,10 +27,12 @@ #define pixel_dst_format pixel_bgr565_format #define pixel_dst_to_rgba pixel_bgr565_to_rgba #define pixel_dst_from_rgb pixel_bgr565_from_rgb -#define pixel_dst_from_rgba(r, g, b, a) pixel_bgr565_from_rgb(r, g, b) +#define pixel_dst_from_rgba pixel_bgr565_from_rgba +// #define pixel_dst_from_rgba(r, g, b, a) pixel_bgr565_from_rgb(r, g, b) #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #define pixel_blend_rgba_dark pixel_bgr565_blend_rgba_dark #define pixel_blend_rgba_premulti pixel_bgr565_blend_rgba_premulti diff --git a/src/blend/fill_image_bgr888.c b/src/blend/fill_image_bgr888.c index e7e4f151e..77fd26862 100644 --- a/src/blend/fill_image_bgr888.c +++ b/src/blend/fill_image_bgr888.c @@ -27,10 +27,12 @@ #define pixel_dst_format pixel_bgr888_format #define pixel_dst_to_rgba pixel_bgr888_to_rgba #define pixel_dst_from_rgb pixel_bgr888_from_rgb -#define pixel_dst_from_rgba(r, g, b, a) pixel_bgr888_from_rgb(r, g, b) +#define pixel_dst_from_rgba pixel_bgr888_from_rgba +// #define pixel_dst_from_rgba(r, g, b, a) pixel_bgr888_from_rgb(r, g, b) #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #define pixel_blend_rgba_dark pixel_bgr888_blend_rgba_dark #define pixel_blend_rgba_premulti pixel_bgr888_blend_rgba_premulti diff --git a/src/blend/fill_image_bgra8888.c b/src/blend/fill_image_bgra8888.c index 3f5fbca0c..707f26e17 100644 --- a/src/blend/fill_image_bgra8888.c +++ b/src/blend/fill_image_bgra8888.c @@ -31,6 +31,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #define pixel_blend_rgba_dark pixel_bgra8888_blend_rgba_dark diff --git a/src/blend/fill_image_rgb565.c b/src/blend/fill_image_rgb565.c index 241280242..66fb4819e 100644 --- a/src/blend/fill_image_rgb565.c +++ b/src/blend/fill_image_rgb565.c @@ -27,10 +27,12 @@ #define pixel_dst_format pixel_rgb565_format #define pixel_dst_to_rgba pixel_rgb565_to_rgba #define pixel_dst_from_rgb pixel_rgb565_from_rgb -#define pixel_dst_from_rgba(r, g, b, a) pixel_rgb565_from_rgb(r, g, b) +#define pixel_dst_from_rgba pixel_rgb565_from_rgba +// #define pixel_dst_from_rgba(r, g, b, a) pixel_rgb565_from_rgb(r, g, b) #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #define pixel_blend_rgba_dark pixel_rgb565_blend_rgba_dark #define pixel_blend_rgba_premulti pixel_rgb565_blend_rgba_premulti diff --git a/src/blend/fill_image_rgb888.c b/src/blend/fill_image_rgb888.c index 3d13dc0f2..1af66e3d0 100644 --- a/src/blend/fill_image_rgb888.c +++ b/src/blend/fill_image_rgb888.c @@ -27,10 +27,12 @@ #define pixel_dst_format pixel_rgb888_format #define pixel_dst_to_rgba pixel_rgb888_to_rgba #define pixel_dst_from_rgb pixel_rgb888_from_rgb -#define pixel_dst_from_rgba(r, g, b, a) pixel_rgb888_from_rgb(r, g, b) +#define pixel_dst_from_rgba pixel_rgb888_from_rgba +// #define pixel_dst_from_rgba(r, g, b, a) pixel_rgb888_from_rgb(r, g, b) #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #define pixel_blend_rgba_dark pixel_rgb888_blend_rgba_dark #define pixel_blend_rgba_premulti pixel_rgb888_blend_rgba_premulti diff --git a/src/blend/fill_image_rgba8888.c b/src/blend/fill_image_rgba8888.c index 3cf452785..161ad340e 100644 --- a/src/blend/fill_image_rgba8888.c +++ b/src/blend/fill_image_rgba8888.c @@ -31,6 +31,7 @@ #define pixel_t pixel_dst_t #define pixel_from_rgb pixel_dst_from_rgb +#define pixel_from_rgba pixel_dst_from_rgba #define pixel_to_rgba pixel_dst_to_rgba #define pixel_blend_rgba_dark pixel_rgba8888_blend_rgba_dark diff --git a/src/blend/pixel_ops.inc b/src/blend/pixel_ops.inc index 592c18afc..bc1a7d8c5 100644 --- a/src/blend/pixel_ops.inc +++ b/src/blend/pixel_ops.inc @@ -19,65 +19,166 @@ * */ +static inline uint8_t tk_pixel_ops_limit_uint8(int32_t tmp) { + if(tmp > 0xff) { + tmp = 0xff; + } else if(tmp < 0) { + tmp = 0; + } + return (uint8_t)tmp; +} + static inline pixel_t blend_color(color_t bg, color_t fg, uint8_t a) { - uint8_t minus_a = 0xff - a; + if(a > 0xf4) { + uint8_t minus_a = 0xff - a; - uint8_t r = (bg.rgba.r * minus_a + fg.rgba.r * a) >> 8; - uint8_t g = (bg.rgba.g * minus_a + fg.rgba.g * a) >> 8; - uint8_t b = (bg.rgba.b * minus_a + fg.rgba.b * a) >> 8; - pixel_t p = pixel_from_rgb(r, g, b); + uint8_t r = (bg.rgba.r * minus_a + fg.rgba.r * a) >> 8; + uint8_t g = (bg.rgba.g * minus_a + fg.rgba.g * a) >> 8; + uint8_t b = (bg.rgba.b * minus_a + fg.rgba.b * a) >> 8; + pixel_t p = pixel_from_rgb(r, g, b); - return p; + return p; + } else { + uint8_t fg_a = (fg.rgba.a * a) >> 8; + uint8_t out_a = tk_pixel_ops_limit_uint8(bg.rgba.a + fg_a - ((bg.rgba.a * fg_a) >> 8)); + if(out_a > 0) { + uint8_t d_a = (bg.rgba.a * (0xff - fg_a)) >> 8; + uint8_t r = (bg.rgba.r * d_a + fg.rgba.r * fg_a) / out_a; + uint8_t g = (bg.rgba.g * d_a + fg.rgba.g * fg_a) / out_a; + uint8_t b = (bg.rgba.b * d_a + fg.rgba.b * fg_a) / out_a; + pixel_t p = pixel_from_rgba(r, g, b, out_a); + return p; + } else { + pixel_t p = pixel_from_rgba(0x0, 0x0, 0x0, 0x0); + return p; + } + } } static inline pixel_t blend_pixel(pixel_t pixel, color_t c) { uint8_t a = c.rgba.a; uint8_t minus_a = 0xff - a; rgba_t rgba = pixel_to_rgba(pixel); + + if(rgba.a > 0xf4) { + uint8_t r = (rgba.r * minus_a + c.rgba.r * a) >> 8; + uint8_t g = (rgba.g * minus_a + c.rgba.g * a) >> 8; + uint8_t b = (rgba.b * minus_a + c.rgba.b * a) >> 8; + pixel_t p = pixel_from_rgb(r, g, b); - uint8_t r = (rgba.r * minus_a + c.rgba.r * a) >> 8; - uint8_t g = (rgba.g * minus_a + c.rgba.g * a) >> 8; - uint8_t b = (rgba.b * minus_a + c.rgba.b * a) >> 8; - pixel_t p = pixel_from_rgb(r, g, b); - - return p; + return p; + } else { + uint8_t out_a = tk_pixel_ops_limit_uint8(c.rgba.a + rgba.a - ((c.rgba.a * rgba.a) >> 8)); + if(out_a > 0) { + uint8_t d_a = (rgba.a * (0xff - c.rgba.a)) >> 8; + uint8_t r = (rgba.r * d_a + c.rgba.r * c.rgba.a) / out_a; + uint8_t g = (rgba.g * d_a + c.rgba.g * c.rgba.a) / out_a; + uint8_t b = (rgba.b * d_a + c.rgba.b * c.rgba.a) / out_a; + pixel_t p = pixel_from_rgba(r, g, b, out_a); + return p; + } else { + pixel_t p = pixel_from_rgba(0x0, 0x0, 0x0, 0x0); + return p; + } + } } static inline pixel_t blend_alpha(color_t fg, uint8_t a) { - uint8_t r = (fg.rgba.r * a) >> 8; - uint8_t g = (fg.rgba.g * a) >> 8; - uint8_t b = (fg.rgba.b * a) >> 8; - pixel_t p = pixel_from_rgb(r, g, b); + if(fg.rgba.a > 0xf4) { + uint8_t r = (fg.rgba.r * a) >> 8; + uint8_t g = (fg.rgba.g * a) >> 8; + uint8_t b = (fg.rgba.b * a) >> 8; + pixel_t p = pixel_from_rgb(r, g, b); - return p; + return p; + } else { + + uint8_t out_a =tk_pixel_ops_limit_uint8(a + fg.rgba.a - ((a * fg.rgba.a) >> 8)); + if(out_a > 0) { + uint8_t d_a = (fg.rgba.a * (0xff - a)) >> 8; + uint8_t r = (fg.rgba.r * d_a) / out_a; + uint8_t g = (fg.rgba.g * d_a) / out_a; + uint8_t b = (fg.rgba.b * d_a) / out_a; + pixel_t p = pixel_from_rgba(r, g, b, out_a); + return p; + } else { + pixel_t p = pixel_from_rgba(0x0, 0x0, 0x0, 0x0); + return p; + } + } } static inline pixel_t blend_rgba(rgba_t d, rgba_t s, uint8_t a) { - uint8_t minus_a = 0xff - a; - uint8_t r = (d.r * minus_a + s.r * a) >> 8; - uint8_t g = (d.g * minus_a + s.g * a) >> 8; - uint8_t b = (d.b * minus_a + s.b * a) >> 8; - pixel_t p = pixel_from_rgb(r, g, b); + if(d.a > 0xf4) { + uint8_t minus_a = 0xff - a; + uint8_t r = (d.r * minus_a + s.r * a) >> 8; + uint8_t g = (d.g * minus_a + s.g * a) >> 8; + uint8_t b = (d.b * minus_a + s.b * a) >> 8; - return p; + pixel_t p = pixel_from_rgb(r, g, b); + return p; + } else { + uint8_t out_a = tk_pixel_ops_limit_uint8(s.a + d.a - ((s.a * d.a) >> 8)); + if(out_a > 0) { + uint8_t d_a = (d.a * (0xff - s.a)) >> 8; + uint8_t r = (d.r * d_a + s.r * s.a) / out_a; + uint8_t g = (d.g * d_a + s.g * s.a) / out_a; + uint8_t b = (d.b * d_a + s.b * s.a) / out_a; + pixel_t p = pixel_from_rgba(r, g, b, out_a); + return p; + } else { + pixel_t p = pixel_from_rgba(0x0, 0x0, 0x0, 0x0); + return p; + } + } } static inline pixel_t blend_rgba_premulti(rgba_t d, rgba_t s, uint8_t a) { - uint8_t r = ((d.r * a) >> 8) + s.r; - uint8_t g = ((d.g * a) >> 8) + s.g; - uint8_t b = ((d.b * a) >> 8) + s.b; + if(d.a > 0xf4) { + uint8_t r = ((d.r * a) >> 8) + s.r; + uint8_t g = ((d.g * a) >> 8) + s.g; + uint8_t b = ((d.b * a) >> 8) + s.b; - pixel_t p = pixel_from_rgb(r, g, b); - - return p; + pixel_t p = pixel_from_rgb(r, g, b); + return p; + } else { + uint8_t out_a = tk_pixel_ops_limit_uint8(s.a + d.a - ((s.a * d.a) >> 8)); + if(out_a > 0) { + uint8_t d_a = (d.a * (0xff - s.a)) >> 8; + uint8_t r = (d.r * d_a + s.r) / out_a; + uint8_t g = (d.g * d_a + s.g) / out_a; + uint8_t b = (d.b * d_a + s.b) / out_a; + pixel_t p = pixel_from_rgba(r, g, b, out_a); + return p; + } else { + pixel_t p = pixel_from_rgba(0x0, 0x0, 0x0, 0x0); + return p; + } + } } static inline pixel_t blend_rgba_dark(rgba_t d, uint8_t a) { - uint8_t r = ((d.r * a) >> 8); - uint8_t g = ((d.g * a) >> 8); - uint8_t b = ((d.b * a) >> 8); + if(d.a > 0xf4) { + uint8_t r = ((d.r * a) >> 8); + uint8_t g = ((d.g * a) >> 8); + uint8_t b = ((d.b * a) >> 8); - pixel_t p = pixel_from_rgb(r, g, b); + pixel_t p = pixel_from_rgb(r, g, b); - return p; + return p; + } else { + + uint8_t out_a =tk_pixel_ops_limit_uint8(a + d.a - ((a * d.a) >> 8)); + if(out_a > 0) { + uint8_t d_a = (d.a * (0xff - a)) >> 8; + uint8_t r = (d.r * d_a) / out_a; + uint8_t g = (d.g * d_a) / out_a; + uint8_t b = (d.b * d_a) / out_a; + pixel_t p = pixel_from_rgba(r, g, b, out_a); + return p; + } else { + pixel_t p = pixel_from_rgba(0x0, 0x0, 0x0, 0x0); + return p; + } + } } diff --git a/src/dialog_highlighters/dialog_highlighter_default.c b/src/dialog_highlighters/dialog_highlighter_default.c index f4961cdbc..051331668 100755 --- a/src/dialog_highlighters/dialog_highlighter_default.c +++ b/src/dialog_highlighters/dialog_highlighter_default.c @@ -53,6 +53,8 @@ static ret_t dialog_highlighter_default_prepare(dialog_highlighter_t* h, canvas_ } static ret_t dialog_highlighter_default_draw(dialog_highlighter_t* h, float_t percent) { + rect_t r; + rect_t save_r; canvas_t* c = h->canvas; bitmap_t* img = &(h->img); rect_t src = rect_init(0, 0, img->w, img->h); @@ -64,7 +66,11 @@ static ret_t dialog_highlighter_default_draw(dialog_highlighter_t* h, float_t pe canvas_draw_image(c, img, &src, &dst); window_manager_paint_system_bar(window_manager(), c); } else { - lcd_draw_image(c->lcd, img, &src, &dst); + canvas_get_clip_rect(c, &save_r); + r = rect_intersect(&save_r, &h->clip_rect); + canvas_set_clip_rect(c, &r); + canvas_draw_image(c, img, &src, &dst); + canvas_set_clip_rect(c, &save_r); } /* diff --git a/src/lcd/lcd_mem.inc b/src/lcd/lcd_mem.inc index 8afa6a680..0ce9c812c 100644 --- a/src/lcd/lcd_mem.inc +++ b/src/lcd/lcd_mem.inc @@ -1,4 +1,4 @@ -/** +/** * File: lcd_mem.c * Author: Li XianJing * Brief: mem implemented lcd interface @@ -74,7 +74,21 @@ static bitmap_t* lcd_mem_init_online_fb(lcd_t* lcd, bitmap_t* fb, lcd_orientatio } static ret_t lcd_mem_begin_frame(lcd_t* lcd, rect_t* dirty_rect) { +#if WITH_LCD_CLEAR_ALPHA + rect_t r; + bitmap_t fb; + + if (lcd->draw_mode == LCD_DRAW_OFFLINE || dirty_rect == NULL) { + r = rect_init(0, 0, lcd->w, lcd->h); + } else { + r = rect_init(dirty_rect->x, dirty_rect->y, dirty_rect->w, dirty_rect->h); + } + + lcd_mem_init_drawing_fb(lcd, &fb); + return image_clear(&fb, &r, color_init(0x0, 0x0, 0x0, 0x0)); +#else 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) { diff --git a/src/lcd/lcd_mem_bgr565.c b/src/lcd/lcd_mem_bgr565.c index 4c0177163..646aec090 100644 --- a/src/lcd/lcd_mem_bgr565.c +++ b/src/lcd/lcd_mem_bgr565.c @@ -29,6 +29,7 @@ #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" diff --git a/src/lcd/lcd_mem_bgr888.c b/src/lcd/lcd_mem_bgr888.c index 428aef796..824e2ea87 100644 --- a/src/lcd/lcd_mem_bgr888.c +++ b/src/lcd/lcd_mem_bgr888.c @@ -29,6 +29,7 @@ #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" diff --git a/src/lcd/lcd_mem_bgra8888.c b/src/lcd/lcd_mem_bgra8888.c index ae2e0a6f9..4ddcee1b8 100644 --- a/src/lcd/lcd_mem_bgra8888.c +++ b/src/lcd/lcd_mem_bgra8888.c @@ -29,6 +29,7 @@ #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" diff --git a/src/lcd/lcd_mem_rgb565.c b/src/lcd/lcd_mem_rgb565.c index f65c722ac..f7b5511c1 100644 --- a/src/lcd/lcd_mem_rgb565.c +++ b/src/lcd/lcd_mem_rgb565.c @@ -29,6 +29,7 @@ #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" diff --git a/src/lcd/lcd_mem_rgb888.c b/src/lcd/lcd_mem_rgb888.c index 2d55bb10a..b7a3f1288 100644 --- a/src/lcd/lcd_mem_rgb888.c +++ b/src/lcd/lcd_mem_rgb888.c @@ -29,6 +29,7 @@ #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" diff --git a/src/lcd/lcd_mem_rgba8888.c b/src/lcd/lcd_mem_rgba8888.c index 394ee941e..df83fdc5b 100644 --- a/src/lcd/lcd_mem_rgba8888.c +++ b/src/lcd/lcd_mem_rgba8888.c @@ -29,6 +29,7 @@ #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" diff --git a/src/lcd/lcd_mem_special.c b/src/lcd/lcd_mem_special.c index d3e7eddd4..fcf860e72 100644 --- a/src/lcd/lcd_mem_special.c +++ b/src/lcd/lcd_mem_special.c @@ -31,7 +31,7 @@ static ret_t lcd_mem_special_begin_frame(lcd_t* lcd, rect_t* dr) { lcd_mem_special_t* special = (lcd_mem_special_t*)lcd; lcd_t* mem = (lcd_t*)(special->lcd_mem); - + mem->draw_mode = lcd->draw_mode; mem->begin_frame(mem, dr); return RET_OK; diff --git a/src/vgcanvas/vgcanvas_nanovg_gl.inc b/src/vgcanvas/vgcanvas_nanovg_gl.inc index 2f680c2d0..a991f5bce 100644 --- a/src/vgcanvas/vgcanvas_nanovg_gl.inc +++ b/src/vgcanvas/vgcanvas_nanovg_gl.inc @@ -11,8 +11,14 @@ static ret_t vgcanvas_nanovg_reinit(vgcanvas_t* vg, uint32_t w, uint32_t h, uint } static inline void vgcanvas_nanovg_set_offline_fb(vgcanvas_nanovg_t* canvas, uint32_t w, - uint32_t h) { + uint32_t h, rect_t* dirty_rect) { GLint default_fbo = 0; + +#if WITH_LCD_CLEAR_ALPHA + rect_t r; + system_info_t* info = system_info(); +#endif + vgcanvas_nanovg_offline_fb_t* offline_fb = canvas->offline_fb; if (offline_fb != NULL) { glGetIntegerv(GL_FRAMEBUFFER_BINDING, &default_fbo); @@ -30,6 +36,33 @@ static inline void vgcanvas_nanovg_set_offline_fb(vgcanvas_nanovg_t* canvas, uin // 去除这两行注释就可以显示脏矩形的工作原理。 // glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + +#if WITH_LCD_CLEAR_ALPHA + switch (info->lcd_orientation) { + case LCD_ORIENTATION_0: + r = rect_init(dirty_rect->x, h - dirty_rect->h - dirty_rect->y, dirty_rect->w, dirty_rect->h); + break; + case LCD_ORIENTATION_90: + r = rect_init(w - dirty_rect->h - dirty_rect->y, h - dirty_rect->w - dirty_rect->x, dirty_rect->h, dirty_rect->w); + break; + case LCD_ORIENTATION_180: + r = rect_init(w - dirty_rect->w - dirty_rect->x, dirty_rect->y, dirty_rect->w, dirty_rect->h); + break; + case LCD_ORIENTATION_270: + r = rect_init(dirty_rect->y, dirty_rect->x, dirty_rect->h, dirty_rect->w); + break; + } + + // 把脏矩形的区域刷新为黑色透明度为0的颜色 + glScissor(r.x, r.y, r.w, r.h); + glEnable(GL_SCISSOR_TEST); + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + glDisable(GL_SCISSOR_TEST); +#else + (void)dirty_rect; +#endif + } } } @@ -44,7 +77,7 @@ static inline void vgcanvas_nanovg_offline_fb_flush(vgcanvas_nanovg_t* canvas) { glViewport(0, 0, info->lcd_w * info->device_pixel_ratio, info->lcd_h * info->device_pixel_ratio); - glClearColor(1.0f, 1.0f, 1.0f, 1.0f); + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glUseProgram(shader_info->program_object); @@ -91,8 +124,6 @@ static ret_t vgcanvas_nanovg_begin_frame(vgcanvas_t* vgcanvas, rect_t* dirty_rec native_window_gl_make_current(canvas->window); - vgcanvas_nanovg_set_offline_fb(canvas, info->lcd_w * info->device_pixel_ratio, - info->lcd_h * info->device_pixel_ratio); if (dirty_rect != NULL) { canvas->base.dirty_rect = rect_init(dirty_rect->x, dirty_rect->y, dirty_rect->w, dirty_rect->h); } else { @@ -104,6 +135,9 @@ static ret_t vgcanvas_nanovg_begin_frame(vgcanvas_t* vgcanvas, rect_t* dirty_rec } } + vgcanvas_nanovg_set_offline_fb(canvas, info->lcd_w * info->device_pixel_ratio, + info->lcd_h * info->device_pixel_ratio, &canvas->base.dirty_rect); + nvgBeginFrame(canvas->vg, info->lcd_w, info->lcd_h, info->device_pixel_ratio); switch (info->lcd_orientation) { @@ -183,9 +217,11 @@ static ret_t vgcanvas_nanovg_bind_fbo(vgcanvas_t* vgcanvas, framebuffer_object_t NVGLUframebuffer* handle = (NVGLUframebuffer*)fbo->handle; vgcanvas->dirty_rect = rect_init(0, 0, fbo->w, fbo->h); nvgluBindFramebuffer(handle); - glClearColor(0, 0, 0, 0); glViewport(0, 0, fbo->w * fbo->ratio, fbo->h * fbo->ratio); - glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + nvgBeginFrame(vg, fbo->w, fbo->h, fbo->ratio); return RET_OK; diff --git a/src/window_manager/window_manager_default.c b/src/window_manager/window_manager_default.c index 1de505c94..3deb2eca8 100644 --- a/src/window_manager/window_manager_default.c +++ b/src/window_manager/window_manager_default.c @@ -153,11 +153,10 @@ ret_t window_manager_default_snap_curr_window(widget_t* widget, widget_t* curr_w ret_t window_manager_default_snap_prev_window(widget_t* widget, widget_t* prev_win, bitmap_t* img, framebuffer_object_t* fbo, bool_t auto_rotate) { + rect_t r = {0}; canvas_t* c = NULL; #ifdef WITH_NANOVG_GPU vgcanvas_t* vg = NULL; -#else - rect_t r = {0}; #endif /*WITH_NANOVG_GPU*/ window_manager_default_t* wm = WINDOW_MANAGER_DEFAULT(widget); @@ -178,11 +177,13 @@ ret_t window_manager_default_snap_prev_window(widget_t* widget, widget_t* prev_w } WIDGET_FOR_EACH_CHILD_END() + r = rect_init(prev_win->x, prev_win->y, prev_win->w, prev_win->h); + #ifdef WITH_NANOVG_GPU vg = lcd_get_vgcanvas(c->lcd); ENSURE(vgcanvas_create_fbo(vg, fbo) == RET_OK); ENSURE(vgcanvas_bind_fbo(vg, fbo) == RET_OK); - canvas_set_clip_rect(c, NULL); + canvas_set_clip_rect(c, &r); ENSURE(widget_on_paint_background(widget, c) == RET_OK); window_manager_paint_system_bar(widget, c); { @@ -203,7 +204,6 @@ ret_t window_manager_default_snap_prev_window(widget_t* widget, widget_t* prev_w ENSURE(vgcanvas_unbind_fbo(vg, fbo) == RET_OK); fbo_to_img(fbo, img); #else - r = rect_init(prev_win->x, prev_win->y, prev_win->w, prev_win->h); ENSURE(canvas_begin_frame(c, &r, LCD_DRAW_OFFLINE) == RET_OK); canvas_set_clip_rect(c, &r); ENSURE(widget_on_paint_background(widget, c) == RET_OK); @@ -229,6 +229,7 @@ ret_t window_manager_default_snap_prev_window(widget_t* widget, widget_t* prev_w if (dialog_highlighter != NULL) { dialog_highlighter_set_bg(dialog_highlighter, img, fbo); + dialog_highlighter_set_bg_clip_rect(dialog_highlighter, &r); } wm->curr_win = NULL; return RET_OK;