rosalina: put screenshot loop inside same TU

This commit is contained in:
TuxSH 2020-05-08 18:19:17 +01:00
parent 1875556f81
commit 49c8888948
3 changed files with 11 additions and 8 deletions

View File

@ -97,4 +97,4 @@ void Draw_FlushFramebuffer(void);
u32 Draw_GetCurrentFramebufferAddress(bool top, bool left);
void Draw_CreateBitmapHeader(u8 *dst, u32 width, u32 heigth);
void Draw_ConvertFrameBufferLine(u8 *line, bool top, bool left, u32 y);
void Draw_ConvertFrameBufferLines(u8 *buf, u32 startingLine, u32 numLines, bool top, bool left);

View File

@ -308,7 +308,7 @@ static inline void Draw_ConvertPixelToBGR8(u8 *dst, const u8 *src, GSPGPU_Frameb
}
}
void Draw_ConvertFrameBufferLine(u8 *line, bool top, bool left, u32 y)
void Draw_ConvertFrameBufferLines(u8 *buf, u32 startingLine, u32 numLines, bool top, bool left)
{
GSPGPU_FramebufferFormats fmt = top ? (GSPGPU_FramebufferFormats)(GPU_FB_TOP_FMT & 7) : (GSPGPU_FramebufferFormats)(GPU_FB_BOTTOM_FMT & 7);
u32 width = top ? 400 : 320;
@ -318,6 +318,9 @@ void Draw_ConvertFrameBufferLine(u8 *line, bool top, bool left, u32 y)
u32 pa = Draw_GetCurrentFramebufferAddress(top, left);
u8 *addr = (u8 *)PA_PTR(pa);
for(u32 x = 0; x < width; x++)
Draw_ConvertPixelToBGR8(line + x * 3 , addr + x * stride + y * formatSizes[(u8)fmt], fmt);
for (u32 y = startingLine; y < startingLine + numLines; y++)
{
for(u32 x = 0; x < width; x++)
Draw_ConvertPixelToBGR8(buf + (x + width * y) * 3 , addr + x * stride + y * formatSizes[(u8)fmt], fmt);
}
}

View File

@ -171,7 +171,7 @@ static Result RosalinaMenu_WriteScreenshot(IFile *file, bool top, bool left)
Draw_CreateBitmapHeader(framebufferCache, dimX, 240);
buf += 54;
u32 n = 0;
u32 y = 0;
// Our buffer might be smaller than the size of the screenshot...
while (remaining != 0)
{
@ -179,14 +179,14 @@ static Result RosalinaMenu_WriteScreenshot(IFile *file, bool top, bool left)
u32 available = (u32)(framebufferCacheEnd - buf);
u32 size = available < remaining ? available : remaining;
u32 nlines = size / lineSize;
for (u32 y = 0; y < nlines; y++)
Draw_ConvertFrameBufferLine(buf + lineSize * y, top, left, y);
Draw_ConvertFrameBufferLines(buf, y, nlines, top, left);
s64 t1 = svcGetSystemTick();
timeSpentConvertingScreenshot += t1 - t0;
TRY(IFile_Write(file, &total, framebufferCache, (n == 0 ? 54 : 0) + lineSize * nlines, 0)); // don't forget to write the header
TRY(IFile_Write(file, &total, framebufferCache, (y == 0 ? 54 : 0) + lineSize * nlines, 0)); // don't forget to write the header
timeSpentWritingScreenshot += svcGetSystemTick() - t1;
y += nlines;
remaining -= lineSize * nlines;
buf = framebufferCache;
}