d3d11screencapture: Fix missing/outdated cursor shape

d3d11screencapture can miss a cursor shape to draw or draw an outdated cursor shape.
 - AcquireNextFrame only provides cursor shape when there is one update
 - current d3d11screencapture skips cursor shape when mouse is not drawn

So, if a gstreamer application uses d3d11screencapture with cursor initially not drawn
"show-cursor"=false and then switches this property to true, the cursor will not be
actually drawn until AcquireNextFrame provides a new cursor shape.
This commit makes d3d11screencapture always update the cursor shape information, even
if the mouse is not drawn. d3d11screencapture will always have the latest cursor shape
when requested to draw it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2485>
This commit is contained in:
Erwann Gouesbet 2022-05-24 11:06:39 +02:00 committed by GStreamer Marge Bot
parent 79c3bbc2ed
commit 09a45c37ca

View file

@ -296,7 +296,7 @@ public:
}
GstFlowReturn
Capture (gboolean draw_mouse)
Capture ()
{
GstFlowReturn ret;
bool timeout = false;
@ -315,14 +315,12 @@ public:
return GST_FLOW_OK;
}
if (draw_mouse) {
GST_TRACE ("Getting mouse pointer info");
ret = GetMouse (&ptr_info_, &frame_info);
if (ret != GST_FLOW_OK) {
GST_WARNING ("Couldn't get mouse pointer info");
dupl_->ReleaseFrame ();
return ret;
}
GST_TRACE ("Getting mouse pointer info");
ret = GetMouse (&ptr_info_, &frame_info);
if (ret != GST_FLOW_OK) {
GST_WARNING ("Couldn't get mouse pointer info");
dupl_->ReleaseFrame ();
return ret;
}
ret = ProcessFrame (texture.Get(), shared_texture_.Get(),
@ -771,10 +769,6 @@ private:
ptr_info->LastTimeStamp = frame_info->LastMouseUpdateTime;
ptr_info->Visible = frame_info->PointerPosition.Visible != 0;
/* Mouse is invisible */
if (!ptr_info->Visible)
return GST_FLOW_OK;
/* No new shape */
if (frame_info->PointerShapeBufferSize == 0)
return GST_FLOW_OK;
@ -782,7 +776,9 @@ private:
/* Realloc buffer if needed */
ptr_info->MaybeReallocBuffer (frame_info->PointerShapeBufferSize);
/* Get shape */
/* Must always get shape of cursor, even if not drawn at the moment.
* Shape of cursor is not repeated by the AcquireNextFrame and can be
* requested to be drawn any time later */
UINT dummy;
HRESULT hr = dupl_->GetFramePointerShape(frame_info->PointerShapeBufferSize,
(void *) ptr_info->PtrShapeBuffer, &dummy, &ptr_info->shape_info);
@ -1887,7 +1883,7 @@ gst_d3d11_screen_capture_do_capture (GstD3D11ScreenCapture * capture,
}
gst_d3d11_device_lock (capture->device);
ret = capture->dupl_obj->Capture (draw_mouse);
ret = capture->dupl_obj->Capture ();
if (ret != GST_FLOW_OK) {
gst_d3d11_device_unlock (capture->device);