From bf58d8631bb1530399fa269ceeaff9fda5e5c73d Mon Sep 17 00:00:00 2001 From: Rodney Date: Jan 08 2020 21:18:48 +0000 Subject: Merge pull request #2990 from otakuto/remove-sdl2 Remove SDL2 --- diff --git a/ci-scripts/linux/travis-install.sh b/ci-scripts/linux/travis-install.sh index 593aebe..38518cd 100644 --- a/ci-scripts/linux/travis-install.sh +++ b/ci-scripts/linux/travis-install.sh @@ -1,7 +1,7 @@ sudo add-apt-repository --yes ppa:beineri/opt-qt597-trusty sudo add-apt-repository --yes ppa:achadwick/mypaint-testing sudo apt-get update -sudo apt-get install -y liblzo2-dev liblz4-dev libfreetype6-dev libpng-dev libegl1-mesa-dev libgles2-mesa-dev libsdl2-dev libglew-dev freeglut3-dev qt59script libsuperlu3-dev qt59svg qt59tools qt59multimedia wget libusb-1.0-0-dev libboost-all-dev liblzma-dev libjson-c-dev libmypaint-dev +sudo apt-get install -y liblzo2-dev liblz4-dev libfreetype6-dev libpng-dev libegl1-mesa-dev libgles2-mesa-dev libglew-dev freeglut3-dev qt59script libsuperlu3-dev qt59svg qt59tools qt59multimedia wget libusb-1.0-0-dev libboost-all-dev liblzma-dev libjson-c-dev libmypaint-dev # someone forgot to include liblz4.pc with the package, use the version from xenial, as it only depends on libc wget http://mirrors.kernel.org/ubuntu/pool/main/l/lz4/liblz4-1_0.0~r131-2ubuntu2_amd64.deb -O liblz4.deb diff --git a/doc/how_to_build_linux.md b/doc/how_to_build_linux.md index e3f6b6f..7a7c8ef 100644 --- a/doc/how_to_build_linux.md +++ b/doc/how_to_build_linux.md @@ -8,7 +8,6 @@ Building OpenToonz from source requires the following dependencies: - CMake (3.4.1 or newer). - Qt5 (5.9 or newer) - Boost (1.55 or newer) -- SDL2 - LibPNG - SuperLU - Lzo2 @@ -18,7 +17,7 @@ Building OpenToonz from source requires the following dependencies: ### Installing Dependencies on Debian / Ubuntu ``` -$ sudo apt-get install build-essential git cmake pkg-config libboost-all-dev qt5-default qtbase5-dev libqt5svg5-dev qtscript5-dev qttools5-dev qttools5-dev-tools libqt5opengl5-dev qtmultimedia5-dev libsuperlu-dev liblz4-dev libusb-1.0-0-dev liblzo2-dev libpng-dev libjpeg-dev libglew-dev freeglut3-dev libsdl2-dev libfreetype6-dev libjson-c-dev qtwayland5 +$ sudo apt-get install build-essential git cmake pkg-config libboost-all-dev qt5-default qtbase5-dev libqt5svg5-dev qtscript5-dev qttools5-dev qttools5-dev-tools libqt5opengl5-dev qtmultimedia5-dev libsuperlu-dev liblz4-dev libusb-1.0-0-dev liblzo2-dev libpng-dev libjpeg-dev libglew-dev freeglut3-dev libfreetype6-dev libjson-c-dev qtwayland5 ``` For newest versions of OS you may install libmypaint from repository and don't need to build it from source: @@ -34,7 +33,7 @@ Notes: (it may include some useless packages) ``` -$ sudo dnf install gcc gcc-c++ automake git cmake boost boost-devel SuperLU SuperLU-devel lz4-devel lzma libusb-devel lzo-devel libjpeg-turbo-devel libGLEW glew-devel freeglut-devel freeglut SDL2 SDL2-devel freetype-devel libpng-devel qt5-qtbase-devel qt5-qtsvg qt5-qtsvg-devel qt5-qtscript qt5-qtscript-devel qt5-qttools qt5-qttools-devel qt5-qtmultimedia-devel blas blas-devel json-c-devel libtool intltool make +$ sudo dnf install gcc gcc-c++ automake git cmake boost boost-devel SuperLU SuperLU-devel lz4-devel lzma libusb-devel lzo-devel libjpeg-turbo-devel libGLEW glew-devel freeglut-devel freeglut freetype-devel libpng-devel qt5-qtbase-devel qt5-qtsvg qt5-qtsvg-devel qt5-qtscript qt5-qtscript-devel qt5-qttools qt5-qttools-devel qt5-qtmultimedia-devel blas blas-devel json-c-devel libtool intltool make ``` For newest versions of OS you may install libmypaint from repository and don't need to build it from source: @@ -47,7 +46,7 @@ $ sudo dnf install libmypaint-devel ### Installing Dependencies on ArchLinux ``` -$ sudo pacman -S base-devel git cmake boost boost-libs qt5-base qt5-svg qt5-script qt5-tools qt5-multimedia lz4 libusb lzo libjpeg-turbo glew freeglut sdl2 freetype2 +$ sudo pacman -S base-devel git cmake boost boost-libs qt5-base qt5-svg qt5-script qt5-tools qt5-multimedia lz4 libusb lzo libjpeg-turbo glew freeglut freetype2 $ sudo pacman -S blas cblas ``` From AUR, using eg. yaourt: @@ -61,7 +60,7 @@ Notes: ### Installing Dependencies on openSUSE ``` -$ zypper in boost-devel cmake freeglut-devel freetype2-devel gcc-c++ glew-devel libQt5OpenGL-devel libSDL2-devel libjpeg-devel liblz4-devel libpng16-compat-devel libqt5-linguist-devel libqt5-qtbase-devel libqt5-qtmultimedia-devel libqt5-qtscript-devel libqt5-qtsvg-devel libtiff-devel libusb-devel lzo-devel openblas-devel pkgconfig sed superlu-devel zlib-devel json-c-devel +$ zypper in boost-devel cmake freeglut-devel freetype2-devel gcc-c++ glew-devel libQt5OpenGL-devel libjpeg-devel liblz4-devel libpng16-compat-devel libqt5-linguist-devel libqt5-qtbase-devel libqt5-qtmultimedia-devel libqt5-qtscript-devel libqt5-qtsvg-devel libtiff-devel libusb-devel lzo-devel openblas-devel pkgconfig sed superlu-devel zlib-devel json-c-devel ``` For newest versions of OS you may install libmypaint from repository and don't need to build it from source: diff --git a/toonz/sources/CMakeLists.txt b/toonz/sources/CMakeLists.txt index 2b8dab2..e0ac08b 100644 --- a/toonz/sources/CMakeLists.txt +++ b/toonz/sources/CMakeLists.txt @@ -464,7 +464,6 @@ elseif(BUILD_ENV_UNIXLIKE) if(NOT BUILD_TARGET_WIN) pkg_check_modules(USB_LIB REQUIRED libusb-1.0) pkg_check_modules(FREETYPE REQUIRED freetype2) - pkg_check_modules(SDL_LIB REQUIRED sdl2) endif() # Can be 'libmypaint' or 'libmypaint-1.x' pkg_search_module(MYPAINT_LIB REQUIRED libmypaint libmypaint-1.3>=1.3) diff --git a/toonz/sources/common/tapptools/ttimer.cpp b/toonz/sources/common/tapptools/ttimer.cpp deleted file mode 100644 index e56fcaf..0000000 --- a/toonz/sources/common/tapptools/ttimer.cpp +++ /dev/null @@ -1,300 +0,0 @@ - - -#include "ttimer.h" -#include "tthreadmessage.h" -#include "texception.h" - -#ifdef _WIN32 - -#include -#include -#include - -// moto strano: se togliamo l'include della glut non linka -#include - -//------------------------------------------------------------------------------ - -namespace { - -void CALLBACK ElapsedTimeCB(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, - DWORD dw2); -}; - -//------------------------------------------------------------------------------ - -class TTimer::Imp { -public: - Imp(std::string name, UINT timerRes, TTimer::Type type, TTimer *timer); - ~Imp(); - - void start(UINT delay) { - if (m_started) throw TException("The timer is already started"); - - m_timerID = timeSetEvent(delay, m_timerRes, (LPTIMECALLBACK)ElapsedTimeCB, - (DWORD)this, m_type | TIME_CALLBACK_FUNCTION); - - m_delay = delay; - m_ticks = 0; - if (m_timerID == NULL) throw TException("Unable to start timer"); - - m_started = true; - } - - void stop() { - if (m_started) timeKillEvent(m_timerID); - m_started = false; - } - - std::string getName() { return m_name; } - TUINT64 getTicks() { return m_ticks; } - UINT getDelay() { return m_delay; } - - std::string m_name; - - UINT m_timerRes; - UINT m_type; - TTimer *m_timer; - - UINT m_timerID; - UINT m_delay; - TUINT64 m_ticks; - bool m_started; - - TGenericTimerAction *m_action; -}; - -//------------------------------------------------------------------------------ - -TTimer::Imp::Imp(std::string name, UINT timerRes, TTimer::Type type, - TTimer *timer) - : m_name(name) - , m_timerRes(timerRes) - , m_timer(timer) - , m_type(type) - , m_timerID(NULL) - , m_ticks(0) - , m_delay(0) - , m_started(false) - , m_action(0) { - TIMECAPS tc; - - if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR) { - throw TException("Unable to create timer"); - } - - m_timerRes = std::min((int)std::max((int)tc.wPeriodMin, (int)m_timerRes), - (int)tc.wPeriodMax); - timeBeginPeriod(m_timerRes); - - switch (type) { - case TTimer::OneShot: - m_type = TIME_ONESHOT; - break; - - case TTimer::Periodic: - m_type = TIME_PERIODIC; - break; - - default: - throw TException("Unexpected timer type"); - break; - } -} - -//------------------------------------------------------------------------------ - -TTimer::Imp::~Imp() { - stop(); - timeEndPeriod(m_timerRes); - - if (m_action) delete m_action; -} - -//------------------------------------------------------------------------------ - -namespace { - -void CALLBACK ElapsedTimeCB(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, - DWORD dw2) { - TTimer::Imp *imp = reinterpret_cast(dwUser); - imp->m_ticks++; - if (imp->m_action) imp->m_action->sendCommand(imp->m_ticks); -} -}; -#elif defined(LINUX) - -#include -#include -#include "tthread.h" -namespace { -Uint32 ElapsedTimeCB(Uint32 interval, void *param); -} - -class TTimer::Imp { -public: - Imp(std::string name, UINT timerRes, TTimer::Type type, TTimer *timer) - : m_action(0), m_ticks(0) {} - ~Imp() {} - - void start(UINT delay) { - static bool first = true; - if (first) { - SDL_Init(SDL_INIT_TIMER); - first = false; - } - m_timerID = SDL_AddTimer(delay, ElapsedTimeCB, this); - } - - void stop() { SDL_RemoveTimer(m_timerID); } - - std::string getName() { return m_name; } - TUINT64 getTicks() { return m_ticks; } - UINT getDelay() { return m_delay; } - - std::string m_name; - - UINT m_timerRes; - UINT m_type; - TTimer *m_timer; - - SDL_TimerID m_timerID; - UINT m_delay; - TUINT64 m_ticks; - bool m_started; - - TGenericTimerAction *m_action; -}; - -class SendCommandMSG final : public TThread::Message { - TTimer::Imp *m_ztimp; - -public: - SendCommandMSG(TTimer::Imp *ztimp) : TThread::Message(), m_ztimp(ztimp) {} - ~SendCommandMSG() {} - TThread::Message *clone() const { return new SendCommandMSG(*this); } - void onDeliver() { - if (m_ztimp->m_action) m_ztimp->m_action->sendCommand(m_ztimp->m_ticks); - } -}; - -namespace { -Uint32 ElapsedTimeCB(Uint32 interval, void *param) { - TTimer::Imp *imp = reinterpret_cast(param); - imp->m_ticks++; - SendCommandMSG(imp).send(); - return interval; -} -} - -#elif defined(__sgi) -class TTimer::Imp { -public: - Imp(std::string name, UINT timerRes, TTimer::Type type, TTimer *timer) - : m_action(0) {} - ~Imp() {} - - void start(UINT delay) { - if (m_started) throw TException("The timer is already started"); - - m_started = true; - } - - void stop() { m_started = false; } - - std::string getName() { return m_name; } - TUINT64 getTicks() { return m_ticks; } - UINT getDelay() { return m_delay; } - - std::string m_name; - - UINT m_timerRes; - UINT m_type; - TTimer *m_timer; - - UINT m_timerID; - UINT m_delay; - TUINT64 m_ticks; - bool m_started; - - TGenericTimerAction *m_action; -}; -#elif defined(MACOSX) -class TTimer::Imp { -public: - Imp(std::string name, UINT timerRes, TTimer::Type type, TTimer *timer) - : m_action(0) {} - ~Imp() {} - - void start(UINT delay) { - if (m_started) throw TException("The timer is already started"); - throw TException("The timer is not yet available under MAC :("); - m_started = true; - } - - void stop() { m_started = false; } - - std::string getName() { return m_name; } - TUINT64 getTicks() { return m_ticks; } - UINT getDelay() { return m_delay; } - - std::string m_name; - - UINT m_timerRes; - UINT m_type; - TTimer *m_timer; - - UINT m_timerID; - UINT m_delay; - TUINT64 m_ticks; - bool m_started; - - TGenericTimerAction *m_action; -}; - -#endif - -//=============================================================================== -// -// TTimer -// -//=============================================================================== - -TTimer::TTimer(const std::string &name, UINT timerRes, Type type) - : m_imp(new TTimer::Imp(name, timerRes, type, this)) {} - -//-------------------------------------------------------------------------------- - -TTimer::~TTimer() {} - -//-------------------------------------------------------------------------------- - -void TTimer::start(UINT delay) { m_imp->start(delay); } - -//-------------------------------------------------------------------------------- - -bool TTimer::isStarted() const { return m_imp->m_started; } - -//-------------------------------------------------------------------------------- - -void TTimer::stop() { m_imp->stop(); } - -//-------------------------------------------------------------------------------- - -std::string TTimer::getName() const { return m_imp->getName(); } - -//-------------------------------------------------------------------------------- - -TUINT64 TTimer::getTicks() const { return m_imp->getTicks(); } - -//-------------------------------------------------------------------------------- - -UINT TTimer::getDelay() const { return m_imp->getDelay(); } - -//-------------------------------------------------------------------------------- - -void TTimer::setAction(TGenericTimerAction *action) { - if (m_imp->m_action) delete m_imp->m_action; - - m_imp->m_action = action; -} diff --git a/toonz/sources/include/ttimer.h b/toonz/sources/include/ttimer.h deleted file mode 100644 index c448926..0000000 --- a/toonz/sources/include/ttimer.h +++ /dev/null @@ -1,111 +0,0 @@ -#pragma once - -#ifndef TTIMER_INCLUDED -#define TTIMER_INCLUDED - -#include - -#include "tcommon.h" - -#undef DVAPI -#undef DVVAR -#ifdef TAPPTOOLS_EXPORTS -#define DVAPI DV_EXPORT_API -#define DVVAR DV_EXPORT_VAR -#else -#define DVAPI DV_IMPORT_API -#define DVVAR DV_IMPORT_VAR -#endif - -//------------------------------------------------------------------- - -class DVAPI TGenericTimerAction { -public: - virtual ~TGenericTimerAction() {} - virtual void sendCommand(TUINT64 tick) = 0; -}; - -//------------------------------------------------------------------- - -template -class TTimerAction final : public TGenericTimerAction { -public: - typedef void (T::*Method)(TUINT64 tick); - TTimerAction(T *target, Method method) : m_target(target), m_method(method) {} - void sendCommand(TUINT64 tick) override { (m_target->*m_method)(tick); } - -private: - T *m_target; - Method m_method; -}; - -//------------------------------------------------------------------------------ -//! THis class is manages general time events. -/*! - This class defines a timer, - i.e a system which, at user defined time steps, sends events - through a callback function. - */ -class DVAPI TTimer { -public: - /*! - Specifies which is the type of timer of this object. - */ - enum Type { - OneShot, /*!< This type of timer sends timer events only at a single time. - */ - Periodic /*!< This type of timer sends timer events periodically. */ - }; - - /*! - Creates a timer with name \p name, resolution \p timerRes and type \p - type. - Resolution is expressed in milliseconds. - */ - TTimer(const std::string &name, UINT timerRes, Type type); - /*! - Deletes the timer. - */ - ~TTimer(); - - /*! - Starts the timer after \p delay milliseconds. - */ - void start(UINT delay); // delay expressed in milliseconds - /*! -Stops the timer immediately. -Doesn't delete the timer. -*/ - void stop(); - /*! - Returns \p true if the timer is started. - */ - bool isStarted() const; - /*! - Returns the name of the timer. - */ - std::string getName() const; - /*! - Asks the timer for number of events so far. - */ - TUINT64 getTicks() const; - /*! - Returns the initial start delay of the timer. - */ - UINT getDelay() const; - /*! - Sets the callback function, i.e. the function to be called every - timer's shot. - */ - void setAction(TGenericTimerAction *action); - - class Imp; - -private: - std::unique_ptr m_imp; - - TTimer(const TTimer &); - void operator=(const TTimer &); -}; - -#endif diff --git a/toonz/sources/include/tw/valuefield.h b/toonz/sources/include/tw/valuefield.h index 0c6815d..1ed3e61 100644 --- a/toonz/sources/include/tw/valuefield.h +++ b/toonz/sources/include/tw/valuefield.h @@ -4,7 +4,6 @@ #define TNZ_VALUEFIELD_INCLUDED #include "tw/tw.h" -#include "ttimer.h" #undef DVAPI #undef DVVAR @@ -132,7 +131,6 @@ protected: // servono nel drag int m_deltaPos; int m_flags; - TTimer m_timer; TRect m_sliderRect, m_arrow0Rect, m_arrow1Rect; TNumField *m_textField0, *m_textField1; bool m_arrowEnabled, m_sliderEnabled; diff --git a/toonz/sources/tnzbase/CMakeLists.txt b/toonz/sources/tnzbase/CMakeLists.txt index f7cbc45..acfa539 100644 --- a/toonz/sources/tnzbase/CMakeLists.txt +++ b/toonz/sources/tnzbase/CMakeLists.txt @@ -55,7 +55,6 @@ set(HEADERS ${MOC_HEADERS} ../include/tcli.h ../include/tcolorutils.h ../include/tparamundo.h - ../include/ttimer.h ../include/ttest.h ../include/texpression.h ../include/tgrammar.h @@ -103,7 +102,6 @@ set(SOURCES ../common/tapptools/tcli.cpp ../common/tapptools/tcolorutils.cpp ../common/tapptools/tparamundo.cpp - ../common/tapptools/ttimer.cpp ../common/ttest/ttest.cpp ../common/expressions/texpression.cpp ../common/expressions/tgrammar.cpp @@ -208,15 +206,6 @@ elseif(BUILD_ENV_APPLE) ) elseif(BUILD_ENV_UNIXLIKE) _find_toonz_library(EXTRA_LIBS "tnzcore") - if(NOT BUILD_TARGET_WIN) - set(EXTRA_LIBS ${EXTRA_LIBS} - ${SDL_LIB_LIBRARIES} - ) - include_directories( - SYSTEM - ${SDL_LIB_INCLUDE_DIRS} - ) - endif() endif() target_link_libraries(tnzbase Qt5::Core Qt5::Gui ${EXTRA_LIBS}) diff --git a/toonz/sources/toonz/flipbook.cpp b/toonz/sources/toonz/flipbook.cpp index 3ec293c..0808df0 100644 --- a/toonz/sources/toonz/flipbook.cpp +++ b/toonz/sources/toonz/flipbook.cpp @@ -3,7 +3,6 @@ // System includes #include "tsystem.h" #include "timagecache.h" -#include "ttimer.h" // Geometry #include "tgeometry.h" diff --git a/toonz/sources/toonz/previewer.cpp b/toonz/sources/toonz/previewer.cpp index 6ace624..797caa7 100644 --- a/toonz/sources/toonz/previewer.cpp +++ b/toonz/sources/toonz/previewer.cpp @@ -6,7 +6,6 @@ #include "timagecache.h" #include "tstopwatch.h" #include "tfiletype.h" -#include "ttimer.h" // Images includes #include "trasterimage.h"