feat(host): vendor PyroWave + minimal Granite subset as crates/pyrowave-sys

Phase 0 of design/pyrowave-codec-plan.md — the opt-in wired-LAN ultra-low-
latency codec. Vendored at upstream 509e4f88 (API 0.4.0, Granite 44362775,
volk + vulkan-headers pins in PUNKTFUNK-VENDOR.txt), pruned to the 6.6 MB
the standalone no-renderer build needs; scripts/vendor-pyrowave.sh
reproduces the tree (a pin bump is protocol-affecting, plan §4.2).

build.rs drives the wrapper CMakeLists (static archives incl. a static
C-API lib upstream only ships shared) + bindgen over pyrowave.h; Linux and
Windows only, empty stub elsewhere (Apple gets a native Metal port, §4.7).
Offline-safe by construction: no network, no system lib, vendored Vulkan
headers — same model as the opus dep (flatpak builder has no network).

Phase-0 validation on .21 (RTX 5070 Ti, driver 610.43.03):
- upstream pyrowave-c-test + interop test (incl. dmabuf/DRM-modifier
  Vulkan<->Vulkan) pass, from the pristine AND the pruned tree
- GPU kernel times at ~1.6 bpp noise: encode/decode 0.090/0.042 ms @800p,
  0.146/0.067 @1080p, 0.226/0.103 @1440p, 0.477/0.201 @4K — order of
  magnitude under NVENC's 1-2 ms retrieve, CBR lands within ~100 B of
  target
