Skip to content

Commit

Permalink
Merge pull request #307 from SixLabors/js/update-refs
Browse files Browse the repository at this point in the history
Update refs to latest
  • Loading branch information
JimBobSquarePants authored Dec 6, 2023
2 parents ec146c9 + 706a8a3 commit 601b074
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 32 deletions.
4 changes: 4 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<PropertyGroup>
<UseImageSharp>true</UseImageSharp>
</PropertyGroup>

<ItemGroup>
<!-- DynamicProxyGenAssembly2 is needed so Moq can use our internals -->
Expand Down
4 changes: 2 additions & 2 deletions src/ImageSharp.Drawing/ImageSharp.Drawing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
<None Include="..\..\shared-infrastructure\branding\icons\imagesharp.drawing\sixlabors.imagesharp.drawing.128.png" Pack="true" PackagePath="" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="SixLabors.Fonts" Version="2.0.0" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.2" />
<PackageReference Include="SixLabors.Fonts" Version="2.0.1" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.0" />
</ItemGroup>
<Import Project="..\..\shared-infrastructure\src\SharedInfrastructure\SharedInfrastructure.projitems" Label="Shared" />
</Project>
1 change: 1 addition & 0 deletions src/ImageSharp.Drawing/Processing/GradientBrush.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Numerics;
using SixLabors.ImageSharp.Drawing.Utilities;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;

namespace SixLabors.ImageSharp.Drawing.Processing;

Expand Down
4 changes: 4 additions & 0 deletions tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@
<!-- Import the solution .props file. -->
<Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.props" />

<PropertyGroup>
<UseImageSharp>true</UseImageSharp>
</PropertyGroup>

</Project>
2 changes: 1 addition & 1 deletion tests/ImageSharp.Drawing.Tests/ConfigurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class ConfigurationTests

public Configuration DefaultConfiguration { get; }

private readonly int expectedDefaultConfigurationCount = 8;
private readonly int expectedDefaultConfigurationCount = 9;

public ConfigurationTests()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public BaseImageOperationsExtensionTest()
this.shapeOptions = new ShapeOptions { IntersectionRule = IntersectionRule.NonZero };
this.source = new Image<Rgba32>(91 + 324, 123 + 56);
this.rect = new Rectangle(91, 123, 324, 56); // make this random?
this.internalOperations = new FakeImageOperationsProvider.FakeImageOperations<Rgba32>(this.source.GetConfiguration(), this.source, false);
this.internalOperations = new FakeImageOperationsProvider.FakeImageOperations<Rgba32>(this.source.Configuration, this.source, false);
this.internalOperations.SetShapeOptions(this.shapeOptions);
this.internalOperations.SetGraphicsOptions(this.graphicsOptions);
this.operations = this.internalOperations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void FillOffCanvas()
var options = new GraphicsOptions { Antialias = true };
var processor = new FillPathProcessor(new DrawingOptions() { GraphicsOptions = options }, brush.Object, path);
var img = new Image<Rgba32>(10, 10);
processor.Execute(img.GetConfiguration(), img, bounds);
processor.Execute(img.Configuration, img, bounds);
}

[Fact]
Expand Down
42 changes: 23 additions & 19 deletions tests/ImageSharp.Drawing.Tests/TestFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,49 @@ namespace SixLabors.ImageSharp.Drawing.Tests;
/// </summary>
public class TestFileSystem : IO.IFileSystem
{
private readonly Dictionary<string, Stream> fileSystem = new(StringComparer.OrdinalIgnoreCase);
private readonly Dictionary<string, Func<Stream>> fileSystem = new(StringComparer.OrdinalIgnoreCase);

public void AddFile(string path, Stream data)
public void AddFile(string path, Func<Stream> data)
{
lock (this.fileSystem)
{
this.fileSystem.Add(path, data);
}
}

public Stream Create(string path)
public Stream Create(string path) => this.GetStream(path) ?? File.Create(path);

public Stream CreateAsynchronous(string path) => this.GetStream(path) ?? File.Open(path, new FileStreamOptions
{
// if we have injected a fake file use it instead
lock (this.fileSystem)
{
if (this.fileSystem.ContainsKey(path))
{
Stream stream = this.fileSystem[path];
stream.Position = 0;
return stream;
}
}
Mode = FileMode.Create,
Access = FileAccess.ReadWrite,
Share = FileShare.None,
Options = FileOptions.Asynchronous,
});

return File.Create(path);
}
public Stream OpenRead(string path) => this.GetStream(path) ?? File.OpenRead(path);

public Stream OpenReadAsynchronous(string path) => this.GetStream(path) ?? File.Open(path, new FileStreamOptions
{
Mode = FileMode.Open,
Access = FileAccess.Read,
Share = FileShare.Read,
Options = FileOptions.Asynchronous,
});

public Stream OpenRead(string path)
private Stream? GetStream(string path)

