Skip to content

Commit f55fa6a

Browse files
committed
Splitted the DX11 Screen Capture logic into a separate project
1 parent 18e5625 commit f55fa6a

File tree

9 files changed

+100
-10
lines changed

9 files changed

+100
-10
lines changed

ScreenCapture.NET/DirectX/DX11CompatibilityExtensions.cs renamed to ScreenCapture.NET.DX11/DX11CompatibilityExtensions.cs

File renamed without changes.
File renamed without changes.

ScreenCapture.NET/DirectX/DX11ScreenCaptureService.cs renamed to ScreenCapture.NET.DX11/DX11ScreenCaptureService.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ public class DX11ScreenCaptureService : IScreenCaptureService
1212
#region Properties & Fields
1313

1414
private readonly IDXGIFactory1 _factory;
15-
1615
private readonly Dictionary<Display, DX11ScreenCapture> _screenCaptures = new();
1716

17+
private bool _isDisposed;
18+
1819
#endregion
1920

2021
#region Constructors
@@ -27,13 +28,17 @@ public DX11ScreenCaptureService()
2728
DXGI.CreateDXGIFactory1(out _factory!).CheckError();
2829
}
2930

31+
~DX11ScreenCaptureService() => Dispose();
32+
3033
#endregion
3134

3235
#region Methods
3336