- cargo test -p pyrowave-sys green (static link + API-version pin check)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-15 00:35:10 +02:00
parent 1b73361372
commit 4c3b11445c
396 changed files with 140058 additions and 0 deletions
@@ -0,0 +1,27 @@
add_granite_internal_lib(granite-application-global
global_managers.hpp global_managers.cpp)
target_include_directories(granite-application-global PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(granite-application-global PUBLIC granite-util)
add_granite_internal_lib(granite-application-global-init
global_managers_init.hpp global_managers_init.cpp)
target_include_directories(granite-application-global-init PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(granite-application-global-init
PUBLIC granite-application-global
PRIVATE granite-threading granite-event granite-filesystem)
if (TARGET granite-renderer)
target_link_libraries(granite-application-global-init PRIVATE granite-renderer granite-ui)
target_compile_definitions(granite-application-global-init PRIVATE HAVE_GRANITE_RENDERER)
endif()
if (GRANITE_AUDIO)
target_link_libraries(granite-application-global-init PRIVATE granite-audio)
endif()
if (GRANITE_BULLET)
target_link_libraries(granite-application-global-init PRIVATE granite-physics)
endif()
add_library(granite-application-global-interface INTERFACE)
target_include_directories(granite-application-global-interface INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
@@ -0,0 +1,308 @@
/* Copyright (c) 2017-2026 Hans-Kristian Arntzen
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "global_managers.hpp"
#include "environment.hpp"
#include "logging.hpp"
#include <thread>
#include <assert.h>
#include <stdlib.h>
namespace Granite
{
namespace Global
{
// Could use unique_ptr here, but would be nice to avoid global ctor/dtor.
struct GlobalManagers
{
Factory *factory;
FilesystemInterface *filesystem;
AssetManagerInterface *asset_manager;
MaterialManagerInterface *material_manager;
EventManagerInterface *event_manager;
ThreadGroupInterface *thread_group;
UI::UIManagerInterface *ui_manager;
CommonRendererDataInterface *common_renderer_data;
Util::MessageQueueInterface *logging;
Audio::BackendInterface *audio_backend;
Audio::MixerInterface *audio_mixer;
PhysicsSystemInterface *physics;
};
static thread_local GlobalManagers global_managers;
GlobalManagersHandle create_thread_context()
{
return GlobalManagersHandle(new GlobalManagers(global_managers));
}
void delete_thread_context(GlobalManagers *managers)
{
delete managers;
}
void GlobalManagerDeleter::operator()(GlobalManagers *managers)
{
delete_thread_context(managers);
}
void set_thread_context(const GlobalManagers &managers)
{
global_managers = managers;
if (managers.thread_group)
managers.thread_group->set_thread_context();
if (managers.logging)
Util::set_thread_logging_interface(managers.logging);
}
void clear_thread_context()
{
global_managers = {};
}
Util::MessageQueueInterface *message_queue()
{
return global_managers.logging;
}
FilesystemInterface *filesystem()
{
return global_managers.filesystem;
}
AssetManagerInterface *asset_manager()
{
return global_managers.asset_manager;
}
MaterialManagerInterface *material_manager()
{
return global_managers.material_manager;
}
EventManagerInterface *event_manager()
{
return global_managers.event_manager;
}
ThreadGroupInterface *thread_group()
{
return global_managers.thread_group;
}
UI::UIManagerInterface *ui_manager()
{
return global_managers.ui_manager;
}
CommonRendererDataInterface *common_renderer_data()
{
return global_managers.common_renderer_data;
}
Audio::BackendInterface *audio_backend() { return global_managers.audio_backend; }
Audio::MixerInterface *audio_mixer() { return global_managers.audio_mixer; }
void install_audio_system(Audio::BackendInterface *backend, Audio::MixerInterface *mixer)
{
delete global_managers.audio_mixer;
global_managers.audio_mixer = mixer;
delete global_managers.audio_backend;
global_managers.audio_backend = backend;
}
PhysicsSystemInterface *physics()
{
return global_managers.physics;
}
void init(Factory &factory, ManagerFeatureFlags flags, unsigned max_threads, float audio_sample_rate)
{
assert(!global_managers.factory || global_managers.factory == &factory);
global_managers.factory = &factory;
if (flags & MANAGER_FEATURE_EVENT_BIT)
{
if (!global_managers.event_manager)
global_managers.event_manager = factory.create_event_manager();
}
if (flags & MANAGER_FEATURE_FILESYSTEM_BIT)
{
if (!global_managers.filesystem)
global_managers.filesystem = factory.create_filesystem();
}
if (flags & MANAGER_FEATURE_ASSET_MANAGER_BIT)
{
if (!global_managers.asset_manager)
global_managers.asset_manager = factory.create_asset_manager();
}
if (flags & MANAGER_FEATURE_MATERIAL_MANAGER_BIT)
{
if (!global_managers.material_manager)
global_managers.material_manager = factory.create_material_manager();
}
bool kick_threads = false;
if (flags & MANAGER_FEATURE_THREAD_GROUP_BIT)
{
if (!global_managers.thread_group)
{
global_managers.thread_group = factory.create_thread_group();
kick_threads = true;
}
}
if (flags & MANAGER_FEATURE_UI_MANAGER_BIT)
{
if (!global_managers.ui_manager)
global_managers.ui_manager = factory.create_ui_manager();
}
if (flags & MANAGER_FEATURE_COMMON_RENDERER_DATA_BIT)
{
if (!global_managers.common_renderer_data)
global_managers.common_renderer_data = factory.create_common_renderer_data();
}
if (flags & MANAGER_FEATURE_LOGGING_BIT)
{
if (!global_managers.logging)
global_managers.logging = factory.create_message_queue();
Util::set_thread_logging_interface(global_managers.logging);
}
if (flags & MANAGER_FEATURE_PHYSICS_BIT)
{
if (!global_managers.physics)
global_managers.physics = factory.create_physics_system();
}
if (flags & MANAGER_FEATURE_AUDIO_MIXER_BIT)
{
if (!global_managers.audio_mixer)
global_managers.audio_mixer = factory.create_audio_mixer();
}
if (flags & MANAGER_FEATURE_AUDIO_BACKEND_BIT)
{
if (!global_managers.audio_backend)
global_managers.audio_backend = factory.create_audio_backend(global_managers.audio_mixer, audio_sample_rate, 2);
}
// Kick threads after all global managers are set up.
if (kick_threads)
{
unsigned cpu_threads = std::thread::hardware_concurrency();
cpu_threads = cpu_threads > 1 ? (cpu_threads - 1u) : 1u;
if (cpu_threads > max_threads)
cpu_threads = max_threads;
cpu_threads = Util::get_environment_uint("GRANITE_NUM_WORKER_THREADS", cpu_threads);
unsigned background_cpu_threads = (cpu_threads + 1) / 2;
global_managers.thread_group->start(cpu_threads, background_cpu_threads,
[ctx = std::shared_ptr<GlobalManagers>(create_thread_context())] {
set_thread_context(*ctx);
});
}
}
void deinit()
{
if (!global_managers.factory)
return;
if (global_managers.audio_backend)
global_managers.audio_backend->stop();
delete global_managers.audio_backend;
delete global_managers.audio_mixer;
delete global_managers.physics;
delete global_managers.common_renderer_data;
delete global_managers.ui_manager;
delete global_managers.thread_group;
delete global_managers.material_manager;
delete global_managers.asset_manager;
delete global_managers.filesystem;
delete global_managers.event_manager;
delete global_managers.logging;
global_managers.audio_backend = nullptr;
global_managers.audio_mixer = nullptr;
global_managers.physics = nullptr;
global_managers.common_renderer_data = nullptr;
global_managers.filesystem = nullptr;
global_managers.material_manager = nullptr;
global_managers.asset_manager = nullptr;
global_managers.event_manager = nullptr;
global_managers.thread_group = nullptr;
global_managers.ui_manager = nullptr;
global_managers.logging = nullptr;
global_managers.factory = nullptr;
}
void start_audio_system()
{
if (!global_managers.audio_backend)
return;
if (!global_managers.audio_backend->start())
{
LOGE("Failed to start audio subsystem!\n");
return;
}
if (global_managers.event_manager && global_managers.audio_mixer)
global_managers.audio_mixer->event_start(*global_managers.event_manager);
}
void stop_audio_system()
{
if (!global_managers.audio_backend)
return;
if (!global_managers.audio_backend->stop())
LOGE("Failed to stop audio subsystem!\n");
if (global_managers.event_manager && global_managers.audio_mixer)
global_managers.audio_mixer->event_stop(*global_managers.event_manager);
}
FilesystemInterface *Factory::create_filesystem() { return nullptr; }
AssetManagerInterface *Factory::create_asset_manager() { return nullptr; }
MaterialManagerInterface *Factory::create_material_manager() { return nullptr; }
EventManagerInterface *Factory::create_event_manager() { return nullptr; }
ThreadGroupInterface *Factory::create_thread_group() { return nullptr; }
CommonRendererDataInterface *Factory::create_common_renderer_data() { return nullptr; }
PhysicsSystemInterface *Factory::create_physics_system() { return nullptr; }
Audio::BackendInterface *Factory::create_audio_backend(Audio::MixerInterface *, float, unsigned) { return nullptr; }
Audio::MixerInterface *Factory::create_audio_mixer() { return nullptr; }
UI::UIManagerInterface *Factory::create_ui_manager() { return nullptr; }
Util::MessageQueueInterface *Factory::create_message_queue() { return nullptr; }
}
}
@@ -0,0 +1,127 @@
/* Copyright (c) 2017-2026 Hans-Kristian Arntzen
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <stdint.h>
#include <functional>
#include <memory>
#include <limits.h>
#include "global_managers_interface.hpp"
namespace Granite
{
namespace Global
{
enum ManagerFeatureFlagBits
{
MANAGER_FEATURE_FILESYSTEM_BIT = 1 << 0,
MANAGER_FEATURE_EVENT_BIT = 1 << 1,
MANAGER_FEATURE_THREAD_GROUP_BIT = 1 << 2,
MANAGER_FEATURE_UI_MANAGER_BIT = 1 << 3,
MANAGER_FEATURE_AUDIO_MIXER_BIT = 1 << 4,
MANAGER_FEATURE_AUDIO_BACKEND_BIT = 1 << 5,
MANAGER_FEATURE_COMMON_RENDERER_DATA_BIT = 1 << 6,
MANAGER_FEATURE_PHYSICS_BIT = 1 << 7,
MANAGER_FEATURE_LOGGING_BIT = 1 << 8,
MANAGER_FEATURE_ASSET_MANAGER_BIT = 1 << 9,
MANAGER_FEATURE_MATERIAL_MANAGER_BIT = 1 << 10,
MANAGER_FEATURE_DEFAULT_BITS = (MANAGER_FEATURE_FILESYSTEM_BIT |
MANAGER_FEATURE_ASSET_MANAGER_BIT |
MANAGER_FEATURE_MATERIAL_MANAGER_BIT |
MANAGER_FEATURE_EVENT_BIT |
MANAGER_FEATURE_THREAD_GROUP_BIT |
MANAGER_FEATURE_COMMON_RENDERER_DATA_BIT |
MANAGER_FEATURE_UI_MANAGER_BIT |
MANAGER_FEATURE_AUDIO_MIXER_BIT |
MANAGER_FEATURE_AUDIO_BACKEND_BIT)
};
using ManagerFeatureFlags = uint32_t;
// Decouple creation from global TLS storage.
// This avoids some nasty cyclical dependencies.
class Factory
{
public:
virtual ~Factory() = default;
virtual FilesystemInterface *create_filesystem();
virtual AssetManagerInterface *create_asset_manager();
virtual MaterialManagerInterface *create_material_manager();
virtual EventManagerInterface *create_event_manager();
virtual ThreadGroupInterface *create_thread_group();
virtual CommonRendererDataInterface *create_common_renderer_data();
virtual PhysicsSystemInterface *create_physics_system();
virtual Audio::BackendInterface *create_audio_backend(Audio::MixerInterface *mixer,
float sample_rate,
unsigned channels);
virtual Audio::MixerInterface *create_audio_mixer();
virtual UI::UIManagerInterface *create_ui_manager();
virtual Util::MessageQueueInterface *create_message_queue();
};
void init(Factory &factory, ManagerFeatureFlags flags = MANAGER_FEATURE_DEFAULT_BITS,
unsigned max_threads = UINT_MAX, float audio_sample_rate = -1.0f);
void deinit();
// Used if the application wants to use multiple instances of Granite in the same process.
// This allows each thread to be associated to a global context.
struct GlobalManagers;
struct GlobalManagerDeleter
{
void operator()(GlobalManagers *managers);
};
using GlobalManagersHandle = std::unique_ptr<GlobalManagers, GlobalManagerDeleter>;
GlobalManagersHandle create_thread_context();
void delete_thread_context(GlobalManagers *managers);
void set_thread_context(const GlobalManagers &managers);
void clear_thread_context();
void start_audio_system();
void stop_audio_system();
void install_audio_system(Audio::BackendInterface *backend, Audio::MixerInterface *mixer);
Util::MessageQueueInterface *message_queue();
FilesystemInterface *filesystem();
AssetManagerInterface *asset_manager();
MaterialManagerInterface *material_manager();
EventManagerInterface *event_manager();
ThreadGroupInterface *thread_group();
UI::UIManagerInterface *ui_manager();
CommonRendererDataInterface *common_renderer_data();
Audio::BackendInterface *audio_backend();
Audio::MixerInterface *audio_mixer();
PhysicsSystemInterface *physics();
}
}
#define GRANITE_MESSAGE_QUEUE() static_cast<::Util::MessageQueue *>(::Granite::Global::message_queue())
#define GRANITE_FILESYSTEM() static_cast<::Granite::Filesystem *>(::Granite::Global::filesystem())
#define GRANITE_ASSET_MANAGER() static_cast<::Granite::AssetManager *>(::Granite::Global::asset_manager())
#define GRANITE_MATERIAL_MANAGER() static_cast<::Granite::MaterialManager *>(::Granite::Global::material_manager())
#define GRANITE_EVENT_MANAGER() static_cast<::Granite::EventManager *>(::Granite::Global::event_manager())
#define GRANITE_THREAD_GROUP() static_cast<::Granite::ThreadGroup *>(::Granite::Global::thread_group())
#define GRANITE_UI_MANAGER() static_cast<::Granite::UI::UIManager *>(::Granite::Global::ui_manager())
#define GRANITE_COMMON_RENDERER_DATA() static_cast<::Granite::CommonRendererData *>(::Granite::Global::common_renderer_data())
#define GRANITE_AUDIO_BACKEND() static_cast<::Granite::Audio::Backend *>(::Granite::Global::audio_backend())
#define GRANITE_AUDIO_MIXER() static_cast<::Granite::Audio::Mixer *>(::Granite::Global::audio_mixer())
#define GRANITE_PHYSICS() static_cast<::Granite::PhysicsSystem *>(::Granite::Global::physics())
@@ -0,0 +1,137 @@
/* Copyright (c) 2017-2026 Hans-Kristian Arntzen
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "global_managers_init.hpp"
#include "global_managers.hpp"
#include "event.hpp"
#include "thread_group.hpp"
#include "filesystem.hpp"
#include "asset_manager.hpp"
#ifdef HAVE_GRANITE_RENDERER
#include "material_manager.hpp"
#include "common_renderer_data.hpp"
#include "ui_manager.hpp"
#endif
#ifdef HAVE_GRANITE_AUDIO
#include "audio_mixer.hpp"
#include "audio_interface.hpp"
#endif
#ifdef HAVE_GRANITE_PHYSICS
#include "physics_system.hpp"
#endif
namespace Granite
{
namespace Global
{
struct FactoryImplementation : Factory
{
FilesystemInterface *create_filesystem() override
{
return new Filesystem;
}
AssetManagerInterface *create_asset_manager() override
{
return new AssetManager;
}
EventManagerInterface *create_event_manager() override
{
return new EventManager;
}
ThreadGroupInterface *create_thread_group() override
{
return new ThreadGroup;
}
CommonRendererDataInterface *create_common_renderer_data() override
{
#ifdef HAVE_GRANITE_RENDERER
return new CommonRendererData;
#else
return nullptr;
#endif
}
UI::UIManagerInterface *create_ui_manager() override
{
#ifdef HAVE_GRANITE_RENDERER
return new UI::UIManager;
#else
return nullptr;
#endif
}
MaterialManagerInterface *create_material_manager() override
{
#ifdef HAVE_GRANITE_RENDERER
return new MaterialManager;
#else
return nullptr;
#endif
}
Audio::MixerInterface *create_audio_mixer() override
{
#ifdef HAVE_GRANITE_AUDIO
return new Audio::Mixer;
#else
return nullptr;
#endif
}
Audio::BackendInterface *create_audio_backend(Audio::MixerInterface *iface, float sample_rate, unsigned channels) override
{
#ifdef HAVE_GRANITE_AUDIO
if (iface)
return Audio::create_default_audio_backend(static_cast<Audio::Mixer *>(iface), sample_rate, channels);
else
return nullptr;
#else
(void)iface;
(void)sample_rate;
(void)channels;
return nullptr;
#endif
}
PhysicsSystemInterface *create_physics_system() override
{
#ifdef HAVE_GRANITE_PHYSICS
return new PhysicsSystem;
#else
return nullptr;
#endif
}
};
static FactoryImplementation factory;
void init(ManagerFeatureFlags flags, unsigned max_threads, float audio_sample_rate)
{
init(factory, flags, max_threads, audio_sample_rate);
}
}
}
@@ -0,0 +1,34 @@
/* Copyright (c) 2017-2026 Hans-Kristian Arntzen
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include "global_managers.hpp"
namespace Granite
{
namespace Global
{
void init(ManagerFeatureFlags flags = MANAGER_FEATURE_DEFAULT_BITS,
unsigned max_threads = UINT_MAX, float audio_sample_rate = -1.0f);
}
}
@@ -0,0 +1,133 @@
/* Copyright (c) 2017-2026 Hans-Kristian Arntzen
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <functional>
#include <string>
#include "logging.hpp"
namespace Util
{
class MessageQueueInterface : public LoggingInterface
{
public:
virtual ~MessageQueueInterface() = default;
};
}
namespace Granite
{
class FilesystemInterface
{
public:
virtual ~FilesystemInterface() = default;
virtual bool load_text_file(const std::string &path, std::string &str) = 0;
};
class AssetManagerInterface
{
public:
virtual ~AssetManagerInterface() = default;
};
class MaterialManagerInterface
{
public:
virtual ~MaterialManagerInterface() = default;
virtual void iterate(AssetManagerInterface *iface) = 0;
};
class ThreadGroupInterface
{
public:
virtual ~ThreadGroupInterface() = default;
virtual void start(unsigned foreground_count, unsigned background_count,
const std::function<void()> &cb) = 0;
virtual void set_thread_context() = 0;
};
class EventManagerInterface
{
public:
virtual ~EventManagerInterface() = default;
};
class CommonRendererDataInterface
{
public:
virtual ~CommonRendererDataInterface() = default;
};
class PhysicsSystemInterface
{
public:
virtual ~PhysicsSystemInterface() = default;
};
class TouchDownEvent;
class TouchUpEvent;
class MouseMoveEvent;
class KeyboardEvent;
class OrientationEvent;
class TouchGestureEvent;
class MouseButtonEvent;
class JoypadButtonEvent;
class JoypadAxisEvent;
namespace UI
{
class UIManagerInterface
{
public:
virtual ~UIManagerInterface() = default;
virtual bool filter_input_event(const TouchDownEvent &e) = 0;
virtual bool filter_input_event(const TouchUpEvent &e) = 0;
virtual bool filter_input_event(const MouseMoveEvent &e) = 0;
virtual bool filter_input_event(const KeyboardEvent &e) = 0;
virtual bool filter_input_event(const OrientationEvent &e) = 0;
virtual bool filter_input_event(const TouchGestureEvent &e) = 0;
virtual bool filter_input_event(const MouseButtonEvent &e) = 0;
virtual bool filter_input_event(const JoypadButtonEvent &e) = 0;
virtual bool filter_input_event(const JoypadAxisEvent &e) = 0;
};
}
namespace Audio
{
class BackendInterface
{
public:
virtual ~BackendInterface() = default;
virtual bool start() = 0;
virtual bool stop() = 0;
};
class MixerInterface
{
public:
virtual ~MixerInterface() = default;
virtual void event_start(EventManagerInterface &event_manager) = 0;
virtual void event_stop(EventManagerInterface &event_manager) = 0;
};
}
}