mirror of
https://github.com/DarthAffe/ScreenCapture.NET.git
synced 2025-12-12 21:38:42 +00:00
Splitted the DX11 Screen Capture logic into a separate project
This commit is contained in:
parent
18e562508e
commit
f55fa6a701
@ -12,9 +12,10 @@ public class DX11ScreenCaptureService : IScreenCaptureService
|
|||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
private readonly IDXGIFactory1 _factory;
|
private readonly IDXGIFactory1 _factory;
|
||||||
|
|
||||||
private readonly Dictionary<Display, DX11ScreenCapture> _screenCaptures = new();
|
private readonly Dictionary<Display, DX11ScreenCapture> _screenCaptures = new();
|
||||||
|
|
||||||
|
private bool _isDisposed;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
@ -27,6 +28,8 @@ public class DX11ScreenCaptureService : IScreenCaptureService
|
|||||||
DXGI.CreateDXGIFactory1(out _factory!).CheckError();
|
DXGI.CreateDXGIFactory1(out _factory!).CheckError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~DX11ScreenCaptureService() => Dispose();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
@ -34,6 +37,8 @@ public class DX11ScreenCaptureService : IScreenCaptureService
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IEnumerable<GraphicsCard> GetGraphicsCards()
|
public IEnumerable<GraphicsCard> GetGraphicsCards()
|
||||||
{
|
{
|
||||||
|
if (_isDisposed) throw new ObjectDisposedException(GetType().FullName);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (_factory.EnumAdapters1(i, out IDXGIAdapter1 adapter).Success)
|
while (_factory.EnumAdapters1(i, out IDXGIAdapter1 adapter).Success)
|
||||||
{
|
{
|
||||||
@ -46,6 +51,8 @@ public class DX11ScreenCaptureService : IScreenCaptureService
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IEnumerable<Display> GetDisplays(GraphicsCard graphicsCard)
|
public IEnumerable<Display> GetDisplays(GraphicsCard graphicsCard)
|
||||||
{
|
{
|
||||||
|
if (_isDisposed) throw new ObjectDisposedException(GetType().FullName);
|
||||||
|
|
||||||
using IDXGIAdapter1? adapter = _factory.GetAdapter1(graphicsCard.Index);
|
using IDXGIAdapter1? adapter = _factory.GetAdapter1(graphicsCard.Index);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@ -71,6 +78,8 @@ public class DX11ScreenCaptureService : IScreenCaptureService
|
|||||||
IScreenCapture IScreenCaptureService.GetScreenCapture(Display display) => GetScreenCapture(display);
|
IScreenCapture IScreenCaptureService.GetScreenCapture(Display display) => GetScreenCapture(display);
|
||||||
public DX11ScreenCapture GetScreenCapture(Display display)
|
public DX11ScreenCapture GetScreenCapture(Display display)
|
||||||
{
|
{
|
||||||
|
if (_isDisposed) throw new ObjectDisposedException(GetType().FullName);
|
||||||
|
|
||||||
if (!_screenCaptures.TryGetValue(display, out DX11ScreenCapture? screenCapture))
|
if (!_screenCaptures.TryGetValue(display, out DX11ScreenCapture? screenCapture))
|
||||||
_screenCaptures.Add(display, screenCapture = new DX11ScreenCapture(_factory, display));
|
_screenCaptures.Add(display, screenCapture = new DX11ScreenCapture(_factory, display));
|
||||||
return screenCapture;
|
return screenCapture;
|
||||||
@ -79,6 +88,8 @@ public class DX11ScreenCaptureService : IScreenCaptureService
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
if (_isDisposed) return;
|
||||||
|
|
||||||
foreach (DX11ScreenCapture screenCapture in _screenCaptures.Values)
|
foreach (DX11ScreenCapture screenCapture in _screenCaptures.Values)
|
||||||
screenCapture.Dispose();
|
screenCapture.Dispose();
|
||||||
_screenCaptures.Clear();
|
_screenCaptures.Clear();
|
||||||
@ -86,6 +97,8 @@ public class DX11ScreenCaptureService : IScreenCaptureService
|
|||||||
_factory.Dispose();
|
_factory.Dispose();
|
||||||
|
|
||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
|
|
||||||
|
_isDisposed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
BIN
ScreenCapture.NET.DX11/Resources/icon.png
Normal file
BIN
ScreenCapture.NET.DX11/Resources/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 705 B |
73
ScreenCapture.NET.DX11/ScreenCapture.NET.DX11.csproj
Normal file
73
ScreenCapture.NET.DX11/ScreenCapture.NET.DX11.csproj
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFrameworks>net7.0-windows;net6.0-windows</TargetFrameworks>
|
||||||
|
<LangVersion>latest</LangVersion>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
|
||||||
|
<Authors>Darth Affe</Authors>
|
||||||
|
<Company>Wyrez</Company>
|
||||||
|
<Language>en-US</Language>
|
||||||
|
<NeutralLanguage>en-US</NeutralLanguage>
|
||||||
|
<Title>ScreenCapture.NET.DX11</Title>
|
||||||
|
<AssemblyName>ScreenCapture.NET.DX11</AssemblyName>
|
||||||
|
<AssemblyTitle>ScreenCapture.NET.DX11</AssemblyTitle>
|
||||||
|
<PackageId>ScreenCapture.NET.DX11</PackageId>
|
||||||
|
<RootNamespace>ScreenCapture.NET</RootNamespace>
|
||||||
|
<Description>Vortice based Screen-Capturing</Description>
|
||||||
|
<Summary>Vortice based Screen-Capturing using Desktop Duplication</Summary>
|
||||||
|
<Copyright>Copyright © Darth Affe 2023</Copyright>
|
||||||
|
<PackageCopyright>Copyright © Darth Affe 2023</PackageCopyright>
|
||||||
|
<PackageIcon>icon.png</PackageIcon>
|
||||||
|
<PackageProjectUrl>https://github.com/DarthAffe/ScreenCapture.NET</PackageProjectUrl>
|
||||||
|
<PackageLicenseExpression>LGPL-2.1-only</PackageLicenseExpression>
|
||||||
|
<RepositoryType>Github</RepositoryType>
|
||||||
|
<RepositoryUrl>https://github.com/DarthAffe/ScreenCapture.NET</RepositoryUrl>
|
||||||
|
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||||
|
|
||||||
|
<PackageReleaseNotes>
|
||||||
|
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.
|
||||||
|
</PackageReleaseNotes>
|
||||||
|
|
||||||
|
<Version>1.3.2</Version>
|
||||||
|
<AssemblyVersion>1.3.2</AssemblyVersion>
|
||||||
|
<FileVersion>1.3.2</FileVersion>
|
||||||
|
|
||||||
|
<OutputPath>..\bin\</OutputPath>
|
||||||
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
|
<IncludeSource>True</IncludeSource>
|
||||||
|
<IncludeSymbols>True</IncludeSymbols>
|
||||||
|
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<DefineConstants>$(DefineConstants);TRACE;DEBUG</DefineConstants>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
|
||||||
|
<DebugType>portable</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<NoWarn>$(NoWarn);CS1591;CS1572;CS1573</NoWarn>
|
||||||
|
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\icon.png">
|
||||||
|
<Pack>True</Pack>
|
||||||
|
<PackagePath></PackagePath>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Vortice.Direct3D11" Version="2.4.2" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\..\..\..\Darth Affe\Source\Repos\ScreenCapture.NET\ScreenCapture.NET\ScreenCapture.NET.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
<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">
|
||||||
|
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=helper/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||||
@ -1,9 +1,11 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 16
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 16.0.31025.194
|
VisualStudioVersion = 17.6.33829.357
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
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
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
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}.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.ActiveCfg = Release|Any CPU
|
||||||
{90596344-E012-4534-A933-3BD1B55469DC}.Release|Any CPU.Build.0 = 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
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@ -14,8 +14,8 @@
|
|||||||
<AssemblyTitle>ScreenCapture.NET</AssemblyTitle>
|
<AssemblyTitle>ScreenCapture.NET</AssemblyTitle>
|
||||||
<PackageId>ScreenCapture.NET</PackageId>
|
<PackageId>ScreenCapture.NET</PackageId>
|
||||||
<RootNamespace>ScreenCapture.NET</RootNamespace>
|
<RootNamespace>ScreenCapture.NET</RootNamespace>
|
||||||
<Description>Vortice based Screen-Capturing</Description>
|
<Description>Core functionality for Screen-Capturing</Description>
|
||||||
<Summary>Vortice based Screen-Capturing using Desktop Duplication</Summary>
|
<Summary>Base package for ScreenCapture.NET projects</Summary>
|
||||||
<Copyright>Copyright © Darth Affe 2023</Copyright>
|
<Copyright>Copyright © Darth Affe 2023</Copyright>
|
||||||
<PackageCopyright>Copyright © Darth Affe 2023</PackageCopyright>
|
<PackageCopyright>Copyright © Darth Affe 2023</PackageCopyright>
|
||||||
<PackageIcon>icon.png</PackageIcon>
|
<PackageIcon>icon.png</PackageIcon>
|
||||||
@ -62,8 +62,4 @@
|
|||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Vortice.Direct3D11" Version="2.4.2" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user