Browse Source

rewrite preprocessor conditionals in simplified form

pull/99/head
JP Cimalando Filipe Coelho <falktx@falktx.com> 5 years ago
parent
commit
2795c66b16
11 changed files with 36 additions and 36 deletions
  1. +3
    -3
      dgl/Base.hpp
  2. +2
    -2
      dgl/Color.hpp
  3. +7
    -7
      dgl/Geometry.hpp
  4. +1
    -1
      dgl/Widget.hpp
  5. +1
    -1
      dgl/Window.hpp
  6. +4
    -4
      dgl/src/Color.cpp
  7. +7
    -7
      dgl/src/Geometry.cpp
  8. +1
    -1
      dgl/src/Widget.cpp
  9. +2
    -2
      dgl/src/WidgetPrivateData.hpp
  10. +7
    -7
      dgl/src/Window.cpp
  11. +1
    -1
      distrho/src/DistrhoUI.cpp

+ 3
- 3
dgl/Base.hpp View File

@@ -73,7 +73,7 @@
// -----------------------------------------------------------------------
// OpenGL includes

#if defined(HAVE_DGL)
#ifdef HAVE_DGL

#ifdef DISTRHO_OS_MAC
# include <OpenGL/gl.h>
@@ -90,14 +90,14 @@
// -----------------------------------------------------------------------
// Cairo includes

#if defined(HAVE_DCAIRO)
#ifdef HAVE_DCAIRO
# include <cairo/cairo.h>
#endif

// -----------------------------------------------------------------------
// Missing OpenGL defines

#if defined(HAVE_DGL)
#ifdef HAVE_DGL

#if defined(GL_BGR_EXT) && ! defined(GL_BGR)
# define GL_BGR GL_BGR_EXT


+ 2
- 2
dgl/Color.hpp View File

@@ -19,7 +19,7 @@

#include "Base.hpp"

#if !defined(HAVE_DCAIRO)
#ifndef HAVE_DCAIRO
struct NVGcolor;
#endif

@@ -97,7 +97,7 @@ struct Color {
*/
void fixBounds() noexcept;

#if !defined(HAVE_DCAIRO)
#ifndef HAVE_DCAIRO
/**
@internal
Needed for NanoVG compatibility.


+ 7
- 7
dgl/Geometry.hpp View File

@@ -346,7 +346,7 @@ public:
*/
void moveBy(const Point<T>& pos) noexcept;

#if defined(HAVE_DGL)
#ifdef HAVE_DGL
/**
Draw this line using the current OpenGL state.
*/
@@ -462,7 +462,7 @@ public:
*/
void setNumSegments(const uint num);

#if defined(HAVE_DGL)
#ifdef HAVE_DGL
/**
Draw this circle using the current OpenGL state.
*/
@@ -486,7 +486,7 @@ private:
// cached values
float fTheta, fCos, fSin;

#if defined(HAVE_DGL)
#ifdef HAVE_DGL
void _draw(const bool outline);
#endif
};
@@ -522,7 +522,7 @@ public:
*/
Triangle(const Triangle<T>& tri) noexcept;

#if defined(HAVE_DGL)
#ifdef HAVE_DGL
/**
Draw this triangle using the current OpenGL state.
*/
@@ -564,7 +564,7 @@ public:
private:
Point<T> fPos1, fPos2, fPos3;

#if defined(HAVE_DGL)
#ifdef HAVE_DGL
void _draw(const bool outline);
#endif
};
@@ -730,7 +730,7 @@ public:
*/
bool containsY(const T& y) const noexcept;

#if defined(HAVE_DGL)
#ifdef HAVE_DGL
/**
Draw this rectangle using the current OpenGL state.
*/
@@ -752,7 +752,7 @@ private:
Point<T> fPos;
Size<T> fSize;

#if defined(HAVE_DGL)
#ifdef HAVE_DGL
void _draw(const bool outline);
#endif
};


+ 1
- 1
dgl/Widget.hpp View File

@@ -312,7 +312,7 @@ public:
*/
Window& getParentWindow() const noexcept;

#if defined(HAVE_DCAIRO)
#ifdef HAVE_DCAIRO
cairo_t* getContext() const noexcept;
#endif



+ 1
- 1
dgl/Window.hpp View File

@@ -119,7 +119,7 @@ public:
Application& getApp() const noexcept;
intptr_t getWindowId() const noexcept;

#if defined(HAVE_DCAIRO)
#ifdef HAVE_DCAIRO
cairo_t* getContext() const noexcept;
#endif



+ 4
- 4
dgl/src/Color.cpp View File

@@ -16,7 +16,7 @@

#include "../Color.hpp"

#if !defined(HAVE_DCAIRO)
#ifndef HAVE_DCAIRO
#include "nanovg/nanovg.h"
#endif

@@ -105,7 +105,7 @@ Color::Color(const Color& color1, const Color& color2, float u) noexcept
interpolate(color2, u);
}

