From 2e334e382f05b88bd2a15c703a809470ae79cc81 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Tue, 1 May 2018 16:26:09 +0300 Subject: [PATCH] Screenshot/capture from multimonitor window that has focus. --- drawing.cpp | 2 +- include/drawing.h | 2 +- od-win32/avioutput.cpp | 46 +++++++++++++++++++++----------------- od-win32/picasso96_win.cpp | 3 +-- 4 files changed, 28 insertions(+), 25 deletions(-) diff --git a/drawing.cpp b/drawing.cpp index 99781f7f..3c326025 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -4031,7 +4031,7 @@ void vsync_handle_redraw(int long_field, int lof_changed, uae_u16 bplcon0p, uae_ finish_drawing_frame(drawlines); #ifdef AVIOUTPUT if (!ad->picasso_on) { - frame_drawn(); + frame_drawn(monid); } #endif } diff --git a/include/drawing.h b/include/drawing.h index 10cfc902..41eebffc 100644 --- a/include/drawing.h +++ b/include/drawing.h @@ -315,7 +315,7 @@ extern void reset_drawing (void); extern void drawing_init (void); extern bool notice_interlace_seen (bool); extern void notice_resolution_seen (int, bool); -extern bool frame_drawn (void); +extern bool frame_drawn (int monid); extern void redraw_frame (void); extern bool draw_frame (struct vidbuffer*); extern int get_custom_limits (int *pw, int *ph, int *pdx, int *pdy, int *prealh); diff --git a/od-win32/avioutput.cpp b/od-win32/avioutput.cpp index b3e55ded..12492f30 100644 --- a/od-win32/avioutput.cpp +++ b/od-win32/avioutput.cpp @@ -60,6 +60,7 @@ static int frame_skip; static uae_u64 total_avi_size; static int partcnt; static int first_frame; +static int aviout_monid; int avioutput_audio, avioutput_video, avioutput_enabled, avioutput_requested; static int videoallocated; @@ -93,7 +94,6 @@ struct avientry { uae_u8 *lpAudio; int sndsize; int expectedsize; - int monid; }; #define AVIENTRY_MAX 10 @@ -181,7 +181,7 @@ static struct avientry *allocavientry_audio (uae_u8 *snd, int size, int expected return ae; } -static struct avientry *allocavientry_video (void) +static struct avientry *allocavientry_video(void) { struct avientry *ae = xcalloc (struct avientry, 1); ae->lpbi = (LPBITMAPINFOHEADER)xmalloc (uae_u8, lpbisize ()); @@ -527,7 +527,7 @@ void AVIOutput_ReleaseVideo (void) static int AVIOutput_AllocateVideo (void) { - struct AmigaMonitor *mon = &AMonitors[0]; + struct AmigaMonitor *mon = &AMonitors[aviout_monid]; avioutput_width = avioutput_height = avioutput_bits = 0; aviout_width_out = aviout_height_out = 0; aviout_xoffset_out = aviout_yoffset_out = 0; @@ -955,7 +955,7 @@ static int getFromRenderTarget11(struct avientry *avie) int w, h, pitch, bits = 32; void *data; - bool got = D3D11_capture(0, &data, &w, &h, &pitch); + bool got = D3D11_capture(aviout_monid, &data, &w, &h, &pitch); if (got) { int dpitch = ((aviout_width_out * avioutput_bits + 31) & ~31) / 8; for (int y = 0; y < h; y++) { @@ -974,7 +974,7 @@ static int getFromRenderTarget11(struct avientry *avie) } } } - D3D11_capture(0, NULL, NULL, NULL, NULL); + D3D11_capture(aviout_monid, NULL, NULL, NULL, NULL); ok = 1; } return ok; @@ -986,7 +986,7 @@ static int getFromRenderTarget(struct avientry *avie) int w, h, bits; HRESULT hr; D3DLOCKED_RECT l; - LPDIRECT3DSURFACE9 s = D3D_capture(0, &w, &h, &bits); + LPDIRECT3DSURFACE9 s = D3D_capture(aviout_monid, &w, &h, &bits); if (s) { hr = s->LockRect(&l, NULL, D3DLOCK_READONLY); if (SUCCEEDED(hr)) { @@ -1044,7 +1044,7 @@ static int getFromDC(struct avientry *avie) HDC hdcMem = NULL; int ok = 1; - hdc = gethdc(avie->monid); + hdc = gethdc(aviout_monid); if (!hdc) return 0; // create a memory device context compatible with the application's current screen @@ -1062,7 +1062,7 @@ static int getFromDC(struct avientry *avie) } DeleteObject(hbitmap); DeleteDC(hdcMem); - releasehdc(avie->monid, hdc); + releasehdc(aviout_monid, hdc); return ok; } @@ -1085,8 +1085,8 @@ extern uae_u8 *bufmem_ptr; static int getFromBuffer(struct avientry *ae, int original) { - struct AmigaMonitor *mon = &AMonitors[0]; - struct vidbuf_description *vidinfo = &adisplays[0].gfxvidinfo; + struct AmigaMonitor *mon = &AMonitors[aviout_monid]; + struct vidbuf_description *vidinfo = &adisplays[aviout_monid].gfxvidinfo; int x, y, w, h, d; uae_u8 *src, *mem; uae_u8 *dst = ae->lpVideo; @@ -1097,11 +1097,11 @@ static int getFromBuffer(struct avientry *ae, int original) dpitch = ((aviout_width_out * avioutput_bits + 31) & ~31) / 8; if (original || WIN32GFX_IsPicassoScreen(mon)) { if (!WIN32GFX_IsPicassoScreen(mon)) { - src = getfilterbuffer(0, &w, &h, &spitch, &d); + src = getfilterbuffer(aviout_monid, &w, &h, &spitch, &d); maxw = vidinfo->outbuffer->outwidth; maxh = vidinfo->outbuffer->outheight; } else { - src = mem = getrtgbuffer(0, &w, &h, &spitch, &d, NULL); + src = mem = getrtgbuffer(aviout_monid, &w, &h, &spitch, &d, NULL); maxw = w; maxh = h; } @@ -1179,14 +1179,14 @@ static int getFromBuffer(struct avientry *ae, int original) src += spitch; } if (mem) - freertgbuffer(0, mem); + freertgbuffer(aviout_monid, mem); return 1; } #endif -void AVIOutput_WriteVideo (void) +static void AVIOutput_WriteVideo(void) { - struct AmigaMonitor *mon = &AMonitors[0]; + struct AmigaMonitor *mon = &AMonitors[aviout_monid]; struct avientry *ae; int v; @@ -1199,7 +1199,7 @@ void AVIOutput_WriteVideo (void) if (avioutput_needs_restart) dorestart (); waitqueuefull (); - ae = allocavientry_video (); + ae = allocavientry_video(); if (avioutput_originalsize || WIN32GFX_IsPicassoScreen(mon)) { v = getFromBuffer (ae, 1); } else { @@ -1386,6 +1386,8 @@ static void AVIOutput_Begin2(bool fullstart, bool immediate) if (!avioutput_requested) return; + aviout_monid = getfocusedmonitor(); + if (avioutput_audio == AVIAUDIO_WAV) { ext1 = _T(".wav"); ext2 = _T(".avi"); } else { @@ -1480,7 +1482,7 @@ static void AVIOutput_Begin2(bool fullstart, bool immediate) } if (avioutput_video) { - ae = allocavientry_video (); + ae = allocavientry_video(); if (!AVIOutput_AllocateVideo ()) goto error; @@ -1546,7 +1548,7 @@ static void AVIOutput_Begin2(bool fullstart, bool immediate) avientryindex = -1; alive = -1; uae_start_thread (_T("aviworker"), AVIOutput_worker, NULL, NULL); - write_log (_T("AVIOutput enabled: video=%d audio=%d path='%s'\n"), avioutput_video, avioutput_audio, avioutput_filename_inuse); + write_log (_T("AVIOutput enabled: monitor=%d video=%d audio=%d path='%s'\n"), aviout_monid, avioutput_video, avioutput_audio, avioutput_filename_inuse); return; error: @@ -1743,15 +1745,17 @@ bool AVIOutput_WriteAudio(uae_u8 *sndbuffer, int sndbufsize) return true; } -bool frame_drawn (void) +bool frame_drawn(int monid) { + if (monid != aviout_monid) + return false; if (!can_record()) return false; start_if_requested(); if (screenshot_multi) { - screenshot(-1, 1, 1); + screenshot(monid, 1, 1); if (screenshot_multi > 0) screenshot_multi--; } @@ -1807,7 +1811,7 @@ bool frame_drawn (void) if (!avioutput_video) return false; - AVIOutput_WriteVideo (); + AVIOutput_WriteVideo(); return true; } diff --git a/od-win32/picasso96_win.cpp b/od-win32/picasso96_win.cpp index 8d6bb272..817f7754 100644 --- a/od-win32/picasso96_win.cpp +++ b/od-win32/picasso96_win.cpp @@ -1159,8 +1159,7 @@ static void picasso_handle_vsync2(struct AmigaMonitor *mon) if (thisisvsync) { rendered = rtg_render(); - if (mon->monitor_id == 0) - frame_drawn(); + frame_drawn(mon->monitor_id); } if (uaegfx) { -- 2.47.3