Skip to content

Commit

Permalink
Merge pull request #892 from LykosAI/main
Browse files Browse the repository at this point in the history
v2.12.0
  • Loading branch information
mohnjiles authored Sep 18, 2024
2 parents f4e3cbe + 4563d3f commit 1447781
Show file tree
Hide file tree
Showing 338 changed files with 15,742 additions and 3,895 deletions.
11 changes: 7 additions & 4 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@
"version": "0.6.0",
"commands": [
"husky"
]
],
"rollForward": false
},
"xamlstyler.console": {
"version": "3.2206.4",
"version": "3.2404.2",
"commands": [
"xstyler"
]
],
"rollForward": false
},
"csharpier": {
"version": "0.26.7",
"commands": [
"dotnet-csharpier"
]
],
"rollForward": false
}
}
}
4 changes: 2 additions & 2 deletions .github/workflows/backport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ jobs:
"commitConflicts": "true",
"prTitle": "[{{sourceBranch}} to {{targetBranch}}] backport: {{sourcePullRequest.title}} ({{sourcePullRequest.number}})"
}
- name: Backport Action
uses: sorenlouv/backport-github-action@v9.3.0
uses: sorenlouv/backport-github-action@v9.5.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
auto_backport_label_prefix: backport-to-
Expand Down
24 changes: 16 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,13 @@ jobs:
run: mv ./Release/linux-x64/StabilityMatrix.x86_64.AppImage ${{ env.out-name }}

- name: Upload Artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: StabilityMatrix-${{ env.platform-id }}
path: ${{ env.out-name }}

retention-days: 1
if-no-files-found: error

- name: Create Sentry release
if: ${{ github.event.inputs.sentry-release == 'true' }}
uses: getsentry/action-release@v1
Expand Down Expand Up @@ -166,10 +168,12 @@ jobs:
run: mv ./out/StabilityMatrix.Avalonia.exe ./out/${{ env.out-name }}

- name: Upload Artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: StabilityMatrix-${{ env.platform-id }}
path: ./out/${{ env.out-name }}
retention-days: 1
if-no-files-found: error

release-macos:
name: Release (macos-arm64)
Expand Down Expand Up @@ -250,10 +254,12 @@ jobs:
run: zip -r -y "../StabilityMatrix-${{ env.platform-id }}-app.zip" "${{ env.app-name }}"

- name: Upload Artifact (App)
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: StabilityMatrix-${{ env.platform-id }}-app
path: StabilityMatrix-${{ env.platform-id }}-app.zip
retention-days: 1
if-no-files-found: error

- uses: actions/setup-node@v4
with:
Expand All @@ -276,10 +282,12 @@ jobs:
run: zip -r -y "../StabilityMatrix-${{ env.platform-id }}-dmg.zip" "${{ env.out-name }}"

- name: Upload Artifact (dmg)
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: StabilityMatrix-${{ env.platform-id }}-dmg
path: StabilityMatrix-${{ env.platform-id }}-dmg.zip
retention-days: 1
if-no-files-found: error

publish-release:
name: Publish GitHub Release
Expand All @@ -300,7 +308,7 @@ jobs:
# Downloads all previous artifacts to the current working directory
- name: Download Artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4

# Zip each build (except macos which is already dmg)
- name: Zip Artifacts
Expand Down Expand Up @@ -346,7 +354,7 @@ jobs:
# Downloads all previous artifacts to the current working directory
- name: Download Artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4

# Zip each build (except macos which is already dmg)
- name: Zip Artifacts
Expand Down Expand Up @@ -428,7 +436,7 @@ jobs:
# Downloads all previous artifacts to the current working directory
- name: Download Artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4

# Zip each build (except macos which is already dmg)
- name: Zip Artifacts
Expand Down
Empty file modified .husky/pre-commit
100644 → 100755
Empty file.
8 changes: 7 additions & 1 deletion Avalonia.Gif/Avalonia.Gif.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
</PropertyGroup>

<PropertyGroup>
<!-- Ignore nullable / unused warnings since this was vendored -->
<NoWarn>$(NoWarn);CS8765;CS8618;CS8625;CS0169</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
<PackageReference Include="SkiaSharp" Version="2.88.7" />
<PackageReference Include="SkiaSharp" Version="3.0.0-preview.4.1" />
<PackageReference Include="DotNet.Bundle" Version="0.9.13" />
</ItemGroup>

