From e49983754fac665eb329f17203550fd149716c4d Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Fri, 25 Nov 2022 16:00:40 +0100 Subject: [PATCH 1/5] Refactored empty EventArgs --- ScreenCapture.NET/Model/CaptureZone.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ScreenCapture.NET/Model/CaptureZone.cs b/ScreenCapture.NET/Model/CaptureZone.cs index 100263d..bec983b 100644 --- a/ScreenCapture.NET/Model/CaptureZone.cs +++ b/ScreenCapture.NET/Model/CaptureZone.cs @@ -141,7 +141,7 @@ public sealed class CaptureZone IsUpdateRequested = false; BlackBars.InvalidateCache(); - Updated?.Invoke(this, new EventArgs()); + Updated?.Invoke(this, EventArgs.Empty); } /// From 21f0b7e8042e7583a7fda8608d21b3de3a75304c Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Fri, 25 Nov 2022 23:28:35 +0100 Subject: [PATCH 2/5] Added missing doc-comment --- ScreenCapture.NET/Model/CaptureZone.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/ScreenCapture.NET/Model/CaptureZone.cs b/ScreenCapture.NET/Model/CaptureZone.cs index bec983b..e33d59e 100644 --- a/ScreenCapture.NET/Model/CaptureZone.cs +++ b/ScreenCapture.NET/Model/CaptureZone.cs @@ -102,6 +102,7 @@ public sealed class CaptureZone /// The y-location of the region on the screen. /// The width of the region on the screen. /// The height of the region on the screen. + /// The number of bytes per pixel. /// The level of downscaling applied to the image of this region before copying to local memory. /// The original width of the region. /// The original height of the region From c01c1fea0dff88459b928458cf23b4187a453004 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Wed, 22 Feb 2023 23:57:59 +0100 Subject: [PATCH 3/5] Updated Vortice to 2.3 --- .../DirectX/DX11CompatibilityExtensions.cs | 19 +++++ .../DirectX/DX11ScreenCapture.cs | 74 +++++++++---------- ScreenCapture.NET/ScreenCapture.NET.csproj | 2 +- 3 files changed, 57 insertions(+), 38 deletions(-) create mode 100644 ScreenCapture.NET/DirectX/DX11CompatibilityExtensions.cs diff --git a/ScreenCapture.NET/DirectX/DX11CompatibilityExtensions.cs b/ScreenCapture.NET/DirectX/DX11CompatibilityExtensions.cs new file mode 100644 index 0000000..de72e55 --- /dev/null +++ b/ScreenCapture.NET/DirectX/DX11CompatibilityExtensions.cs @@ -0,0 +1,19 @@ +using Vortice.DXGI; + +namespace ScreenCapture.NET; + +// DarthAffe 22.02.2023: These helper-methods where removed from Vortice and are readded here since they are used. +internal static class DX11CompatibilityExtensions +{ + public static IDXGIAdapter1 GetAdapter1(this IDXGIFactory1 factory, int index) + { + factory.EnumAdapters1(index, out IDXGIAdapter1 adapter).CheckError(); + return adapter; + } + + public static IDXGIOutput GetOutput(this IDXGIAdapter1 adapter, int index) + { + adapter.EnumOutputs(index, out IDXGIOutput output).CheckError(); + return output; + } +} \ No newline at end of file diff --git a/ScreenCapture.NET/DirectX/DX11ScreenCapture.cs b/ScreenCapture.NET/DirectX/DX11ScreenCapture.cs index 7afc9fb..3bcda1c 100644 --- a/ScreenCapture.NET/DirectX/DX11ScreenCapture.cs +++ b/ScreenCapture.NET/DirectX/DX11ScreenCapture.cs @@ -305,18 +305,18 @@ public sealed class DX11ScreenCapture : IScreenCapture private void InitializeCaptureZone(in CaptureZone captureZone) { Texture2DDescription stagingTextureDesc = new() - { - CpuAccessFlags = CpuAccessFlags.Read, - BindFlags = BindFlags.None, - Format = Format.B8G8R8A8_UNorm, - Width = captureZone.Width, - Height = captureZone.Height, - OptionFlags = ResourceOptionFlags.None, - MipLevels = 1, - ArraySize = 1, - SampleDescription = { Count = 1, Quality = 0 }, - Usage = ResourceUsage.Staging - }; + { + CPUAccessFlags = CpuAccessFlags.Read, + BindFlags = BindFlags.None, + Format = Format.B8G8R8A8_UNorm, + Width = captureZone.Width, + Height = captureZone.Height, + MiscFlags = ResourceOptionFlags.None, + MipLevels = 1, + ArraySize = 1, + SampleDescription = { Count = 1, Quality = 0 }, + Usage = ResourceUsage.Staging + }; ID3D11Texture2D stagingTexture = _device!.CreateTexture2D(stagingTextureDesc); ID3D11Texture2D? scalingTexture = null; @@ -324,18 +324,18 @@ public sealed class DX11ScreenCapture : IScreenCapture if (captureZone.DownscaleLevel > 0) { Texture2DDescription scalingTextureDesc = new() - { - CpuAccessFlags = CpuAccessFlags.None, - BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource, - Format = Format.B8G8R8A8_UNorm, - Width = captureZone.UnscaledWidth, - Height = captureZone.UnscaledHeight, - OptionFlags = ResourceOptionFlags.GenerateMips, - MipLevels = captureZone.DownscaleLevel + 1, - ArraySize = 1, - SampleDescription = { Count = 1, Quality = 0 }, - Usage = ResourceUsage.Default - }; + { + CPUAccessFlags = CpuAccessFlags.None, + BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource, + Format = Format.B8G8R8A8_UNorm, + Width = captureZone.UnscaledWidth, + Height = captureZone.UnscaledHeight, + MiscFlags = ResourceOptionFlags.GenerateMips, + MipLevels = captureZone.DownscaleLevel + 1, + ArraySize = 1, + SampleDescription = { Count = 1, Quality = 0 }, + Usage = ResourceUsage.Default + }; scalingTexture = _device!.CreateTexture2D(scalingTextureDesc); scalingTextureView = _device.CreateShaderResourceView(scalingTexture); } @@ -362,18 +362,18 @@ public sealed class DX11ScreenCapture : IScreenCapture using IDXGIOutput5 output = _output.QueryInterface(); Texture2DDescription captureTextureDesc = new() - { - CpuAccessFlags = CpuAccessFlags.None, - BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource, - Format = Format.B8G8R8A8_UNorm, - Width = Display.Width, - Height = Display.Height, - OptionFlags = ResourceOptionFlags.None, - MipLevels = 1, - ArraySize = 1, - SampleDescription = { Count = 1, Quality = 0 }, - Usage = ResourceUsage.Default - }; + { + CPUAccessFlags = CpuAccessFlags.None, + BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource, + Format = Format.B8G8R8A8_UNorm, + Width = Display.Width, + Height = Display.Height, + MiscFlags = ResourceOptionFlags.None, + MipLevels = 1, + ArraySize = 1, + SampleDescription = { Count = 1, Quality = 0 }, + Usage = ResourceUsage.Default + }; _captureTexture = _device.CreateTexture2D(captureTextureDesc); lock (_captureZones) @@ -383,7 +383,7 @@ public sealed class DX11ScreenCapture : IScreenCapture } if (_useNewDuplicationAdapter) - _duplicatedOutput = output.DuplicateOutput1(_device, Format.B8G8R8A8_UNorm); // DarthAffe 27.02.2021: This prepares for the use of 10bit color depth + _duplicatedOutput = output.DuplicateOutput1(_device, new[] { Format.B8G8R8A8_UNorm }); // DarthAffe 27.02.2021: This prepares for the use of 10bit color depth else _duplicatedOutput = output.DuplicateOutput(_device); } diff --git a/ScreenCapture.NET/ScreenCapture.NET.csproj b/ScreenCapture.NET/ScreenCapture.NET.csproj index b3f3072..d0cb645 100644 --- a/ScreenCapture.NET/ScreenCapture.NET.csproj +++ b/ScreenCapture.NET/ScreenCapture.NET.csproj @@ -64,7 +64,7 @@ - + From 48951f08ea111b1206b52a8b8bdb77e5cb4c9279 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Wed, 22 Feb 2023 23:58:32 +0100 Subject: [PATCH 4/5] Added net7-target removed unsupported net5 --- ScreenCapture.NET/ScreenCapture.NET.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ScreenCapture.NET/ScreenCapture.NET.csproj b/ScreenCapture.NET/ScreenCapture.NET.csproj index d0cb645..43a53a3 100644 --- a/ScreenCapture.NET/ScreenCapture.NET.csproj +++ b/ScreenCapture.NET/ScreenCapture.NET.csproj @@ -1,6 +1,6 @@  - net6.0;net5.0 + net7.0;net6.0 latest enable true From 67fb24bf47515c91d6846f5c4749e03e23cfea00 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Thu, 23 Feb 2023 00:01:19 +0100 Subject: [PATCH 5/5] Bumped version to 1.2.1 --- ScreenCapture.NET/ScreenCapture.NET.csproj | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ScreenCapture.NET/ScreenCapture.NET.csproj b/ScreenCapture.NET/ScreenCapture.NET.csproj index 43a53a3..852f83f 100644 --- a/ScreenCapture.NET/ScreenCapture.NET.csproj +++ b/ScreenCapture.NET/ScreenCapture.NET.csproj @@ -16,8 +16,8 @@ ScreenCapture.NET Vortice based Screen-Capturing Vortice based Screen-Capturing using Desktop Duplication - Copyright © Darth Affe 2022 - Copyright © Darth Affe 2022 + Copyright © Darth Affe 2023 + Copyright © Darth Affe 2023 icon.png https://github.com/DarthAffe/ScreenCapture.NET LGPL-2.1-only @@ -26,14 +26,14 @@ True - - Added IScreenCapture.UpdateCaptureZone to modify existing CaptureZones without having to remove and add them again. - (This has performance benefits when only X and/or Y is changed, changes to width, height and downscale are internally still reinitializing the zone.) - - Fixed ambiguous equals in Display + - Updated Vortice + - Added .NET 7 Target + - Removed unsupported .NET 5 Target - 1.2.0 - 1.2.0 - 1.2.0 + 1.2.1 + 1.2.1 + 1.2.1 ..\bin\ true