Skip to content
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
55 changes: 46 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,50 +71,79 @@ jobs:
run: dotnet restore

- name: Build AffinityPluginLoader
run: dotnet build AffinityPluginLoader/AffinityPluginLoader.csproj -c Release
run: dotnet build AffinityPluginLoader/AffinityPluginLoader.csproj -c Debug

- name: Build WineFix
run: dotnet build WineFix/WineFix.csproj -c Release
run: dotnet build WineFix/WineFix.csproj -c Debug

- name: Build AffinityHook
run: dotnet build AffinityHook/AffinityHook.csproj -c Release
run: dotnet build AffinityHook/AffinityHook.csproj -c Debug

- name: Upload AffinityPluginLoader artifacts
uses: actions/upload-artifact@v4
with:
name: AffinityPluginLoader
path: |
AffinityPluginLoader/bin/Release/net48/win-x64/AffinityPluginLoader.dll
AffinityPluginLoader/bin/Release/net48/win-x64/0Harmony.dll
AffinityPluginLoader/bin/Debug/net48/win-x64/AffinityPluginLoader.dll
AffinityPluginLoader/bin/Debug/net48/win-x64/0Harmony.dll
if-no-files-found: error

- name: Upload AffinityHook artifacts
uses: actions/upload-artifact@v4
with:
name: AffinityHook
path: AffinityHook/bin/Release/net48/win-x64/AffinityHook.exe
path: AffinityHook/bin/Debug/net48/win-x64/AffinityHook.exe
if-no-files-found: error

- name: Upload WineFix artifacts
uses: actions/upload-artifact@v4
with:
name: WineFix
path: WineFix/bin/Release/net48/win-x64/WineFix.dll
path: WineFix/bin/Debug/net48/win-x64/WineFix.dll
if-no-files-found: error

# Build d2d1.dll for Wine (x86_64-unix)
build-d2d1:
name: Build d2d1.dll (Wine Native)
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Wine development tools
run: |
sudo dpkg --add-architecture i386
sudo mkdir -pm755 /etc/apt/keyrings
sudo wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key
sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/jammy/winehq-jammy.sources
sudo apt update
sudo apt install -y --install-recommends wine64-tools

- name: Build d2d1.dll for x86_64-unix
working-directory: WineFix/lib/d2d1
run: make TARGET=x86_64-unix

- name: Upload d2d1 artifact
uses: actions/upload-artifact@v4
with:
name: d2d1
path: WineFix/lib/d2d1/build/x86_64-unix/d2d1.dll.so
if-no-files-found: error

# Package all artifacts into release archives
package:
name: Package Release Artifacts
runs-on: ubuntu-latest
needs: [build-bootstrap, build-csharp]
needs: [build-bootstrap, build-csharp, build-d2d1]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get short commit hash
id: commit
run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
run: echo "short_sha=$(echo ${{ github.event.pull_request.head.sha }} | cut -c1-7)" >> $GITHUB_OUTPUT

- name: Download AffinityBootstrap artifact
uses: actions/download-artifact@v4
Expand All @@ -140,6 +169,12 @@ jobs:
name: WineFix
path: build/winefix

- name: Download d2d1 artifact
uses: actions/download-artifact@v4
with:
name: d2d1
path: build/d2d1

- name: Create affinitypluginloader package structure
run: |
mkdir -p package/affinitypluginloader
Expand All @@ -155,6 +190,7 @@ jobs:
mkdir -p package/winefix/plugins
cp build/winefix/WineFix.dll package/winefix/plugins/
cp WineFix/LICENSE package/winefix/plugins/LICENSE
cp build/d2d1/d2d1.dll.so package/winefix/d2d1.dll

- name: Create combined package structure
run: |
Expand All @@ -164,6 +200,7 @@ jobs:
cp build/pluginloader/AffinityPluginLoader.dll package/combined/
cp build/pluginloader/0Harmony.dll package/combined/
cp build/winefix/WineFix.dll package/combined/plugins/
cp build/d2d1/d2d1.dll.so package/combined/d2d1.dll