3437
/// <inheritdoc />
3538
public IEnumerable<GraphicsCard> GetGraphicsCards()
3639
{
40+
if (_isDisposed) throw new ObjectDisposedException(GetType().FullName);
41+
3742
int i = 0;
3843
while (_factory.EnumAdapters1(i, out IDXGIAdapter1 adapter).Success)
3944
{
@@ -46,6 +51,8 @@ public IEnumerable<GraphicsCard> GetGraphicsCards()
4651
/// <inheritdoc />
4752
public IEnumerable<Display> GetDisplays(GraphicsCard graphicsCard)
4853
{
54+
if (_isDisposed) throw new ObjectDisposedException(GetType().FullName);
55+
4956
using IDXGIAdapter1? adapter = _factory.GetAdapter1(graphicsCard.Index);
5057

5158
int i = 0;
@@ -71,6 +78,8 @@ public IEnumerable<Display> GetDisplays(GraphicsCard graphicsCard)
7178
IScreenCapture IScreenCaptureService.GetScreenCapture(Display display) => GetScreenCapture(display);
7279
public DX11ScreenCapture GetScreenCapture(Display display)
7380
{
81+
if (_isDisposed) throw new ObjectDisposedException(GetType().FullName);
82+
7483
if (!_screenCaptures.TryGetValue(display, out DX11ScreenCapture? screenCapture))
7584
_screenCaptures.Add(display, screenCapture = new DX11ScreenCapture(_factory, display));
7685
return screenCapture;
@@ -79,13 +88,17 @@ public DX11ScreenCapture GetScreenCapture(Display display)
7988
/// <inheritdoc />
8089
public void Dispose()
8190
{
91+
if (_isDisposed) return;
92+
8293
foreach (DX11ScreenCapture screenCapture in _screenCaptures.Values)
8394
screenCapture.Dispose();
8495
_screenCaptures.Clear();
8596

8697
_factory.Dispose();
8798

8899
GC.SuppressFinalize(this);
100+
101+
_isDisposed = true;
89102
}
90103

91104
#endregion
File renamed without changes.
705 Bytes
Loading
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFrameworks>net7.0-windows;net6.0-windows</TargetFrameworks>
4+
<LangVersion>latest</LangVersion>
5+
<Nullable>enable</Nullable>
6+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
7+
8+
<Authors>Darth Affe</Authors>
9+
<Company>Wyrez</Company>
10+
<Language>en-US</Language>
11+
<NeutralLanguage>en-US</NeutralLanguage>
12+
<Title>ScreenCapture.NET.DX11</Title>
13+
<AssemblyName>ScreenCapture.NET.DX11</AssemblyName>
14+
<AssemblyTitle>ScreenCapture.NET.DX11</AssemblyTitle>
15+
<PackageId>ScreenCapture.NET.DX11</PackageId>
16+
<RootNamespace>ScreenCapture.NET</RootNamespace>
17+
<Description>Vortice based Screen-Capturing</Description>
18+
<Summary>Vortice based Screen-Capturing using Desktop Duplication</Summary>
19+
<Copyright>Copyright © Darth Affe 2023</Copyright>
20+
<PackageCopyright>Copyright © Darth Affe 2023</PackageCopyright>
21+
<PackageIcon>icon.png</PackageIcon>
22+
<PackageProjectUrl>https://github.com/DarthAffe/ScreenCapture.NET</PackageProjectUrl>
23+
<PackageLicenseExpression>LGPL-2.1-only</PackageLicenseExpression>
24+
<RepositoryType>Github</RepositoryType>
25+
<RepositoryUrl>https://github.com/DarthAffe/ScreenCapture.NET</RepositoryUrl>
26+
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
27+
28+
<PackageReleaseNotes>
29+
The downscale-level is now automatically limited if it would scale the image below a size of 1x1 px.
30+
This is change that can potentially break existing behavior but should only affect cases that are expected to crash with earlier versions.
31+
</PackageReleaseNotes>
32+
33+
<Version>1.3.2</Version>
34+
<AssemblyVersion>1.3.2</AssemblyVersion>
35+
<FileVersion>1.3.2</FileVersion>
36+
37+
<OutputPath>..\bin\</OutputPath>
38+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
39+
<IncludeSource>True</IncludeSource>
40+
<IncludeSymbols>True</IncludeSymbols>
41+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
42+
</PropertyGroup>
43+
44+
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
45+
<DefineConstants>$(DefineConstants);TRACE;DEBUG</DefineConstants>
46+
<DebugSymbols>true</DebugSymbols>
47+
<DebugType>full</DebugType>
48+
<Optimize>false</Optimize>
49+
</PropertyGroup>
50+
51+
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
52+
<DebugType>portable</DebugType>
53+
<Optimize>true</Optimize>
54+
<NoWarn>$(NoWarn);CS1591;CS1572;CS1573</NoWarn>
55+
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
56+
</PropertyGroup>
57+
58+
<ItemGroup>
59+
<None Include="Resources\icon.png">
60+
<Pack>True</Pack>
61+
<PackagePath></PackagePath>
62+
</None>
63+
</ItemGroup>
64+
65+
<ItemGroup>
66+
<PackageReference Include="Vortice.Direct3D11" Version="2.4.2" />
67+
</ItemGroup>
68+
69+
<ItemGroup>
70+
<ProjectReference Include="..\..\..\..\..\Darth Affe\Source\Repos\ScreenCapture.NET\ScreenCapture.NET\ScreenCapture.NET.csproj" />
71+
</ItemGroup>
72+
73+
</Project>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=helper/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

ScreenCapture.NET.sln

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.31025.194
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.6.33829.357
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScreenCapture.NET", "ScreenCapture.NET\ScreenCapture.NET.csproj", "{90596344-E012-4534-A933-3BD1B55469DC}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScreenCapture.NET", "ScreenCapture.NET\ScreenCapture.NET.csproj", "{90596344-E012-4534-A933-3BD1B55469DC}"
7+
EndProject
8+
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}"
79
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -15,6 +17,10 @@ Global
1517
{90596344-E012-4534-A933-3BD1B55469DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
1618
{90596344-E012-4534-A933-3BD1B55469DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
1719
{90596344-E012-4534-A933-3BD1B55469DC}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{58A09AD8-D66F-492E-8BC7-62BDB85E57EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{58A09AD8-D66F-492E-8BC7-62BDB85E57EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{58A09AD8-D66F-492E-8BC7-62BDB85E57EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{58A09AD8-D66F-492E-8BC7-62BDB85E57EC}.Release|Any CPU.Build.0 = Release|Any CPU
1824
EndGlobalSection
1925
GlobalSection(SolutionProperties) = preSolution
2026
HideSolutionNode = FALSE

ScreenCapture.NET/ScreenCapture.NET.csproj

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
<AssemblyTitle>ScreenCapture.NET</AssemblyTitle>
1515
<PackageId>ScreenCapture.NET</PackageId>
1616
<RootNamespace>ScreenCapture.NET</RootNamespace>
17-
<Description>Vortice based Screen-Capturing</Description>
18-
<Summary>Vortice based Screen-Capturing using Desktop Duplication</Summary>
17+
<Description>Core functionality for Screen-Capturing</Description>
18+
<Summary>Base package for ScreenCapture.NET projects</Summary>
1919
<Copyright>Copyright © Darth Affe 2023</Copyright>
2020
<PackageCopyright>Copyright © Darth Affe 2023</PackageCopyright>
2121
<PackageIcon>icon.png</PackageIcon>
@@ -62,8 +62,4 @@
6262
</None>
6363
</ItemGroup>
6464

65-
<ItemGroup>
66-
<PackageReference Include="Vortice.Direct3D11" Version="2.4.2" />
67-
</ItemGroup>
68-
6965
</Project>

0 commit comments

Comments
 (0)