GNOME Bugzilla – Bug 760172
dx9screencapsrc: add "cursor" option to draw the cursor
Last modified: 2016-11-02 08:40:00 UTC
Created attachment 318272 [details] [review] dx9screencapsrc cursor patch Drawing is done via the GDI drawing functions. The cursor is converted to a monochrome version before drawing. This is because the GDI drawing functions seem to have undefined behavior with cursor images including an alpha channel. I could not find any other reliable way to draw these alpha channel cursors without producing unwanted artifacts. These type of cursors were introduced with Window Vista when run with it's Aero theme. Also adjust the cursor coordinates when capturing non-primary screens via the "monitor" option. -- This is close to the version found in the "gdiscreencapsrc" element of the same plugin. I think the gdi version is lacking support for non-primary screens though (but I may not have been looking close enough). Also it took me quite some time on figuring out on how to reliably draw the cursor due to the behavior of alpha channel cursors. It depends on the application if it shows a monochrome or alpha channel cursor on _modern_ Windows systems. This looked like the cursor was _randomly_ disappearing in the captured image. This now should reliably draw a cursor into the image - with a little loss of fidelity. Usually it is the cursor's drop shadow effect that is missing.
Review of attachment 318272 [details] [review]: ::: sys/winscreencap/gstdx9screencapsrc.c @@ +563,3 @@ + GetIconInfo (ci.hCursor, &ii); + + if (SUCCEEDED (IDirect3DSurface9_GetDC (src->surface, &memDC))) { Wouldn't it be possible to use D3D functions to render the cursor directly over the surface? Maybe by first converting the cursor into a D3D surface? That probably also solves the problem that required first converting it to monochrome.
I cannot tell to be honest. I do not know the DirectX API well enough. I gave it my best shot with the GDI way to be a useful feature :-) I briefly looked into the DirectX surface drawing API. But I'm completely puzzled how I would even load HICON/HCURSOR data into a DirectX9 surface. Also drawing one surface onto another seems to have a lot of restrictions which seem unfulfilled currently (the surface creation flags I think at least). I'm afraid I'm not getting any further here. If anyone else move things around to be fully DirectX-ishy I would be happy.
Ping. What is the current stance on the provided patch? In case none comes up with a better way, is this acceptable as an additional feature? It would help me if this was part of some official release some day..
Any other opinions on this? Otherwise we might as well merge this, it seems like a useful feature to have.
commit 8960debc249a6d0eb4589ef04f77428762e92d33 Author: Florian Zwoch <fzwoch@gmail.com> Date: Tue Jan 5 18:50:45 2016 +0100 dx9screencapsrc: add "cursor" option to draw the cursor Drawing is done via the GDI drawing functions. The cursor is converted to a monochrome version before drawing. This is because the GDI drawing functions seem to have undefined behavior with cursor images including an alpha channel. I could not find any other reliable way to draw these alpha channel cursors without producing unwanted artifacts. These type of cursors were introduced with Window Vista when run with it's Aero theme. Also adjust the cursor coordinates when capturing non-primary screens via the "monitor" option. https://bugzilla.gnome.org/show_bug.cgi?id=760172