Expand Down
29 changes: 24 additions & 5 deletions Avalonia.Gif/Decoding/GifDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System;
using System.Buffers;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
Expand Down Expand Up @@ -190,7 +191,9 @@ private void RenderFrameAt(int idx, WriteableBitmap writeableBitmap)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void DrawFrame(GifFrame curFrame, Memory<byte> frameIndexSpan)
{
var activeColorTable = curFrame.IsLocalColorTableUsed ? curFrame.LocalColorTable : Header.GlobarColorTable;
var activeColorTable = curFrame.IsLocalColorTableUsed
? curFrame.LocalColorTable
: Header.GlobarColorTable;

var cX = curFrame.Dimensions.X;
var cY = curFrame.Dimensions.Y;
Expand Down Expand Up @@ -232,7 +235,11 @@ void DrawRow(int row)
{
var indexColor = frameIndexSpan.Span[indexOffset + i];

if (activeColorTable == null || targetOffset >= len || indexColor > activeColorTable.Length)
if (
activeColorTable == null
|| targetOffset >= len
|| indexColor > activeColorTable.Length
)
return;

if (!(hT & indexColor == tC))
Expand Down Expand Up @@ -420,14 +427,20 @@ private void WriteBackBufToFb(IntPtr targetPointer)
unsafe
{
fixed (void* src = &_bitmapBackBuffer[0])

Check warning on line 429 in Avalonia.Gif/Decoding/GifDecoder.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 429 in Avalonia.Gif/Decoding/GifDecoder.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 429 in Avalonia.Gif/Decoding/GifDecoder.cs

View workflow job for this annotation

GitHub Actions / Release (linux-x64)

Dereference of a possibly null reference.

Check warning on line 429 in Avalonia.Gif/Decoding/GifDecoder.cs

View workflow job for this annotation

GitHub Actions / Release (win-x64)

Dereference of a possibly null reference.

Check warning on line 429 in Avalonia.Gif/Decoding/GifDecoder.cs

View workflow job for this annotation

GitHub Actions / Release (macos-arm64)

Dereference of a possibly null reference.
Buffer.MemoryCopy(src, targetPointer.ToPointer(), (uint)_backBufferBytes, (uint)_backBufferBytes);
Buffer.MemoryCopy(
src,
targetPointer.ToPointer(),
(uint)_backBufferBytes,
(uint)_backBufferBytes
);
_hasNewFrame = false;
}
}

/// <summary>
/// Processes GIF Header.
/// </summary>
[MemberNotNull(nameof(Header))]
private void ProcessHeaderData()
{
var str = _fileStream;
Expand Down Expand Up @@ -549,7 +562,9 @@ private void ProcessFrameData()

// Break the loop when the stream is not valid anymore.
if (_fileStream.Position >= _fileStream.Length & terminate == false)
throw new InvalidProgramException("Reach the end of the filestream without trailer block.");
throw new InvalidProgramException(
"Reach the end of the filestream without trailer block."
);
} while (!terminate);

ArrayPool<byte>.Shared.Return(tempBuf);
Expand Down Expand Up @@ -581,7 +596,11 @@ private void ProcessImageDescriptor(ref int curFrame, byte[] tempBuf)
currentFrame.LocalColorTableSize = (int)Math.Pow(2, (packed & 0x07) + 1);

if (currentFrame.IsLocalColorTableUsed)
currentFrame.LocalColorTable = ProcessColorTable(ref str, tempBuf, currentFrame.LocalColorTableSize);
currentFrame.LocalColorTable = ProcessColorTable(
ref str,
tempBuf,
currentFrame.LocalColorTableSize
);

currentFrame.LzwMinCodeSize = str.ReadByteS(tempBuf);
currentFrame.LzwStreamPosition = str.Position;
Expand Down
6 changes: 0 additions & 6 deletions Avalonia.Gif/Decoding/InvalidGifStreamException.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Licensed under the MIT License.
// Copyright (C) 2018 Jumar A. Macato, All Rights Reserved.

using System;
using System.Runtime.Serialization;

namespace Avalonia.Gif.Decoding
{
[Serializable]
Expand All @@ -16,8 +13,5 @@ public InvalidGifStreamException(string message)

public InvalidGifStreamException(string message, Exception innerException)
: base(message, innerException) { }

protected InvalidGifStreamException(SerializationInfo info, StreamingContext context)
: base(info, context) { }
}
}
6 changes: 0 additions & 6 deletions Avalonia.Gif/Decoding/LzwDecompressionException.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Licensed under the MIT License.
// Copyright (C) 2018 Jumar A. Macato, All Rights Reserved.

using System;
using System.Runtime.Serialization;

