Skip to content

Commit 0ab0c47

Browse files
Merge branch 'main' into sn/net8
2 parents 6aa8cff + e69e622 commit 0ab0c47

File tree

179 files changed

+2243
-1019
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

179 files changed

+2243
-1019
lines changed

src/ImageSharp/Common/Helpers/SimdUtils.HwIntrinsics.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the Six Labors Split License.
33

44
using System.Diagnostics.CodeAnalysis;
5+
using System.Numerics;
56
using System.Runtime.CompilerServices;
67
using System.Runtime.InteropServices;
78
using System.Runtime.Intrinsics;
@@ -657,6 +658,36 @@ public static Vector128<byte> BlendVariable(Vector128<byte> left, Vector128<byte
657658
return AdvSimd.BitwiseSelect(signedMask, right.AsInt16(), left.AsInt16()).AsByte();
658659
}
659660

661+
/// <summary>
662+
/// Blend packed 32-bit unsigned integers from <paramref name="left"/> and <paramref name="right"/> using <paramref name="mask"/>.
663+
/// The high bit of each corresponding <paramref name="mask"/> byte determines the selection.
664+
/// If the high bit is set the element of <paramref name="left"/> is selected.
665+
/// The element of <paramref name="right"/> is selected otherwise.
666+
/// </summary>
667+
/// <param name="left">The left vector.</param>
668+
/// <param name="right">The right vector.</param>
669+
/// <param name="mask">The mask vector.</param>
670+
/// <returns>The <see cref="Vector256{T}"/>.</returns>
671+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
672+
public static Vector128<uint> BlendVariable(Vector128<uint> left, Vector128<uint> right, Vector128<uint> mask)
673+
=> BlendVariable(left.AsByte(), right.AsByte(), mask.AsByte()).AsUInt32();
674+
675+
/// <summary>
676+
/// Count the number of leading zero bits in a mask.
677+
/// Similar in behavior to the x86 instruction LZCNT.
678+
/// </summary>
679+
/// <param name="value">The value.</param>
680+
public static ushort LeadingZeroCount(ushort value)
681+
=> (ushort)(BitOperations.LeadingZeroCount(value) - 16);
682+
683+
/// <summary>
684+
/// Count the number of trailing zero bits in an integer value.
685+
/// Similar in behavior to the x86 instruction TZCNT.
686+
/// </summary>
687+
/// <param name="value">The value.</param>
688+
public static ushort TrailingZeroCount(ushort value)
689+
=> (ushort)(BitOperations.TrailingZeroCount(value << 16) - 16);
690+
660691
/// <summary>
661692
/// <see cref="ByteToNormalizedFloat"/> as many elements as possible, slicing them down (keeping the remainder).
662693
/// </summary>
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
// Copyright (c) Six Labors.
2+
// Licensed under the Six Labors Split License.
3+
4+
namespace SixLabors.ImageSharp.Formats;
5+
internal class AnimatedImageFrameMetadata
6+
{
7+
/// <summary>
8+
/// Gets or sets the frame color table.
9+
/// </summary>
10+
public ReadOnlyMemory<Color>? ColorTable { get; set; }
11+
12+
/// <summary>
13+
/// Gets or sets the frame color table mode.
14+
/// </summary>
15+
public FrameColorTableMode ColorTableMode { get; set; }
16+
17+
/// <summary>
18+
/// Gets or sets the duration of the frame.
19+
/// </summary>
20+
public TimeSpan Duration { get; set; }
21+
22+
/// <summary>
23+
/// Gets or sets the frame alpha blending mode.
24+
/// </summary>
25+
public FrameBlendMode BlendMode { get; set; }
26+
27+
/// <summary>
28+
/// Gets or sets the frame disposal mode.
29+
/// </summary>
30+
public FrameDisposalMode DisposalMode { get; set; }
31+
}
32+
33+
#pragma warning disable SA1201 // Elements should appear in the correct order
34+
internal enum FrameBlendMode
35+
#pragma warning restore SA1201 // Elements should appear in the correct order
36+
{
37+
/// <summary>
38+
/// Do not blend. Render the current frame on the canvas by overwriting the rectangle covered by the current frame.
39+
/// </summary>
40+
Source = 0,
41+
42+
/// <summary>
43+
/// Blend the current frame with the previous frame in the animation sequence within the rectangle covered
44+
/// by the current frame.
45+
/// If the current has any transparent areas, the corresponding areas of the previous frame will be visible
46+
/// through these transparent regions.
47+
/// </summary>
48+
Over = 1
49+
}
50+
51+
internal enum FrameDisposalMode
52+
{
53+
/// <summary>
54+
/// No disposal specified.
55+
/// The decoder is not required to take any action.
56+
/// </summary>
57+
Unspecified = 0,
58+
59+
/// <summary>
60+
/// Do not dispose. The current frame is not disposed of, or in other words, not cleared or altered when moving to
61+
/// the next frame. This means that the next frame is drawn over the current frame, and if the next frame contains
62+
/// transparency, the previous frame will be visible through these transparent areas.
63+
/// </summary>
64+
DoNotDispose = 1,
65+
66+
/// <summary>
67+
/// Restore to background color. When transitioning to the next frame, the area occupied by the current frame is
68+
/// filled with the background color specified in the image metadata.
69+
/// This effectively erases the current frame by replacing it with the background color before the next frame is displayed.
70+
/// </summary>
71+
RestoreToBackground = 2,
72+
73+
/// <summary>
74+
/// Restore to previous. This method restores the area affected by the current frame to what it was before the
75+
/// current frame was displayed. It essentially "undoes" the current frame, reverting to the state of the image
76+
/// before the frame was displayed, then the next frame is drawn. This is useful for animations where only a small
77+
/// part of the image changes from frame to frame.
78+
/// </summary>
79+
RestoreToPrevious = 3
80+
}
81+
82+
internal enum FrameColorTableMode
83+
{
84+
/// <summary>
85+
/// The frame uses the shared color table specified by the image metadata.
86+
/// </summary>
87+
Global,
88+
89+
/// <summary>
90+
/// The frame uses a color table specified by the frame metadata.
91+
/// </summary>
92+
Local
93+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright (c) Six Labors.
2+
// Licensed under the Six Labors Split License.
3+
4+
namespace SixLabors.ImageSharp.Formats;
5+
internal class AnimatedImageMetadata
6+
{
7+
/// <summary>
8+
/// Gets or sets the shared color table.
9+
/// </summary>
10+
public ReadOnlyMemory<Color>? ColorTable { get; set; }
11+
12+
/// <summary>
13+
/// Gets or sets the shared color table mode.
14+
/// </summary>
15+
public FrameColorTableMode ColorTableMode { get; set; }
16+
17+
/// <summary>
18+
/// Gets or sets the default background color of the canvas when animating.
19+
/// This color may be used to fill the unused space on the canvas around the frames,
20+
/// as well as the transparent pixels of the first frame.
21+
/// The background color is also used when the disposal mode is <see cref="FrameDisposalMode.RestoreToBackground"/>.
22+
/// </summary>
23+
public Color BackgroundColor { get; set; }
24+
25+
/// <summary>
26+
/// Gets or sets the number of times any animation is repeated.
27+
/// <remarks>
28+
/// 0 means to repeat indefinitely, count is set as repeat n-1 times. Defaults to 1.
29+
/// </remarks>
30+
/// </summary>
31+
public ushort RepeatCount { get; set; }
32+
}

0 commit comments

Comments
 (0)