Blame synfig-core/src/synfig/layers/layer_pastecanvas.cpp

Carlos Lopez a09598
/* === S Y N F I G ========================================================= */
Carlos Lopez a09598
/*!	\file layer_pastecanvas.cpp
Carlos Lopez a09598
**	\brief Implementation of the "Paste Canvas" layer
Carlos Lopez a09598
**
Carlos Lopez a09598
**	$Id$
Carlos Lopez a09598
**
Carlos Lopez a09598
**	\legal
Carlos Lopez a09598
**	Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
Carlos Lopez a09598
**	Copyright (c) 2007, 2008 Chris Moore
Carlos Lopez e83454
**	Copyright (c) 2011-2013 Carlos Lรณpez
39b9b1
**	......... ... 2014-2017 Ivan Mahonin
Carlos Lopez a09598
**
Carlos Lopez a09598
**	This package is free software; you can redistribute it and/or
Carlos Lopez a09598
**	modify it under the terms of the GNU General Public License as
Carlos Lopez a09598
**	published by the Free Software Foundation; either version 2 of
Carlos Lopez a09598
**	the License, or (at your option) any later version.
Carlos Lopez a09598
**
Carlos Lopez a09598
**	This package is distributed in the hope that it will be useful,
Carlos Lopez a09598
**	but WITHOUT ANY WARRANTY; without even the implied warranty of
Carlos Lopez a09598
**	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Carlos Lopez a09598
**	General Public License for more details.
Carlos Lopez a09598
**	\endlegal
Carlos Lopez a09598
*/
Carlos Lopez a09598
/* ========================================================================= */
Carlos Lopez a09598
Carlos Lopez a09598
/* === H E A D E R S ======================================================= */
Carlos Lopez a09598
Carlos Lopez a09598
#ifdef USING_PCH
Carlos Lopez a09598
#	include "pch.h"
Carlos Lopez a09598
#else
Carlos Lopez a09598
#ifdef HAVE_CONFIG_H
Carlos Lopez a09598
#	include <config.h></config.h>
Carlos Lopez a09598
#endif
Carlos Lopez a09598
Carlos Lopez a09598
#include "layer_pastecanvas.h"
bw 94d8a6
bw 94d8a6
#include <synfig general.h=""></synfig>
bw 94d8a6
#include <synfig localization.h=""></synfig>
bw 94d8a6
bw 94d8a6
#include <synfig cairo_renddesc.h=""></synfig>
bw 94d8a6
#include <synfig canvas.h=""></synfig>
bw 94d8a6
#include <synfig context.h=""></synfig>
bw 94d8a6
#include <synfig paramdesc.h=""></synfig>
bw 94d8a6
#include <synfig renddesc.h=""></synfig>
bw 94d8a6
#include <synfig time.h=""></synfig>
bw 94d8a6
#include <synfig string.h=""></synfig>
bw 94d8a6
#include <synfig surface.h=""></synfig>
bw 94d8a6
#include <synfig value.h=""></synfig>
bw 94d8a6
#include <synfig valuenode.h=""></synfig>
Carlos Lopez 94849c
c50f66
#include <synfig common="" rendering="" task="" taskblend.h=""></synfig>
c50f66
#include <synfig common="" rendering="" task="" tasktransformation.h=""></synfig>
a4bbdd
#include <synfig common="" rendering="" task="" taskpixelprocessor.h=""></synfig>
da4398
#include <synfig primitive="" rendering="" transformationaffine.h=""></synfig>
Carlos Lopez a09598
Carlos Lopez a09598
#endif
Carlos Lopez a09598
Carlos Lopez a09598
/* === U S I N G =========================================================== */
Carlos Lopez a09598
Carlos Lopez a09598
using namespace etl;
Carlos Lopez a09598
using namespace std;
Carlos Lopez a09598
using namespace synfig;
Carlos Lopez a09598
Carlos Lopez a09598
/* === M A C R O S ========================================================= */
Carlos Lopez a09598
Carlos Lopez a09598
#define MAX_DEPTH 10
Carlos Lopez a09598
ede284
// if this isn't defined, the 'dead heads' in examples/pirates.sif don't render properly
Carlos Lopez a09598
#define SYNFIG_CLIP_PASTECANVAS
Carlos Lopez a09598
Carlos Lopez a09598
//#ifdef __APPLE__
Carlos Lopez a09598
//#undef SYNFIG_CLIP_PASTECANVAS
Carlos Lopez a09598
//#endif
Carlos Lopez a09598
Carlos Lopez a09598
/* === C L A S S E S ======================================================= */
Carlos Lopez a09598
Carlos Lopez a09598
class depth_counter	// Makes our recursive depth counter exception-safe
Carlos Lopez a09598
{
Carlos Lopez a09598
	int *depth;
Carlos Lopez a09598
public:
Carlos Lopez a09598
	depth_counter(int &x):depth(&x) { (*depth)++; }
Carlos Lopez a09598
	~depth_counter() { (*depth)--; }
Carlos Lopez a09598
};
Carlos Lopez a09598
Carlos Lopez a09598
/* === G L O B A L S ======================================================= */
Carlos Lopez a09598
Carlos Lopez a09598
/* === M E T H O D S ======================================================= */
Carlos Lopez a09598
39b9b1
Layer_PasteCanvas::Layer_PasteCanvas(Real amount, Color::BlendMethod blend_method):
39b9b1
	Layer_Composite(amount, blend_method),