namespace Avalonia.Gif.Decoding
{
[Serializable]
Expand All @@ -16,8 +13,5 @@ public LzwDecompressionException(string message)

public LzwDecompressionException(string message, Exception innerException)
: base(message, innerException) { }

protected LzwDecompressionException(SerializationInfo info, StreamingContext context)
: base(info, context) { }
}
}
21 changes: 14 additions & 7 deletions Avalonia.Gif/GifInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,23 @@ public GifInstance(Stream currentStream)
CurrentCts = new CancellationTokenSource();

_gifDecoder = new GifDecoder(currentStream, CurrentCts.Token);
var pixSize = new PixelSize(_gifDecoder.Header.Dimensions.Width, _gifDecoder.Header.Dimensions.Height);

_targetBitmap = new WriteableBitmap(pixSize, new Vector(96, 96), PixelFormat.Bgra8888, AlphaFormat.Opaque);
var pixSize = new PixelSize(
_gifDecoder.Header.Dimensions.Width,
_gifDecoder.Header.Dimensions.Height
);

_targetBitmap = new WriteableBitmap(
pixSize,
new Vector(96, 96),
PixelFormat.Bgra8888,
AlphaFormat.Opaque
);
GifPixelSize = pixSize;

_totalTime = TimeSpan.Zero;

_frameTimes = _gifDecoder
.Frames
.Select(frame =>
.Frames.Select(frame =>
{
_totalTime = _totalTime.Add(frame.FrameDelay);
return _totalTime;
Expand Down Expand Up @@ -138,10 +145,10 @@ public void Dispose()

internal WriteableBitmap ProcessFrameIndex(int frameIndex)
{
_gifDecoder.RenderFrame(frameIndex, _targetBitmap);
_gifDecoder.RenderFrame(frameIndex, _targetBitmap!);
_currentFrameIndex = frameIndex;

return _targetBitmap;
return _targetBitmap!;
}
}
}
6 changes: 0 additions & 6 deletions Avalonia.Gif/InvalidGifStreamException.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Runtime.Serialization;

namespace Avalonia.Gif
{
[Serializable]
Expand All @@ -13,8 +10,5 @@ public InvalidGifStreamException(string message)

public InvalidGifStreamException(string message, Exception innerException)
: base(message, innerException) { }

protected InvalidGifStreamException(SerializationInfo info, StreamingContext context)
: base(info, context) { }
}
}
9 changes: 9 additions & 0 deletions Build/_utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

print_hyperlink() {
local url="$1"
local text="$2"

# macOS Terminal supports clickable links in the following format
printf "\033]8;;%s\a%s\033]8;;\a" "$url" "$text"
}
45 changes: 39 additions & 6 deletions Build/build_macos_app.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,59 @@
#!/bin/sh
#!/bin/bash

output_dir="$(pwd)/out/osx-arm64/"
app_name="Stability Matrix.app"

. "./_utils.sh" > /dev/null 2>&1 || . "${BASH_SOURCE%/*}/_utils.sh"

# Parse args
while getopts v: flag
do
case "${flag}" in
v) version=${OPTARG};;
*) echo "Invalid option";;
v)
version=${OPTARG}
;;
*)
echo "Invalid option: -$OPTARG" >&2
exit 2
;;
esac
done

shift $((OPTIND - 1))
echo $"Passing extra args to msbuild: $@"

set -e

# Build the app
dotnet \
msbuild \
StabilityMatrix.Avalonia \
-t:BundleApp \
-p:RuntimeIdentifier=osx-arm64 \
-p:UseAppHost=true \
-p:Configuration=Release \
-p:CFBundleShortVersionString="$version" \
-p:SelfContained=true \
-p:CFBundleName="Stability Matrix" \
-p:CFBundleDisplayName="Stability Matrix" \
-p:CFBundleVersion="$version" \
-p:PublishDir="$(pwd)/out/osx-arm64/bin" \
-p:CFBundleShortVersionString="$version" \
-p:PublishDir="${output_dir:?}/bin" \
"$@"

target_plist_path="${output_dir:?}/bin/${app_name:?}/Contents/Info.plist"

echo "> Checking Info.plist..."
file "${target_plist_path:?}"
plutil -lint "${target_plist_path:?}"

echo "> Copying app to output..."
# Delete existing file
rm -rf "${output_dir:?}/${app_name:?}"
# Copy the app out of bin
cp -r ./out/osx-arm64/bin/Stability\ Matrix.app ./out/osx-arm64/Stability\ Matrix.app
cp -r "${output_dir:?}/bin/${app_name:?}" "${output_dir:?}/${app_name:?}"

# Print output location
echo "[App Build Completed]"
print_hyperlink "file:///${output_dir:?}" "${output_dir:?}"
print_hyperlink "file:///${output_dir:?}/${app_name:?}" "${app_name:?}"
echo ""
Loading

0 comments on commit 1447781

Please sign in to comment.