From 204fbeb807d604042c4cd3fcb076df7906521739 Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 7 Jan 2019 01:10:57 +0100 Subject: Adjustments for Cairo, and general cleanup Signed-off-by: falkTX --- Makefile | 7 +- Makefile.base.mk | 101 ++++++++++++++++------- Makefile.plugins.mk | 62 +++++++++++--- dgl/Base.hpp | 113 ++------------------------ dgl/Cairo.hpp | 40 +++++++++ dgl/Color.hpp | 6 +- dgl/Geometry.hpp | 37 +++------ dgl/Image.hpp | 82 +++++++------------ dgl/ImageBase.hpp | 125 ++++++++++++++++++++++++++++ dgl/Makefile | 106 +++++++++++++++++++----- dgl/NanoVG.hpp | 3 +- dgl/OpenGL.hpp | 121 +++++++++++++++++++++++++++ dgl/Widget.hpp | 4 +- dgl/Window.hpp | 4 +- dgl/src/Cairo.cpp | 27 +++++++ dgl/src/Color.cpp | 52 +++--------- dgl/src/Geometry.cpp | 116 +++----------------------- dgl/src/Image.cpp | 102 +++++++---------------- dgl/src/ImageBase.cpp | 106 ++++++++++++++++++++++++ dgl/src/ImageWidgets.cpp | 6 +- dgl/src/NanoVG.cpp | 21 ++++- dgl/src/OpenGL.cpp | 157 ++++++++++++++++++++++++++++++++++++ dgl/src/Widget.cpp | 7 +- dgl/src/WidgetPrivateData.cpp | 92 +++++++++++++++++++++ dgl/src/WidgetPrivateData.hpp | 63 +-------------- dgl/src/Window.cpp | 34 ++++---- dgl/src/pugl/pugl.h | 76 ++++++++--------- dgl/src/pugl/pugl_internal.h | 4 +- dgl/src/pugl/pugl_osx.m | 22 ++--- dgl/src/pugl/pugl_win.cpp | 40 ++++----- dgl/src/pugl/pugl_x11.c | 46 +++++------ distrho/DistrhoUI.hpp | 9 ++- distrho/src/DistrhoPluginChecks.h | 6 +- distrho/src/DistrhoUI.cpp | 4 +- dpf.doxygen | 3 +- examples/Info/Makefile | 4 +- examples/Meters/Makefile | 6 +- examples/Parameters/Makefile | 6 +- examples/States/Makefile | 6 +- utils/lv2-ttl-generator/GNUmakefile | 2 +- 40 files changed, 1153 insertions(+), 675 deletions(-) create mode 100644 dgl/Cairo.hpp create mode 100644 dgl/ImageBase.hpp create mode 100644 dgl/OpenGL.hpp create mode 100644 dgl/src/Cairo.cpp create mode 100644 dgl/src/ImageBase.cpp create mode 100644 dgl/src/OpenGL.cpp create mode 100644 dgl/src/WidgetPrivateData.cpp diff --git a/Makefile b/Makefile index e14bbfd2..8d12bc33 100644 --- a/Makefile +++ b/Makefile @@ -11,9 +11,7 @@ all: dgl examples gen # -------------------------------------------------------------- dgl: -ifeq ($(HAVE_DGL),true) $(MAKE) -C dgl -endif examples: dgl $(MAKE) all -C examples/Info @@ -23,6 +21,10 @@ examples: dgl $(MAKE) all -C examples/Parameters $(MAKE) all -C examples/States +ifeq ($(HAVE_CAIRO),true) + $(MAKE) all -C examples/CairoUI +endif + ifneq ($(MACOS_OR_WIN32),true) # ExternalUI is WIP $(MAKE) all -C examples/ExternalUI @@ -50,6 +52,7 @@ endif clean: $(MAKE) clean -C dgl + $(MAKE) clean -C examples/CairoUI $(MAKE) clean -C examples/ExternalUI $(MAKE) clean -C examples/Info $(MAKE) clean -C examples/Latency diff --git a/Makefile.base.mk b/Makefile.base.mk index ea729767..7274bade 100644 --- a/Makefile.base.mk +++ b/Makefile.base.mk @@ -16,7 +16,7 @@ ifneq ($(HAIKU),true) ifneq ($(HURD),true) ifneq ($(LINUX),true) ifneq ($(MACOS),true) -ifneq ($(WIN32),true) +ifneq ($(WINDOWS),true) TARGET_MACHINE := $(shell $(CC) -dumpmachine) ifneq (,$(findstring bsd,$(TARGET_MACHINE))) @@ -35,7 +35,7 @@ ifneq (,$(findstring apple,$(TARGET_MACHINE))) MACOS=true endif ifneq (,$(findstring mingw,$(TARGET_MACHINE))) -WIN32=true +WINDOWS=true endif endif @@ -57,14 +57,20 @@ LINUX_OR_MACOS=true endif # --------------------------------------------------------------------------------------------------------------------- -# Set MACOS_OR_WIN32 +# Set MACOS_OR_WINDOWS and HAIKU_OR_MACOS_OR_WINDOWS + +ifeq ($(HAIKU),true) +HAIKU_OR_MACOS_OR_WINDOWS=true +endif ifeq ($(MACOS),true) -MACOS_OR_WIN32=true +MACOS_OR_WINDOWS=true +HAIKU_OR_MACOS_OR_WINDOWS=true endif -ifeq ($(WIN32),true) -MACOS_OR_WIN32=true +ifeq ($(WINDOWS),true) +MACOS_OR_WINDOWS=true +HAIKU_OR_MACOS_OR_WINDOWS=true endif # --------------------------------------------------------------------------------------------------------------------- @@ -108,7 +114,7 @@ ifeq ($(NOOPT),true) BASE_OPTS = -O2 -ffast-math -fdata-sections -ffunction-sections endif -ifeq ($(WIN32),true) +ifeq ($(WINDOWS),true) # mingw has issues with this specific optimization # See https://github.com/falkTX/Carla/issues/696 BASE_OPTS += -fno-rerun-cse-after-loop @@ -141,7 +147,7 @@ ifeq ($(MACOS_OLD),true) BUILD_CXX_FLAGS = $(BASE_FLAGS) $(CXXFLAGS) -DHAVE_CPP11_SUPPORT=0 endif -ifeq ($(WIN32),true) +ifeq ($(WINDOWS),true) # Always build statically on windows LINK_FLAGS += -static endif @@ -170,46 +176,81 @@ CXXFLAGS += -Weffc++ -Wnon-virtual-dtor -Woverloaded-virtual endif # --------------------------------------------------------------------------------------------------------------------- -# Check for optional libs +# Check for required libraries -ifeq ($(MACOS_OR_WIN32),true) -HAVE_DGL = true +HAVE_CAIRO = $(shell pkg-config --exists cairo && echo true) + +ifeq ($(HAIKU_OR_MACOS_OR_WINDOWS),true) +HAVE_OPENGL = true else -HAVE_DGL = $(shell pkg-config --exists gl x11 && echo true) -HAVE_JACK = $(shell pkg-config --exists jack && echo true) -HAVE_LIBLO = $(shell pkg-config --exists liblo && echo true) +HAVE_OPENGL = $(shell pkg-config --exists gl && echo true) +HAVE_X11 = $(shell pkg-config --exists x11 && echo true) +endif + +# --------------------------------------------------------------------------------------------------------------------- +# Check for optional libraries + +HAVE_JACK = $(shell pkg-config --exists jack && echo true) +HAVE_LIBLO = $(shell pkg-config --exists liblo && echo true) + +# --------------------------------------------------------------------------------------------------------------------- +# Set Generic DGL stuff + +ifeq ($(MACOS),true) +DGL_LIBS += -framework Cocoa endif -ifneq ($(HAVE_DGL),true) -$(error DGL missing 22) +ifeq ($(WINDOWS),true) +DGL_LIBS += -lgdi32 +endif + +ifneq ($(HAIKU_OR_MACOS_OR_WINDOWS),true) +DGL_FLAGS += $(shell pkg-config --cflags x11) +DGL_LIBS += $(shell pkg-config --libs x11) endif # --------------------------------------------------------------------------------------------------------------------- -# Set libs stuff +# Set Cairo specific stuff + +ifeq ($(HAVE_CAIRO),true) -ifeq ($(HAVE_DGL),true) +DGL_FLAGS += -DHAVE_CAIRO -DGL_FLAGS += -DHAVE_DGL +CAIRO_FLAGS = $(shell pkg-config --cflags cairo) +CAIRO_LIBS = $(shell pkg-config --libs cairo) + +HAVE_CAIRO_OR_OPENGL = true + +endif + +# --------------------------------------------------------------------------------------------------------------------- +# Set OpenGL specific stuff + +ifeq ($(HAVE_OPENGL),true) + +DGL_FLAGS += -DHAVE_OPENGL ifeq ($(MACOS),true) -DGL_LIBS = -framework OpenGL -framework Cocoa +OPENGL_LIBS = -framework OpenGL endif -ifeq ($(WIN32),true) -DGL_LIBS = -lopengl32 -lgdi32 +ifeq ($(WINDOWS),true) +OPENGL_LIBS = -lopengl32 endif -ifneq ($(MACOS_OR_WIN32),true) -DGL_FLAGS += $(shell pkg-config --cflags gl x11) -DGL_LIBS += $(shell pkg-config --libs gl x11) +ifneq ($(MACOS_OR_WINDOWS),true) +OPENGL_FLAGS = $(shell pkg-config --cflags gl x11) +OPENGL_LIBS = $(shell pkg-config --libs gl x11) endif -endif # HAVE_DGL +HAVE_CAIRO_OR_OPENGL = true + +endif # --------------------------------------------------------------------------------------------------------------------- # Set app extension -ifeq ($(WIN32),true) +ifeq ($(WINDOWS),true) APP_EXT = .exe endif @@ -222,17 +263,17 @@ ifeq ($(MACOS),true) LIB_EXT = .dylib endif -ifeq ($(WIN32),true) +ifeq ($(WINDOWS),true) LIB_EXT = .dll endif # --------------------------------------------------------------------------------------------------------------------- # Set shared library CLI arg -SHARED = -shared - ifeq ($(MACOS),true) SHARED = -dynamiclib +else +SHARED = -shared endif # --------------------------------------------------------------------------------------------------------------------- diff --git a/Makefile.plugins.mk b/Makefile.plugins.mk index aa69a91c..76ddddd2 100644 --- a/Makefile.plugins.mk +++ b/Makefile.plugins.mk @@ -15,10 +15,6 @@ endif include $(DPF_PATH)/Makefile.base.mk -ifeq ($(FILES_UI),) -HAVE_DGL = false -endif - # --------------------------------------------------------------------------------------------------------------------- # Basic setup @@ -28,8 +24,12 @@ BUILD_DIR = ../../build/$(NAME) BUILD_C_FLAGS += -I. BUILD_CXX_FLAGS += -I. -I$(DPF_PATH)/distrho -I$(DPF_PATH)/dgl -ifeq ($(HAVE_DGL),true) -BASE_FLAGS += -DHAVE_DGL +ifeq ($(HAVE_CAIRO),true) +DGL_FLAGS += -DHAVE_CAIRO +endif + +ifeq ($(HAVE_OPENGL),true) +DGL_FLAGS += -DHAVE_OPENGL endif ifeq ($(HAVE_JACK),true) @@ -59,7 +59,37 @@ lv2_ui = $(TARGET_DIR)/$(NAME).lv2/$(NAME)_ui$(LIB_EXT) vst = $(TARGET_DIR)/$(NAME)-vst$(LIB_EXT) # --------------------------------------------------------------------------------------------------------------------- -# Handle plugins without UI +# Handle UI stuff, disable UI support automatically + +ifeq ($(FILES_UI),) +UI_TYPE = none +endif + +ifeq ($(UI_TYPE),) +UI_TYPE = opengl +endif + +ifeq ($(UI_TYPE),cairo) +ifeq ($(HAVE_CAIRO),true) +DGL_FLAGS += $(CAIRO_FLAGS) -DDGL_CAIRO +DGL_LIBS += $(CAIRO_LIBS) +DGL_LIB = $(DPF_PATH)/build/libdgl-cairo.a +HAVE_DGL = true +else +HAVE_DGL = false +endif +endif + +ifeq ($(UI_TYPE),opengl) +ifeq ($(HAVE_OPENGL),true) +DGL_FLAGS += $(OPENGL_FLAGS) -DDGL_OPENGL +DGL_LIBS += $(OPENGL_LIBS) +DGL_LIB = $(DPF_PATH)/build/libdgl-opengl.a +HAVE_DGL = true +else +HAVE_DGL = false +endif +endif ifneq ($(HAVE_DGL),true) dssi_ui = @@ -68,6 +98,9 @@ DGL_LIBS = OBJS_UI = endif +# TODO split dsp and ui object build flags +BASE_FLAGS += $(DGL_FLAGS) + # --------------------------------------------------------------------------------------------------------------------- # all needs to be first @@ -81,6 +114,11 @@ $(BUILD_DIR)/%.c.o: %.c @echo "Compiling $<" @$(CC) $< $(BUILD_C_FLAGS) -c -o $@ +$(BUILD_DIR)/%.cc.o: %.cc + -@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)" + @echo "Compiling $<" + @$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ + $(BUILD_DIR)/%.cpp.o: %.cpp -@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)" @echo "Compiling $<" @@ -118,7 +156,7 @@ $(BUILD_DIR)/DistrhoUIMain_DSSI.cpp.o: $(DPF_PATH)/distrho/DistrhoUIMain.cpp jack: $(jack) ifeq ($(HAVE_DGL),true) -$(jack): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_JACK.cpp.o $(BUILD_DIR)/DistrhoUIMain_JACK.cpp.o $(DPF_PATH)/build/libdgl.a +$(jack): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_JACK.cpp.o $(BUILD_DIR)/DistrhoUIMain_JACK.cpp.o $(DGL_LIB) else $(jack): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_JACK.cpp.o endif @@ -148,7 +186,7 @@ $(dssi_dsp): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_DSSI.cpp.o @echo "Creating DSSI plugin library for $(NAME)" @$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(SHARED) -o $@ -$(dssi_ui): $(OBJS_UI) $(BUILD_DIR)/DistrhoUIMain_DSSI.cpp.o $(DPF_PATH)/build/libdgl.a +$(dssi_ui): $(OBJS_UI) $(BUILD_DIR)/DistrhoUIMain_DSSI.cpp.o $(DGL_LIB) -@mkdir -p $(shell dirname $@) @echo "Creating DSSI UI for $(NAME)" @$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(shell pkg-config --libs liblo) -o $@ @@ -160,7 +198,7 @@ lv2: $(lv2) lv2_dsp: $(lv2_dsp) lv2_sep: $(lv2_dsp) $(lv2_ui) -$(lv2): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_LV2.cpp.o $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.o $(DPF_PATH)/build/libdgl.a +$(lv2): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_LV2.cpp.o $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.o $(DGL_LIB) -@mkdir -p $(shell dirname $@) @echo "Creating LV2 plugin for $(NAME)" @$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(SHARED) -o $@ @@ -170,7 +208,7 @@ $(lv2_dsp): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_LV2.cpp.o @echo "Creating LV2 plugin library for $(NAME)" @$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(SHARED) -o $@ -$(lv2_ui): $(OBJS_UI) $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.o $(DPF_PATH)/build/libdgl.a +$(lv2_ui): $(OBJS_UI) $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.o $(DGL_LIB) -@mkdir -p $(shell dirname $@) @echo "Creating LV2 plugin UI for $(NAME)" @$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(SHARED) -o $@ @@ -181,7 +219,7 @@ $(lv2_ui): $(OBJS_UI) $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.o $(DPF_PATH)/build/lib vst: $(vst) ifeq ($(HAVE_DGL),true) -$(vst): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_VST.cpp.o $(BUILD_DIR)/DistrhoUIMain_VST.cpp.o $(DPF_PATH)/build/libdgl.a +$(vst): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_VST.cpp.o $(BUILD_DIR)/DistrhoUIMain_VST.cpp.o $(DGL_LIB) else $(vst): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_VST.cpp.o endif diff --git a/dgl/Base.hpp b/dgl/Base.hpp index 24a7cb01..90377883 100644 --- a/dgl/Base.hpp +++ b/dgl/Base.hpp @@ -31,104 +31,6 @@ #define END_NAMESPACE_DGL } #define USE_NAMESPACE_DGL using namespace DGL_NAMESPACE; -#ifdef DISTRHO_OS_WINDOWS -// ----------------------------------------------------------------------- -// Fix OpenGL includes for Windows, based on glfw code - -#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 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 - -#endif // DISTRHO_OS_WINDOWS - -// ----------------------------------------------------------------------- -// OpenGL includes - -#ifdef HAVE_DGL - -#ifdef DISTRHO_OS_MAC -# include -#else -# ifndef DISTRHO_OS_WINDOWS -# define GL_GLEXT_PROTOTYPES -# endif -# include -# include -#endif - -#endif - -// ----------------------------------------------------------------------- -// Cairo includes - -#ifdef HAVE_DCAIRO -# include -#endif - -// ----------------------------------------------------------------------- -// Missing OpenGL defines - -#ifdef HAVE_DGL - -#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 - -#endif - -#ifdef DISTRHO_OS_WINDOWS -// ----------------------------------------------------------------------- -// Fix OpenGL includes for Windows, based on glfw code - -#ifdef DGL_WINGDIAPI_DEFINED -# undef WINGDIAPI -# undef DGL_WINGDIAPI_DEFINED -#endif - -#ifdef DGL_CALLBACK_DEFINED -# undef CALLBACK -# undef DGL_CALLBACK_DEFINED -#endif - -#endif // DISTRHO_OS_WINDOWS - START_NAMESPACE_DGL // ----------------------------------------------------------------------- @@ -187,6 +89,11 @@ enum Key { // ----------------------------------------------------------------------- // Base DGL classes +/** + Graphics context, definition depends on build type. + */ +struct GraphicsContext; + /** Idle callback. */ @@ -197,16 +104,6 @@ public: virtual void idleCallback() = 0; }; -/** - Graphics context. - */ -struct Context -{ -#ifdef HAVE_DCAIRO - cairo_t* cairo; -#endif -}; - // ----------------------------------------------------------------------- END_NAMESPACE_DGL diff --git a/dgl/Cairo.hpp b/dgl/Cairo.hpp new file mode 100644 index 00000000..ce0c920b --- /dev/null +++ b/dgl/Cairo.hpp @@ -0,0 +1,40 @@ +/* + * DISTRHO Plugin Framework (DPF) + * Copyright (C) 2012-2019 Filipe Coelho + * + * 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. + */ + +#ifndef DGL_CAIRO_HPP_INCLUDED +#define DGL_CAIRO_HPP_INCLUDED + +#include "Base.hpp" + +#include + +START_NAMESPACE_DGL + +// ----------------------------------------------------------------------- + +/** + Graphics context. + */ +struct GraphicsContext +{ + cairo_t* cairo; // FIXME proper name.. +}; + +// ----------------------------------------------------------------------- + +END_NAMESPACE_DGL + +#endif diff --git a/dgl/Color.hpp b/dgl/Color.hpp index 62b7426d..a874f660 100644 --- a/dgl/Color.hpp +++ b/dgl/Color.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2016 Filipe Coelho + * Copyright (C) 2012-2019 Filipe Coelho * * 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 @@ -19,9 +19,7 @@ #include "Base.hpp" -#ifndef HAVE_DCAIRO struct NVGcolor; -#endif START_NAMESPACE_DGL @@ -97,14 +95,12 @@ struct Color { */ void fixBounds() noexcept; -#ifndef HAVE_DCAIRO /** @internal Needed for NanoVG compatibility. */ Color(const NVGcolor&) noexcept; operator NVGcolor() const noexcept; -#endif }; // ----------------------------------------------------------------------- diff --git a/dgl/Geometry.hpp b/dgl/Geometry.hpp index 2a30cf8f..f7fe31ec 100644 --- a/dgl/Geometry.hpp +++ b/dgl/Geometry.hpp @@ -346,12 +346,10 @@ public: */ void moveBy(const Point& pos) noexcept; -#ifdef HAVE_DGL /** Draw this line using the current OpenGL state. */ void draw(); -#endif /** Return true if line is null (start and end pos are equal). @@ -462,7 +460,6 @@ public: */ void setNumSegments(const uint num); -#ifdef HAVE_DGL /** Draw this circle using the current OpenGL state. */ @@ -472,7 +469,6 @@ public: Draw lines (outline of this circle) using the current OpenGL state. */ void drawOutline(); -#endif Circle& operator=(const Circle& cir) noexcept; bool operator==(const Circle& cir) const noexcept; @@ -486,9 +482,8 @@ private: // cached values float fTheta, fCos, fSin; -#ifdef HAVE_DGL + /** @internal */ void _draw(const bool outline); -#endif }; // ----------------------------------------------------------------------- @@ -522,18 +517,6 @@ public: */ Triangle(const Triangle& tri) noexcept; -#ifdef HAVE_DGL - /** - Draw this triangle using the current OpenGL state. - */ - void draw(); - - /** - Draw lines (outline of this triangle) using the current OpenGL state. - */ - void drawOutline(); -#endif - /** Return true if triangle is null (all its points are equal). An null triangle is also invalid. @@ -557,6 +540,16 @@ public: */ bool isInvalid() const noexcept; + /** + Draw this triangle using the current OpenGL state. + */ + void draw(); + + /** + Draw lines (outline of this triangle) using the current OpenGL state. + */ + void drawOutline(); + Triangle& operator=(const Triangle& tri) noexcept; bool operator==(const Triangle& tri) const noexcept; bool operator!=(const Triangle& tri) const noexcept; @@ -564,9 +557,8 @@ public: private: Point fPos1, fPos2, fPos3; -#ifdef HAVE_DGL + /** @internal */ void _draw(const bool outline); -#endif }; // ----------------------------------------------------------------------- @@ -730,7 +722,6 @@ public: */ bool containsY(const T& y) const noexcept; -#ifdef HAVE_DGL /** Draw this rectangle using the current OpenGL state. */ @@ -740,7 +731,6 @@ public: Draw lines (outline of this rectangle) using the current OpenGL state. */ void drawOutline(); -#endif Rectangle& operator=(const Rectangle& rect) noexcept; Rectangle& operator*=(double m) noexcept; @@ -752,9 +742,8 @@ private: Point fPos; Size fSize; -#ifdef HAVE_DGL + /** @internal */ void _draw(const bool outline); -#endif }; // ----------------------------------------------------------------------- diff --git a/dgl/Image.hpp b/dgl/Image.hpp index 3df5bd84..634665ff 100644 --- a/dgl/Image.hpp +++ b/dgl/Image.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2016 Filipe Coelho + * Copyright (C) 2012-2019 Filipe Coelho * * 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 @@ -17,14 +17,15 @@ #ifndef DGL_IMAGE_HPP_INCLUDED #define DGL_IMAGE_HPP_INCLUDED -#include "Geometry.hpp" +#include "ImageBase.hpp" +#include "OpenGL.hpp" START_NAMESPACE_DGL // ----------------------------------------------------------------------- /** - Base DGL Image class. + OpenGL Image class. This is an Image class that handles raw image data in pixels. You can init the image data on the contructor or later on by calling loadFromMemory(). @@ -35,7 +36,7 @@ START_NAMESPACE_DGL Images are drawn on screen via 2D textures. */ -class Image +class Image : public ImageBase { public: /** @@ -47,13 +48,20 @@ public: Constructor using raw image data. @note @a rawData must remain valid for the lifetime of this Image. */ - Image(const char* const rawData, const uint width, const uint height, const GLenum format = GL_BGRA, const GLenum type = GL_UNSIGNED_BYTE); + Image(const char* const rawData, + const uint width, + const uint height, + const GLenum format = GL_BGRA, + const GLenum type = GL_UNSIGNED_BYTE); /** Constructor using raw image data. @note @a rawData must remain valid for the lifetime of this Image. */ - Image(const char* const rawData, const Size& size, const GLenum format = GL_BGRA, const GLenum type = GL_UNSIGNED_BYTE); + Image(const char* const rawData, + const Size& size, + const GLenum format = GL_BGRA, + const GLenum type = GL_UNSIGNED_BYTE); /** Constructor using another image data. @@ -63,44 +71,26 @@ public: /** Destructor. */ - ~Image(); + ~Image() override; /** Load image data from memory. @note @a rawData must remain valid for the lifetime of this Image. */ - void loadFromMemory(const char* const rawData, const uint width, const uint height, const GLenum format = GL_BGRA, const GLenum type = GL_UNSIGNED_BYTE) noexcept; + void loadFromMemory(const char* const rawData, + const uint width, + const uint height, + const GLenum format = GL_BGRA, + const GLenum type = GL_UNSIGNED_BYTE) noexcept; /** Load image data from memory. @note @a rawData must remain valid for the lifetime of this Image. */ - void loadFromMemory(const char* const rawData, const Size& size, const GLenum format = GL_BGRA, const GLenum type = GL_UNSIGNED_BYTE) noexcept; - - /** - Check if this image is valid. - */ - bool isValid() const noexcept; - - /** - Get width. - */ - uint getWidth() const noexcept; - - /** - Get height. - */ - uint getHeight() const noexcept; - - /** - Get size. - */ - const Size& getSize() const noexcept; - - /** - Get the raw image data. - */ - const char* getRawData() const noexcept; + void loadFromMemory(const char* const rawData, + const Size& size, + const GLenum format = GL_BGRA, + const GLenum type = GL_UNSIGNED_BYTE) noexcept; /** Get the image format. @@ -113,27 +103,15 @@ public: GLenum getType() const noexcept; /** - Draw this image at (0, 0) point. - */ - void draw(); - - /** - Draw this image at (x, y) point. + TODO document this. */ - void drawAt(const int x, const int y); - - /** - Draw this image at position @a pos. - */ - void drawAt(const Point& pos); - Image& operator=(const Image& image) noexcept; - bool operator==(const Image& image) const noexcept; - bool operator!=(const Image& image) const noexcept; + +protected: + /** @internal */ + void _drawAt(const Point& pos) override; private: - const char* fRawData; - Size fSize; GLenum fFormat; GLenum fType; GLuint fTextureId; @@ -144,4 +122,4 @@ private: END_NAMESPACE_DGL -#endif // DGL_IMAGE_HPP_INCLUDED +#endif diff --git a/dgl/ImageBase.hpp b/dgl/ImageBase.hpp new file mode 100644 index 00000000..0a7ee780 --- /dev/null +++ b/dgl/ImageBase.hpp @@ -0,0 +1,125 @@ +/* + * DISTRHO Plugin Framework (DPF) + * Copyright (C) 2012-2019 Filipe Coelho + * + * 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. + */ + +#ifndef DGL_IMAGE_BASE_HPP_INCLUDED +#define DGL_IMAGE_BASE_HPP_INCLUDED + +#include "Geometry.hpp" + +START_NAMESPACE_DGL + +// ----------------------------------------------------------------------- + +/** + Base DGL Image class. + + This is an Image class that handles raw image data in pixels. + It is an abstract class that provides the common methods to build on top. + Cairo and OpenGL Image classes are based upon this one. + + @see Image + */ +class ImageBase +{ +protected: + /** + Constructor for a null Image. + */ + ImageBase(); + + /** + Constructor using raw image data. + @note @a rawData must remain valid for the lifetime of this Image. + */ + ImageBase(const char* const rawData, const uint width, const uint height); + + /** + Constructor using raw image data. + @note @a rawData must remain valid for the lifetime of this Image. + */ + ImageBase(const char* const rawData, const Size& size); + + /** + Constructor using another image data. + */ + ImageBase(const ImageBase& image); + +public: + /** + Destructor. + */ + virtual ~ImageBase(); + + /** + Check if this image is valid. + */ + bool isValid() const noexcept; + + /** + Get width. + */ + uint getWidth() const noexcept; + + /** + Get height. + */ + uint getHeight() const noexcept; + + /** + Get size. + */ + const Size& getSize() const noexcept; + + /** + Get the raw image data. + */ + const char* getRawData() const noexcept; + + /** + Draw this image at (0, 0) point. + */ + void draw(); + + /** + Draw this image at (x, y) point. + */ + void drawAt(const int x, const int y); + + /** + Draw this image at position @a pos. + */ + void drawAt(const Point& pos); + + /** + TODO document this. + */ + ImageBase& operator=(const ImageBase& image) noexcept; + bool operator==(const ImageBase& image) const noexcept; + bool operator!=(const ImageBase& image) const noexcept; + +protected: + /** @internal */ + virtual void _drawAt(const Point& pos) = 0; + + const char* fRawData; + Size fSize; +}; + +// ----------------------------------------------------------------------- + +END_NAMESPACE_DGL + +#endif // DGL_IMAGE_HPP_INCLUDED diff --git a/dgl/Makefile b/dgl/Makefile index b0b4f419..e5143b1e 100644 --- a/dgl/Makefile +++ b/dgl/Makefile @@ -9,7 +9,7 @@ include ../Makefile.base.mk # --------------------------------------------------------------------------------------------------------------------- BUILD_C_FLAGS += $(DGL_FLAGS) -I. -Isrc -BUILD_CXX_FLAGS += $(DGL_FLAGS) -I. -Isrc +BUILD_CXX_FLAGS += $(DGL_FLAGS) -I. -Isrc -Wno-unused-parameter LINK_FLAGS += $(DGL_LIBS) # ifneq ($(MACOS_OLD),true) @@ -19,36 +19,78 @@ LINK_FLAGS += $(DGL_LIBS) # --------------------------------------------------------------------------------------------------------------------- -OBJS = \ +OBJS_common = \ ../build/dgl/Application.cpp.o \ ../build/dgl/Color.cpp.o \ ../build/dgl/Geometry.cpp.o \ - ../build/dgl/Image.cpp.o \ - ../build/dgl/ImageWidgets.cpp.o \ - ../build/dgl/NanoVG.cpp.o \ + ../build/dgl/ImageBase.cpp.o \ ../build/dgl/Resources.cpp.o \ ../build/dgl/Widget.cpp.o +# TODO: ImageWidgets.cpp + +# --------------------------------------------------------------------------------------------------------------------- + +OBJS_cairo = $(OBJS_common) \ + ../build/dgl/Cairo.cpp.cairo.o \ + ../build/dgl/WidgetPrivateData.cpp.cairo.o + +ifeq ($(MACOS),true) +OBJS_cairo += ../build/dgl/Window.mm.cairo.o +else +OBJS_cairo += ../build/dgl/Window.cpp.cairo.o +endif + +# --------------------------------------------------------------------------------------------------------------------- + +OBJS_opengl = $(OBJS_common) \ + ../build/dgl/OpenGL.cpp.opengl.o \ + ../build/dgl/Image.cpp.opengl.o \ + ../build/dgl/ImageWidgets.cpp.opengl.o \ + ../build/dgl/NanoVG.cpp.opengl.o \ + ../build/dgl/WidgetPrivateData.cpp.opengl.o + ifeq ($(MACOS),true) -OBJS += ../build/dgl/Window.mm.o +OBJS_opengl += ../build/dgl/Window.mm.opengl.o else -OBJS += ../build/dgl/Window.cpp.o +OBJS_opengl += ../build/dgl/Window.cpp.opengl.o endif -TARGET = ../build/libdgl.a +# --------------------------------------------------------------------------------------------------------------------- + +ifeq ($(HAVE_CAIRO),true) +TARGETS += ../build/libdgl-cairo.a +endif + +ifeq ($(HAVE_OPENGL),true) +TARGETS += ../build/libdgl-opengl.a +# Compat name, to be removed soon +TARGETS += ../build/libdgl.a +endif # --------------------------------------------------------------------------------------------------------------------- -all: $(TARGET) +all: $(TARGETS) # --------------------------------------------------------------------------------------------------------------------- -../build/libdgl.a: $(OBJS) +../build/libdgl-cairo.a: $(OBJS_cairo) + -@mkdir -p ../build + @echo "Creating libdgl-cairo.a" + @rm -f $@ + @$(AR) crs $@ $^ + +../build/libdgl-opengl.a: $(OBJS_opengl) -@mkdir -p ../build - @echo "Creating libdgl.a" + @echo "Creating libdgl-opengl.a" @rm -f $@ @$(AR) crs $@ $^ +# Compat name, to be removed soon +../build/libdgl.a: ../build/libdgl-opengl.a + @echo "Symlinking libdgl.a" + @ln -s $< $@ + # --------------------------------------------------------------------------------------------------------------------- ../build/dgl/%.c.o: src/%.c @@ -61,26 +103,52 @@ all: $(TARGET) @echo "Compiling $<" @$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ -../build/dgl/Window.cpp.o: src/Window.cpp src/sofd/* src/pugl/* +# --------------------------------------------------------------------------------------------------------------------- + +../build/dgl/%.cpp.cairo.o: src/%.cpp -@mkdir -p ../build/dgl - @echo "Compiling $<" - @$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ + @echo "Compiling $< (Cairo variant)" + @$(CXX) $< $(BUILD_CXX_FLAGS) -DDGL_CAIRO -c -o $@ -../build/dgl/Window.mm.o: src/Window.cpp src/sofd/* src/pugl/* +../build/dgl/Window.cpp.cairo.o: src/Window.cpp src/sofd/* src/pugl/* -@mkdir -p ../build/dgl - @echo "Compiling $<" - @$(CXX) $< $(BUILD_CXX_FLAGS) -ObjC++ -c -o $@ + @echo "Compiling $< (Cairo variant)" + @$(CXX) $< $(BUILD_CXX_FLAGS) -DDGL_CAIRO -c -o $@ + +../build/dgl/Window.mm.cairo.o: src/Window.cpp src/sofd/* src/pugl/* + -@mkdir -p ../build/dgl + @echo "Compiling $< (Cairo variant)" + @$(CXX) $< $(BUILD_CXX_FLAGS) -DDGL_CAIRO -ObjC++ -c -o $@ + +# --------------------------------------------------------------------------------------------------------------------- + +../build/dgl/%.cpp.opengl.o: src/%.cpp + -@mkdir -p ../build/dgl + @echo "Compiling $< (OpenGL variant)" + @$(CXX) $< $(BUILD_CXX_FLAGS) -DDGL_OPENGL -c -o $@ + +../build/dgl/Window.cpp.opengl.o: src/Window.cpp src/sofd/* src/pugl/* + -@mkdir -p ../build/dgl + @echo "Compiling $< (OpenGL variant)" + @$(CXX) $< $(BUILD_CXX_FLAGS) -DDGL_OPENGL -c -o $@ + +../build/dgl/Window.mm.opengl.o: src/Window.cpp src/sofd/* src/pugl/* + -@mkdir -p ../build/dgl + @echo "Compiling $< (OpenGL variant)" + @$(CXX) $< $(BUILD_CXX_FLAGS) -DDGL_OPENGL -ObjC++ -c -o $@ # --------------------------------------------------------------------------------------------------------------------- clean: - rm -rf ../build/dgl ../build/libdgl.* + rm -rf ../build/dgl ../build/libdgl*.* debug: $(MAKE) DEBUG=true # --------------------------------------------------------------------------------------------------------------------- --include $(OBJS:%.o=%.d) +-include $(OBJS_common:%.o=%.d) +-include $(OBJS_cairo:%.o=%.d) +-include $(OBJS_opengl:%.o=%.d) # --------------------------------------------------------------------------------------------------------------------- diff --git a/dgl/NanoVG.hpp b/dgl/NanoVG.hpp index e94da105..ea07df28 100644 --- a/dgl/NanoVG.hpp +++ b/dgl/NanoVG.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2016 Filipe Coelho + * Copyright (C) 2012-2019 Filipe Coelho * * 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 @@ -18,6 +18,7 @@ #define DGL_NANO_WIDGET_HPP_INCLUDED #include "Color.hpp" +#include "OpenGL.hpp" #include "Widget.hpp" #ifndef DGL_NO_SHARED_RESOURCES diff --git a/dgl/OpenGL.hpp b/dgl/OpenGL.hpp new file mode 100644 index 00000000..5466161c --- /dev/null +++ b/dgl/OpenGL.hpp @@ -0,0 +1,121 @@ +/* + * DISTRHO Plugin Framework (DPF) + * Copyright (C) 2012-2019 Filipe Coelho + * + * 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. + */ + +#ifndef DGL_OPENGL_HPP_INCLUDED +#define DGL_OPENGL_HPP_INCLUDED + +#include "ImageBase.hpp" + +// ----------------------------------------------------------------------- +// 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 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 + +#endif // DISTRHO_OS_WINDOWS + +// ----------------------------------------------------------------------- +// OpenGL includes + +#ifdef DISTRHO_OS_MAC +# include +#else +# ifndef DISTRHO_OS_WINDOWS +# define GL_GLEXT_PROTOTYPES +# endif +# include +# include +#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 + +START_NAMESPACE_DGL + +// ----------------------------------------------------------------------- + +/** + Graphics context. + */ +struct GraphicsContext +{ +}; + +// ----------------------------------------------------------------------- + +END_NAMESPACE_DGL + +#endif diff --git a/dgl/Widget.hpp b/dgl/Widget.hpp index 4e39d552..f8d7139d 100644 --- a/dgl/Widget.hpp +++ b/dgl/Widget.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2016 Filipe Coelho + * Copyright (C) 2012-2019 Filipe Coelho * * 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 @@ -312,8 +312,6 @@ public: */ Window& getParentWindow() const noexcept; - const Context& getContext() const noexcept; - /** Check if this widget contains the point defined by @a x and @a y. */ diff --git a/dgl/Window.hpp b/dgl/Window.hpp index c5de5762..45b88b9f 100644 --- a/dgl/Window.hpp +++ b/dgl/Window.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2016 Filipe Coelho + * Copyright (C) 2012-2019 Filipe Coelho * * 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 @@ -119,7 +119,7 @@ public: Application& getApp() const noexcept; intptr_t getWindowId() const noexcept; - const Context& getContext() const noexcept; + const GraphicsContext& getGraphicsContext() const noexcept; void addIdleCallback(IdleCallback* const callback); void removeIdleCallback(IdleCallback* const callback); diff --git a/dgl/src/Cairo.cpp b/dgl/src/Cairo.cpp new file mode 100644 index 00000000..2c9e42ee --- /dev/null +++ b/dgl/src/Cairo.cpp @@ -0,0 +1,27 @@ +/* + * DISTRHO Plugin Framework (DPF) + * Copyright (C) 2012-2019 Filipe Coelho + * + * 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. + */ + +#include "../Base.hpp" + +START_NAMESPACE_DGL + +// ----------------------------------------------------------------------- + +// nothing here yet + +// ----------------------------------------------------------------------- + +END_NAMESPACE_DGL diff --git a/dgl/src/Color.cpp b/dgl/src/Color.cpp index b7079ffe..3fc570ca 100644 --- a/dgl/src/Color.cpp +++ b/dgl/src/Color.cpp @@ -24,6 +24,19 @@ START_NAMESPACE_DGL // ----------------------------------------------------------------------- +static float computeHue(float h, float m1, float m2) +{ + if (h < 0) h += 1; + if (h > 1) h -= 1; + if (h < 1.0f/6.0f) + return m1 + (m2 - m1) * h * 6.0f; + if (h < 3.0f/6.0f) + return m2; + if (h < 4.0f/6.0f) + return m1 + (m2 - m1) * (2.0f/3.0f - h) * 6.0f; + return m1; +} + static void fixRange(float& value) { /**/ if (value < 0.0f) @@ -105,26 +118,8 @@ Color::Color(const Color& color1, const Color& color2, float u) noexcept interpolate(color2, u); } -#ifndef HAVE_DGL -static float computeHue(float h, float m1, float m2) -{ - if (h < 0) h += 1; - if (h > 1) h -= 1; - if (h < 1.0f/6.0f) - return m1 + (m2 - m1) * h * 6.0f; - else if (h < 3.0f/6.0f) - return m2; - else if (h < 4.0f/6.0f) - return m1 + (m2 - m1) * (2.0f/3.0f - h) * 6.0f; - return m1; -} -#endif - Color Color::fromHSL(float hue, float saturation, float lightness, float alpha) { -#ifdef HAVE_DGL - return nvgHSLA(hue, saturation, lightness, static_cast(getFixedRange(alpha)*255.0f)); -#else float m1, m2; Color col; hue = fmodf(hue, 1.0f); @@ -139,7 +134,6 @@ Color Color::fromHSL(float hue, float saturation, float lightness, float alpha) col.alpha = alpha; col.fixBounds(); return col; -#endif } Color Color::fromHTML(const char* rgb, float alpha) @@ -258,24 +252,4 @@ void Color::fixBounds() noexcept // ----------------------------------------------------------------------- -#ifndef HAVE_DCAIRO -Color::Color(const NVGcolor& c) noexcept - : red(c.r), green(c.g), blue(c.b), alpha(c.a) -{ - fixBounds(); -} - -Color::operator NVGcolor() const noexcept -{ - NVGcolor nc; - nc.r = red; - nc.g = green; - nc.b = blue; - nc.a = alpha; - return nc; -} -#endif - -// ----------------------------------------------------------------------- - END_NAMESPACE_DGL diff --git a/dgl/src/Geometry.cpp b/dgl/src/Geometry.cpp index 58e7642d..7ee3e8fc 100644 --- a/dgl/src/Geometry.cpp +++ b/dgl/src/Geometry.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2016 Filipe Coelho + * Copyright (C) 2012-2019 Filipe Coelho * * 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 @@ -441,23 +441,6 @@ void Line::moveBy(const Point& pos) noexcept fPosEnd.moveBy(pos); } -#ifdef HAVE_DGL -template -void Line::draw() -{ - DISTRHO_SAFE_ASSERT_RETURN(fPosStart != fPosEnd,); - - glBegin(GL_LINES); - - { - glVertex2d(fPosStart.fX, fPosStart.fY); - glVertex2d(fPosEnd.fX, fPosEnd.fY); - } - - glEnd(); -} -#endif - template bool Line::isNull() const noexcept { @@ -616,7 +599,6 @@ void Circle::setNumSegments(const uint num) fSin = std::sin(fTheta); } -#ifdef HAVE_DGL template void Circle::draw() { @@ -628,7 +610,6 @@ void Circle::drawOutline() { _draw(true); } -#endif template Circle& Circle::operator=(const Circle& cir) noexcept @@ -654,29 +635,6 @@ bool Circle::operator!=(const Circle& cir) const noexcept return (fPos != cir.fPos || d_isNotEqual(fSize, cir.fSize) || fNumSegments != cir.fNumSegments); } -#ifdef HAVE_DGL -template -void Circle::_draw(const bool outline) -{ - DISTRHO_SAFE_ASSERT_RETURN(fNumSegments >= 3 && fSize > 0.0f,); - - double t, x = fSize, y = 0.0; - - glBegin(outline ? GL_LINE_LOOP : GL_POLYGON); - - for (uint i=0; i::Triangle(const Triangle& tri) noexcept fPos2(tri.fPos2), fPos3(tri.fPos3) {} -#ifdef HAVE_DGL -template -void Triangle::draw() -{ - _draw(false); -} - -template -void Triangle::drawOutline() -{ - _draw(true); -} -#endif - template bool Triangle::isNull() const noexcept { @@ -742,6 +686,18 @@ bool Triangle::isInvalid() const noexcept return fPos1 == fPos2 || fPos1 == fPos3; } +template +void Triangle::draw() +{ + _draw(false); +} + +template +void Triangle::drawOutline() +{ + _draw(true); +} + template Triangle& Triangle::operator=(const Triangle& tri) noexcept { @@ -763,24 +719,6 @@ bool Triangle::operator!=(const Triangle& tri) const noexcept return (fPos1 != tri.fPos1 || fPos2 != tri.fPos2 || fPos3 != tri.fPos3); } -#ifdef HAVE_DGL -template -void Triangle::_draw(const bool outline) -{ - DISTRHO_SAFE_ASSERT_RETURN(fPos1 != fPos2 && fPos1 != fPos3,); - - glBegin(outline ? GL_LINE_LOOP : GL_TRIANGLES); - - { - glVertex2d(fPos1.fX, fPos1.fY); - glVertex2d(fPos2.fX, fPos2.fY); - glVertex2d(fPos3.fX, fPos3.fY); - } - - glEnd(); -} -#endif - // ----------------------------------------------------------------------- // Rectangle @@ -962,7 +900,6 @@ bool Rectangle::containsY(const T& y) const noexcept return (y >= fPos.fY && y <= fPos.fY + fSize.fHeight); } -#ifdef HAVE_DGL template void Rectangle::draw() { @@ -974,7 +911,6 @@ void Rectangle::drawOutline() { _draw(true); } -#endif template Rectangle& Rectangle::operator=(const Rectangle& rect) noexcept @@ -1010,32 +946,6 @@ bool Rectangle::operator!=(const Rectangle& rect) const noexcept return (fPos != rect.fPos || fSize != rect.fSize); } -#ifdef HAVE_DGL -template -void Rectangle::_draw(const bool outline) -{ - DISTRHO_SAFE_ASSERT_RETURN(fSize.isValid(),); - - glBegin(outline ? GL_LINE_LOOP : GL_QUADS); - - { - glTexCoord2f(0.0f, 0.0f); - glVertex2d(fPos.fX, fPos.fY); - - glTexCoord2f(1.0f, 0.0f); - glVertex2d(fPos.fX+fSize.fWidth, fPos.fY); - - glTexCoord2f(1.0f, 1.0f); - glVertex2d(fPos.fX+fSize.fWidth, fPos.fY+fSize.fHeight); - - glTexCoord2f(0.0f, 1.0f); - glVertex2d(fPos.fX, fPos.fY+fSize.fHeight); - } - - glEnd(); -} -#endif - // ----------------------------------------------------------------------- // Possible template data types diff --git a/dgl/src/Image.cpp b/dgl/src/Image.cpp index b79b8d44..90596fec 100644 --- a/dgl/src/Image.cpp +++ b/dgl/src/Image.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2016 Filipe Coelho + * Copyright (C) 2012-2019 Filipe Coelho * * 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 @@ -21,8 +21,7 @@ START_NAMESPACE_DGL // ----------------------------------------------------------------------- Image::Image() - : fRawData(nullptr), - fSize(0, 0), + : ImageBase(), fFormat(0), fType(0), fTextureId(0), @@ -31,20 +30,18 @@ Image::Image() glGenTextures(1, &fTextureId); } -Image::Image(const char* const rawData, const uint width, const uint height, const GLenum format, const GLenum type) - : fRawData(rawData), - fSize(width, height), - fFormat(format), - fType(type), +Image::Image(const Image& image) + : ImageBase(image), + fFormat(image.fFormat), + fType(image.fType), fTextureId(0), fIsReady(false) { glGenTextures(1, &fTextureId); } -Image::Image(const char* const rawData, const Size& size, const GLenum format, const GLenum type) - : fRawData(rawData), - fSize(size), +Image::Image(const char* const rawData, const uint width, const uint height, const GLenum format, const GLenum type) + : ImageBase(rawData, width, height), fFormat(format), fType(type), fTextureId(0), @@ -53,11 +50,10 @@ Image::Image(const char* const rawData, const Size& size, const GLenum for glGenTextures(1, &fTextureId); } -Image::Image(const Image& image) - : fRawData(image.fRawData), - fSize(image.fSize), - fFormat(image.fFormat), - fType(image.fType), +Image::Image(const char* const rawData, const Size& size, const GLenum format, const GLenum type) + : ImageBase(rawData, size), + fFormat(format), + fType(type), fTextureId(0), fIsReady(false) { @@ -75,12 +71,19 @@ Image::~Image() } } -void Image::loadFromMemory(const char* const rawData, const uint width, const uint height, const GLenum format, const GLenum type) noexcept +void Image::loadFromMemory(const char* const rawData, + const uint width, + const uint height, + const GLenum format, + const GLenum type) noexcept { loadFromMemory(rawData, Size(width, height), format, type); } -void Image::loadFromMemory(const char* const rawData, const Size& size, const GLenum format, const GLenum type) noexcept +void Image::loadFromMemory(const char* const rawData, + const Size& size, + const GLenum format, + const GLenum type) noexcept { fRawData = rawData; fSize = size; @@ -89,31 +92,6 @@ void Image::loadFromMemory(const char* const rawData, const Size& size, co fIsReady = false; } -bool Image::isValid() const noexcept -{ - return (fRawData != nullptr && fSize.getWidth() > 0 && fSize.getHeight() > 0); -} - -uint Image::getWidth() const noexcept -{ - return fSize.getWidth(); -} - -uint Image::getHeight() const noexcept -{ - return fSize.getHeight(); -} - -const Size& Image::getSize() const noexcept -{ - return fSize; -} - -const char* Image::getRawData() const noexcept -{ - return fRawData; -} - GLenum Image::getFormat() const noexcept { return fFormat; @@ -124,17 +102,17 @@ GLenum Image::getType() const noexcept return fType; } -void Image::draw() -{ - drawAt(0, 0); -} - -void Image::drawAt(const int x, const int y) +Image& Image::operator=(const Image& image) noexcept { - drawAt(Point(x, y)); + fRawData = image.fRawData; + fSize = image.fSize; + fFormat = image.fFormat; + fType = image.fType; + fIsReady = false; + return *this; } -void Image::drawAt(const Point& pos) +void Image::_drawAt(const Point& pos) { if (fTextureId == 0 || ! isValid()) return; @@ -169,26 +147,4 @@ void Image::drawAt(const Point& pos) // ----------------------------------------------------------------------- -Image& Image::operator=(const Image& image) noexcept -{ - fRawData = image.fRawData; - fSize = image.fSize; - fFormat = image.fFormat; - fType = image.fType; - fIsReady = false; - return *this; -} - -bool Image::operator==(const Image& image) const noexcept -{ - return (fRawData == image.fRawData && fSize == image.fSize); -} - -bool Image::operator!=(const Image& image) const noexcept -{ - return !operator==(image); -} - -// ----------------------------------------------------------------------- - END_NAMESPACE_DGL diff --git a/dgl/src/ImageBase.cpp b/dgl/src/ImageBase.cpp new file mode 100644 index 00000000..b5dfbb96 --- /dev/null +++ b/dgl/src/ImageBase.cpp @@ -0,0 +1,106 @@ +/* + * DISTRHO Plugin Framework (DPF) + * Copyright (C) 2012-2019 Filipe Coelho + * + * 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. + */ + +#include "../ImageBase.hpp" + +START_NAMESPACE_DGL + +// ----------------------------------------------------------------------- + +ImageBase::ImageBase() + : fRawData(nullptr), + fSize(0, 0) {} + +ImageBase::ImageBase(const char* const rawData, const uint width, const uint height) + : fRawData(rawData), + fSize(width, height) {} + +ImageBase::ImageBase(const char* const rawData, const Size& size) + : fRawData(rawData), + fSize(size) {} + +ImageBase::ImageBase(const ImageBase& image) + : fRawData(image.fRawData), + fSize(image.fSize) {} + +ImageBase::~ImageBase() {} + +// ----------------------------------------------------------------------- + +bool ImageBase::isValid() const noexcept +{ + return (fRawData != nullptr && fSize.isValid()); +} + +uint ImageBase::getWidth() const noexcept +{ + return fSize.getWidth(); +} + +uint ImageBase::getHeight() const noexcept +{ + return fSize.getHeight(); +} + +const Size& ImageBase::getSize() const noexcept +{ + return fSize; +} + +const char* ImageBase::getRawData() const noexcept +{ + return fRawData; +} + +// ----------------------------------------------------------------------- + +void ImageBase::draw() +{ + _drawAt(Point()); +} + +void ImageBase::drawAt(const int x, const int y) +{ + _drawAt(Point(x, y)); +} + +void ImageBase::drawAt(const Point& pos) +{ + _drawAt(pos); +} + +// ----------------------------------------------------------------------- + +ImageBase& ImageBase::operator=(const ImageBase& image) noexcept +{ + fRawData = image.fRawData; + fSize = image.fSize; + return *this; +} + +bool ImageBase::operator==(const ImageBase& image) const noexcept +{ + return (fRawData == image.fRawData && fSize == image.fSize); +} + +bool ImageBase::operator!=(const ImageBase& image) const noexcept +{ + return !operator==(image); +} + +// ----------------------------------------------------------------------- + +END_NAMESPACE_DGL diff --git a/dgl/src/ImageWidgets.cpp b/dgl/src/ImageWidgets.cpp index 12f952e7..71276e36 100644 --- a/dgl/src/ImageWidgets.cpp +++ b/dgl/src/ImageWidgets.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2016 Filipe Coelho + * Copyright (C) 2012-2019 Filipe Coelho * * 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 @@ -14,9 +14,13 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "../Image.hpp" #include "Common.hpp" #include "WidgetPrivateData.hpp" +// FIXME make this code more generic and move GL specific bits to OpenGL.cpp +#include "../OpenGL.hpp" + START_NAMESPACE_DGL // ----------------------------------------------------------------------- diff --git a/dgl/src/NanoVG.cpp b/dgl/src/NanoVG.cpp index 3c29222a..06fc49f7 100644 --- a/dgl/src/NanoVG.cpp +++ b/dgl/src/NanoVG.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2018 Filipe Coelho + * Copyright (C) 2012-2019 Filipe Coelho * * 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 @@ -124,6 +124,25 @@ DGL_EXT(PFNGLVERTEXATTRIBPOINTERPROC, glVertexAttribPointer) START_NAMESPACE_DGL +// ----------------------------------------------------------------------- +// DGL Color class conversion + +Color::Color(const NVGcolor& c) noexcept + : red(c.r), green(c.g), blue(c.b), alpha(c.a) +{ + fixBounds(); +} + +Color::operator NVGcolor() const noexcept +{ + NVGcolor nc; + nc.r = red; + nc.g = green; + nc.b = blue; + nc.a = alpha; + return nc; +} + // ----------------------------------------------------------------------- // NanoImage diff --git a/dgl/src/OpenGL.cpp b/dgl/src/OpenGL.cpp new file mode 100644 index 00000000..25a38619 --- /dev/null +++ b/dgl/src/OpenGL.cpp @@ -0,0 +1,157 @@ +/* + * DISTRHO Plugin Framework (DPF) + * Copyright (C) 2012-2019 Filipe Coelho + * + * 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. + */ + +#include "../Geometry.hpp" +#include "../OpenGL.hpp" + +START_NAMESPACE_DGL + +// ----------------------------------------------------------------------- +// Line + +template +void Line::draw() +{ + DISTRHO_SAFE_ASSERT_RETURN(fPosStart != fPosEnd,); + + glBegin(GL_LINES); + + { + glVertex2d(fPosStart.fX, fPosStart.fY); + glVertex2d(fPosEnd.fX, fPosEnd.fY); + } + + glEnd(); +} + +// ----------------------------------------------------------------------- +// Circle + +template +void Circle::_draw(const bool outline) +{ + DISTRHO_SAFE_ASSERT_RETURN(fNumSegments >= 3 && fSize > 0.0f,); + + double t, x = fSize, y = 0.0; + + glBegin(outline ? GL_LINE_LOOP : GL_POLYGON); + + for (uint i=0; i +void Triangle::_draw(const bool outline) +{ + DISTRHO_SAFE_ASSERT_RETURN(fPos1 != fPos2 && fPos1 != fPos3,); + + glBegin(outline ? GL_LINE_LOOP : GL_TRIANGLES); + + { + glVertex2d(fPos1.fX, fPos1.fY); + glVertex2d(fPos2.fX, fPos2.fY); + glVertex2d(fPos3.fX, fPos3.fY); + } + + glEnd(); +} + +// ----------------------------------------------------------------------- +// Rectangle + +template +void Rectangle::_draw(const bool outline) +{ + DISTRHO_SAFE_ASSERT_RETURN(fSize.isValid(),); + + glBegin(outline ? GL_LINE_LOOP : GL_QUADS); + + { + glTexCoord2f(0.0f, 0.0f); + glVertex2d(fPos.fX, fPos.fY); + + glTexCoord2f(1.0f, 0.0f); + glVertex2d(fPos.fX+fSize.fWidth, fPos.fY); + + glTexCoord2f(1.0f, 1.0f); + glVertex2d(fPos.fX+fSize.fWidth, fPos.fY+fSize.fHeight); + + glTexCoord2f(0.0f, 1.0f); + glVertex2d(fPos.fX, fPos.fY+fSize.fHeight); + } + + glEnd(); +} + +// ----------------------------------------------------------------------- +// Possible template data types + +template class Point; +template class Point; +template class Point; +template class Point; +template class Point; +template class Point; + +template class Size; +template class Size; +template class Size; +template class Size; +template class Size; +template class Size; + +template class Line; +template class Line; +template class Line; +template class Line; +template class Line; +template class Line; + +template class Circle; +template class Circle; +template class Circle; +template class Circle; +template class Circle; +template class Circle; + +template class Triangle; +template class Triangle; +template class Triangle; +template class Triangle; +template class Triangle; +template class Triangle; + +template class Rectangle; +template class Rectangle; +template class Rectangle; +template class Rectangle; +template class Rectangle; +template class Rectangle; + +// ----------------------------------------------------------------------- + +END_NAMESPACE_DGL diff --git a/dgl/src/Widget.cpp b/dgl/src/Widget.cpp index 7a87fd6f..4ef69b8e 100644 --- a/dgl/src/Widget.cpp +++ b/dgl/src/Widget.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2016 Filipe Coelho + * Copyright (C) 2012-2019 Filipe Coelho * * 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 @@ -189,11 +189,6 @@ Window& Widget::getParentWindow() const noexcept return pData->parent; } -const Context& Widget::getContext() const noexcept -{ - return pData->parent.getContext(); -} - bool Widget::contains(int x, int y) const noexcept { return (x >= 0 && y >= 0 && static_cast(x) < pData->size.getWidth() && static_cast(y) < pData->size.getHeight()); diff --git a/dgl/src/WidgetPrivateData.cpp b/dgl/src/WidgetPrivateData.cpp new file mode 100644 index 00000000..fc3da447 --- /dev/null +++ b/dgl/src/WidgetPrivateData.cpp @@ -0,0 +1,92 @@ +/* + * DISTRHO Plugin Framework (DPF) + * Copyright (C) 2012-2019 Filipe Coelho + * + * 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. + */ + +#include "WidgetPrivateData.hpp" + +#ifdef DGL_OPENGL +# include "../OpenGL.hpp" +#endif + +START_NAMESPACE_DGL + +// ----------------------------------------------------------------------- + +void Widget::PrivateData::display(const uint width, + const uint height, + const double scaling, + const bool renderingSubWidget) +{ + if ((skipDisplay && ! renderingSubWidget) || size.isInvalid() || ! visible) + return; + +#ifdef DGL_OPENGL + bool needsDisableScissor = false; + + // reset color + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + + if (needsFullViewport || (absolutePos.isZero() && size == Size(width, height))) + { + // full viewport size + glViewport(0, + -(height * scaling - height), + width * scaling, + height * scaling); + } + else if (needsScaling) + { + // limit viewport to widget bounds + glViewport(absolutePos.getX(), + height - self->getHeight() - absolutePos.getY(), + self->getWidth(), + self->getHeight()); + } + else + { + // only set viewport pos + glViewport(absolutePos.getX() * scaling, + -std::round((height * scaling - height) + (absolutePos.getY() * scaling)), + std::round(width * scaling), + std::round(height * scaling)); + + // then cut the outer bounds + glScissor(absolutePos.getX() * scaling, + height - std::round((self->getHeight() + absolutePos.getY()) * scaling), + std::round(self->getWidth() * scaling), + std::round(self->getHeight() * scaling)); + + glEnable(GL_SCISSOR_TEST); + needsDisableScissor = true; + } +#endif + + // display widget + self->onDisplay(); + +#ifdef DGL_OPENGL + if (needsDisableScissor) + { + glDisable(GL_SCISSOR_TEST); + needsDisableScissor = false; + } +#endif + + displaySubWidgets(width, height, scaling); +} + +// ----------------------------------------------------------------------- + +END_NAMESPACE_DGL diff --git a/dgl/src/WidgetPrivateData.hpp b/dgl/src/WidgetPrivateData.hpp index 06886f6d..f48a33bc 100644 --- a/dgl/src/WidgetPrivateData.hpp +++ b/dgl/src/WidgetPrivateData.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2018 Filipe Coelho + * Copyright (C) 2012-2019 Filipe Coelho * * 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 @@ -63,65 +63,8 @@ struct Widget::PrivateData { subWidgets.clear(); } - void display(const uint width, const uint height, const double scaling, const bool renderingSubWidget) - { - if ((skipDisplay && ! renderingSubWidget) || size.isInvalid() || ! visible) - return; - -#ifdef HAVE_DGL - bool needsDisableScissor = false; - - // reset color - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - - if (needsFullViewport || (absolutePos.isZero() && size == Size(width, height))) - { - // full viewport size - glViewport(0, - -(height * scaling - height), - width * scaling, - height * scaling); - } - else if (needsScaling) - { - // limit viewport to widget bounds - glViewport(absolutePos.getX(), - height - self->getHeight() - absolutePos.getY(), - self->getWidth(), - self->getHeight()); - } - else - { - // only set viewport pos - glViewport(absolutePos.getX() * scaling, - -std::round((height * scaling - height) + (absolutePos.getY() * scaling)), - std::round(width * scaling), - std::round(height * scaling)); - - // then cut the outer bounds - glScissor(absolutePos.getX() * scaling, - height - std::round((self->getHeight() + absolutePos.getY()) * scaling), - std::round(self->getWidth() * scaling), - std::round(self->getHeight() * scaling)); - - glEnable(GL_SCISSOR_TEST); - needsDisableScissor = true; - } -#endif - - // display widget - self->onDisplay(); - -#ifdef HAVE_DGL - if (needsDisableScissor) - { - glDisable(GL_SCISSOR_TEST); - needsDisableScissor = false; - } -#endif - - displaySubWidgets(width, height, scaling); - } + // display function is different depending on build type + void display(const uint width, const uint height, const double scaling, const bool renderingSubWidget); void displaySubWidgets(const uint width, const uint height, const double scaling) { diff --git a/dgl/src/Window.cpp b/dgl/src/Window.cpp index 118008d7..1b3955c9 100644 --- a/dgl/src/Window.cpp +++ b/dgl/src/Window.cpp @@ -19,14 +19,13 @@ #include "../Base.hpp" -#undef PUGL_HAVE_CAIRO -#undef PUGL_HAVE_GL - -#ifdef HAVE_DGL -#define PUGL_HAVE_GL 1 +#ifdef DGL_CAIRO +# define PUGL_CAIRO +# include "../Cairo.hpp" #endif -#ifdef HAVE_DCAIRO -#define PUGL_HAVE_CAIRO 1 +#ifdef DGL_OPENGL +# define PUGL_OPENGL +# include "../OpenGL.hpp" #endif #include "pugl/pugl.h" @@ -1049,10 +1048,10 @@ struct Window::PrivateData { // ------------------------------------------------------------------- - Application& fApp; - Window* fSelf; - Context fContext; - PuglView* fView; + Application& fApp; + Window* fSelf; + GraphicsContext fContext; + PuglView* fView; bool fFirstInit; bool fVisible; @@ -1377,12 +1376,11 @@ intptr_t Window::getWindowId() const noexcept return puglGetNativeWindow(pData->fView); } -const Context& Window::getContext() const noexcept +const GraphicsContext& Window::getGraphicsContext() const noexcept { - Context& context = pData->fContext; -#ifdef HAVE_DCAIRO - if (context.type == kContextCairo) - context.cairo.graphics = (cairo_t*)puglGetContext(pData->fView); + GraphicsContext& context = pData->fContext; +#ifdef DGL_CAIRO + context.cairo = (cairo_t*)puglGetContext(pData->fView); #endif return context; } @@ -1422,7 +1420,7 @@ void Window::removeIdleCallback(IdleCallback* const callback) void Window::onDisplayBefore() { -#ifdef HAVE_DGL +#ifdef DGL_OPENGL glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); #endif @@ -1434,7 +1432,7 @@ void Window::onDisplayAfter() void Window::onReshape(uint width, uint height) { -#ifdef HAVE_DGL +#ifdef DGL_OPENGL glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glMatrixMode(GL_PROJECTION); diff --git a/dgl/src/pugl/pugl.h b/dgl/src/pugl/pugl.h index 898ef056..20a38140 100644 --- a/dgl/src/pugl/pugl.h +++ b/dgl/src/pugl/pugl.h @@ -30,19 +30,13 @@ platforms so they are included here to allow for pure portable programs. */ #ifdef __APPLE__ -# include "OpenGL/gl.h" +# include #else # ifdef _WIN32 # include # include /* Broken Windows GL headers require this */ # endif -# include "GL/gl.h" -#endif - -#ifdef _WIN32 -# define PUGL_API -#else -# define PUGL_API __attribute__((visibility("hidden"))) +# include #endif #ifdef __cplusplus @@ -238,31 +232,31 @@ typedef void (*PuglFileSelectedFunc)(PuglView* view, const char* filename); To create a window, call the various puglInit* functions as necessary, then call puglCreateWindow(). */ -PUGL_API PuglView* +PuglView* puglInit(void); /** Set the parent window before creating a window (for embedding). */ -PUGL_API void +void puglInitWindowParent(PuglView* view, PuglNativeWindow parent); /** Set the window size before creating a window. */ -PUGL_API void +void puglInitWindowSize(PuglView* view, int width, int height); /** Set the minimum window size before creating a window. */ -PUGL_API void +void puglInitWindowMinSize(PuglView* view, int width, int height); /** Enable or disable resizing before creating a window. */ -PUGL_API void +void puglInitUserResizable(PuglView* view, bool resizable); /** @@ -271,7 +265,7 @@ puglInitUserResizable(PuglView* view, bool resizable); On X11, parent_id must be a Window. On OSX, parent_id must be an NSView*. */ -PUGL_API void +void puglInitTransientFor(PuglView* view, uintptr_t parent); /** @@ -289,7 +283,7 @@ puglInitTransientFor(PuglView* view, uintptr_t parent); @return 1 (pugl does not currently support multiple windows). */ -PUGL_API int +int puglCreateWindow(PuglView* view, const char* title); /** @@ -300,7 +294,7 @@ puglCreateWindow(PuglView* view, const char* title); @param height Window height in pixels. @param resizable Whether window should be user resizable. */ -PUGL_API PuglView* +PuglView* puglCreate(PuglNativeWindow parent, const char* title, int min_width, @@ -313,19 +307,19 @@ puglCreate(PuglNativeWindow parent, /** Show Window (external ui) */ -PUGL_API void +void puglShowWindow(PuglView* view); /** Hide Window (external ui) */ -PUGL_API void +void puglHideWindow(PuglView* view); /** Return the native window handle. */ -PUGL_API PuglNativeWindow +PuglNativeWindow puglGetNativeWindow(PuglView* view); /** @@ -341,13 +335,13 @@ puglGetNativeWindow(PuglView* view); Note the lack of this facility makes GLUT unsuitable for plugins or non-trivial programs; this mistake is largely why Pugl exists. */ -PUGL_API void +void puglSetHandle(PuglView* view, PuglHandle handle); /** Get the handle to be passed to all callbacks. */ -PUGL_API PuglHandle +PuglHandle puglGetHandle(PuglView* view); /** @@ -355,13 +349,13 @@ puglGetHandle(PuglView* view); For Cairo contexts, this returns a pointer to a cairo_t. For everything else, this is unused and returns NULL. */ -PUGL_API void* +void* puglGetContext(PuglView* view); /** Return the timestamp (if any) of the currently-processing event. */ -PUGL_API uint32_t +uint32_t puglGetEventTimestamp(PuglView* view); /** @@ -369,13 +363,13 @@ puglGetEventTimestamp(PuglView* view); This should only be called from an event handler. */ -PUGL_API int +int puglGetModifiers(PuglView* view); /** Ignore synthetic repeated key events. */ -PUGL_API void +void puglIgnoreKeyRepeat(PuglView* view, bool ignore); /** @@ -387,61 +381,61 @@ puglIgnoreKeyRepeat(PuglView* view, bool ignore); /** Set the function to call when the window is closed. */ -PUGL_API void +void puglSetCloseFunc(PuglView* view, PuglCloseFunc closeFunc); /** Set the display function which should draw the UI using GL. */ -PUGL_API void +void puglSetDisplayFunc(PuglView* view, PuglDisplayFunc displayFunc); /** Set the function to call on keyboard events. */ -PUGL_API void +void puglSetKeyboardFunc(PuglView* view, PuglKeyboardFunc keyboardFunc); /** Set the function to call on mouse motion. */ -PUGL_API void +void puglSetMotionFunc(PuglView* view, PuglMotionFunc motionFunc); /** Set the function to call on mouse button events. */ -PUGL_API void +void puglSetMouseFunc(PuglView* view, PuglMouseFunc mouseFunc); /** Set the function to call on scroll events. */ -PUGL_API void +void puglSetScrollFunc(PuglView* view, PuglScrollFunc scrollFunc); /** Set the function to call on special events. */ -PUGL_API void +void puglSetSpecialFunc(PuglView* view, PuglSpecialFunc specialFunc); /** Set the function to call when the window size changes. */ -PUGL_API void +void puglSetReshapeFunc(PuglView* view, PuglReshapeFunc reshapeFunc); /** Set callback function to change window size. */ -PUGL_API void +void puglSetResizeFunc(PuglView* view, PuglResizeFunc resizeFunc); /** Set the function to call on file-browser selections. */ -PUGL_API void +void puglSetFileSelectedFunc(PuglView* view, PuglFileSelectedFunc fileSelectedFunc); /** @@ -451,13 +445,13 @@ puglSetFileSelectedFunc(PuglView* view, PuglFileSelectedFunc fileSelectedFunc); /** TODO document this. */ -PUGL_API int +int puglUpdateGeometryConstraints(PuglView* view, int min_width, int min_height, bool aspect); /** Grab the input focus. */ -PUGL_API void +void puglGrabFocus(PuglView* view); /** @@ -466,25 +460,25 @@ puglGrabFocus(PuglView* view); This handles input events as well as rendering, so it should be called regularly and rapidly enough to keep the UI responsive. */ -PUGL_API PuglStatus +PuglStatus puglProcessEvents(PuglView* view); /** Request a redisplay on the next call to puglProcessEvents(). */ -PUGL_API void +void puglPostRedisplay(PuglView* view); /** Request a resize on the next call to puglProcessEvents(). */ -PUGL_API void +void puglPostResize(PuglView* view); /** Destroy a GL window. */ -PUGL_API void +void puglDestroy(PuglView* view); /** diff --git a/dgl/src/pugl/pugl_internal.h b/dgl/src/pugl/pugl_internal.h index 0a353275..609c97b9 100644 --- a/dgl/src/pugl/pugl_internal.h +++ b/dgl/src/pugl/pugl_internal.h @@ -240,7 +240,7 @@ puglLeaveContext(PuglView* view, bool flush); static void puglDefaultReshape(int width, int height) { -#ifdef PUGL_HAVE_GL +#ifdef PUGL_OPENGL #ifdef ROBTK_HERE glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); @@ -259,5 +259,5 @@ puglDefaultReshape(int width, int height) glMatrixMode(GL_MODELVIEW); glLoadIdentity(); #endif -#endif +#endif // PUGL_OPENGL } diff --git a/dgl/src/pugl/pugl_osx.m b/dgl/src/pugl/pugl_osx.m index 18191628..80b99304 100644 --- a/dgl/src/pugl/pugl_osx.m +++ b/dgl/src/pugl/pugl_osx.m @@ -21,11 +21,11 @@ #include -#import -#ifdef PUGL_HAVE_CAIRO +#ifdef PUGL_CAIRO #import #import #endif +#import #include "pugl_internal.h" @@ -290,7 +290,7 @@ flagsChanged(NSView *self, NSEvent *event) } } -#ifdef PUGL_HAVE_GL +#ifdef PUGL_OPENGL @interface PuglOpenGLView : NSOpenGLView { @public @@ -530,7 +530,7 @@ flagsChanged(NSView *self, NSEvent *event) @end #endif -#ifdef PUGL_HAVE_CAIRO +#ifdef PUGL_CAIRO @interface PuglCairoView : NSView { PuglView* puglview; @@ -755,10 +755,10 @@ flagsChanged(NSView *self, NSEvent *event) struct PuglInternalsImpl { union { NSView* view; -#ifdef PUGL_HAVE_GL +#ifdef PUGL_OPENGL PuglOpenGLView* glview; #endif -#ifdef PUGL_HAVE_CAIRO +#ifdef PUGL_CAIRO PuglCairoView* cairoview; #endif }; @@ -774,7 +774,7 @@ puglInitInternals() void puglEnterContext(PuglView* view) { -#ifdef PUGL_HAVE_GL +#ifdef PUGL_OPENGL [[view->impl->glview openGLContext] makeCurrentContext]; #endif } @@ -783,7 +783,7 @@ void puglLeaveContext(PuglView* view, bool flush) { if (flush) { -#ifdef PUGL_HAVE_GL +#ifdef PUGL_OPENGL if (view->impl->glview->doubleBuffered) { [[view->impl->glview openGLContext] flushBuffer]; } else { @@ -802,10 +802,10 @@ puglCreateWindow(PuglView* view, const char* title) [NSAutoreleasePool new]; [NSApplication sharedApplication]; -#ifdef PUGL_HAVE_GL +#ifdef PUGL_OPENGL impl->glview = [PuglOpenGLView new]; #endif -#ifdef PUGL_HAVE_CAIRO +#ifdef PUGL_CAIRO impl->cairoview = [PuglCairoView new]; #endif @@ -919,7 +919,7 @@ puglGetNativeWindow(PuglView* view) void* puglGetContext(PuglView* view) { -#ifdef PUGL_HAVE_CAIRO +#ifdef PUGL_CAIRO return [view->impl->cairoview cairoContext]; #endif return NULL; diff --git a/dgl/src/pugl/pugl_win.cpp b/dgl/src/pugl/pugl_win.cpp index 445820bd..d8b3866d 100644 --- a/dgl/src/pugl/pugl_win.cpp +++ b/dgl/src/pugl/pugl_win.cpp @@ -19,22 +19,22 @@ @file pugl_win.cpp Windows/WGL Pugl Implementation. */ +#include +#include +#include + #include #include #include -#ifdef PUGL_HAVE_GL -#include -#endif -#ifdef PUGL_HAVE_CAIRO +#ifdef PUGL_CAIRO #include #include #endif +#ifdef PUGL_OPENGL +#include +#endif -#include -#include -#include - -#include "pugl/pugl_internal.h" +#include "pugl_internal.h" #ifndef WM_MOUSEWHEEL # define WM_MOUSEWHEEL 0x020A @@ -55,11 +55,11 @@ HINSTANCE hInstance = NULL; struct PuglInternalsImpl { HWND hwnd; -#ifdef PUGL_HAVE_GL +#ifdef PUGL_OPENGL HDC hdc; HGLRC hglrc; #endif -#ifdef PUGL_HAVE_CAIRO +#ifdef PUGL_CAIRO cairo_t* buffer_cr; cairo_surface_t* buffer_surface; #endif @@ -90,7 +90,7 @@ puglInitInternals() void puglEnterContext(PuglView* view) { -#ifdef PUGL_HAVE_GL +#ifdef PUGL_OPENGL wglMakeCurrent(view->impl->hdc, view->impl->hglrc); #endif } @@ -98,7 +98,7 @@ puglEnterContext(PuglView* view) void puglLeaveContext(PuglView* view, bool flush) { -#ifdef PUGL_HAVE_GL +#ifdef PUGL_OPENGL if (flush) { glFlush(); SwapBuffers(view->impl->hdc); @@ -177,7 +177,7 @@ puglCreateWindow(PuglView* view, const char* title) SetWindowLongPtr(impl->hwnd, GWLP_USERDATA, (LONG_PTR)view); -#ifdef PUGL_HAVE_GL +#ifdef PUGL_OPENGL impl->hdc = GetDC(impl->hwnd); PIXELFORMATDESCRIPTOR pfd; @@ -228,12 +228,12 @@ puglDestroy(PuglView* view) PuglInternals* const impl = view->impl; -#ifdef PUGL_HAVE_GL +#ifdef PUGL_OPENGL wglMakeCurrent(NULL, NULL); wglDeleteContext(impl->hglrc); ReleaseDC(impl->hwnd, impl->hdc); #endif -#ifdef PUGL_HAVE_CAIRO +#ifdef PUGL_CAIRO cairo_destroy(impl->buffer_cr); cairo_surface_destroy(impl->buffer_surface); #endif @@ -267,7 +267,7 @@ puglDisplay(PuglView* view) puglEnterContext(view); -#ifdef PUGL_HAVE_CAIRO +#ifdef PUGL_CAIRO cairo_t *wc = NULL; cairo_t *bc = NULL; cairo_surface_t *ws = NULL; @@ -298,7 +298,7 @@ puglDisplay(PuglView* view) if (view->displayFunc) { view->displayFunc(view); } -#ifdef PUGL_HAVE_CAIRO +#ifdef PUGL_CAIRO cairo_set_source_surface(wc, bs, 0, 0); cairo_paint(wc); #endif @@ -306,7 +306,7 @@ puglDisplay(PuglView* view) puglLeaveContext(view, success); -#ifdef PUGL_HAVE_CAIRO +#ifdef PUGL_CAIRO cairo_destroy(wc); cairo_surface_destroy(ws); #endif @@ -545,7 +545,7 @@ puglGetNativeWindow(PuglView* view) void* puglGetContext(PuglView* view) { -#ifdef PUGL_HAVE_CAIRO +#ifdef PUGL_CAIRO return view->impl->buffer_cr; #endif return NULL; diff --git a/dgl/src/pugl/pugl_x11.c b/dgl/src/pugl/pugl_x11.c index 44202830..3146cfcc 100644 --- a/dgl/src/pugl/pugl_x11.c +++ b/dgl/src/pugl/pugl_x11.c @@ -25,14 +25,14 @@ #include #include -#ifdef PUGL_HAVE_GL -#include -#include -#endif -#ifdef PUGL_HAVE_CAIRO +#ifdef PUGL_CAIRO #include #include #endif +#ifdef PUGL_OPENGL +#include +#include +#endif #include #include #include @@ -60,19 +60,19 @@ struct PuglInternalsImpl { Display* display; int screen; Window win; -#ifdef PUGL_HAVE_CAIRO +#ifdef PUGL_CAIRO cairo_t* xlib_cr; cairo_t* buffer_cr; cairo_surface_t* xlib_surface; cairo_surface_t* buffer_surface; #endif -#ifdef PUGL_HAVE_GL +#ifdef PUGL_OPENGL GLXContext ctx; Bool doubleBuffered; #endif }; -#ifdef PUGL_HAVE_GL +#ifdef PUGL_OPENGL /** Attributes for single-buffered RGBA with at least 4 bits per color and a 16 bit depth buffer. @@ -129,7 +129,7 @@ puglInitInternals(void) void puglEnterContext(PuglView* view) { -#ifdef PUGL_HAVE_GL +#ifdef PUGL_OPENGL glXMakeCurrent(view->impl->display, view->impl->win, view->impl->ctx); #endif } @@ -137,7 +137,7 @@ puglEnterContext(PuglView* view) void puglLeaveContext(PuglView* view, bool flush) { -#ifdef PUGL_HAVE_GL +#ifdef PUGL_OPENGL if (flush) { glFlush(); if (view->impl->doubleBuffered) { @@ -166,7 +166,7 @@ puglCreateWindow(PuglView* view, const char* title) XVisualInfo* vi = NULL; -#ifdef PUGL_HAVE_GL +#ifdef PUGL_OPENGL impl->doubleBuffered = True; vi = glXChooseVisual(impl->display, impl->screen, attrListDblMS); @@ -182,7 +182,7 @@ puglCreateWindow(PuglView* view, const char* title) impl->doubleBuffered = False; } #endif -#ifdef PUGL_HAVE_CAIRO +#ifdef PUGL_CAIRO XVisualInfo pat; int n; pat.screen = impl->screen; @@ -196,14 +196,14 @@ puglCreateWindow(PuglView* view, const char* title) } #ifdef PUGL_VERBOSE -#ifdef PUGL_HAVE_GL +#ifdef PUGL_OPENGL int glxMajor, glxMinor; glXQueryVersion(impl->display, &glxMajor, &glxMinor); printf("puGL: GLX-Version : %d.%d\n", glxMajor, glxMinor); #endif #endif -#ifdef PUGL_HAVE_GL +#ifdef PUGL_OPENGL impl->ctx = glXCreateContext(impl->display, vi, 0, GL_TRUE); if (!impl->ctx) { @@ -237,7 +237,7 @@ puglCreateWindow(PuglView* view, const char* title) CWBorderPixel | CWColormap | CWEventMask, &attr); if (!impl->win) { -#ifdef PUGL_HAVE_GL +#ifdef PUGL_OPENGL glXDestroyContext(impl->display, impl->ctx); #endif XFree(vi); @@ -246,7 +246,7 @@ puglCreateWindow(PuglView* view, const char* title) return 1; } -#ifdef PUGL_HAVE_CAIRO +#ifdef PUGL_CAIRO impl->xlib_surface = cairo_xlib_surface_create( impl->display, impl->win, vi->visual, view->width, view->height); if (impl->xlib_surface == NULL || cairo_surface_status(impl->xlib_surface) != CAIRO_STATUS_SUCCESS) { @@ -288,7 +288,7 @@ puglCreateWindow(PuglView* view, const char* title) } #ifdef PUGL_VERBOSE -#ifdef PUGL_HAVE_GL +#ifdef PUGL_OPENGL if (glXIsDirect(impl->display, impl->ctx)) { printf("puGL: DRI enabled (to disable, set LIBGL_ALWAYS_INDIRECT=1\n"); } else { @@ -314,10 +314,10 @@ puglDestroy(PuglView* view) x_fib_close(impl->display); #endif -#ifdef PUGL_HAVE_GL +#ifdef PUGL_OPENGL glXDestroyContext(impl->display, impl->ctx); #endif -#ifdef PUGL_HAVE_CAIRO +#ifdef PUGL_CAIRO cairo_destroy(impl->xlib_cr); cairo_destroy(impl->buffer_cr); cairo_surface_destroy(impl->xlib_surface); @@ -365,7 +365,7 @@ puglDisplay(PuglView* view) puglEnterContext(view); -#ifdef PUGL_HAVE_CAIRO +#ifdef PUGL_CAIRO cairo_t* bc = impl->buffer_cr; cairo_surface_t* xs = impl->xlib_surface; cairo_surface_t* bs = impl->buffer_surface; @@ -394,7 +394,7 @@ puglDisplay(PuglView* view) view->displayFunc(view); } -#ifdef PUGL_HAVE_CAIRO +#ifdef PUGL_CAIRO cairo_t* xc = impl->xlib_cr; cairo_set_source_surface(xc, impl->buffer_surface, 0, 0); cairo_paint(xc); @@ -661,7 +661,7 @@ puglProcessEvents(PuglView* view) } if (conf_width != -1) { -#ifdef PUGL_HAVE_CAIRO +#ifdef PUGL_CAIRO // Resize surfaces/contexts before dispatching view->redisplay = true; cairo_xlib_surface_set_size(view->impl->xlib_surface, @@ -702,7 +702,7 @@ puglGetNativeWindow(PuglView* view) void* puglGetContext(PuglView* view) { -#ifdef PUGL_HAVE_CAIRO +#ifdef PUGL_CAIRO return view->impl->buffer_cr; #endif return NULL; diff --git a/distrho/DistrhoUI.hpp b/distrho/DistrhoUI.hpp index 244b25bc..3ef8c5f4 100644 --- a/distrho/DistrhoUI.hpp +++ b/distrho/DistrhoUI.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2018 Filipe Coelho + * Copyright (C) 2012-2019 Filipe Coelho * * 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 @@ -32,6 +32,13 @@ typedef DGL_NAMESPACE::NanoWidget UIWidget; typedef DGL_NAMESPACE::Widget UIWidget; #endif +#ifdef DGL_CAIRO +# include "Cairo.hpp" +#endif +#ifdef DGL_OPENGL +# include "OpenGL.hpp" +#endif + START_NAMESPACE_DISTRHO /* ------------------------------------------------------------------------------------------------------------ diff --git a/distrho/src/DistrhoPluginChecks.h b/distrho/src/DistrhoPluginChecks.h index 0d2fc94c..d52fb20d 100644 --- a/distrho/src/DistrhoPluginChecks.h +++ b/distrho/src/DistrhoPluginChecks.h @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2016 Filipe Coelho + * Copyright (C) 2012-2019 Filipe Coelho * * 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 @@ -93,7 +93,7 @@ // Define DISTRHO_PLUGIN_HAS_EMBED_UI if needed #ifndef DISTRHO_PLUGIN_HAS_EMBED_UI -# if defined(HAVE_DGL) || defined(HAVE_DCAIRO) +# if defined(HAVE_CAIRO) || defined(HAVE_OPENGL) # define DISTRHO_PLUGIN_HAS_EMBED_UI 1 # else # define DISTRHO_PLUGIN_HAS_EMBED_UI 0 @@ -135,7 +135,7 @@ // ----------------------------------------------------------------------- // Disable UI if DGL or External UI is not available -#if DISTRHO_PLUGIN_HAS_UI && ! DISTRHO_PLUGIN_HAS_EXTERNAL_UI && ! defined(HAVE_DGL) && ! defined(HAVE_DCAIRO) +#if DISTRHO_PLUGIN_HAS_UI && ! DISTRHO_PLUGIN_HAS_EXTERNAL_UI && ! defined(HAVE_CAIRO) && ! defined(HAVE_OPENGL) # undef DISTRHO_PLUGIN_HAS_UI # define DISTRHO_PLUGIN_HAS_UI 0 #endif diff --git a/distrho/src/DistrhoUI.cpp b/distrho/src/DistrhoUI.cpp index 1316d965..f5ef489d 100644 --- a/distrho/src/DistrhoUI.cpp +++ b/distrho/src/DistrhoUI.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2018 Filipe Coelho + * Copyright (C) 2012-2019 Filipe Coelho * * 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 @@ -152,7 +152,7 @@ void UI::uiFileBrowserSelected(const char*) void UI::uiReshape(uint width, uint height) { -#ifdef HAVE_DGL +#ifdef DGL_OPENGL glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glMatrixMode(GL_PROJECTION); diff --git a/dpf.doxygen b/dpf.doxygen index 9c05ec0c..2516e934 100644 --- a/dpf.doxygen +++ b/dpf.doxygen @@ -242,7 +242,8 @@ SEARCH_INCLUDES = YES INCLUDE_PATH = INCLUDE_FILE_PATTERNS = PREDEFINED = DOXYGEN \ - HAVE_DGL=1 \ + HAVE_CAIRO=1 \ + HAVE_OPENGL=1 \ DISTRHO_PLUGIN_NAME="Plugin Name" \ DISTRHO_PLUGIN_NUM_INPUTS=2 \ DISTRHO_PLUGIN_NUM_OUTPUTS=2 \ diff --git a/examples/Info/Makefile b/examples/Info/Makefile index 200ee8c9..4fe4fa54 100644 --- a/examples/Info/Makefile +++ b/examples/Info/Makefile @@ -26,13 +26,13 @@ include ../../Makefile.plugins.mk # -------------------------------------------------------------- # Enable all possible plugin types -ifeq ($(HAVE_DGL),true) ifeq ($(HAVE_JACK),true) +ifeq ($(HAVE_OPENGL),true) TARGETS += jack endif endif -ifeq ($(HAVE_DGL),true) +ifeq ($(HAVE_OPENGL),true) TARGETS += lv2_sep else TARGETS += lv2_dsp diff --git a/examples/Meters/Makefile b/examples/Meters/Makefile index 3fc712ce..ac50f2f9 100644 --- a/examples/Meters/Makefile +++ b/examples/Meters/Makefile @@ -26,21 +26,21 @@ include ../../Makefile.plugins.mk # -------------------------------------------------------------- # Enable all possible plugin types -ifeq ($(HAVE_DGL),true) ifeq ($(HAVE_JACK),true) +ifeq ($(HAVE_OPENGL),true) TARGETS += jack endif endif ifeq ($(LINUX),true) -ifeq ($(HAVE_DGL),true) ifeq ($(HAVE_LIBLO),true) +ifeq ($(HAVE_OPENGL),true) TARGETS += dssi endif endif endif -ifeq ($(HAVE_DGL),true) +ifeq ($(HAVE_OPENGL),true) TARGETS += lv2_sep else TARGETS += lv2_dsp diff --git a/examples/Parameters/Makefile b/examples/Parameters/Makefile index 15c39099..f097b403 100644 --- a/examples/Parameters/Makefile +++ b/examples/Parameters/Makefile @@ -26,22 +26,22 @@ include ../../Makefile.plugins.mk # -------------------------------------------------------------- # Enable all possible plugin types -ifeq ($(HAVE_DGL),true) ifeq ($(HAVE_JACK),true) +ifeq ($(HAVE_OPENGL),true) TARGETS += jack endif endif ifeq ($(LINUX),true) -ifeq ($(HAVE_DGL),true) ifeq ($(HAVE_LIBLO),true) +ifeq ($(HAVE_OPENGL),true) TARGETS += ladspa TARGETS += dssi endif endif endif -ifeq ($(HAVE_DGL),true) +ifeq ($(HAVE_OPENGL),true) TARGETS += lv2_sep else TARGETS += lv2_dsp diff --git a/examples/States/Makefile b/examples/States/Makefile index 026e4ec2..5f4a4811 100644 --- a/examples/States/Makefile +++ b/examples/States/Makefile @@ -26,21 +26,21 @@ include ../../Makefile.plugins.mk # -------------------------------------------------------------- # Enable all possible plugin types -ifeq ($(HAVE_DGL),true) ifeq ($(HAVE_JACK),true) +ifeq ($(HAVE_OPENGL),true) TARGETS += jack endif endif ifeq ($(LINUX),true) -ifeq ($(HAVE_DGL),true) ifeq ($(HAVE_LIBLO),true) +ifeq ($(HAVE_OPENGL),true) TARGETS += dssi endif endif endif -ifeq ($(HAVE_DGL),true) +ifeq ($(HAVE_OPENGL),true) TARGETS += lv2_sep else TARGETS += lv2_dsp diff --git a/utils/lv2-ttl-generator/GNUmakefile b/utils/lv2-ttl-generator/GNUmakefile index 1042b7bd..490e9343 100644 --- a/utils/lv2-ttl-generator/GNUmakefile +++ b/utils/lv2-ttl-generator/GNUmakefile @@ -2,7 +2,7 @@ all: build -ifeq ($(WIN32),true) +ifeq ($(WINDOWS),true) build: ../lv2_ttl_generator.exe else build: ../lv2_ttl_generator -- cgit v1.2.3