Skip to content

Commit

Permalink
Merge branch 'main' into dev/spouliot/metal-extra
Browse files Browse the repository at this point in the history
  • Loading branch information
mattleibow authored Nov 26, 2024
2 parents 9a133bd + ef6f234 commit a103730
Show file tree
Hide file tree
Showing 27 changed files with 370 additions and 113 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/label-with-ai.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Apply labels using AI

on:
issues:
types: [opened, reopened]

jobs:
apply-label-and-add-comment:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: mattleibow/labeled-by-ai@main
name: Apply AREA labels
with:
label-pattern: '^area/.*'
apply-label: 'false'
add-comment: 'false'
- uses: mattleibow/labeled-by-ai@main
name: Apply PLATFORM labels
with:
label-pattern: '^os/.*'
apply-label: 'false'
add-comment: 'false'
- uses: mattleibow/labeled-by-ai@main
name: Apply BACKEND labels
with:
label-pattern: '^backend/.*'
apply-label: 'false'
add-comment: 'false'
- uses: mattleibow/labeled-by-ai@main
name: Apply TENET labels
with:
label-pattern: '^tenet/.*'
apply-label: 'false'
add-comment: 'false'
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ However, these are easy to install as they are found on the various websites. If
- To get started building, [go here](https://github.com/mono/SkiaSharp/wiki/Building-SkiaSharp).
- If you are just wanting a custom Linux build, [go here](https://github.com/mono/SkiaSharp/wiki/Building-on-Linux)

## Contributors

<a href="https://github.com/mono/SkiaSharp/graphs/contributors">
<img src="https://contrib.rocks/image?repo=mono/SkiaSharp" />
</a>


Made with [contrib.rocks](https://contrib.rocks).

## Compare Code

Here are some links to show the differences in our code as compared to Google's code.
Expand Down
4 changes: 2 additions & 2 deletions scripts/azure-pipelines-complete-internal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ parameters:
default:
pool:
name: Azure Pipelines
vmImage: macos-13
vmImage: macos-14
os: macos
- name: buildAgentLinux
displayName: 'The Linux build agent configuration:'
Expand Down Expand Up @@ -144,7 +144,7 @@ extends:
buildAgentWindows: ${{ parameters.buildAgentWindows }}
buildAgentWindowsNative: ${{ parameters.buildAgentWindows }}
buildAgentMac: ${{ parameters.buildAgentMac }}
buildAgentMacNative: ${{ parameters.buildAgentMac }}
buildAgentMacNative: ${{ parameters.buildAgentMacNative }}
buildAgentLinux: ${{ parameters.buildAgentLinux }}
buildAgentLinuxNative: ${{ parameters.buildAgentLinuxNative }}
buildAgentAndroidTests: ${{ parameters.buildAgentAndroidTests }}
2 changes: 1 addition & 1 deletion scripts/azure-pipelines-complete.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ parameters:
default:
pool:
name: Azure Pipelines
vmImage: macos-13
vmImage: macos-14
os: macos
- name: buildAgentLinux
displayName: 'The Linux build agent configuration:'
Expand Down
2 changes: 1 addition & 1 deletion scripts/azure-pipelines-variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ variables:
TIZEN_LINUX_PACKAGES: libxcb-icccm4 libxcb-render-util0 gettext libxcb-image0 libsdl1.2debian libv4l-0 libxcb-randr0 bridge-utils libxcb-shape0 libpython2.7 openvpn libkf5itemmodels5 libkf5kiowidgets5 libkchart2
MANAGED_LINUX_PACKAGES: ttf-ancient-fonts ninja-build
XCODE_VERSION: '15.4'
XCODE_VERSION_NATIVE: '14.3.1'
XCODE_VERSION_NATIVE: '15.4'
VISUAL_STUDIO_VERSION: ''
DOTNET_VERSION: '8.0.304'
DOTNET_VERSION_PREVIEW: ''
Expand Down
2 changes: 1 addition & 1 deletion scripts/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ parameters:
default:
pool:
name: Azure Pipelines
vmImage: macos-13
vmImage: macos-14
os: macos
- name: buildAgentLinux
displayName: 'The Linux build agent configuration:'
Expand Down
8 changes: 4 additions & 4 deletions scripts/azure-templates-bootstrapper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ jobs:
submodules: recursive
- template: /scripts/azure-templates-variables.yml@self

# checkout required skia PR
- pwsh: .\scripts\checkout-skia.ps1 -GitHubToken $(GitHub.Token.PublicAccess)
displayName: Checkout required skia PR
condition: eq(variables['Build.Reason'], 'PullRequest')
# # checkout required skia PR
# - pwsh: .\scripts\checkout-skia.ps1 -GitHubToken $(GitHub.Token.PublicAccess)
# displayName: Checkout required skia PR
# condition: eq(variables['Build.Reason'], 'PullRequest')

- ${{ if eq(parameters.buildPipelineType, 'tests') }}:
- template: /scripts/azure-templates-github-status.yml@self
Expand Down
4 changes: 2 additions & 2 deletions scripts/azure-templates-stages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,11 @@ stages:
- 3.1.56:
displayName: '3.1.56_SIMD'
version: 3.1.56
features: _wasmeh,simd,st
features: _wasmeh,st,simd
- 3.1.56:
displayName: '3.1.56_SIMD_Threading'
version: 3.1.56
features: _wasmeh,simd,mt
features: _wasmeh,mt,simd

- ${{ if ne(parameters.buildPipelineType, 'tests') }}:
- stage: native
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if !NET7_0_OR_GREATER
using System;
using System.ComponentModel;
using Microsoft.JSInterop;

Expand All @@ -18,3 +19,4 @@ public ActionHelper(Action action)
public void Invoke() => action?.Invoke();
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
using System;
using System;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using Microsoft.JSInterop;

#if NET7_0_OR_GREATER
using System.Runtime.InteropServices.JavaScript;
#endif

namespace SkiaSharp.Views.Blazor.Internal
{
internal class DpiWatcherInterop : JSModuleInterop
[SupportedOSPlatform("browser")]
internal partial class DpiWatcherInterop : JSModuleInterop
{
private const string ModuleName = "DpiWatcher";
private const string JsFilename = "./_content/SkiaSharp.Views.Blazor/DpiWatcher.js";
private const string StartSymbol = "DpiWatcher.start";
private const string StopSymbol = "DpiWatcher.stop";
Expand All @@ -14,9 +21,13 @@ internal class DpiWatcherInterop : JSModuleInterop
private static DpiWatcherInterop? instance;

private event Action<double>? callbacksEvent;
#if NET7_0_OR_GREATER
private readonly Action<double, double> callbackHelper;
#else
private readonly FloatFloatActionHelper callbackHelper;

private DotNetObjectReference<FloatFloatActionHelper>? callbackReference;
#endif

public static async Task<DpiWatcherInterop> ImportAsync(IJSRuntime js, Action<double>? callback = null)
{
Expand All @@ -31,9 +42,9 @@ public static DpiWatcherInterop Get(IJSRuntime js) =>
instance ??= new DpiWatcherInterop(js);

private DpiWatcherInterop(IJSRuntime js)
: base(js, JsFilename)
: base(js, ModuleName, JsFilename)
{
callbackHelper = new FloatFloatActionHelper((o, n) => callbacksEvent?.Invoke(n));
callbackHelper = new((o, n) => callbacksEvent?.Invoke((float)n));
}

protected override void OnDisposingModule() =>
Expand All @@ -60,21 +71,28 @@ public void Unsubscribe(Action<double> callback)
Stop();
}

#if NET7_0_OR_GREATER
private double Start() =>
Start(callbackHelper);

[JSImport(StartSymbol, ModuleName)]
private static partial double Start([JSMarshalAs<JSType.Function<JSType.Number, JSType.Number>>] Action<double, double> callback);

[JSImport(StopSymbol, ModuleName)]
private static partial void Stop();

[JSImport(GetDpiSymbol, ModuleName)]
public static partial double GetDpi();
#else
private double Start()
{
if (callbackReference != null)
return GetDpi();

callbackReference = DotNetObjectReference.Create(callbackHelper);
callbackReference ??= DotNetObjectReference.Create(callbackHelper);

return Invoke<double>(StartSymbol, callbackReference);
}

private void Stop()
{
if (callbackReference == null)
return;

Invoke(StopSymbol);

callbackReference?.Dispose();
Expand All @@ -83,5 +101,6 @@ private void Stop()

public double GetDpi() =>
Invoke<double>(GetDpiSymbol);
#endif
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if !NET7_0_OR_GREATER
using System;
using System.ComponentModel;
using Microsoft.JSInterop;

Expand All @@ -18,3 +19,4 @@ public FloatFloatActionHelper(Action<float, float> action)
public void Invoke(float width, float height) => action?.Invoke(width, height);
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
using System;
using System.Threading.Tasks;
using System.Runtime.Versioning;
using Microsoft.JSInterop;

#if NET7_0_OR_GREATER
using System.Runtime.InteropServices.JavaScript;
#else
using JSObject = Microsoft.JSInterop.IJSUnmarshalledObjectReference;
#endif

namespace SkiaSharp.Views.Blazor.Internal
{
internal class JSModuleInterop : IDisposable
[SupportedOSPlatform("browser")]
internal partial class JSModuleInterop : IDisposable
{
private readonly Task<IJSUnmarshalledObjectReference> moduleTask;
private IJSUnmarshalledObjectReference? module;
private readonly Task<JSObject> moduleTask;
private JSObject? module;

public JSModuleInterop(IJSRuntime js, string filename)
public JSModuleInterop(IJSRuntime js, string moduleName, string moduleUrl)
{
#if NET7_0_OR_GREATER
moduleTask = JSHost.ImportAsync(moduleName, "/" + moduleUrl);
#else
if (js is not IJSInProcessRuntime)
throw new NotSupportedException("SkiaSharp currently only works on Web Assembly.");

moduleTask = js.InvokeAsync<IJSUnmarshalledObjectReference>("import", filename).AsTask();
moduleTask = js.InvokeAsync<JSObject>("import", moduleUrl).AsTask();
#endif
}

public async Task ImportAsync()
Expand All @@ -28,14 +40,16 @@ public void Dispose()
Module.Dispose();
}

protected IJSUnmarshalledObjectReference Module =>
protected JSObject Module =>
module ?? throw new InvalidOperationException("Make sure to run ImportAsync() first.");

#if !NET7_0_OR_GREATER
protected void Invoke(string identifier, params object?[]? args) =>
Module.InvokeVoid(identifier, args);

protected TValue Invoke<TValue>(string identifier, params object?[]? args) =>
Module.Invoke<TValue>(identifier, args);
#endif

protected virtual void OnDisposingModule() { }
}
Expand Down
Loading

0 comments on commit a103730

Please sign in to comment.