Skip to content

Commit

Permalink
refactor(NoiseDistort): remove useless method, argument, intermediate…
Browse files Browse the repository at this point in the history
… var (#2887)
  • Loading branch information
rodolforg committed Nov 16, 2022
1 parent 980fd1e commit ecd8ea6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
20 changes: 6 additions & 14 deletions synfig-core/src/modules/mod_noise/distort.cpp
Expand Up @@ -132,17 +132,9 @@ NoiseDistort::point_func(const Point &point)const
}

inline Color
NoiseDistort::color_func(const Point &point, float /*supersample*/,Context context)const
NoiseDistort::color_func(const Point &point, Context context)const
{
Color ret(0,0,0,0);
ret=context.get_color(point_func(point));
return ret;
}

inline float
NoiseDistort::calc_supersample(const synfig::Point &/*x*/, float /*pw*/,float /*ph*/)const
{
return 0.0f;
return context.get_color(point_func(point));
}

synfig::Layer::Handle
Expand All @@ -152,7 +144,7 @@ NoiseDistort::hit_check(synfig::Context context, const synfig::Point &point)cons
return const_cast<NoiseDistort*>(this);
if(get_amount()==0.0)
return context.hit_check(point);
if(color_func(point,0,context).get_a()>0.5)
if(color_func(point,context).get_a()>0.5)
return const_cast<NoiseDistort*>(this);
return synfig::Layer::Handle();
}
Expand Down Expand Up @@ -243,7 +235,7 @@ NoiseDistort::get_param_vocab()const
Color
NoiseDistort::get_color(Context context, const Point &point)const
{
const Color color(color_func(point,0,context));
const Color color(color_func(point,context));

if(get_amount()==1.0 && get_blend_method()==Color::BLEND_STRAIGHT)
return color;
Expand Down Expand Up @@ -326,13 +318,13 @@ NoiseDistort::accelerated_render(Context context,Surface *surface,int quality, c
{
for(y=0,pos[1]=tl[1];y<h;y++,pen.inc_y(),pen.dec_x(x),pos[1]+=ph)
for(x=0,pos[0]=tl[0];x<w;x++,pen.inc_x(),pos[0]+=pw)
pen.put_value(color_func(pos,calc_supersample(pos,pw,ph),context));
pen.put_value(color_func(pos,context));
}
else
{
for(y=0,pos[1]=tl[1];y<h;y++,pen.inc_y(),pen.dec_x(x),pos[1]+=ph)
for(x=0,pos[0]=tl[0];x<w;x++,pen.inc_x(),pos[0]+=pw)
pen.put_value(Color::blend(color_func(pos,calc_supersample(pos,pw,ph),context),pen.get_value(),get_amount(),get_blend_method()));
pen.put_value(Color::blend(color_func(pos,context),pen.get_value(),get_amount(),get_blend_method()));
}
// Mark our progress as finished
Expand Down
4 changes: 1 addition & 3 deletions synfig-core/src/modules/mod_noise/distort.h
Expand Up @@ -65,11 +65,9 @@ class NoiseDistort : public synfig::Layer_CompositeFork
//!Parameter: (bool)
synfig::ValueBase param_turbulent;

synfig::Color color_func(const synfig::Point &x, float supersample,synfig::Context context)const;
synfig::Color color_func(const synfig::Point &x,synfig::Context context)const;
synfig::Point point_func(const synfig::Point &point)const;

float calc_supersample(const synfig::Point &x, float pw,float ph)const;

public:
NoiseDistort();

Expand Down

0 comments on commit ecd8ea6

Please sign in to comment.