[client] renderer: add interface for high DPI rendering

This commit is contained in:
Quantum 2021-02-21 00:08:52 -05:00 committed by Geoffrey McRae
parent 6b26089353
commit b35e19fc27
10 changed files with 18 additions and 15 deletions

View file

@ -381,6 +381,7 @@ static int sdlEventFilter(void * userdata, SDL_Event * event)
app_handleResizeEvent(
event->window.data1,
event->window.data2,
1,
border);
break;
}

View file

@ -80,7 +80,7 @@ void waylandEGLSwapBuffers(EGLDisplay display, EGLSurface surface)
wl_surface_set_opaque_region(wlWm.surface, region);
wl_region_destroy(region);
app_handleResizeEvent(wlWm.width, wlWm.height, (struct Border) {0, 0, 0, 0});
app_handleResizeEvent(wlWm.width, wlWm.height, 1, (struct Border) {0, 0, 0, 0});
xdg_surface_ack_configure(wlWm.xdgSurface, wlWm.resizeSerial);
wlWm.resizeSerial = 0;
}

View file

@ -569,10 +569,10 @@ static int x11EventThread(void * unused)
if (x11.fullscreen)
{
struct Border border = {0};
app_handleResizeEvent(x11.rect.w, x11.rect.h, border);
app_handleResizeEvent(x11.rect.w, x11.rect.h, 1, border);
}
else
app_handleResizeEvent(x11.rect.w, x11.rect.h, x11.border);
app_handleResizeEvent(x11.rect.w, x11.rect.h, 1, x11.border);
break;
}
@ -648,7 +648,7 @@ static int x11EventThread(void * unused)
x11.border.right = cardinal[1];
x11.border.top = cardinal[2];
x11.border.bottom = cardinal[3];
app_handleResizeEvent(x11.rect.w, x11.rect.h, x11.border);
app_handleResizeEvent(x11.rect.w, x11.rect.h, 1, x11.border);
}
XFree(data);

View file

@ -39,7 +39,7 @@ bool app_isRunning(void);
bool app_inputEnabled(void);
void app_updateCursorPos(double x, double y);
void app_updateWindowPos(int x, int y);
void app_handleResizeEvent(int w, int h, const struct Border border);
void app_handleResizeEvent(int w, int h, double scale, const struct Border border);
void app_handleMouseRelative(double normx, double normy,
double rawx, double rawy);

View file

@ -109,7 +109,7 @@ typedef bool (* LG_RendererInitialize )(void * opaque);
typedef void (* LG_RendererDeInitialize )(void * opaque);
typedef bool (* LG_RendererSupports )(void * opaque, LG_RendererSupport support);
typedef void (* LG_RendererOnRestart )(void * opaque);
typedef void (* LG_RendererOnResize )(void * opaque, const int width, const int height, const LG_RendererRect destRect, LG_RendererRotate rotate);
typedef void (* LG_RendererOnResize )(void * opaque, const int width, const int height, const double scale, const LG_RendererRect destRect, LG_RendererRotate rotate);
typedef bool (* LG_RendererOnMouseShape )(void * opaque, const LG_RendererCursor cursor, const int width, const int height, const int pitch, const uint8_t * data);
typedef bool (* LG_RendererOnMouseEvent )(void * opaque, const bool visible , const int x, const int y);
typedef bool (* LG_RendererOnFrameFormat)(void * opaque, const LG_RendererFormat format, bool useDMA);

View file

@ -379,7 +379,7 @@ static void egl_update_scale_type(struct Inst * this)
this->scaleType = EGL_DESKTOP_UPSCALE;
}
void egl_on_resize(void * opaque, const int width, const int height,
void egl_on_resize(void * opaque, const int width, const int height, const double scale,
const LG_RendererRect destRect, LG_RendererRotate rotate)
{
struct Inst * this = (struct Inst *)opaque;

View file

@ -298,7 +298,7 @@ void opengl_on_restart(void * opaque)
this->waiting = true;
}
void opengl_on_resize(void * opaque, const int width, const int height,
void opengl_on_resize(void * opaque, const int width, const int height, const double scale,
const LG_RendererRect destRect, LG_RendererRotate rotate)
{
struct Inst * this = (struct Inst *)opaque;

View file

@ -349,18 +349,19 @@ void app_updateWindowPos(int x, int y)
g_state.windowPos.y = y;
}
void app_handleResizeEvent(int w, int h, const struct Border border)
void app_handleResizeEvent(int w, int h, double scale, const struct Border border)
{
memcpy(&g_state.border, &border, sizeof(border));
/* don't do anything else if the window dimensions have not changed */
if (g_state.windowW == w && g_state.windowH == h)
if (g_state.windowW == w && g_state.windowH == h && g_state.windowScale == scale)
return;
g_state.windowW = w;
g_state.windowH = h;
g_state.windowCX = w / 2;
g_state.windowCY = h / 2;
g_state.windowW = w;
g_state.windowH = h;
g_state.windowCX = w / 2;
g_state.windowCY = h / 2;
g_state.windowScale = scale;
core_updatePositionInfo();
if (core_inputEnabled())

View file

@ -126,7 +126,7 @@ static int renderThread(void * unused)
{
if (g_state.lgr)
g_state.lgr->on_resize(g_state.lgrData, g_state.windowW, g_state.windowH,
g_state.dstRect, g_params.winRotate);
g_state.windowScale, g_state.dstRect, g_params.winRotate);
atomic_compare_exchange_weak(&g_state.lgrResize, &resize, 0);
}

View file

@ -58,6 +58,7 @@ struct AppState
struct Point windowPos;
int windowW, windowH;
int windowCX, windowCY;
double windowScale;
LG_RendererRotate rotate;
bool focused;
struct Border border;