Skip to content

Commit

Permalink
Fix some compiler warnings, fix non-mac/win vst2 export
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <falktx@falktx.com>
  • Loading branch information
falkTX committed Feb 11, 2024
1 parent ce3f6c1 commit 56c106c
Show file tree
Hide file tree
Showing 13 changed files with 133 additions and 75 deletions.
4 changes: 2 additions & 2 deletions dgl/EventHandlers.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2022 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2024 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 Down Expand Up @@ -186,7 +186,7 @@ class SliderEventHandler
struct PrivateData;
PrivateData* const pData;

DISTRHO_LEAK_DETECTOR(SliderEventHandler)
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SliderEventHandler)
};

// --------------------------------------------------------------------------------------------------------------------
Expand Down
14 changes: 7 additions & 7 deletions dgl/src/Cairo.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2023 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2024 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2019-2021 Jean Pierre Cimalando <jp-dev@inbox.ru>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
Expand Down Expand Up @@ -438,9 +438,9 @@ void CairoImage::loadFromMemory(const char* const rdata, const Size<uint>& s, co
for (int w = 0; w < width; ++w)
{
const uchar a = urdata[h*width*4+w*4+3];
newdata[h*width*4+w*4+0] = (urdata[h*width*4+w*4+0] * a) >> 8;
newdata[h*width*4+w*4+1] = (urdata[h*width*4+w*4+1] * a) >> 8;
newdata[h*width*4+w*4+2] = (urdata[h*width*4+w*4+2] * a) >> 8;
newdata[h*width*4+w*4+0] = static_cast<uchar>((urdata[h*width*4+w*4+0] * a) >> 8);
newdata[h*width*4+w*4+1] = static_cast<uchar>((urdata[h*width*4+w*4+1] * a) >> 8);
newdata[h*width*4+w*4+2] = static_cast<uchar>((urdata[h*width*4+w*4+2] * a) >> 8);
newdata[h*width*4+w*4+3] = a;
}
}
Expand All @@ -465,9 +465,9 @@ void CairoImage::loadFromMemory(const char* const rdata, const Size<uint>& s, co
for (int w = 0; w < width; ++w)
{
const uchar a = urdata[h*width*4+w*4+3];
newdata[h*width*4+w*4+0] = (urdata[h*width*4+w*4+2] * a) >> 8;
newdata[h*width*4+w*4+1] = (urdata[h*width*4+w*4+1] * a) >> 8;
newdata[h*width*4+w*4+2] = (urdata[h*width*4+w*4+0] * a) >> 8;
newdata[h*width*4+w*4+0] = static_cast<uchar>((urdata[h*width*4+w*4+2] * a) >> 8);
newdata[h*width*4+w*4+1] = static_cast<uchar>((urdata[h*width*4+w*4+1] * a) >> 8);
newdata[h*width*4+w*4+2] = static_cast<uchar>((urdata[h*width*4+w*4+0] * a) >> 8);
newdata[h*width*4+w*4+3] = a;
}
}
Expand Down
10 changes: 5 additions & 5 deletions dgl/src/EventHandlers.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2022 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2024 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 Down Expand Up @@ -419,7 +419,7 @@ struct KnobEventHandler::PrivateData {
if ((state & kKnobStateDragging) == 0x0)
return false;

float movDiff;
double movDiff;

switch (orientation)
{
Expand All @@ -431,8 +431,8 @@ struct KnobEventHandler::PrivateData {
break;
case Both:
{
const float movDiffX = ev.pos.getX() / scaleFactor - lastX;
const float movDiffY = lastY - ev.pos.getY() / scaleFactor;
const double movDiffX = ev.pos.getX() / scaleFactor - lastX;
const double movDiffY = lastY - ev.pos.getY() / scaleFactor;
movDiff = std::abs(movDiffX) > std::abs(movDiffY) ? movDiffX : movDiffY;
}
break;
Expand All @@ -444,7 +444,7 @@ struct KnobEventHandler::PrivateData {
return true;

const float divisor = (ev.mod & kModifierControl) ? accel * 10.f : accel;
valueTmp += (maximum - minimum) / divisor * movDiff;
valueTmp += (maximum - minimum) / divisor * static_cast<float>(movDiff);

if (usingLog)
valueTmp = logscale(valueTmp);
Expand Down
26 changes: 13 additions & 13 deletions dgl/src/Layout.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2022 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2024 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 Down Expand Up @@ -35,8 +35,8 @@ uint Layout<true>::setAbsolutePos(int x, const int y, const uint padding)
SubWidgetWithSizeHint& s(*it);
maxHeight = std::max(maxHeight, s.widget->getHeight());
s.widget->setAbsolutePos(x, y);
x += s.widget->getWidth();
x += padding;
x += static_cast<int>(s.widget->getWidth());
x += static_cast<int>(padding);
}

return maxHeight;
Expand All @@ -52,8 +52,8 @@ uint Layout<false>::setAbsolutePos(const int x, int y, const uint padding)
SubWidgetWithSizeHint& s(*it);
maxWidth = std::max(maxWidth, s.widget->getWidth());
s.widget->setAbsolutePos(x, y);
y += s.widget->getHeight();
y += padding;
y += static_cast<int>(s.widget->getHeight());
y += static_cast<int>(padding);
}

return maxWidth;
Expand All @@ -78,7 +78,7 @@ void Layout<true>::setSize(const uint width, const uint padding)
}

if (const size_t numWidgets = widgets.size())
nonFixedWidth -= padding * (numWidgets - 1);
nonFixedWidth -= padding * static_cast<uint>(numWidgets - 1);

const uint widthPerWidget = numDynamiclySizedWidgets != 0 ? nonFixedWidth / numDynamiclySizedWidgets : 0;

Expand Down Expand Up @@ -111,7 +111,7 @@ void Layout<false>::setSize(const uint height, const uint padding)
}

