Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add WinUI native helper for GetByteBuffer #3039

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions VERSIONS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ SkiaSharp.NativeAssets.tvOS nuget 2.88.9
SkiaSharp.NativeAssets.UWP nuget 2.88.9
SkiaSharp.NativeAssets.watchOS nuget 2.88.9
SkiaSharp.NativeAssets.Win32 nuget 2.88.9
SkiaSharp.NativeAssets.WinUI nuget 2.88.9
SkiaSharp.Views nuget 2.88.9
SkiaSharp.Views.NativeAssets.UWP nuget 2.88.9
SkiaSharp.Views.Desktop.Common nuget 2.88.9
Expand Down
16 changes: 16 additions & 0 deletions binding/IncludeNativeAssets.SkiaSharp.WinUI.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Content Include="$(MSBuildThisFileDirectory)..\output\native\winui\any\*.dll" Visible="False" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.Contains('-windows')) and '$(Platform)' != 'AnyCPU' and '$(Platform)' != 'Any CPU'">
<Content Include="$(MSBuildThisFileDirectory)..\output\native\winui\$(Platform)\*" Visible="False" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.Contains('-windows')) and ('$(Platform)' == 'AnyCPU' or '$(Platform)' == 'Any CPU')">
<Content Include="$(MSBuildThisFileDirectory)..\output\native\winui\x64\*" Condition="'$(RuntimeIdentifier)' == 'win10-x64'" Visible="False" />
<Content Include="$(MSBuildThisFileDirectory)..\output\native\winui\x86\*" Condition="'$(RuntimeIdentifier)' == 'win10-x86'" Visible="False" />
<Content Include="$(MSBuildThisFileDirectory)..\output\native\winui\arm64\*" Condition="'$(RuntimeIdentifier)' == 'win10-arm64'" Visible="False" />
<Content Include="$(MSBuildThisFileDirectory)..\output\native\winui\x64\*" Condition="'$(RuntimeIdentifier)' == ''" Visible="False" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</Project>
7 changes: 7 additions & 0 deletions binding/SkiaSharp/SkiaSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
<None Include="..\..\output\native\windows\arm64\libSkiaSharp*" Link="nuget\runtimes\win-arm64\native\%(Filename)%(Extension)" />
<!-- Windows: Nano Server -->
<None Include="..\..\output\native\nanoserver\x64\libSkiaSharp*" Link="nuget\runtimes\nanoserver-x64\native\%(Filename)%(Extension)" />
<!-- Windows: WinUI -->
<None Include="..\..\output\native\winui\x86\SkiaSharp.Views.WinUI.Native*" Link="nuget\runtimes\winui-x86\native\%(Filename)%(Extension)" />
<None Include="..\..\output\native\winui\any\SkiaSharp.Views.WinUI.Native.Projection*" Link="nuget\runtimes\winui-x86\lib\net6.0-windows10.0.19041\%(Filename)%(Extension)" />
<None Include="..\..\output\native\winui\x64\SkiaSharp.Views.WinUI.Native*" Link="nuget\runtimes\winui-x64\native\%(Filename)%(Extension)" />
<None Include="..\..\output\native\winui\any\SkiaSharp.Views.WinUI.Native.Projection*" Link="nuget\runtimes\winui-x64\lib\net6.0-windows10.0.19041\%(Filename)%(Extension)" />
<None Include="..\..\output\native\winui\arm64\SkiaSharp.Views.WinUI.Native*" Link="nuget\runtimes\winui-arm64\native\%(Filename)%(Extension)" />
<None Include="..\..\output\native\winui\any\SkiaSharp.Views.WinUI.Native.Projection*" Link="nuget\runtimes\winui-arm64\lib\net6.0-windows10.0.19041\%(Filename)%(Extension)" />
<!-- Linux -->
<None Include="..\..\output\native\linux\x64\libSkiaSharp*" Link="nuget\runtimes\linux-x64\native\%(Filename)%(Extension)" />
<None Include="..\..\output\native\linux\x86\libSkiaSharp*" Link="nuget\runtimes\linux-x86\native\%(Filename)%(Extension)" />
Expand Down
1 change: 1 addition & 0 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ var TRACKED_NUGETS = new Dictionary<string, Version> {
{ "SkiaSharp.NativeAssets.UWP", new Version (1, 60, 0) },
{ "SkiaSharp.NativeAssets.watchOS", new Version (1, 60, 0) },
{ "SkiaSharp.NativeAssets.Win32", new Version (1, 60, 0) },
{ "SkiaSharp.NativeAssets.WinUI", new Version (1, 60, 0) },
{ "SkiaSharp.Views", new Version (1, 60, 0) },
{ "SkiaSharp.Views.NativeAssets.UWP", new Version (1, 60, 0) },
{ "SkiaSharp.Views.Desktop.Common", new Version (1, 60, 0) },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>

<Import Project="$(MSBuildThisFileDirectory)..\..\..\..\source\SkiaSharp.Build.props" />

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>

<Import Project="$(MSBuildThisFileDirectory)..\..\..\..\source\SkiaSharp.Build.targets" />

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>$(WindowsTargetFrameworks)</TargetFrameworks>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<PackageId>SkiaSharp.Views.WinUI</PackageId>
<PackagingGroup>SkiaSharp.Views.WinUI</PackagingGroup>
<IsPackable>false</IsPackable>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup>
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
<CsWinRTIncludes>SkiaSharp.Views.WinUI.Native</CsWinRTIncludes>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.4" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\SkiaSharp.Views.WinUI.Native\SkiaSharp.Views.WinUI.Native.vcxproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34310.174
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SkiaSharp.Views.WinUI.Native", "SkiaSharp.Views.WinUI.Native\SkiaSharp.Views.WinUI.Native.vcxproj", "{730AF4C9-82D2-4FA7-AA32-154F3524EBD2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.Views.WinUI.Native.Projection", "SkiaSharp.Views.WinUI.Native.Projection\SkiaSharp.Views.WinUI.Native.Projection.csproj", "{95E9FEB4-DCD3-4514-8208-A87688788BB2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{730AF4C9-82D2-4FA7-AA32-154F3524EBD2}.Debug|Any CPU.ActiveCfg = Debug|x64
{730AF4C9-82D2-4FA7-AA32-154F3524EBD2}.Debug|Any CPU.Build.0 = Debug|x64
{730AF4C9-82D2-4FA7-AA32-154F3524EBD2}.Debug|ARM64.ActiveCfg = Debug|ARM64
{730AF4C9-82D2-4FA7-AA32-154F3524EBD2}.Debug|ARM64.Build.0 = Debug|ARM64
{730AF4C9-82D2-4FA7-AA32-154F3524EBD2}.Debug|x64.ActiveCfg = Debug|x64
{730AF4C9-82D2-4FA7-AA32-154F3524EBD2}.Debug|x64.Build.0 = Debug|x64
{730AF4C9-82D2-4FA7-AA32-154F3524EBD2}.Debug|x86.ActiveCfg = Debug|Win32
{730AF4C9-82D2-4FA7-AA32-154F3524EBD2}.Debug|x86.Build.0 = Debug|Win32
{730AF4C9-82D2-4FA7-AA32-154F3524EBD2}.Release|Any CPU.ActiveCfg = Release|x64
{730AF4C9-82D2-4FA7-AA32-154F3524EBD2}.Release|Any CPU.Build.0 = Release|x64
{730AF4C9-82D2-4FA7-AA32-154F3524EBD2}.Release|ARM64.ActiveCfg = Release|ARM64
{730AF4C9-82D2-4FA7-AA32-154F3524EBD2}.Release|ARM64.Build.0 = Release|ARM64
{730AF4C9-82D2-4FA7-AA32-154F3524EBD2}.Release|x64.ActiveCfg = Release|x64
{730AF4C9-82D2-4FA7-AA32-154F3524EBD2}.Release|x64.Build.0 = Release|x64
{730AF4C9-82D2-4FA7-AA32-154F3524EBD2}.Release|x86.ActiveCfg = Release|Win32
{730AF4C9-82D2-4FA7-AA32-154F3524EBD2}.Release|x86.Build.0 = Release|Win32
{95E9FEB4-DCD3-4514-8208-A87688788BB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{95E9FEB4-DCD3-4514-8208-A87688788BB2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{95E9FEB4-DCD3-4514-8208-A87688788BB2}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{95E9FEB4-DCD3-4514-8208-A87688788BB2}.Debug|ARM64.Build.0 = Debug|Any CPU
{95E9FEB4-DCD3-4514-8208-A87688788BB2}.Debug|x64.ActiveCfg = Debug|Any CPU
{95E9FEB4-DCD3-4514-8208-A87688788BB2}.Debug|x64.Build.0 = Debug|Any CPU
{95E9FEB4-DCD3-4514-8208-A87688788BB2}.Debug|x86.ActiveCfg = Debug|Any CPU
{95E9FEB4-DCD3-4514-8208-A87688788BB2}.Debug|x86.Build.0 = Debug|Any CPU
{95E9FEB4-DCD3-4514-8208-A87688788BB2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{95E9FEB4-DCD3-4514-8208-A87688788BB2}.Release|Any CPU.Build.0 = Release|Any CPU
{95E9FEB4-DCD3-4514-8208-A87688788BB2}.Release|ARM64.ActiveCfg = Release|Any CPU
{95E9FEB4-DCD3-4514-8208-A87688788BB2}.Release|ARM64.Build.0 = Release|Any CPU
{95E9FEB4-DCD3-4514-8208-A87688788BB2}.Release|x64.ActiveCfg = Release|Any CPU
{95E9FEB4-DCD3-4514-8208-A87688788BB2}.Release|x64.Build.0 = Release|Any CPU
{95E9FEB4-DCD3-4514-8208-A87688788BB2}.Release|x86.ActiveCfg = Release|Any CPU
{95E9FEB4-DCD3-4514-8208-A87688788BB2}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FB8DA12F-84B5-4D7F-A6E1-7F0A53AA4535}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "pch.h"
#include "BufferExtensions.h"
#include "BufferExtensions.g.cpp"

using namespace winrt::Windows::Storage::Streams;

namespace winrt::SkiaSharp::Views::WinUI::Native::implementation
{
intptr_t BufferExtensions::GetByteBuffer(IBuffer const& buffer)
{
byte* current_data = nullptr;
auto bufferByteAccess = buffer.as<winrt::impl::IBufferByteAccess>();
bufferByteAccess->Buffer(&current_data);
return (intptr_t)current_data;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#include "BufferExtensions.g.h"

using namespace winrt::Windows::Storage::Streams;

namespace winrt::SkiaSharp::Views::WinUI::Native::implementation
{
struct BufferExtensions
{
BufferExtensions() = default;

static intptr_t GetByteBuffer(IBuffer const& buffer);
};
}

namespace winrt::SkiaSharp::Views::WinUI::Native::factory_implementation
{
struct BufferExtensions : BufferExtensionsT<BufferExtensions, implementation::BufferExtensions>
{
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace SkiaSharp.Views.WinUI.Native
{
static runtimeclass BufferExtensions
{
static Int64 GetByteBuffer(Windows.Storage.Streams.IBuffer buffer);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "pch.h"
#include "PropertySetExtensions.h"
#include "PropertySetExtensions.g.cpp"

using namespace winrt::Windows::Foundation;
using namespace winrt::Windows::Foundation::Collections;

namespace winrt::SkiaSharp::Views::WinUI::Native::implementation
{
void PropertySetExtensions::AddSingle(PropertySet const& propertySet, hstring const& key, float value)
{
propertySet.Insert(key, PropertyValue::CreateSingle(value));
}

void PropertySetExtensions::AddSize(PropertySet const& propertySet, hstring const& key, Size const& height)
{
propertySet.Insert(key, PropertyValue::CreateSize(height));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#include "PropertySetExtensions.g.h"

using namespace winrt::Windows::Foundation;
using namespace winrt::Windows::Foundation::Collections;

namespace winrt::SkiaSharp::Views::WinUI::Native::implementation
{
struct PropertySetExtensions
{
PropertySetExtensions() = default;

static void AddSingle(PropertySet const& propertySet, hstring const& key, float value);
static void AddSize(PropertySet const& propertySet, hstring const& key, Size const& value);
};
}

namespace winrt::SkiaSharp::Views::WinUI::Native::factory_implementation
{
struct PropertySetExtensions : PropertySetExtensionsT<PropertySetExtensions, implementation::PropertySetExtensions>
{
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace SkiaSharp.Views.WinUI.Native
{
static runtimeclass PropertySetExtensions
{
static void AddSingle(Windows.Foundation.Collections.PropertySet propertySet, String key, Single value);
static void AddSize(Windows.Foundation.Collections.PropertySet propertySet, String key, Windows.Foundation.Size value);
}
}
Loading
Loading