GUI: Screenshot dimensions are now passed through
Jeffrey Pfau jeffrey@endrift.com
Sat, 06 Aug 2016 10:46:54 -0700
6 files changed,
19 insertions(+),
19 deletions(-)
M
src/feature/gui/gui-runner.c
→
src/feature/gui/gui-runner.c
@@ -60,13 +60,13 @@ static void _drawState(struct GUIBackground* background, void* id) {
struct mGUIBackground* gbaBackground = (struct mGUIBackground*) background; int stateId = ((int) id) >> 16; if (gbaBackground->p->drawScreenshot) { + unsigned w, h; + gbaBackground->p->core->desiredVideoDimensions(gbaBackground->p->core, &w, &h); if (gbaBackground->screenshot && gbaBackground->screenshotId == (int) id) { - gbaBackground->p->drawScreenshot(gbaBackground->p, gbaBackground->screenshot, true); + gbaBackground->p->drawScreenshot(gbaBackground->p, gbaBackground->screenshot, w, h, true); return; } struct VFile* vf = mCoreGetState(gbaBackground->p->core, stateId, false); - unsigned w, h; - gbaBackground->p->core->desiredVideoDimensions(gbaBackground->p->core, &w, &h); uint32_t* pixels = gbaBackground->screenshot; if (!pixels) { pixels = anonymousMemoryMap(w * h * 4);@@ -88,7 +88,7 @@ if (vf) {
vf->close(vf); } if (success) { - gbaBackground->p->drawScreenshot(gbaBackground->p, pixels, true); + gbaBackground->p->drawScreenshot(gbaBackground->p, pixels, w, h, true); gbaBackground->screenshotId = (int) id; } else if (gbaBackground->p->drawFrame) { gbaBackground->p->drawFrame(gbaBackground->p, true);
M
src/feature/gui/gui-runner.h
→
src/feature/gui/gui-runner.h
@@ -57,7 +57,7 @@ void (*gameLoaded)(struct mGUIRunner*);
void (*gameUnloaded)(struct mGUIRunner*); void (*prepareForFrame)(struct mGUIRunner*); void (*drawFrame)(struct mGUIRunner*, bool faded); - void (*drawScreenshot)(struct mGUIRunner*, const uint32_t* pixels, bool faded); + void (*drawScreenshot)(struct mGUIRunner*, const uint32_t* pixels, unsigned width, unsigned height, bool faded); void (*paused)(struct mGUIRunner*); void (*unpaused)(struct mGUIRunner*); void (*incrementScreenMode)(struct mGUIRunner*);
M
src/platform/3ds/main.c
→
src/platform/3ds/main.c
@@ -409,16 +409,15 @@ gspWaitForPPF();
_drawTex(runner->core, faded); } -static void _drawScreenshot(struct mGUIRunner* runner, const uint32_t* pixels, bool faded) { - UNUSED(runner); +static void _drawScreenshot(struct mGUIRunner* runner, const uint32_t* pixels, unsigned width, unsigned height, bool faded) { C3D_Tex* tex = &outputTexture; - u16* newPixels = linearMemAlign(256 * VIDEO_VERTICAL_PIXELS * sizeof(u32), 0x100); + u16* newPixels = linearMemAlign(256 * height * sizeof(u32), 0x100); // Convert image from RGBX8 to BGR565 - for (unsigned y = 0; y < VIDEO_VERTICAL_PIXELS; ++y) { - for (unsigned x = 0; x < VIDEO_HORIZONTAL_PIXELS; ++x) { + for (unsigned y = 0; y < height; ++y) { + for (unsigned x = 0; x < width; ++x) { // 0xXXBBGGRR -> 0bRRRRRGGGGGGBBBBB u32 p = *pixels++; newPixels[y * 256 + x] =@@ -426,12 +425,12 @@ (p << 24 >> (24 + 3) << 11) | // R
(p << 16 >> (24 + 2) << 5) | // G (p << 8 >> (24 + 3) << 0); // B } - memset(&newPixels[y * 256 + VIDEO_HORIZONTAL_PIXELS], 0, (256 - VIDEO_HORIZONTAL_PIXELS) * sizeof(u32)); + memset(&newPixels[y * 256 + width], 0, (256 - width) * sizeof(u32)); } - GSPGPU_FlushDataCache(newPixels, 256 * VIDEO_VERTICAL_PIXELS * sizeof(u32)); + GSPGPU_FlushDataCache(newPixels, 256 * height * sizeof(u32)); C3D_SafeDisplayTransfer( - (u32*) newPixels, GX_BUFFER_DIM(256, VIDEO_VERTICAL_PIXELS), + (u32*) newPixels, GX_BUFFER_DIM(256, height), tex->data, GX_BUFFER_DIM(256, 256), GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGB565) | GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB565) |
M
src/platform/psp2/psp2-context.c
→
src/platform/psp2/psp2-context.c
@@ -283,12 +283,12 @@ break;
} } -void mPSP2DrawScreenshot(struct mGUIRunner* runner, const uint32_t* pixels, bool faded) { +void mPSP2DrawScreenshot(struct mGUIRunner* runner, const uint32_t* pixels, unsigned width, unsigned height, bool faded) { UNUSED(runner); uint32_t* texpixels = vita2d_texture_get_datap(screenshot); int y; - for (y = 0; y < VIDEO_VERTICAL_PIXELS; ++y) { - memcpy(&texpixels[256 * y], &pixels[VIDEO_HORIZONTAL_PIXELS * y], VIDEO_HORIZONTAL_PIXELS * 4); + for (y = 0; y < height; ++y) { + memcpy(&texpixels[256 * y], &pixels[width * y], width * 4); } switch (screenMode) { case SM_BACKDROP:@@ -296,10 +296,10 @@ default:
vita2d_draw_texture_tint(backdrop, 0, 0, (faded ? 0 : 0xC0000000) | 0x3FFFFFFF); // Fall through case SM_PLAIN: - vita2d_draw_texture_tint_part_scale(screenshot, 120, 32, 0, 0, 240, 160, 3.0f, 3.0f, (faded ? 0 : 0xC0000000) | 0x3FFFFFFF); + vita2d_draw_texture_tint_part_scale(screenshot, (960.0f - width * 3.0f) / 2.0f, (544.0f - height * 3.0f) / 2.0f, 0, 0, width, height, 3.0f, 3.0f, (faded ? 0 : 0xC0000000) | 0x3FFFFFFF); break; case SM_FULL: - vita2d_draw_texture_tint_scale(screenshot, 0, 0, 960.0f / 240.0f, 544.0f / 160.0f, (faded ? 0 : 0xC0000000) | 0x3FFFFFFF); + vita2d_draw_texture_tint_scale(screenshot, 0, 0, 960.0f / width, 544.0f / height, (faded ? 0 : 0xC0000000) | 0x3FFFFFFF); break; } }
M
src/platform/psp2/psp2-context.h
→
src/platform/psp2/psp2-context.h
@@ -18,7 +18,7 @@ void mPSP2UnloadROM(struct mGUIRunner* runner);
void mPSP2PrepareForFrame(struct mGUIRunner* runner); void mPSP2Unpaused(struct mGUIRunner* runner); void mPSP2Draw(struct mGUIRunner* runner, bool faded); -void mPSP2DrawScreenshot(struct mGUIRunner* runner, const uint32_t* pixels, bool faded); +void mPSP2DrawScreenshot(struct mGUIRunner* runner, const uint32_t* pixels, unsigned width, unsigned height, bool faded); void mPSP2IncrementScreenMode(struct mGUIRunner* runner); uint16_t mPSP2PollInput(struct mGUIRunner* runner);