Skip to content

Commit

Permalink
Update included DPF
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <falktx@falktx.com>
  • Loading branch information
falkTX committed Jul 25, 2022
1 parent d7d94ec commit 33ef884
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 54 deletions.
2 changes: 1 addition & 1 deletion data/update-dpf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ rm ${CARLA_DIR}/source/modules/dgl/src/pugl-upstream/include/pugl/vulkan.h

rm ${CARLA_DIR}/source/modules/distrho/DistrhoInfo.hpp
rm ${CARLA_DIR}/source/modules/distrho/src/DistrhoPlugin{JACK,LADSPA+DSSI,LV2,LV2export,VST2,VST3}.cpp
rm ${CARLA_DIR}/source/modules/distrho/src/DistrhoPluginVST3.hpp
rm ${CARLA_DIR}/source/modules/distrho/src/DistrhoPluginVST.hpp
rm ${CARLA_DIR}/source/modules/distrho/src/DistrhoUI{DSSI,LV2,VST3}.cpp
rm ${CARLA_DIR}/source/modules/distrho/DistrhoStandaloneUtils.hpp

Expand Down
30 changes: 18 additions & 12 deletions source/modules/dgl/src/NanoVG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ DGL_EXT(PFNGLUSEPROGRAMPROC, glUseProgram)
DGL_EXT(PFNGLVERTEXATTRIBPOINTERPROC, glVertexAttribPointer)
DGL_EXT(PFNGLBLENDFUNCSEPARATEPROC, glBlendFuncSeparate)
# ifdef DGL_USE_NANOVG_FBO
DGL_EXT(PFNGLCHECKFRAMEBUFFERSTATUSPROC, glCheckFramebufferStatus)
DGL_EXT(PFNGLBINDFRAMEBUFFERPROC, glBindFramebuffer)
DGL_EXT(PFNGLBINDRENDERBUFFERPROC, glBindRenderbuffer)
DGL_EXT(PFNGLCHECKFRAMEBUFFERSTATUSPROC, glCheckFramebufferStatus)
DGL_EXT(PFNGLDELETEFRAMEBUFFERSPROC, glDeleteFramebuffers)
DGL_EXT(PFNGLDELETERENDERBUFFERSPROC, glDeleteRenderbuffers)
DGL_EXT(PFNGLFRAMEBUFFERTEXTURE2DPROC, glFramebufferTexture2D)
Expand Down Expand Up @@ -140,6 +140,11 @@ NVGcontext* nvgCreateGL(int flags)
# define DGL_EXT(PROC, func) \
if (needsInit) func = (PROC) wglGetProcAddress ( #func ); \
DISTRHO_SAFE_ASSERT_RETURN(func != nullptr, nullptr);
# define DGL_EXT2(PROC, func, fallback) \
if (needsInit) { \
func = (PROC) wglGetProcAddress ( #func ); \
if (func == nullptr) func = (PROC) wglGetProcAddress ( #fallback ); \
} DISTRHO_SAFE_ASSERT_RETURN(func != nullptr, nullptr);
DGL_EXT(PFNGLACTIVETEXTUREPROC, glActiveTexture)
DGL_EXT(PFNGLATTACHSHADERPROC, glAttachShader)
DGL_EXT(PFNGLBINDATTRIBLOCATIONPROC, glBindAttribLocation)
Expand Down Expand Up @@ -169,16 +174,16 @@ DGL_EXT(PFNGLUSEPROGRAMPROC, glUseProgram)
DGL_EXT(PFNGLVERTEXATTRIBPOINTERPROC, glVertexAttribPointer)
DGL_EXT(PFNGLBLENDFUNCSEPARATEPROC, glBlendFuncSeparate)
# ifdef DGL_USE_NANOVG_FBO
DGL_EXT(PFNGLBINDFRAMEBUFFERPROC, glBindFramebuffer)
DGL_EXT(PFNGLBINDRENDERBUFFERPROC, glBindRenderbuffer)
DGL_EXT(PFNGLCHECKFRAMEBUFFERSTATUSPROC, glCheckFramebufferStatus)
DGL_EXT(PFNGLDELETEFRAMEBUFFERSPROC, glDeleteFramebuffers)
DGL_EXT(PFNGLDELETERENDERBUFFERSPROC, glDeleteRenderbuffers)
DGL_EXT(PFNGLFRAMEBUFFERTEXTURE2DPROC, glFramebufferTexture2D)
DGL_EXT(PFNGLFRAMEBUFFERRENDERBUFFERPROC, glFramebufferRenderbuffer)
DGL_EXT(PFNGLGENFRAMEBUFFERSPROC, glGenFramebuffers)
DGL_EXT(PFNGLGENRENDERBUFFERSPROC, glGenRenderbuffers)
DGL_EXT(PFNGLRENDERBUFFERSTORAGEPROC, glRenderbufferStorage)
DGL_EXT2(PFNGLBINDFRAMEBUFFERPROC, glBindFramebuffer, glBindFramebufferEXT)
DGL_EXT2(PFNGLBINDRENDERBUFFERPROC, glBindRenderbuffer, glBindRenderbufferEXT)
DGL_EXT2(PFNGLDELETEFRAMEBUFFERSPROC, glDeleteFramebuffers, glDeleteFramebuffersEXT)
DGL_EXT2(PFNGLDELETERENDERBUFFERSPROC, glDeleteRenderbuffers, glDeleteRenderbuffersEXT)
DGL_EXT2(PFNGLFRAMEBUFFERTEXTURE2DPROC, glFramebufferTexture2D, glFramebufferTexture2DEXT)
DGL_EXT2(PFNGLFRAMEBUFFERRENDERBUFFERPROC, glFramebufferRenderbuffer, glFramebufferRenderbufferEXT)
DGL_EXT2(PFNGLGENFRAMEBUFFERSPROC, glGenFramebuffers, glGenFramebuffersEXT)
DGL_EXT2(PFNGLGENRENDERBUFFERSPROC, glGenRenderbuffers, glGenRenderbuffersEXT)
DGL_EXT2(PFNGLRENDERBUFFERSTORAGEPROC, glRenderbufferStorage, glRenderbufferStorageEXT)
# endif
# ifdef DGL_USE_OPENGL3
DGL_EXT(PFNGLBINDBUFFERRANGEPROC, glBindBufferRange)
Expand All @@ -190,6 +195,7 @@ DGL_EXT(PFNGLGENVERTEXARRAYSPROC, glGenVertexArrays)
DGL_EXT(PFNGLUNIFORMBLOCKBINDINGPROC, glUniformBlockBinding)
# endif
# undef DGL_EXT
# undef DGL_EXT2
needsInit = false;
# if defined(__GNUC__) && (__GNUC__ >= 9)
# pragma GCC diagnostic pop
Expand Down Expand Up @@ -318,12 +324,12 @@ NanoVG::NanoVG(int flags)
fInFrame(false),
fIsSubWidget(false)
{
DISTRHO_SAFE_ASSERT(fContext);
DISTRHO_CUSTOM_SAFE_ASSERT("Failed to create NanoVG context, expect a black screen", fContext != nullptr);
}

NanoVG::~NanoVG()
{
DISTRHO_SAFE_ASSERT(! fInFrame);
DISTRHO_CUSTOM_SAFE_ASSERT("Destroying NanoVG context with still active frame", ! fInFrame);

if (fContext != nullptr && ! fIsSubWidget)
nvgDeleteGL(fContext);
Expand Down
6 changes: 3 additions & 3 deletions source/modules/dgl/src/pugl-upstream/src/x11.c
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ puglGrabFocus(PuglView* const view)
{
PuglInternals* const impl = view->impl;
Display* const display = view->world->impl->display;
XWindowAttributes attrs = {0};
XWindowAttributes attrs = PUGL_INIT_STRUCT;

if (!impl->win || !XGetWindowAttributes(display, impl->win, &attrs)) {
return PUGL_UNKNOWN_ERROR;
Expand Down Expand Up @@ -980,7 +980,7 @@ puglRequestAttention(PuglView* const view)
PuglInternals* const impl = view->impl;
Display* const display = view->world->impl->display;
const PuglX11Atoms* const atoms = &view->world->impl->atoms;
XEvent event = {0};
XEvent event = PUGL_INIT_STRUCT;

event.type = ClientMessage;
event.xclient.window = impl->win;
Expand Down Expand Up @@ -1081,7 +1081,7 @@ puglStopTimer(PuglView* const view, const uintptr_t id)
static XEvent
eventToX(PuglView* const view, const PuglEvent* const event)
{
XEvent xev = {0};
XEvent xev = PUGL_INIT_STRUCT;
xev.xany.send_event = True;

switch (event->type) {
Expand Down
3 changes: 3 additions & 0 deletions source/modules/distrho/DistrhoPlugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,9 @@ struct Parameter {
A group can be applied to both inputs and outputs (at the same time).
The same group cannot be used in audio ports and parameters.
When both audio and parameter groups are used, audio groups MUST be defined first.
That is, group indexes start with audio ports, then parameters.
An audio port group logically combines ports which should be considered part of the same stream.@n
For example, two audio ports in a group may form a stereo stream.
Expand Down
34 changes: 32 additions & 2 deletions source/modules/distrho/src/DistrhoPluginInternal.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2022 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
Expand All @@ -20,7 +20,7 @@
#include "../DistrhoPlugin.hpp"

#ifdef DISTRHO_PLUGIN_TARGET_VST3
# include "DistrhoPluginVST3.hpp"
# include "DistrhoPluginVST.hpp"
#endif

#include <set>
Expand Down Expand Up @@ -523,6 +523,36 @@ class PluginExporter
{
return getAudioPort(input, index).hints;
}

uint32_t getAudioPortCountWithGroupId(const bool input, const uint32_t groupId) const noexcept
{
DISTRHO_SAFE_ASSERT_RETURN(fData != nullptr, 0);

uint32_t numPorts = 0;

if (input)
{
#if DISTRHO_PLUGIN_NUM_INPUTS > 0
for (uint32_t i=0; i<DISTRHO_PLUGIN_NUM_INPUTS; ++i)
{
if (fData->audioPorts[i].groupId == groupId)
++numPorts;
}
#endif
}
else
{
#if DISTRHO_PLUGIN_NUM_OUTPUTS > 0
for (uint32_t i=0; i<DISTRHO_PLUGIN_NUM_OUTPUTS; ++i)
{
if (fData->audioPorts[i + DISTRHO_PLUGIN_NUM_INPUTS].groupId == groupId)
++numPorts;
}
#endif
}

return numPorts;
}
#endif

uint32_t getParameterCount() const noexcept
Expand Down
53 changes: 18 additions & 35 deletions source/modules/distrho/src/DistrhoUIInternal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,53 +329,36 @@ class UIExporter
}

#if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
bool handlePluginKeyboardVST2(const bool press, const uint key, const uint16_t mods)
bool handlePluginKeyboardVST(const bool press, const bool special, const uint keychar, const uint keycode, const uint16_t mods)
{
DGL_NAMESPACE::Widget::KeyboardEvent ev;
ev.mod = mods;
ev.press = press;
ev.key = key;
using namespace DGL_NAMESPACE;

const bool ret = ui->onKeyboard(ev);

if (! press)
return ret;

DGL_NAMESPACE::Widget::CharacterInputEvent cev;
cev.mod = mods;
cev.character = key;

// if shift modifier is on, convert a-z -> A-Z for character input
if (key >= 'a' && key <= 'z' && (mods & DGL_NAMESPACE::kModifierShift) != 0)
cev.character -= 'a' - 'A';

ui->onCharacterInput(cev);
return ret;
}

bool handlePluginKeyboardVST3(const bool press, const uint keychar, const uint keycode, const uint16_t mods)
{
DGL_NAMESPACE::Widget::KeyboardEvent ev;
Widget::KeyboardEvent ev;
ev.mod = mods;
ev.press = press;
ev.key = keychar;
ev.keycode = keycode;

// keyboard events must always be lowercase
if (ev.key >= 'A' && ev.key <= 'Z')
ev.key += 'a' - 'A'; // A-Z -> a-z

const bool ret = ui->onKeyboard(ev);

if (! press)
return ret;
if (press && !special && (mods & (kModifierControl|kModifierAlt|kModifierSuper)) == 0)
{
Widget::CharacterInputEvent cev;
cev.mod = mods;
cev.character = keychar;
cev.keycode = keycode;

DGL_NAMESPACE::Widget::CharacterInputEvent cev;
cev.mod = mods;
cev.keycode = keycode;
cev.character = keychar;
// if shift modifier is on, convert a-z -> A-Z for character input
if (cev.character >= 'a' && cev.character <= 'z' && (mods & kModifierShift) != 0)
cev.character -= 'a' - 'A';

// if shift modifier is on, convert a-z -> A-Z for character input
if (keychar >= 'a' && keychar <= 'z' && (mods & DGL_NAMESPACE::kModifierShift) != 0)
cev.character -= 'a' - 'A';
ui->onCharacterInput(cev);
}

ui->onCharacterInput(cev);
return ret;
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion source/modules/distrho/src/DistrhoUIPrivateData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "../DistrhoUI.hpp"

#ifdef DISTRHO_PLUGIN_TARGET_VST3
# include "DistrhoPluginVST3.hpp"
# include "DistrhoPluginVST.hpp"
#endif

#if DISTRHO_PLUGIN_HAS_EXTERNAL_UI
Expand Down
15 changes: 15 additions & 0 deletions source/modules/distrho/src/DistrhoUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#endif

#include "../extra/String.hpp"
#include "../DistrhoStandaloneUtils.hpp"

#ifdef DISTRHO_OS_WINDOWS
# include <windows.h>
Expand Down Expand Up @@ -141,6 +142,20 @@ const char* getResourcePath(const char* const bundlePath) noexcept
return nullptr;
}

#ifndef DISTRHO_PLUGIN_TARGET_JACK
// all these are null for non-standalone targets
bool isUsingNativeAudio() noexcept { return false; }
bool supportsAudioInput() { return false; }
bool supportsBufferSizeChanges() { return false; }
bool supportsMIDI() { return false; }
bool isAudioInputEnabled() { return false; }
bool isMIDIEnabled() { return false; }
uint getBufferSize() { return 0; }
bool requestAudioInput() { return false; }
bool requestBufferSizeChange(uint) { return false; }
bool requestMIDI() { return false; }
#endif

// -----------------------------------------------------------------------

END_NAMESPACE_DISTRHO

0 comments on commit 33ef884

Please sign in to comment.