Browse Source

Fix build errors

pull/1552/head
Brian Popow 5 years ago
parent
commit
ce5338bf92
  1. 15
      src/ImageSharp/Formats/WebP/WebpEncoderCore.cs
  2. 1
      tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs
  3. 10
      tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs
  4. 18
      tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs

15
src/ImageSharp/Formats/WebP/WebpEncoderCore.cs

@ -4,7 +4,7 @@
using System.IO; using System.IO;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Formats.Experimental.Webp.Lossless; using SixLabors.ImageSharp.Formats.Experimental.Webp.Lossless;
using SixLabors.ImageSharp.Formats.Experimental.Webp.Lossy; using SixLabors.ImageSharp.Formats.Experimental.Webp.Lossy;
using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Memory;
@ -48,6 +48,11 @@ namespace SixLabors.ImageSharp.Formats.Experimental.Webp
/// </summary> /// </summary>
private readonly int entropyPasses; private readonly int entropyPasses;
/// <summary>
/// The global configuration.
/// </summary>
private Configuration configuration;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="WebpEncoderCore"/> class. /// Initializes a new instance of the <see cref="WebpEncoderCore"/> class.
/// </summary> /// </summary>
@ -76,6 +81,8 @@ namespace SixLabors.ImageSharp.Formats.Experimental.Webp
Guard.NotNull(image, nameof(image)); Guard.NotNull(image, nameof(image));
Guard.NotNull(stream, nameof(stream)); Guard.NotNull(stream, nameof(stream));
this.configuration = image.GetConfiguration();
if (this.lossy) if (this.lossy)
{ {
var enc = new Vp8Encoder(this.memoryAllocator, image.Width, image.Height, this.quality, this.method, this.entropyPasses); var enc = new Vp8Encoder(this.memoryAllocator, image.Width, image.Height, this.quality, this.method, this.entropyPasses);
@ -98,6 +105,8 @@ namespace SixLabors.ImageSharp.Formats.Experimental.Webp
public async Task EncodeAsync<TPixel>(Image<TPixel> image, Stream stream, CancellationToken cancellationToken) public async Task EncodeAsync<TPixel>(Image<TPixel> image, Stream stream, CancellationToken cancellationToken)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
this.configuration = image.GetConfiguration();
if (stream.CanSeek) if (stream.CanSeek)
{ {
this.Encode(image, stream, cancellationToken); this.Encode(image, stream, cancellationToken);
@ -106,9 +115,9 @@ namespace SixLabors.ImageSharp.Formats.Experimental.Webp
{ {
using (var ms = new MemoryStream()) using (var ms = new MemoryStream())
{ {
this.Encode(image, ms); this.Encode(image, ms, cancellationToken);
ms.Position = 0; ms.Position = 0;
await ms.CopyToAsync(stream, cancellationToken).ConfigureAwait(false); await ms.CopyToAsync(stream, this.configuration.StreamProcessingBufferSize, cancellationToken).ConfigureAwait(false);
} }
} }
} }

1
tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs

@ -7,7 +7,6 @@ using System.Linq;
using Moq; using Moq;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Formats.Bmp; using SixLabors.ImageSharp.Formats.Bmp;
using SixLabors.ImageSharp.Formats.Experimental.Webp;
using SixLabors.ImageSharp.Formats.Gif; using SixLabors.ImageSharp.Formats.Gif;
using SixLabors.ImageSharp.Formats.Jpeg; using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.Formats.Png; using SixLabors.ImageSharp.Formats.Png;

10
tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs

@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.WebP
[Trait("Format", "Webp")] [Trait("Format", "Webp")]
public class LosslessUtilsTests public class LosslessUtilsTests
{ {
private static void RunSubstractGreenTest() private static void RunSubtractGreenTest()
{ {
uint[] pixelData = uint[] pixelData =
{ {
@ -133,7 +133,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.WebP
} }
[Fact] [Fact]
public void SubtractGreen_Works() => RunSubstractGreenTest(); public void SubtractGreen_Works() => RunSubtractGreenTest();
[Fact] [Fact]
public void AddGreenToBlueAndRed_Works() => RunAddGreenToBlueAndRedTest(); public void AddGreenToBlueAndRed_Works() => RunAddGreenToBlueAndRedTest();
@ -146,13 +146,13 @@ namespace SixLabors.ImageSharp.Tests.Formats.WebP
#if SUPPORTS_RUNTIME_INTRINSICS #if SUPPORTS_RUNTIME_INTRINSICS
[Fact] [Fact]
public void SubtractGreen_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunSubstractGreenTest, HwIntrinsics.AllowAll); public void SubtractGreen_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunSubtractGreenTest, HwIntrinsics.AllowAll);
[Fact] [Fact]
public void SubtractGreen_WithoutAvx_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunSubstractGreenTest, HwIntrinsics.DisableAVX); public void SubtractGreen_WithoutAvx_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunSubtractGreenTest, HwIntrinsics.DisableAVX);
[Fact] [Fact]
public void SubtractGreen_WithoutAvxOrSSSE3_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunSubstractGreenTest, HwIntrinsics.DisableAVX | HwIntrinsics.DisableSSSE3); public void SubtractGreen_WithoutAvxOrSSSE3_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunSubtractGreenTest, HwIntrinsics.DisableAVX | HwIntrinsics.DisableSSSE3);
[Fact] [Fact]
public void AddGreenToBlueAndRed_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunAddGreenToBlueAndRedTest, HwIntrinsics.AllowAll); public void AddGreenToBlueAndRed_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunAddGreenToBlueAndRedTest, HwIntrinsics.AllowAll);

