From f55fa6a7014bc063a6a7a8b0b85926155b577c9f Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Tue, 5 Sep 2023 22:44:06 +0200 Subject: [PATCH] Splitted the DX11 Screen Capture logic into a separate project --- .../DX11CompatibilityExtensions.cs | 0 .../DX11ScreenCapture.cs | 0 .../DX11ScreenCaptureService.cs | 15 +++- .../Helper/DPIAwareness.cs | 0 ScreenCapture.NET.DX11/Resources/icon.png | Bin 0 -> 705 bytes .../ScreenCapture.NET.DX11.csproj | 73 ++++++++++++++++++ .../ScreenCapture.NET.DX11.csproj.DotSettings | 2 + ScreenCapture.NET.sln | 12 ++- ScreenCapture.NET/ScreenCapture.NET.csproj | 8 +- 9 files changed, 100 insertions(+), 10 deletions(-) rename {ScreenCapture.NET/DirectX => ScreenCapture.NET.DX11}/DX11CompatibilityExtensions.cs (100%) rename {ScreenCapture.NET/DirectX => ScreenCapture.NET.DX11}/DX11ScreenCapture.cs (100%) rename {ScreenCapture.NET/DirectX => ScreenCapture.NET.DX11}/DX11ScreenCaptureService.cs (88%) rename {ScreenCapture.NET => ScreenCapture.NET.DX11}/Helper/DPIAwareness.cs (100%) create mode 100644 ScreenCapture.NET.DX11/Resources/icon.png create mode 100644 ScreenCapture.NET.DX11/ScreenCapture.NET.DX11.csproj create mode 100644 ScreenCapture.NET.DX11/ScreenCapture.NET.DX11.csproj.DotSettings diff --git a/ScreenCapture.NET/DirectX/DX11CompatibilityExtensions.cs b/ScreenCapture.NET.DX11/DX11CompatibilityExtensions.cs similarity index 100% rename from ScreenCapture.NET/DirectX/DX11CompatibilityExtensions.cs rename to ScreenCapture.NET.DX11/DX11CompatibilityExtensions.cs diff --git a/ScreenCapture.NET/DirectX/DX11ScreenCapture.cs b/ScreenCapture.NET.DX11/DX11ScreenCapture.cs similarity index 100% rename from ScreenCapture.NET/DirectX/DX11ScreenCapture.cs rename to ScreenCapture.NET.DX11/DX11ScreenCapture.cs diff --git a/ScreenCapture.NET/DirectX/DX11ScreenCaptureService.cs b/ScreenCapture.NET.DX11/DX11ScreenCaptureService.cs similarity index 88% rename from ScreenCapture.NET/DirectX/DX11ScreenCaptureService.cs rename to ScreenCapture.NET.DX11/DX11ScreenCaptureService.cs index 28d0fce..40363a8 100644 --- a/ScreenCapture.NET/DirectX/DX11ScreenCaptureService.cs +++ b/ScreenCapture.NET.DX11/DX11ScreenCaptureService.cs @@ -12,9 +12,10 @@ public class DX11ScreenCaptureService : IScreenCaptureService #region Properties & Fields private readonly IDXGIFactory1 _factory; - private readonly Dictionary _screenCaptures = new(); + private bool _isDisposed; + #endregion #region Constructors @@ -27,6 +28,8 @@ public class DX11ScreenCaptureService : IScreenCaptureService DXGI.CreateDXGIFactory1(out _factory!).CheckError(); } + ~DX11ScreenCaptureService() => Dispose(); + #endregion #region Methods @@ -34,6 +37,8 @@ public class DX11ScreenCaptureService : IScreenCaptureService /// public IEnumerable GetGraphicsCards() { + if (_isDisposed) throw new ObjectDisposedException(GetType().FullName); + int i = 0; while (_factory.EnumAdapters1(i, out IDXGIAdapter1 adapter).Success) { @@ -46,6 +51,8 @@ public class DX11ScreenCaptureService : IScreenCaptureService /// public IEnumerable GetDisplays(GraphicsCard graphicsCard) { + if (_isDisposed) throw new ObjectDisposedException(GetType().FullName); + using IDXGIAdapter1? adapter = _factory.GetAdapter1(graphicsCard.Index); int i = 0; @@ -71,6 +78,8 @@ public class DX11ScreenCaptureService : IScreenCaptureService IScreenCapture IScreenCaptureService.GetScreenCapture(Display display) => GetScreenCapture(display); public DX11ScreenCapture GetScreenCapture(Display display) { + if (_isDisposed) throw new ObjectDisposedException(GetType().FullName); + if (!_screenCaptures.TryGetValue(display, out DX11ScreenCapture? screenCapture)) _screenCaptures.Add(display, screenCapture = new DX11ScreenCapture(_factory, display)); return screenCapture; @@ -79,6 +88,8 @@ public class DX11ScreenCaptureService : IScreenCaptureService /// public void Dispose() { + if (_isDisposed) return; + foreach (DX11ScreenCapture screenCapture in _screenCaptures.Values) screenCapture.Dispose(); _screenCaptures.Clear(); @@ -86,6 +97,8 @@ public class DX11ScreenCaptureService : IScreenCaptureService _factory.Dispose(); GC.SuppressFinalize(this); + + _isDisposed = true; } #endregion diff --git a/ScreenCapture.NET/Helper/DPIAwareness.cs b/ScreenCapture.NET.DX11/Helper/DPIAwareness.cs similarity index 100% rename from ScreenCapture.NET/Helper/DPIAwareness.cs rename to ScreenCapture.NET.DX11/Helper/DPIAwareness.cs diff --git a/ScreenCapture.NET.DX11/Resources/icon.png b/ScreenCapture.NET.DX11/Resources/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..46c50338bdcd4535ff63138ab7030dab6b11e747 GIT binary patch literal 705 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7uRSY)RhkE(}r(cNo+^b@?U(MK}vQ zB8wRq_zr_Gjld?%{_ ztr9WvFf!(ud)_hqTTgv1lK=yg0|Q4xQ(Jdkg4JB9rJ^Rjo9|v{Of#O&87B4MV8Tqx z4J--_EDa10g$#`NIO`H_d}WsCKYsQ3gY4<$_kLD0Pp^0{GYzUeVYwf(_)H(Qv`p5; z7c+MIGuOJDO*?*FD1jft^xe4+S2zAkKQD-8--fqso^qvsB>H@v%YPLtyk9P!U(~eM zu*KE;fR(M!C!>@57OoXPuv_IkZ|2#}4d!b5->DVYpZxAC`z@F0_kPYj*=M(deB*G^ zH{q7=1KrsNX3ajJQaS6%@`vkov(%jXmobia3;O{% zghLi|+^bJ?xonb_*<4kxD&Wn)1Pnm9boPaI?Z*D<4-)s(cGjN#{!{m)Hs`m)h0mrh zS^xQ3_j$KXED=m)r~azw7k%Bn+TNq+^DOz-k(2!Yf2@8#xn|0{{e6@Eym}CD@95hT zCGlkuDUbB;@%jF~)BCL;O1EM2x1H1Pv)uD83NZN7{B5T-w*!L+--1u#(!YX^mkIcB z + + net7.0-windows;net6.0-windows + latest + enable + true + + Darth Affe + Wyrez + en-US + en-US + ScreenCapture.NET.DX11 + ScreenCapture.NET.DX11 + ScreenCapture.NET.DX11 + ScreenCapture.NET.DX11 + ScreenCapture.NET + Vortice based Screen-Capturing + Vortice based Screen-Capturing using Desktop Duplication + Copyright © Darth Affe 2023 + Copyright © Darth Affe 2023 + icon.png + https://github.com/DarthAffe/ScreenCapture.NET + LGPL-2.1-only + Github + https://github.com/DarthAffe/ScreenCapture.NET + True + + + The downscale-level is now automatically limited if it would scale the image below a size of 1x1 px. + This is change that can potentially break existing behavior but should only affect cases that are expected to crash with earlier versions. + + + 1.3.2 + 1.3.2 + 1.3.2 + + ..\bin\ + true + True + True + snupkg + + + + $(DefineConstants);TRACE;DEBUG + true + full + false + + + + portable + true + $(NoWarn);CS1591;CS1572;CS1573 + $(DefineConstants);RELEASE + + + + + True + + + + + + + + + + + + + diff --git a/ScreenCapture.NET.DX11/ScreenCapture.NET.DX11.csproj.DotSettings b/ScreenCapture.NET.DX11/ScreenCapture.NET.DX11.csproj.DotSettings new file mode 100644 index 0000000..bdcca3e --- /dev/null +++ b/ScreenCapture.NET.DX11/ScreenCapture.NET.DX11.csproj.DotSettings @@ -0,0 +1,2 @@ + + True \ No newline at end of file diff --git a/ScreenCapture.NET.sln b/ScreenCapture.NET.sln index 3888c2c..5691b86 100644 --- a/ScreenCapture.NET.sln +++ b/ScreenCapture.NET.sln @@ -1,9 +1,11 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31025.194 +# Visual Studio Version 17 +VisualStudioVersion = 17.6.33829.357 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScreenCapture.NET", "ScreenCapture.NET\ScreenCapture.NET.csproj", "{90596344-E012-4534-A933-3BD1B55469DC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScreenCapture.NET", "ScreenCapture.NET\ScreenCapture.NET.csproj", "{90596344-E012-4534-A933-3BD1B55469DC}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScreenCapture.NET.DX11", "..\..\..\..\DarthAffe\Source\Repos\ScreenCapture.NET\ScreenCapture.NET.DX11\ScreenCapture.NET.DX11.csproj", "{58A09AD8-D66F-492E-8BC7-62BDB85E57EC}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,6 +17,10 @@ Global {90596344-E012-4534-A933-3BD1B55469DC}.Debug|Any CPU.Build.0 = Debug|Any CPU {90596344-E012-4534-A933-3BD1B55469DC}.Release|Any CPU.ActiveCfg = Release|Any CPU {90596344-E012-4534-A933-3BD1B55469DC}.Release|Any CPU.Build.0 = Release|Any CPU + {58A09AD8-D66F-492E-8BC7-62BDB85E57EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {58A09AD8-D66F-492E-8BC7-62BDB85E57EC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {58A09AD8-D66F-492E-8BC7-62BDB85E57EC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {58A09AD8-D66F-492E-8BC7-62BDB85E57EC}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ScreenCapture.NET/ScreenCapture.NET.csproj b/ScreenCapture.NET/ScreenCapture.NET.csproj index 49dfad2..63094cd 100644 --- a/ScreenCapture.NET/ScreenCapture.NET.csproj +++ b/ScreenCapture.NET/ScreenCapture.NET.csproj @@ -14,8 +14,8 @@ ScreenCapture.NET ScreenCapture.NET ScreenCapture.NET - Vortice based Screen-Capturing - Vortice based Screen-Capturing using Desktop Duplication + Core functionality for Screen-Capturing + Base package for ScreenCapture.NET projects Copyright © Darth Affe 2023 Copyright © Darth Affe 2023 icon.png @@ -62,8 +62,4 @@ - - - -