X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Flayer_composite.cpp;h=6a25efc8d09bc60cee7b7c38837c24675adf3759;hb=9459638ad6797b8139f1e9f0715c96076dbf0890;hp=038d68ff4759d576b325d4ad9f587bdd77204852;hpb=e3acc0b267b14fda5db3c7bbb2f218b993ef84b3;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/layer_composite.cpp b/synfig-core/trunk/src/synfig/layer_composite.cpp index 038d68f..6a25efc 100644 --- a/synfig-core/trunk/src/synfig/layer_composite.cpp +++ b/synfig-core/trunk/src/synfig/layer_composite.cpp @@ -1,20 +1,22 @@ -/* === S I N F G =========================================================== */ +/* === S Y N F I G ========================================================= */ /*! \file layer_composite.cpp ** \brief Template File ** -** $Id: layer_composite.cpp,v 1.2 2005/01/24 03:08:18 darco Exp $ +** $Id$ ** ** \legal -** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2008 Chris Moore ** -** This software and associated documentation -** are CONFIDENTIAL and PROPRIETARY property of -** the above-mentioned copyright holder. +** This package is free software; you can redistribute it and/or +** modify it under the terms of the GNU General Public License as +** published by the Free Software Foundation; either version 2 of +** the License, or (at your option) any later version. ** -** You may not copy, print, publish, or in any -** other way distribute this software without -** a prior written agreement with -** the copyright holder. +** This package is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. ** \endlegal */ /* ========================================================================= */ @@ -48,7 +50,7 @@ using namespace std; using namespace etl; -using namespace sinfg; +using namespace synfig; /* === M A C R O S ========================================================= */ @@ -62,7 +64,7 @@ bool Layer_Composite::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc_, ProgressCallback *cb) const { RendDesc renddesc(renddesc_); - + if(!amount_) return context.accelerated_render(surface,quality,renddesc,cb); @@ -74,7 +76,7 @@ Layer_Composite::accelerated_render(Context context,Surface *surface,int quality Layer_Bitmap::Handle surfacelayer(new class Layer_Bitmap()); Context iter; - + for(iter=context;*iter;iter++) image.push_back(*iter); @@ -102,19 +104,19 @@ Layer_Composite::accelerated_render(Context context,Surface *surface,int quality surfacelayer->br=renddesc.get_br(); surfacelayer->set_blend_method(Color::BLEND_STRAIGHT); - image.push_front(const_cast(this)); + image.push_front(const_cast(this)); // Set up a surface target Target::Handle target(surface_target(surface)); - + if(!target) { if(cb)cb->error(_("Unable to create surface target")); return false; } - + RendDesc desc(renddesc); - + target->set_rend_desc(&desc); // Render the scene @@ -149,11 +151,47 @@ Layer_Composite::get_param_vocab()const bool Layer_Composite::set_param(const String & param, const ValueBase &value) { - if(param=="amount" && value.same_as(amount_)) + if(param=="amount" && value.same_type_as(amount_)) amount_=value.get(amount_); else - if(param=="blend_method" && value.same_as(int())) - blend_method_=static_cast(value.get(int())); + if(param=="blend_method" && value.same_type_as(int())) + { + blend_method_ = static_cast(value.get(int())); + + if (blend_method_ < 0 || blend_method_ >= Color::BLEND_END) + { + warning("illegal value (%d) for blend_method - using Composite instead", blend_method_); + blend_method_ = Color::BLEND_COMPOSITE; + return false; + } + + if (blend_method_ == Color::BLEND_STRAIGHT && !reads_context()) + { + Canvas::Handle canvas(get_canvas()); + if (canvas) + { + String version(canvas->get_version()); + + if (version == "0.1" || version == "0.2") + { + if (get_name() == "PasteCanvas") + warning("loaded a version %s canvas with a 'Straight' blended PasteCanvas (%s) - check it renders OK", + version.c_str(), get_non_empty_description().c_str()); + else + { + blend_method_ = Color::BLEND_COMPOSITE; + converted_blend_ = true; + + // if this layer has a transparent color, go back and set the color again + // now that we know we are converting the blend method as well. that will + // make the color non-transparent, and change the blend method to alpha over + if (transparent_color_) + set_param("color", get_param("color")); + } + } + } + } + } else return Layer::set_param(param,value); return true;