#if !defined(HAVE_DGL)
#ifndef HAVE_DGL
static float computeHue(float h, float m1, float m2)
{
if (h < 0) h += 1;
@@ -122,7 +122,7 @@ static float computeHue(float h, float m1, float m2)

Color Color::fromHSL(float hue, float saturation, float lightness, float alpha)
{
#if defined(HAVE_DGL)
#ifdef HAVE_DGL
return nvgHSLA(hue, saturation, lightness, static_cast<uchar>(getFixedRange(alpha)*255.0f));
#else
float m1, m2;
@@ -258,7 +258,7 @@ void Color::fixBounds() noexcept

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

#if !defined(HAVE_DCAIRO)
#ifndef HAVE_DCAIRO
Color::Color(const NVGcolor& c) noexcept
: red(c.r), green(c.g), blue(c.b), alpha(c.a)
{


+ 7
- 7
dgl/src/Geometry.cpp View File

@@ -441,7 +441,7 @@ void Line<T>::moveBy(const Point<T>& pos) noexcept
fPosEnd.moveBy(pos);
}

#if defined(HAVE_DGL)
#ifdef HAVE_DGL
template<typename T>
void Line<T>::draw()
{
@@ -616,7 +616,7 @@ void Circle<T>::setNumSegments(const uint num)
fSin = std::sin(fTheta);
}

#if defined(HAVE_DGL)
#ifdef HAVE_DGL
template<typename T>
void Circle<T>::draw()
{
@@ -654,7 +654,7 @@ bool Circle<T>::operator!=(const Circle<T>& cir) const noexcept
return (fPos != cir.fPos || d_isNotEqual(fSize, cir.fSize) || fNumSegments != cir.fNumSegments);
}

#if defined(HAVE_DGL)
#ifdef HAVE_DGL
template<typename T>
void Circle<T>::_draw(const bool outline)
{
@@ -704,7 +704,7 @@ Triangle<T>::Triangle(const Triangle<T>& tri) noexcept
fPos2(tri.fPos2),
fPos3(tri.fPos3) {}

#if defined(HAVE_DGL)
#ifdef HAVE_DGL
template<typename T>
void Triangle<T>::draw()
{
@@ -763,7 +763,7 @@ bool Triangle<T>::operator!=(const Triangle<T>& tri) const noexcept
return (fPos1 != tri.fPos1 || fPos2 != tri.fPos2 || fPos3 != tri.fPos3);
}

#if defined(HAVE_DGL)
#ifdef HAVE_DGL
template<typename T>
void Triangle<T>::_draw(const bool outline)
{
@@ -962,7 +962,7 @@ bool Rectangle<T>::containsY(const T& y) const noexcept
return (y >= fPos.fY && y <= fPos.fY + fSize.fHeight);
}

#if defined(HAVE_DGL)
#ifdef HAVE_DGL
template<typename T>
void Rectangle<T>::draw()
{
@@ -1010,7 +1010,7 @@ bool Rectangle<T>::operator!=(const Rectangle<T>& rect) const noexcept
return (fPos != rect.fPos || fSize != rect.fSize);
}

#if defined(HAVE_DGL)
#ifdef HAVE_DGL
template<typename T>
void Rectangle<T>::_draw(const bool outline)
{


+ 1
- 1
dgl/src/Widget.cpp View File

@@ -189,7 +189,7 @@ Window& Widget::getParentWindow() const noexcept
return pData->parent;
}

#if defined(HAVE_DCAIRO)
#ifdef HAVE_DCAIRO
cairo_t* Widget::getContext() const noexcept
{
return pData->parent.getContext();


+ 2
- 2
dgl/src/WidgetPrivateData.hpp View File

@@ -68,7 +68,7 @@ struct Widget::PrivateData {
if ((skipDisplay && ! renderingSubWidget) || size.isInvalid() || ! visible)
return;

#if defined(HAVE_DGL)
#ifdef HAVE_DGL
bool needsDisableScissor = false;

// reset color
@@ -112,7 +112,7 @@ struct Widget::PrivateData {
// display widget
self->onDisplay();

#if defined(HAVE_DGL)
#ifdef HAVE_DGL
if (needsDisableScissor)
{
glDisable(GL_SCISSOR_TEST);


+ 7
- 7
dgl/src/Window.cpp View File

@@ -22,10 +22,10 @@
#undef PUGL_HAVE_CAIRO
#undef PUGL_HAVE_GL

#if defined(HAVE_DGL)
#ifdef HAVE_DGL
#define PUGL_HAVE_GL 1
#endif
#if defined(HAVE_DCAIRO)
#ifdef HAVE_DCAIRO
#define PUGL_HAVE_CAIRO 1
#endif

@@ -213,10 +213,10 @@ struct Window::PrivateData {
return;
}

#if defined(HAVE_DGL)
#ifdef HAVE_DGL
PuglContextType contextType = PUGL_GL;
#endif
#if defined(HAVE_DCAIRO)
#ifdef HAVE_DCAIRO
PuglContextType contextType = PUGL_CAIRO;
#endif

@@ -1384,7 +1384,7 @@ intptr_t Window::getWindowId() const noexcept
return puglGetNativeWindow(pData->fView);
}

#if defined(HAVE_DCAIRO)
#ifdef HAVE_DCAIRO
cairo_t* Window::getContext() const noexcept
{
return (cairo_t*)puglGetContext(pData->fView);
@@ -1426,7 +1426,7 @@ void Window::removeIdleCallback(IdleCallback* const callback)

void Window::onDisplayBefore()
{
#if defined(HAVE_DGL)
#ifdef HAVE_DGL
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
#endif
@@ -1438,7 +1438,7 @@ void Window::onDisplayAfter()

void Window::onReshape(uint width, uint height)
{
#if defined(HAVE_DGL)
#ifdef HAVE_DGL
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glMatrixMode(GL_PROJECTION);


+ 1
- 1
distrho/src/DistrhoUI.cpp View File

@@ -152,7 +152,7 @@ void UI::uiFileBrowserSelected(const char*)

void UI::uiReshape(uint width, uint height)
{
#if defined(HAVE_DGL)
#ifdef HAVE_DGL
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glMatrixMode(GL_PROJECTION);


Loading…
Cancel
Save