Skip to content

Commit

Permalink
improve nanovg_plus
Browse files Browse the repository at this point in the history
  • Loading branch information
xianjimli committed Feb 12, 2025
1 parent 09ec489 commit 7d92ea7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
13 changes: 9 additions & 4 deletions 3rd/nanovg_plus/base/nanovg_plus.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,18 @@ void nvgp_reset_curr_state(nvgp_context_t* ctx) {

}

static void nvgp_set_ratio(nvgp_context_t* ctx, float ratio) {
ctx->ratio = ratio;
ctx->tess_tol = 0.25f / ratio;
ctx->dist_tol = 0.01f / ratio;
ctx->fringe_width = 1.0f / ratio;
}

static int nvgp_init(nvgp_context_t* context, nvgp_mode_t nvgp_mode, uint32_t w, uint32_t h) {
context->nvgp_mode = nvgp_mode;
context->context_width = w;
context->context_height = h;
nvgp_set_ratio(context, 1.0f);
nvgp_darray_init(&context->commands, NVGP_INIT_COMMANDS_SIZE, 0);
nvgp_darray_init(&context->states, NVGP_INIT_STATES, sizeof(nvgp_state_t));

Expand Down Expand Up @@ -302,10 +310,7 @@ void nvgp_begin_frame_ex(nvgp_context_t *ctx, float width, float height, float p
CHECK_OBJECT_IS_NULL(ctx);
ctx->width = width;
ctx->height = height;
ctx->ratio = pixel_ratio;
ctx->tess_tol = 0.25f / pixel_ratio;
ctx->dist_tol = 0.01f / pixel_ratio;
ctx->fringe_width = 1.0f / pixel_ratio;
nvgp_set_ratio(ctx, pixel_ratio);

if (reset) {
nvgp_darray_clear(&ctx->states);
Expand Down
3 changes: 3 additions & 0 deletions docs/changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# 最新动态

2025/02/12
* nanovg plus 初始化 ratio 为 1(感谢兆坤提供补丁)

2025/02/09
* 完善matrix注释(感谢兆坤提供补丁)

Expand Down

0 comments on commit 7d92ea7

Please sign in to comment.