diff --git a/synfig-core/src/modules/lyr_std/clamp.cpp b/synfig-core/src/modules/lyr_std/clamp.cpp index 9bde682..d03c59b 100644 --- a/synfig-core/src/modules/lyr_std/clamp.cpp +++ b/synfig-core/src/modules/lyr_std/clamp.cpp @@ -44,7 +44,7 @@ #include #include -#include +#include #endif @@ -71,6 +71,144 @@ SYNFIG_LAYER_SET_CVS_ID(Layer_Clamp,"$Id$"); /* === E N T R Y P O I N T ================================================= */ + +void +TaskClampSW::split(const RectInt &sub_target_rect) +{ + trunc_target_rect(sub_target_rect); + if (valid_target() && sub_task() && sub_task()->valid_target()) + { + sub_task() = sub_task()->clone(); + sub_task()->trunc_target_rect( + get_target_rect() + - get_target_offset() + - get_offset() ); + } +} + +void +TaskClampSW::clamp_pixel(Color &dst, const Color &src) const +{ + if (fabs(src.get_a()) < 1e-8) + { dst = Color::alpha(); return; } + + dst = src; + + if (invert_negative) + { + if (dst.get_a() < floor) + dst = -dst; + + if(dst.get_r() < floor) + { + dst.set_g(dst.get_g() - dst.get_r()); + dst.set_b(dst.get_b() - dst.get_r()); + dst.set_r(floor); + } + + if(dst.get_g() < floor) + { + dst.set_r(dst.get_r() - dst.get_g()); + dst.set_b(dst.get_b() - dst.get_g()); + dst.set_g(floor); + } + + if(dst.get_b() < floor) + { + dst.set_g(dst.get_g() - dst.get_b()); + dst.set_r(dst.get_r() - dst.get_b()); + dst.set_b(floor); + } + } + else + if (clamp_floor) + { + if (dst.get_r() < floor) dst.set_r(floor); + if (dst.get_g() < floor) dst.set_g(floor); + if (dst.get_b() < floor) dst.set_b(floor); + if (dst.get_a() < floor) dst.set_a(floor); + } + + if (clamp_ceiling) + { + if (dst.get_r() > ceiling) dst.set_r(ceiling); + if (dst.get_g() > ceiling) dst.set_g(ceiling); + if (dst.get_b() > ceiling) dst.set_b(ceiling); + if (dst.get_a() > ceiling) dst.set_a(ceiling); + } +} + +bool +TaskClampSW::run(RunParams & /* params */) const +{ + const synfig::Surface &a = + rendering::SurfaceSW::Handle::cast_dynamic( sub_task()->target_surface )->get_surface(); + synfig::Surface &c = + rendering::SurfaceSW::Handle::cast_dynamic( target_surface )->get_surface(); + + //debug::DebugSurface::save_to_file(a, "TaskClampSW__run__a"); + + RectInt r = get_target_rect(); + if (r.valid()) + { + VectorInt offset = get_offset(); + RectInt ra = sub_task()->get_target_rect() + r.get_min() + get_offset(); + if (ra.valid()) + { + etl::set_intersect(ra, ra, r); + if (ra.valid()) + { + synfig::Surface::pen pc = c.get_pen(ra.minx, ra.maxx); + synfig::Surface::pen pa = c.get_pen(ra.minx, ra.maxx); + for(int y = ra.miny; y < ra.maxy; ++y) + { + const Color *ca = &a[y - r.miny + offset[1]][ra.minx - r.minx + offset[0]]; + Color *cc = &c[y][ra.minx]; + for(int x = ra.minx; x < ra.maxx; ++x, ++ca, ++cc) + clamp_pixel(*cc, *ca); + } + } + } + } + + //debug::DebugSurface::save_to_file(c, "TaskClampSW__run__c"); + + return true; +} + + +void +OptimizerClampSW::run(const RunParams& params) const +{ + TaskClamp::Handle clamp = TaskClamp::Handle::cast_dynamic(params.ref_task); + if ( clamp + && clamp->target_surface + && clamp.type_equal() ) + { + TaskClampSW::Handle clamp_sw; + init_and_assign_all(clamp_sw, clamp); + + // TODO: Are we really need to check 'is_temporary' flag? + if ( clamp_sw->sub_task()->target_surface->is_temporary ) + { + clamp_sw->sub_task()->target_surface = clamp_sw->target_surface; + clamp_sw->sub_task()->move_target_rect( + clamp_sw->get_target_offset() ); + } + else + { + clamp_sw->sub_task()->set_target_origin( VectorInt::zero() ); + clamp_sw->sub_task()->target_surface->set_size( + clamp_sw->sub_task()->get_target_rect().maxx, + clamp_sw->sub_task()->get_target_rect().maxy ); + } + assert( clamp_sw->sub_task()->check() ); + + apply(params, clamp_sw); + } +} + + Layer_Clamp::Layer_Clamp(): param_invert_negative(ValueBase(false)), param_clamp_ceiling(ValueBase(true)), @@ -229,7 +367,7 @@ Layer_Clamp::get_full_bounding_rect(Context context)const rendering::Task::Handle Layer_Clamp::build_rendering_task_vfunc(Context context)const { - rendering::TaskClamp::Handle task_clamp(new rendering::TaskClamp()); + TaskClamp::Handle task_clamp(new TaskClamp()); task_clamp->invert_negative = param_invert_negative.get(bool()); task_clamp->clamp_ceiling = param_clamp_ceiling.get(bool()); task_clamp->floor = param_floor.get(Real()); diff --git a/synfig-core/src/modules/lyr_std/clamp.h b/synfig-core/src/modules/lyr_std/clamp.h index 2d0a569..b90bc72 100644 --- a/synfig-core/src/modules/lyr_std/clamp.h +++ b/synfig-core/src/modules/lyr_std/clamp.h @@ -30,6 +30,11 @@ #include +#include +#include +#include +#include + /* === M A C R O S ========================================================= */ /* === T Y P E D E F S ===================================================== */ @@ -43,6 +48,55 @@ namespace modules namespace lyr_std { + +class TaskClamp: public rendering::TaskPixelProcessor +{ +public: + typedef etl::handle Handle; + + bool invert_negative; + bool clamp_floor; + bool clamp_ceiling; + Real floor; + Real ceiling; + + TaskClamp(): + invert_negative(false), + clamp_floor(true), + clamp_ceiling(true), + floor(0.0), + ceiling(1.0) { } + Task::Handle clone() const { return clone_pointer(this); } +}; + + +class TaskClampSW: public TaskClamp, public rendering::TaskSW, public rendering::TaskSplittable +{ +private: + void clamp_pixel(Color &dst, const Color &src) const; + +public: + typedef etl::handle Handle; + Task::Handle clone() const { return clone_pointer(this); } + virtual void split(const RectInt &sub_target_rect); + virtual bool run(RunParams ¶ms) const; +}; + + +class OptimizerClampSW: public rendering::Optimizer +{ +public: + OptimizerClampSW() + { + category_id = CATEGORY_ID_SPECIALIZE; + depends_from = CATEGORY_COMMON & CATEGORY_PRE_SPECIALIZE; + for_task = true; + } + + virtual void run(const RunParams ¶ms) const; +}; + + class Layer_Clamp : public Layer { SYNFIG_LAYER_MODULE_EXT diff --git a/synfig-core/src/modules/lyr_std/main.cpp b/synfig-core/src/modules/lyr_std/main.cpp index b0f1704..5af6c09 100644 --- a/synfig-core/src/modules/lyr_std/main.cpp +++ b/synfig-core/src/modules/lyr_std/main.cpp @@ -39,6 +39,7 @@ #include #include +#include #include "zoom.h" //#include "blur.h" @@ -59,8 +60,6 @@ #include "twirl.h" #include "sphere_distort.h" - - #include "shade.h" #include "bevel.h" //#include "halftone2.h" @@ -114,4 +113,7 @@ MODULE_INVENTORY_BEGIN(liblyr_std) LAYER(CurveWarp) LAYER(Layer_FreeTime) END_LAYERS + BEGIN_OPTIMIZERS + OPTIMIZER(OptimizerClampSW) + END_OPTIMIZERS MODULE_INVENTORY_END diff --git a/synfig-core/src/modules/mod_filter/colorcorrect.cpp b/synfig-core/src/modules/mod_filter/colorcorrect.cpp index 18519b4..72ccffc 100644 --- a/synfig-core/src/modules/mod_filter/colorcorrect.cpp +++ b/synfig-core/src/modules/mod_filter/colorcorrect.cpp @@ -44,7 +44,7 @@ #include #include -#include +#include #endif @@ -53,6 +53,8 @@ using namespace etl; using namespace std; using namespace synfig; +using namespace modules; +using namespace mod_filter; /* === G L O B A L S ======================================================= */ @@ -69,6 +71,172 @@ SYNFIG_LAYER_SET_CVS_ID(Layer_ColorCorrect,"$Id$"); /* === E N T R Y P O I N T ================================================= */ +void +TaskColorCorrectSW::split(const RectInt &sub_target_rect) +{ + trunc_target_rect(sub_target_rect); + if (valid_target() && sub_task() && sub_task()->valid_target()) + { + sub_task() = sub_task()->clone(); + sub_task()->trunc_target_rect( + get_target_rect() + - get_target_offset() + - get_offset() ); + } +} + +void +TaskColorCorrectSW::correct_pixel(Color &dst, const Color &src, const Angle &hue_adjust, ColorReal shift, ColorReal amplifier, const Gamma &gamma) const +{ + static const double precision = 1e-8; + + dst = src; + + if (fabs(gamma.get_gamma_r() - 1.0) > precision) + { + if (dst.get_r() < 0) + dst.set_r(-gamma.r_F32_to_F32(-dst.get_r())); + else + dst.set_r(gamma.r_F32_to_F32(dst.get_r())); + } + + if (fabs(gamma.get_gamma_g() - 1.0) > precision) + { + if (dst.get_g() < 0) + dst.set_g(-gamma.g_F32_to_F32(-dst.get_g())); + else + dst.set_g(gamma.g_F32_to_F32(dst.get_g())); + } + + if (fabs(gamma.get_gamma_b() - 1.0) > precision) + { + if (dst.get_b() < 0) + dst.set_b(-gamma.b_F32_to_F32(-dst.get_b())); + else + dst.set_b(gamma.b_F32_to_F32(dst.get_b())); + } + + assert(!isnan(dst.get_r())); + assert(!isnan(dst.get_g())); + assert(!isnan(dst.get_b())); + + if (fabs(amplifier - 1.0) > precision) + { + dst.set_r(dst.get_r()*amplifier); + dst.set_g(dst.get_g()*amplifier); + dst.set_b(dst.get_b()*amplifier); + } + + if (fabs(shift) > precision) + { + // Adjust R Channel Brightness + if (dst.get_r() > -shift) + dst.set_r(dst.get_r() + shift); + else + if(dst.get_r() < shift) + dst.set_r(dst.get_r() - shift); + else + dst.set_r(0); + + // Adjust G Channel Brightness + if (dst.get_g() > -shift) + dst.set_g(dst.get_g() + shift); + else + if(dst.get_g() < shift) + dst.set_g(dst.get_g() - shift); + else + dst.set_g(0); + + // Adjust B Channel Brightness + if (dst.get_b() > -shift) + dst.set_b(dst.get_b() + shift); + else + if(dst.get_b() < shift) + dst.set_b(dst.get_b() - shift); + else + dst.set_b(0); + } + + // Return the color, adjusting the hue if necessary + if (!!hue_adjust) + dst.rotate_uv(hue_adjust); +} + +bool +TaskColorCorrectSW::run(RunParams & /* params */) const +{ + const synfig::Surface &a = + rendering::SurfaceSW::Handle::cast_dynamic( sub_task()->target_surface )->get_surface(); + synfig::Surface &c = + rendering::SurfaceSW::Handle::cast_dynamic( target_surface )->get_surface(); + + //debug::DebugSurface::save_to_file(a, "TaskClampSW__run__a"); + + RectInt r = get_target_rect(); + if (r.valid()) + { + VectorInt offset = get_offset(); + RectInt ra = sub_task()->get_target_rect() + r.get_min() + offset; + if (ra.valid()) + { + etl::set_intersect(ra, ra, r); + if (ra.valid()) + { + ColorReal amplifier = (ColorReal)(contrast*exp(exposure)); + ColorReal shift = (ColorReal)((brightness - 0.5)*contrast + 0.5); + Gamma g(fabs(gamma) < 1e-8 ? 1.0 : 1.0/gamma); + + synfig::Surface::pen pc = c.get_pen(ra.minx, ra.maxx); + synfig::Surface::pen pa = c.get_pen(ra.minx, ra.maxx); + for(int y = ra.miny; y < ra.maxy; ++y) + { + const Color *ca = &a[y - r.miny - offset[1]][ra.minx - r.minx - offset[0]]; + Color *cc = &c[y][ra.minx]; + for(int x = ra.minx; x < ra.maxx; ++x, ++ca, ++cc) + correct_pixel(*cc, *ca, hue_adjust, shift, amplifier, g); + } + } + } + } + + //debug::DebugSurface::save_to_file(c, "TaskClampSW__run__c"); + + return true; +} + + +void +OptimizerColorCorrectSW::run(const RunParams& params) const +{ + TaskColorCorrect::Handle color_correct = TaskColorCorrect::Handle::cast_dynamic(params.ref_task); + if ( color_correct + && color_correct->target_surface + && color_correct.type_equal() ) + { + TaskColorCorrectSW::Handle color_correct_sw; + init_and_assign_all(color_correct_sw, color_correct); + + // TODO: Are we really need to check 'is_temporary' flag? + if ( color_correct_sw->sub_task()->target_surface->is_temporary ) + { + color_correct_sw->sub_task()->target_surface = color_correct_sw->target_surface; + color_correct_sw->sub_task()->move_target_rect( + color_correct_sw->get_target_offset() ); + } + else + { + color_correct_sw->sub_task()->set_target_origin( VectorInt::zero() ); + color_correct_sw->sub_task()->target_surface->set_size( + color_correct_sw->sub_task()->get_target_rect().maxx, + color_correct_sw->sub_task()->get_target_rect().maxy ); + } + assert( color_correct_sw->sub_task()->check() ); + + apply(params, color_correct_sw); + } +} + + Layer_ColorCorrect::Layer_ColorCorrect(): param_hue_adjust(ValueBase(Angle::zero())), param_brightness(ValueBase(Real(0))), @@ -339,7 +507,7 @@ Layer_ColorCorrect::get_full_bounding_rect(Context context)const rendering::Task::Handle Layer_ColorCorrect::build_rendering_task_vfunc(Context context)const { - rendering::TaskColorCorrect::Handle task_color_correct(new rendering::TaskColorCorrect()); + TaskColorCorrect::Handle task_color_correct(new TaskColorCorrect()); task_color_correct->hue_adjust = param_hue_adjust.get(Angle()); task_color_correct->brightness = param_brightness.get(Real()); task_color_correct->contrast = param_contrast.get(Real()); diff --git a/synfig-core/src/modules/mod_filter/colorcorrect.h b/synfig-core/src/modules/mod_filter/colorcorrect.h index f31883e..f1c6212 100644 --- a/synfig-core/src/modules/mod_filter/colorcorrect.h +++ b/synfig-core/src/modules/mod_filter/colorcorrect.h @@ -33,6 +33,11 @@ #include #include +#include +#include +#include +#include + /* === M A C R O S ========================================================= */ /* === T Y P E D E F S ===================================================== */ @@ -40,6 +45,56 @@ /* === C L A S S E S & S T R U C T S ======================================= */ namespace synfig { +namespace modules { +namespace mod_filter { + +class TaskColorCorrect: public rendering::TaskPixelProcessor +{ +public: + typedef etl::handle Handle; + + Angle hue_adjust; + Real brightness; + Real contrast; + Real exposure; + Real gamma; + + TaskColorCorrect(): + hue_adjust(Angle::zero()), + brightness(0.0), + contrast(1.0), + exposure(0.0), + gamma(1.0) { } + Task::Handle clone() const { return clone_pointer(this); } +}; + + +class TaskColorCorrectSW: public TaskColorCorrect, public rendering::TaskSW, public rendering::TaskSplittable +{ +private: + void correct_pixel(Color &dst, const Color &src, const Angle &hue_djust, ColorReal shift, ColorReal amplifier, const Gamma &gamma) const; + +public: + typedef etl::handle Handle; + Task::Handle clone() const { return clone_pointer(this); } + virtual void split(const RectInt &sub_target_rect); + virtual bool run(RunParams ¶ms) const; +}; + + +class OptimizerColorCorrectSW: public rendering::Optimizer +{ +public: + OptimizerColorCorrectSW() + { + category_id = CATEGORY_ID_SPECIALIZE; + depends_from = CATEGORY_COMMON & CATEGORY_PRE_SPECIALIZE; + for_task = true; + } + + virtual void run(const RunParams ¶ms) const; +}; + class Layer_ColorCorrect : public Layer { @@ -82,6 +137,8 @@ public: virtual rendering::Task::Handle build_rendering_task_vfunc(Context context)const; }; // END of class Layer_ColorCorrect +}; // END of namespace mod_filter +}; // END of namespace modules }; // END of namespace synfig /* === E N D =============================================================== */ diff --git a/synfig-core/src/modules/mod_filter/main.cpp b/synfig-core/src/modules/mod_filter/main.cpp index ba044c6..79618aa 100644 --- a/synfig-core/src/modules/mod_filter/main.cpp +++ b/synfig-core/src/modules/mod_filter/main.cpp @@ -40,6 +40,8 @@ #include #include +#include + #include "blur.h" #include "colorcorrect.h" #include "halftone2.h" @@ -49,6 +51,10 @@ #endif +using namespace synfig; +using namespace modules; +using namespace mod_filter; + /* === E N T R Y P O I N T ================================================= */ MODULE_DESC_BEGIN(libmod_filter) @@ -68,4 +74,8 @@ MODULE_INVENTORY_BEGIN(libmod_filter) LAYER(RadialBlur) LAYER(Layer_ColorCorrect) END_LAYERS + BEGIN_OPTIMIZERS + OPTIMIZER(OptimizerColorCorrectSW) + END_OPTIMIZERS + rendering::Renderer::get_renderer("safe")->register_optimizer(new OptimizerColorCorrectSW()); MODULE_INVENTORY_END diff --git a/synfig-core/src/synfig/module.h b/synfig-core/src/synfig/module.h index 069780e..b56e529 100644 --- a/synfig-core/src/synfig/module.h +++ b/synfig-core/src/synfig/module.h @@ -168,9 +168,32 @@ //! Marks the end of the valuenodes in the module's inventory #define END_VALUENODES } +//! Marks the start of the optimizers in the module's inventory +#define BEGIN_OPTIMIZERS { + +//! Registers a optimizer with order and other extra parameters that is defined in the module's inventory +#define OPTIMIZER_ORDER_EXT(renderer, order, optimizer) \ + ::synfig::rendering::Renderer::get_renderer(renderer)-> \ + register_optimizer(order, optimizer); + +//! Registers a optimizer with extra parameters that is defined in the module's inventory +#define OPTIMIZER_EXT(renderer, optimizer) \ + ::synfig::rendering::Renderer::get_renderer(renderer)-> \ + register_optimizer(optimizer); + +//! Registers a optimizer that is defined in the module's inventory +#define OPTIMIZER(optimizer_class) \ + OPTIMIZER_EXT("safe", new optimizer_class()) \ + OPTIMIZER_EXT("software", new optimizer_class()) \ + OPTIMIZER_EXT("gl", new optimizer_class()) + +//! Marks the end of the optimizers in the module's inventory +#define END_OPTIMIZERS } + //! Marks the end of a module's inventory #define MODULE_INVENTORY_END } + /* === T Y P E D E F S ===================================================== */ /* === C L A S S E S & S T R U C T S ======================================= */ diff --git a/synfig-core/src/synfig/rendering/Makefile_insert b/synfig-core/src/synfig/rendering/Makefile_insert index e0fce71..f34d0fe 100644 --- a/synfig-core/src/synfig/rendering/Makefile_insert +++ b/synfig-core/src/synfig/rendering/Makefile_insert @@ -18,7 +18,6 @@ include rendering/common/Makefile_insert if WITH_OPENGL include rendering/opengl/Makefile_insert endif -include rendering/module/Makefile_insert include rendering/primitive/Makefile_insert include rendering/software/Makefile_insert diff --git a/synfig-core/src/synfig/rendering/module/Makefile_insert b/synfig-core/src/synfig/rendering/module/Makefile_insert deleted file mode 100644 index 02a8e51..0000000 --- a/synfig-core/src/synfig/rendering/module/Makefile_insert +++ /dev/null @@ -1,13 +0,0 @@ -RENDERING_MODULE_HH = - -RENDERING_MODULE_CC = - -include rendering/module/common/Makefile_insert -include rendering/module/software/Makefile_insert - -RENDERING_HH += \ - $(RENDERING_MODULE_HH) - -RENDERING_CC += \ - $(RENDERING_MODULE_CC) - diff --git a/synfig-core/src/synfig/rendering/module/common/Makefile_insert b/synfig-core/src/synfig/rendering/module/common/Makefile_insert deleted file mode 100644 index da9d398..0000000 --- a/synfig-core/src/synfig/rendering/module/common/Makefile_insert +++ /dev/null @@ -1,12 +0,0 @@ -RENDERING_MODULE_COMMON_HH = - -RENDERING_MODULE_COMMON_CC = - -include rendering/module/common/task/Makefile_insert - -RENDERING_MODULE_HH += \ - $(RENDERING_MODULE_COMMON_HH) - -RENDERING_MODULE_CC += \ - $(RENDERING_MODULE_COMMON_CC) - diff --git a/synfig-core/src/synfig/rendering/module/common/task/Makefile_insert b/synfig-core/src/synfig/rendering/module/common/task/Makefile_insert deleted file mode 100644 index 784f1ad..0000000 --- a/synfig-core/src/synfig/rendering/module/common/task/Makefile_insert +++ /dev/null @@ -1,12 +0,0 @@ -RENDERING_MODULE_COMMON_TASK_HH = \ - rendering/module/common/task/taskclamp.h \ - rendering/module/common/task/taskcolorcorrect.h - -RENDERING_MODULE_COMMON_TASK_CC = - -RENDERING_MODULE_COMMON_HH += \ - $(RENDERING_MODULE_COMMON_TASK_HH) - -RENDERING_MODULE_COMMON_CC += \ - $(RENDERING_MODULE_COMMON_TASK_CC) - diff --git a/synfig-core/src/synfig/rendering/module/common/task/taskclamp.h b/synfig-core/src/synfig/rendering/module/common/task/taskclamp.h deleted file mode 100644 index 881c888..0000000 --- a/synfig-core/src/synfig/rendering/module/common/task/taskclamp.h +++ /dev/null @@ -1,68 +0,0 @@ -/* === S Y N F I G ========================================================= */ -/*! \file synfig/rendering/module/common/task/taskclamp.h -** \brief TaskClamp Header -** -** $Id$ -** -** \legal -** ......... ... 2016 Ivan Mahonin -** -** This package is free software; you can redistribute it and/or -** modify it under the terms of the GNU General Public License as -** published by the Free Software Foundation; either version 2 of -** the License, or (at your option) any later version. -** -** This package is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -** General Public License for more details. -** \endlegal -*/ -/* ========================================================================= */ - -/* === S T A R T =========================================================== */ - -#ifndef __SYNFIG_RENDERING_MODULE_TASKCLAMP_H -#define __SYNFIG_RENDERING_MODULE_TASKCLAMP_H - -/* === H E A D E R S ======================================================= */ - -#include - -/* === M A C R O S ========================================================= */ - -/* === T Y P E D E F S ===================================================== */ - -/* === C L A S S E S & S T R U C T S ======================================= */ - -namespace synfig -{ -namespace rendering -{ - -class TaskClamp: public TaskPixelProcessor -{ -public: - typedef etl::handle Handle; - - bool invert_negative; - bool clamp_floor; - bool clamp_ceiling; - Real floor; - Real ceiling; - - TaskClamp(): - invert_negative(false), - clamp_floor(true), - clamp_ceiling(true), - floor(0.0), - ceiling(1.0) { } - Task::Handle clone() const { return clone_pointer(this); } -}; - -} /* end namespace rendering */ -} /* end namespace synfig */ - -/* -- E N D ----------------------------------------------------------------- */ - -#endif diff --git a/synfig-core/src/synfig/rendering/module/common/task/taskcolorcorrect.h b/synfig-core/src/synfig/rendering/module/common/task/taskcolorcorrect.h deleted file mode 100644 index e922a13..0000000 --- a/synfig-core/src/synfig/rendering/module/common/task/taskcolorcorrect.h +++ /dev/null @@ -1,68 +0,0 @@ -/* === S Y N F I G ========================================================= */ -/*! \file synfig/rendering/module/common/task/taskcolorcorrect.h -** \brief TaskColorCorrect Header -** -** $Id$ -** -** \legal -** ......... ... 2016 Ivan Mahonin -** -** This package is free software; you can redistribute it and/or -** modify it under the terms of the GNU General Public License as -** published by the Free Software Foundation; either version 2 of -** the License, or (at your option) any later version. -** -** This package is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -** General Public License for more details. -** \endlegal -*/ -/* ========================================================================= */ - -/* === S T A R T =========================================================== */ - -#ifndef __SYNFIG_RENDERING_MODULE_TASKCOLORCORRECT_H -#define __SYNFIG_RENDERING_MODULE_TASKCOLORCORRECT_H - -/* === H E A D E R S ======================================================= */ - -#include - -/* === M A C R O S ========================================================= */ - -/* === T Y P E D E F S ===================================================== */ - -/* === C L A S S E S & S T R U C T S ======================================= */ - -namespace synfig -{ -namespace rendering -{ - -class TaskColorCorrect: public TaskPixelProcessor -{ -public: - typedef etl::handle Handle; - - Angle hue_adjust; - Real brightness; - Real contrast; - Real exposure; - Real gamma; - - TaskColorCorrect(): - hue_adjust(Angle::zero()), - brightness(0.0), - contrast(1.0), - exposure(0.0), - gamma(1.0) { } - Task::Handle clone() const { return clone_pointer(this); } -}; - -} /* end namespace rendering */ -} /* end namespace synfig */ - -/* -- E N D ----------------------------------------------------------------- */ - -#endif diff --git a/synfig-core/src/synfig/rendering/module/software/Makefile_insert b/synfig-core/src/synfig/rendering/module/software/Makefile_insert deleted file mode 100644 index d82d9c3..0000000 --- a/synfig-core/src/synfig/rendering/module/software/Makefile_insert +++ /dev/null @@ -1,13 +0,0 @@ -RENDERING_MODULE_SOFTWARE_HH = - -RENDERING_MODULE_SOFTWARE_CC = - -include rendering/module/software/optimizer/Makefile_insert -include rendering/module/software/task/Makefile_insert - -RENDERING_MODULE_HH += \ - $(RENDERING_MODULE_SOFTWARE_HH) - -RENDERING_MODULE_CC += \ - $(RENDERING_MODULE_SOFTWARE_CC) - diff --git a/synfig-core/src/synfig/rendering/module/software/optimizer/Makefile_insert b/synfig-core/src/synfig/rendering/module/software/optimizer/Makefile_insert deleted file mode 100644 index 1630763..0000000 --- a/synfig-core/src/synfig/rendering/module/software/optimizer/Makefile_insert +++ /dev/null @@ -1,14 +0,0 @@ -RENDERING_MODULE_SOFTWARE_OPTIMIZER_HH = \ - rendering/module/software/optimizer/optimizerclampsw.h \ - rendering/module/software/optimizer/optimizercolorcorrectsw.h - -RENDERING_MODULE_SOFTWARE_OPTIMIZER_CC = \ - rendering/module/software/optimizer/optimizerclampsw.cpp \ - rendering/module/software/optimizer/optimizercolorcorrectsw.cpp - -RENDERING_MODULE_SOFTWARE_HH += \ - $(RENDERING_MODULE_SOFTWARE_OPTIMIZER_HH) - -RENDERING_MODULE_SOFTWARE_CC += \ - $(RENDERING_MODULE_SOFTWARE_OPTIMIZER_CC) - diff --git a/synfig-core/src/synfig/rendering/module/software/optimizer/optimizerclampsw.cpp b/synfig-core/src/synfig/rendering/module/software/optimizer/optimizerclampsw.cpp deleted file mode 100644 index f708a21..0000000 --- a/synfig-core/src/synfig/rendering/module/software/optimizer/optimizerclampsw.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* === S Y N F I G ========================================================= */ -/*! \file synfig/rendering/module/software/optimizer/optimizerclampsw.cpp -** \brief OptimizerClampSW -** -** $Id$ -** -** \legal -** ......... ... 2016 Ivan Mahonin -** -** This package is free software; you can redistribute it and/or -** modify it under the terms of the GNU General Public License as -** published by the Free Software Foundation; either version 2 of -** the License, or (at your option) any later version. -** -** This package is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -** General Public License for more details. -** \endlegal -*/ -/* ========================================================================= */ - -/* === H E A D E R S ======================================================= */ - -#ifdef USING_PCH -# include "pch.h" -#else -#ifdef HAVE_CONFIG_H -# include -#endif - -#ifndef _WIN32 -#include -#include -#include -#endif - -#include "optimizerclampsw.h" - -#include - -#include "../task/taskclampsw.h" - - -#endif - -using namespace synfig; -using namespace rendering; - -/* === M A C R O S ========================================================= */ - -/* === G L O B A L S ======================================================= */ - -/* === P R O C E D U R E S ================================================= */ - -/* === M E T H O D S ======================================================= */ - -void -OptimizerClampSW::run(const RunParams& params) const -{ - TaskClamp::Handle clamp = TaskClamp::Handle::cast_dynamic(params.ref_task); - if ( clamp - && clamp->target_surface - && clamp.type_equal() ) - { - TaskClampSW::Handle clamp_sw; - init_and_assign_all(clamp_sw, clamp); - - // TODO: Are we really need to check 'is_temporary' flag? - if ( clamp_sw->sub_task()->target_surface->is_temporary ) - { - clamp_sw->sub_task()->target_surface = clamp_sw->target_surface; - clamp_sw->sub_task()->move_target_rect( - clamp_sw->get_target_offset() ); - } - else - { - clamp_sw->sub_task()->set_target_origin( VectorInt::zero() ); - clamp_sw->sub_task()->target_surface->set_size( - clamp_sw->sub_task()->get_target_rect().maxx, - clamp_sw->sub_task()->get_target_rect().maxy ); - } - assert( clamp_sw->sub_task()->check() ); - - apply(params, clamp_sw); - } -} - -/* === E N T R Y P O I N T ================================================= */ diff --git a/synfig-core/src/synfig/rendering/module/software/optimizer/optimizerclampsw.h b/synfig-core/src/synfig/rendering/module/software/optimizer/optimizerclampsw.h deleted file mode 100644 index 428ec25..0000000 --- a/synfig-core/src/synfig/rendering/module/software/optimizer/optimizerclampsw.h +++ /dev/null @@ -1,61 +0,0 @@ -/* === S Y N F I G ========================================================= */ -/*! \file synfig/rendering/module/software/optimizer/optimizerclampsw.h -** \brief OptimizerClampSW Header -** -** $Id$ -** -** \legal -** ......... ... 2016 Ivan Mahonin -** -** This package is free software; you can redistribute it and/or -** modify it under the terms of the GNU General Public License as -** published by the Free Software Foundation; either version 2 of -** the License, or (at your option) any later version. -** -** This package is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -** General Public License for more details. -** \endlegal -*/ -/* ========================================================================= */ - -/* === S T A R T =========================================================== */ - -#ifndef __SYNFIG_RENDERING_OPTIMIZERCLAMPSW_H -#define __SYNFIG_RENDERING_OPTIMIZERCLAMPSW_H - -/* === H E A D E R S ======================================================= */ - -#include - -/* === M A C R O S ========================================================= */ - -/* === T Y P E D E F S ===================================================== */ - -/* === C L A S S E S & S T R U C T S ======================================= */ - -namespace synfig -{ -namespace rendering -{ - -class OptimizerClampSW: public Optimizer -{ -public: - OptimizerClampSW() - { - category_id = CATEGORY_ID_SPECIALIZE; - depends_from = CATEGORY_COMMON & CATEGORY_PRE_SPECIALIZE; - for_task = true; - } - - virtual void run(const RunParams ¶ms) const; -}; - -} /* end namespace rendering */ -} /* end namespace synfig */ - -/* -- E N D ----------------------------------------------------------------- */ - -#endif diff --git a/synfig-core/src/synfig/rendering/module/software/optimizer/optimizercolorcorrectsw.cpp b/synfig-core/src/synfig/rendering/module/software/optimizer/optimizercolorcorrectsw.cpp deleted file mode 100644 index 8361427..0000000 --- a/synfig-core/src/synfig/rendering/module/software/optimizer/optimizercolorcorrectsw.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* === S Y N F I G ========================================================= */ -/*! \file synfig/rendering/module/software/optimizer/optimizercolorcorrectsw.cpp -** \brief OptimizerColorCorrectSW -** -** $Id$ -** -** \legal -** ......... ... 2016 Ivan Mahonin -** -** This package is free software; you can redistribute it and/or -** modify it under the terms of the GNU General Public License as -** published by the Free Software Foundation; either version 2 of -** the License, or (at your option) any later version. -** -** This package is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -** General Public License for more details. -** \endlegal -*/ -/* ========================================================================= */ - -/* === H E A D E R S ======================================================= */ - -#ifdef USING_PCH -# include "pch.h" -#else -#ifdef HAVE_CONFIG_H -# include -#endif - -#ifndef _WIN32 -#include -#include -#include -#endif - -#include "optimizercolorcorrectsw.h" - -#include - -#include "../task/taskcolorcorrectsw.h" - - -#endif - -using namespace synfig; -using namespace rendering; - -/* === M A C R O S ========================================================= */ - -/* === G L O B A L S ======================================================= */ - -/* === P R O C E D U R E S ================================================= */ - -/* === M E T H O D S ======================================================= */ - -void -OptimizerColorCorrectSW::run(const RunParams& params) const -{ - TaskColorCorrect::Handle color_correct = TaskColorCorrect::Handle::cast_dynamic(params.ref_task); - if ( color_correct - && color_correct->target_surface - && color_correct.type_equal() ) - { - TaskColorCorrectSW::Handle color_correct_sw; - init_and_assign_all(color_correct_sw, color_correct); - - // TODO: Are we really need to check 'is_temporary' flag? - if ( color_correct_sw->sub_task()->target_surface->is_temporary ) - { - color_correct_sw->sub_task()->target_surface = color_correct_sw->target_surface; - color_correct_sw->sub_task()->move_target_rect( - color_correct_sw->get_target_offset() ); - } - else - { - color_correct_sw->sub_task()->set_target_origin( VectorInt::zero() ); - color_correct_sw->sub_task()->target_surface->set_size( - color_correct_sw->sub_task()->get_target_rect().maxx, - color_correct_sw->sub_task()->get_target_rect().maxy ); - } - assert( color_correct_sw->sub_task()->check() ); - - apply(params, color_correct_sw); - } -} - -/* === E N T R Y P O I N T ================================================= */ diff --git a/synfig-core/src/synfig/rendering/module/software/optimizer/optimizercolorcorrectsw.h b/synfig-core/src/synfig/rendering/module/software/optimizer/optimizercolorcorrectsw.h deleted file mode 100644 index 2ce850e..0000000 --- a/synfig-core/src/synfig/rendering/module/software/optimizer/optimizercolorcorrectsw.h +++ /dev/null @@ -1,61 +0,0 @@ -/* === S Y N F I G ========================================================= */ -/*! \file synfig/rendering/module/software/optimizer/optimizercolorcorrectsw.h -** \brief OptimizerColorCorrectSW Header -** -** $Id$ -** -** \legal -** ......... ... 2016 Ivan Mahonin -** -** This package is free software; you can redistribute it and/or -** modify it under the terms of the GNU General Public License as -** published by the Free Software Foundation; either version 2 of -** the License, or (at your option) any later version. -** -** This package is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -** General Public License for more details. -** \endlegal -*/ -/* ========================================================================= */ - -/* === S T A R T =========================================================== */ - -#ifndef __SYNFIG_RENDERING_OPTIMIZERCOLORCORRECTSW_H -#define __SYNFIG_RENDERING_OPTIMIZERCOLORCORRECTSW_H - -/* === H E A D E R S ======================================================= */ - -#include - -/* === M A C R O S ========================================================= */ - -/* === T Y P E D E F S ===================================================== */ - -/* === C L A S S E S & S T R U C T S ======================================= */ - -namespace synfig -{ -namespace rendering -{ - -class OptimizerColorCorrectSW: public Optimizer -{ -public: - OptimizerColorCorrectSW() - { - category_id = CATEGORY_ID_SPECIALIZE; - depends_from = CATEGORY_COMMON & CATEGORY_PRE_SPECIALIZE; - for_task = true; - } - - virtual void run(const RunParams ¶ms) const; -}; - -} /* end namespace rendering */ -} /* end namespace synfig */ - -/* -- E N D ----------------------------------------------------------------- */ - -#endif diff --git a/synfig-core/src/synfig/rendering/module/software/task/Makefile_insert b/synfig-core/src/synfig/rendering/module/software/task/Makefile_insert deleted file mode 100644 index 8ad3c03..0000000 --- a/synfig-core/src/synfig/rendering/module/software/task/Makefile_insert +++ /dev/null @@ -1,14 +0,0 @@ -RENDERING_MODULE_SOFTWARE_TASK_HH = \ - rendering/module/software/task/taskclampsw.h \ - rendering/module/software/task/taskcolorcorrectsw.h - -RENDERING_MODULE_SOFTWARE_TASK_CC = \ - rendering/module/software/task/taskclampsw.cpp \ - rendering/module/software/task/taskcolorcorrectsw.cpp - -RENDERING_MODULE_SOFTWARE_HH += \ - $(RENDERING_MODULE_SOFTWARE_TASK_HH) - -RENDERING_MODULE_SOFTWARE_CC += \ - $(RENDERING_MODULE_SOFTWARE_TASK_CC) - diff --git a/synfig-core/src/synfig/rendering/module/software/task/taskclampsw.cpp b/synfig-core/src/synfig/rendering/module/software/task/taskclampsw.cpp deleted file mode 100644 index 13ace1c..0000000 --- a/synfig-core/src/synfig/rendering/module/software/task/taskclampsw.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* === S Y N F I G ========================================================= */ -/*! \file synfig/rendering/module/software/task/taskclampsw.cpp -** \brief TaskClampSW -** -** $Id$ -** -** \legal -** ......... ... 2016 Ivan Mahonin -** -** This package is free software; you can redistribute it and/or -** modify it under the terms of the GNU General Public License as -** published by the Free Software Foundation; either version 2 of -** the License, or (at your option) any later version. -** -** This package is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -** General Public License for more details. -** \endlegal -*/ -/* ========================================================================= */ - -/* === H E A D E R S ======================================================= */ - -#ifdef USING_PCH -# include "pch.h" -#else -#ifdef HAVE_CONFIG_H -# include -#endif - -#ifndef _WIN32 -#include -#include -#include -#endif - -#include -#include - -#include "taskclampsw.h" - -#include -#include - -#endif - -using namespace synfig; -using namespace rendering; - -/* === M A C R O S ========================================================= */ - -/* === G L O B A L S ======================================================= */ - -/* === P R O C E D U R E S ================================================= */ - -/* === M E T H O D S ======================================================= */ - -void -TaskClampSW::split(const RectInt &sub_target_rect) -{ - trunc_target_rect(sub_target_rect); - if (valid_target() && sub_task() && sub_task()->valid_target()) - { - sub_task() = sub_task()->clone(); - sub_task()->trunc_target_rect( - get_target_rect() - - get_target_offset() - - get_offset() ); - } -} - -void -TaskClampSW::clamp_pixel(Color &dst, const Color &src) const -{ - if (fabs(src.get_a()) < 1e-8) - { dst = Color::alpha(); return; } - - dst = src; - - if (invert_negative) - { - if (dst.get_a() < floor) - dst = -dst; - - if(dst.get_r() < floor) - { - dst.set_g(dst.get_g() - dst.get_r()); - dst.set_b(dst.get_b() - dst.get_r()); - dst.set_r(floor); - } - - if(dst.get_g() < floor) - { - dst.set_r(dst.get_r() - dst.get_g()); - dst.set_b(dst.get_b() - dst.get_g()); - dst.set_g(floor); - } - - if(dst.get_b() < floor) - { - dst.set_g(dst.get_g() - dst.get_b()); - dst.set_r(dst.get_r() - dst.get_b()); - dst.set_b(floor); - } - } - else - if (clamp_floor) - { - if (dst.get_r() < floor) dst.set_r(floor); - if (dst.get_g() < floor) dst.set_g(floor); - if (dst.get_b() < floor) dst.set_b(floor); - if (dst.get_a() < floor) dst.set_a(floor); - } - - if (clamp_ceiling) - { - if (dst.get_r() > ceiling) dst.set_r(ceiling); - if (dst.get_g() > ceiling) dst.set_g(ceiling); - if (dst.get_b() > ceiling) dst.set_b(ceiling); - if (dst.get_a() > ceiling) dst.set_a(ceiling); - } -} - -bool -TaskClampSW::run(RunParams & /* params */) const -{ - const synfig::Surface &a = - SurfaceSW::Handle::cast_dynamic( sub_task()->target_surface )->get_surface(); - synfig::Surface &c = - SurfaceSW::Handle::cast_dynamic( target_surface )->get_surface(); - - //debug::DebugSurface::save_to_file(a, "TaskClampSW__run__a"); - - RectInt r = get_target_rect(); - if (r.valid()) - { - VectorInt offset = get_offset(); - RectInt ra = sub_task()->get_target_rect() + r.get_min() + get_offset(); - if (ra.valid()) - { - etl::set_intersect(ra, ra, r); - if (ra.valid()) - { - synfig::Surface::pen pc = c.get_pen(ra.minx, ra.maxx); - synfig::Surface::pen pa = c.get_pen(ra.minx, ra.maxx); - for(int y = ra.miny; y < ra.maxy; ++y) - { - const Color *ca = &a[y - r.miny + offset[1]][ra.minx - r.minx + offset[0]]; - Color *cc = &c[y][ra.minx]; - for(int x = ra.minx; x < ra.maxx; ++x, ++ca, ++cc) - clamp_pixel(*cc, *ca); - } - } - } - } - - //debug::DebugSurface::save_to_file(c, "TaskClampSW__run__c"); - - return true; -} - -/* === E N T R Y P O I N T ================================================= */ diff --git a/synfig-core/src/synfig/rendering/module/software/task/taskclampsw.h b/synfig-core/src/synfig/rendering/module/software/task/taskclampsw.h deleted file mode 100644 index 41a8b75..0000000 --- a/synfig-core/src/synfig/rendering/module/software/task/taskclampsw.h +++ /dev/null @@ -1,63 +0,0 @@ -/* === S Y N F I G ========================================================= */ -/*! \file synfig/rendering/module/software/task/taskclampsw.h -** \brief TaskClampSW Header -** -** $Id$ -** -** \legal -** ......... ... 2016 Ivan Mahonin -** -** This package is free software; you can redistribute it and/or -** modify it under the terms of the GNU General Public License as -** published by the Free Software Foundation; either version 2 of -** the License, or (at your option) any later version. -** -** This package is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -** General Public License for more details. -** \endlegal -*/ -/* ========================================================================= */ - -/* === S T A R T =========================================================== */ - -#ifndef __SYNFIG_RENDERING_MODULE_TASKBLENDSW_H -#define __SYNFIG_RENDERING_MODULE_TASKBLENDSW_H - -/* === H E A D E R S ======================================================= */ - -#include "../../common/task/taskclamp.h" - -#include -#include - -/* === M A C R O S ========================================================= */ - -/* === T Y P E D E F S ===================================================== */ - -/* === C L A S S E S & S T R U C T S ======================================= */ - -namespace synfig -{ -namespace rendering -{ - -class TaskClampSW: public TaskClamp, public TaskSW, public TaskSplittable -{ -private: - void clamp_pixel(Color &dst, const Color &src) const; - -public: - typedef etl::handle Handle; - Task::Handle clone() const { return clone_pointer(this); } - virtual void split(const RectInt &sub_target_rect); - virtual bool run(RunParams ¶ms) const; -}; - -} /* end namespace rendering */ -} /* end namespace synfig */ - -/* -- E N D ----------------------------------------------------------------- */ - -#endif diff --git a/synfig-core/src/synfig/rendering/module/software/task/taskcolorcorrectsw.cpp b/synfig-core/src/synfig/rendering/module/software/task/taskcolorcorrectsw.cpp deleted file mode 100644 index 06a77e8..0000000 --- a/synfig-core/src/synfig/rendering/module/software/task/taskcolorcorrectsw.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* === S Y N F I G ========================================================= */ -/*! \file synfig/rendering/module/software/task/taskcolorcorrectsw.cpp -** \brief TaskColorCorrectSW -** -** $Id$ -** -** \legal -** ......... ... 2016 Ivan Mahonin -** -** This package is free software; you can redistribute it and/or -** modify it under the terms of the GNU General Public License as -** published by the Free Software Foundation; either version 2 of -** the License, or (at your option) any later version. -** -** This package is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -** General Public License for more details. -** \endlegal -*/ -/* ========================================================================= */ - -/* === H E A D E R S ======================================================= */ - -#ifdef USING_PCH -# include "pch.h" -#else -#ifdef HAVE_CONFIG_H -# include -#endif - -#ifndef _WIN32 -#include -#include -#include -#endif - -#include -#include - -#include "taskcolorcorrectsw.h" - -#include -#include - -#endif - -using namespace synfig; -using namespace rendering; - -/* === M A C R O S ========================================================= */ - -/* === G L O B A L S ======================================================= */ - -/* === P R O C E D U R E S ================================================= */ - -/* === M E T H O D S ======================================================= */ - -void -TaskColorCorrectSW::split(const RectInt &sub_target_rect) -{ - trunc_target_rect(sub_target_rect); - if (valid_target() && sub_task() && sub_task()->valid_target()) - { - sub_task() = sub_task()->clone(); - sub_task()->trunc_target_rect( - get_target_rect() - - get_target_offset() - - get_offset() ); - } -} - -void -TaskColorCorrectSW::correct_pixel(Color &dst, const Color &src, const Angle &hue_adjust, ColorReal shift, ColorReal amplifier, const Gamma &gamma) const -{ - static const double precision = 1e-8; - - dst = src; - - if (fabs(gamma.get_gamma_r() - 1.0) > precision) - { - if (dst.get_r() < 0) - dst.set_r(-gamma.r_F32_to_F32(-dst.get_r())); - else - dst.set_r(gamma.r_F32_to_F32(dst.get_r())); - } - - if (fabs(gamma.get_gamma_g() - 1.0) > precision) - { - if (dst.get_g() < 0) - dst.set_g(-gamma.g_F32_to_F32(-dst.get_g())); - else - dst.set_g(gamma.g_F32_to_F32(dst.get_g())); - } - - if (fabs(gamma.get_gamma_b() - 1.0) > precision) - { - if (dst.get_b() < 0) - dst.set_b(-gamma.b_F32_to_F32(-dst.get_b())); - else - dst.set_b(gamma.b_F32_to_F32(dst.get_b())); - } - - assert(!isnan(dst.get_r())); - assert(!isnan(dst.get_g())); - assert(!isnan(dst.get_b())); - - if (fabs(amplifier - 1.0) > precision) - { - dst.set_r(dst.get_r()*amplifier); - dst.set_g(dst.get_g()*amplifier); - dst.set_b(dst.get_b()*amplifier); - } - - if (fabs(shift) > precision) - { - // Adjust R Channel Brightness - if (dst.get_r() > -shift) - dst.set_r(dst.get_r() + shift); - else - if(dst.get_r() < shift) - dst.set_r(dst.get_r() - shift); - else - dst.set_r(0); - - // Adjust G Channel Brightness - if (dst.get_g() > -shift) - dst.set_g(dst.get_g() + shift); - else - if(dst.get_g() < shift) - dst.set_g(dst.get_g() - shift); - else - dst.set_g(0); - - // Adjust B Channel Brightness - if (dst.get_b() > -shift) - dst.set_b(dst.get_b() + shift); - else - if(dst.get_b() < shift) - dst.set_b(dst.get_b() - shift); - else - dst.set_b(0); - } - - // Return the color, adjusting the hue if necessary - if (!!hue_adjust) - dst.rotate_uv(hue_adjust); -} - -bool -TaskColorCorrectSW::run(RunParams & /* params */) const -{ - const synfig::Surface &a = - SurfaceSW::Handle::cast_dynamic( sub_task()->target_surface )->get_surface(); - synfig::Surface &c = - SurfaceSW::Handle::cast_dynamic( target_surface )->get_surface(); - - //debug::DebugSurface::save_to_file(a, "TaskClampSW__run__a"); - - RectInt r = get_target_rect(); - if (r.valid()) - { - VectorInt offset = get_offset(); - RectInt ra = sub_task()->get_target_rect() + r.get_min() + offset; - if (ra.valid()) - { - etl::set_intersect(ra, ra, r); - if (ra.valid()) - { - ColorReal amplifier = (ColorReal)(contrast*exp(exposure)); - ColorReal shift = (ColorReal)((brightness - 0.5)*contrast + 0.5); - Gamma g(fabs(gamma) < 1e-8 ? 1.0 : 1.0/gamma); - - synfig::Surface::pen pc = c.get_pen(ra.minx, ra.maxx); - synfig::Surface::pen pa = c.get_pen(ra.minx, ra.maxx); - for(int y = ra.miny; y < ra.maxy; ++y) - { - const Color *ca = &a[y - r.miny - offset[1]][ra.minx - r.minx - offset[0]]; - Color *cc = &c[y][ra.minx]; - for(int x = ra.minx; x < ra.maxx; ++x, ++ca, ++cc) - correct_pixel(*cc, *ca, hue_adjust, shift, amplifier, g); - } - } - } - } - - //debug::DebugSurface::save_to_file(c, "TaskClampSW__run__c"); - - return true; -} - -/* === E N T R Y P O I N T ================================================= */ diff --git a/synfig-core/src/synfig/rendering/module/software/task/taskcolorcorrectsw.h b/synfig-core/src/synfig/rendering/module/software/task/taskcolorcorrectsw.h deleted file mode 100644 index 4894928..0000000 --- a/synfig-core/src/synfig/rendering/module/software/task/taskcolorcorrectsw.h +++ /dev/null @@ -1,64 +0,0 @@ -/* === S Y N F I G ========================================================= */ -/*! \file synfig/rendering/module/software/task/taskcolorcorrectsw.h -** \brief TaskColorCorrectSW Header -** -** $Id$ -** -** \legal -** ......... ... 2016 Ivan Mahonin -** -** This package is free software; you can redistribute it and/or -** modify it under the terms of the GNU General Public License as -** published by the Free Software Foundation; either version 2 of -** the License, or (at your option) any later version. -** -** This package is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -** General Public License for more details. -** \endlegal -*/ -/* ========================================================================= */ - -/* === S T A R T =========================================================== */ - -#ifndef __SYNFIG_RENDERING_MODULE_TASKCOLORCORRECTSW_H -#define __SYNFIG_RENDERING_MODULE_TASKCOLORCORRECTSW_H - -/* === H E A D E R S ======================================================= */ - -#include "../../common/task/taskcolorcorrect.h" - -#include -#include -#include - -/* === M A C R O S ========================================================= */ - -/* === T Y P E D E F S ===================================================== */ - -/* === C L A S S E S & S T R U C T S ======================================= */ - -namespace synfig -{ -namespace rendering -{ - -class TaskColorCorrectSW: public TaskColorCorrect, public TaskSW, public TaskSplittable -{ -private: - void correct_pixel(Color &dst, const Color &src, const Angle &hue_djust, ColorReal shift, ColorReal amplifier, const Gamma &gamma) const; - -public: - typedef etl::handle Handle; - Task::Handle clone() const { return clone_pointer(this); } - virtual void split(const RectInt &sub_target_rect); - virtual bool run(RunParams ¶ms) const; -}; - -} /* end namespace rendering */ -} /* end namespace synfig */ - -/* -- E N D ----------------------------------------------------------------- */ - -#endif diff --git a/synfig-core/src/synfig/rendering/opengl/renderergl.cpp b/synfig-core/src/synfig/rendering/opengl/renderergl.cpp index 682b039..c858741 100644 --- a/synfig-core/src/synfig/rendering/opengl/renderergl.cpp +++ b/synfig-core/src/synfig/rendering/opengl/renderergl.cpp @@ -61,9 +61,6 @@ #include "../software/optimizer/optimizerlayersw.h" #include "../software/optimizer/optimizermeshsw.h" -#include "../module/software/optimizer/optimizerclampsw.h" -#include "../module/software/optimizer/optimizercolorcorrectsw.h" - #endif using namespace synfig; @@ -89,9 +86,6 @@ RendererGL::RendererGL() register_optimizer(new OptimizerLayerSW()); register_optimizer(new OptimizerSurfaceResampleGL()); - register_optimizer(new OptimizerClampSW()); - register_optimizer(new OptimizerColorCorrectSW()); - register_optimizer(new OptimizerSurfaceConvert()); register_optimizer(new OptimizerLinear()); diff --git a/synfig-core/src/synfig/rendering/software/renderersafe.cpp b/synfig-core/src/synfig/rendering/software/renderersafe.cpp index c27660d..cbe82d4 100644 --- a/synfig-core/src/synfig/rendering/software/renderersafe.cpp +++ b/synfig-core/src/synfig/rendering/software/renderersafe.cpp @@ -55,9 +55,6 @@ #include "optimizer/optimizermeshsw.h" #include "optimizer/optimizersurfaceresamplesw.h" -#include "../module/software/optimizer/optimizerclampsw.h" -#include "../module/software/optimizer/optimizercolorcorrectsw.h" - #endif using namespace synfig; @@ -84,9 +81,6 @@ RendererSafe::RendererSafe() register_optimizer(new OptimizerLayerSW()); register_optimizer(new OptimizerSurfaceResampleSW()); - register_optimizer(new OptimizerClampSW()); - register_optimizer(new OptimizerColorCorrectSW()); - register_optimizer(new OptimizerSurfaceConvert()); register_optimizer(new OptimizerLinear()); diff --git a/synfig-core/src/synfig/rendering/software/renderersw.cpp b/synfig-core/src/synfig/rendering/software/renderersw.cpp index e9e0d89..0244c26 100644 --- a/synfig-core/src/synfig/rendering/software/renderersw.cpp +++ b/synfig-core/src/synfig/rendering/software/renderersw.cpp @@ -65,9 +65,6 @@ #include "optimizer/optimizermeshsw.h" #include "optimizer/optimizersurfaceresamplesw.h" -#include "../module/software/optimizer/optimizerclampsw.h" -#include "../module/software/optimizer/optimizercolorcorrectsw.h" - #include "function/fft.h" #endif @@ -96,9 +93,6 @@ RendererSW::RendererSW() register_optimizer(new OptimizerLayerSW()); register_optimizer(new OptimizerSurfaceResampleSW()); - register_optimizer(new OptimizerClampSW()); - register_optimizer(new OptimizerColorCorrectSW()); - register_optimizer(new OptimizerBlendZero()); register_optimizer(new OptimizerBlendBlend()); register_optimizer(new OptimizerBlendComposite());