51c171
	param_origin(Point()),
0e8ab5
	param_transformation(Transformation()),
f8f499
	param_time_dilation(Real(1)),
f8f499
	param_time_offset(Time(0)),
f8f499
	param_outline_grow(Real(0)),
f8f499
	param_children_lock(bool(false)),
Carlos Lopez a09598
	depth(0),
Carlos Lopez 771bab
	extra_reference(false)
Carlos Lopez a09598
{
Carlos Lopez b3fcc2
	SET_INTERPOLATION_DEFAULTS();
Carlos Lopez b3fcc2
	SET_STATIC_DEFAULTS();
Carlos Lopez a09598
}
Carlos Lopez a09598
Carlos Lopez a09598
Layer_PasteCanvas::~Layer_PasteCanvas()
Carlos Lopez a09598
{
39b9b1
/*	if(sub_canvas)
39b9b1
		sub_canvas->parent_set.erase(this);
Carlos Lopez a09598
*/
Carlos Lopez a09598
39b9b1
	//if(sub_canvas)DEBUGINFO(strprintf("%d",sub_canvas->count()));
Carlos Lopez a09598
Carlos Lopez a09598
	set_sub_canvas(0);
Carlos Lopez a09598
39b9b1
	//if(sub_canvas && (sub_canvas->is_inline() || !get_canvas() || get_canvas()->get_root()!=sub_canvas->get_root()))
Carlos Lopez a09598
	//if(extra_reference)
39b9b1
	//	sub_canvas->unref();
Carlos Lopez a09598
}
Carlos Lopez a09598
Carlos Lopez a09598
String
Carlos Lopez a09598
Layer_PasteCanvas::get_local_name()const
Carlos Lopez a09598
{
39b9b1
	if(!sub_canvas || sub_canvas->is_inline()) return String();
39b9b1
	if(sub_canvas->get_root()==get_canvas()->get_root()) return sub_canvas->get_id();
39b9b1
	return sub_canvas->get_file_name();
Carlos Lopez a09598
}
Carlos Lopez a09598
Carlos Lopez a09598
Layer::Vocab
Carlos Lopez a09598
Layer_PasteCanvas::get_param_vocab()const
Carlos Lopez a09598
{
Carlos Lopez a09598
	Layer::Vocab ret(Layer_Composite::get_param_vocab());
Carlos Lopez a09598
a50429
	ret.push_back(ParamDesc("origin")
a50429
		.set_local_name(_("Origin"))
a50429
		.set_description(_("Position offset"))
991889
	);
b41041
	
0e8ab5
	ret.push_back(ParamDesc("transformation")
0e8ab5
		.set_local_name(_("Transformation"))
9b0d60
		.set_description(_("Position, rotation, skew and scale"))
1798f7
	);
1798f7
Carlos Lopez a09598
	ret.push_back(ParamDesc("canvas")
Carlos Lopez a09598
		.set_local_name(_("Canvas"))
Carlos Lopez e02170
		.set_description(_("Group content"))
Carlos Lopez a09598
	);
Carlos Lopez a09598
Permutator e9d9cb
	ret.push_back(ParamDesc("time_dilation")
8314b1
		.set_local_name(_("Speed"))
Permutator e9d9cb
		.set_description(_("Multiplier to speed up, slow down, freeze, or reverse time"))
Permutator e9d9cb
	);
Permutator e9d9cb
Carlos Lopez a09598
	ret.push_back(ParamDesc("time_offset")
Carlos Lopez a09598
		.set_local_name(_("Time Offset"))
Carlos Lopez d243d7
		.set_description(_("Time Offset to apply to the context"))
Carlos Lopez a09598
	);
Carlos Lopez a09598
Carlos Lopez a09598
	ret.push_back(ParamDesc("children_lock")
db0680
		.set_local_name(_("Lock Selection"))
Carlos Lopez d243d7
		.set_description(_("When checked prevents to select the children using the mouse click"))
Carlos Lopez 1a39e8
		.set_static(true)
Carlos Lopez a09598
	);
Carlos Lopez a09598
Carlos Lopez ce69d4
	ret.push_back(ParamDesc("outline_grow")
Carlos Lopez ce69d4
		.set_local_name(_("Outline Grow"))
Carlos Lopez ce69d4
		.set_description(_("Exponential value to grow children Outline layers width"))
Carlos Lopez ce69d4
	);
39b9b1
	if(sub_canvas && !(sub_canvas->is_inline()))
Carlos López f37627
	{
Carlos López f37627
		ret.back().hidden();
Carlos López f37627
	}
Carlos Lopez ce69d4
Carlos Lopez a09598
	return ret;
Carlos Lopez a09598
}
Carlos Lopez a09598
Carlos Lopez a09598
bool
Carlos Lopez a09598
Layer_PasteCanvas::set_param(const String & param, const ValueBase &value)
Carlos Lopez a09598
{
a50429
	IMPORT_VALUE(param_origin);
0e8ab5
	IMPORT_VALUE(param_transformation);
Carlos Lopez a09598
Carlos Lopez a09598
	// IMPORT(canvas);
d89783
	if(param=="canvas" && value.can_get(Canvas::Handle()))
Carlos Lopez a09598
	{
Carlos Lopez a09598
		set_sub_canvas(value.get(Canvas::Handle()));
Carlos Lopez a09598
		return true;
Carlos Lopez a09598
	}
Carlos Lopez a09598
	//! \todo this introduces bug 1844764 if enabled; it was introduced in r954.
Carlos Lopez a09598
	// http://synfig.org/images/3/3d/Moving-waypoints.sifz is an
Carlos Lopez a09598
	// example of an animation that has its waypoints displayed
Carlos Lopez a09598
	// incorrectly without this fix; select the outer layer and drag
Carlos Lopez a09598
	// the time slider.  The linear waypoints don't take effect until
Carlos Lopez a09598
	// 5s, but the time slider appears to pass the first one at 3s.
Carlos Lopez a09598
#if 0
Carlos Lopez a09598
	if (param=="time_offset" && value.same_type_as(time_offset))
Carlos Lopez a09598
	{
Carlos Lopez a09598
		if (time_offset != value.get(Time()))
Carlos Lopez a09598
		{
Carlos Lopez a09598
			value.put(&time_offset);
Carlos Lopez a09598
			// notify that the time_offset has changed so we can update the
Carlos Lopez a09598
			// waypoint positions in parent layers
Carlos Lopez a09598
			changed();
Carlos Lopez a09598
		}
Carlos Lopez a09598
		return true;
Carlos Lopez a09598
	}
Carlos Lopez a09598
#else
Permutator e9d9cb
	IMPORT_VALUE(param_time_dilation);
Carlos Lopez 1a39e8
	IMPORT_VALUE(param_time_offset);
Carlos Lopez a09598
#endif
Carlos Lopez a09598
Carlos Lopez 1a39e8
	IMPORT_VALUE(param_children_lock);
dd97a8
	IMPORT_VALUE_PLUS(param_outline_grow,
39b9b1
		if (sub_canvas)
dd97a8
		{
dd97a8
			Real sub_outline_grow = param_outline_grow.get(Real());
39b9b1
			sub_canvas->set_outline_grow(get_outline_grow_mark() + sub_outline_grow);
dd97a8
		}
dd97a8
	);
Carlos Lopez a09598
	return Layer_Composite::set_param(param,value);
Carlos Lopez a09598
}
Carlos Lopez a09598
Carlos Lopez a09598
void
2051d1
Layer_PasteCanvas::childs_changed()
386914
{
386914
	if (get_canvas()) get_canvas()->signal_changed()();
386914
	on_childs_changed();
386914
}
2051d1
2051d1
void
Carlos Lopez a09598
Layer_PasteCanvas::set_sub_canvas(etl::handle<synfig::canvas> x)</synfig::canvas>
Carlos Lopez a09598
{
39b9b1
	if (sub_canvas)
39b9b1
		remove_child(sub_canvas.get());
Carlos Lopez a09598
39b9b1
	// if(sub_canvas && (sub_canvas->is_inline() || !get_canvas() || get_canvas()->get_root()!=sub_canvas->get_root()))
Carlos Lopez a09598
	if (extra_reference)
39b9b1
		sub_canvas->unref();
Carlos Lopez a09598
2051d1
	childs_changed_connection.disconnect();
Carlos Lopez a09598
39b9b1
	if (sub_canvas != x) signal_subcanvas_changed()();
Carlos Lopez a09598
39b9b1
	sub_canvas=x;
Carlos Lopez a09598
39b9b1
	if (sub_canvas)
39b9b1
		childs_changed_connection=sub_canvas->signal_changed().connect(
2051d1
			sigc::mem_fun(*this, &Layer_PasteCanvas::childs_changed) );
Carlos Lopez a09598
39b9b1
	if (sub_canvas)
39b9b1
		add_child(sub_canvas.get());
Carlos Lopez a09598
39b9b1
	if (sub_canvas && (sub_canvas->is_inline() || !get_canvas() || get_canvas()->get_root()!=sub_canvas->get_root()))
Carlos Lopez a09598
	{
39b9b1
		sub_canvas->ref();
Carlos Lopez a09598
		extra_reference = true;
Carlos Lopez a09598
	}
Carlos Lopez a09598
	else
Carlos Lopez a09598
		extra_reference = false;
Carlos Lopez a09598
39b9b1
	if (sub_canvas)
Carlos Lopez a09598
		on_canvas_set();
Carlos Lopez a09598
}
Carlos Lopez a09598
Carlos Lopez a09598
// when a pastecanvas that contains another pastecanvas is copy/pasted
Carlos Lopez a09598
// from one document to another, only the outermost pastecanvas was
Carlos Lopez a09598
// getting its renddesc set to match that of its new parent.  this
Carlos Lopez a09598
// function is used to recurse through the pastecanvas copying its
Carlos Lopez a09598
// renddesc to any pastecanvases it contains (bug #2116947, svn r2200)
Carlos Lopez a09598
void
Carlos Lopez a09598
Layer_PasteCanvas::update_renddesc()
Carlos Lopez a09598
{
39b9b1
	if(!get_canvas() || !sub_canvas || !sub_canvas->is_inline()) return;
Carlos Lopez a09598
39b9b1
	sub_canvas->rend_desc()=get_canvas()->rend_desc();
39b9b1
	for (IndependentContext iter = sub_canvas->get_independent_context(); !iter->empty(); iter++)
Carlos Lopez a09598
	{
8dcfee
		etl::handle<layer_pastecanvas> paste = etl::handle<layer_pastecanvas>::cast_dynamic(*iter);</layer_pastecanvas></layer_pastecanvas>
Carlos Lopez a09598
		if (paste) paste->update_renddesc();
Carlos Lopez a09598
	}
Carlos Lopez a09598
}
Carlos Lopez a09598
Carlos Lopez a09598
// This is called whenever the parent canvas gets set/changed
Carlos Lopez a09598
void
Carlos Lopez a09598
Layer_PasteCanvas::on_canvas_set()
Carlos Lopez a09598
{
39b9b1
	if(get_canvas() && sub_canvas && sub_canvas->is_inline() && sub_canvas->parent()!=get_canvas())
39b9b1
		sub_canvas->set_inline(get_canvas());
0ea095
	Layer_Composite::on_canvas_set();
Carlos Lopez a09598
}
Carlos Lopez a09598
Carlos Lopez a09598
ValueBase
Carlos Lopez a09598
Layer_PasteCanvas::get_param(const String& param)const
Carlos Lopez a09598
{
a50429
	EXPORT_VALUE(param_origin);
0e8ab5
	EXPORT_VALUE(param_transformation);
Carlos Lopez 9a5dc9
	if (param=="canvas")
Carlos Lopez 9a5dc9
	{
39b9b1
		synfig::ValueBase ret(sub_canvas);
Carlos Lopez 9a5dc9
		return ret;
Carlos Lopez 9a5dc9
	}
Permutator e9d9cb
	EXPORT_VALUE(param_time_dilation);
Carlos Lopez 1a39e8
	EXPORT_VALUE(param_time_offset);
Carlos Lopez 1a39e8
	EXPORT_VALUE(param_children_lock);
Carlos Lopez 1a39e8
	EXPORT_VALUE(param_outline_grow);
Carlos Lopez a09598
Carlos Lopez a09598
	return Layer_Composite::get_param(param);
Carlos Lopez a09598
}
Carlos Lopez a09598
Carlos Lopez a09598
void
dd97a8
Layer_PasteCanvas::set_time_vfunc(IndependentContext context, Time time)const
Carlos Lopez a09598
{
39b9b1
	context.set_time(time);
39b9b1
39b9b1
	if (!sub_canvas)
39b9b1
		return;
39b9b1
	if (depth == MAX_DEPTH)
39b9b1
		return;
f8f499
	depth_counter counter(depth);
Carlos Lopez a09598
39b9b1
	Real time_dilation = param_time_dilation.get(Real());
39b9b1
	Time time_offset = param_time_offset.get(Time());
39b9b1
	sub_canvas->set_time(time*time_dilation + time_offset);
dd97a8
}
dd97a8
dd97a8
void
c006c9
Layer_PasteCanvas::load_resources_vfunc(IndependentContext context, Time time)const
c006c9
{
c006c9
	context.load_resources(time);
c006c9
c006c9
	if (!sub_canvas)
c006c9
		return;
c006c9
	if (depth == MAX_DEPTH)
c006c9
		return;
c006c9
	depth_counter counter(depth);
c006c9
c006c9
	Real time_dilation = param_time_dilation.get(Real());
c006c9
	Time time_offset = param_time_offset.get(Time());
c006c9
	sub_canvas->load_resources(time*time_dilation + time_offset);
c006c9
}
c006c9
c006c9
void
dd97a8
Layer_PasteCanvas::set_outline_grow_vfunc(IndependentContext context, Real outline_grow)const
dd97a8
{
39b9b1
	context.set_outline_grow(outline_grow);
39b9b1
39b9b1
	if (!sub_canvas)
39b9b1
		return;
39b9b1
	if (depth == MAX_DEPTH)
39b9b1
		return;
dd97a8
	depth_counter counter(depth);
dd97a8
39b9b1
	Real sub_outline_grow = param_outline_grow.get(Real());
39b9b1
	sub_canvas->set_outline_grow(outline_grow + sub_outline_grow);
Carlos Lopez a09598
}
Carlos Lopez a09598
b7acad
void
8bbd89
Layer_PasteCanvas::apply_z_range_to_params(ContextParams &cp)const
b7acad
{
8bbd89
	ContextParams p;
8bbd89
	cp.z_range = p.z_range;
8bbd89
	cp.z_range_position = p.z_range_position;
8bbd89
	cp.z_range_depth = p.z_range_depth;
8bbd89
	cp.z_range_blur = p.z_range_blur;
b7acad
}
b7acad
Carlos Lopez a09598
synfig::Layer::Handle
Carlos Lopez a09598
Layer_PasteCanvas::hit_check(synfig::Context context, const synfig::Point &pos)const
Carlos Lopez a09598
{
39b9b1
	if(!sub_canvas || !get_amount())
39b9b1
		return context.hit_check(pos);
39b9b1
	if (depth == MAX_DEPTH)
39b9b1
		return 0;
39b9b1
	depth_counter counter(depth);
Carlos Lopez a09598
1798f7
	Transformation transformation(get_summary_transformation());
39b9b1
	Point target_pos = transformation.back_transform(pos);
edd586
39b9b1
	CanvasBase queue;
39b9b1
	Context subcontext = build_context_queue(context, queue);
39b9b1
	if (subcontext.get_color(target_pos).get_a() >= 0.25)
39b9b1
		return param_children_lock.get(bool(true))
39b9b1
			 ? const_cast<layer_pastecanvas*>(this)</layer_pastecanvas*>
39b9b1
			 : subcontext.hit_check(target_pos);
Carlos Lopez a09598
	return context.hit_check(pos);
Carlos Lopez a09598
}
Carlos Lopez a09598
Carlos Lopez a09598
Color
Carlos Lopez a09598
Layer_PasteCanvas::get_color(Context context, const Point &pos)const
Carlos Lopez a09598
{
39b9b1
	if(!sub_canvas || !get_amount())
Carlos Lopez a09598
		return context.get_color(pos);
39b9b1
	if (depth == MAX_DEPTH)
39b9b1
		return Color::alpha();
39b9b1
	depth_counter counter(depth);
Carlos Lopez a09598
39b9b1
	Transformation transformation(get_summary_transformation());
9b0d60
	Point target_pos = transformation.back_transform(pos);
Carlos Lopez a09598
39b9b1
	CanvasBase queue;
39b9b1
	Context subcontext = build_context_queue(context, queue);
39b9b1
	return Color::blend( subcontext.get_color(target_pos),
39b9b1
			             context.get_color(pos),
39b9b1
						 get_amount(),
39b9b1
						 get_blend_method() );
Carlos Lopez a09598
}
Carlos Lopez a09598
8dcfee
Rect
8dcfee
Layer_PasteCanvas::get_bounding_rect_context_dependent(const ContextParams &context_params)const
8dcfee
{
39b9b1
	if (!sub_canvas)
39b9b1
		return Rect::zero();
324bbc
39b9b1
	ContextParams subparams(context_params);
39b9b1
	apply_z_range_to_params(subparams);
39b9b1
39b9b1
	CanvasBase queue;
39b9b1
	Context subcontext = sub_canvas->get_context_sorted(subparams, queue);
39b9b1
39b9b1
	return get_summary_transformation().transform_bounds(
39b9b1
			subcontext.get_full_bounding_rect() );
8dcfee
}
8dcfee
8dcfee
Rect
8dcfee
Layer_PasteCanvas::get_full_bounding_rect(Context context)const
8dcfee
{
39b9b1
	if (is_disabled() || Color::is_onto(get_blend_method()) || !sub_canvas)
8dcfee
		return context.get_full_bounding_rect();
8dcfee
39b9b1
	CanvasBase queue;
39b9b1
	Rect rect = get_summary_transformation().transform_bounds(
39b9b1
		build_context_queue(context, queue).get_full_bounding_rect() );
39b9b1
39b9b1
	return rect | context.get_full_bounding_rect();
8dcfee
}
Carlos Lopez a09598
b8aa2b
void
b8aa2b
Layer_PasteCanvas::get_times_vfunc(Node::time_set &set) const
Carlos Lopez a09598
{
Permutator e9d9cb
	Real time_dilation=param_time_dilation.get(Real());
Carlos Lopez 1a39e8
	Time time_offset=param_time_offset.get(Time());
Carlos Lopez 1a39e8
Carlos Lopez a09598
	Node::time_set tset;
39b9b1
	if(sub_canvas) tset = sub_canvas->get_times();
Carlos Lopez a09598
Carlos Lopez a09598
	Node::time_set::iterator i = tset.begin(), end = tset.end();
Carlos Lopez a09598
Carlos Lopez a09598
	//Make sure we offset the time...
Carlos Lopez a09598
	//! \todo: SOMETHING STILL HAS TO BE DONE WITH THE OTHER DIRECTION
Carlos Lopez a09598
	//		   (recursing down the tree needs to take this into account too...)
Permutator e9d9cb
	for(; i != end; ++i) {
Carlos Lopez a09598
#ifdef ADJUST_WAYPOINTS_FOR_TIME_OFFSET // see node.h
c2b5ba
		if (time_dilation!=0)
c2b5ba
		{
c2b5ba
			TimePoint tp = *i;
c2b5ba
			tp.set_time((tp.get_time() - time_offset) / time_dilation);
c2b5ba
			set.insert(tp);
c2b5ba
		}
Permutator e9d9cb
#else
Permutator e9d9cb
		set.insert(*i);
Carlos Lopez a09598
#endif
Permutator e9d9cb
	}
Carlos Lopez a09598
Carlos Lopez a09598
	Layer::get_times_vfunc(set);
Carlos Lopez a09598
}
Carlos Lopez 79520f
a435f0
void
a435f0
Layer_PasteCanvas::fill_sound_processor(SoundProcessor &soundProcessor) const
a435f0
{
39b9b1
	if (active() && sub_canvas) sub_canvas->fill_sound_processor(soundProcessor);
a435f0
}
c50f66
c50f66
rendering::Task::Handle
39b9b1
Layer_PasteCanvas::build_rendering_task_vfunc(Context context)const
c50f66
{
39b9b1
	rendering::Task::Handle sub_task;
39b9b1
	if (sub_canvas)
39b9b1
	{
39b9b1
		CanvasBase sub_queue;
39b9b1
		Context sub_context = build_context_queue(context, sub_queue);
39b9b1
5e2754
		rendering::TaskTransformationAffine::Handle task_transformation(new rendering::TaskTransformationAffine());
5e2754
		task_transformation->transformation->matrix = get_summary_transformation().get_matrix();
39b9b1
		task_transformation->sub_task() = sub_context.build_rendering_task();
39b9b1
		sub_task = task_transformation;
a4bbdd
		
a4bbdd
		if (sub_canvas->get_root() != get_canvas()->get_root()) {
a4bbdd
			rendering::TaskPixelGamma::Handle task_gamma(new rendering::TaskPixelGamma());
a4bbdd
			task_gamma->gamma = get_canvas()->get_root()->rend_desc().get_gamma()
a4bbdd
							  / sub_canvas->get_root()->rend_desc().get_gamma();
a4bbdd
			task_gamma->sub_task() = sub_task;
a4bbdd
			if (!task_gamma->is_transparent())
a4bbdd
				sub_task = task_gamma;
a4bbdd
		}
39b9b1
	}
39b9b1
39b9b1
	rendering::TaskBlend::Handle task_blend(new rendering::TaskBlend());
39b9b1
	task_blend->amount = get_amount() * Context::z_depth_visibility(context.get_params(), *this);
39b9b1
	task_blend->blend_method = get_blend_method();
39b9b1
	task_blend->sub_task_a() = context.build_rendering_task();
39b9b1
	task_blend->sub_task_b() = sub_task;
39b9b1
	return task_blend;
c50f66
}
c50f66
39b9b1
Context
39b9b1
Layer_PasteCanvas::build_context_queue(Context context, CanvasBase &out_queue)const
39b9b1
{
39b9b1
	ContextParams params(context.get_params());
39b9b1
	apply_z_range_to_params(params);
39b9b1
39b9b1
	if (sub_canvas)
39b9b1
		return sub_canvas->get_context_sorted(params, out_queue);
c50f66
39b9b1
	out_queue.push_back(Layer::Handle());
39b9b1
	return Context(out_queue.begin(), params);
39b9b1
}