[client] interface: refactor to use camlCase function names

This commit is contained in:
Geoffrey McRae 2021-08-08 15:43:42 +10:00
parent d347b28481
commit 30ed563504
5 changed files with 77 additions and 77 deletions

View File

@ -27,16 +27,16 @@
#include "common/framebuffer.h"
#define IS_LG_RENDERER_VALID(x) \
((x)->get_name && \
((x)->getName && \
(x)->create && \
(x)->initialize && \
(x)->deinitialize && \
(x)->on_restart && \
(x)->on_resize && \
(x)->on_mouse_shape && \
(x)->on_mouse_event && \
(x)->render_startup && \
(x)->needs_render && \
(x)->onRestart && \
(x)->onResize && \
(x)->onMouseShape && \
(x)->onMouseEvent && \
(x)->renderStartup && \
(x)->needsRender && \
(x)->render)
typedef struct LG_RendererParams
@ -99,7 +99,7 @@ typedef struct LG_Renderer LG_Renderer;
typedef struct LG_RendererOps
{
/* returns the friendly name of the renderer */
const char * (*get_name)(void);
const char * (*getName)(void);
/* called pre-creation to allow the renderer to register any options it may
* have */
@ -124,41 +124,41 @@ typedef struct LG_RendererOps
/* called when the renderer is to reset it's state
* Context: lg_run & frameThread */
void (*on_restart)(LG_Renderer * renderer);
void (*onRestart)(LG_Renderer * renderer);
/* called when the viewport has been resized
* Context: renderThrtead */
void (*on_resize)(LG_Renderer * renderer, const int width, const int height,
void (*onResize)(LG_Renderer * renderer, const int width, const int height,
const double scale, const LG_RendererRect destRect,
LG_RendererRotate rotate);
/* called when the mouse shape has changed
* Context: cursorThread */
bool (*on_mouse_shape)(LG_Renderer * renderer, const LG_RendererCursor cursor,
bool (*onMouseShape)(LG_Renderer * renderer, const LG_RendererCursor cursor,
const int width, const int height, const int pitch, const uint8_t * data);
/* called when the mouse has moved or changed visibillity
* Context: cursorThread */
bool (*on_mouse_event)(LG_Renderer * renderer, const bool visible, const int x,
bool (*onMouseEvent)(LG_Renderer * renderer, const bool visible, const int x,
const int y);
/* called when the frame format has changed
* Context: frameThread */
bool (*on_frame_format)(LG_Renderer * renderer,
bool (*onFrameFormat)(LG_Renderer * renderer,
const LG_RendererFormat format);
/* called when there is a new frame
* Context: frameThread */
bool (*on_frame)(LG_Renderer * renderer, const FrameBuffer * frame, int dmaFD,
bool (*onFrame)(LG_Renderer * renderer, const FrameBuffer * frame, int dmaFD,
const FrameDamageRect * damage, int damageCount);
/* called when the rederer is to startup
* Context: renderThread */
bool (*render_startup)(LG_Renderer * renderer, bool useDMA);
bool (*renderStartup)(LG_Renderer * renderer, bool useDMA);
/* returns if the render method must be called even if nothing has changed.
* Context: renderThread */
bool (*needs_render)(LG_Renderer * renderer);
bool (*needsRender)(LG_Renderer * renderer);
/* called to render the scene
* Context: renderThread */

View File

@ -184,7 +184,7 @@ static struct Option egl_options[] =
{0}
};
static const char * egl_get_name(void)
static const char * egl_getName(void)
{
return "EGL";
}
@ -286,7 +286,7 @@ static bool egl_supports(LG_Renderer * renderer, LG_RendererSupport flag)
}
}
static void egl_on_restart(LG_Renderer * renderer)
static void egl_onRestart(LG_Renderer * renderer)
{
struct Inst * this = UPCAST(struct Inst, renderer);
@ -400,7 +400,7 @@ static void egl_update_scale_type(struct Inst * this)
this->scaleType = EGL_DESKTOP_UPSCALE;
}
static void egl_on_resize(LG_Renderer * renderer, const int width, const int height, const double scale,
static void egl_onResize(LG_Renderer * renderer, const int width, const int height, const double scale,
const LG_RendererRect destRect, LG_RendererRotate rotate)
{
struct Inst * this = UPCAST(struct Inst, renderer);
@ -447,7 +447,7 @@ static void egl_on_resize(LG_Renderer * renderer, const int width, const int hei
egl_damage_resize(this->damage, this->translateX, this->translateY, this->scaleX, this->scaleY);
}
static bool egl_on_mouse_shape(LG_Renderer * renderer, const LG_RendererCursor cursor,
static bool egl_onMouseShape(LG_Renderer * renderer, const LG_RendererCursor cursor,
const int width, const int height,
const int pitch, const uint8_t * data)
{
@ -466,7 +466,7 @@ static bool egl_on_mouse_shape(LG_Renderer * renderer, const LG_RendererCursor c
return true;
}
static bool egl_on_mouse_event(LG_Renderer * renderer, const bool visible, const int x, const int y)
static bool egl_onMouseEvent(LG_Renderer * renderer, const bool visible, const int x, const int y)
{
struct Inst * this = UPCAST(struct Inst, renderer);
this->cursorVisible = visible;
@ -476,7 +476,7 @@ static bool egl_on_mouse_event(LG_Renderer * renderer, const bool visible, const
return true;
}
static bool egl_on_frame_format(LG_Renderer * renderer, const LG_RendererFormat format)
static bool egl_onFrameFormat(LG_Renderer * renderer, const LG_RendererFormat format)
{
struct Inst * this = UPCAST(struct Inst, renderer);
memcpy(&this->format, &format, sizeof(LG_RendererFormat));
@ -509,7 +509,7 @@ static bool egl_on_frame_format(LG_Renderer * renderer, const LG_RendererFormat
return egl_desktop_setup(this->desktop, format);
}
static bool egl_on_frame(LG_Renderer * renderer, const FrameBuffer * frame, int dmaFd,
static bool egl_onFrame(LG_Renderer * renderer, const FrameBuffer * frame, int dmaFd,
const FrameDamageRect * damageRects, int damageRectsCount)
{
struct Inst * this = UPCAST(struct Inst, renderer);
@ -624,7 +624,7 @@ static void egl_config_ui(void * opaque)
egl_desktop_config_ui(this->desktop);
}
static bool egl_render_startup(LG_Renderer * renderer, bool useDMA)
static bool egl_renderStartup(LG_Renderer * renderer, bool useDMA)
{
struct Inst * this = UPCAST(struct Inst, renderer);
@ -818,7 +818,7 @@ static bool egl_render_startup(LG_Renderer * renderer, bool useDMA)
return true;
}
static bool egl_needs_render(LG_Renderer * renderer)
static bool egl_needsRender(LG_Renderer * renderer)
{
struct Inst * this = UPCAST(struct Inst, renderer);
return !this->waitDone;
@ -1070,19 +1070,19 @@ static bool egl_render(LG_Renderer * renderer, LG_RendererRotate rotate,
struct LG_RendererOps LGR_EGL =
{
.get_name = egl_get_name,
.getName = egl_getName,
.setup = egl_setup,
.create = egl_create,
.initialize = egl_initialize,
.deinitialize = egl_deinitialize,
.supports = egl_supports,
.on_restart = egl_on_restart,
.on_resize = egl_on_resize,
.on_mouse_shape = egl_on_mouse_shape,
.on_mouse_event = egl_on_mouse_event,
.on_frame_format = egl_on_frame_format,
.on_frame = egl_on_frame,
.render_startup = egl_render_startup,
.needs_render = egl_needs_render,
.onRestart = egl_onRestart,
.onResize = egl_onResize,
.onMouseShape = egl_onMouseShape,
.onMouseEvent = egl_onMouseEvent,
.onFrameFormat = egl_onFrameFormat,
.onFrame = egl_onFrame,
.renderStartup = egl_renderStartup,
.needsRender = egl_needsRender,
.render = egl_render
};

View File

@ -179,7 +179,7 @@ static bool draw_frame(struct Inst * this);
static void draw_mouse(struct Inst * this);
static void render_wait(struct Inst * this);
const char * opengl_get_name(void)
const char * opengl_getName(void)
{
return "OpenGL";
}
@ -261,14 +261,14 @@ void opengl_deinitialize(LG_Renderer * renderer)
free(this);
}
void opengl_on_restart(LG_Renderer * renderer)
void opengl_onRestart(LG_Renderer * renderer)
{
struct Inst * this = UPCAST(struct Inst, renderer);
this->waiting = true;
}
void opengl_on_resize(LG_Renderer * renderer, const int width, const int height, const double scale,
void opengl_onResize(LG_Renderer * renderer, const int width, const int height, const double scale,
const LG_RendererRect destRect, LG_RendererRotate rotate)
{
struct Inst * this = UPCAST(struct Inst, renderer);
@ -310,7 +310,7 @@ void opengl_on_resize(LG_Renderer * renderer, const int width, const int height,
ImGui_ImplOpenGL2_NewFrame();
}
bool opengl_on_mouse_shape(LG_Renderer * renderer, const LG_RendererCursor cursor,
bool opengl_onMouseShape(LG_Renderer * renderer, const LG_RendererCursor cursor,
const int width, const int height, const int pitch, const uint8_t * data)
{
struct Inst * this = UPCAST(struct Inst, renderer);
@ -337,7 +337,7 @@ bool opengl_on_mouse_shape(LG_Renderer * renderer, const LG_RendererCursor curso
return true;
}
bool opengl_on_mouse_event(LG_Renderer * renderer, const bool visible, const int x, const int y)
bool opengl_onMouseEvent(LG_Renderer * renderer, const bool visible, const int x, const int y)
{
struct Inst * this = UPCAST(struct Inst, renderer);
@ -351,7 +351,7 @@ bool opengl_on_mouse_event(LG_Renderer * renderer, const bool visible, const int
return false;
}
bool opengl_on_frame_format(LG_Renderer * renderer, const LG_RendererFormat format)
bool opengl_onFrameFormat(LG_Renderer * renderer, const LG_RendererFormat format)
{
struct Inst * this = UPCAST(struct Inst, renderer);
@ -362,7 +362,7 @@ bool opengl_on_frame_format(LG_Renderer * renderer, const LG_RendererFormat form
return true;
}
bool opengl_on_frame(LG_Renderer * renderer, const FrameBuffer * frame, int dmaFd,
bool opengl_onFrame(LG_Renderer * renderer, const FrameBuffer * frame, int dmaFd,
const FrameDamageRect * damage, int damageCount)
{
struct Inst * this = UPCAST(struct Inst, renderer);
@ -387,7 +387,7 @@ bool opengl_on_frame(LG_Renderer * renderer, const FrameBuffer * frame, int dmaF
return true;
}
bool opengl_render_startup(LG_Renderer * renderer, bool useDMA)
bool opengl_renderStartup(LG_Renderer * renderer, bool useDMA)
{
struct Inst * this = UPCAST(struct Inst, renderer);
@ -450,7 +450,7 @@ bool opengl_render_startup(LG_Renderer * renderer, bool useDMA)
return true;
}
static bool opengl_needs_render(LG_Renderer * renderer)
static bool opengl_needsRender(LG_Renderer * renderer)
{
struct Inst * this = UPCAST(struct Inst, renderer);
return !this->waitDone;
@ -604,20 +604,20 @@ static void render_wait(struct Inst * this)
const LG_RendererOps LGR_OpenGL =
{
.get_name = opengl_get_name,
.getName = opengl_getName,
.setup = opengl_setup,
.create = opengl_create,
.initialize = opengl_initialize,
.deinitialize = opengl_deinitialize,
.on_restart = opengl_on_restart,
.on_resize = opengl_on_resize,
.on_mouse_shape = opengl_on_mouse_shape,
.on_mouse_event = opengl_on_mouse_event,
.on_frame_format = opengl_on_frame_format,
.on_frame = opengl_on_frame,
.render_startup = opengl_render_startup,
.needs_render = opengl_needs_render,
.onRestart = opengl_onRestart,
.onResize = opengl_onResize,
.onMouseShape = opengl_onMouseShape,
.onMouseEvent = opengl_onMouseEvent,
.onFrameFormat = opengl_onFrameFormat,
.onFrame = opengl_onFrame,
.renderStartup = opengl_renderStartup,
.needsRender = opengl_needsRender,
.render = opengl_render
};

View File

@ -674,7 +674,7 @@ static bool optRendererParse(struct Option * opt, const char * str)
}
for(unsigned int i = 0; i < LG_RENDERER_COUNT; ++i)
if (strcasecmp(str, LG_Renderers[i]->get_name()) == 0)
if (strcasecmp(str, LG_Renderers[i]->getName()) == 0)
{
g_params.forceRenderer = true;
g_params.forceRendererIndex = i;
@ -690,7 +690,7 @@ static StringList optRendererValues(struct Option * opt)
// this typecast is safe as the stringlist doesn't own the values
for(unsigned int i = 0; i < LG_RENDERER_COUNT; ++i)
stringlist_push(sl, (char *)LG_Renderers[i]->get_name());
stringlist_push(sl, (char *)LG_Renderers[i]->getName());
return sl;
}
@ -703,7 +703,7 @@ static char * optRendererToString(struct Option * opt)
if (g_params.forceRendererIndex >= LG_RENDERER_COUNT)
return NULL;
return strdup(LG_Renderers[g_params.forceRendererIndex]->get_name());
return strdup(LG_Renderers[g_params.forceRendererIndex]->getName());
}
static bool optPosParse(struct Option * opt, const char * str)

View File

@ -147,7 +147,7 @@ static void preSwapCallback(void * udata)
static int renderThread(void * unused)
{
if (!RENDERER(render_startup, g_state.useDMA))
if (!RENDERER(renderStartup, g_state.useDMA))
{
g_state.state = APP_STATE_SHUTDOWN;
@ -190,7 +190,7 @@ static int renderThread(void * unused)
&& !forceRender
&& !pending
&& !app_overlayNeedsRender()
&& !RENDERER(needs_render))
&& !RENDERER(needsRender))
{
if (g_state.ds->skipFrame)
g_state.ds->skipFrame();
@ -235,7 +235,7 @@ static int renderThread(void * unused)
DEBUG_FATAL("Failed to build font atlas: %s (%s)", g_params.uiFont, g_state.fontName);
if (g_state.lgr)
RENDERER(on_resize, g_state.windowW, g_state.windowH,
RENDERER(onResize, g_state.windowW, g_state.windowH,
g_state.windowScale, g_state.dstRect, g_params.winRotate);
atomic_compare_exchange_weak(&g_state.lgrResize, &resize, 0);
}
@ -337,7 +337,7 @@ static int cursorThread(void * unused)
if (g_cursor.redraw && g_cursor.guest.valid)
{
g_cursor.redraw = false;
RENDERER(on_mouse_event,
RENDERER(onMouseEvent,
g_cursor.guest.visible && (g_cursor.draw || !g_params.useSpiceInput),
g_cursor.guest.x,
g_cursor.guest.y
@ -400,7 +400,7 @@ static int cursorThread(void * unused)
g_cursor.guest.hy = cursor->hy;
const uint8_t * data = (const uint8_t *)(cursor + 1);
if (!RENDERER(on_mouse_shape,
if (!RENDERER(onMouseShape,
cursorType,
cursor->width,
cursor->height,
@ -433,7 +433,7 @@ static int cursorThread(void * unused)
g_cursor.redraw = false;
RENDERER(on_mouse_event,
RENDERER(onMouseEvent,
g_cursor.guest.visible && (g_cursor.draw || !g_params.useSpiceInput),
g_cursor.guest.x,
g_cursor.guest.y
@ -610,7 +610,7 @@ int main_frameThread(void * unused)
frame->rotation);
LG_LOCK(g_state.lgrLock);
if (!RENDERER(on_frame_format, lgrFormat))
if (!RENDERER(onFrameFormat, lgrFormat))
{
DEBUG_ERROR("renderer failed to configure format");
g_state.state = APP_STATE_SHUTDOWN;
@ -677,7 +677,7 @@ int main_frameThread(void * unused)
}
FrameBuffer * fb = (FrameBuffer *)(((uint8_t*)frame) + frame->offset);
if (!RENDERER(on_frame, fb, g_state.useDMA ? dma->fd : -1,
if (!RENDERER(onFrame, fb, g_state.useDMA ? dma->fd : -1,
frame->damageRects, frame->damageRectsCount))
{
lgmpClientMessageDone(queue);
@ -717,7 +717,7 @@ int main_frameThread(void * unused)
}
lgmpClientUnsubscribe(&queue);
RENDERER(on_restart);
RENDERER(onRestart);
if (g_state.useDMA)
{
@ -799,7 +799,7 @@ static bool tryRenderer(const int index, const LG_RendererParams lgrParams,
return false;
}
DEBUG_INFO("Using Renderer: %s", r->get_name());
DEBUG_INFO("Using Renderer: %s", r->getName());
return true;
}
@ -1173,7 +1173,7 @@ restart:
lgInit();
RENDERER(on_restart);
RENDERER(onRestart);
DEBUG_INFO("Waiting for the host to restart...");
goto restart;