From 1664a524a77af1b6d501a6f54892599bb232249e Mon Sep 17 00:00:00 2001 From: Olli Wang Date: Fri, 5 Aug 2016 16:56:36 +0800 Subject: [PATCH] Passes the device pixel ratio parameter to `renderViewport` function. This commit updates the `nvgBeginFrame()` function to forward the received `devicePixelRatio` parameter to the `renderViewport()` function so it is possible to configure the environemnt correctly when using `bgfx` backend. --- src/nanovg.c | 2 +- src/nanovg.h | 2 +- src/nanovg_gl.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/nanovg.c b/src/nanovg.c index 370dbf0..43371ec 100644 --- a/src/nanovg.c +++ b/src/nanovg.c @@ -295,7 +295,7 @@ void nvgBeginFrame(NVGcontext* ctx, int windowWidth, int windowHeight, float dev nvg__setDevicePixelRatio(ctx, devicePixelRatio); - ctx->params.renderViewport(ctx->params.userPtr, windowWidth, windowHeight); + ctx->params.renderViewport(ctx->params.userPtr, windowWidth, windowHeight, devicePixelRatio); ctx->drawCallCount = 0; ctx->fillTriCount = 0; diff --git a/src/nanovg.h b/src/nanovg.h index 870a04d..603b8e3 100644 --- a/src/nanovg.h +++ b/src/nanovg.h @@ -588,7 +588,7 @@ struct NVGparams { int (*renderDeleteTexture)(void* uptr, int image); int (*renderUpdateTexture)(void* uptr, int image, int x, int y, int w, int h, const unsigned char* data); int (*renderGetTextureSize)(void* uptr, int image, int* w, int* h); - void (*renderViewport)(void* uptr, int width, int height); + void (*renderViewport)(void* uptr, int width, int height, float devicePixelRatio); void (*renderCancel)(void* uptr); void (*renderFlush)(void* uptr); void (*renderFill)(void* uptr, NVGpaint* paint, NVGscissor* scissor, float fringe, const float* bounds, const NVGpath* paths, int npaths); diff --git a/src/nanovg_gl.h b/src/nanovg_gl.h index 4ba87f3..7580af1 100644 --- a/src/nanovg_gl.h +++ b/src/nanovg_gl.h @@ -941,7 +941,7 @@ static void glnvg__setUniforms(GLNVGcontext* gl, int uniformOffset, int image) } } -static void glnvg__renderViewport(void* uptr, int width, int height) +static void glnvg__renderViewport(void* uptr, int width, int height, float devicePixelRatio) { GLNVGcontext* gl = (GLNVGcontext*)uptr; gl->view[0] = (float)width;