Util: Namespace geometry structs to avoid conflicts

This commit is contained in:
Vicki Pfau 2023-03-19 03:03:55 -07:00
parent 96d0193136
commit 9a4cf28776
12 changed files with 35 additions and 35 deletions

View File

@ -10,20 +10,20 @@
CXX_GUARD_START CXX_GUARD_START
struct Size { struct mSize {
int width; int width;
int height; int height;
}; };
struct Rectangle { struct mRectangle {
int x; int x;
int y; int y;
int width; int width;
int height; int height;
}; };
void RectangleUnion(struct Rectangle* dst, const struct Rectangle* add); void mRectangleUnion(struct mRectangle* dst, const struct mRectangle* add);
void RectangleCenter(const struct Rectangle* ref, struct Rectangle* rect); void mRectangleCenter(const struct mRectangle* ref, struct mRectangle* rect);
CXX_GUARD_END CXX_GUARD_END

View File

@ -63,7 +63,7 @@ static inline void _setTexDims(int width, int height) {
#endif #endif
} }
static void mGLContextSetLayerDimensions(struct VideoBackend* v, enum VideoLayer layer, const struct Rectangle* dims) { static void mGLContextSetLayerDimensions(struct VideoBackend* v, enum VideoLayer layer, const struct mRectangle* dims) {
struct mGLContext* context = (struct mGLContext*) v; struct mGLContext* context = (struct mGLContext*) v;
if (layer >= VIDEO_LAYER_MAX) { if (layer >= VIDEO_LAYER_MAX) {
return; return;
@ -89,7 +89,7 @@ static void mGLContextSetLayerDimensions(struct VideoBackend* v, enum VideoLayer
} }
} }
static void mGLContextLayerDimensions(const struct VideoBackend* v, enum VideoLayer layer, struct Rectangle* dims) { static void mGLContextLayerDimensions(const struct VideoBackend* v, enum VideoLayer layer, struct mRectangle* dims) {
struct mGLContext* context = (struct mGLContext*) v; struct mGLContext* context = (struct mGLContext*) v;
if (layer >= VIDEO_LAYER_MAX) { if (layer >= VIDEO_LAYER_MAX) {
return; return;
@ -141,7 +141,7 @@ static void _setFilter(struct VideoBackend* v) {
} }
} }
static void _setFrame(struct Rectangle* dims, int frameW, int frameH) { static void _setFrame(struct mRectangle* dims, int frameW, int frameH) {
GLint viewport[4]; GLint viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport); glGetIntegerv(GL_VIEWPORT, viewport);
glScissor(viewport[0] + dims->x * viewport[2] / frameW, glScissor(viewport[0] + dims->x * viewport[2] / frameW,

View File

@ -29,8 +29,8 @@ struct mGLContext {
int activeTex; int activeTex;
GLuint tex[2]; GLuint tex[2];
GLuint layers[VIDEO_LAYER_MAX]; GLuint layers[VIDEO_LAYER_MAX];
struct Rectangle layerDims[VIDEO_LAYER_MAX]; struct mRectangle layerDims[VIDEO_LAYER_MAX];
struct Size imageSizes[VIDEO_LAYER_MAX]; struct mSize imageSizes[VIDEO_LAYER_MAX];
}; };
void mGLContextCreate(struct mGLContext*); void mGLContextCreate(struct mGLContext*);

View File

@ -194,7 +194,7 @@ static inline void _setTexDims(int width, int height) {
#endif #endif
} }
static void mGLES2ContextSetLayerDimensions(struct VideoBackend* v, enum VideoLayer layer, const struct Rectangle* dims) { static void mGLES2ContextSetLayerDimensions(struct VideoBackend* v, enum VideoLayer layer, const struct mRectangle* dims) {
struct mGLES2Context* context = (struct mGLES2Context*) v; struct mGLES2Context* context = (struct mGLES2Context*) v;
if (layer >= VIDEO_LAYER_MAX) { if (layer >= VIDEO_LAYER_MAX) {
return; return;
@ -229,7 +229,7 @@ static void mGLES2ContextSetLayerDimensions(struct VideoBackend* v, enum VideoLa
} }
} }
static void mGLES2ContextLayerDimensions(const struct VideoBackend* v, enum VideoLayer layer, struct Rectangle* dims) { static void mGLES2ContextLayerDimensions(const struct VideoBackend* v, enum VideoLayer layer, struct mRectangle* dims) {
struct mGLES2Context* context = (struct mGLES2Context*) v; struct mGLES2Context* context = (struct mGLES2Context*) v;
if (layer >= VIDEO_LAYER_MAX) { if (layer >= VIDEO_LAYER_MAX) {
return; return;

View File

@ -82,8 +82,8 @@ struct mGLES2Context {
GLuint tex[VIDEO_LAYER_MAX]; GLuint tex[VIDEO_LAYER_MAX];
GLuint vbo; GLuint vbo;
struct Rectangle layerDims[VIDEO_LAYER_MAX]; struct mRectangle layerDims[VIDEO_LAYER_MAX];
struct Size imageSizes[VIDEO_LAYER_MAX]; struct mSize imageSizes[VIDEO_LAYER_MAX];
unsigned width; unsigned width;
unsigned height; unsigned height;

View File

@ -683,7 +683,7 @@ void PainterGL::resizeContext() {
} }
dequeueAll(false); dequeueAll(false);
Rectangle dims = {0, 0, size.width(), size.height()}; mRectangle dims = {0, 0, size.width(), size.height()};
m_backend->setLayerDimensions(m_backend, VIDEO_LAYER_IMAGE, &dims); m_backend->setLayerDimensions(m_backend, VIDEO_LAYER_IMAGE, &dims);
recenterLayers(); recenterLayers();
} }
@ -697,10 +697,10 @@ void PainterGL::recenterLayers() {
return; return;
} }
const static std::initializer_list<VideoLayer> centeredLayers{VIDEO_LAYER_BACKGROUND, VIDEO_LAYER_IMAGE}; const static std::initializer_list<VideoLayer> centeredLayers{VIDEO_LAYER_BACKGROUND, VIDEO_LAYER_IMAGE};
Rectangle frame = {0}; mRectangle frame = {0};
unsigned scale = std::max(1U, m_context->videoScale()); unsigned scale = std::max(1U, m_context->videoScale());
for (VideoLayer l : centeredLayers) { for (VideoLayer l : centeredLayers) {
Rectangle dims{}; mRectangle dims{};
int width, height; int width, height;
m_backend->imageSize(m_backend, l, &width, &height); m_backend->imageSize(m_backend, l, &width, &height);
dims.width = width; dims.width = width;
@ -710,12 +710,12 @@ void PainterGL::recenterLayers() {
dims.height *= scale; dims.height *= scale;
m_backend->setLayerDimensions(m_backend, l, &dims); m_backend->setLayerDimensions(m_backend, l, &dims);
} }
RectangleUnion(&frame, &dims); mRectangleUnion(&frame, &dims);
} }
for (VideoLayer l : centeredLayers) { for (VideoLayer l : centeredLayers) {
Rectangle dims; mRectangle dims;
m_backend->layerDimensions(m_backend, l, &dims); m_backend->layerDimensions(m_backend, l, &dims);
RectangleCenter(&frame, &dims); mRectangleCenter(&frame, &dims);
m_backend->setLayerDimensions(m_backend, l, &dims); m_backend->setLayerDimensions(m_backend, l, &dims);
} }
} }

View File

@ -66,7 +66,7 @@ bool mSDLGLCommonLoadBackground(struct VideoBackend* context) {
goto done; goto done;
} }
struct Rectangle dims = { struct mRectangle dims = {
.width = width, .width = width,
.height = height .height = height
}; };
@ -136,13 +136,13 @@ void mSDLGLCommonRunloop(struct mSDLRenderer* renderer, void* user) {
if (mSDLGLCommonLoadBackground(v)) { if (mSDLGLCommonLoadBackground(v)) {
renderer->player.windowUpdated = true; renderer->player.windowUpdated = true;
struct Rectangle frame; struct mRectangle frame;
VideoBackendGetFrame(v, &frame); VideoBackendGetFrame(v, &frame);
int i; int i;
for (i = 0; i <= VIDEO_LAYER_IMAGE; ++i) { for (i = 0; i <= VIDEO_LAYER_IMAGE; ++i) {
struct Rectangle dims; struct mRectangle dims;
v->layerDimensions(v, i, &dims); v->layerDimensions(v, i, &dims);
RectangleCenter(&frame, &dims); mRectangleCenter(&frame, &dims);
v->setLayerDimensions(v, i, &dims); v->setLayerDimensions(v, i, &dims);
} }
@ -168,7 +168,7 @@ void mSDLGLCommonRunloop(struct mSDLRenderer* renderer, void* user) {
} }
} }
renderer->core->currentVideoSize(renderer->core, &renderer->width, &renderer->height); renderer->core->currentVideoSize(renderer->core, &renderer->width, &renderer->height);
struct Rectangle dims; struct mRectangle dims;
v->layerDimensions(v, VIDEO_LAYER_IMAGE, &dims); v->layerDimensions(v, VIDEO_LAYER_IMAGE, &dims);
if (renderer->width != dims.width || renderer->height != dims.height) { if (renderer->width != dims.width || renderer->height != dims.height) {
renderer->core->setVideoBuffer(renderer->core, renderer->outputBuffer, renderer->width); renderer->core->setVideoBuffer(renderer->core, renderer->outputBuffer, renderer->width);

View File

@ -35,7 +35,7 @@ bool mSDLGLInit(struct mSDLRenderer* renderer) {
renderer->gl.d.filter = renderer->filter; renderer->gl.d.filter = renderer->filter;
renderer->gl.d.swap = mSDLGLCommonSwap; renderer->gl.d.swap = mSDLGLCommonSwap;
renderer->gl.d.init(&renderer->gl.d, 0); renderer->gl.d.init(&renderer->gl.d, 0);
struct Rectangle dims = { struct mRectangle dims = {
.x = 0, .x = 0,
.y = 0, .y = 0,
.width = renderer->width, .width = renderer->width,

View File

@ -50,7 +50,7 @@ bool mSDLGLES2Init(struct mSDLRenderer* renderer) {
#endif #endif
renderer->gl2.d.init(&renderer->gl2.d, 0); renderer->gl2.d.init(&renderer->gl2.d, 0);
struct Rectangle dims = { struct mRectangle dims = {
.x = 0, .x = 0,
.y = 0, .y = 0,
.width = renderer->width, .width = renderer->width,

View File

@ -5,18 +5,18 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "video-backend.h" #include "video-backend.h"
void VideoBackendGetFrame(const struct VideoBackend* v, struct Rectangle* frame) { void VideoBackendGetFrame(const struct VideoBackend* v, struct mRectangle* frame) {
memset(frame, 0, sizeof(*frame)); memset(frame, 0, sizeof(*frame));
int i; int i;
for (i = 0; i < VIDEO_LAYER_MAX; ++i) { for (i = 0; i < VIDEO_LAYER_MAX; ++i) {
struct Rectangle dims; struct mRectangle dims;
v->layerDimensions(v, i, &dims); v->layerDimensions(v, i, &dims);
RectangleUnion(frame, &dims); mRectangleUnion(frame, &dims);
} }
} }
void VideoBackendGetFrameSize(const struct VideoBackend* v, unsigned* width, unsigned* height) { void VideoBackendGetFrameSize(const struct VideoBackend* v, unsigned* width, unsigned* height) {
struct Rectangle frame; struct mRectangle frame;
VideoBackendGetFrame(v, &frame); VideoBackendGetFrame(v, &frame);
*width = frame.width; *width = frame.width;
*height = frame.height; *height = frame.height;

View File

@ -30,8 +30,8 @@ enum VideoLayer {
struct VideoBackend { struct VideoBackend {
void (*init)(struct VideoBackend*, WHandle handle); void (*init)(struct VideoBackend*, WHandle handle);
void (*deinit)(struct VideoBackend*); void (*deinit)(struct VideoBackend*);
void (*setLayerDimensions)(struct VideoBackend*, enum VideoLayer, const struct Rectangle*); void (*setLayerDimensions)(struct VideoBackend*, enum VideoLayer, const struct mRectangle*);
void (*layerDimensions)(const struct VideoBackend*, enum VideoLayer, struct Rectangle*); void (*layerDimensions)(const struct VideoBackend*, enum VideoLayer, struct mRectangle*);
void (*swap)(struct VideoBackend*); void (*swap)(struct VideoBackend*);
void (*clear)(struct VideoBackend*); void (*clear)(struct VideoBackend*);
void (*contextResized)(struct VideoBackend*, unsigned w, unsigned h); void (*contextResized)(struct VideoBackend*, unsigned w, unsigned h);
@ -58,7 +58,7 @@ struct VideoShader {
size_t nPasses; size_t nPasses;
}; };
void VideoBackendGetFrame(const struct VideoBackend*, struct Rectangle* frame); void VideoBackendGetFrame(const struct VideoBackend*, struct mRectangle* frame);
void VideoBackendGetFrameSize(const struct VideoBackend*, unsigned* width, unsigned* height); void VideoBackendGetFrameSize(const struct VideoBackend*, unsigned* width, unsigned* height);
CXX_GUARD_END CXX_GUARD_END

View File

@ -5,7 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <mgba-util/geometry.h> #include <mgba-util/geometry.h>
void RectangleUnion(struct Rectangle* dst, const struct Rectangle* add) { void mRectangleUnion(struct mRectangle* dst, const struct mRectangle* add) {
int x0 = dst->x; int x0 = dst->x;
int y0 = dst->y; int y0 = dst->y;
int x1 = dst->x + dst->width; int x1 = dst->x + dst->width;
@ -30,7 +30,7 @@ void RectangleUnion(struct Rectangle* dst, const struct Rectangle* add) {
dst->height = y1 - y0; dst->height = y1 - y0;
} }
void RectangleCenter(const struct Rectangle* ref, struct Rectangle* rect) { void mRectangleCenter(const struct mRectangle* ref, struct mRectangle* rect) {
rect->x = ref->x + (ref->width - rect->width) / 2; rect->x = ref->x + (ref->width - rect->width) / 2;
rect->y = ref->y + (ref->height - rect->height) / 2; rect->y = ref->y + (ref->height - rect->height) / 2;
} }