X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Flayer_duplicate.cpp;h=09c9e77bea17a074043a4167e7171b59a102210f;hb=756c0d29ac1742f231e6615f9a577e574e35a4af;hp=202a754ce416d3ec5bc47d86d1604be2034531fb;hpb=03f9d7a946e2d2465f263349b2d6c60dd426d036;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/layer_duplicate.cpp b/synfig-core/trunk/src/synfig/layer_duplicate.cpp index 202a754..09c9e77 100644 --- a/synfig-core/trunk/src/synfig/layer_duplicate.cpp +++ b/synfig-core/trunk/src/synfig/layer_duplicate.cpp @@ -6,7 +6,7 @@ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley -** Copyright (c) 2007 Chris Moore +** Copyright (c) 2007, 2008 Chris Moore ** ** This package is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as @@ -63,10 +63,28 @@ SYNFIG_LAYER_SET_CVS_ID(Layer_Duplicate,"$Id$"); Layer_Duplicate::Layer_Duplicate(): Layer_Composite(1.0,Color::BLEND_COMPOSITE) { - LinkableValueNode* index_value_node = ValueNode_Duplicate::create(int(3)); + LinkableValueNode* index_value_node = ValueNode_Duplicate::create(Real(3)); connect_dynamic_param("index", index_value_node); } +Layer::Handle +Layer_Duplicate::clone(const GUID& deriv_guid)const +{ + printf("cloning layer duplicate\n"); + Layer::Handle ret = (Layer::Handle)Layer_Composite::clone(deriv_guid); + + const DynamicParamList &dpl = dynamic_param_list(); + DynamicParamList::const_iterator iter = dpl.find("index"); + + // if we have a dynamic "index" parameter, make a new one in the clone + // it's not good to have two references to the same index valuenode, + // or nested duplicatations cause an infinite loop + if (iter != dpl.end()) + ret->connect_dynamic_param(iter->first,iter->second->clone(deriv_guid)); + + return ret; +} + bool Layer_Duplicate::set_param(const String ¶m, const ValueBase &value) { @@ -109,7 +127,7 @@ Layer::Vocab Layer_Duplicate::get_param_vocab()const { Layer::Vocab ret; - //ret=Layer_Composite::get_param_vocab(); + ret=Layer_Composite::get_param_vocab(); ret.push_back(ParamDesc("index") .set_local_name(_("Index")) @@ -119,6 +137,16 @@ Layer_Duplicate::get_param_vocab()const return ret; } +ValueNode_Duplicate::Handle +Layer_Duplicate::get_duplicate_param()const +{ + const DynamicParamList &dpl = dynamic_param_list(); + DynamicParamList::const_iterator iter = dpl.find("index"); + if (iter == dpl.end()) return NULL; + etl::rhandle param(iter->second); + return ValueNode_Duplicate::Handle::cast_dynamic(param); +} + bool Layer_Duplicate::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const { @@ -136,16 +164,8 @@ Layer_Duplicate::accelerated_render(Context context,Surface *surface,int quality Surface tmp; int i = 0; - const DynamicParamList &dpl = dynamic_param_list(); - DynamicParamList::const_iterator iter = dpl.find("index"); - if (iter == dpl.end()) - return context.accelerated_render(surface,quality,renddesc,cb); - - etl::rhandle param(iter->second); - handle duplicate_param(handle::cast_dynamic(param)); - - if (!duplicate_param) - return context.accelerated_render(surface,quality,renddesc,cb); + handle duplicate_param = get_duplicate_param(); + if (!duplicate_param) return context.accelerated_render(surface,quality,renddesc,cb); surface->set_wh(renddesc.get_w(),renddesc.get_h()); surface->clear(); @@ -153,6 +173,7 @@ Layer_Duplicate::accelerated_render(Context context,Surface *surface,int quality Color::BlendMethod blend_method(get_blend_method()); int steps = duplicate_param->count_steps(time_cur); + Mutex::Lock lock(mutex); duplicate_param->reset_index(time_cur); do { @@ -163,14 +184,12 @@ Layer_Duplicate::accelerated_render(Context context,Surface *surface,int quality if(!context.accelerated_render(&tmp,quality,renddesc,&subimagecb)) return false; Surface::alpha_pen apen(surface->begin()); - apen.set_alpha(1.0); + apen.set_alpha(get_amount()); // \todo have a checkbox allowing use of 'behind' to reverse the order? - apen.set_blend_method(blend_method); + apen.set_blend_method(i ? blend_method : Color::BLEND_COMPOSITE); tmp.blit_to(apen); i++; } while (duplicate_param->step(time_cur)); - duplicate_param->reset_index(time_cur); - return true; }