Reorganize files, add Fundamental plugins
This commit is contained in:
parent
934e7ad021
commit
2a5769a6ca
27 changed files with 515 additions and 157 deletions
297
src/CardinalPlugin.cpp
Normal file
297
src/CardinalPlugin.cpp
Normal file
|
@ -0,0 +1,297 @@
|
|||
/*
|
||||
* DISTRHO Cardinal Plugin
|
||||
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 3 of
|
||||
* the License, or any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* For a full copy of the GNU General Public License see the LICENSE file.
|
||||
*/
|
||||
|
||||
#include <asset.hpp>
|
||||
#include <audio.hpp>
|
||||
#include <context.hpp>
|
||||
#include <gamepad.hpp>
|
||||
#include <library.hpp>
|
||||
#include <keyboard.hpp>
|
||||
#include <midi.hpp>
|
||||
#include <patch.hpp>
|
||||
#include <plugin.hpp>
|
||||
#include <random.hpp>
|
||||
#include <settings.hpp>
|
||||
#include <system.hpp>
|
||||
|
||||
#include <app/Scene.hpp>
|
||||
#include <engine/Engine.hpp>
|
||||
#include <ui/common.hpp>
|
||||
#include <window/Window.hpp>
|
||||
|
||||
#include <osdialog.h>
|
||||
|
||||
#ifdef NDEBUG
|
||||
# undef DEBUG
|
||||
#endif
|
||||
#include "DistrhoPlugin.hpp"
|
||||
|
||||
namespace rack {
|
||||
namespace plugin {
|
||||
void initStaticPlugins();
|
||||
}
|
||||
}
|
||||
|
||||
START_NAMESPACE_DISTRHO
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------
|
||||
// The following code was based from VCVRack adapters/standalone.cpp
|
||||
|
||||
/*
|
||||
Copyright (C) 2016-2021 VCV
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the
|
||||
GNU General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
struct Initializer {
|
||||
Initializer()
|
||||
{
|
||||
using namespace rack;
|
||||
|
||||
settings::autoCheckUpdates = false;
|
||||
settings::autosaveInterval = 0;
|
||||
settings::discordUpdateActivity = false;
|
||||
settings::isPlugin = true;
|
||||
system::init();
|
||||
asset::init();
|
||||
logger::init();
|
||||
random::init();
|
||||
|
||||
// Make system dir point to source code location. It is good enough for now
|
||||
asset::systemDir = CARDINAL_PLUGIN_SOURCE_DIR DISTRHO_OS_SEP_STR "Rack";
|
||||
|
||||
// Log environment
|
||||
INFO("%s %s v%s", APP_NAME.c_str(), APP_EDITION.c_str(), APP_VERSION.c_str());
|
||||
INFO("%s", system::getOperatingSystemInfo().c_str());
|
||||
INFO("System directory: %s", asset::systemDir.c_str());
|
||||
INFO("User directory: %s", asset::userDir.c_str());
|
||||
INFO("System time: %s", string::formatTimeISO(system::getUnixTime()).c_str());
|
||||
|
||||
// Load settings
|
||||
settings::init();
|
||||
#if 0
|
||||
try {
|
||||
settings::load();
|
||||
}
|
||||
catch (Exception& e) {
|
||||
std::string message = e.what();
|
||||
message += "\n\nResetting settings to default";
|
||||
d_stdout(message.c_str());
|
||||
/*
|
||||
if (!osdialog_message(OSDIALOG_WARNING, OSDIALOG_OK_CANCEL, msg.c_str())) {
|
||||
exit(1);
|
||||
}
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
|
||||
// Check existence of the system res/ directory
|
||||
std::string resDir = asset::system("res");
|
||||
if (!system::isDirectory(resDir)) {
|
||||
std::string message = string::f("Rack's resource directory \"%s\" does not exist. Make sure Rack is correctly installed and launched.", resDir.c_str());
|
||||
d_stderr2(message.c_str());
|
||||
/*
|
||||
osdialog_message(OSDIALOG_ERROR, OSDIALOG_OK, message.c_str());
|
||||
*/
|
||||
// exit(1);
|
||||
}
|
||||
|
||||
INFO("Initializing environment");
|
||||
audio::init(); // does nothing
|
||||
midi::init(); // does nothing
|
||||
plugin::init();
|
||||
ui::init();
|
||||
|
||||
plugin::initStaticPlugins();
|
||||
}
|
||||
|
||||
~Initializer()
|
||||
{
|
||||
using namespace rack;
|
||||
|
||||
ui::destroy();
|
||||
midi::destroy();
|
||||
audio::destroy();
|
||||
plugin::destroy();
|
||||
INFO("Destroying logger");
|
||||
logger::destroy();
|
||||
}
|
||||
};
|
||||
|
||||
static const Initializer& getInitializerInstance()
|
||||
{
|
||||
static const Initializer init;
|
||||
return init;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------
|
||||
|
||||
class CardinalPlugin : public Plugin
|
||||
{
|
||||
rack::Context* const fContext;
|
||||
|
||||
struct ScopedContext {
|
||||
ScopedContext(CardinalPlugin* const plugin)
|
||||
{
|
||||
rack::contextSet(plugin->fContext);
|
||||
}
|
||||
|
||||
~ScopedContext()
|
||||
{
|
||||
rack::contextSet(nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
CardinalPlugin()
|
||||
: Plugin(0, 0, 0),
|
||||
fContext(new rack::Context)
|
||||
{
|
||||
const ScopedContext sc(this);
|
||||
|
||||
fContext->engine = new rack::engine::Engine;
|
||||
fContext->history = new rack::history::State;
|
||||
fContext->patch = new rack::patch::Manager;
|
||||
fContext->patch->autosavePath = "/OBVIOUSLY-NOT-VALID-PATH/";
|
||||
fContext->engine->startFallbackThread();
|
||||
}
|
||||
|
||||
~CardinalPlugin() override
|
||||
{
|
||||
const ScopedContext sc(this);
|
||||
|
||||
delete fContext;
|
||||
}
|
||||
|
||||
rack::Context* getRackContext() const noexcept
|
||||
{
|
||||
return fContext;
|
||||
}
|
||||
|
||||
protected:
|
||||
/* --------------------------------------------------------------------------------------------------------
|
||||
* Information */
|
||||
|
||||
/**
|
||||
Get the plugin label.
|
||||
A plugin label follows the same rules as Parameter::symbol, with the exception that it can start with numbers.
|
||||
*/
|
||||
const char* getLabel() const override
|
||||
{
|
||||
return "Cardinal";
|
||||
}
|
||||
|
||||
/**
|
||||
Get an extensive comment/description about the plugin.
|
||||
*/
|
||||
const char* getDescription() const override
|
||||
{
|
||||
return "...";
|
||||
}
|
||||
|
||||
/**
|
||||
Get the plugin author/maker.
|
||||
*/
|
||||
const char* getMaker() const override
|
||||
{
|
||||
return "DISTRHO";
|
||||
}
|
||||
|
||||
/**
|
||||
Get the plugin homepage.
|
||||
*/
|
||||
const char* getHomePage() const override
|
||||
{
|
||||
return "https://github.com/DISTRHO/Cardinal";
|
||||
}
|
||||
|
||||
/**
|
||||
Get the plugin license name (a single line of text).
|
||||
For commercial plugins this should return some short copyright information.
|
||||
*/
|
||||
const char* getLicense() const override
|
||||
{
|
||||
return "ISC";
|
||||
}
|
||||
|
||||
/**
|
||||
Get the plugin version, in hexadecimal.
|
||||
*/
|
||||
uint32_t getVersion() const override
|
||||
{
|
||||
return d_version(1, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
Get the plugin unique Id.
|
||||
This value is used by LADSPA, DSSI and VST plugin formats.
|
||||
*/
|
||||
int64_t getUniqueId() const override
|
||||
{
|
||||
return d_cconst('d', 'C', 'd', 'n');
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------------------
|
||||
* Init */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------------------
|
||||
* Internal data */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------------------
|
||||
* Process */
|
||||
|
||||
/**
|
||||
Run/process function for plugins without MIDI input.
|
||||
*/
|
||||
void run(const float** inputs, float** outputs, uint32_t frames) override
|
||||
{
|
||||
// copy inputs over outputs if needed
|
||||
if (outputs[0] != inputs[0])
|
||||
std::memcpy(outputs[0], inputs[0], sizeof(float)*frames);
|
||||
|
||||
if (outputs[1] != inputs[1])
|
||||
std::memcpy(outputs[1], inputs[1], sizeof(float)*frames);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
|
||||
private:
|
||||
/**
|
||||
Set our plugin class as non-copyable and add a leak detector just in case.
|
||||
*/
|
||||
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CardinalPlugin)
|
||||
};
|
||||
|
||||
rack::Context* getRackContextFromPlugin(void* const ptr)
|
||||
{
|
||||
return static_cast<CardinalPlugin*>(ptr)->getRackContext();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------
|
||||
* Plugin entry point, called by DPF to create a new plugin instance. */
|
||||
|
||||
Plugin* createPlugin()
|
||||
{
|
||||
getInitializerInstance();
|
||||
return new CardinalPlugin();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------
|
||||
|
||||
END_NAMESPACE_DISTRHO
|
322
src/CardinalUI.cpp
Normal file
322
src/CardinalUI.cpp
Normal file
|
@ -0,0 +1,322 @@
|
|||
/*
|
||||
* DISTRHO Cardinal Plugin
|
||||
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 3 of
|
||||
* the License, or any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* For a full copy of the GNU General Public License see the LICENSE file.
|
||||
*/
|
||||
|
||||
#include <app/common.hpp>
|
||||
#include <app/Scene.hpp>
|
||||
#include <context.hpp>
|
||||
#include <ui/common.hpp>
|
||||
#include <window/Window.hpp>
|
||||
|
||||
#ifdef NDEBUG
|
||||
# undef DEBUG
|
||||
#endif
|
||||
#include "DistrhoUI.hpp"
|
||||
#include "ResizeHandle.hpp"
|
||||
|
||||
GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window) { return nullptr; }
|
||||
GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char*) {}
|
||||
GLFWAPI const char* glfwGetKeyName(int key, int scancode) { return nullptr; }
|
||||
GLFWAPI int glfwGetKeyScancode(int key) { return 0; }
|
||||
|
||||
namespace rack {
|
||||
namespace window {
|
||||
DISTRHO_NAMESPACE::UI* lastUI = nullptr;
|
||||
|
||||
void mouseButtonCallback(Context* ctx, int button, int action, int mods);
|
||||
void cursorPosCallback(Context* ctx, double xpos, double ypos);
|
||||
void cursorEnterCallback(Context* ctx, int entered);
|
||||
void scrollCallback(Context* ctx, double x, double y);
|
||||
void charCallback(Context* ctx, unsigned int codepoint);
|
||||
void keyCallback(Context* ctx, int key, int scancode, int action, int mods);
|
||||
}
|
||||
}
|
||||
|
||||
START_NAMESPACE_DISTRHO
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------
|
||||
|
||||
rack::Context* getRackContextFromPlugin(void* ptr);
|
||||
|
||||
class CardinalUI : public UI
|
||||
{
|
||||
rack::Context* const fContext;
|
||||
ResizeHandle fResizeHandle;
|
||||
|
||||
struct ScopedContext {
|
||||
ScopedContext(CardinalUI* const ui)
|
||||
{
|
||||
rack::contextSet(ui->fContext);
|
||||
}
|
||||
|
||||
~ScopedContext()
|
||||
{
|
||||
rack::contextSet(nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
CardinalUI()
|
||||
: UI(1280, 720),
|
||||
fContext(getRackContextFromPlugin(getPluginInstancePointer())),
|
||||
fResizeHandle(this)
|
||||
{
|
||||
const ScopedContext sc(this);
|
||||
|
||||
fContext->event = new rack::widget::EventState;
|
||||
fContext->scene = new rack::app::Scene;
|
||||
fContext->event->rootWidget = fContext->scene;
|
||||
|
||||
// Initialize context
|
||||
d_stdout("UI context ptr %p", NanoVG::getContext());
|
||||
rack::window::lastUI = this;
|
||||
fContext->window = new rack::window::Window;
|
||||
rack::window::lastUI = nullptr;
|
||||
}
|
||||
|
||||
~CardinalUI() override
|
||||
{
|
||||
const ScopedContext sc(this);
|
||||
|
||||
delete fContext->window;
|
||||
fContext->window = nullptr;
|
||||
}
|
||||
|
||||
void onNanoDisplay() override
|
||||
{
|
||||
const ScopedContext sc(this);
|
||||
|
||||
fContext->window->step();
|
||||
}
|
||||
|
||||
void uiIdle() override
|
||||
{
|
||||
repaint();
|
||||
}
|
||||
|
||||
protected:
|
||||
/* --------------------------------------------------------------------------------------------------------
|
||||
* DSP/Plugin Callbacks */
|
||||
|
||||
/**
|
||||
A parameter has changed on the plugin side.
|
||||
This is called by the host to inform the UI about parameter changes.
|
||||
*/
|
||||
void parameterChanged(uint32_t index, float value) override
|
||||
{
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
|
||||
bool onMouse(const MouseEvent& ev) override
|
||||
{
|
||||
const ScopedContext sc(this);
|
||||
|
||||
int button;
|
||||
int mods = 0;
|
||||
int action = ev.press;
|
||||
|
||||
if (ev.mod & kModifierControl)
|
||||
mods |= GLFW_MOD_CONTROL;
|
||||
if (ev.mod & kModifierShift)
|
||||
mods |= GLFW_MOD_SHIFT;
|
||||
if (ev.mod & kModifierAlt)
|
||||
mods |= GLFW_MOD_ALT;
|
||||
|
||||
#ifdef DISTRHO_OS_MAC
|
||||
switch (ev.button)
|
||||
{
|
||||
case 1:
|
||||
button = GLFW_MOUSE_BUTTON_LEFT;
|
||||
break;
|
||||
case 2:
|
||||
button = GLFW_MOUSE_BUTTON_RIGHT;
|
||||
break;
|
||||
case 3:
|
||||
button = GLFW_MOUSE_BUTTON_MIDDLE;
|
||||
break;
|
||||
default:
|
||||
button = 0;
|
||||
break;
|
||||
}
|
||||
#else
|
||||
switch (ev.button)
|
||||
{
|
||||
case 1:
|
||||
button = GLFW_MOUSE_BUTTON_LEFT;
|
||||
break;
|
||||
case 2:
|
||||
button = GLFW_MOUSE_BUTTON_MIDDLE;
|
||||
break;
|
||||
case 3:
|
||||
button = GLFW_MOUSE_BUTTON_RIGHT;
|
||||
break;
|
||||
// case 4:
|
||||
// button = GLFW_MOUSE_WHEELUP;
|
||||
// break;
|
||||
// case 5:
|
||||
// button = GLFW_MOUSE_WHEELDOWN;
|
||||
// break;
|
||||
default:
|
||||
button = 0;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
rack::window::mouseButtonCallback(fContext, button, action, mods);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool onMotion(const MotionEvent& ev) override
|
||||
{
|
||||
const ScopedContext sc(this);
|
||||
|
||||
rack::window::cursorPosCallback(fContext, ev.pos.getX(), ev.pos.getY());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool onScroll(const ScrollEvent& ev) override
|
||||
{
|
||||
const ScopedContext sc(this);
|
||||
|
||||
rack::window::scrollCallback(fContext, ev.delta.getX(), ev.delta.getY());
|
||||
return true;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void onResize(const ResizeEvent& ev) override
|
||||
{
|
||||
UI::onResize(ev);
|
||||
// APP->window->setSize(rack::math::Vec(ev.size.getWidth(), ev.size.getHeight()));
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO uiFocus
|
||||
|
||||
bool onCharacterInput(const CharacterInputEvent& ev) override
|
||||
{
|
||||
if (ev.character == 0)
|
||||
return false;
|
||||
|
||||
const ScopedContext sc(this);
|
||||
|
||||
rack::window::charCallback(fContext, ev.character);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool onKeyboard(const KeyboardEvent& ev) override
|
||||
{
|
||||
const ScopedContext sc(this);
|
||||
|
||||
int key;
|
||||
int mods = 0;
|
||||
int action = ev.press;
|
||||
|
||||
/* These are unsupported in pugl right now
|
||||
#define GLFW_KEY_KP_0 320
|
||||
#define GLFW_KEY_KP_1 321
|
||||
#define GLFW_KEY_KP_2 322
|
||||
#define GLFW_KEY_KP_3 323
|
||||
#define GLFW_KEY_KP_4 324
|
||||
#define GLFW_KEY_KP_5 325
|
||||
#define GLFW_KEY_KP_6 326
|
||||
#define GLFW_KEY_KP_7 327
|
||||
#define GLFW_KEY_KP_8 328
|
||||
#define GLFW_KEY_KP_9 329
|
||||
#define GLFW_KEY_KP_DECIMAL 330
|
||||
#define GLFW_KEY_KP_DIVIDE 331
|
||||
#define GLFW_KEY_KP_MULTIPLY 332
|
||||
#define GLFW_KEY_KP_SUBTRACT 333
|
||||
#define GLFW_KEY_KP_ADD 334
|
||||
#define GLFW_KEY_KP_ENTER 335
|
||||
#define GLFW_KEY_KP_EQUAL 336
|
||||
*/
|
||||
|
||||
switch (ev.key)
|
||||
{
|
||||
case '\r': key = GLFW_KEY_ENTER; break;
|
||||
case '\t': key = GLFW_KEY_TAB; break;
|
||||
case kKeyBackspace: key = GLFW_KEY_BACKSPACE; break;
|
||||
case kKeyEscape: key = GLFW_KEY_ESCAPE; break;
|
||||
case kKeyDelete: key = GLFW_KEY_DELETE; break;
|
||||
case kKeyF1: key = GLFW_KEY_F1; break;
|
||||
case kKeyF2: key = GLFW_KEY_F2; break;
|
||||
case kKeyF3: key = GLFW_KEY_F3; break;
|
||||
case kKeyF4: key = GLFW_KEY_F4; break;
|
||||
case kKeyF5: key = GLFW_KEY_F5; break;
|
||||
case kKeyF6: key = GLFW_KEY_F6; break;
|
||||
case kKeyF7: key = GLFW_KEY_F7; break;
|
||||
case kKeyF8: key = GLFW_KEY_F8; break;
|
||||
case kKeyF9: key = GLFW_KEY_F9; break;
|
||||
case kKeyF10: key = GLFW_KEY_F10; break;
|
||||
case kKeyF11: key = GLFW_KEY_F11; break;
|
||||
case kKeyF12: key = GLFW_KEY_F12; break;
|
||||
case kKeyLeft: key = GLFW_KEY_LEFT; break;
|
||||
case kKeyUp: key = GLFW_KEY_UP; break;
|
||||
case kKeyRight: key = GLFW_KEY_RIGHT; break;
|
||||
case kKeyDown: key = GLFW_KEY_DOWN; break;
|
||||
case kKeyPageUp: key = GLFW_KEY_PAGE_UP; break;
|
||||
case kKeyPageDown: key = GLFW_KEY_PAGE_DOWN; break;
|
||||
case kKeyHome: key = GLFW_KEY_HOME; break;
|
||||
case kKeyEnd: key = GLFW_KEY_END; break;
|
||||
case kKeyInsert: key = GLFW_KEY_INSERT; break;
|
||||
case kKeyShiftL: key = GLFW_KEY_LEFT_SHIFT; break;
|
||||
case kKeyShiftR: key = GLFW_KEY_RIGHT_SHIFT; break;
|
||||
case kKeyControlL: key = GLFW_KEY_LEFT_CONTROL; break;
|
||||
case kKeyControlR: key = GLFW_KEY_RIGHT_CONTROL; break;
|
||||
case kKeyAltL: key = GLFW_KEY_LEFT_ALT; break;
|
||||
case kKeyAltR: key = GLFW_KEY_RIGHT_ALT; break;
|
||||
case kKeySuperL: key = GLFW_KEY_LEFT_SUPER; break;
|
||||
case kKeySuperR: key = GLFW_KEY_RIGHT_SUPER; break;
|
||||
case kKeyMenu: key = GLFW_KEY_MENU; break;
|
||||
case kKeyCapsLock: key = GLFW_KEY_CAPS_LOCK; break;
|
||||
case kKeyScrollLock: key = GLFW_KEY_SCROLL_LOCK; break;
|
||||
case kKeyNumLock: key = GLFW_KEY_NUM_LOCK; break;
|
||||
case kKeyPrintScreen: key = GLFW_KEY_PRINT_SCREEN; break;
|
||||
case kKeyPause: key = GLFW_KEY_PAUSE; break;
|
||||
default: key = ev.key; break;
|
||||
}
|
||||
|
||||
if (ev.mod & kModifierControl)
|
||||
mods |= GLFW_MOD_CONTROL;
|
||||
if (ev.mod & kModifierShift)
|
||||
mods |= GLFW_MOD_SHIFT;
|
||||
if (ev.mod & kModifierAlt)
|
||||
mods |= GLFW_MOD_ALT;
|
||||
|
||||
// TODO special key conversion
|
||||
rack::window::keyCallback(fContext, key, ev.keycode, action, mods);
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
Set our UI class as non-copyable and add a leak detector just in case.
|
||||
*/
|
||||
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CardinalUI)
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------
|
||||
* UI entry point, called by DPF to create a new UI instance. */
|
||||
|
||||
UI* createUI()
|
||||
{
|
||||
return new CardinalUI();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------
|
||||
|
||||
END_NAMESPACE_DISTRHO
|
39
src/DistrhoPluginInfo.h
Normal file
39
src/DistrhoPluginInfo.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* DISTRHO Cardinal Plugin
|
||||
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 3 of
|
||||
* the License, or any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* For a full copy of the GNU General Public License see the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef DISTRHO_PLUGIN_INFO_H_INCLUDED
|
||||
#define DISTRHO_PLUGIN_INFO_H_INCLUDED
|
||||
|
||||
#define DISTRHO_PLUGIN_BRAND "DISTRHO"
|
||||
#define DISTRHO_PLUGIN_NAME "Cardinal"
|
||||
#define DISTRHO_PLUGIN_URI "https://distrho.kx.studio/plugins/cardinal"
|
||||
|
||||
#define DISTRHO_PLUGIN_HAS_UI 1
|
||||
#define DISTRHO_PLUGIN_NUM_INPUTS 2
|
||||
#define DISTRHO_PLUGIN_NUM_OUTPUTS 2
|
||||
#define DISTRHO_PLUGIN_WANT_DIRECT_ACCESS 1
|
||||
// #define DISTRHO_PLUGIN_LV2_CATEGORY "lv2:AnalyserPlugin"
|
||||
// #define DISTRHO_PLUGIN_VST3_CATEGORIES "Fx|Analyzer"
|
||||
#define DISTRHO_UI_USE_NANOVG 1
|
||||
#define DISTRHO_UI_USER_RESIZABLE 0
|
||||
#define DISTRHO_PLUGIN_WANT_DIRECT_ACCESS 1
|
||||
|
||||
enum Parameters {
|
||||
kParameterCount
|
||||
};
|
||||
|
||||
#endif // DISTRHO_PLUGIN_INFO_H_INCLUDED
|
124
src/GL/glew.h
Normal file
124
src/GL/glew.h
Normal file
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
* DISTRHO Cardinal Plugin
|
||||
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 3 of
|
||||
* the License, or any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* For a full copy of the GNU General Public License see the LICENSE file.
|
||||
*/
|
||||
|
||||
// this file matches the top of `OpenGL.hpp` provided by DPF
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef NDEBUG
|
||||
# undef DEBUG
|
||||
#endif
|
||||
|
||||
/* Check OS */
|
||||
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
|
||||
# define DISTRHO_OS_WINDOWS 1
|
||||
#else
|
||||
# if defined(__APPLE__)
|
||||
# define DISTRHO_OS_MAC 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Fix OpenGL includes for Windows, based on glfw code (part 1)
|
||||
|
||||
#undef DGL_CALLBACK_DEFINED
|
||||
#undef DGL_WINGDIAPI_DEFINED
|
||||
|
||||
#ifdef DISTRHO_OS_WINDOWS
|
||||
|
||||
#ifndef APIENTRY
|
||||
# define APIENTRY __stdcall
|
||||
#endif // APIENTRY
|
||||
|
||||
/* We need WINGDIAPI defined */
|
||||
#ifndef WINGDIAPI
|
||||
# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__POCC__)
|
||||
# define WINGDIAPI __declspec(dllimport)
|
||||
# elif defined(__LCC__)
|
||||
# define WINGDIAPI __stdcall
|
||||
# else
|
||||
# define WINGDIAPI extern
|
||||
# endif
|
||||
# define DGL_WINGDIAPI_DEFINED
|
||||
#endif // WINGDIAPI
|
||||
|
||||
/* Some <GL/glu.h> files also need CALLBACK defined */
|
||||
#ifndef CALLBACK
|
||||
# if defined(_MSC_VER)
|
||||
# if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS)
|
||||
# define CALLBACK __stdcall
|
||||
# else
|
||||
# define CALLBACK
|
||||
# endif
|
||||
# else
|
||||
# define CALLBACK __stdcall
|
||||
# endif
|
||||
# define DGL_CALLBACK_DEFINED
|
||||
#endif // CALLBACK
|
||||
|
||||
/* Most GL/glu.h variants on Windows need wchar_t */
|
||||
#include <cstddef>
|
||||
|
||||
#endif // DISTRHO_OS_WINDOWS
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// OpenGL includes
|
||||
|
||||
#ifdef DISTRHO_OS_MAC
|
||||
# ifdef DGL_USE_OPENGL3
|
||||
# include <OpenGL/gl3.h>
|
||||
# include <OpenGL/gl3ext.h>
|
||||
# else
|
||||
# include <OpenGL/gl.h>
|
||||
# endif
|
||||
#else
|
||||
# ifdef DISTRHO_OS_WINDOWS
|
||||
# define GL_GLEXT_PROTOTYPES
|
||||
# endif
|
||||
# ifndef __GLEW_H__
|
||||
# include <GL/gl.h>
|
||||
# include <GL/glext.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Missing OpenGL defines
|
||||
|
||||
#if defined(GL_BGR_EXT) && !defined(GL_BGR)
|
||||
# define GL_BGR GL_BGR_EXT
|
||||
#endif
|
||||
|
||||
#if defined(GL_BGRA_EXT) && !defined(GL_BGRA)
|
||||
# define GL_BGRA GL_BGRA_EXT
|
||||
#endif
|
||||
|
||||
#ifndef GL_CLAMP_TO_BORDER
|
||||
# define GL_CLAMP_TO_BORDER 0x812D
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Fix OpenGL includes for Windows, based on glfw code (part 2)
|
||||
|
||||
#ifdef DGL_CALLBACK_DEFINED
|
||||
# undef CALLBACK
|
||||
# undef DGL_CALLBACK_DEFINED
|
||||
#endif
|
||||
|
||||
#ifdef DGL_WINGDIAPI_DEFINED
|
||||
# undef WINGDIAPI
|
||||
# undef DGL_WINGDIAPI_DEFINED
|
||||
#endif
|
141
src/Makefile
Normal file
141
src/Makefile
Normal file
|
@ -0,0 +1,141 @@
|
|||
#!/usr/bin/make -f
|
||||
# Makefile for DISTRHO Plugins #
|
||||
# ---------------------------- #
|
||||
# Created by falkTX
|
||||
#
|
||||
|
||||
# --------------------------------------------------------------
|
||||
# Project name, used for binaries
|
||||
|
||||
NAME = Cardinal
|
||||
|
||||
# --------------------------------------------------------------
|
||||
# Files to build (DPF stuff)
|
||||
|
||||
FILES_DSP = \
|
||||
CardinalPlugin.cpp
|
||||
|
||||
FILES_UI = \
|
||||
CardinalUI.cpp \
|
||||
dep.cpp \
|
||||
Window.cpp
|
||||
|
||||
# --------------------------------------------------------------
|
||||
# Import base definitions
|
||||
|
||||
USE_NANOVG_FBO = true
|
||||
USE_RGBA = true
|
||||
include ../dpf/Makefile.base.mk
|
||||
|
||||
# --------------------------------------------------------------
|
||||
# Files to build (VCV stuff)
|
||||
|
||||
FILES_DSP += Rack/dep/pffft/pffft.c
|
||||
FILES_DSP += Rack/dep/pffft/fftpack.c
|
||||
|
||||
FILES_UI += Rack/dep/oui-blendish/blendish.c
|
||||
|
||||
# FIXME dont use this
|
||||
FILES_UI += Rack/dep/osdialog/osdialog.c
|
||||
ifeq ($(MACOS),true)
|
||||
FILES_UI += Rack/dep/osdialog/osdialog_mac.m
|
||||
else ifeq ($(WINDOWS),true)
|
||||
FILES_UI += Rack/dep/osdialog/osdialog_win.c
|
||||
else
|
||||
FILES_UI += Rack/dep/osdialog/osdialog_zenity.c
|
||||
endif
|
||||
|
||||
FILES_DSP += $(wildcard Rack/src/*.c)
|
||||
FILES_DSP += $(wildcard Rack/src/*/*.c)
|
||||
FILES_DSP += $(filter-out Rack/src/dep.cpp Rack/src/discord.cpp Rack/src/gamepad.cpp Rack/src/keyboard.cpp Rack/src/library.cpp Rack/src/network.cpp Rack/src/rtaudio.cpp Rack/src/rtmidi.cpp, $(wildcard Rack/src/*.cpp))
|
||||
FILES_DSP += $(filter-out Rack/src/window/Window.cpp, $(wildcard Rack/src/*/*.cpp))
|
||||
|
||||
# --------------------------------------------------------------
|
||||
# Extra libraries to link against
|
||||
|
||||
EXTRA_LIBS = ../plugins/plugins.a
|
||||
EXTRA_LIBS += Rack/dep/lib/libjansson.a
|
||||
EXTRA_LIBS += Rack/dep/lib/libsamplerate.a
|
||||
EXTRA_LIBS += Rack/dep/lib/libspeexdsp.a
|
||||
ifeq ($(WINDOWS),true)
|
||||
EXTRA_LIBS += Rack/dep/lib/libarchive_static.a
|
||||
else
|
||||
EXTRA_LIBS += Rack/dep/lib/libarchive.a
|
||||
endif
|
||||
EXTRA_LIBS += Rack/dep/lib/libzstd.a
|
||||
|
||||
# --------------------------------------------------------------
|
||||
# Do some magic
|
||||
|
||||
DPF_PATH = ../dpf
|
||||
DPF_TARGET_DIR = ../bin
|
||||
include ../dpf/Makefile.plugins.mk
|
||||
|
||||
# --------------------------------------------------------------
|
||||
# Extra flags for VCV stuff
|
||||
|
||||
ifeq ($(MACOS),true)
|
||||
BASE_FLAGS += -DARCH_MAC
|
||||
else ifeq ($(WINDOWS),true)
|
||||
BASE_FLAGS += -DARCH_WIN
|
||||
else
|
||||
BASE_FLAGS += -DARCH_LIN
|
||||
endif
|
||||
|
||||
BASE_FLAGS += -D_APP_VERSION=Cardinal
|
||||
BASE_FLAGS += -I../dpf/dgl/src/nanovg
|
||||
BASE_FLAGS += -IRack/include
|
||||
BASE_FLAGS += -IRack/dep/include
|
||||
BASE_FLAGS += -IRack/dep/filesystem/include
|
||||
BASE_FLAGS += -IRack/dep/fuzzysearchdatabase/src
|
||||
BASE_FLAGS += -IRack/dep/glfw/include
|
||||
BASE_FLAGS += -IRack/dep/nanosvg/src
|
||||
BASE_FLAGS += -IRack/dep/osdialog
|
||||
BASE_FLAGS += -IRack/dep/oui-blendish
|
||||
BASE_FLAGS += -IRack/dep/pffft
|
||||
BASE_FLAGS += -Ineon-compat
|
||||
BASE_FLAGS += -pthread
|
||||
|
||||
ifeq ($(WINDOWS),true)
|
||||
BASE_FLAGS += -Imingw-compat
|
||||
BASE_FLAGS += -Imingw-std-threads
|
||||
endif
|
||||
|
||||
BUILD_C_FLAGS += -std=gnu11
|
||||
|
||||
# --------------------------------------------------------------
|
||||
# FIXME lots of warnings from VCV side
|
||||
|
||||
BASE_FLAGS += -Wno-unused-parameter
|
||||
BASE_FLAGS += -Wno-unused-variable
|
||||
|
||||
# --------------------------------------------------------------
|
||||
# extra linker flags
|
||||
|
||||
ifneq ($(HAIKU_OR_MACOS_OR_WINDOWS),true)
|
||||
LINK_FLAGS += -ldl
|
||||
endif
|
||||
|
||||
ifeq ($(MACOS),true)
|
||||
LINK_FLAGS += -framework IOKit
|
||||
else ifeq ($(WINDOWS),true)
|
||||
LINK_FLAGS += -ldbghelp -lshlwapi
|
||||
endif
|
||||
|
||||
# --------------------------------------------------------------
|
||||
# temporary macro just to get the ball rolling
|
||||
|
||||
ifeq ($(EXE_WRAPPER),wine)
|
||||
SOURCE_DIR = Z:$(subst /,\\,$(CURDIR))
|
||||
else
|
||||
SOURCE_DIR = $(CURDIR)
|
||||
endif
|
||||
|
||||
BUILD_CXX_FLAGS += -DCARDINAL_PLUGIN_SOURCE_DIR='"$(SOURCE_DIR)"'
|
||||
|
||||
# --------------------------------------------------------------
|
||||
# Enable all possible plugin types
|
||||
|
||||
all: jack lv2 vst2 vst3
|
||||
|
||||
# --------------------------------------------------------------
|
1
src/Rack
Submodule
1
src/Rack
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 420e781fa7bfdcf47163ab1fa976c171c91cb92b
|
185
src/ResizeHandle.hpp
Normal file
185
src/ResizeHandle.hpp
Normal file
|
@ -0,0 +1,185 @@
|
|||
/*
|
||||
* Resize handle for DPF
|
||||
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any purpose with
|
||||
* or without fee is hereby granted, provided that the above copyright notice and this
|
||||
* permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
|
||||
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
|
||||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "TopLevelWidget.hpp"
|
||||
#include "../dgl/Color.hpp"
|
||||
|
||||
START_NAMESPACE_DGL
|
||||
|
||||
/** Resize handle for DPF windows, will sit on bottom-right. */
|
||||
class ResizeHandle : public TopLevelWidget
|
||||
{
|
||||
public:
|
||||
/** Constructor for placing this handle on top of a window. */
|
||||
explicit ResizeHandle(Window& window)
|
||||
: TopLevelWidget(window),
|
||||
handleSize(16),
|
||||
resizing(false)
|
||||
{
|
||||
resetArea();
|
||||
}
|
||||
|
||||
/** Overloaded constructor, will fetch the window from an existing top-level widget. */
|
||||
explicit ResizeHandle(TopLevelWidget* const tlw)
|
||||
: TopLevelWidget(tlw->getWindow()),
|
||||
handleSize(16),
|
||||
resizing(false)
|
||||
{
|
||||
resetArea();
|
||||
}
|
||||
|
||||
/** Set the handle size, minimum 16. */
|
||||
void setHandleSize(const uint size)
|
||||
{
|
||||
handleSize = std::max(16u, size);
|
||||
resetArea();
|
||||
}
|
||||
|
||||
protected:
|
||||
void onDisplay() override
|
||||
{
|
||||
const GraphicsContext& context(getGraphicsContext());
|
||||
const double lineWidth = 1.0 * getScaleFactor();
|
||||
|
||||
#ifdef DGL_OPENGL
|
||||
// glUseProgram(0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
#endif
|
||||
|
||||
// draw white lines, 1px wide
|
||||
Color(1.0f, 1.0f, 1.0f).setFor(context);
|
||||
l1.draw(context, lineWidth);
|
||||
l2.draw(context, lineWidth);
|
||||
l3.draw(context, lineWidth);
|
||||
|
||||
// draw black lines, offset by 1px and 1px wide
|
||||
Color(0.0f, 0.0f, 0.0f).setFor(context);
|
||||
Line<double> l1b(l1), l2b(l2), l3b(l3);
|
||||
l1b.moveBy(lineWidth, lineWidth);
|
||||
l2b.moveBy(lineWidth, lineWidth);
|
||||
l3b.moveBy(lineWidth, lineWidth);
|
||||
l1b.draw(context, lineWidth);
|
||||
l2b.draw(context, lineWidth);
|
||||
l3b.draw(context, lineWidth);
|
||||
}
|
||||
|
||||
bool onMouse(const MouseEvent& ev) override
|
||||
{
|
||||
if (ev.button != 1)
|
||||
return false;
|
||||
|
||||
if (ev.press && area.contains(ev.pos))
|
||||
{
|
||||
resizing = true;
|
||||
resizingSize = Size<double>(getWidth(), getHeight());
|
||||
lastResizePoint = ev.pos;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (resizing && ! ev.press)
|
||||
{
|
||||
resizing = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool onMotion(const MotionEvent& ev) override
|
||||
{
|
||||
if (! resizing)
|
||||
return false;
|
||||
|
||||
const Size<double> offset(ev.pos.getX() - lastResizePoint.getX(),
|
||||
ev.pos.getY() - lastResizePoint.getY());
|
||||
|
||||
resizingSize += offset;
|
||||
lastResizePoint = ev.pos;
|
||||
|
||||
// TODO min width, min height
|
||||
const uint minWidth = 16;
|
||||
const uint minHeight = 16;
|
||||
|
||||
if (resizingSize.getWidth() < minWidth)
|
||||
resizingSize.setWidth(minWidth);
|
||||
if (resizingSize.getWidth() > 16384)
|
||||
resizingSize.setWidth(16384);
|
||||
if (resizingSize.getHeight() < minHeight)
|
||||
resizingSize.setHeight(minHeight);
|
||||
if (resizingSize.getHeight() > 16384)
|
||||
resizingSize.setHeight(16384);
|
||||
|
||||
setSize(resizingSize.getWidth(), resizingSize.getHeight());
|
||||
return true;
|
||||
}
|
||||
|
||||
void onResize(const ResizeEvent& ev) override
|
||||
{
|
||||
TopLevelWidget::onResize(ev);
|
||||
resetArea();
|
||||
}
|
||||
|
||||
private:
|
||||
Rectangle<uint> area;
|
||||
Line<double> l1, l2, l3;
|
||||
uint handleSize;
|
||||
|
||||
// event handling state
|
||||
bool resizing;
|
||||
Point<double> lastResizePoint;
|
||||
Size<double> resizingSize;
|
||||
|
||||
void resetArea()
|
||||
{
|
||||
const double scaleFactor = getScaleFactor();
|
||||
const uint margin = 0.0 * scaleFactor;
|
||||
const uint size = handleSize * scaleFactor;
|
||||
|
||||
area = Rectangle<uint>(getWidth() - size - margin,
|
||||
getHeight() - size - margin,
|
||||
size, size);
|
||||
|
||||
recreateLines(area.getX(), area.getY(), size);
|
||||
}
|
||||
|
||||
void recreateLines(const uint x, const uint y, const uint size)
|
||||
{
|
||||
uint linesize = size;
|
||||
uint offset = 0;
|
||||
|
||||
// 1st line, full diagonal size
|
||||
l1.setStartPos(x + size, y);
|
||||
l1.setEndPos(x, y + size);
|
||||
|
||||
// 2nd line, bit more to the right and down, cropped
|
||||
offset += size / 3;
|
||||
linesize -= size / 3;
|
||||
l2.setStartPos(x + linesize + offset, y + offset);
|
||||
l2.setEndPos(x + offset, y + linesize + offset);
|
||||
|
||||
// 3rd line, even more right and down
|
||||
offset += size / 3;
|
||||
linesize -= size / 3;
|
||||
l3.setStartPos(x + linesize + offset, y + offset);
|
||||
l3.setEndPos(x + offset, y + linesize + offset);
|
||||
}
|
||||
|
||||
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ResizeHandle)
|
||||
};
|
||||
|
||||
END_NAMESPACE_DGL
|
427
src/Window.cpp
Normal file
427
src/Window.cpp
Normal file
|
@ -0,0 +1,427 @@
|
|||
#include <map>
|
||||
#include <queue>
|
||||
#include <thread>
|
||||
|
||||
#include <osdialog.h>
|
||||
|
||||
#include <window/Window.hpp>
|
||||
#include <asset.hpp>
|
||||
#include <widget/Widget.hpp>
|
||||
#include <app/Scene.hpp>
|
||||
#include <context.hpp>
|
||||
#include <patch.hpp>
|
||||
#include <settings.hpp>
|
||||
#include <plugin.hpp> // used in Window::screenshot
|
||||
#include <system.hpp> // used in Window::screenshot
|
||||
|
||||
#ifdef NDEBUG
|
||||
# undef DEBUG
|
||||
#endif
|
||||
|
||||
#include "DistrhoUI.hpp"
|
||||
|
||||
namespace rack {
|
||||
namespace window {
|
||||
|
||||
extern DISTRHO_NAMESPACE::UI* lastUI;
|
||||
|
||||
static const math::Vec minWindowSize = math::Vec(640, 480);
|
||||
|
||||
|
||||
void Font::loadFile(const std::string& filename, NVGcontext* vg) {
|
||||
this->vg = vg;
|
||||
handle = nvgCreateFont(vg, filename.c_str(), filename.c_str());
|
||||
if (handle < 0)
|
||||
throw Exception("Failed to load font %s", filename.c_str());
|
||||
INFO("Loaded font %s", filename.c_str());
|
||||
}
|
||||
|
||||
|
||||
Font::~Font() {
|
||||
// There is no NanoVG deleteFont() function yet, so do nothing
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<Font> Font::load(const std::string& filename) {
|
||||
return APP->window->loadFont(filename);
|
||||
}
|
||||
|
||||
|
||||
void Image::loadFile(const std::string& filename, NVGcontext* vg) {
|
||||
this->vg = vg;
|
||||
handle = nvgCreateImage(vg, filename.c_str(), NVG_IMAGE_REPEATX | NVG_IMAGE_REPEATY);
|
||||
if (handle <= 0)
|
||||
throw Exception("Failed to load image %s", filename.c_str());
|
||||
INFO("Loaded image %s", filename.c_str());
|
||||
}
|
||||
|
||||
|
||||
Image::~Image() {
|
||||
// TODO What if handle is invalid?
|
||||
if (handle >= 0)
|
||||
nvgDeleteImage(vg, handle);
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<Image> Image::load(const std::string& filename) {
|
||||
return APP->window->loadImage(filename);
|
||||
}
|
||||
|
||||
|
||||
struct Window::Internal {
|
||||
DISTRHO_NAMESPACE::UI* ui;
|
||||
math::Vec size;
|
||||
|
||||
std::string lastWindowTitle;
|
||||
|
||||
int frame = 0;
|
||||
bool ignoreNextMouseDelta = false;
|
||||
int frameSwapInterval = 1;
|
||||
double monitorRefreshRate = 60.0; // FIXME
|
||||
double frameTime = 0.0;
|
||||
double lastFrameDuration = 0.0;
|
||||
|
||||
math::Vec lastMousePos;
|
||||
|
||||
std::map<std::string, std::shared_ptr<Font>> fontCache;
|
||||
std::map<std::string, std::shared_ptr<Image>> imageCache;
|
||||
|
||||
bool fbDirtyOnSubpixelChange = true;
|
||||
};
|
||||
|
||||
Window::Window() {
|
||||
internal = new Internal;
|
||||
internal->ui = lastUI;
|
||||
internal->size = minWindowSize;
|
||||
|
||||
int err;
|
||||
|
||||
const GLubyte* vendor = glGetString(GL_VENDOR);
|
||||
const GLubyte* renderer = glGetString(GL_RENDERER);
|
||||
const GLubyte* version = glGetString(GL_VERSION);
|
||||
INFO("Renderer: %s %s", vendor, renderer);
|
||||
INFO("OpenGL: %s", version);
|
||||
INFO("UI pointer: %p", lastUI);
|
||||
|
||||
vg = lastUI->getContext();
|
||||
fbVg = nvgCreateSharedGL2(vg, NVG_ANTIALIAS);
|
||||
|
||||
// Load default Blendish font
|
||||
uiFont = loadFont(asset::system("res/fonts/DejaVuSans.ttf"));
|
||||
bndSetFont(uiFont->handle);
|
||||
|
||||
if (APP->scene) {
|
||||
widget::Widget::ContextCreateEvent e;
|
||||
APP->scene->onContextCreate(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Window::~Window() {
|
||||
if (APP->scene) {
|
||||
widget::Widget::ContextDestroyEvent e;
|
||||
APP->scene->onContextDestroy(e);
|
||||
}
|
||||
|
||||
// Fonts and Images in the cache must be deleted before the NanoVG context is deleted
|
||||
internal->fontCache.clear();
|
||||
internal->imageCache.clear();
|
||||
|
||||
delete internal;
|
||||
}
|
||||
|
||||
|
||||
math::Vec Window::getSize() {
|
||||
return internal->size;
|
||||
}
|
||||
|
||||
|
||||
void Window::setSize(math::Vec size) {
|
||||
internal->size = size.max(minWindowSize);
|
||||
}
|
||||
|
||||
|
||||
void Window::run() {
|
||||
internal->frame = 0;
|
||||
}
|
||||
|
||||
|
||||
void Window::step() {
|
||||
double frameTime = system::getTime();
|
||||
double lastFrameTime = internal->frameTime;
|
||||
internal->frameTime = frameTime;
|
||||
internal->lastFrameDuration = frameTime - lastFrameTime;
|
||||
// DEBUG("%.2lf Hz", 1.0 / internal->lastFrameDuration);
|
||||
double t1 = 0.0, t2 = 0.0, t3 = 0.0, t4 = 0.0, t5 = 0.0;
|
||||
|
||||
// Make event handlers and step() have a clean NanoVG context
|
||||
// nvgReset(vg);
|
||||
|
||||
bndSetFont(uiFont->handle);
|
||||
|
||||
// Poll events
|
||||
// Save and restore context because event handler set their own context based on which window they originate from.
|
||||
// Context* context = contextGet();
|
||||
// glfwPollEvents();
|
||||
// contextSet(context);
|
||||
|
||||
// Set window title
|
||||
std::string windowTitle = APP_NAME + " " + APP_EDITION_NAME + " " + APP_VERSION;
|
||||
if (APP->patch->path != "") {
|
||||
windowTitle += " - ";
|
||||
if (!APP->history->isSaved())
|
||||
windowTitle += "*";
|
||||
windowTitle += system::getFilename(APP->patch->path);
|
||||
}
|
||||
if (windowTitle != internal->lastWindowTitle) {
|
||||
internal->ui->getWindow().setTitle(windowTitle.c_str());
|
||||
internal->lastWindowTitle = windowTitle;
|
||||
}
|
||||
|
||||
// Get desired pixel ratio
|
||||
float newPixelRatio = internal->ui->getScaleFactor();
|
||||
if (newPixelRatio != pixelRatio) {
|
||||
pixelRatio = newPixelRatio;
|
||||
APP->event->handleDirty();
|
||||
}
|
||||
|
||||
// Get framebuffer/window ratio
|
||||
int winWidth = internal->ui->getWidth();
|
||||
int winHeight = internal->ui->getHeight();
|
||||
int fbWidth = winWidth;// * newPixelRatio;
|
||||
int fbHeight = winHeight;// * newPixelRatio;
|
||||
windowRatio = (float)fbWidth / winWidth;
|
||||
t1 = system::getTime();
|
||||
|
||||
if (APP->scene) {
|
||||
// DEBUG("%f %f %d %d", pixelRatio, windowRatio, fbWidth, winWidth);
|
||||
// Resize scene
|
||||
APP->scene->box.size = math::Vec(fbWidth, fbHeight).div(pixelRatio);
|
||||
|
||||
// Step scene
|
||||
APP->scene->step();
|
||||
t2 = system::getTime();
|
||||
|
||||
// Render scene
|
||||
bool visible = true;
|
||||
if (visible) {
|
||||
// Update and render
|
||||
// nvgBeginFrame(vg, fbWidth, fbHeight, pixelRatio);
|
||||
nvgScale(vg, pixelRatio, pixelRatio);
|
||||
|
||||
// Draw scene
|
||||
widget::Widget::DrawArgs args;
|
||||
args.vg = vg;
|
||||
args.clipBox = APP->scene->box.zeroPos();
|
||||
APP->scene->draw(args);
|
||||
t3 = system::getTime();
|
||||
|
||||
glViewport(0, 0, fbWidth, fbHeight);
|
||||
glClearColor(0.0, 0.0, 0.0, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
// nvgEndFrame(vg);
|
||||
t4 = system::getTime();
|
||||
}
|
||||
}
|
||||
|
||||
t5 = system::getTime();
|
||||
|
||||
// DEBUG("pre-step %6.1f step %6.1f draw %6.1f nvgEndFrame %6.1f glfwSwapBuffers %6.1f total %6.1f",
|
||||
// (t1 - frameTime) * 1e3f,
|
||||
// (t2 - t1) * 1e3f,
|
||||
// (t3 - t2) * 1e3f,
|
||||
// (t4 - t2) * 1e3f,
|
||||
// (t5 - t4) * 1e3f,
|
||||
// (t5 - frameTime) * 1e3f
|
||||
// );
|
||||
internal->frame++;
|
||||
}
|
||||
|
||||
|
||||
void Window::screenshot(const std::string&) {
|
||||
}
|
||||
|
||||
|
||||
void Window::screenshotModules(const std::string&, float) {
|
||||
}
|
||||
|
||||
|
||||
void Window::close() {
|
||||
internal->ui->getWindow().close();
|
||||
}
|
||||
|
||||
|
||||
void Window::cursorLock() {
|
||||
if (!settings::allowCursorLock)
|
||||
return;
|
||||
|
||||
internal->ignoreNextMouseDelta = true;
|
||||
}
|
||||
|
||||
|
||||
void Window::cursorUnlock() {
|
||||
if (!settings::allowCursorLock)
|
||||
return;
|
||||
|
||||
internal->ignoreNextMouseDelta = true;
|
||||
}
|
||||
|
||||
|
||||
bool Window::isCursorLocked() {
|
||||
return internal->ignoreNextMouseDelta;
|
||||
}
|
||||
|
||||
|
||||
int Window::getMods() {
|
||||
int mods = 0;
|
||||
/*
|
||||
if (glfwGetKey(win, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS || glfwGetKey(win, GLFW_KEY_RIGHT_SHIFT) == GLFW_PRESS)
|
||||
mods |= GLFW_MOD_SHIFT;
|
||||
if (glfwGetKey(win, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS || glfwGetKey(win, GLFW_KEY_RIGHT_CONTROL) == GLFW_PRESS)
|
||||
mods |= GLFW_MOD_CONTROL;
|
||||
if (glfwGetKey(win, GLFW_KEY_LEFT_ALT) == GLFW_PRESS || glfwGetKey(win, GLFW_KEY_RIGHT_ALT) == GLFW_PRESS)
|
||||
mods |= GLFW_MOD_ALT;
|
||||
if (glfwGetKey(win, GLFW_KEY_LEFT_SUPER) == GLFW_PRESS || glfwGetKey(win, GLFW_KEY_RIGHT_SUPER) == GLFW_PRESS)
|
||||
mods |= GLFW_MOD_SUPER;
|
||||
*/
|
||||
return mods;
|
||||
}
|
||||
|
||||
|
||||
void Window::setFullScreen(bool) {
|
||||
}
|
||||
|
||||
|
||||
bool Window::isFullScreen() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
double Window::getMonitorRefreshRate() {
|
||||
return internal->monitorRefreshRate;
|
||||
}
|
||||
|
||||
|
||||
double Window::getFrameTime() {
|
||||
return internal->frameTime;
|
||||
}
|
||||
|
||||
|
||||
double Window::getLastFrameDuration() {
|
||||
return internal->lastFrameDuration;
|
||||
}
|
||||
|
||||
|
||||
double Window::getFrameDurationRemaining() {
|
||||
double frameDurationDesired = internal->frameSwapInterval / internal->monitorRefreshRate;
|
||||
return frameDurationDesired - (system::getTime() - internal->frameTime);
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<Font> Window::loadFont(const std::string& filename) {
|
||||
const auto& pair = internal->fontCache.find(filename);
|
||||
if (pair != internal->fontCache.end())
|
||||
return pair->second;
|
||||
|
||||
// Load font
|
||||
std::shared_ptr<Font> font;
|
||||
try {
|
||||
font = std::make_shared<Font>();
|
||||
font->loadFile(filename, vg);
|
||||
}
|
||||
catch (Exception& e) {
|
||||
WARN("%s", e.what());
|
||||
font = NULL;
|
||||
}
|
||||
internal->fontCache[filename] = font;
|
||||
return font;
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<Image> Window::loadImage(const std::string& filename) {
|
||||
const auto& pair = internal->imageCache.find(filename);
|
||||
if (pair != internal->imageCache.end())
|
||||
return pair->second;
|
||||
|
||||
// Load image
|
||||
std::shared_ptr<Image> image;
|
||||
try {
|
||||
image = std::make_shared<Image>();
|
||||
image->loadFile(filename, vg);
|
||||
}
|
||||
catch (Exception& e) {
|
||||
WARN("%s", e.what());
|
||||
image = NULL;
|
||||
}
|
||||
internal->imageCache[filename] = image;
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
bool& Window::fbDirtyOnSubpixelChange() {
|
||||
return internal->fbDirtyOnSubpixelChange;
|
||||
}
|
||||
|
||||
|
||||
void mouseButtonCallback(Context* ctx, int button, int action, int mods) {
|
||||
/*
|
||||
#if defined ARCH_MAC
|
||||
// Remap Ctrl-left click to right click on Mac
|
||||
if (button == GLFW_MOUSE_BUTTON_LEFT && (mods & RACK_MOD_MASK) == GLFW_MOD_CONTROL) {
|
||||
button = GLFW_MOUSE_BUTTON_RIGHT;
|
||||
mods &= ~GLFW_MOD_CONTROL;
|
||||
}
|
||||
// Remap Ctrl-shift-left click to middle click on Mac
|
||||
if (button == GLFW_MOUSE_BUTTON_LEFT && (mods & RACK_MOD_MASK) == (GLFW_MOD_CONTROL | GLFW_MOD_SHIFT)) {
|
||||
button = GLFW_MOUSE_BUTTON_MIDDLE;
|
||||
mods &= ~(GLFW_MOD_CONTROL | GLFW_MOD_SHIFT);
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
ctx->event->handleButton(ctx->window->internal->lastMousePos, button, action, mods);
|
||||
}
|
||||
|
||||
void cursorPosCallback(Context* ctx, double xpos, double ypos) {
|
||||
math::Vec mousePos = math::Vec(xpos, ypos).div(ctx->window->pixelRatio / ctx->window->windowRatio).round();
|
||||
math::Vec mouseDelta = mousePos.minus(ctx->window->internal->lastMousePos);
|
||||
|
||||
// Workaround for GLFW warping mouse to a different position when the cursor is locked or unlocked.
|
||||
if (ctx->window->internal->ignoreNextMouseDelta) {
|
||||
ctx->window->internal->ignoreNextMouseDelta = false;
|
||||
mouseDelta = math::Vec();
|
||||
}
|
||||
|
||||
ctx->window->internal->lastMousePos = mousePos;
|
||||
|
||||
ctx->event->handleHover(mousePos, mouseDelta);
|
||||
}
|
||||
|
||||
void cursorEnterCallback(Context* ctx, int entered) {
|
||||
if (!entered) {
|
||||
ctx->event->handleLeave();
|
||||
}
|
||||
}
|
||||
|
||||
void scrollCallback(Context* ctx, double x, double y) {
|
||||
math::Vec scrollDelta = math::Vec(x, y);
|
||||
#if defined ARCH_MAC
|
||||
scrollDelta = scrollDelta.mult(10.0);
|
||||
#else
|
||||
scrollDelta = scrollDelta.mult(50.0);
|
||||
#endif
|
||||
|
||||
ctx->event->handleScroll(ctx->window->internal->lastMousePos, scrollDelta);
|
||||
}
|
||||
|
||||
void charCallback(Context* ctx, unsigned int codepoint) {
|
||||
ctx->event->handleText(ctx->window->internal->lastMousePos, codepoint);
|
||||
}
|
||||
|
||||
void keyCallback(Context* ctx, int key, int scancode, int action, int mods) {
|
||||
ctx->event->handleKey(ctx->window->internal->lastMousePos, key, scancode, action, mods);
|
||||
}
|
||||
|
||||
|
||||
} // namespace window
|
||||
} // namespace rack
|
53
src/dep.cpp
Normal file
53
src/dep.cpp
Normal file
|
@ -0,0 +1,53 @@
|
|||
// This source file compiles those nice implementation-in-header little libraries
|
||||
|
||||
#include <common.hpp> // for fopen_u8
|
||||
|
||||
#ifdef NDEBUG
|
||||
# undef DEBUG
|
||||
#endif
|
||||
#include "OpenGL.hpp"
|
||||
|
||||
#ifdef DEBUG
|
||||
// fix blendish build, missing symbol in debug mode
|
||||
extern "C" {
|
||||
float bnd_clamp(float v, float mn, float mx) {
|
||||
return (v > mx)?mx:(v < mn)?mn:v;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#define NANOSVG_IMPLEMENTATION
|
||||
#define NANOSVG_ALL_COLOR_KEYWORDS
|
||||
#include <nanosvg.h>
|
||||
|
||||
#include <library.hpp>
|
||||
#include <network.hpp>
|
||||
|
||||
namespace rack {
|
||||
namespace library {
|
||||
std::string appChangelogUrl;
|
||||
std::string appDownloadUrl;
|
||||
std::string appVersion;
|
||||
std::string loginStatus;
|
||||
std::map<std::string, UpdateInfo> updateInfos;
|
||||
std::string updateStatus;
|
||||
std::string updateSlug;
|
||||
float updateProgress = 0.f;
|
||||
bool isSyncing = false;
|
||||
bool restartRequested = false;
|
||||
void checkAppUpdate() {}
|
||||
void checkUpdates() {}
|
||||
bool hasUpdates() { return false; }
|
||||
bool isAppUpdateAvailable() { return false; }
|
||||
bool isLoggedIn() { return false; }
|
||||
void logIn(const std::string&, const std::string&) {}
|
||||
void logOut() {}
|
||||
void syncUpdate(const std::string&) {}
|
||||
void syncUpdates() {}
|
||||
}
|
||||
namespace network {
|
||||
std::string encodeUrl(const std::string&) { return {}; }
|
||||
json_t* requestJson(Method, const std::string&, json_t*, const CookieMap&) { return nullptr; }
|
||||
bool requestDownload(const std::string&, const std::string&, float*, const CookieMap&) { return false; }
|
||||
}
|
||||
}
|
18
src/mingw-compat/Shlobj.h
Normal file
18
src/mingw-compat/Shlobj.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* DISTRHO Cardinal Plugin
|
||||
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 3 of
|
||||
* the License, or any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* For a full copy of the GNU General Public License see the LICENSE file.
|
||||
*/
|
||||
|
||||
#include <shlobj.h>
|
18
src/mingw-compat/Shlwapi.h
Normal file
18
src/mingw-compat/Shlwapi.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* DISTRHO Cardinal Plugin
|
||||
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 3 of
|
||||
* the License, or any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* For a full copy of the GNU General Public License see the LICENSE file.
|
||||
*/
|
||||
|
||||
#include <shlwapi.h>
|
18
src/mingw-compat/Windows.h
Normal file
18
src/mingw-compat/Windows.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* DISTRHO Cardinal Plugin
|
||||
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 3 of
|
||||
* the License, or any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* For a full copy of the GNU General Public License see the LICENSE file.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
20
src/mingw-compat/condition_variable
Normal file
20
src/mingw-compat/condition_variable
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* DISTRHO Cardinal Plugin
|
||||
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 3 of
|
||||
* the License, or any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* For a full copy of the GNU General Public License see the LICENSE file.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include_next <condition_variable>
|
||||
#include "mingw.condition_variable.h"
|
20
src/mingw-compat/mutex
Normal file
20
src/mingw-compat/mutex
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* DISTRHO Cardinal Plugin
|
||||
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 3 of
|
||||
* the License, or any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* For a full copy of the GNU General Public License see the LICENSE file.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include_next <mutex>
|
||||
#include "mingw.mutex.h"
|
20
src/mingw-compat/thread
Normal file
20
src/mingw-compat/thread
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* DISTRHO Cardinal Plugin
|
||||
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 3 of
|
||||
* the License, or any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* For a full copy of the GNU General Public License see the LICENSE file.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include_next <thread>
|
||||
#include "mingw.thread.h"
|
1
src/mingw-std-threads
Submodule
1
src/mingw-std-threads
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit f6365f900fb9b1cd6014c8d1cf13ceacf8faf3de
|
37
src/neon-compat/pmmintrin.h
Normal file
37
src/neon-compat/pmmintrin.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* DISTRHO Cardinal Plugin
|
||||
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 3 of
|
||||
* the License, or any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* For a full copy of the GNU General Public License see the LICENSE file.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
# include_next <pmmintrin.h>
|
||||
#else
|
||||
# include "../sse2neon/sse2neon.h"
|
||||
|
||||
static inline
|
||||
void __builtin_ia32_pause()
|
||||
{
|
||||
__asm__ __volatile__("isb\n");
|
||||
}
|
||||
|
||||
static inline
|
||||
uint32_t _mm_getcsr()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
1
src/sse2neon
Submodule
1
src/sse2neon
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit be721a98e7829ce5824a53da78d8210c024ba6c0
|
Loading…
Add table
Add a link
Reference in a new issue