X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Fcanvas.cpp;h=b8e33a00908ee8206fe9a04823c161b9fdac0fb4;hb=c3e45b84cbe115d9a8d216f1ce99d06fdd49ccca;hp=e5b8ab762fd13bcd31384c6275924990b286e915;hpb=7d49a80c399bf1d580680227a2edd4540f2bce1a;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/canvas.cpp b/synfig-core/trunk/src/synfig/canvas.cpp index e5b8ab7..b8e33a0 100644 --- a/synfig-core/trunk/src/synfig/canvas.cpp +++ b/synfig-core/trunk/src/synfig/canvas.cpp @@ -6,6 +6,7 @@ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2007 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 @@ -68,8 +69,9 @@ int _CanvasCounter::counter(0); /* === M E T H O D S ======================================================= */ -Canvas::Canvas(const string &id): +Canvas::Canvas(const String &id): id_ (id), + version_ (CURRENT_CANVAS_VERSION), cur_time_ (0), is_inline_ (false), is_dirty_ (true), @@ -733,7 +735,7 @@ Canvas::push_back_simple(etl::handle x) } void -Canvas::erase(Canvas::iterator iter) +Canvas::erase(iterator iter) { if(!(*iter)->get_group().empty()) remove_group_pair((*iter)->get_group(),(*iter)); @@ -768,7 +770,7 @@ Canvas::clone(const GUID& deriv_guid)const { name=get_id()+"_CLONE"; - throw runtime_error("Cloning of non-inline canvases is not yet suported"); + throw runtime_error("Cloning of non-inline canvases is not yet supported"); } Handle canvas(new Canvas(name)); @@ -776,7 +778,11 @@ Canvas::clone(const GUID& deriv_guid)const if(is_inline()) { canvas->is_inline_=true; - canvas->parent_=0; + // \todo this was setting parent_=0 - is there a reason for that? + // this was causing bug 1838132, where cloning an inline canvas that contains an imported image fails + // it was failing to ascertain the absolute pathname of the imported image, since it needs the pathname + // of the canvas to get that, which is stored in the parent canvas + canvas->parent_=parent(); //canvas->set_inline(parent()); } @@ -1018,10 +1024,10 @@ synfig::optimize_layers(Context context, Canvas::Handle op_canvas, bool seen_mot Context iter; std::vector< std::pair > sort_list; - int i, motion_blur_i; // motion_blur_i is for resolving which layer comes first in the event of a z_depth tie - float motion_blur_z_depth; // the z_depth of the least deep motion blur layer in this context + int i, motion_blur_i=0; // motion_blur_i is for resolving which layer comes first in the event of a z_depth tie + float motion_blur_z_depth=0; // the z_depth of the least deep motion blur layer in this context bool seen_motion_blur_locally = false; - bool motion_blurred; // the final result - is this layer blurred or not? + bool motion_blurred; // the final result - is this layer blurred or not? // If the parent didn't cause us to already be motion blurred, // check whether there's a motion blur in this context, @@ -1080,33 +1086,36 @@ synfig::optimize_layers(Context context, Canvas::Handle op_canvas, bool seen_mot continue; Layer_PasteCanvas* paste_canvas(static_cast(layer.get())); - if(layer->get_name()=="PasteCanvas" && paste_canvas->get_time_offset()==0) + + // note: this used to include "&& paste_canvas->get_time_offset()==0", but then + // time-shifted layers weren't being sorted by z-depth (bug #1806852) + if(layer->get_name()=="PasteCanvas") { - Canvas::Handle sub_canvas(Canvas::create_inline(op_canvas)); - Canvas::Handle paste_sub_canvas = paste_canvas->get_sub_canvas(); - if(paste_sub_canvas) - { - // we need to blur the sub canvas if: - // our parent is blurred, - // or the child is lower than a local blur, - // or the child is at the same z_depth as a local blur, but later in the context + // we need to blur the sub canvas if: + // our parent is blurred, + // or the child is lower than a local blur, + // or the child is at the same z_depth as a local blur, but later in the context + #if 0 // DEBUG - if (seen_motion_blur_in_parent) synfig::info("seen BLUR in parent\n"); - else if (seen_motion_blur_locally) - if (z_depth > motion_blur_z_depth) synfig::info("paste is deeper than BLUR\n"); - else if (z_depth == motion_blur_z_depth) { synfig::info("paste is same depth as BLUR\n"); - if (i > motion_blur_i) synfig::info("paste is physically deeper than BLUR\n"); - else synfig::info("paste is less physically deep than BLUR\n"); - } else synfig::info("paste is less deep than BLUR\n"); - else synfig::info("no BLUR at all\n"); + if (seen_motion_blur_in_parent) synfig::info("seen BLUR in parent\n"); + else if (seen_motion_blur_locally) + if (z_depth > motion_blur_z_depth) synfig::info("paste is deeper than BLUR\n"); + else if (z_depth == motion_blur_z_depth) { synfig::info("paste is same depth as BLUR\n"); + if (i > motion_blur_i) synfig::info("paste is physically deeper than BLUR\n"); + else synfig::info("paste is less physically deep than BLUR\n"); + } else synfig::info("paste is less deep than BLUR\n"); + else synfig::info("no BLUR at all\n"); #endif // DEBUG - motion_blurred = (seen_motion_blur_in_parent || - (seen_motion_blur_locally && - (z_depth > motion_blur_z_depth || - (z_depth == motion_blur_z_depth && i > motion_blur_i)))); + motion_blurred = (seen_motion_blur_in_parent || + (seen_motion_blur_locally && + (z_depth > motion_blur_z_depth || + (z_depth == motion_blur_z_depth && i > motion_blur_i)))); + + Canvas::Handle sub_canvas(Canvas::create_inline(op_canvas)); + Canvas::Handle paste_sub_canvas = paste_canvas->get_sub_canvas(); + if(paste_sub_canvas) optimize_layers(paste_sub_canvas->get_context(),sub_canvas,motion_blurred); - } //#define SYNFIG_OPTIMIZE_PASTE_CANVAS 1 #ifdef SYNFIG_OPTIMIZE_PASTE_CANVAS @@ -1250,13 +1259,13 @@ Canvas::remove_group_pair(String group, etl::handle layer) } void -Canvas::add_connection(Layer::LooseHandle layer, sigc::connection connection) +Canvas::add_connection(etl::loose_handle layer, sigc::connection connection) { connections_[layer].push_back(connection); } void -Canvas::disconnect_connections(Layer::LooseHandle layer) +Canvas::disconnect_connections(etl::loose_handle layer) { std::vector::iterator iter; for(iter=connections_[layer].begin();iter!=connections_[layer].end();++iter)