After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 760172 - dx9screencapsrc: add "cursor" option to draw the cursor
dx9screencapsrc: add "cursor" option to draw the cursor
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Windows
: Normal enhancement
: 1.11.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-01-05 18:31 UTC by Florian Zwoch
Modified: 2016-11-02 08:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
dx9screencapsrc cursor patch (5.04 KB, patch)
2016-01-05 18:31 UTC, Florian Zwoch
committed Details | Review

Description Florian Zwoch 2016-01-05 18:31:13 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.
Comment 1 Sebastian Dröge (slomo) 2016-01-06 09:21:00 UTC
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.
Comment 2 Florian Zwoch 2016-01-06 13:38:44 UTC
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.
Comment 3 Florian Zwoch 2016-03-04 09:16:28 UTC
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..
Comment 4 Sebastian Dröge (slomo) 2016-09-26 06:32:11 UTC
Any other opinions on this? Otherwise we might as well merge this, it seems like a useful feature to have.
Comment 5 Sebastian Dröge (slomo) 2016-11-02 08:39:26 UTC
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