Merge branch 'master' into dev

This commit is contained in:
xianjimli 2020-04-28 12:10:50 +08:00
commit 632282057c
6 changed files with 215 additions and 200 deletions

View File

@ -234,6 +234,7 @@ struct GLNVGcontext {
int ctextures;
int textureId;
GLuint vertBuf;
float devicePixelRatio;
#if defined NANOVG_GL3
GLuint vertArr;
#endif
@ -996,10 +997,11 @@ static void glnvg__setUniforms(GLNVGcontext* gl, int uniformOffset, int image) {
}
static void glnvg__renderViewport(void* uptr, float width, float height, float devicePixelRatio) {
NVG_NOTUSED(devicePixelRatio);
//NVG_NOTUSED(devicePixelRatio);
GLNVGcontext* gl = (GLNVGcontext*)uptr;
gl->view[0] = width;
gl->view[1] = height;
gl->devicePixelRatio = devicePixelRatio;
}
static void glnvg__fill(GLNVGcontext* gl, GLNVGcall* call) {
@ -1547,6 +1549,7 @@ static void glnvg__renderTriangles(void* uptr, NVGpaint* paint,
GLNVGcontext* gl = (GLNVGcontext*)uptr;
GLNVGcall* call = glnvg__allocCall(gl);
GLNVGfragUniforms* frag;
float fringe = 1.0f / gl->devicePixelRatio;
if (call == NULL) return;
@ -1565,7 +1568,7 @@ static void glnvg__renderTriangles(void* uptr, NVGpaint* paint,
call->uniformOffset = glnvg__allocFragUniforms(gl, 1);
if (call->uniformOffset == -1) goto error;
frag = nvg__fragUniformPtr(gl, call->uniformOffset);
glnvg__convertPaint(gl, frag, paint, scissor, 1.0f, 1.0f, -1.0f);
glnvg__convertPaint(gl, frag, paint, scissor, 1.0f, fringe, -1.0f);
if(glnvg__VertsInScissor(verts, nverts, scissor) && glnvg_getSupportFastDraw(gl, scissor)) {
frag->type = NSVG_SHADER_FAST_FILLGLYPH;
} else {

View File

@ -1,15 +1,22 @@
# 最新动态
* 2020/04/28
* 完善 color picker感谢尧燊提供补丁
* 修复 guage_pointer 函数设置锚点不正确的问题(感谢智明提供补丁)
* 修复 nanovg 在高分屏下裁剪区裁剪字体显示不正常的问题(感谢智明提供补丁)
* 修复 vgcanvas 的着色器精度问题导致显示不正常的 bug感谢智明提供补丁
* 完善 image gen感谢大恒提供补丁
* 2020/04/27
* edit/mledit 支持翻译提示信息(感谢瑞安提供补丁)。
* 更新文档。
* 2020/04/24
* 增加 rich text view 控件用于协调 rich text 和 scroll bar。
* 修复在板子上面使用位图资源时候出现内存泄漏的问题(感谢智明提供补丁)
* 修复圆角矩形画线的 bug 和圆角矩形支持片段式显存(感谢智明提供补丁)。
* 修复 input method 中注释错误(感谢大恒提供补丁)。
* 修复 is\_dialog\_opened错误感谢大恒提供补丁
* 修复 is\_dialog\_opened 错误(感谢大恒提供补丁)。
* 2020/04/23
* 去掉 widget 中不必要的 log。

View File

@ -400,10 +400,10 @@ ret_t color_picker_set_color(widget_t* widget, const char* color) {
float s = 0;
float v = 0;
color_picker->init_c = color_parse(color);
color_picker_update_color(widget, color_picker->init_c);
convertRGBtoHSV(color_picker->init_c.rgba.r, color_picker->init_c.rgba.g,
color_picker->init_c.rgba.b, &h, &s, &v);
color_picker->last_hue = h;
color_picker_update_color(widget, color_picker->init_c);
return RET_OK;
}

View File

@ -92,7 +92,7 @@ ret_t guage_pointer_set_anchor(widget_t* widget, const char* anchor_x, const cha
return_value_if_fail(guage_pointer != NULL, RET_BAD_PARAMS);
guage_pointer_set_anchor_for_str(widget, anchor_x, TRUE);
guage_pointer_set_anchor_for_str(widget, anchor_x, FALSE);
guage_pointer_set_anchor_for_str(widget, anchor_y, FALSE);
return RET_OK;
}

View File

@ -200,43 +200,48 @@ vgcanvas_nanovg_screen_shader_info_t* vgcanvas_create_init_screen_shader() {
" void main(void) { \n"
" ftcoord = tcoord; \n"
#if defined(WITH_SCREEN_GL_FLIP_VERTICAL) && defined(WITH_SCREEN_GL_FLIP_HORIZONTAL)
" gl_Position = vec4(-g_vPosition.x, -g_vPosition.y, g_vPosition.z, 1.0); \n"
" gl_Position = vec4(-g_vPosition.x, -g_vPosition.y, g_vPosition.z, 1.0); \n"
#elif defined(WITH_SCREEN_GL_FLIP_VERTICAL)
" gl_Position = vec4(g_vPosition.x, -g_vPosition.y, g_vPosition.z, 1.0); \n"
" gl_Position = vec4(g_vPosition.x, -g_vPosition.y, g_vPosition.z, 1.0); \n"
#elif defined(WITH_SCREEN_GL_FLIP_HORIZONTAL)
" gl_Position = vec4(-g_vPosition.x, g_vPosition.y, g_vPosition.z, 1.0); \n"
" gl_Position = vec4(-g_vPosition.x, g_vPosition.y, g_vPosition.z, 1.0); \n"
#else
" gl_Position = vec4(g_vPosition.x, g_vPosition.y, g_vPosition.z, 1.0); \n"
" gl_Position = vec4(g_vPosition.x, g_vPosition.y, g_vPosition.z, 1.0); \n"
#endif
" } \n";
const char* fragment_shader =
" #ifdef NANOVG_GL3 \n"
" precision highp float; \n"
" in vec2 ftcoord; \n"
" out vec4 outColor; \n"
" #else \n"
" precision mediump float; \n"
" varying vec2 ftcoord; \n"
" #endif \n"
" uniform sampler2D screentexture; \n"
" void main() { \n"
" #ifdef NANOVG_GL3 \n"
" vec4 color = texture(screentexture, ftcoord); \n"
" #ifdef GL_ES \n"
" #if defined(GL_FRAGMENT_PRECISION_HIGH) || defined(NANOVG_GL3) \n"
" precision highp float; \n"
" #else \n"
" precision mediump float; \n"
" #endif \n"
" #endif \n"
" #ifdef NANOVG_GL3 \n"
" in vec2 ftcoord; \n"
" out vec4 outColor; \n"
" #else \n"
" varying vec2 ftcoord; \n"
" #endif \n"
" uniform sampler2D screentexture; \n"
" void main() { \n"
" #ifdef NANOVG_GL3 \n"
" vec4 color = texture(screentexture, ftcoord); \n"
#if defined(WITH_SCREEN_GL_BGRA)
" outColor = vec4(color.b, color.g, color.r, color.a); \n"
" outColor = vec4(color.b, color.g, color.r, color.a); \n"
#else
" outColor = vec4(color.r, color.g, color.b, color.a); \n"
" outColor = vec4(color.r, color.g, color.b, color.a); \n"
#endif
" #else \n"
" vec4 color = texture2D(screentexture, ftcoord); \n"
" #else \n"
" vec4 color = texture2D(screentexture, ftcoord); \n"
#if defined(WITH_SCREEN_GL_BGRA)
" gl_FragColor = vec4(color.b, color.g, color.r, color.a); \n"
" gl_FragColor = vec4(color.b, color.g, color.r, color.a); \n"
#else
" gl_FragColor = vec4(color.r, color.g, color.b, color.a); \n"
" gl_FragColor = vec4(color.r, color.g, color.b, color.a); \n"
#endif
" #endif \n"
" } \n";
" #endif \n"
" } \n";
vgcanvas_nanovg_screen_shader_info_t* shader_info =
(vgcanvas_nanovg_screen_shader_info_t*)TKMEM_ZALLOC(vgcanvas_nanovg_screen_shader_info_t);

View File

@ -1,170 +1,170 @@
/**
* File: main.c
* Author: AWTK Develop Team
* Brief: bitmap font generator
*
* Copyright (c) 2018 - 2020 Guangzhou ZHIYUAN Electronics Co.,Ltd.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* License file for more details.
*
*/
/**
* History:
* ================================================================
* 2018-01-21 Li XianJing <xianjimli@hotmail.com> created
*
*/
#include "tkc/fs.h"
#include "tkc/path.h"
#include "tkc/mem.h"
#include "image_gen.h"
#include "common/utils.h"
#include "base/image_manager.h"
#include "image_loader/image_loader_stb.h"
typedef struct _image_format_t {
bool_t mono;
bool_t require_bgra;
bool_t enable_bgr565;
bool_t enable_rgb565;
} image_format_t;
ret_t image_format_set(image_format_t* image_format, const wchar_t* format) {
if (format != NULL) {
if (tk_wstr_eq(format, L"mono")) {
image_format->mono = TRUE;
}
if (tk_wstr_eq(format, L"bgra")) {
image_format->require_bgra = TRUE;
}
if (tk_wstr_eq(format, L"bgr565")) {
image_format->enable_bgr565 = TRUE;
};
if (tk_wstr_eq(format, L"rgb565")) {
image_format->enable_rgb565 = TRUE;
};
}
return RET_OK;
}
ret_t gen_one(const char* input_file, const char* output_file, const char* theme,
image_format_t* image_format) {
ret_t ret = RET_OK;
if (!exit_if_need_not_update(input_file, output_file)) {
bitmap_t image;
uint32_t size = 0;
uint8_t* buff = NULL;
buff = (uint8_t*)read_file(input_file, &size);
if (buff != NULL) {
ret = stb_load_image(0, buff, size, &image, image_format->require_bgra,
image_format->enable_bgr565, image_format->enable_rgb565);
if (ret == RET_OK) {
ret = image_gen(&image, output_file, theme, image_format->mono);
}
TKMEM_FREE(buff);
} else {
ret = RET_FAIL;
}
if (ret != RET_OK) {
GEN_ERROR(input_file);
}
}
return ret;
}
static ret_t gen_floder(const char* in_flodername, const char* out_flodername, const char* theme,
image_format_t* image_format) {
ret_t ret = RET_OK;
fs_dir_t* dir = fs_open_dir(os_fs(), in_flodername);
fs_item_t item;
char in_name[MAX_PATH] = {0};
char out_name[MAX_PATH] = {0};
while (dir->read(dir, &item) != RET_FAIL) {
if (item.is_reg_file) {
str_t str_name;
char ext_array[MAX_PATH] = {0};
path_extname(item.name, ext_array, MAX_PATH);
str_init(&str_name, 0);
str_set(&str_name, item.name);
str_replace(&str_name, ext_array, "");
filter_name(str_name.str);
str_append(&str_name, ".data");
path_build(in_name, MAX_PATH, in_flodername, item.name, NULL);
path_build(out_name, MAX_PATH, out_flodername, str_name.str, NULL);
ret = gen_one(in_name, out_name, theme, image_format);
str_reset(&str_name);
if (ret != RET_OK) {
break;
}
}
}
fs_dir_close(dir);
return RET_OK;
}
int wmain(int argc, wchar_t* argv[]) {
const char* in_filename = NULL;
const char* out_filename = NULL;
const wchar_t* format = NULL;
TKMEM_INIT(4 * 1024 * 1024);
if (argc < 3) {
printf("Usage: %S in_filename out_filename (bgra|bgr565|rgb565|mono)\n", argv[0]);
return 0;
}
if (argc > 3) {
format = argv[3];
}
image_format_t image_format = {FALSE, FALSE, FALSE, FALSE};
image_format_set(&image_format, format);
str_t theme_name;
str_init(&theme_name, 0);
if (argc > 4) {
str_from_wstr(&theme_name, argv[4]);
}
str_t in_file;
str_t out_file;
str_init(&in_file, 0);
str_init(&out_file, 0);
str_from_wstr(&in_file, argv[1]);
str_from_wstr(&out_file, argv[2]);
in_filename = in_file.str;
out_filename = out_file.str;
fs_stat_info_t in_stat_info;
fs_stat_info_t out_stat_info;
fs_stat(os_fs(), in_filename, &in_stat_info);
fs_stat(os_fs(), out_filename, &out_stat_info);
if (in_stat_info.is_dir == TRUE && out_stat_info.is_dir == TRUE) {
gen_floder(in_filename, out_filename, theme_name.str, &image_format);
} else if (in_stat_info.is_reg_file == TRUE) {
gen_one(in_filename, out_filename, theme_name.str, &image_format);
} else {
GEN_ERROR(in_filename);
}
str_reset(&in_file);
str_reset(&out_file);
str_reset(&theme_name);
return 0;
}
#include "common/main.inc"
/**
* File: main.c
* Author: AWTK Develop Team
* Brief: bitmap font generator
*
* Copyright (c) 2018 - 2020 Guangzhou ZHIYUAN Electronics Co.,Ltd.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* License file for more details.
*
*/
/**
* History:
* ================================================================
* 2018-01-21 Li XianJing <xianjimli@hotmail.com> created
*
*/
#include "tkc/fs.h"
#include "tkc/path.h"
#include "tkc/mem.h"
#include "image_gen.h"
#include "common/utils.h"
#include "base/image_manager.h"
#include "image_loader/image_loader_stb.h"
typedef struct _image_format_t {
bool_t mono;
bool_t require_bgra;
bool_t enable_bgr565;
bool_t enable_rgb565;
} image_format_t;
ret_t image_format_set(image_format_t* image_format, const wchar_t* format) {
if (format != NULL) {
if (wcsstr(format, L"mono")) {
image_format->mono = TRUE;
}
if (wcsstr(format, L"bgra")) {
image_format->require_bgra = TRUE;
}
if (wcsstr(format, L"bgr565")) {
image_format->enable_bgr565 = TRUE;
};
if (wcsstr(format, L"rgb565")) {
image_format->enable_rgb565 = TRUE;
};
}
return RET_OK;
}
ret_t gen_one(const char* input_file, const char* output_file, const char* theme,
image_format_t* image_format) {
ret_t ret = RET_OK;
if (!exit_if_need_not_update(input_file, output_file)) {
bitmap_t image;
uint32_t size = 0;
uint8_t* buff = NULL;
buff = (uint8_t*)read_file(input_file, &size);
if (buff != NULL) {
ret = stb_load_image(0, buff, size, &image, image_format->require_bgra,
image_format->enable_bgr565, image_format->enable_rgb565);
if (ret == RET_OK) {
ret = image_gen(&image, output_file, theme, image_format->mono);
}
TKMEM_FREE(buff);
} else {
ret = RET_FAIL;
}
if (ret != RET_OK) {
GEN_ERROR(input_file);
}
}
return ret;
}
static ret_t gen_floder(const char* in_flodername, const char* out_flodername, const char* theme,
image_format_t* image_format) {
ret_t ret = RET_OK;
fs_dir_t* dir = fs_open_dir(os_fs(), in_flodername);
fs_item_t item;
char in_name[MAX_PATH] = {0};
char out_name[MAX_PATH] = {0};
while (dir->read(dir, &item) != RET_FAIL) {
if (item.is_reg_file) {
str_t str_name;
char ext_array[MAX_PATH] = {0};
path_extname(item.name, ext_array, MAX_PATH);
str_init(&str_name, 0);
str_set(&str_name, item.name);
str_replace(&str_name, ext_array, "");
filter_name(str_name.str);
str_append(&str_name, ".data");
path_build(in_name, MAX_PATH, in_flodername, item.name, NULL);
path_build(out_name, MAX_PATH, out_flodername, str_name.str, NULL);
ret = gen_one(in_name, out_name, theme, image_format);
str_reset(&str_name);
if (ret != RET_OK) {
break;
}
}
}
fs_dir_close(dir);
return RET_OK;
}
int wmain(int argc, wchar_t* argv[]) {
const char* in_filename = NULL;
const char* out_filename = NULL;
const wchar_t* format = NULL;
TKMEM_INIT(4 * 1024 * 1024);
if (argc < 3) {
printf("Usage: %S in_filename out_filename (bgra|bgr565|rgb565|mono)\n", argv[0]);
return 0;
}
if (argc > 3) {
format = argv[3];
}
image_format_t image_format = {FALSE, FALSE, FALSE, FALSE};
image_format_set(&image_format, format);
str_t theme_name;
str_init(&theme_name, 0);
if (argc > 4) {
str_from_wstr(&theme_name, argv[4]);
}
str_t in_file;
str_t out_file;
str_init(&in_file, 0);
str_init(&out_file, 0);
str_from_wstr(&in_file, argv[1]);
str_from_wstr(&out_file, argv[2]);
in_filename = in_file.str;
out_filename = out_file.str;
fs_stat_info_t in_stat_info;
fs_stat_info_t out_stat_info;
fs_stat(os_fs(), in_filename, &in_stat_info);
fs_stat(os_fs(), out_filename, &out_stat_info);
if (in_stat_info.is_dir == TRUE && out_stat_info.is_dir == TRUE) {
gen_floder(in_filename, out_filename, theme_name.str, &image_format);
} else if (in_stat_info.is_reg_file == TRUE) {
gen_one(in_filename, out_filename, theme_name.str, &image_format);
} else {
GEN_ERROR(in_filename);
}
str_reset(&in_file);
str_reset(&out_file);
str_reset(&theme_name);
return 0;
}
#include "common/main.inc"