mirror of
https://github.com/lvgl/lvgl.git
synced 2026-06-01 08:54:52 +08:00
arch(draw): allow replacing the draw engine
BREAKING CHANGE: the API of lv_draw_... function have been changed
This commit is contained in:
@@ -1280,13 +1280,13 @@ static void slider_event_cb(lv_event_t * e)
|
||||
lv_draw_rect_dsc_init(&rect_dsc);
|
||||
rect_dsc.bg_color = lv_palette_darken(LV_PALETTE_GREY, 3);
|
||||
rect_dsc.radius = LV_DPX(5);
|
||||
lv_draw_rect(&bg_area, dsc->clip_area, &rect_dsc);
|
||||
lv_draw_rect(dsc->draw_ctx, &rect_dsc, &bg_area);
|
||||
|
||||
lv_draw_label_dsc_t label_dsc;
|
||||
lv_draw_label_dsc_init(&label_dsc);
|
||||
label_dsc.color = lv_color_white();
|
||||
label_dsc.font = font_normal;
|
||||
lv_draw_label(&txt_area, dsc->clip_area, &label_dsc, buf, NULL);
|
||||
lv_draw_label(dsc->draw_ctx, &label_dsc, &txt_area, buf, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1334,15 +1334,16 @@ static void chart_event_cb(lv_event_t * e)
|
||||
draw_rect_dsc.bg_color = dsc->line_dsc->color;
|
||||
|
||||
lv_area_t obj_clip_area;
|
||||
_lv_area_intersect(&obj_clip_area, dsc->clip_area, &obj->coords);
|
||||
|
||||
_lv_area_intersect(&obj_clip_area, dsc->draw_ctx->clip_area, &obj->coords);
|
||||
const lv_area_t * clip_area_ori = dsc->draw_ctx->clip_area;
|
||||
dsc->draw_ctx->clip_area = &obj_clip_area;
|
||||
lv_area_t a;
|
||||
a.x1 = dsc->p1->x;
|
||||
a.x2 = dsc->p2->x - 1;
|
||||
a.y1 = LV_MIN(dsc->p1->y, dsc->p2->y);
|
||||
a.y2 = obj->coords.y2;
|
||||
lv_draw_rect(&a, &obj_clip_area, &draw_rect_dsc);
|
||||
|
||||
lv_draw_rect(dsc->draw_ctx, &draw_rect_dsc, &a);
|
||||
dsc->draw_ctx->clip_area = clip_area_ori;
|
||||
/*Remove the masks*/
|
||||
lv_draw_mask_remove_id(line_mask_id);
|
||||
lv_draw_mask_remove_id(fade_mask_id);
|
||||
@@ -1396,13 +1397,13 @@ static void chart_event_cb(lv_event_t * e)
|
||||
lv_draw_rect_dsc_init(&rect_dsc);
|
||||
rect_dsc.bg_color = ser->color;
|
||||
rect_dsc.radius = LV_DPX(5);
|
||||
lv_draw_rect(&bg_area, dsc->clip_area, &rect_dsc);
|
||||
lv_draw_rect(dsc->draw_ctx, &rect_dsc, &bg_area);
|
||||
|
||||
lv_draw_label_dsc_t label_dsc;
|
||||
lv_draw_label_dsc_init(&label_dsc);
|
||||
label_dsc.color = lv_color_white();
|
||||
label_dsc.font = font_normal;
|
||||
lv_draw_label(&txt_area, dsc->clip_area, &label_dsc, buf, NULL);
|
||||
lv_draw_label(dsc->draw_ctx, &label_dsc, &txt_area, buf, NULL);
|
||||
} else {
|
||||
dsc->rect_dsc->outline_width = 0;
|
||||
dsc->rect_dsc->shadow_width = 0;
|
||||
@@ -1447,18 +1448,18 @@ static void shop_chart_event_cb(lv_event_t * e)
|
||||
a.y2 = a.y1 + 4 + (devices[dsc->id] * h) / 100; /*+4 to overlap the radius*/
|
||||
draw_rect_dsc.bg_color = lv_palette_main(LV_PALETTE_RED);
|
||||
draw_rect_dsc.radius = 4;
|
||||
lv_draw_rect(&a, dsc->clip_area, &draw_rect_dsc);
|
||||
lv_draw_rect(dsc->draw_ctx, &draw_rect_dsc, &a);
|
||||
|
||||
a.y1 = a.y2 - 4; /*-4 to overlap the radius*/
|
||||
a.y2 = a.y1 + (clothes[dsc->id] * h) / 100;
|
||||
draw_rect_dsc.bg_color = lv_palette_main(LV_PALETTE_BLUE);
|
||||
draw_rect_dsc.radius = 0;
|
||||
lv_draw_rect(&a, dsc->clip_area, &draw_rect_dsc);
|
||||
lv_draw_rect( dsc->draw_ctx, &draw_rect_dsc, &a);
|
||||
|
||||
a.y1 = a.y2;
|
||||
a.y2 = a.y1 + (services[dsc->id] * h) / 100;
|
||||
draw_rect_dsc.bg_color = lv_palette_main(LV_PALETTE_GREEN);
|
||||
lv_draw_rect(&a, dsc->clip_area, &draw_rect_dsc);
|
||||
lv_draw_rect( dsc->draw_ctx, &draw_rect_dsc, &a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../lv_examples.h"
|
||||
#if LV_BUILD_EXAMPLES
|
||||
#if LV_USE_FLEX && LV_BUILD_EXAMPLES
|
||||
|
||||
static lv_anim_timeline_t * anim_timeline = NULL;
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_FFMPEG && LV_BUILD_EXAMPLES
|
||||
#if LV_BUILD_EXAMPLES
|
||||
#if LV_USE_FFMPEG
|
||||
|
||||
|
||||
/**
|
||||
* Open an image from a file
|
||||
@@ -24,3 +26,4 @@ void lv_example_ffmpeg_1(void)
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_FFMPEG && LV_BUILD_EXAMPLES
|
||||
#if LV_BUILD_EXAMPLES
|
||||
#if LV_USE_FFMPEG
|
||||
|
||||
/**
|
||||
* Open a video from a file
|
||||
@@ -28,3 +29,4 @@ void lv_example_ffmpeg_2(void)
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_FREETYPE && LV_BUILD_EXAMPLES
|
||||
#if LV_BUILD_EXAMPLES
|
||||
#if LV_USE_FREETYPE
|
||||
|
||||
/**
|
||||
* Load a font with FreeType
|
||||
@@ -42,3 +43,4 @@ void lv_example_freetype_1(void)
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_PNG && LV_BUILD_EXAMPLES
|
||||
#if LV_USE_PNG && LV_USE_IMG && LV_BUILD_EXAMPLES
|
||||
|
||||
/**
|
||||
* Open a PNG image from a file and a variable
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_RLOTTIE && LV_BUILD_EXAMPLES
|
||||
#if LV_BUILD_EXAMPLES
|
||||
#if LV_USE_RLOTTIE
|
||||
|
||||
/**
|
||||
* Load an lottie animation from flash
|
||||
@@ -23,3 +24,4 @@ void lv_example_rlottie_1(void)
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_RLOTTIE && LV_BUILD_EXAMPLES
|
||||
#if LV_BUILD_EXAMPLES
|
||||
#if LV_USE_RLOTTIE
|
||||
|
||||
/**
|
||||
* Load an lottie animation from file
|
||||
@@ -24,3 +25,4 @@ void lv_example_rlottie_2(void)
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -31,11 +31,12 @@ void lv_example_snapshot_1(void)
|
||||
lv_obj_set_style_bg_color(snapshot_obj, lv_palette_main(LV_PALETTE_PURPLE), 0);
|
||||
lv_obj_set_style_bg_opa(snapshot_obj, LV_OPA_100, 0);
|
||||
lv_img_set_zoom(snapshot_obj, 128);
|
||||
lv_img_set_angle(snapshot_obj, 300);
|
||||
|
||||
/*Create the container and its children*/
|
||||
lv_obj_t * container = lv_obj_create(root);
|
||||
|
||||
lv_obj_align(container, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_center(container);
|
||||
lv_obj_set_size(container, 180, 180);
|
||||
lv_obj_set_flex_flow(container, LV_FLEX_FLOW_ROW_WRAP);
|
||||
lv_obj_set_flex_align(container, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../lv_examples.h"
|
||||
#if LV_BUILD_EXAMPLES
|
||||
#if LV_BUILD_EXAMPLES && LV_USE_FLEX
|
||||
|
||||
static void scroll_event_cb(lv_event_t * e)
|
||||
{
|
||||
|
||||
@@ -15,10 +15,10 @@ void lv_example_style_5(void)
|
||||
lv_style_set_bg_color(&style, lv_palette_lighten(LV_PALETTE_GREY, 1));
|
||||
|
||||
/*Add a shadow*/
|
||||
lv_style_set_shadow_width(&style, 25);
|
||||
lv_style_set_shadow_width(&style, 55);
|
||||
lv_style_set_shadow_color(&style, lv_palette_main(LV_PALETTE_BLUE));
|
||||
lv_style_set_shadow_ofs_x(&style, 10);
|
||||
lv_style_set_shadow_ofs_y(&style, 20);
|
||||
// lv_style_set_shadow_ofs_x(&style, 10);
|
||||
// lv_style_set_shadow_ofs_y(&style, 20);
|
||||
|
||||
/*Create an object with the new style*/
|
||||
lv_obj_t * obj = lv_obj_create(lv_scr_act());
|
||||
|
||||
@@ -40,7 +40,7 @@ static void event_cb(lv_event_t * e)
|
||||
txt_area.y1 = dsc->draw_area->y1 + (lv_area_get_height(dsc->draw_area) - txt_size.y) / 2;
|
||||
txt_area.y2 = txt_area.y1 + txt_size.y - 1;
|
||||
|
||||
lv_draw_label(&txt_area, dsc->clip_area, &label_dsc, buf, NULL);
|
||||
lv_draw_label(dsc->draw_ctx, &label_dsc, &txt_area, buf, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -54,7 +54,7 @@ static void event_cb(lv_event_t * e)
|
||||
img_draw_dsc.recolor = lv_color_black();
|
||||
if(lv_btnmatrix_get_selected_btn(obj) == dsc->id) img_draw_dsc.recolor_opa = LV_OPA_30;
|
||||
|
||||
lv_draw_img(&a, dsc->clip_area, &img_star, &img_draw_dsc);
|
||||
lv_draw_img(dsc->draw_ctx, &img_draw_dsc, &a, &img_star);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ void lv_example_canvas_1(void)
|
||||
|
||||
lv_draw_label_dsc_t label_dsc;
|
||||
lv_draw_label_dsc_init(&label_dsc);
|
||||
label_dsc.color = lv_palette_main(LV_PALETTE_YELLOW);
|
||||
label_dsc.color = lv_palette_main(LV_PALETTE_ORANGE);
|
||||
|
||||
static lv_color_t cbuf[LV_CANVAS_BUF_SIZE_TRUE_COLOR(CANVAS_WIDTH, CANVAS_HEIGHT)];
|
||||
|
||||
@@ -47,7 +47,7 @@ void lv_example_canvas_1(void)
|
||||
img.header.h = CANVAS_HEIGHT;
|
||||
|
||||
lv_canvas_fill_bg(canvas, lv_palette_lighten(LV_PALETTE_GREY, 3), LV_OPA_COVER);
|
||||
lv_canvas_transform(canvas, &img, 30, LV_IMG_ZOOM_NONE, 0, 0, CANVAS_WIDTH / 2, CANVAS_HEIGHT / 2, true);
|
||||
lv_canvas_transform(canvas, &img, 120, LV_IMG_ZOOM_NONE, 0, 0, CANVAS_WIDTH / 2, CANVAS_HEIGHT / 2, true);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -36,7 +36,7 @@ static void draw_event_cb(lv_event_t * e)
|
||||
a.x2 = dsc->p2->x - 1;
|
||||
a.y1 = LV_MIN(dsc->p1->y, dsc->p2->y);
|
||||
a.y2 = obj->coords.y2;
|
||||
lv_draw_rect(&a, dsc->clip_area, &draw_rect_dsc);
|
||||
lv_draw_rect(dsc->draw_ctx, &draw_rect_dsc, &a);
|
||||
|
||||
/*Remove the masks*/
|
||||
lv_draw_mask_free_param(&line_mask_param);
|
||||
|
||||
@@ -45,8 +45,8 @@ static void event_cb(lv_event_t * e)
|
||||
a.y1 = chart->coords.y1 + p.y - 30;
|
||||
a.y2 = chart->coords.y1 + p.y - 10;
|
||||
|
||||
const lv_area_t * clip_area = lv_event_get_clip_area(e);
|
||||
lv_draw_rect(&a, clip_area, &draw_rect_dsc);
|
||||
lv_draw_ctx_t * draw_ctx = lv_event_get_draw_ctx(e);
|
||||
lv_draw_rect(draw_ctx, &draw_rect_dsc, &a);
|
||||
|
||||
ser = lv_chart_get_series_next(chart, ser);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ static void event_cb(lv_event_t * e)
|
||||
draw_rect_dsc.bg_color = lv_palette_main(LV_PALETTE_BLUE);
|
||||
draw_rect_dsc.radius = 3;
|
||||
|
||||
lv_draw_rect(&a, dsc->clip_area, &draw_rect_dsc);
|
||||
lv_draw_rect(dsc->draw_ctx, &draw_rect_dsc, &a);
|
||||
|
||||
lv_draw_label_dsc_t draw_label_dsc;
|
||||
lv_draw_label_dsc_init(&draw_label_dsc);
|
||||
@@ -50,7 +50,7 @@ static void event_cb(lv_event_t * e)
|
||||
a.x2 -= 5;
|
||||
a.y1 += 5;
|
||||
a.y2 -= 5;
|
||||
lv_draw_label(&a, dsc->clip_area, &draw_label_dsc, buf, NULL);
|
||||
lv_draw_label(dsc->draw_ctx, &draw_label_dsc, &a, buf, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ static void draw_event_cb(lv_event_t *e)
|
||||
a.x2 = dsc->p2->x;
|
||||
a.y1 = LV_MIN(dsc->p1->y, dsc->p2->y);
|
||||
a.y2 = obj->coords.y2 - 13; /* -13 cuts off where the rectangle draws over the chart margin. Without this an area of 0 doesnt look like 0 */
|
||||
lv_draw_rect(&a, dsc->clip_area, &draw_rect_dsc);
|
||||
lv_draw_rect(dsc->draw_ctx, &draw_rect_dsc, &a);
|
||||
|
||||
/*Remove the mask*/
|
||||
lv_draw_mask_free_param(&line_mask_param);
|
||||
|
||||
@@ -15,7 +15,6 @@ void lv_example_label_1(void)
|
||||
lv_obj_set_style_text_align(label1, LV_TEXT_ALIGN_CENTER, 0);
|
||||
lv_obj_align(label1, LV_ALIGN_CENTER, 0, -40);
|
||||
|
||||
|
||||
lv_obj_t * label2 = lv_label_create(lv_scr_act());
|
||||
lv_label_set_long_mode(label2, LV_LABEL_LONG_SCROLL_CIRCULAR); /*Circular scroll*/
|
||||
lv_obj_set_width(label2, 150);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_LABEL && LV_BUILD_EXAMPLES && LV_DRAW_COMPLEX
|
||||
#if LV_USE_LABEL && LV_USE_CANVAS && LV_BUILD_EXAMPLES && LV_DRAW_COMPLEX
|
||||
|
||||
#define MASK_WIDTH 100
|
||||
#define MASK_HEIGHT 45
|
||||
|
||||
@@ -24,7 +24,7 @@ void lv_example_meter_2(void)
|
||||
/*Add a scale first*/
|
||||
lv_meter_scale_t * scale = lv_meter_add_scale(meter);
|
||||
lv_meter_set_scale_ticks(meter, scale, 11, 2, 10, lv_palette_main(LV_PALETTE_GREY));
|
||||
lv_meter_set_scale_major_ticks(meter, scale, 1, 2, 30, lv_color_hex3(0xeee), 10);
|
||||
lv_meter_set_scale_major_ticks(meter, scale, 1, 2, 30, lv_color_hex3(0xeee), 15);
|
||||
lv_meter_set_scale_range(meter, scale, 0, 100, 270, 90);
|
||||
|
||||
/*Add a three arc indicator*/
|
||||
|
||||
@@ -49,7 +49,7 @@ static void slider_event_cb(lv_event_t * e)
|
||||
lv_draw_label_dsc_t label_draw_dsc;
|
||||
lv_draw_label_dsc_init(&label_draw_dsc);
|
||||
|
||||
lv_draw_label(&label_area, dsc->clip_area, &label_draw_dsc, buf, NULL);
|
||||
lv_draw_label(dsc->draw_ctx, &label_draw_dsc, &label_area, buf, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,10 +24,10 @@ void lv_example_span_1(void)
|
||||
lv_spangroup_set_mode(spans, LV_SPAN_MODE_BREAK);
|
||||
|
||||
lv_span_t * span = lv_spangroup_new_span(spans);
|
||||
lv_span_set_text(span, "china is a beautiful country.");
|
||||
lv_span_set_text(span, "China is a beautiful country.");
|
||||
lv_style_set_text_color(&span->style, lv_palette_main(LV_PALETTE_RED));
|
||||
lv_style_set_text_decor(&span->style, LV_TEXT_DECOR_STRIKETHROUGH | LV_TEXT_DECOR_UNDERLINE);
|
||||
lv_style_set_text_opa(&span->style, LV_OPA_30);
|
||||
lv_style_set_text_opa(&span->style, LV_OPA_50);
|
||||
|
||||
span = lv_spangroup_new_span(spans);
|
||||
lv_span_set_text_static(span, "good good study, day day up.");
|
||||
|
||||
@@ -21,7 +21,7 @@ static void draw_event_cb(lv_event_t * e)
|
||||
sw_area.x2 = sw_area.x1 + 40;
|
||||
sw_area.y1 = dsc->draw_area->y1 + lv_area_get_height(dsc->draw_area) / 2 - 10;
|
||||
sw_area.y2 = sw_area.y1 + 20;
|
||||
lv_draw_rect(&sw_area, dsc->clip_area, &rect_dsc);
|
||||
lv_draw_rect(dsc->draw_ctx, &rect_dsc, &sw_area);
|
||||
|
||||
rect_dsc.bg_color = lv_color_white();
|
||||
if(chk) {
|
||||
@@ -33,7 +33,7 @@ static void draw_event_cb(lv_event_t * e)
|
||||
}
|
||||
sw_area.y1 += 2;
|
||||
sw_area.y2 -= 2;
|
||||
lv_draw_rect(&sw_area, dsc->clip_area, &rect_dsc);
|
||||
lv_draw_rect(dsc->draw_ctx, &rect_dsc, &sw_area);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-4
@@ -157,13 +157,11 @@
|
||||
/*Use NXP's VG-Lite GPU iMX RTxxx platforms*/
|
||||
#define LV_USE_GPU_NXP_VG_LITE 0
|
||||
|
||||
/*Use exnternal renderer*/
|
||||
#define LV_USE_EXTERNAL_RENDERER 0
|
||||
|
||||
/*Use SDL renderer API. Requires LV_USE_EXTERNAL_RENDERER*/
|
||||
/*Use SDL renderer API*/
|
||||
#define LV_USE_GPU_SDL 0
|
||||
#if LV_USE_GPU_SDL
|
||||
#define LV_GPU_SDL_INCLUDE_PATH <SDL2/SDL.h>
|
||||
#define LV_GPU_SDL_LRU_SIZE (1024 * 1024 * 8)
|
||||
#endif
|
||||
|
||||
/*-------------
|
||||
|
||||
+2
-2
@@ -85,7 +85,7 @@ lv_res_t lv_obj_event_base(const lv_obj_class_t * class_p, lv_event_t * e)
|
||||
if(class_p == NULL) base = e->current_target->class_p;
|
||||
else base = class_p->base_class;
|
||||
|
||||
/*Find a base in which Call the ancestor's event handler_cb is set*/
|
||||
/*Find a base in which call the ancestor's event handler_cb if set*/
|
||||
while(base && base->event_cb == NULL) base = base->base_class;
|
||||
|
||||
if(base == NULL) return LV_RES_OK;
|
||||
@@ -290,7 +290,7 @@ lv_obj_draw_part_dsc_t * lv_event_get_draw_part_dsc(lv_event_t * e)
|
||||
}
|
||||
}
|
||||
|
||||
const lv_area_t * lv_event_get_clip_area(lv_event_t * e)
|
||||
lv_draw_ctx_t * lv_event_get_draw_ctx(lv_event_t * e)
|
||||
{
|
||||
if(e->code == LV_EVENT_DRAW_MAIN ||
|
||||
e->code == LV_EVENT_DRAW_MAIN_BEGIN ||
|
||||
|
||||
+3
-3
@@ -268,12 +268,12 @@ lv_indev_t * lv_event_get_indev(lv_event_t * e);
|
||||
lv_obj_draw_part_dsc_t * lv_event_get_draw_part_dsc(lv_event_t * e);
|
||||
|
||||
/**
|
||||
* Get the clip area passed as parameter to draw events events.
|
||||
* Get the draw context which should be the first parameter of the draw functions.
|
||||
* Namely: `LV_EVENT_DRAW_MAIN/POST`, `LV_EVENT_DRAW_MAIN/POST_BEGIN`, `LV_EVENT_DRAW_MAIN/POST_END`
|
||||
* @param e pointer to an event
|
||||
* @return the clip area to use during drawing or NULL if called on an unrelated event
|
||||
* @return pointer to a draw context or NULL if called on an unrelated event
|
||||
*/
|
||||
const lv_area_t * lv_event_get_clip_area(lv_event_t * e);
|
||||
lv_draw_ctx_t * lv_event_get_draw_ctx(lv_event_t * e);
|
||||
|
||||
/**
|
||||
* Get the old area of the object before its size was changed. Can be used in `LV_EVENT_SIZE_CHANGED`
|
||||
|
||||
+27
-36
@@ -27,7 +27,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#if LV_USE_GPU_STM32_DMA2D
|
||||
#include "../gpu/lv_gpu_stm32_dma2d.h"
|
||||
#include "../draw/stm32_dma2d/lv_gpu_stm32_dma2d.h"
|
||||
#endif
|
||||
|
||||
#if LV_USE_GPU_NXP_PXP && LV_USE_GPU_NXP_PXP_AUTO_INIT
|
||||
@@ -35,10 +35,6 @@
|
||||
#include "../gpu/lv_gpu_nxp_pxp_osa.h"
|
||||
#endif
|
||||
|
||||
#if LV_USE_GPU_SDL
|
||||
#include "../gpu/lv_gpu_sdl.h"
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
@@ -59,7 +55,7 @@ static void lv_obj_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj);
|
||||
static void lv_obj_destructor(const lv_obj_class_t * class_p, lv_obj_t * obj);
|
||||
static void lv_obj_draw(lv_event_t * e);
|
||||
static void lv_obj_event(const lv_obj_class_t * class_p, lv_event_t * e);
|
||||
static void draw_scrollbar(lv_obj_t * obj, const lv_area_t * clip_area);
|
||||
static void draw_scrollbar(lv_obj_t * obj, lv_draw_ctx_t * draw_ctx);
|
||||
static lv_res_t scrollbar_init_draw_dsc(lv_obj_t * obj, lv_draw_rect_dsc_t * dsc);
|
||||
static bool obj_valid_child(const lv_obj_t * parent, const lv_obj_t * obj_to_find);
|
||||
static void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state);
|
||||
@@ -116,20 +112,17 @@ void lv_init(void)
|
||||
|
||||
lv_draw_init();
|
||||
|
||||
//#if LV_USE_GPU_STM32_DMA2D
|
||||
// /*Initialize DMA2D GPU*/
|
||||
// lv_gpu_stm32_dma2d_init();
|
||||
//#endif
|
||||
//
|
||||
//#if LV_USE_GPU_NXP_PXP && LV_USE_GPU_NXP_PXP_AUTO_INIT
|
||||
// if(lv_gpu_nxp_pxp_init(&pxp_default_cfg) != LV_RES_OK) {
|
||||
// LV_LOG_ERROR("PXP init error. STOP.\n");
|
||||
// for(; ;) ;
|
||||
// }
|
||||
//#endif
|
||||
//#if LV_USE_GPU_SDL
|
||||
// lv_gpu_sdl_init();
|
||||
//#endif
|
||||
#if LV_USE_GPU_STM32_DMA2D
|
||||
/*Initialize DMA2D GPU*/
|
||||
lv_draw_stm32_dma2d_init();
|
||||
#endif
|
||||
|
||||
#if LV_USE_GPU_NXP_PXP && LV_USE_GPU_NXP_PXP_AUTO_INIT
|
||||
if(lv_gpu_nxp_pxp_init(&pxp_default_cfg) != LV_RES_OK) {
|
||||
LV_LOG_ERROR("PXP init error. STOP.\n");
|
||||
for(; ;) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
_lv_obj_style_init();
|
||||
_lv_ll_init(&LV_GC_ROOT(_lv_disp_ll), sizeof(lv_disp_t));
|
||||
@@ -186,13 +179,10 @@ void lv_init(void)
|
||||
LV_LOG_TRACE("finished");
|
||||
}
|
||||
|
||||
#if LV_ENABLE_GC || !LV_MEM_CUSTOM || LV_USE_GPU_SDL
|
||||
#if LV_ENABLE_GC || !LV_MEM_CUSTOM
|
||||
|
||||
void lv_deinit(void)
|
||||
{
|
||||
#if LV_USE_GPU_SDL
|
||||
lv_gpu_sdl_deinit();
|
||||
#endif
|
||||
_lv_gc_clear_roots();
|
||||
|
||||
lv_disp_set_default(NULL);
|
||||
@@ -514,7 +504,7 @@ static void lv_obj_draw(lv_event_t * e)
|
||||
|
||||
}
|
||||
else if(code == LV_EVENT_DRAW_MAIN) {
|
||||
const lv_area_t * clip_area = lv_event_get_param(e);
|
||||
lv_draw_ctx_t * draw_ctx = lv_event_get_draw_ctx(e);
|
||||
lv_draw_rect_dsc_t draw_dsc;
|
||||
lv_draw_rect_dsc_init(&draw_dsc);
|
||||
/*If the border is drawn later disable loading its properties*/
|
||||
@@ -523,7 +513,6 @@ static void lv_obj_draw(lv_event_t * e)
|
||||
}
|
||||
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_PART_MAIN, &draw_dsc);
|
||||
|
||||
lv_coord_t w = lv_obj_get_style_transform_width(obj, LV_PART_MAIN);
|
||||
lv_coord_t h = lv_obj_get_style_transform_height(obj, LV_PART_MAIN);
|
||||
lv_area_t coords;
|
||||
@@ -534,7 +523,7 @@ static void lv_obj_draw(lv_event_t * e)
|
||||
coords.y2 += h;
|
||||
|
||||
lv_obj_draw_part_dsc_t part_dsc;
|
||||
lv_obj_draw_dsc_init(&part_dsc, clip_area);
|
||||
lv_obj_draw_dsc_init(&part_dsc, draw_ctx);
|
||||
part_dsc.class_p = MY_CLASS;
|
||||
part_dsc.type = LV_OBJ_DRAW_PART_RECTANGLE;
|
||||
part_dsc.rect_dsc = &draw_dsc;
|
||||
@@ -542,7 +531,8 @@ static void lv_obj_draw(lv_event_t * e)
|
||||
part_dsc.part = LV_PART_MAIN;
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_dsc);
|
||||
|
||||
lv_draw_rect(&coords, clip_area, &draw_dsc);
|
||||
|
||||
lv_draw_rect(draw_ctx, &draw_dsc, &coords);
|
||||
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &part_dsc);
|
||||
|
||||
@@ -560,8 +550,8 @@ static void lv_obj_draw(lv_event_t * e)
|
||||
#endif
|
||||
}
|
||||
else if(code == LV_EVENT_DRAW_POST) {
|
||||
const lv_area_t * clip_area = lv_event_get_param(e);
|
||||
draw_scrollbar(obj, clip_area);
|
||||
lv_draw_ctx_t * draw_ctx = lv_event_get_draw_ctx(e);
|
||||
draw_scrollbar(obj, draw_ctx);
|
||||
|
||||
#if LV_DRAW_COMPLEX
|
||||
if(lv_obj_get_style_clip_corner(obj, LV_PART_MAIN)) {
|
||||
@@ -593,7 +583,7 @@ static void lv_obj_draw(lv_event_t * e)
|
||||
coords.y2 += h;
|
||||
|
||||
lv_obj_draw_part_dsc_t part_dsc;
|
||||
lv_obj_draw_dsc_init(&part_dsc, clip_area);
|
||||
lv_obj_draw_dsc_init(&part_dsc, draw_ctx);
|
||||
part_dsc.class_p = MY_CLASS;
|
||||
part_dsc.type = LV_OBJ_DRAW_PART_BORDER_POST;
|
||||
part_dsc.rect_dsc = &draw_dsc;
|
||||
@@ -601,13 +591,13 @@ static void lv_obj_draw(lv_event_t * e)
|
||||
part_dsc.part = LV_PART_MAIN;
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_dsc);
|
||||
|
||||
lv_draw_rect(&coords, clip_area, &draw_dsc);
|
||||
lv_draw_rect(draw_ctx, &draw_dsc, &coords);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &part_dsc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_scrollbar(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
static void draw_scrollbar(lv_obj_t * obj, lv_draw_ctx_t * draw_ctx)
|
||||
{
|
||||
|
||||
lv_area_t hor_area;
|
||||
@@ -621,7 +611,7 @@ static void draw_scrollbar(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
if(sb_res != LV_RES_OK) return;
|
||||
|
||||
lv_obj_draw_part_dsc_t part_dsc;
|
||||
lv_obj_draw_dsc_init(&part_dsc, clip_area);
|
||||
lv_obj_draw_dsc_init(&part_dsc, draw_ctx);
|
||||
part_dsc.class_p = MY_CLASS;
|
||||
part_dsc.type = LV_OBJ_DRAW_PART_SCROLLBAR;
|
||||
part_dsc.rect_dsc = &draw_dsc;
|
||||
@@ -630,13 +620,14 @@ static void draw_scrollbar(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
if(lv_area_get_size(&hor_area) > 0) {
|
||||
part_dsc.draw_area = &hor_area;
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_dsc);
|
||||
lv_draw_rect(&hor_area, clip_area, &draw_dsc);
|
||||
lv_draw_rect(draw_ctx, &draw_dsc, &hor_area);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &part_dsc);
|
||||
}
|
||||
if(lv_area_get_size(&ver_area) > 0) {
|
||||
part_dsc.draw_area = &ver_area;
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_dsc);
|
||||
lv_draw_rect(&ver_area, clip_area, &draw_dsc);
|
||||
part_dsc.draw_area = &ver_area;
|
||||
lv_draw_rect(draw_ctx, &draw_dsc, &ver_area);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &part_dsc);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -194,7 +194,7 @@ typedef struct _lv_obj_t {
|
||||
*/
|
||||
void lv_init(void);
|
||||
|
||||
#if LV_ENABLE_GC || !LV_MEM_CUSTOM || LV_USE_GPU_SDL
|
||||
#if LV_ENABLE_GC || !LV_MEM_CUSTOM
|
||||
|
||||
/**
|
||||
* Deinit the 'lv' library
|
||||
|
||||
@@ -322,10 +322,10 @@ lv_coord_t lv_obj_calculate_ext_draw_size(lv_obj_t * obj, uint32_t part)
|
||||
return s;
|
||||
}
|
||||
|
||||
void lv_obj_draw_dsc_init(lv_obj_draw_part_dsc_t * dsc, const lv_area_t * clip_area)
|
||||
void lv_obj_draw_dsc_init(lv_obj_draw_part_dsc_t * dsc, lv_draw_ctx_t * draw_ctx)
|
||||
{
|
||||
lv_memset_00(dsc, sizeof(lv_obj_draw_part_dsc_t));
|
||||
dsc->clip_area = clip_area;
|
||||
dsc->draw_ctx = draw_ctx;
|
||||
}
|
||||
|
||||
bool lv_obj_draw_part_check_type(lv_obj_draw_part_dsc_t * dsc, const lv_obj_class_t * class_p, uint32_t type)
|
||||
|
||||
@@ -34,7 +34,7 @@ typedef enum {
|
||||
} lv_cover_res_t;
|
||||
|
||||
typedef struct {
|
||||
const lv_area_t * clip_area; /**< The current clip area, required if you need to draw something in the event*/
|
||||
lv_draw_ctx_t * draw_ctx; /**< Draw context*/
|
||||
const struct _lv_obj_class_t * class_p; /**< The class that sent the event */
|
||||
uint32_t type; /**< The type if part being draw. Element of `lv_<name>_draw_part_type_t` */
|
||||
lv_area_t * draw_area; /**< The area of the part being drawn*/
|
||||
@@ -125,9 +125,9 @@ lv_coord_t lv_obj_calculate_ext_draw_size(struct _lv_obj_t * obj, uint32_t part)
|
||||
/**
|
||||
* Initialize a draw descriptor used in events.
|
||||
* @param dsc pointer to a descriptor. Later it should be passed as parameter to an `LV_EEVNT_DRAW_PART_BEGIN/END` event.
|
||||
* @param clip_area the current clip area of the drawing
|
||||
* @param draw the current draw context. (usually returned by `lv_event_get_draw_ctx(e)`)
|
||||
*/
|
||||
void lv_obj_draw_dsc_init(lv_obj_draw_part_dsc_t * dsc, const lv_area_t * clip_area);
|
||||
void lv_obj_draw_dsc_init(lv_obj_draw_part_dsc_t * dsc, lv_draw_ctx_t * draw_ctx);
|
||||
|
||||
/**
|
||||
* Check the type obj a part draw descriptor
|
||||
|
||||
+188
-215
File diff suppressed because it is too large
Load Diff
@@ -56,6 +56,13 @@ void _lv_refr_init(void);
|
||||
*/
|
||||
void lv_refr_now(lv_disp_t * disp);
|
||||
|
||||
/**
|
||||
* Redrawn on object an all its children using the passed draw context
|
||||
* @param draw pointer to an initialized draw context
|
||||
* @param obj the start object from the redraw should start
|
||||
*/
|
||||
void lv_refr_obj(lv_draw_ctx_t * draw_ctx, lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Invalidate an area on display to redraw it
|
||||
* @param area_p pointer to area which should be invalidated (NULL: delete the invalidated areas)
|
||||
|
||||
+7
-20
@@ -29,8 +29,6 @@
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
static lv_draw_backend_t * backend_head;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
@@ -41,26 +39,15 @@ static lv_draw_backend_t * backend_head;
|
||||
|
||||
void lv_draw_init(void)
|
||||
{
|
||||
backend_head = NULL;
|
||||
lv_draw_sw_init();
|
||||
}
|
||||
|
||||
void lv_draw_backend_init(lv_draw_backend_t * backend)
|
||||
{
|
||||
lv_memset_00(backend, sizeof(lv_draw_backend_t));
|
||||
}
|
||||
|
||||
void lv_draw_backend_add(lv_draw_backend_t * backend)
|
||||
{
|
||||
backend->base = backend_head;
|
||||
backend_head = backend;
|
||||
}
|
||||
|
||||
const lv_draw_backend_t * lv_draw_backend_get(void)
|
||||
{
|
||||
return backend_head;
|
||||
// backend_head = NULL;
|
||||
// lv_draw_sw_init();
|
||||
//
|
||||
//#if LV_USE_GPU_STM32_DMA2D == 0
|
||||
// lv_gpu_stm32_dma2d_init();
|
||||
//#endif
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
|
||||
+45
-56
@@ -35,66 +35,61 @@ extern "C" {
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct _lv_draw_backend_t {
|
||||
struct _lv_draw_backend_t * base;
|
||||
|
||||
void * ctx;
|
||||
|
||||
void (*draw_rect)(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc);
|
||||
|
||||
void (*draw_arc)(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uint16_t start_angle, uint16_t end_angle,
|
||||
const lv_area_t * clip_area, const lv_draw_arc_dsc_t * dsc);
|
||||
|
||||
void (*draw_img)(const lv_area_t * map_area, const lv_area_t * clip_area,
|
||||
const uint8_t * map_p,
|
||||
const lv_draw_img_dsc_t * draw_dsc,
|
||||
bool chroma_key, bool alpha_byte);
|
||||
|
||||
lv_res_t (*draw_img_core)(const lv_area_t * coords, const lv_area_t * clip_area, const void * src,
|
||||
const lv_draw_img_dsc_t * draw_dsc);
|
||||
|
||||
void (*draw_letter)(const lv_point_t * pos_p, const lv_area_t * clip_area,
|
||||
const lv_font_t * font_p, uint32_t letter,
|
||||
lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode);
|
||||
typedef struct {
|
||||
void * user_data;
|
||||
} lv_draw_mask_t;
|
||||
|
||||
|
||||
void (*draw_line)(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip,
|
||||
const lv_draw_line_dsc_t * dsc);
|
||||
|
||||
|
||||
void (*draw_polygon)(const lv_point_t points[], uint16_t point_cnt, const lv_area_t * clip_area,
|
||||
const lv_draw_rect_dsc_t * draw_dsc);
|
||||
|
||||
typedef struct _lv_draw_ctx_t {
|
||||
/**
|
||||
* Pointer to a buffer to draw into
|
||||
*/
|
||||
void * buf;
|
||||
|
||||
/**
|
||||
* Fill an arae of a buffer with a color
|
||||
* @param dest_buf pointer to a buffer to fill
|
||||
* @param dest_stride stride of `dest_buf` (number of pixel in a line)
|
||||
* @param fill_area the area to fill on `dest_buf`
|
||||
* @param color fill color
|
||||
* @param mask NULL if ignored, or an alpha mask to apply on `fill_area`
|
||||
* @param opa overall opacity
|
||||
* @param blend_mode e.g. LV_BLEND_MODE_ADDITIVE
|
||||
* The the position and size of `buf` (absolute coordinates)
|
||||
*/
|
||||
void (*blend_fill)(lv_color_t * dest_buf, lv_coord_t dest_stride, const lv_area_t * fill_area,
|
||||
lv_color_t color, lv_opa_t * mask, lv_opa_t opa, lv_blend_mode_t blend_mode);
|
||||
lv_area_t * buf_area;
|
||||
|
||||
/**
|
||||
* Blend a source buffer to a destination buffer
|
||||
* @param dest_buf pointer to the destination buffer
|
||||
* @param dest_stride stride of `dest_buf` (number of pixel in a line)
|
||||
* @param clip_area clip the blending to this area
|
||||
* @param src_buf pointer to the destination buffer
|
||||
* @param src_area coordinates of the `src_buf` relative to the `dest_buf`
|
||||
* @param mask NULL if ignored, or an alpha mask to apply on `clip_area` (it's size is equal to the `clip_area`)
|
||||
* @param opa overall opacity
|
||||
* @param blend_mode e.g. LV_BLEND_MODE_ADDITIVE
|
||||
* The current clip area with absolute coordinates, always the same or smaller than `buf_area`
|
||||
*/
|
||||
void (*blend_map)(lv_color_t * dest_buf, lv_coord_t dest_stride, const lv_area_t * clip_area,
|
||||
const lv_color_t * src_buf, const lv_area_t * src_area,
|
||||
lv_opa_t * mask, lv_opa_t opa, lv_blend_mode_t blend_mode);
|
||||
const lv_area_t * clip_area;
|
||||
|
||||
} lv_draw_backend_t;
|
||||
|
||||
void (*draw_rect)(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_rect_dsc_t * dsc, const lv_area_t * coords);
|
||||
|
||||
void (*draw_arc)(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_arc_dsc_t * dsc, const lv_point_t * center,
|
||||
uint16_t radius, uint16_t start_angle, uint16_t end_angle);
|
||||
|
||||
void (*draw_img_decoded)(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_img_dsc_t * dsc,
|
||||
const lv_area_t * coords, const uint8_t * map_p, lv_img_cf_t color_format);
|
||||
|
||||
lv_res_t (*draw_img)(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_img_dsc_t * draw_dsc,
|
||||
const lv_area_t * coords, const void * src);
|
||||
|
||||
void (*draw_letter)(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_label_dsc_t * dsc, const lv_point_t * pos_p,
|
||||
uint32_t letter);
|
||||
|
||||
|
||||
void (*draw_line)(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_line_dsc_t * dsc, const lv_point_t * point1,
|
||||
const lv_point_t * point2);
|
||||
|
||||
|
||||
void (*draw_polygon)(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_rect_dsc_t * draw_dsc,
|
||||
const lv_point_t * points, uint16_t point_cnt);
|
||||
|
||||
/**
|
||||
* Wait until all background operation are finished. (E.g. GPU opertions)
|
||||
*/
|
||||
void (*wait_for_finish)(struct _lv_draw_ctx_t * draw);
|
||||
|
||||
#if LV_USE_USER_DATA
|
||||
void * user_data;
|
||||
#endif
|
||||
|
||||
} lv_draw_ctx_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
@@ -102,12 +97,6 @@ typedef struct _lv_draw_backend_t {
|
||||
|
||||
void lv_draw_init(void);
|
||||
|
||||
void lv_draw_backend_init(lv_draw_backend_t * backend);
|
||||
|
||||
void lv_draw_backend_add(lv_draw_backend_t * backend);
|
||||
|
||||
const lv_draw_backend_t * lv_draw_backend_get(void);
|
||||
|
||||
/**********************
|
||||
* GLOBAL VARIABLES
|
||||
**********************/
|
||||
|
||||
@@ -41,15 +41,17 @@ void lv_draw_arc_dsc_init(lv_draw_arc_dsc_t * dsc)
|
||||
dsc->color = lv_color_black();
|
||||
}
|
||||
|
||||
void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uint16_t start_angle, uint16_t end_angle,
|
||||
const lv_area_t * clip_area, const lv_draw_arc_dsc_t * dsc)
|
||||
void lv_draw_arc(lv_draw_ctx_t * draw_ctx, const lv_draw_arc_dsc_t * dsc, const lv_point_t * center, uint16_t radius,
|
||||
uint16_t start_angle, uint16_t end_angle)
|
||||
{
|
||||
if(dsc->opa <= LV_OPA_MIN) return;
|
||||
if(dsc->width == 0) return;
|
||||
if(start_angle == end_angle) return;
|
||||
|
||||
const lv_draw_backend_t * backend = lv_draw_backend_get();
|
||||
backend->draw_arc(center_x, center_y, radius, start_angle, end_angle, clip_area, dsc);
|
||||
draw_ctx->draw_arc(draw_ctx, dsc, center, radius, start_angle, end_angle);
|
||||
|
||||
// const lv_draw_backend_t * backend = lv_draw_backend_get();
|
||||
// backend->draw_arc(center_x, center_y, radius, start_angle, end_angle, clip_area, dsc);
|
||||
}
|
||||
|
||||
void lv_draw_arc_get_area(lv_coord_t x, lv_coord_t y, uint16_t radius, uint16_t start_angle, uint16_t end_angle,
|
||||
|
||||
@@ -28,12 +28,16 @@ extern "C" {
|
||||
typedef struct {
|
||||
lv_color_t color;
|
||||
lv_coord_t width;
|
||||
uint16_t start_angle;
|
||||
uint16_t end_angle;
|
||||
const void * img_src;
|
||||
lv_opa_t opa;
|
||||
lv_blend_mode_t blend_mode : 2;
|
||||
uint8_t rounded : 1;
|
||||
} lv_draw_arc_dsc_t;
|
||||
|
||||
struct _lv_draw_ctx_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
@@ -51,8 +55,8 @@ void lv_draw_arc_dsc_init(lv_draw_arc_dsc_t * dsc);
|
||||
* @param clip_area the arc will be drawn only in this area
|
||||
* @param dsc pointer to an initialized `lv_draw_line_dsc_t` variable
|
||||
*/
|
||||
void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uint16_t start_angle, uint16_t end_angle,
|
||||
const lv_area_t * clip_area, const lv_draw_arc_dsc_t * dsc);
|
||||
void lv_draw_arc(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_arc_dsc_t * dsc, const lv_point_t * center,
|
||||
uint16_t radius, uint16_t start_angle, uint16_t end_angle);
|
||||
|
||||
/**
|
||||
* Get an area the should be invalidated when the arcs angle changed between start_angle and end_ange
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
/**
|
||||
* @file lv_draw_blend.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_draw_blend.h"
|
||||
#include "lv_img_decoder.h"
|
||||
#include "../misc/lv_math.h"
|
||||
#include "../hal/lv_hal_disp.h"
|
||||
#include "../core/lv_refr.h"
|
||||
|
||||
#if LV_USE_GPU_NXP_PXP
|
||||
#include "../gpu/lv_gpu_nxp_pxp.h"
|
||||
#elif LV_USE_GPU_NXP_VG_LITE
|
||||
#include "../gpu/lv_gpu_nxp_vglite.h"
|
||||
#elif LV_USE_GPU_STM32_DMA2D
|
||||
#include "../gpu/lv_gpu_stm32_dma2d.h"
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define GPU_SIZE_LIMIT 240
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
LV_ATTRIBUTE_FAST_MEM void lv_draw_blend_fill(const lv_area_t * clip_area, const lv_area_t * fill_area,
|
||||
lv_color_t color, lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_opa_t opa,
|
||||
lv_blend_mode_t blend_mode)
|
||||
{
|
||||
/*Do not draw transparent things*/
|
||||
if(opa < LV_OPA_MIN) return;
|
||||
if(mask_res == LV_DRAW_MASK_RES_TRANSP) return;
|
||||
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask = NULL;
|
||||
|
||||
/*Get clipped fill area which is the real draw area.
|
||||
*It is always the same or inside `fill_area`*/
|
||||
lv_area_t draw_area;
|
||||
if(!_lv_area_intersect(&draw_area, clip_area, fill_area)) return;
|
||||
|
||||
lv_disp_t * disp = _lv_refr_get_disp_refreshing();
|
||||
lv_disp_draw_buf_t * draw_buf = lv_disp_get_draw_buf(disp);
|
||||
const lv_area_t * disp_area = &draw_buf->area;
|
||||
lv_color_t * disp_buf = draw_buf->buf_act;
|
||||
|
||||
/*Now `draw_area` has absolute coordinates.
|
||||
*Make it relative to `disp_area` to simplify the drawing to `disp_buf`*/
|
||||
lv_area_move(&draw_area, -disp_area->x1, -disp_area->y1);
|
||||
|
||||
lv_coord_t stride = lv_area_get_width(disp_area);
|
||||
|
||||
if(disp->driver->gpu_wait_cb) disp->driver->gpu_wait_cb(disp->driver);
|
||||
|
||||
const lv_draw_backend_t * backend = lv_draw_backend_get();
|
||||
backend->blend_fill(disp_buf, stride, &draw_area, color, mask, opa, blend_mode);
|
||||
|
||||
}
|
||||
|
||||
void lv_draw_blend_map(const lv_area_t * clip_area, const lv_area_t * map_area,
|
||||
const lv_color_t * map_buf,
|
||||
lv_opa_t * mask, lv_draw_mask_res_t mask_res,
|
||||
lv_opa_t opa, lv_blend_mode_t blend_mode)
|
||||
{
|
||||
/*Do not draw transparent things*/
|
||||
if(opa < LV_OPA_MIN) return;
|
||||
if(mask_res == LV_DRAW_MASK_RES_TRANSP) return;
|
||||
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask = NULL;
|
||||
|
||||
/*Get clipped fill area which is the real draw area.
|
||||
*It is always the same or inside `map_area`*/
|
||||
lv_area_t draw_area;
|
||||
if(!_lv_area_intersect(&draw_area, clip_area, map_area)) return;
|
||||
|
||||
lv_disp_t * disp = _lv_refr_get_disp_refreshing();
|
||||
lv_disp_draw_buf_t * draw_buf = lv_disp_get_draw_buf(disp);
|
||||
const lv_area_t * disp_area = &draw_buf->area;
|
||||
lv_color_t * buf = draw_buf->buf_act;
|
||||
|
||||
|
||||
/*Now `draw_area` has absolute coordinates.
|
||||
*Make it relative to `disp_area` to simplify draw to `disp_buf`*/
|
||||
lv_area_move(&draw_area, -disp_area->x1, -disp_area->y1);
|
||||
|
||||
lv_area_t map_area_relative;
|
||||
lv_area_copy(&map_area_relative, map_area);
|
||||
lv_area_move(&map_area_relative, -disp_area->x1, -disp_area->y1);
|
||||
|
||||
if(disp->driver->gpu_wait_cb) disp->driver->gpu_wait_cb(disp->driver);
|
||||
|
||||
lv_coord_t stride = lv_area_get_width(disp_area);
|
||||
|
||||
const lv_draw_backend_t * backend = lv_draw_backend_get();
|
||||
backend->blend_map(buf, stride, &draw_area,
|
||||
map_buf, &map_area_relative,
|
||||
mask, opa, blend_mode);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
@@ -1,72 +0,0 @@
|
||||
/**
|
||||
* @file lv_draw_blend.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_DRAW_BLEND_H
|
||||
#define LV_DRAW_BLEND_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../misc/lv_color.h"
|
||||
#include "../misc/lv_area.h"
|
||||
#include "../misc/lv_style.h"
|
||||
#include "lv_draw_mask.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Fill an area with a color in the display's draw buffer.
|
||||
* @param clip_area the current clip area (absolute coordinate)
|
||||
* @param fill_area the area to fill (absolute coordinate)
|
||||
* @param color the fill color
|
||||
* @param mask an alpha mask to apply on `fill_area` or `NULL` to simply fill. (Interpreted on the fill area)
|
||||
* @param mask_res LV_MASK_RES_COVER: the mask has only 0xff values (no mask),
|
||||
* LV_MASK_RES_TRANSP: the mask has only 0x00 values (full transparent),
|
||||
* LV_MASK_RES_CHANGED: the mask has mixed values
|
||||
* @param opa overall opacity
|
||||
* @param mode blend mode from `lv_blend_mode_t`
|
||||
*/
|
||||
void lv_draw_blend_fill(const lv_area_t * clip_area, const lv_area_t * fill_area, lv_color_t color,
|
||||
lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_opa_t opa, lv_blend_mode_t mode);
|
||||
|
||||
/**
|
||||
* Copy a source buffer to the display's draw buffer.
|
||||
* @param clip_area clip the result to this area (absolute coordinates)
|
||||
* @param src_area coordinates of the source buffer (absolute coordinates)
|
||||
* @param src_buf the source buffer
|
||||
* @param mask an alpha mask to apply on `clip_area` or `NULL` to simply fill. (Interpreted on the clip area)
|
||||
* @param mask_res LV_MASK_RES_COVER: the mask has only 0xff values (no mask),
|
||||
* LV_MASK_RES_TRANSP: the mask has only 0x00 values (full transparent),
|
||||
* LV_MASK_RES_CHANGED: the mask has mixed values
|
||||
* @param opa overall opacity in 0x00..0xff range
|
||||
* @param mode blend mode from `lv_blend_mode_t`
|
||||
*/
|
||||
void lv_draw_blend_map(const lv_area_t * clip_area, const lv_area_t * src_area,
|
||||
const lv_color_t * src_buf,
|
||||
lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_opa_t opa, lv_blend_mode_t mode);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_DRAW_BLEND_H*/
|
||||
+36
-28
@@ -25,11 +25,10 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * clip_area,
|
||||
const void * src,
|
||||
const lv_draw_img_dsc_t * draw_dsc);
|
||||
LV_ATTRIBUTE_FAST_MEM static lv_res_t decode_and_draw(lv_draw_ctx_t * draw_ctx, const lv_draw_img_dsc_t * draw_dsc,
|
||||
const lv_area_t * coords, const void * src);
|
||||
|
||||
static void show_error(const lv_area_t * coords, const lv_area_t * clip_area, const char * msg);
|
||||
static void show_error(lv_draw_ctx_t * draw_ctx, const lv_area_t * coords, const char * msg);
|
||||
static void draw_cleanup(_lv_img_cache_entry_t * cache);
|
||||
|
||||
/**********************
|
||||
@@ -60,29 +59,27 @@ void lv_draw_img_dsc_init(lv_draw_img_dsc_t * dsc)
|
||||
* @param src pointer to a lv_color_t array which contains the pixels of the image
|
||||
* @param dsc pointer to an initialized `lv_draw_img_dsc_t` variable
|
||||
*/
|
||||
void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * src, const lv_draw_img_dsc_t * dsc)
|
||||
void lv_draw_img(lv_draw_ctx_t * draw_ctx, const lv_draw_img_dsc_t * dsc, const lv_area_t * coords, const void * src)
|
||||
{
|
||||
if(src == NULL) {
|
||||
LV_LOG_WARN("Image draw: src is NULL");
|
||||
show_error(coords, mask, "No\ndata");
|
||||
show_error(draw_ctx, coords, "No\ndata");
|
||||
return;
|
||||
}
|
||||
|
||||
if(dsc->opa <= LV_OPA_MIN) return;
|
||||
|
||||
const lv_draw_backend_t * backend = lv_draw_backend_get();
|
||||
|
||||
lv_res_t res;
|
||||
if(backend->draw_img_core) {
|
||||
res = backend->draw_img_core(coords, mask, src, dsc);
|
||||
if(draw_ctx->draw_img) {
|
||||
res = draw_ctx->draw_img(draw_ctx, dsc, coords, src);
|
||||
}
|
||||
else {
|
||||
res = lv_img_draw_core(coords, mask, src, dsc);
|
||||
res = decode_and_draw(draw_ctx, dsc, coords, src);
|
||||
}
|
||||
|
||||
if(res == LV_RES_INV) {
|
||||
LV_LOG_WARN("Image draw error");
|
||||
show_error(coords, mask, "No\ndata");
|
||||
show_error(draw_ctx, coords, "No\ndata");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -222,13 +219,20 @@ lv_img_src_t lv_img_src_get_type(const void * src)
|
||||
return img_src_type;
|
||||
}
|
||||
|
||||
void lv_draw_img_decoded(lv_draw_ctx_t * draw_ctx, const lv_draw_img_dsc_t * dsc,
|
||||
const lv_area_t * coords, const uint8_t * map_p, lv_img_cf_t color_format)
|
||||
{
|
||||
if(draw_ctx->draw_img_decoded == NULL) return;
|
||||
|
||||
draw_ctx->draw_img_decoded(draw_ctx, dsc, coords, map_p, color_format);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * clip_area,
|
||||
const void * src,
|
||||
const lv_draw_img_dsc_t * draw_dsc)
|
||||
LV_ATTRIBUTE_FAST_MEM static lv_res_t decode_and_draw(lv_draw_ctx_t * draw_ctx, const lv_draw_img_dsc_t * draw_dsc,
|
||||
const lv_area_t * coords, const void * src)
|
||||
{
|
||||
if(draw_dsc->opa <= LV_OPA_MIN) return LV_RES_OK;
|
||||
|
||||
@@ -237,14 +241,15 @@ LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords,
|
||||
if(cdsc == NULL) return LV_RES_INV;
|
||||
|
||||
|
||||
const lv_draw_backend_t * backend = lv_draw_backend_get();
|
||||
bool chroma_keyed = lv_img_cf_is_chroma_keyed(cdsc->dec_dsc.header.cf);
|
||||
bool alpha_byte = lv_img_cf_has_alpha(cdsc->dec_dsc.header.cf);
|
||||
lv_img_cf_t cf;
|
||||
if(lv_img_cf_is_chroma_keyed(cdsc->dec_dsc.header.cf)) cf = LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED;
|
||||
else if(lv_img_cf_has_alpha(cdsc->dec_dsc.header.cf)) cf = LV_IMG_CF_TRUE_COLOR_ALPHA;
|
||||
else cf = LV_IMG_CF_TRUE_COLOR;
|
||||
|
||||
if(cdsc->dec_dsc.error_msg != NULL) {
|
||||
LV_LOG_WARN("Image draw error");
|
||||
|
||||
show_error(coords, clip_area, cdsc->dec_dsc.error_msg);
|
||||
show_error(draw_ctx, coords, cdsc->dec_dsc.error_msg);
|
||||
}
|
||||
/*The decoder could open the image and gave the entire uncompressed image.
|
||||
*Just draw it!*/
|
||||
@@ -263,22 +268,25 @@ LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords,
|
||||
map_area_rot.y2 += coords->y1;
|
||||
}
|
||||
|
||||
lv_area_t mask_com; /*Common area of mask and coords*/
|
||||
lv_area_t clip_com; /*Common area of mask and coords*/
|
||||
bool union_ok;
|
||||
union_ok = _lv_area_intersect(&mask_com, clip_area, &map_area_rot);
|
||||
union_ok = _lv_area_intersect(&clip_com, draw_ctx->clip_area, &map_area_rot);
|
||||
/*Out of mask. There is nothing to draw so the image is drawn successfully.*/
|
||||
if(union_ok == false) {
|
||||
draw_cleanup(cdsc);
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
backend->draw_img(coords, &mask_com, cdsc->dec_dsc.img_data, draw_dsc, chroma_keyed, alpha_byte);
|
||||
const lv_area_t * clip_area_ori = draw_ctx->clip_area;
|
||||
draw_ctx->clip_area = &clip_com;
|
||||
lv_draw_img_decoded(draw_ctx, draw_dsc, coords, cdsc->dec_dsc.img_data, cf);
|
||||
draw_ctx->clip_area = clip_area_ori;
|
||||
}
|
||||
/*The whole uncompressed image is not available. Try to read it line-by-line*/
|
||||
else {
|
||||
lv_area_t mask_com; /*Common area of mask and coords*/
|
||||
bool union_ok;
|
||||
union_ok = _lv_area_intersect(&mask_com, clip_area, coords);
|
||||
union_ok = _lv_area_intersect(&mask_com, draw_ctx->clip_area, coords);
|
||||
/*Out of mask. There is nothing to draw so the image is drawn successfully.*/
|
||||
if(union_ok == false) {
|
||||
draw_cleanup(cdsc);
|
||||
@@ -299,7 +307,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords,
|
||||
lv_res_t read_res;
|
||||
for(row = mask_com.y1; row <= mask_com.y2; row++) {
|
||||
lv_area_t mask_line;
|
||||
union_ok = _lv_area_intersect(&mask_line, clip_area, &line);
|
||||
union_ok = _lv_area_intersect(&mask_line, draw_ctx->clip_area, &line);
|
||||
if(union_ok == false) continue;
|
||||
|
||||
read_res = lv_img_decoder_read_line(&cdsc->dec_dsc, x, y, width, buf);
|
||||
@@ -311,7 +319,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords,
|
||||
return LV_RES_INV;
|
||||
}
|
||||
|
||||
backend->draw_img(&line, &mask_line, buf, draw_dsc, chroma_keyed, alpha_byte);
|
||||
lv_draw_img_decoded(draw_ctx, draw_dsc, &line, buf, cf);
|
||||
line.y1++;
|
||||
line.y2++;
|
||||
y++;
|
||||
@@ -324,16 +332,16 @@ LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords,
|
||||
}
|
||||
|
||||
|
||||
static void show_error(const lv_area_t * coords, const lv_area_t * clip_area, const char * msg)
|
||||
static void show_error(lv_draw_ctx_t * draw_ctx, const lv_area_t * coords, const char * msg)
|
||||
{
|
||||
lv_draw_rect_dsc_t rect_dsc;
|
||||
lv_draw_rect_dsc_init(&rect_dsc);
|
||||
rect_dsc.bg_color = lv_color_white();
|
||||
lv_draw_rect(coords, clip_area, &rect_dsc);
|
||||
lv_draw_rect(draw_ctx, &rect_dsc, coords);
|
||||
|
||||
lv_draw_label_dsc_t label_dsc;
|
||||
lv_draw_label_dsc_init(&label_dsc);
|
||||
lv_draw_label(coords, clip_area, &label_dsc, msg, NULL);
|
||||
lv_draw_label(draw_ctx, &label_dsc, coords, msg, NULL);
|
||||
}
|
||||
|
||||
static void draw_cleanup(_lv_img_cache_entry_t * cache)
|
||||
|
||||
@@ -45,6 +45,8 @@ typedef struct {
|
||||
uint8_t antialias : 1;
|
||||
} lv_draw_img_dsc_t;
|
||||
|
||||
struct _lv_draw_ctx_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
@@ -57,7 +59,12 @@ void lv_draw_img_dsc_init(lv_draw_img_dsc_t * dsc);
|
||||
* @param src pointer to a lv_color_t array which contains the pixels of the image
|
||||
* @param dsc pointer to an initialized `lv_draw_img_dsc_t` variable
|
||||
*/
|
||||
void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * src, const lv_draw_img_dsc_t * dsc);
|
||||
void lv_draw_img(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_img_dsc_t * dsc, const lv_area_t * coords,
|
||||
const void * src);
|
||||
|
||||
|
||||
void lv_draw_img_decoded(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_img_dsc_t * dsc,
|
||||
const lv_area_t * coords, const uint8_t * map_p, lv_img_cf_t color_format);
|
||||
|
||||
/**
|
||||
* Get the type of an image source
|
||||
|
||||
+30
-22
@@ -74,12 +74,22 @@ void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc)
|
||||
* @param hint pointer to a `lv_draw_label_hint_t` variable.
|
||||
* It is managed by the draw to speed up the drawing of very long texts (thousands of lines).
|
||||
*/
|
||||
LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask,
|
||||
const lv_draw_label_dsc_t * dsc,
|
||||
const char * txt,
|
||||
lv_draw_label_hint_t * hint)
|
||||
LV_ATTRIBUTE_FAST_MEM void lv_draw_label(lv_draw_ctx_t * draw_ctx, const lv_draw_label_dsc_t * dsc,
|
||||
const lv_area_t * coords, const char * txt, lv_draw_label_hint_t * hint)
|
||||
{
|
||||
if(dsc->opa <= LV_OPA_MIN) return;
|
||||
if(dsc->font == NULL) {
|
||||
LV_LOG_WARN("dsc->font == NULL");
|
||||
return;
|
||||
}
|
||||
|
||||
if(draw_ctx->draw_letter == NULL) {
|
||||
LV_LOG_WARN("draw->draw_letter == NULL (there is no function to draw letters)");
|
||||
return;
|
||||
}
|
||||
|
||||
lv_draw_label_dsc_t dsc_mod = *dsc;
|
||||
|
||||
const lv_font_t * font = dsc->font;
|
||||
int32_t w;
|
||||
|
||||
@@ -88,7 +98,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
||||
return;
|
||||
|
||||
lv_area_t clipped_area;
|
||||
bool clip_ok = _lv_area_intersect(&clipped_area, coords, mask);
|
||||
bool clip_ok = _lv_area_intersect(&clipped_area, coords, draw_ctx->clip_area);
|
||||
if(!clip_ok) return;
|
||||
|
||||
lv_text_align_t align = dsc->align;
|
||||
@@ -144,7 +154,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
||||
uint32_t line_end = line_start + _lv_txt_get_next_line(&txt[line_start], font, dsc->letter_space, w, NULL, dsc->flag);
|
||||
|
||||
/*Go the first visible line*/
|
||||
while(pos.y + line_height_font < mask->y1) {
|
||||
while(pos.y + line_height_font < draw_ctx->clip_area->y1) {
|
||||
/*Go to next line*/
|
||||
line_start = line_end;
|
||||
line_end += _lv_txt_get_next_line(&txt[line_start], font, dsc->letter_space, w, NULL, dsc->flag);
|
||||
@@ -172,9 +182,6 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
||||
line_width = lv_txt_get_width(&txt[line_start], line_end - line_start, font, dsc->letter_space, dsc->flag);
|
||||
pos.x += lv_area_get_width(coords) - line_width;
|
||||
}
|
||||
|
||||
lv_opa_t opa = dsc->opa;
|
||||
|
||||
uint32_t sel_start = dsc->sel_start;
|
||||
uint32_t sel_end = dsc->sel_end;
|
||||
if(sel_start > sel_end) {
|
||||
@@ -196,6 +203,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
||||
uint32_t i;
|
||||
uint32_t par_start = 0;
|
||||
lv_color_t recolor;
|
||||
lv_color_t color = lv_color_black();
|
||||
int32_t letter_w;
|
||||
|
||||
lv_draw_rect_dsc_t draw_dsc_sel;
|
||||
@@ -272,7 +280,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
||||
}
|
||||
}
|
||||
|
||||
lv_color_t color = dsc->color;
|
||||
color = dsc->color;
|
||||
|
||||
if(cmd_state == CMD_STATE_IN) color = recolor;
|
||||
|
||||
@@ -285,12 +293,13 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
||||
sel_coords.y1 = pos.y;
|
||||
sel_coords.x2 = pos.x + letter_w + dsc->letter_space - 1;
|
||||
sel_coords.y2 = pos.y + line_height - 1;
|
||||
lv_draw_rect(&sel_coords, mask, &draw_dsc_sel);
|
||||
lv_draw_rect(draw_ctx, &draw_dsc_sel, &sel_coords);
|
||||
color = dsc->sel_color;
|
||||
}
|
||||
}
|
||||
|
||||
lv_draw_letter(&pos, mask, font, letter, color, opa, dsc->blend_mode);
|
||||
dsc_mod.color = color;
|
||||
lv_draw_letter(draw_ctx, &dsc_mod, &pos, letter);
|
||||
|
||||
if(letter_w > 0) {
|
||||
pos.x += letter_w + dsc->letter_space;
|
||||
@@ -304,7 +313,8 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
||||
p1.y = pos.y + (dsc->font->line_height / 2) + line_dsc.width / 2;
|
||||
p2.x = pos.x;
|
||||
p2.y = p1.y;
|
||||
lv_draw_line(&p1, &p2, mask, &line_dsc);
|
||||
line_dsc.color = color;
|
||||
lv_draw_line(draw_ctx, &line_dsc, &p1, &p2);
|
||||
}
|
||||
|
||||
if(dsc->decor & LV_TEXT_DECOR_UNDERLINE) {
|
||||
@@ -314,7 +324,8 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
||||
p1.y = pos.y + dsc->font->line_height - dsc->font->base_line - font->underline_position;
|
||||
p2.x = pos.x;
|
||||
p2.y = p1.y;
|
||||
lv_draw_line(&p1, &p2, mask, &line_dsc);
|
||||
line_dsc.color = color;
|
||||
lv_draw_line(draw_ctx, &line_dsc, &p1, &p2);
|
||||
}
|
||||
|
||||
#if LV_USE_BIDI
|
||||
@@ -344,22 +355,19 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
||||
/*Go the next line position*/
|
||||
pos.y += line_height;
|
||||
|
||||
if(pos.y > mask->y2) return;
|
||||
if(pos.y > draw_ctx->clip_area->y2) return;
|
||||
}
|
||||
|
||||
LV_ASSERT_MEM_INTEGRITY();
|
||||
}
|
||||
|
||||
void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * clip_area,
|
||||
const lv_font_t * font_p,
|
||||
uint32_t letter,
|
||||
lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode)
|
||||
void lv_draw_letter(lv_draw_ctx_t * draw_ctx, const lv_draw_label_dsc_t * dsc, const lv_point_t * pos_p,
|
||||
uint32_t letter)
|
||||
{
|
||||
|
||||
const lv_draw_backend_t * backend = lv_draw_backend_get();
|
||||
backend->draw_letter(pos_p, clip_area, font_p, letter, color, opa, blend_mode);
|
||||
draw_ctx->draw_letter(draw_ctx, dsc, pos_p, letter);
|
||||
}
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
@@ -63,6 +63,7 @@ typedef struct _lv_draw_label_hint_t {
|
||||
int32_t coord_y;
|
||||
} lv_draw_label_hint_t;
|
||||
|
||||
struct _lv_draw_ctx_t;
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
@@ -78,14 +79,12 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc);
|
||||
* @param hint pointer to a `lv_draw_label_hint_t` variable.
|
||||
* It is managed by the draw to speed up the drawing of very long texts (thousands of lines).
|
||||
*/
|
||||
LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask,
|
||||
const lv_draw_label_dsc_t * dsc,
|
||||
const char * txt, lv_draw_label_hint_t * hint);
|
||||
LV_ATTRIBUTE_FAST_MEM void lv_draw_label(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_label_dsc_t * dsc,
|
||||
const lv_area_t * coords, const char * txt, lv_draw_label_hint_t * hint);
|
||||
|
||||
void lv_draw_letter(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_label_dsc_t * dsc, const lv_point_t * pos_p,
|
||||
uint32_t letter);
|
||||
|
||||
void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * clip_area,
|
||||
const lv_font_t * font_p,
|
||||
uint32_t letter,
|
||||
lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode);
|
||||
/***********************
|
||||
* GLOBAL VARIABLES
|
||||
***********************/
|
||||
|
||||
@@ -42,14 +42,13 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc)
|
||||
dsc->color = lv_color_black();
|
||||
}
|
||||
|
||||
LV_ATTRIBUTE_FAST_MEM void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip,
|
||||
const lv_draw_line_dsc_t * dsc)
|
||||
LV_ATTRIBUTE_FAST_MEM void lv_draw_line(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_line_dsc_t * dsc,
|
||||
const lv_point_t * point1, const lv_point_t * point2)
|
||||
{
|
||||
if(dsc->width == 0) return;
|
||||
if(dsc->opa <= LV_OPA_MIN) return;
|
||||
|
||||
const lv_draw_backend_t * backend = lv_draw_backend_get();
|
||||
backend->draw_line(point1, point2, clip, dsc);
|
||||
draw_ctx->draw_line(draw_ctx, dsc, point1, point2);
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
||||
@@ -37,6 +37,8 @@ typedef struct {
|
||||
uint8_t raw_end : 1; /*Do not bother with perpendicular line ending if it's not visible for any reason*/
|
||||
} lv_draw_line_dsc_t;
|
||||
|
||||
struct _lv_draw_ctx_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
@@ -50,8 +52,8 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc);
|
||||
* @param clip the line will be drawn only in this area
|
||||
* @param dsc pointer to an initialized `lv_draw_line_dsc_t` variable
|
||||
*/
|
||||
LV_ATTRIBUTE_FAST_MEM void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip,
|
||||
const lv_draw_line_dsc_t * dsc);
|
||||
void lv_draw_line(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_line_dsc_t * dsc, const lv_point_t * point1,
|
||||
const lv_point_t * point2);
|
||||
|
||||
|
||||
/**********************
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_draw_sw.h"
|
||||
#include "lv_draw.h"
|
||||
#if LV_DRAW_COMPLEX
|
||||
#include "../../misc/lv_math.h"
|
||||
#include "../../misc/lv_log.h"
|
||||
#include "../../misc/lv_assert.h"
|
||||
#include "../../misc/lv_gc.h"
|
||||
#include "../misc/lv_math.h"
|
||||
#include "../misc/lv_log.h"
|
||||
#include "../misc/lv_assert.h"
|
||||
#include "../misc/lv_gc.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -57,13 +57,11 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc)
|
||||
* @param mask the rectangle will be drawn only in this mask
|
||||
* @param dsc pointer to an initialized `lv_draw_rect_dsc_t` variable
|
||||
*/
|
||||
void lv_draw_rect(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc)
|
||||
void lv_draw_rect(lv_draw_ctx_t * draw_ctx, const lv_draw_rect_dsc_t * dsc, const lv_area_t * coords)
|
||||
{
|
||||
if(lv_area_get_height(coords) < 1 || lv_area_get_width(coords) < 1) return;
|
||||
|
||||
|
||||
const lv_draw_backend_t * backend = lv_draw_backend_get();
|
||||
backend->draw_rect(coords, clip, dsc);
|
||||
draw_ctx->draw_rect(draw_ctx, dsc, coords);
|
||||
|
||||
LV_ASSERT_MEM_INTEGRITY();
|
||||
}
|
||||
|
||||
@@ -70,6 +70,8 @@ typedef struct {
|
||||
lv_opa_t shadow_opa;
|
||||
} lv_draw_rect_dsc_t;
|
||||
|
||||
struct _lv_draw_ctx_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
@@ -83,7 +85,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc);
|
||||
* @param clip the rectangle will be drawn only in this area
|
||||
* @param dsc pointer to an initialized `lv_draw_rect_dsc_t` variable
|
||||
*/
|
||||
void lv_draw_rect(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc);
|
||||
void lv_draw_rect(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_rect_dsc_t * dsc, const lv_area_t * coords);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
||||
@@ -35,27 +35,16 @@
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Draw a polygon. Only convex polygons are supported
|
||||
* @param points an array of points
|
||||
* @param point_cnt number of points
|
||||
* @param clip_area polygon will be drawn only in this area
|
||||
* @param draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable
|
||||
*/
|
||||
void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_area_t * clip_area,
|
||||
const lv_draw_rect_dsc_t * draw_dsc)
|
||||
void lv_draw_polygon(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_rect_dsc_t * draw_dsc, const lv_point_t points[],
|
||||
uint16_t point_cnt)
|
||||
{
|
||||
|
||||
const lv_draw_backend_t * backend = lv_draw_backend_get();
|
||||
backend->draw_polygon(points, point_cnt, clip_area, draw_dsc);
|
||||
draw_ctx->draw_polygon(draw_ctx, draw_dsc, points, point_cnt);
|
||||
}
|
||||
|
||||
void lv_draw_triangle(const lv_point_t points[], const lv_area_t * clip_area,
|
||||
const lv_draw_rect_dsc_t * draw_dsc)
|
||||
void lv_draw_triangle(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_rect_dsc_t * draw_dsc, const lv_point_t points[])
|
||||
{
|
||||
|
||||
const lv_draw_backend_t * backend = lv_draw_backend_get();
|
||||
backend->draw_polygon(points, 3, clip_area, draw_dsc);
|
||||
draw_ctx->draw_polygon(draw_ctx, draw_dsc, points, 3);
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user