if (const size_t numWidgets = widgets.size())
nonFixedHeight -= padding * (numWidgets - 1);
nonFixedHeight -= padding * static_cast<uint>(numWidgets - 1);

const uint heightPerWidget = numDynamiclySizedWidgets != 0 ? nonFixedHeight / numDynamiclySizedWidgets : 0;

Expand All @@ -138,8 +138,8 @@ void HorizontallyStackedVerticalLayout::setAbsolutePos(int x, const int y, const
for (VerticalLayoutIterator it=items.begin(), end=items.end(); it != end; ++it)
{
VerticalLayout* l(*it);
x += l->setAbsolutePos(x, y, padding);
x += padding;
x += static_cast<int>(l->setAbsolutePos(x, y, padding));
x += static_cast<int>(padding);
}
}

Expand All @@ -157,9 +157,9 @@ Size<uint> VerticallyStackedHorizontalLayout::adjustSize(const uint padding)
uint width = 0;
uint height = 0;

for (SubWidgetWithSizeHintIterator it=l->widgets.begin(), end=l->widgets.end(); it != end; ++it)
for (SubWidgetWithSizeHintIterator it2=l->widgets.begin(), end2=l->widgets.end(); it2 != end2; ++it2)
{
SubWidgetWithSizeHint& s(*it);
SubWidgetWithSizeHint& s(*it2);

if (width != 0)
width += padding;
Expand Down Expand Up @@ -191,8 +191,8 @@ void VerticallyStackedHorizontalLayout::setAbsolutePos(const int x, int y, const
for (HorizontalLayoutIterator it=items.begin(), end=items.end(); it != end; ++it)
{
HorizontalLayout* l(*it);
y += l->setAbsolutePos(x, y, padding);
y += padding;
y += static_cast<int>(l->setAbsolutePos(x, y, padding));
y += static_cast<int>(padding);
}
}

Expand Down
22 changes: 11 additions & 11 deletions dgl/src/OpenGL.cpp
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-2024 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 Down Expand Up @@ -691,12 +691,12 @@ void SubWidget::PrivateData::display(const uint width, const uint height, const
const int w = static_cast<int>(self->getWidth());
const int h = static_cast<int>(self->getHeight());

if (viewportScaleFactor != 0.0 && viewportScaleFactor != 1.0)
if (d_isNotZero(viewportScaleFactor) && d_isNotEqual(viewportScaleFactor, 1.0))
{
glViewport(x,
-static_cast<int>(height * viewportScaleFactor - height + absolutePos.getY() + 0.5),
static_cast<int>(width * viewportScaleFactor + 0.5),
static_cast<int>(height * viewportScaleFactor + 0.5));
-d_roundToIntPositive(height * viewportScaleFactor - height + absolutePos.getY()),
d_roundToIntPositive(width * viewportScaleFactor),
d_roundToIntPositive(height * viewportScaleFactor));
}
else
{
Expand All @@ -712,16 +712,16 @@ void SubWidget::PrivateData::display(const uint width, const uint height, const
else
{
// set viewport pos
glViewport(static_cast<int>(absolutePos.getX() * autoScaleFactor + 0.5),
-static_cast<int>(absolutePos.getY() * autoScaleFactor + 0.5),
glViewport(d_roundToIntPositive(absolutePos.getX() * autoScaleFactor),
-d_roundToIntPositive(absolutePos.getY() * autoScaleFactor),
static_cast<int>(width),
static_cast<int>(height));

// then cut the outer bounds
glScissor(static_cast<int>(absolutePos.getX() * autoScaleFactor + 0.5),
static_cast<int>(height - (self->getHeight() + absolutePos.getY()) * autoScaleFactor + 0.5),
static_cast<int>(self->getWidth() * autoScaleFactor + 0.5),
static_cast<int>(self->getHeight() * autoScaleFactor + 0.5));
glScissor(d_roundToIntPositive(absolutePos.getX() * autoScaleFactor),
d_roundToIntPositive(height - (static_cast<int>(self->getHeight()) + absolutePos.getY()) * autoScaleFactor),
d_roundToIntPositive(self->getWidth() * autoScaleFactor),
d_roundToIntPositive(self->getHeight() * autoScaleFactor));

glEnable(GL_SCISSOR_TEST);
needsDisableScissor = true;
Expand Down
4 changes: 2 additions & 2 deletions dgl/src/SubWidget.cpp
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-2024 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 Down Expand Up @@ -71,7 +71,7 @@ Rectangle<uint> SubWidget::getConstrainedAbsoluteArea() const noexcept
const int y = getAbsoluteY();

if (x >= 0 && y >= 0)
return Rectangle<uint>(x, y, getSize());
return Rectangle<uint>(static_cast<uint>(x), static_cast<uint>(y), getSize());

const int xOffset = std::min(0, x);
const int yOffset = std::min(0, y);
Expand Down
24 changes: 12 additions & 12 deletions dgl/src/Window.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2023 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2024 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 Down Expand Up @@ -269,10 +269,10 @@ void Window::setSize(uint width, uint height)
uint minWidth = pData->minWidth;
uint minHeight = pData->minHeight;

if (pData->autoScaling && scaleFactor != 1.0)
if (pData->autoScaling && d_isNotEqual(scaleFactor, 1.0))
{
minWidth *= scaleFactor;
minHeight *= scaleFactor;
minWidth = d_roundToUnsignedInt(minWidth * scaleFactor);
minHeight = d_roundToUnsignedInt(minHeight * scaleFactor);
}

// handle geometry constraints here
Expand All @@ -293,10 +293,10 @@ void Window::setSize(uint width, uint height)
{
// fix width
if (reqRatio > ratio)
width = static_cast<uint>(height * ratio + 0.5);
width = d_roundToUnsignedInt(height * ratio);
// fix height
else
height = static_cast<uint>(static_cast<double>(width) / ratio + 0.5);
height = d_roundToUnsignedInt(static_cast<double>(width) / ratio);
}
}
}
Expand Down Expand Up @@ -430,10 +430,10 @@ void Window::repaint(const Rectangle<uint>& rect) noexcept
{
const double autoScaleFactor = pData->autoScaleFactor;

prect.x *= autoScaleFactor;
prect.y *= autoScaleFactor;
prect.width *= autoScaleFactor;
prect.height *= autoScaleFactor;
prect.x = static_cast<PuglCoord>(prect.x * autoScaleFactor);
prect.y = static_cast<PuglCoord>(prect.y * autoScaleFactor);
prect.width = static_cast<PuglSpan>(prect.width * autoScaleFactor + 0.5);
prect.height = static_cast<PuglSpan>(prect.height * autoScaleFactor + 0.5);
}
puglPostRedisplayRect(pData->view, prect);
}
Expand Down Expand Up @@ -479,8 +479,8 @@ void Window::setGeometryConstraints(uint minimumWidth,

if (automaticallyScale && scaleFactor != 1.0)
{
minimumWidth *= scaleFactor;
minimumHeight *= scaleFactor;
minimumWidth = d_roundToUnsignedInt(minimumWidth * scaleFactor);
minimumHeight = d_roundToUnsignedInt(minimumHeight * scaleFactor);
}

puglSetGeometryConstraints(pData->view, minimumWidth, minimumHeight, keepAspectRatio);
Expand Down
10 changes: 5 additions & 5 deletions dgl/src/WindowPrivateData.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2023 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2024 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 Down Expand Up @@ -270,18 +270,18 @@ void Window::PrivateData::initPre(const uint width, const uint height, const boo

puglSetViewHint(view, PUGL_RESIZABLE, resizable ? PUGL_TRUE : PUGL_FALSE);
puglSetViewHint(view, PUGL_IGNORE_KEY_REPEAT, PUGL_FALSE);
#if DGL_USE_RGBA
#if defined(DGL_USE_RGBA) && DGL_USE_RGBA
puglSetViewHint(view, PUGL_DEPTH_BITS, 24);
#else
#else
puglSetViewHint(view, PUGL_DEPTH_BITS, 16);
#endif
#endif
puglSetViewHint(view, PUGL_STENCIL_BITS, 8);

// PUGL_SAMPLES ??
puglSetEventFunc(view, puglEventCallback);

// setting default size triggers system-level calls, do it last
puglSetSizeHint(view, PUGL_DEFAULT_SIZE, width, height);
puglSetSizeHint(view, PUGL_DEFAULT_SIZE, static_cast<PuglSpan>(width), static_cast<PuglSpan>(height));
}

bool Window::PrivateData::initPost()
Expand Down
17 changes: 12 additions & 5 deletions dgl/src/pugl.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2023 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2024 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 Down Expand Up @@ -181,7 +181,14 @@ START_NAMESPACE_DGL
# include "pugl-upstream/src/win_vulkan.c"
# endif
#elif defined(HAVE_X11)
# if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wsign-conversion"
# endif
# include "pugl-upstream/src/x11.c"
# if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
# pragma GCC diagnostic pop
# endif
# include "pugl-upstream/src/x11_stub.c"
# ifdef DGL_CAIRO
# include "pugl-upstream/src/x11_cairo.c"
Expand Down Expand Up @@ -277,13 +284,13 @@ void puglRaiseWindow(PuglView* const view)

PuglStatus puglSetGeometryConstraints(PuglView* const view, const uint width, const uint height, const bool aspect)
{
view->sizeHints[PUGL_MIN_SIZE].width = width;
view->sizeHints[PUGL_MIN_SIZE].height = height;
view->sizeHints[PUGL_MIN_SIZE].width = static_cast<PuglSpan>(width);
view->sizeHints[PUGL_MIN_SIZE].height = static_cast<PuglSpan>(height);

if (aspect)
{
view->sizeHints[PUGL_FIXED_ASPECT].width = width;
view->sizeHints[PUGL_FIXED_ASPECT].height = height;
view->sizeHints[PUGL_FIXED_ASPECT].width = static_cast<PuglSpan>(width);
view->sizeHints[PUGL_FIXED_ASPECT].height = static_cast<PuglSpan>(height);
}

#if defined(DISTRHO_OS_HAIKU)
Expand Down
Loading

0 comments on commit 56c106c

Please sign in to comment.