- name: Create release archives
run: |
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/pr-comment-complete.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,16 @@ jobs:
PR_NUMBER=$(gh pr view "$PR_BRANCH" --repo ${{ github.repository }} --json number --jq '.number')
echo "number=$PR_NUMBER" >> $GITHUB_OUTPUT

- name: Download commit SHA artifact
uses: actions/download-artifact@v4
with:
name: commit_sha
run-id: ${{ github.event.workflow_run.id }}

- name: Get commit and run info
id: run-info
run: |
echo "short_sha=$(echo ${{ github.event.workflow_run.head_sha }} | cut -c1-7)" >> $GITHUB_OUTPUT
echo "short_sha=$(cat commit_sha.txt | cut -c1-7)" >> $GITHUB_OUTPUT
echo "run_id=${{ github.event.workflow_run.id }}" >> $GITHUB_OUTPUT
echo "conclusion=${{ github.event.workflow_run.conclusion }}" >> $GITHUB_OUTPUT

Expand Down
9 changes: 7 additions & 2 deletions WineFix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@ especially if the bug needs to be patched in native code.

## Licensing

WineFix is licensed under the terms of the GPLv2 except for the exemption noted below. You can find a copy of the license in the LICENSE file.
WineFix is licensed under the terms of the GPLv2 except for the exclusion and exemption noted below. You can find a copy of the license in the LICENSE file.

### License Exclusion

WineFix includes source code from the Wine project for d2d1.dll under `/WineFix/lib/d2d1`. In accordance with the original project, the code in this directory are instead licensed under the LGPLv2.1. A copy of this license can be found at `/WineFix/lib/d2d1/LICENSE`. Changes have been applied to the d2d1 source code to implement a recursive cubic bezier subdivision algorithm to correct cubic bezier rendering in Affinity, and to allow building d2d1.dll standalone from the full Wine source code repository.

### License Exemption

