mirror of https://github.com/mgba-emu/mgba.git
GBA Video: const-correctness
This commit is contained in:
parent
95f6a8f8d6
commit
02020369d1
|
@ -19,7 +19,7 @@ static void GBAVideoSoftwareRendererWritePalette(struct GBAVideoRenderer* render
|
|||
static uint16_t GBAVideoSoftwareRendererWriteVideoRegister(struct GBAVideoRenderer* renderer, uint32_t address, uint16_t value);
|
||||
static void GBAVideoSoftwareRendererDrawScanline(struct GBAVideoRenderer* renderer, int y);
|
||||
static void GBAVideoSoftwareRendererFinishFrame(struct GBAVideoRenderer* renderer);
|
||||
static void GBAVideoSoftwareRendererGetPixels(struct GBAVideoRenderer* renderer, unsigned* stride, void** pixels);
|
||||
static void GBAVideoSoftwareRendererGetPixels(struct GBAVideoRenderer* renderer, unsigned* stride, const void** pixels);
|
||||
static void GBAVideoSoftwareRendererPutPixels(struct GBAVideoRenderer* renderer, unsigned stride, void* pixels);
|
||||
|
||||
static void GBAVideoSoftwareRendererUpdateDISPCNT(struct GBAVideoSoftwareRenderer* renderer);
|
||||
|
@ -558,7 +558,7 @@ static void GBAVideoSoftwareRendererFinishFrame(struct GBAVideoRenderer* rendere
|
|||
softwareRenderer->bg[3].sy = softwareRenderer->bg[3].refy;
|
||||
}
|
||||
|
||||
static void GBAVideoSoftwareRendererGetPixels(struct GBAVideoRenderer* renderer, unsigned* stride, void** pixels) {
|
||||
static void GBAVideoSoftwareRendererGetPixels(struct GBAVideoRenderer* renderer, unsigned* stride, const void** pixels) {
|
||||
struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer;
|
||||
|
||||
*stride = softwareRenderer->outputBufferStride;
|
||||
|
|
|
@ -196,7 +196,7 @@ struct VFile* GBAGetState(struct GBA* gba, struct VDir* dir, int slot, bool writ
|
|||
#ifdef USE_PNG
|
||||
static bool _savePNGState(struct GBA* gba, struct VFile* vf) {
|
||||
unsigned stride;
|
||||
void* pixels = 0;
|
||||
const void* pixels = 0;
|
||||
gba->video.renderer->getPixels(gba->video.renderer, &stride, &pixels);
|
||||
if (!pixels) {
|
||||
return false;
|
||||
|
@ -367,8 +367,8 @@ void GBARecordFrame(struct GBAThread* thread) {
|
|||
|
||||
if (thread->rewindScreenBuffer) {
|
||||
unsigned stride;
|
||||
uint8_t* pixels = 0;
|
||||
thread->gba->video.renderer->getPixels(thread->gba->video.renderer, &stride, (void*) &pixels);
|
||||
const uint8_t* pixels = 0;
|
||||
thread->gba->video.renderer->getPixels(thread->gba->video.renderer, &stride, (const void**) &pixels);
|
||||
if (pixels) {
|
||||
size_t y;
|
||||
for (y = 0; y < VIDEO_VERTICAL_PIXELS; ++y) {
|
||||
|
|
|
@ -757,7 +757,7 @@ struct GBAThread* GBAThreadGetContext(void) {
|
|||
#ifdef USE_PNG
|
||||
void GBAThreadTakeScreenshot(struct GBAThread* threadContext) {
|
||||
unsigned stride;
|
||||
void* pixels = 0;
|
||||
const void* pixels = 0;
|
||||
struct VFile* vf = VDirOptionalOpenIncrementFile(threadContext->stateDir, threadContext->gba->activeFile, "screenshot", "-", ".png", O_CREAT | O_TRUNC | O_WRONLY);
|
||||
threadContext->gba->video.renderer->getPixels(threadContext->gba->video.renderer, &stride, &pixels);
|
||||
png_structp png = PNGWriteOpen(vf);
|
||||
|
|
|
@ -22,7 +22,7 @@ static void GBAVideoDummyRendererWritePalette(struct GBAVideoRenderer* renderer,
|
|||
static void GBAVideoDummyRendererWriteOAM(struct GBAVideoRenderer* renderer, uint32_t oam);
|
||||
static void GBAVideoDummyRendererDrawScanline(struct GBAVideoRenderer* renderer, int y);
|
||||
static void GBAVideoDummyRendererFinishFrame(struct GBAVideoRenderer* renderer);
|
||||
static void GBAVideoDummyRendererGetPixels(struct GBAVideoRenderer* renderer, unsigned* stride, void** pixels);
|
||||
static void GBAVideoDummyRendererGetPixels(struct GBAVideoRenderer* renderer, unsigned* stride, const void** pixels);
|
||||
|
||||
const int GBAVideoObjSizes[16][2] = {
|
||||
{ 8, 8 },
|
||||
|
@ -260,7 +260,7 @@ static void GBAVideoDummyRendererFinishFrame(struct GBAVideoRenderer* renderer)
|
|||
// Nothing to do
|
||||
}
|
||||
|
||||
static void GBAVideoDummyRendererGetPixels(struct GBAVideoRenderer* renderer, unsigned* stride, void** pixels) {
|
||||
static void GBAVideoDummyRendererGetPixels(struct GBAVideoRenderer* renderer, unsigned* stride, const void** pixels) {
|
||||
UNUSED(renderer);
|
||||
UNUSED(stride);
|
||||
UNUSED(pixels);
|
||||
|
|
|
@ -167,7 +167,7 @@ struct GBAVideoRenderer {
|
|||
void (*drawScanline)(struct GBAVideoRenderer* renderer, int y);
|
||||
void (*finishFrame)(struct GBAVideoRenderer* renderer);
|
||||
|
||||
void (*getPixels)(struct GBAVideoRenderer* renderer, unsigned* stride, void** pixels);
|
||||
void (*getPixels)(struct GBAVideoRenderer* renderer, unsigned* stride, const void** pixels);
|
||||
void (*putPixels)(struct GBAVideoRenderer* renderer, unsigned stride, void* pixels);
|
||||
|
||||
uint16_t* palette;
|
||||
|
|
|
@ -423,9 +423,9 @@ void _ffmpegPostVideoFrame(struct GBAAVStream* stream, struct GBAVideoRenderer*
|
|||
if (!encoder->context) {
|
||||
return;
|
||||
}
|
||||
uint8_t* pixels;
|
||||
const uint8_t* pixels;
|
||||
unsigned stride;
|
||||
renderer->getPixels(renderer, &stride, (void**) &pixels);
|
||||
renderer->getPixels(renderer, &stride, (const void**) &pixels);
|
||||
stride *= BYTES_PER_PIXEL;
|
||||
|
||||
AVPacket packet;
|
||||
|
|
|
@ -53,9 +53,9 @@ static void _magickPostVideoFrame(struct GBAAVStream* stream, struct GBAVideoRen
|
|||
return;
|
||||
}
|
||||
|
||||
uint8_t* pixels;
|
||||
const uint8_t* pixels;
|
||||
unsigned stride;
|
||||
renderer->getPixels(renderer, &stride, (void**) &pixels);
|
||||
renderer->getPixels(renderer, &stride, (const void**) &pixels);
|
||||
size_t row;
|
||||
for (row = 0; row < VIDEO_VERTICAL_PIXELS; ++row) {
|
||||
memcpy(&encoder->frame[row * VIDEO_HORIZONTAL_PIXELS], &pixels[row * 4 * stride], VIDEO_HORIZONTAL_PIXELS * 4);
|
||||
|
|
|
@ -407,7 +407,7 @@ static void _postAudioBuffer(struct GBAAVStream* stream, struct GBAAudio* audio)
|
|||
|
||||
static void _postVideoFrame(struct GBAAVStream* stream, struct GBAVideoRenderer* renderer) {
|
||||
UNUSED(stream);
|
||||
void* pixels;
|
||||
const void* pixels;
|
||||
unsigned stride;
|
||||
renderer->getPixels(renderer, &stride, &pixels);
|
||||
videoCallback(pixels, VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS, BYTES_PER_PIXEL * stride);
|
||||
|
|
|
@ -48,12 +48,12 @@ png_infop PNGWriteHeader(png_structp png, unsigned width, unsigned height) {
|
|||
return info;
|
||||
}
|
||||
|
||||
bool PNGWritePixels(png_structp png, unsigned width, unsigned height, unsigned stride, void* pixels) {
|
||||
bool PNGWritePixels(png_structp png, unsigned width, unsigned height, unsigned stride, const void* pixels) {
|
||||
png_bytep row = malloc(sizeof(png_bytep) * width * 3);
|
||||
if (!row) {
|
||||
return false;
|
||||
}
|
||||
png_bytep pixelData = pixels;
|
||||
png_const_bytep pixelData = pixels;
|
||||
if (setjmp(png_jmpbuf(png))) {
|
||||
free(row);
|
||||
return false;
|
||||
|
@ -81,7 +81,7 @@ bool PNGWriteCustomChunk(png_structp png, const char* name, size_t size, void* d
|
|||
if (setjmp(png_jmpbuf(png))) {
|
||||
return false;
|
||||
}
|
||||
png_write_chunk(png, (const png_bytep) realName, data, size);
|
||||
png_write_chunk(png, (png_const_bytep) realName, data, size);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ bool PNGInstallChunkHandler(png_structp png, void* context, ChunkHandler handler
|
|||
return false;
|
||||
}
|
||||
png_set_read_user_chunk_fn(png, context, handler);
|
||||
png_set_keep_unknown_chunks(png, PNG_HANDLE_CHUNK_ALWAYS, (const png_bytep) chunkName, 1);
|
||||
png_set_keep_unknown_chunks(png, PNG_HANDLE_CHUNK_ALWAYS, (png_const_bytep) chunkName, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ enum {
|
|||
|
||||
png_structp PNGWriteOpen(struct VFile* source);
|
||||
png_infop PNGWriteHeader(png_structp png, unsigned width, unsigned height);
|
||||
bool PNGWritePixels(png_structp png, unsigned width, unsigned height, unsigned stride, void* pixels);
|
||||
bool PNGWritePixels(png_structp png, unsigned width, unsigned height, unsigned stride, const void* pixels);
|
||||
bool PNGWriteCustomChunk(png_structp png, const char* name, size_t size, void* data);
|
||||
void PNGWriteClose(png_structp png, png_infop info);
|
||||
|
||||
|
|
Loading…
Reference in New Issue