Check warning on line 41 in tests/ImageSharp.Drawing.Tests/TestFileSystem.cs

View workflow job for this annotation

GitHub Actions / Build (false, windows-latest, net6.0, 6.0.x, -x64, true)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 41 in tests/ImageSharp.Drawing.Tests/TestFileSystem.cs

View workflow job for this annotation

GitHub Actions / Build (false, windows-latest, net6.0, 6.0.x, -x64, true)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
// if we have injected a fake file use it instead
lock (this.fileSystem)
{
if (this.fileSystem.ContainsKey(path))
if (this.fileSystem.TryGetValue(path, out Func<Stream>? streamFactory))

Check warning on line 46 in tests/ImageSharp.Drawing.Tests/TestFileSystem.cs

View workflow job for this annotation

GitHub Actions / Build (false, windows-latest, net6.0, 6.0.x, -x64, true)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 46 in tests/ImageSharp.Drawing.Tests/TestFileSystem.cs

View workflow job for this annotation

GitHub Actions / Build (false, windows-latest, net6.0, 6.0.x, -x64, true)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
Stream stream = this.fileSystem[path];
Stream stream = streamFactory();
stream.Position = 0;
return stream;
}
}

return File.OpenRead(path);
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public override ImageSimilarityReport<TPixelA, TPixelB> CompareImagesOrFrames<TP
var bBuffer = new Rgba64[width];

var differences = new List<PixelDifference>();
Configuration configuration = expected.GetConfiguration();
Configuration configuration = expected.Configuration;
Buffer2D<TPixelA> expectedBuffer = expected.PixelBuffer;
Buffer2D<TPixelB> actualBuffer = actual.PixelBuffer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public override ImageSimilarityReport<TPixelA, TPixelB> CompareImagesOrFrames<TP
float totalDifference = 0F;

var differences = new List<PixelDifference>();
Configuration configuration = expected.GetConfiguration();
Configuration configuration = expected.Configuration;
Buffer2D<TPixelA> expectedBuffer = expected.PixelBuffer;
Buffer2D<TPixelB> actualBuffer = actual.PixelBuffer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ internal static unsafe Image<TPixel> From32bppArgbSystemDrawingBitmap<TPixel>(Bi
long sourceRowByteCount = data.Stride;
long destRowByteCount = w * sizeof(Bgra32);

Configuration configuration = image.GetConfiguration();
Configuration configuration = image.Configuration;
image.ProcessPixelRows(accessor =>
{
using IMemoryOwner<Bgra32> workBuffer = Configuration.Default.MemoryAllocator.Allocate<Bgra32>(w);
Expand Down Expand Up @@ -104,7 +104,7 @@ internal static unsafe Image<TPixel> From24bppRgbSystemDrawingBitmap<TPixel>(Bit
long sourceRowByteCount = data.Stride;
long destRowByteCount = w * sizeof(Bgr24);

Configuration configuration = image.GetConfiguration();
Configuration configuration = image.Configuration;
Buffer2D<TPixel> imageBuffer = image.GetRootFramePixelBuffer();

using IMemoryOwner<Bgr24> workBuffer = Configuration.Default.MemoryAllocator.Allocate<Bgr24>(w);
Expand Down Expand Up @@ -132,7 +132,7 @@ internal static unsafe Image<TPixel> From24bppRgbSystemDrawingBitmap<TPixel>(Bit
internal static unsafe Bitmap To32bppArgbSystemDrawingBitmap<TPixel>(Image<TPixel> image)
where TPixel : unmanaged, IPixel<TPixel>
{
Configuration configuration = image.GetConfiguration();
Configuration configuration = image.Configuration;
int w = image.Width;
int h = image.Height;

Expand All @@ -147,7 +147,7 @@ internal static unsafe Bitmap To32bppArgbSystemDrawingBitmap<TPixel>(Image<TPixe
long sourceRowByteCount = w * sizeof(Bgra32);
image.ProcessPixelRows(accessor =>
{
using IMemoryOwner<Bgra32> workBuffer = image.GetConfiguration().MemoryAllocator.Allocate<Bgra32>(w);
using IMemoryOwner<Bgra32> workBuffer = image.Configuration.MemoryAllocator.Allocate<Bgra32>(w);
fixed (Bgra32* sourcePtr = &workBuffer.GetReference())
{
for (int y = 0; y < h; y++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ private static void EnsureCustomConfigurationIsApplied<TPixel>(TestImageProvider
using (Image<TPixel> image2 = provider.GetImage())
using (Image<TPixel> image3 = provider.GetImage())
{
Assert.Same(customConfiguration, image2.GetConfiguration());
Assert.Same(customConfiguration, image3.GetConfiguration());
Assert.Same(customConfiguration, image2.Configuration);
Assert.Same(customConfiguration, image3.Configuration);
}
}
}
Expand Down

0 comments on commit 601b074

Please sign in to comment.