mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
GE Debugger: Add a direct copy for preview images.
This commit is contained in:
1 parent
c3b4caa30b
commit
f3722faef4
5 files changed
+68
-2
No files matched your search
@@ -291,6 +291,9 @@ void CGEDebugger::SetupPreviews() {
|
||||
case ID_GEDBG_EXPORT_IMAGE:
|
||||
PreviewExport(primaryBuffer_);
|
||||
break;
|
||||
case ID_GEDBG_COPY_IMAGE:
|
||||
PreviewToClipboard(primaryBuffer_);
|
||||
break;
|
||||
case ID_GEDBG_ENABLE_PREVIEW:
|
||||
previewsEnabled_ ^= 1;
|
||||
primaryWindow->Redraw();
|
||||
@@ -321,6 +324,9 @@ void CGEDebugger::SetupPreviews() {
|
||||
case ID_GEDBG_EXPORT_IMAGE:
|
||||
PreviewExport(secondBuffer_);
|
||||
break;
|
||||
case ID_GEDBG_COPY_IMAGE:
|
||||
PreviewToClipboard(secondBuffer_);
|
||||
break;
|
||||
case ID_GEDBG_ENABLE_PREVIEW:
|
||||
previewsEnabled_ ^= 2;
|
||||
secondWindow->Redraw();
|
||||
@@ -393,6 +399,62 @@ void CGEDebugger::PreviewExport(const GPUDebugBuffer *dbgBuffer) {
|
||||
}
|
||||
}
|
||||
|
||||
void CGEDebugger::PreviewToClipboard(const GPUDebugBuffer *dbgBuffer) {
|
||||
if (!OpenClipboard(GetDlgHandle())) {
|
||||
return;
|
||||
}
|
||||
EmptyClipboard();
|
||||
|
||||
uint32_t byteStride = 3 * dbgBuffer->GetStride();
|
||||
while ((byteStride & 3) != 0)
|
||||
++byteStride;
|
||||
|
||||
HANDLE memHandle = GlobalAlloc(GHND, sizeof(BITMAPV5HEADER) + byteStride * dbgBuffer->GetHeight());
|
||||
if (memHandle == NULL) {
|
||||
CloseClipboard();
|
||||
return;
|
||||
}
|
||||
|
||||
BITMAPV5HEADER *header = (BITMAPV5HEADER *)GlobalLock(memHandle);
|
||||
header->bV5Size = sizeof(BITMAPV5HEADER);
|
||||
header->bV5Width = dbgBuffer->GetStride();
|
||||
// Bitmaps are flipped, but we can specify negative height to not be flipped.
|
||||
header->bV5Height = -dbgBuffer->GetHeight();
|
||||
header->bV5Planes = 1;
|
||||
header->bV5BitCount = 24;
|
||||
header->bV5Compression = BI_RGB;
|
||||
header->bV5SizeImage = byteStride * dbgBuffer->GetHeight();
|
||||
header->bV5CSType = LCS_sRGB;
|
||||
header->bV5Intent = LCS_GM_GRAPHICS;
|
||||
|
||||
uint8_t *flipbuffer = nullptr;
|
||||
uint32_t w = (uint32_t)-1;
|
||||
uint32_t h = (uint32_t)-1;
|
||||
const uint8_t *buffer = ConvertBufferToScreenshot(*dbgBuffer, false, flipbuffer, w, h);
|
||||
if (buffer != nullptr) {
|
||||
uint8_t *pixels = (uint8_t *)(header + 1);
|
||||
for (uint32_t y = 0; y < dbgBuffer->GetHeight(); ++y) {
|
||||
const uint8_t *src = buffer + y * 3 * w;
|
||||
uint8_t *dst = pixels + y * byteStride;
|
||||
for (uint32_t x = 0; x < w; ++x) {
|
||||
// Have to swap B/R again for the bitmap, unfortunate.
|
||||
dst[0] = src[2];
|
||||
dst[1] = src[1];
|
||||
dst[2] = src[0];
|
||||
src += 3;
|
||||
dst += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
delete [] flipbuffer;
|
||||
|
||||
GlobalUnlock(memHandle);
|
||||
|
||||
// Takes ownership.
|
||||
SetClipboardData(CF_DIBV5, memHandle);
|
||||
CloseClipboard();
|
||||
}
|
||||
|
||||
void CGEDebugger::UpdatePreviews() {
|
||||
auto memLock = Memory::Lock();
|
||||
if (!PSP_IsInited()) {
|
||||
|
||||
@@ -113,6 +113,7 @@ private:
|
||||
void PrimaryPreviewHover(int x, int y);
|
||||
void SecondPreviewHover(int x, int y);
|
||||
void PreviewExport(const GPUDebugBuffer *buffer);
|
||||
void PreviewToClipboard(const GPUDebugBuffer *buffer);
|
||||
static void DescribePixel(u32 pix, GPUDebugBufferFormat fmt, int x, int y, char desc[256]);
|
||||
static void DescribePixelRGBA(u32 pix, GPUDebugBufferFormat fmt, int x, int y, char desc[256]);
|
||||
void UpdateMenus();
|
||||
|
||||
@@ -59,7 +59,8 @@ namespace W32Util
|
||||
}
|
||||
|
||||
BOOL CopyTextToClipboard(HWND hwnd, const std::wstring &wtext) {
|
||||
OpenClipboard(hwnd);
|
||||
if (!OpenClipboard(hwnd))
|
||||
return FALSE;
|
||||
EmptyClipboard();
|
||||
HANDLE hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (wtext.size() + 1) * sizeof(wchar_t));
|
||||
if (hglbCopy == NULL) {
|
||||
|
||||
@@ -784,6 +784,7 @@ BEGIN
|
||||
POPUP "gepreviewoptions"
|
||||
BEGIN
|
||||
MENUITEM "Export Image...", ID_GEDBG_EXPORT_IMAGE
|
||||
MENUITEM "Copy Opaque Image", ID_GEDBG_COPY_IMAGE
|
||||
MENUITEM "Show Prim Preview", ID_GEDBG_ENABLE_PREVIEW
|
||||
END
|
||||
POPUP "matrixoptions"
|
||||
|
||||
+2
-1
@@ -333,6 +333,7 @@
|
||||
#define ID_GEDBG_SHOWONTOPRIGHT 40221
|
||||
#define IDC_GEDBG_STEPVSYNC 40222
|
||||
#define ID_GEDBG_SETCOND 40223
|
||||
#define ID_GEDBG_COPY_IMAGE 40224
|
||||
|
||||
|
||||
// Dummy option to let the buffered rendering hotkey cycle through all the options.
|
||||
@@ -346,7 +347,7 @@
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 256
|
||||
#define _APS_NEXT_COMMAND_VALUE 40224
|
||||
#define _APS_NEXT_COMMAND_VALUE 40225
|
||||
#define _APS_NEXT_CONTROL_VALUE 1202
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user