Blame synfig-core/src/synfig/rendering/common/task/taskblend.cpp

e788a2
/* === S Y N F I G ========================================================= */
e788a2
/*!	\file synfig/rendering/common/task/taskblend.cpp
e788a2
**	\brief TaskBlend
e788a2
**
e788a2
**	$Id$
e788a2
**
e788a2
**	\legal
da4398
**	......... ... 2015-2018 Ivan Mahonin
e788a2
**
e788a2
**	This package is free software; you can redistribute it and/or
e788a2
**	modify it under the terms of the GNU General Public License as
e788a2
**	published by the Free Software Foundation; either version 2 of
e788a2
**	the License, or (at your option) any later version.
e788a2
**
e788a2
**	This package is distributed in the hope that it will be useful,
e788a2
**	but WITHOUT ANY WARRANTY; without even the implied warranty of
e788a2
**	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e788a2
**	General Public License for more details.
e788a2
**	\endlegal
e788a2
*/
e788a2
/* ========================================================================= */
e788a2
e788a2
/* === H E A D E R S ======================================================= */
e788a2
e788a2
#ifdef USING_PCH
e788a2
#	include "pch.h"
e788a2
#else
e788a2
#ifdef HAVE_CONFIG_H
e788a2
#	include <config.h></config.h>
e788a2
#endif
e788a2
e788a2
#include "taskblend.h"
e788a2
e788a2
#endif
e788a2
e788a2
using namespace synfig;
e788a2
using namespace rendering;
e788a2
e788a2
/* === M A C R O S ========================================================= */
e788a2
e788a2
/* === G L O B A L S ======================================================= */
e788a2
e788a2
/* === P R O C E D U R E S ================================================= */
e788a2
e788a2
/* === M E T H O D S ======================================================= */
e788a2
da4398
5e2754
Task::Token TaskBlend::token(
5e2754
	DescAbstract<taskblend>("Blend") );</taskblend>
da4398
78f7a3
int
78f7a3
TaskBlend::get_pass_subtask_index() const
78f7a3
{
ce743b
	bool a = (bool)sub_task_a();
ce743b
	bool b = (bool)sub_task_b();
78f7a3
	if (!a && !b)
78f7a3
		return PASSTO_NO_TASK;
78f7a3
	if (!a && Color::is_onto(blend_method))
78f7a3
		return PASSTO_NO_TASK;
78f7a3
	if (blend_method == Color::BLEND_COMPOSITE) {
78f7a3
		if (!b)
78f7a3
			return 0;
78f7a3
		if (approximate_equal_lp(amount, ColorReal(0.0)))
78f7a3
			return a ? 0 : PASSTO_NO_TASK;
78f7a3
		if (!a && approximate_equal_lp(amount, ColorReal(1.0)))
78f7a3
			return 1;
78f7a3
	}
78f7a3
	return PASSTO_THIS_TASK;
78f7a3
}
da4398
e788a2
Rect
e788a2
TaskBlend::calc_bounds() const
e788a2
{
232715
	Rect ra = sub_task_a() ? sub_task_a()->get_bounds() : Rect::zero();
232715
	Rect rb = sub_task_b() ? sub_task_b()->get_bounds() : Rect::zero();
e2adca
	Rect bounds = ra | rb;
e788a2
	if (Color::is_onto(blend_method))
e2adca
		bounds &= ra;
e2adca
	if (approximate_equal(amount, Color::value_type(1)) && Color::is_straight(blend_method))
e2adca
		bounds &= rb;
e788a2
	return bounds;
e788a2
}
e788a2
e788a2
/* === E N T R Y P O I N T ================================================= */