18
tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs

@ -27,27 +27,19 @@ namespace SixLabors.ImageSharp.Tests.Formats.WebP
#if SUPPORTS_RUNTIME_INTRINSICS #if SUPPORTS_RUNTIME_INTRINSICS
[Fact] [Fact]
public void ColorSpaceTransform_WithPeakImage_WithHardwareIntrinsics_Works() public void ColorSpaceTransform_WithPeakImage_WithHardwareIntrinsics_Works()
{ => FeatureTestRunner.RunWithHwIntrinsicsFeature(ColorSpaceTransform_WithPeakImage_ProducesExpectedData, HwIntrinsics.AllowAll);
FeatureTestRunner.RunWithHwIntrinsicsFeature(ColorSpaceTransform_WithPeakImage_ProducesExpectedData, HwIntrinsics.AllowAll);
}
[Fact] [Fact]
public void ColorSpaceTransform_WithPeakImage_WithoutSSE41_Works() public void ColorSpaceTransform_WithPeakImage_WithoutSSE41_Works()
{ => FeatureTestRunner.RunWithHwIntrinsicsFeature(ColorSpaceTransform_WithPeakImage_ProducesExpectedData, HwIntrinsics.DisableSSE41);
FeatureTestRunner.RunWithHwIntrinsicsFeature(ColorSpaceTransform_WithPeakImage_ProducesExpectedData, HwIntrinsics.DisableSSE41);
}
[Fact] [Fact]
public void ColorSpaceTransform_WithBikeImage_WithHardwareIntrinsics_Works() public void ColorSpaceTransform_WithBikeImage_WithHardwareIntrinsics_Works()
{ => FeatureTestRunner.RunWithHwIntrinsicsFeature(ColorSpaceTransform_WithBikeImage_ProducesExpectedData, HwIntrinsics.AllowAll);
FeatureTestRunner.RunWithHwIntrinsicsFeature(ColorSpaceTransform_WithBikeImage_ProducesExpectedData, HwIntrinsics.AllowAll);
}
[Fact] [Fact]
public void ColorSpaceTransform_WithBikeImage_WithoutSSE41_Works() public void ColorSpaceTransform_WithBikeImage_WithoutSSE41_Works()
{ => FeatureTestRunner.RunWithHwIntrinsicsFeature(ColorSpaceTransform_WithBikeImage_ProducesExpectedData, HwIntrinsics.DisableSSE41);
FeatureTestRunner.RunWithHwIntrinsicsFeature(ColorSpaceTransform_WithBikeImage_ProducesExpectedData, HwIntrinsics.DisableSSE41);
}
#endif #endif
private static void RunColorSpaceTransformTestWithPeakImage() private static void RunColorSpaceTransformTestWithPeakImage()
@ -91,7 +83,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.WebP
// Convert image pixels to bgra array. // Convert image pixels to bgra array.
var imgBytes = File.ReadAllBytes(TestImageFullPath(TestImages.WebP.Peak)); var imgBytes = File.ReadAllBytes(TestImageFullPath(TestImages.WebP.Peak));
using var image = Image.Load(imgBytes); using var image = Image.Load<Rgba32>(imgBytes);
uint[] bgra = ToBgra(image); uint[] bgra = ToBgra(image);
int colorTransformBits = 3; int colorTransformBits = 3;

Loading…
Cancel
Save