diff --git a/synfig-core/src/modules/lyr_freetype/lyr_freetype.cpp b/synfig-core/src/modules/lyr_freetype/lyr_freetype.cpp index 49eee8b..581c8cd 100644 --- a/synfig-core/src/modules/lyr_freetype/lyr_freetype.cpp +++ b/synfig-core/src/modules/lyr_freetype/lyr_freetype.cpp @@ -481,7 +481,7 @@ Layer_Freetype::new_face(const String &newfont) bool Layer_Freetype::set_param(const String & param, const ValueBase &value) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex); /* if(param=="font" && value.same_type_as(font)) { diff --git a/synfig-core/src/modules/lyr_freetype/lyr_freetype.h b/synfig-core/src/modules/lyr_freetype/lyr_freetype.h index bc9e4c3..8ce34b0 100644 --- a/synfig-core/src/modules/lyr_freetype/lyr_freetype.h +++ b/synfig-core/src/modules/lyr_freetype/lyr_freetype.h @@ -70,9 +70,6 @@ /* === C L A S S E S & S T R U C T S ======================================= */ using namespace synfig; -using namespace std; -using namespace etl; - struct Glyph { @@ -150,7 +147,7 @@ private: synfig::Color color_func(const synfig::Point &x, int quality=10, synfig::ColorReal supersample=0)const; - mutable std::mutex mutex_; + mutable std::mutex mutex; public: Layer_Freetype(); diff --git a/synfig-core/src/modules/mod_particle/plant.cpp b/synfig-core/src/modules/mod_particle/plant.cpp index 7221d48..614229b 100644 --- a/synfig-core/src/modules/mod_particle/plant.cpp +++ b/synfig-core/src/modules/mod_particle/plant.cpp @@ -223,7 +223,7 @@ Plant::sync()const int splits=param_splits.get(int()); bool use_width=param_use_width.get(bool()); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex); if (!needs_sync_) return; time_t start_time; time(&start_time); particle_list.clear(); diff --git a/synfig-core/src/modules/mod_particle/plant.h b/synfig-core/src/modules/mod_particle/plant.h index 08db880..6053e43 100644 --- a/synfig-core/src/modules/mod_particle/plant.h +++ b/synfig-core/src/modules/mod_particle/plant.h @@ -46,7 +46,6 @@ /* === C L A S S E S & S T R U C T S ======================================= */ using namespace synfig; -using namespace std; using namespace etl; class Plant : public Layer_Composite, public Layer_NoDeform @@ -104,7 +103,7 @@ private: Real mass; mutable bool needs_sync_; - mutable mutex mutex_; + mutable std::mutex mutex; void branch(int n, int depth,float t, float stunt_growth, Point position,Vector velocity)const; void sync()const; diff --git a/synfig-core/src/synfig/debug/log.cpp b/synfig-core/src/synfig/debug/log.cpp index 33cde88..c335285 100644 --- a/synfig-core/src/synfig/debug/log.cpp +++ b/synfig-core/src/synfig/debug/log.cpp @@ -53,11 +53,11 @@ using namespace debug; /* === M E T H O D S ======================================================= */ -std::mutex Log::mutex_; +std::mutex Log::mutex; void Log::append_line_to_file(const String &logfile, const String &str) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex); std::ofstream f(logfile.c_str(), std::ios_base::app); f << str << std::endl; } diff --git a/synfig-core/src/synfig/debug/log.h b/synfig-core/src/synfig/debug/log.h index 272172b..65e196b 100644 --- a/synfig-core/src/synfig/debug/log.h +++ b/synfig-core/src/synfig/debug/log.h @@ -44,7 +44,7 @@ namespace debug { class Log { private: - static std::mutex mutex_; + static std::mutex mutex; public: diff --git a/synfig-core/src/synfig/debug/measure.cpp b/synfig-core/src/synfig/debug/measure.cpp index cf248ce..9497764 100644 --- a/synfig-core/src/synfig/debug/measure.cpp +++ b/synfig-core/src/synfig/debug/measure.cpp @@ -52,12 +52,12 @@ using namespace debug; /* === M E T H O D S ======================================================= */ -Glib::Threads::Mutex Measure::mutex; +std::mutex Measure::mutex; std::vector Measure::stack; String Measure::text; void Measure::init() { - Glib::Threads::Mutex::Lock lock(mutex); + std::lock_guard lock(mutex); hide = !stack.empty() && stack.back()->hide_subs; hide_subs = hide_subs || hide; if (!hide) @@ -71,7 +71,7 @@ void Measure::init() { } Measure::~Measure() { - Glib::Threads::Mutex::Lock lock(mutex); + std::lock_guard lock(mutex); long long dt = g_get_monotonic_time() - t; long long cpu_dt = clock() - cpu_t; diff --git a/synfig-core/src/synfig/debug/measure.h b/synfig-core/src/synfig/debug/measure.h index 940deef..12e8d86 100644 --- a/synfig-core/src/synfig/debug/measure.h +++ b/synfig-core/src/synfig/debug/measure.h @@ -29,7 +29,7 @@ #include -#include +#include #include @@ -46,7 +46,7 @@ namespace debug { class Measure { private: - static Glib::Threads::Mutex mutex; + static std::mutex mutex; static std::vector stack; static String text; diff --git a/synfig-core/src/synfig/layers/layer_bitmap.cpp b/synfig-core/src/synfig/layers/layer_bitmap.cpp index d8b0fae..ad6cf25 100644 --- a/synfig-core/src/synfig/layers/layer_bitmap.cpp +++ b/synfig-core/src/synfig/layers/layer_bitmap.cpp @@ -257,7 +257,7 @@ synfig::Layer_Bitmap::get_color(Context context, const Point &pos)const surface_pos[1]/=br[1]-tl[1]; if(surface_pos[1]<=1.0 && surface_pos[1]>=0.0) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex); if (trimmed) { @@ -364,7 +364,7 @@ Layer_Bitmap::accelerated_render(Context context,Surface *surface,int quality, c { RENDER_TRANSFORMED_IF_NEED(__FILE__, __LINE__) - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex); Point tl(param_tl.get(Point())); Point br(param_br.get(Point())); diff --git a/synfig-core/src/synfig/layers/layer_bitmap.h b/synfig-core/src/synfig/layers/layer_bitmap.h index ff98b7a..3071206 100644 --- a/synfig-core/src/synfig/layers/layer_bitmap.h +++ b/synfig-core/src/synfig/layers/layer_bitmap.h @@ -60,7 +60,7 @@ public: ValueBase param_c; ValueBase param_gamma_adjust; - mutable std::mutex mutex_; + mutable std::mutex mutex; mutable rendering::software::PackedSurface::Reader reader; mutable rendering::SurfaceResource::Handle rendering_surface; mutable bool trimmed; diff --git a/synfig-core/src/synfig/layers/layer_duplicate.cpp b/synfig-core/src/synfig/layers/layer_duplicate.cpp index 251f8a2..edd58ce 100644 --- a/synfig-core/src/synfig/layers/layer_duplicate.cpp +++ b/synfig-core/src/synfig/layers/layer_duplicate.cpp @@ -121,7 +121,7 @@ Layer_Duplicate::get_color(Context context, const Point &pos)const float amount(get_amount()); Color color; - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex); Time time_cur = get_time_mark(); duplicate_param->reset_index(time_cur); do @@ -187,7 +187,7 @@ Layer_Duplicate::accelerated_render(Context context,Surface *surface,int quality Time time_cur = get_time_mark(); int steps = duplicate_param->count_steps(time_cur); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex); duplicate_param->reset_index(time_cur); do { @@ -233,7 +233,7 @@ Layer_Duplicate::accelerated_cairorender(Context context, cairo_t *cr, int quali Time time_cur = get_time_mark(); int steps = duplicate_param->count_steps(time_cur); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex); duplicate_param->reset_index(time_cur); cairo_save(cr); do @@ -269,7 +269,7 @@ Layer_Duplicate::build_rendering_task_vfunc(Context context) const rendering::Task::Handle task; - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex); duplicate_param->reset_index(time_cur); do { diff --git a/synfig-core/src/synfig/layers/layer_duplicate.h b/synfig-core/src/synfig/layers/layer_duplicate.h index 15caeff..6701574 100644 --- a/synfig-core/src/synfig/layers/layer_duplicate.h +++ b/synfig-core/src/synfig/layers/layer_duplicate.h @@ -42,7 +42,7 @@ class Layer_Duplicate : public synfig::Layer_CompositeFork private: mutable ValueBase param_index; - mutable std::mutex mutex_; + mutable std::mutex mutex; public: diff --git a/synfig-core/src/synfig/main.cpp b/synfig-core/src/synfig/main.cpp index 0cef8ec..bae475f 100644 --- a/synfig-core/src/synfig/main.cpp +++ b/synfig-core/src/synfig/main.cpp @@ -86,7 +86,6 @@ #define PATH_MAX 4096 #endif -using namespace std; using namespace etl; using namespace synfig; @@ -101,13 +100,13 @@ Main *Main::instance = NULL; class GeneralIOMutexHolder { private: - mutex mutex_; + std::mutex mutex; bool initialized; public: GeneralIOMutexHolder(): initialized(true) { } ~GeneralIOMutexHolder() { initialized = false; } - void lock() { if (initialized) mutex_.lock(); } - void unlock() { if (initialized) mutex_.unlock(); } + void lock() { if (initialized) mutex.lock(); } + void unlock() { if (initialized) mutex.unlock(); } }; GeneralIOMutexHolder general_io_mutex; @@ -447,7 +446,7 @@ void synfig::error(const String &str) { general_io_mutex.lock(); - cerr<<"\033[31m"<<"synfig("< Map; private: - std::mutex mutex_; + std::mutex mutex; Map map; public: Node* get(const GUID &guid) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex); Map::iterator i = map.find(guid); return i == map.end() ? nullptr : i->second; } @@ -86,7 +86,7 @@ namespace { assert(guid); assert(node); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex); assert(!map.count(guid)); map[guid] = node; } @@ -95,7 +95,7 @@ namespace { assert(guid); assert(node); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex); Map::iterator i = map.find(guid); assert(i != map.end() && i->second == node); map.erase(i); @@ -110,7 +110,7 @@ namespace { } assert(oldguid); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex); Map::iterator i = map.find(oldguid); assert(i != map.end() && i->second == node); map.erase(i); diff --git a/synfig-core/src/synfig/rendering/opengl/internal/context.h b/synfig-core/src/synfig/rendering/opengl/internal/context.h index 2e7d112..d7d8e39 100644 --- a/synfig-core/src/synfig/rendering/opengl/internal/context.h +++ b/synfig-core/src/synfig/rendering/opengl/internal/context.h @@ -32,7 +32,7 @@ #include #include -#include +#include #include #include @@ -97,7 +97,7 @@ public: }; private: - Glib::Threads::RecMutex rec_mutex; + std::recursive_mutex rec_mutex; Display *display; GLXFBConfig config; diff --git a/synfig-core/src/synfig/rendering/software/function/fft.cpp b/synfig-core/src/synfig/rendering/software/function/fft.cpp index 1dc8936..14282ca 100644 --- a/synfig-core/src/synfig/rendering/software/function/fft.cpp +++ b/synfig-core/src/synfig/rendering/software/function/fft.cpp @@ -33,7 +33,7 @@ #include //#include -#include +#include #include #include @@ -59,11 +59,11 @@ class software::FFT::Internal { public: static std::set counts; - static Glib::Mutex mutex; + static std::mutex mutex; }; std::set software::FFT::Internal::counts; -Glib::Mutex software::FFT::Internal::mutex; +std::mutex software::FFT::Internal::mutex; void software::FFT::initialize() @@ -118,7 +118,7 @@ software::FFT::fft(const Array &x, bool invert) iodim.os = x.stride; { - Glib::Mutex::Lock lock(Internal::mutex); + std::lock_guard lock(Internal::mutex); fftw_plan plan = fftw_plan_guru_dft( 1, &iodim, 0, NULL, (fftw_complex*)x.pointer, (fftw_complex*)x.pointer, @@ -153,7 +153,7 @@ software::FFT::fft2d(const Array &x, bool invert, bool do_rows, bool iodim[1].os = x.stride; { - Glib::Mutex::Lock lock(Internal::mutex); + std::lock_guard lock(Internal::mutex); fftw_plan plan; if (do_rows && do_cols) diff --git a/synfig-core/src/synfig/rendering/software/function/packedsurface.cpp b/synfig-core/src/synfig/rendering/software/function/packedsurface.cpp index 11de59e..4843126 100644 --- a/synfig-core/src/synfig/rendering/software/function/packedsurface.cpp +++ b/synfig-core/src/synfig/rendering/software/function/packedsurface.cpp @@ -89,7 +89,7 @@ PackedSurface::Reader::open(const PackedSurface &surface) { this->surface = &surface; - std::lock_guard lock(surface.mutex_); + std::lock_guard lock(surface.mutex); surface.readers.insert(this); } @@ -120,7 +120,7 @@ PackedSurface::Reader::close() if (is_opened()) { { - std::lock_guard lock(surface->mutex_); + std::lock_guard lock(surface->mutex); surface->readers.erase(this); } if (cache) delete[] cache; diff --git a/synfig-core/src/synfig/rendering/software/function/packedsurface.h b/synfig-core/src/synfig/rendering/software/function/packedsurface.h index ce5ed5a..72e5c7e 100644 --- a/synfig-core/src/synfig/rendering/software/function/packedsurface.h +++ b/synfig-core/src/synfig/rendering/software/function/packedsurface.h @@ -128,7 +128,7 @@ public: typedef etl::sampler Sampler; private: - mutable std::mutex mutex_; + mutable std::mutex mutex; mutable std::set readers; int width; diff --git a/synfig-core/src/synfig/rendering/surface.cpp b/synfig-core/src/synfig/rendering/surface.cpp index 6c68716..8c2f73a 100644 --- a/synfig-core/src/synfig/rendering/surface.cpp +++ b/synfig-core/src/synfig/rendering/surface.cpp @@ -225,7 +225,7 @@ SurfaceResource::get_surface( if (!full && !rect.is_valid()) return Surface::Handle(); - Glib::Threads::Mutex::Lock lock(mutex); + std::lock_guard lock(mutex); if (width <= 0 || height <= 0) return Surface::Handle(); @@ -281,7 +281,7 @@ void SurfaceResource::create(int width, int height) { Glib::Threads::RWLock::WriterLock lock(rwlock); - Glib::Threads::Mutex::Lock short_lock(mutex); + std::lock_guard short_lock(mutex); if (width > 0 && height > 0) { this->width = width; this->height = height; @@ -297,7 +297,7 @@ void SurfaceResource::assign(Surface::Handle surface) { Glib::Threads::RWLock::WriterLock lock(rwlock); - Glib::Threads::Mutex::Lock short_lock(mutex); + std::lock_guard short_lock(mutex); for(Map::const_iterator i = surfaces.begin(); i != surfaces.end(); ++i) if (i->second == surface) @@ -320,7 +320,7 @@ void SurfaceResource::clear() { Glib::Threads::RWLock::WriterLock lock(rwlock); - Glib::Threads::Mutex::Lock short_lock(mutex); + std::lock_guard short_lock(mutex); blank = true; surfaces.clear(); } @@ -329,7 +329,7 @@ void SurfaceResource::reset() { Glib::Threads::RWLock::WriterLock lock(rwlock); - Glib::Threads::Mutex::Lock short_lock(mutex); + std::lock_guard short_lock(mutex); width = 0; height = 0; blank = true; diff --git a/synfig-core/src/synfig/rendering/surface.h b/synfig-core/src/synfig/rendering/surface.h index b709e2c..032b404 100644 --- a/synfig-core/src/synfig/rendering/surface.h +++ b/synfig-core/src/synfig/rendering/surface.h @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -330,7 +331,7 @@ private: bool blank; Map surfaces; - mutable Glib::Threads::Mutex mutex; + mutable std::mutex mutex; mutable Glib::Threads::RWLock rwlock; Surface::Handle get_surface( @@ -357,22 +358,22 @@ public: int get_id() const //!< helps to debug of renderer optimizers { return id; } int get_width() const - { Glib::Threads::Mutex::Lock lock(mutex); return width; } + { std::lock_guard lock(mutex); return width; } int get_height() const - { Glib::Threads::Mutex::Lock lock(mutex); return height; } + { std::lock_guard lock(mutex); return height; } VectorInt get_size() const - { Glib::Threads::Mutex::Lock lock(mutex); return VectorInt(width, height); } + { std::lock_guard lock(mutex); return VectorInt(width, height); } bool is_exists() const - { Glib::Threads::Mutex::Lock lock(mutex); return width > 0 && height > 0; } + { std::lock_guard lock(mutex); return width > 0 && height > 0; } bool is_blank() const - { Glib::Threads::Mutex::Lock lock(mutex); return blank; } + { std::lock_guard lock(mutex); return blank; } bool has_surface(const Surface::Token::Handle &token) const - { Glib::Threads::Mutex::Lock lock(mutex); return surfaces.count(token); } + { std::lock_guard lock(mutex); return surfaces.count(token); } template bool has_surface() const { return has_surface(T::token.handle()); } bool get_tokens(std::vector &outTokens) const { - Glib::Threads::Mutex::Lock lock(mutex); + std::lock_guard lock(mutex); for(Map::const_iterator i = surfaces.begin(); i != surfaces.end(); ++i) outTokens.push_back(i->first); return !surfaces.empty(); diff --git a/synfig-studio/src/gui/workarearenderer/renderer_canvas.cpp b/synfig-studio/src/gui/workarearenderer/renderer_canvas.cpp index 76ab73b..0ebf256 100644 --- a/synfig-studio/src/gui/workarearenderer/renderer_canvas.cpp +++ b/synfig-studio/src/gui/workarearenderer/renderer_canvas.cpp @@ -238,7 +238,7 @@ Renderer_Canvas::on_tile_finished(bool success, const Tile::Handle &tile) if (success && tile->surface) cairo_surface = convert(tile->surface, tile->rect.get_width(), tile->rect.get_height()); - Glib::Threads::Mutex::Lock lock(mutex); + std::lock_guard lock(mutex); --enqueued_tasks; @@ -267,7 +267,7 @@ Renderer_Canvas::on_post_tile_finished(const Tile::Handle &tile) int local_enqueued_tasks; Time time; { - Glib::Threads::Mutex::Lock lock(mutex); + std::lock_guard lock(mutex); time = tile->frame_id.time; if (visible_frames.count(tile->frame_id)) tile_visible = true; @@ -519,7 +519,7 @@ Renderer_Canvas::enqueue_render() rendering::Task::List events; { - Glib::Threads::Mutex::Lock lock(mutex); + std::lock_guard lock(mutex); String renderer_name = get_work_area()->get_renderer(); RectInt window_rect = get_work_area()->get_window_rect(); @@ -620,7 +620,7 @@ Renderer_Canvas::wait_render() { rendering::TaskEvent::List events; { - Glib::Threads::Mutex::Lock lock(mutex); + std::lock_guard lock(mutex); for(FrameList::const_iterator i = onion_frames.begin(); i != onion_frames.end(); ++i) { TileMap::const_iterator ii = tiles.find(i->id); if (ii != tiles.end()) @@ -639,7 +639,7 @@ Renderer_Canvas::clear_render() rendering::Task::List events; bool cleared = false; { - Glib::Threads::Mutex::Lock lock(mutex); + std::lock_guard lock(mutex); cleared = !tiles.empty(); for(TileMap::iterator i = tiles.begin(); i != tiles.end(); ++i) while(!i->second.empty()) { @@ -700,7 +700,7 @@ Renderer_Canvas::calc_frame_status(const FrameId &id, const RectInt &window_rect void Renderer_Canvas::get_render_status(StatusMap &out_map) { - Glib::Threads::Mutex::Lock lock(mutex); + std::lock_guard lock(mutex); RectInt window_rect = get_work_area()->get_window_rect(); @@ -777,7 +777,7 @@ Renderer_Canvas::render_vfunc( empty_rects.push_back(previous_rect); { // merge all tiles into single surface - Glib::Threads::Mutex::Lock lock(mutex); + std::lock_guard lock(mutex); if (onion_frames.empty()) return; @@ -902,7 +902,7 @@ Renderer_Canvas::render_vfunc( Cairo::RefPtr Renderer_Canvas::get_thumb(const Time &time) { - Glib::Threads::Mutex::Lock lock(mutex); + std::lock_guard lock(mutex); TileMap::const_iterator i = tiles.find( current_thumb.with_time(time) ); return i == tiles.end() || i->second.empty() || !*(i->second.begin()) ? Cairo::RefPtr() diff --git a/synfig-studio/src/gui/workarearenderer/renderer_canvas.h b/synfig-studio/src/gui/workarearenderer/renderer_canvas.h index d3e50bd..e3673e2 100644 --- a/synfig-studio/src/gui/workarearenderer/renderer_canvas.h +++ b/synfig-studio/src/gui/workarearenderer/renderer_canvas.h @@ -33,8 +33,6 @@ #include #include -#include - #include #include #include @@ -149,7 +147,7 @@ private: const int max_enqueued_tasks; //! controls access to fields: enqueued_tasks, tiles, onion_frames, visible_frames, current_frame, frame_duration, tiles_size - Glib::Threads::Mutex mutex; + std::mutex mutex; int enqueued_tasks; diff --git a/synfig-studio/src/synfigapp/actions/layerpaint.cpp b/synfig-studio/src/synfigapp/actions/layerpaint.cpp index b44fd25..5972d8a 100644 --- a/synfig-studio/src/synfigapp/actions/layerpaint.cpp +++ b/synfig-studio/src/synfigapp/actions/layerpaint.cpp @@ -154,7 +154,7 @@ Action::LayerPaint::PaintStroke::add_point_and_apply(const PaintPoint &point) int w = wrapper.surface->get_w(); int h = wrapper.surface->get_h(); { - std::lock_guard lock(layer->mutex_); + std::lock_guard lock(layer->mutex); brush_.stroke_to(&wrapper, point.x, point.y, point.pressure, 0.f, 0.f, point.dtime); // fix state in case of surface resized @@ -219,7 +219,7 @@ Action::LayerPaint::PaintStroke::undo() assert(prepared); if (!applied) return; { - std::lock_guard lock(layer->mutex_); + std::lock_guard lock(layer->mutex); Surface *surface = new Surface(); paint_prev(*surface); layer->rendering_surface = new rendering::SurfaceResource( @@ -237,7 +237,7 @@ Action::LayerPaint::PaintStroke::apply() assert(prepared); if (applied) return; { - std::lock_guard lock(layer->mutex_); + std::lock_guard lock(layer->mutex); Surface *surface = new Surface(); paint_self(*surface); layer->rendering_surface = new rendering::SurfaceResource(