Bläddra i källkod

更新CPU工程中的awtk库文件
1.关闭矢量字体缓存,需要时可通过宏定义自行打开。
2.添加VGLite超时自动复位机制。

helen 1 månad sedan
förälder
incheckning
5238bc5dc7

+ 21 - 32
amt630hv160-freertos-beta/lib/awtk/awtk/3rd/vglite/nanovg_vglite.h

@@ -1,5 +1,3 @@
-/* this file is only on purpose of store a structure which wrap NVGcontext into VGLcontext,
-	and let every source file to include this file to retain this structure.*/
 
 BEGIN_C_DECLS
 #include "vg_lite.h"
@@ -8,47 +6,38 @@ BEGIN_C_DECLS
 #define __func__ __FUNCTION__
 
 /*vg lite gpu use vg_lite_color_t as default color format, which is in sequence of ABGR*/
-#define RGBA2ABGR(x) (((uint32_t)(x.a*255))<<24|((uint32_t)(x.b*255))<<16|((uint32_t)(x.g*255))<<8|((uint32_t)(x.r*255)))
-#define RGBA2ARGB(x) (((uint32_t)(x.a*255))<<24|((uint32_t)(x.r*255))<<16|((uint32_t)(x.g*255))<<8|((uint32_t)(x.b*255)))
-
-static char *error_type[] =
-{
-	"VG_LITE_SUCCESS",
-	"VG_LITE_INVALID_ARGUMENT",
-	"VG_LITE_OUT_OF_MEMORY",
-	"VG_LITE_NO_CONTEXT",
-	"VG_LITE_TIMEOUT",
-	"VG_LITE_OUT_OF_RESOURCES",
-	"VG_LITE_GENERIC_IO",
-	"VG_LITE_NOT_SUPPORT",
+#define RGBA2ABGR(x) (((uint32_t)(x.a * 255)) << 24 | ((uint32_t)(x.b * 255)) << 16 | ((uint32_t)(x.g * 255)) << 8 | ((uint32_t)(x.r * 255)))
+#define RGBA2ARGB(x) (((uint32_t)(x.a * 255)) << 24 | ((uint32_t)(x.r * 255)) << 16 | ((uint32_t)(x.g * 255)) << 8 | ((uint32_t)(x.b * 255)))
+
+static char* error_type[] = {
+	"VG_LITE_SUCCESS", "VG_LITE_INVALID_ARGUMENT", "VG_LITE_OUT_OF_MEMORY", "VG_LITE_NO_CONTEXT",
+	"VG_LITE_TIMEOUT", "VG_LITE_OUT_OF_RESOURCES", "VG_LITE_GENERIC_IO",	"VG_LITE_NOT_SUPPORT",
 };
 
-#define IS_ERROR(status)         (status > 0)
-#define CHECK_ERROR(Function) \
-    error = Function; \
-    if (IS_ERROR(error)) \
-    { \
-        printf("[%s: %d] failed.error type is %s\n", __func__, __LINE__,error_type[error]);\
-    }
+#define IS_ERROR(status) (status > 0)
+#define CHECK_ERROR(Function)                                                                \
+	error = Function;                                                                        \
+	if (IS_ERROR(error)) {                                                                   \
+		printf("[%s: %d] failed.error type is %s\n", __func__, __LINE__, error_type[error]); \
+		vglite_restart();                                                                    \
+	}
 
-typedef struct _VGLcontext{
-	void* abc;
-	}VGLcontext;
+void vglite_restart();
 
-vg_lite_buffer_t* vglite_offlinefb_wrapper( uint8_t* offline_fb);
+vg_lite_buffer_t* vglite_offlinefb_wrapper(uint8_t* offline_fb);
 
 int vglite_global_orientation_caller(void);
 
-vg_lite_buffer_t *vglite_get_render_target();
+vg_lite_buffer_t* vglite_get_render_target();
 
-vg_lite_buffer_t *vglite_get_g2dfb(void);
+vg_lite_buffer_t* vglite_get_g2dfb(void);
 
-void *vglite_get_path_cache(void);
+void* vglite_get_path_cache(void);
 
-vg_lite_buffer_t *vglite_get_imgfb(uint8_t* address, uint32_t width, uint32_t height, uint32_t stride, vg_lite_buffer_format_t format);
+vg_lite_buffer_t* vglite_get_imgfb(uint8_t* address, uint32_t width, uint32_t height, uint32_t stride, vg_lite_buffer_format_t format);
 
-int vglite_set_image(vg_lite_buffer_t *buffer, uint8_t *imm_array, int32_t width, int32_t height, int32_t stride, vg_lite_buffer_format_t format);
+int vglite_set_image(vg_lite_buffer_t* buffer, uint8_t* imm_array, int32_t width, int32_t height, int32_t stride, vg_lite_buffer_format_t format);
 
-void vglite_buffer_wrapper(vg_lite_buffer_t *buffer, uint32_t address, int32_t width, int32_t height, int32_t stride,		vg_lite_buffer_format_t format);
+void vglite_buffer_wrapper(vg_lite_buffer_t* buffer, uint32_t address, int32_t width, int32_t height, int32_t stride, vg_lite_buffer_format_t format);
 
 END_C_DECLS

+ 31 - 16
amt630hv160-freertos-beta/lib/awtk/awtk/3rd/vglite/vgcanvas_nanovg_vglite.c

@@ -27,39 +27,47 @@
 
 #ifdef VGLITE_FONT
 
-/* undefine this macro VGLITE_FONT_CACHE to disable font cache */
-#define VGLITE_FONT_CACHE
+/*
+ * Font Cache Mechanism (not enabled by default):
+ * Here defines the macros which control the font cache mechanism. Detail as follows:
+ *
+ * 1.VGLITE_FONT_CACHE: enable font cache for English characters. Undefined by default.
+ *
+ * 2.FONT_CACHE_CH: enable font cache for all characters, which maximal amount is limited 
+ * by FONT_CACHE_SIZE,need to define VGLITE_FONT_CACHE and FONT_CACHE_CH together.
+ *
+ * 3.FONT_LIB_COUNT: the font files(.ttf) reserved in cache, increase this value 
+ * lead to more memory usage, define as 16 by default.
+ * Note: to decrease memory usage and improve performance, define FONT_LIB_COUNT as the number of font files(.ttf)
+ *
+ * 4.FONT_CACHE_SIZE: cache slots reserved for data of fonts, define as 100 by default, 
+ * please defined FONT_CACHE_SIZE manually if not enough. 
+ * Note: increasing this number will increase the memory usage, and may lead to decrease in efficiency.
+ *
+ */
+
+// #define VGLITE_FONT_CACHE
+// #define FONT_CACHE_CH
+
 #ifndef FONT_SIZE
 #define FONT_SIZE_MAX 4096
 #endif /* FONT_SIZE */
 
-/* if FONT_CACHE_CH is not defined, only load char between 0x7E and 0x20 in
- * cache, otherwise, load all font used */
-#define FONT_CACHE_CH
-
 #ifdef VGLITE_FONT_CACHE
 #ifndef FONT_CACHE_SIZE
-
 #ifndef FONT_LIB_COUNT
-/* if numbern of font files(.ttf) include in app resource is more than 5,
- * please define FONT_LIB_COUNT as the correct amount of font files */
-#define FONT_LIB_COUNT 5
+#define FONT_LIB_COUNT 16
 #endif /* FONT_LIB_COUNT */
 
 #define FONT_CACHE_OFFSET (0x7E - 0x20 + 1)
 #ifndef FONT_CACHE_CH
 #define FONT_CACHE_SIZE (FONT_CACHE_OFFSET * FONT_LIB_COUNT)
 #else
-
-/* 100 cache slots were reserved by default for data of fonts, please defined
- * FONT_CACHE_SIZE manually if not enough. However, increasing this size is not
- * recommand, which will lead to a decrease in efficiency.
- * Consider to undifine FONT_CACHE_CH when enconter this issue. */
 #ifndef FONT_CACHE_SIZE
 #define FONT_CACHE_SIZE 100
 #endif
-
 #endif /* FONT_CACHE_CH */
+
 #endif /* FONT_CACHE_SIZE */
 #endif /* VGLITE_FONT_CACHE */
 #endif /* VGLITE_FONT */
@@ -128,6 +136,13 @@ void vglite_cleanup(void) {
 	vg_lite_close();
 }
 
+void vglite_restart() {
+	printf("vg_lite restart..");
+	vg_lite_close();
+	vg_lite_init(TS_WIDTH, TS_HEIGHT);
+	printf("done\n");
+}
+
 void convert_nvg_matrix_to_vgl(float* nvg_matrix, vg_lite_matrix_t* matrix) {
 	matrix->m[0][0] = nvg_matrix[0];
 	matrix->m[0][1] = nvg_matrix[2];

+ 1 - 1
amt630hv160-freertos-beta/lib/awtk/awtk/src/platforms/ark/ark_g2d_vglite.c

@@ -18,7 +18,7 @@ static ret_t vglite_run(void) {
 		return RET_OK;
 
 	printf("%s, vglite g2d fail\n", __func__);
-
+	vglite_restart();
 	return RET_FAIL;
 }