Skip to content

Commit

Permalink
Fix Linux patch for VSTGUI 4.13
Browse files Browse the repository at this point in the history
`cairographicscontext.patch` is provided by Konstantin Voinov (@KottV on GitHub).

Reference:
- #48
  • Loading branch information
ryukau committed Dec 28, 2023
1 parent 994cd6c commit 1799c58
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)

project(UhhyouPlugins
VERSION 0.59.0)
VERSION 0.61.0)

option(SMTG_ADD_VST3_HOSTING_SAMPLES OFF)
option(SMTG_ENABLE_VST3_PLUGIN_EXAMPLES OFF)
Expand Down
17 changes: 12 additions & 5 deletions build_instruction.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Following plugins are only available for x86_64 or aarch64.
- EsPhaser
- IterativeSinCluster

To disable building them, comment out those plugins in top level `CMakeLists.txt`.
To stop building these plugins, comment out these plugins in top level `CMakeLists.txt`.

To target a specific x86_64 SIMD instructions, see `common/cmake/simd_x86_64_and_aarch64.cmake`.

Expand All @@ -31,10 +31,11 @@ git clone --recursive https://github.com/ryukau/VSTPlugins.git
cd VSTPlugins

# Patch vst3sdk.
# - https://github.com/ryukau/VSTPlugins/issues/3
cp \
ci/linux_patch/cairocontext.cpp \
lib/vst3sdk/vstgui4/vstgui/lib/platform/linux/cairocontext.cpp
# - https://github.com/ryukau/VSTPlugins/issues/48
# - https://github.com/steinbergmedia/vstgui/issues/126
cd lib/vst3sdk/vstgui4/
git apply ../../../ci/linux_patch/cairographicscontext.patch
cd ../../../

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j
Expand Down Expand Up @@ -133,6 +134,12 @@ cmake --build build --config Release

Plugins are built into `~/code/vst/VSTPlugins/build/VST3/Release`. To install plugins, copy them to `/Users/$USERNAME/Library/Audio/Plug-ins/VST3/`.

If CMake is installed from Homebrew, `cmake -S . -B build -GXcode` may fail. In this case, try running following command.

```
sudo xcode-select --reset
```

## Reference
Steinberg's vst3sdk repository on GitHub.

Expand Down
9 changes: 5 additions & 4 deletions ci/ci_ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ sudo apt-get update
sudo apt-get install cmake gcc "libstdc++6" libx11-xcb-dev libxcb-util-dev libxcb-cursor-dev libxcb-xkb-dev libxkbcommon-dev libxkbcommon-x11-dev libfontconfig1-dev libcairo2-dev libgtkmm-3.0-dev libsqlite3-dev libxcb-keysyms1-dev

# Patch vst3sdk.
# - https://github.com/ryukau/VSTPlugins/issues/3
cp \
ci/linux_patch/cairocontext.cpp \
lib/vst3sdk/vstgui4/vstgui/lib/platform/linux/cairocontext.cpp
# - https://github.com/ryukau/VSTPlugins/issues/48
# - https://github.com/steinbergmedia/vstgui/issues/126
cd lib/vst3sdk/vstgui4/
git apply ../../../ci/linux_patch/cairographicscontext.patch
cd ../../../

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
Expand Down
54 changes: 54 additions & 0 deletions ci/linux_patch/cairographicscontext.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
diff --git a/vstgui/lib/platform/linux/cairographicscontext.cpp b/vstgui/lib/platform/linux/cairographicscontext.cpp
index ab620cc9..f9b735bf 100644
--- a/vstgui/lib/platform/linux/cairographicscontext.cpp
+++ b/vstgui/lib/platform/linux/cairographicscontext.cpp
@@ -406,15 +406,11 @@ bool CairoGraphicsDeviceContext::drawPolygon (const PointList& polygonPointList,
vstgui_assert (polygonPointList.empty () == false);
impl->doInContext ([&] () {
bool doPixelAlign = impl->state.drawMode.integralMode ();
- auto last = polygonPointList.back ();
- if (doPixelAlign)
- last = pixelAlign (impl->state.tm, last);
- cairo_move_to (impl->context, last.x, last.y);
- for (auto p : polygonPointList)
+ auto first = polygonPointList.front ();
+ cairo_move_to (impl->context, first.x, first.y);
+ for (auto p = polygonPointList.begin () + 1; p != polygonPointList.end (); ++p)
{
- if (doPixelAlign)
- p = pixelAlign (impl->state.tm, p);
- cairo_line_to (impl->context, p.x, p.y);
+ cairo_line_to (impl->context, (*p).x, (*p).y);
}
impl->draw (drawStyle);
});
@@ -448,15 +444,17 @@ bool CairoGraphicsDeviceContext::drawRect (CRect rect, PlatformGraphicsDrawStyle
return true;
}

-//------------------------------------------------------------------------
+//------------------------------cairo_restore (------------------------------------------
bool CairoGraphicsDeviceContext::drawArc (CRect rect, double startAngle1, double endAngle2,
PlatformGraphicsDrawStyle drawStyle) const
{
impl->doInContext ([&] () {
+ cairo_save (impl->context);
CPoint center = rect.getCenter ();
cairo_translate (impl->context, center.x, center.y);
- cairo_scale (impl->context, 2.0 / rect.getWidth (), 2.0 / rect.getHeight ());
- cairo_arc (impl->context, 0, 0, 1, startAngle1, endAngle2);
+ cairo_scale (impl->context, rect.getWidth () /2.0 , rect.getHeight () / 2.0);
+ cairo_arc (impl->context, 0, 0, 1, startAngle1 / 180.0 * M_PI, endAngle2 / 180.0 * M_PI);
+ cairo_restore (impl->context);
impl->draw (drawStyle);
});
return true;
@@ -468,7 +466,7 @@ bool CairoGraphicsDeviceContext::drawEllipse (CRect rect, PlatformGraphicsDrawSt
impl->doInContext ([&] () {
CPoint center = rect.getCenter ();
cairo_translate (impl->context, center.x, center.y);
- cairo_scale (impl->context, 2.0 / rect.getWidth (), 2.0 / rect.getHeight ());
+ cairo_scale (impl->context, rect.getWidth () / 2.0, rect.getHeight () / 2.0);
cairo_arc (impl->context, 0, 0, 1, 0, 2 * M_PI);
impl->draw (drawStyle);
});

0 comments on commit 1799c58

Please sign in to comment.