[Canva](https://github.com/canva) and it's subsidiaries are exempt from MIT licensing and may (at its option) instead license any source code authored for the WineFix project under the Zero-Clause BSD license.
[Canva](https://github.com/canva) and it's subsidiaries are exempt from GPLv2 licensing and may (at its option) instead license any source code authored for the WineFix project under the Zero-Clause BSD license.
- Due to requirements of the upstream Wine licensing, this exemption **does not apply** to the d2d1.dll implementation source code, ie. all code under `WineFix/lib/d2d1/` is excluded from this exemption.


# Credits
Expand Down
55 changes: 55 additions & 0 deletions WineFix/lib/d2d1/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Build directories
build/
build-*/

# Object files
*.o
*.obj
*.lo

# Libraries
*.lib
*.a
*.la

# Shared objects (DLLs)
*.dll
*.dll.so
*.so
*.dylib

# Executables
*.exe
*.out
*.app

# Generated files
*.res
*.rc.tmp
*_processed.rc

# IDL generated headers
include/generated/

# CMake
CMakeCache.txt
CMakeFiles/
cmake_install.cmake
install_manifest.txt

# IDE files
.vscode/
.idea/
*.swp
*.swo
*~

# OS files
.DS_Store
Thumbs.db

# Dependency files
*.d

# Log files
*.log
134 changes: 134 additions & 0 deletions WineFix/lib/d2d1/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
cmake_minimum_required(VERSION 3.16)
project(d2d1 VERSION 10.18 LANGUAGES C)

# Options for build configuration
option(BUILD_FOR_UNIX "Build Unix PE format (requires winegcc)" OFF)
option(BUILD_SYSWOW64 "Build for SysWoW64 mode" OFF)
set(TARGET_ARCH "x86_64" CACHE STRING "Target architecture (x86_64 or i386)")

# Set compiler based on architecture
if(TARGET_ARCH STREQUAL "i386")
set(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
set(CMAKE_RC_COMPILER i686-w64-mingw32-windres)
set(ARCH_FLAGS -m32 -D__i386__)
else()
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
set(ARCH_FLAGS -m64 -D__x86_64__)
endif()

# Source files
set(D2D1_SOURCES
src/bitmap.c
src/bitmap_render_target.c
src/brush.c
src/command_list.c
src/dc_render_target.c
src/device.c
src/effect.c
src/factory.c
src/geometry.c
src/hwnd_render_target.c
src/layer.c
src/mesh.c
src/state_block.c
src/stroke.c
src/wic_render_target.c
)

# IDL files to process
file(GLOB IDL_FILES "include/windows/*.idl")

# Create custom command to process IDL files
set(IDL_HEADERS "")
foreach(IDL_FILE ${IDL_FILES})
get_filename_component(IDL_NAME ${IDL_FILE} NAME_WE)
set(IDL_HEADER "${CMAKE_BINARY_DIR}/include/${IDL_NAME}.h")
add_custom_command(
OUTPUT ${IDL_HEADER}
COMMAND widl -I${CMAKE_SOURCE_DIR}/include/windows -h -o ${IDL_HEADER} ${IDL_FILE}
DEPENDS ${IDL_FILE}
COMMENT "Processing IDL: ${IDL_NAME}.idl"
)
list(APPEND IDL_HEADERS ${IDL_HEADER})
endforeach()

# Create a custom target for IDL headers
add_custom_target(idl_headers DEPENDS ${IDL_HEADERS})

# Create the DLL
add_library(d2d1 SHARED ${D2D1_SOURCES})

# Make sure IDL headers are generated before compiling
add_dependencies(d2d1 idl_headers)

# Include directories
target_include_directories(d2d1 PRIVATE
${CMAKE_SOURCE_DIR}/include/wine
${CMAKE_SOURCE_DIR}/include/windows
${CMAKE_BINARY_DIR}/include
${CMAKE_SOURCE_DIR}/src
)

# Compiler definitions
target_compile_definitions(d2d1 PRIVATE
__WINE__
_REENTRANT
WINE_UNICODE_NATIVE
$<$<BOOL:${BUILD_FOR_UNIX}>:__unix__>
$<$<BOOL:${BUILD_SYSWOW64}>:__WINE_SYSWOW64__>
)

# Compiler flags
target_compile_options(d2d1 PRIVATE
${ARCH_FLAGS}
-Wall
-O2
)

# Linker flags
target_link_options(d2d1 PRIVATE
${ARCH_FLAGS}
$<$<NOT:$<BOOL:${BUILD_FOR_UNIX}>>:-shared>
)

# Link libraries
target_link_libraries(d2d1 PRIVATE
d3d11
dxgi
d3d10_1
d3dcompiler
dwrite
gdi32
user32
advapi32
ole32
xmllite
uuid
)

# Set output name
set_target_properties(d2d1 PROPERTIES
OUTPUT_NAME "d2d1"
PREFIX ""
SUFFIX ".dll"
)

# Resource file handling
if(EXISTS "${CMAKE_SOURCE_DIR}/src/version.rc")
target_sources(d2d1 PRIVATE src/version.rc)
endif()

# Install rules
install(TARGETS d2d1
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)

# Print configuration
message(STATUS "D2D1 Build Configuration:")
message(STATUS " Architecture: ${TARGET_ARCH}")
message(STATUS " Build for Unix PE: ${BUILD_FOR_UNIX}")
message(STATUS " SysWoW64 mode: ${BUILD_SYSWOW64}")
message(STATUS " Compiler: ${CMAKE_C_COMPILER}")
37 changes: 37 additions & 0 deletions WineFix/lib/d2d1/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999

Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

---

This code is extracted from Wine 10.18
Copyright (c) 1993-2025 the Wine project authors

For a complete list of Wine authors, see:
https://www.winehq.org/

The Wine project is licensed under the LGPL 2.1.
For the full license text, see:
https://www.winehq.org/license
Loading