Skip to content

Commit

Permalink
Merge pull request #16 from sudara/macos-fallbacks
Browse files Browse the repository at this point in the history
Add tests in CI. Conditional support at compile and run time macOS versions
  • Loading branch information
sudara authored Nov 11, 2023
2 parents a7c4d59 + 632fac3 commit ab9654d
Show file tree
Hide file tree
Showing 27 changed files with 742 additions and 445 deletions.
89 changes: 89 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# https://forum.juce.com/t/automatic-juce-like-code-formatting-with-clang-format/31624/20
---
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AlignConsecutiveAssignments: None
AlignConsecutiveDeclarations: None
AlignEscapedNewlines: Left
AlignOperands: Align
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BreakAfterJavaFieldAnnotations: false
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BraceWrapping: # Allman except for lambdas
AfterClass: true
AfterCaseLabel: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
BeforeElse: true
AfterControlStatement: Always
BeforeLambdaBody: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakStringLiterals: false
ColumnLimit: 0
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
IndentCaseLabels: true
IndentPPDirectives: BeforeHash
IndentWidth: 4
IndentWrappedFunctionNames: true
KeepEmptyLinesAtTheStartOfBlocks: false
Language: Cpp
MaxEmptyLinesToKeep: 1
FixNamespaceComments: false
NamespaceIndentation: All
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: true
SpaceBeforeParens: NonEmptyParentheses
SpaceInEmptyParentheses: false
SpaceBeforeInheritanceColon: true
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: true
SpacesInParentheses: false
SpacesInLineCommentPrefix:
Minimum: 1
SpacesInSquareBrackets: false
Standard: "c++20"
TabWidth: 4
UseTab: Never
UseCRLF: false
---
Language: ObjC
BasedOnStyle: Chromium
BreakBeforeBraces: Allman
ColumnLimit: 0
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: false
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PointerAlignment: Left
SpacesBeforeTrailingComments: 1
TabWidth: 4
UseTab: Never
LineEnding: LF
68 changes: 68 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Tests

on:
workflow_dispatch:
push:

env:
BUILD_TYPE: Release
BUILD_DIR: Builds
CMAKE_BUILD_PARALLEL_LEVEL: 3 # Use up to 3 cpus to build juceaide, etc
HOMEBREW_NO_INSTALL_CLEANUP: 1
SCCACHE_GHA_ENABLED: "true"

concurrency:
group: ${{ github.workflow }}.${{ github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash

permissions:
contents: read

jobs:

BuildAndTest:
name: Tests
runs-on: ${{ matrix.os }}
timeout-minutes: 10

strategy:
fail-fast: false # show errors for each platform vs. cancel build
matrix:
os: [ macos-11, macos-12, macos-latest, windows-latest ]

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Install Ninja (Windows)
if: runner.os == 'Windows'
shell: bash
run: choco install ninja

- name: Install macOS Deps
if: ${{ matrix.os != 'windows-latest' }}
run: brew install ninja osxutils

- name: Checkout code
uses: actions/checkout@v3

- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.3

- name: Configure
shell: bash
run: cmake -B ${{ env.BUILD_DIR }} -G Ninja -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE}} -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache .

- name: Build
shell: bash
run: cmake --build ${{ env.BUILD_DIR }} --config ${{ env.BUILD_TYPE }} --parallel 4

- name: Test
working-directory: ${{ env.BUILD_DIR }}
run: ctest --output-on-failure -j4 -VV
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.DS_Store
JuceLibraryCode
Builds
Testing/
.idea/
cmake-build-release
cmake-build-relwithdebinfo
cmake-build-debug
CMakeCache.txt
CMakeFiles/
xcode
.vs
out
56 changes: 56 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
cmake_minimum_required(VERSION 3.20)

project(MelatoninBlur VERSION 1.0.0 LANGUAGES CXX
DESCRIPTION "Fast Blurs for JUCE"
HOMEPAGE_URL "https://github.com/sudara/melatonin_blur")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED YES)

include(FetchContent)
if (MelatoninBlur_IS_TOP_LEVEL)
message(STATUS "Cloning JUCE...")

FetchContent_Declare(JUCE
GIT_REPOSITORY https://github.com/juce-framework/JUCE.git
GIT_TAG origin/master
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE)
FetchContent_MakeAvailable(JUCE)

FetchContent_Declare(Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_PROGRESS TRUE
GIT_SHALLOW TRUE
GIT_TAG v3.4.0)
FetchContent_MakeAvailable(Catch2) # find_package equivalent

enable_testing()
add_executable(Tests ${TestFiles})
target_compile_features(Tests PUBLIC cxx_std_17)

target_sources(Tests PRIVATE "tests/blur_implementations.cpp" "tests/drop_shadow.cpp" "tests/inner_shadow.cpp")

# Our test executable also wants to know about our plugin code...
target_include_directories(Tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/source)

juce_add_module("${CMAKE_CURRENT_SOURCE_DIR}")

target_link_libraries(Tests PRIVATE
melatonin_blur
Catch2::Catch2WithMain
juce::juce_graphics # Image, etc
juce::juce_gui_basics # Colour, etc
juce::juce_audio_basics # FloatVectorOperations
juce::juce_recommended_config_flags
juce::juce_recommended_lto_flags
juce::juce_recommended_warning_flags)

# Enable this once tests are happy fundamentally in CI
# set_target_properties("${TARGET_NAME}" PROPERTIES COMPILE_WARNING_AS_ERROR ON)

include(${Catch2_SOURCE_DIR}/extras/Catch.cmake)
catch_discover_tests(Tests)
else ()
message(WARNING "This CMake config is just for CI tests.\nSubmit an Issue / PR if you want more CMake support: https://github.com/sudara/melatonin_blur ")
endif ()
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
![Figma - 2023-11-09 42@2x](https://github.com/sudara/melatonin_blur/assets/472/0cb16190-bce7-4d9a-8a7c-d15846946354)

![](https://github.com/sudara/melatonin_blur/actions/workflows/tests.yml/badge.svg)

Melatonin Blur is a batteries-included, cross-platform CPU blur library for the [JUCE C++ framework](https://juce.com/).

The goal: Get drop shadows and inner shadows fast enough that entire modern vector interfaces in JUCE can be built without resorting to deprecated solutions with lower quality of life (looking at you, OpenGL on macOS!).
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/argb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ TEST_CASE ("Melatonin Blur ARGB Benchmarks")
BENCHMARK ("gin")
{
// this modifies the image directly!
melatonin::stackBlur::ginRGBA (src, radius);
melatonin::stackBlur::ginARGB (src, radius);
g.drawImageAt (src, 0, 0, true);
auto color = srcData.getPixelColour (20, 20);
return color;
Expand All @@ -38,7 +38,7 @@ TEST_CASE ("Melatonin Blur ARGB Benchmarks")
BENCHMARK ("Melatonin uncached")
{
// uses a temp copy internally
melatonin::blur::argb (src, radius);
melatonin::blur::argb (src, dst, radius);
g.drawImageAt (src, 0, 0, true);
auto color = dstData.getPixelColour (20, 20);
return color;
Expand Down
Loading

0 comments on commit ab9654d

Please sign in to comment.