|
|
@@ -1113,8 +1113,11 @@ NVGcontext* nvgCreateVGLite(uint32_t w, uint32_t h, uint32_t stride, enum NVGtex
|
|
|
|
|
|
ctx = nvgCreateInternal(¶ms);
|
|
|
if (ctx == NULL) goto error;
|
|
|
-
|
|
|
- nvgInitVGL(ctx, ¶ms, w, h, stride, format, data);
|
|
|
+ static int vglite_init_flag = 0;
|
|
|
+ if (vglite_init_flag == 0) {
|
|
|
+ vglite_init_flag = 1;
|
|
|
+ nvgInitVGL(ctx, ¶ms, w, h, stride, format, data);
|
|
|
+ }
|
|
|
|
|
|
printf("VGLite init success\r\n");
|
|
|
|
|
|
@@ -1467,7 +1470,7 @@ static uint32_t get_vglite_vertor_font(stbtt_vertex* vertices, int num_vertices)
|
|
|
dataSize *= 2;
|
|
|
|
|
|
if (dataSize > PATH_MAX_SIZE) {
|
|
|
- printf("font lib number over limit, plz defind FONT_LIB_COUNT\n");
|
|
|
+ printf("PATH_MAX_SIZE font path to long, num_vertices = %d,dataSize = %d \r\n\n", num_vertices, dataSize);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
@@ -1527,7 +1530,8 @@ static uint32_t get_vglite_vertor_font(stbtt_vertex* vertices, int num_vertices)
|
|
|
return dataSize;
|
|
|
}
|
|
|
|
|
|
-void vglite_draw_glyph_truetype(stbtt_fontinfo* sf, wchar_t chr, const rect_t* dst, rect_t* r, float_t scale, float tx, float ty, vg_lite_color_t color) {
|
|
|
+void vglite_draw_glyph_truetype(stbtt_fontinfo* sf, wchar_t chr, const rect_t* dst, rect_t* r, float_t scale, float tx, float ty,
|
|
|
+ vg_lite_color_t color, uint8_t global_alpha) {
|
|
|
int glyphIndex, num_vertices;
|
|
|
stbtt_vertex* vertices;
|
|
|
vg_lite_error_t error;
|
|
|
@@ -1535,7 +1539,7 @@ void vglite_draw_glyph_truetype(stbtt_fontinfo* sf, wchar_t chr, const rect_t* d
|
|
|
vg_lite_path_t pathx = {0};
|
|
|
vg_lite_matrix_t matrix = {0};
|
|
|
uint32_t bounds[4] = {dst->x, dst->y - dst->h, dst->w, dst->y};
|
|
|
- int32_t x0,x1,y0,y1;
|
|
|
+ int32_t x0, x1, y0, y1;
|
|
|
uint32_t start_address, rt_pixsize, dataSize = 0, vertFlag = 0;
|
|
|
void* tempData;
|
|
|
vg_lite_enable_scissor();
|
|
|
@@ -1566,6 +1570,9 @@ void vglite_draw_glyph_truetype(stbtt_fontinfo* sf, wchar_t chr, const rect_t* d
|
|
|
num_vertices = stbtt_GetGlyphShape(sf, glyphIndex, &vertices);
|
|
|
vertFlag = 1;
|
|
|
dataSize = get_vglite_vertor_font(vertices, num_vertices);
|
|
|
+ if (dataSize <= 0) {
|
|
|
+ printf("dataSize %d,glyphIndex:%d,chr:%lc\r\n", (uint32_t)tempData, glyphIndex, chr);
|
|
|
+ }
|
|
|
#ifdef VGLITE_FONT_CACHE
|
|
|
#ifndef FONT_CACHE_CH
|
|
|
if (charFlag)
|
|
|
@@ -1594,6 +1601,11 @@ void vglite_draw_glyph_truetype(stbtt_fontinfo* sf, wchar_t chr, const rect_t* d
|
|
|
start_address = rt->address + bounds[1] * rt->stride + bounds[0] * rt_pixsize;
|
|
|
ark_g2d_invalidate_cache(start_address, bounds[2], bounds[3], rt->stride, rt_pixsize);
|
|
|
vg_lite_set_draw_path_type(&pathx, VG_LITE_DRAW_FILL_PATH);
|
|
|
+
|
|
|
+ if (global_alpha != 0xFF) {
|
|
|
+ uint32_t alpha_ch = (((color >> 24) * global_alpha) >> 8) << 24;
|
|
|
+ color = color & 0x00FFFFFF | alpha_ch;
|
|
|
+ }
|
|
|
CHECK_ERROR(vg_lite_draw(rt, &pathx, VG_LITE_FILL_NON_ZERO, &matrix, VG_LITE_BLEND_SRC_OVER, color));
|
|
|
CHECK_ERROR(vg_lite_flush());
|
|
|
vg_lite_clear_path(&pathx);
|
|
|
@@ -1636,3 +1648,36 @@ void vglite_draw_dash_line(vgcanvas_t* vg, float_t* pts, uint32_t data_size, col
|
|
|
vg_lite_clear_path(&pathx);
|
|
|
vg_lite_disable_scissor();
|
|
|
}
|
|
|
+
|
|
|
+static int clear_alpha_flag = 0;
|
|
|
+// clear_alpha_flag:
|
|
|
+// 0 - Disable alpha clear
|
|
|
+// 1 - Enable alpha clear
|
|
|
+// Set clear_alpha_flag
|
|
|
+int lcd_set_clear_alpha(int clear_alpha_value) {
|
|
|
+ clear_alpha_flag = clear_alpha_value;
|
|
|
+ return clear_alpha_flag;
|
|
|
+}
|
|
|
+
|
|
|
+// Get clear_alpha_flag
|
|
|
+int lcd_get_clear_alpha(void) {
|
|
|
+ return clear_alpha_flag;
|
|
|
+}
|
|
|
+
|
|
|
+// x, y, w, h:
|
|
|
+// Rectangle position and size
|
|
|
+// color:
|
|
|
+// Clear color.
|
|
|
+// Use 0x00000000 to clear the region with full transparency.
|
|
|
+void vg_lite_clear_rect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color) {
|
|
|
+ vg_lite_rectangle_t dstRect = {x, y, w, h};
|
|
|
+ vg_lite_color_t vg_color = color;
|
|
|
+ vg_lite_buffer_t* rt;
|
|
|
+ ret_t ret;
|
|
|
+ rt = (vg_lite_buffer_t*)vglite_get_render_target();
|
|
|
+ if (!rt) {
|
|
|
+ printf("rt not found, %d\r\n", __LINE__);
|
|
|
+ }
|
|
|
+ vg_lite_clear(rt, &dstRect, vg_color);
|
|
|
+ vg_lite_finish();
|
|
|
+}
|