From 998f0399992786d84246f56815c698f3a561c310 Mon Sep 17 00:00:00 2001 From: dooglus Date: Thu, 24 Jan 2008 17:20:08 +0000 Subject: [PATCH] Quite a lot of the example canvases use the trick of blending a transparent shape using blend method "straight", and relying on an old bug to mask just the pixels in the shape. Now that "straight" blending no longer only applies to the pixels in the shape, but to the whole layer, this trick no longer works. The example .sif files have been modified to no longer rely on the trick, but it's possible that other .sif files do use it, and so this change looks out for the trick and changes it to use a fully opaque shape with "alpha over" blending, which has the same effect. git-svn-id: http://svn.voria.com/code@1457 1f10aa63-cdf2-0310-b900-c93c546f37ac --- synfig-core/trunk/src/modules/mod_geometry/circle.cpp | 4 +++- synfig-core/trunk/src/modules/mod_geometry/rectangle.cpp | 4 +++- synfig-core/trunk/src/synfig/layer_composite.cpp | 9 +++++++++ synfig-core/trunk/src/synfig/layer_composite.h | 7 ++++++- synfig-core/trunk/src/synfig/layer_shape.cpp | 4 +++- 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/synfig-core/trunk/src/modules/mod_geometry/circle.cpp b/synfig-core/trunk/src/modules/mod_geometry/circle.cpp index b5d59e2..cef640a 100644 --- a/synfig-core/trunk/src/modules/mod_geometry/circle.cpp +++ b/synfig-core/trunk/src/modules/mod_geometry/circle.cpp @@ -73,7 +73,9 @@ Circle::Circle(): bool Circle::ImportParameters(const String ¶m, const ValueBase &value) { - IMPORT(color); + IMPORT_PLUS(color, { if (color.get_a() == 0) if (converted_blend_) { + set_blend_method(Color::BLEND_ALPHA_OVER); + color.set_a(1); } else transparent_color_ = true; }); IMPORT(radius); IMPORT(feather); IMPORT(invert); diff --git a/synfig-core/trunk/src/modules/mod_geometry/rectangle.cpp b/synfig-core/trunk/src/modules/mod_geometry/rectangle.cpp index eea1a21..ab1be69 100644 --- a/synfig-core/trunk/src/modules/mod_geometry/rectangle.cpp +++ b/synfig-core/trunk/src/modules/mod_geometry/rectangle.cpp @@ -87,7 +87,9 @@ Rectangle::Rectangle(): bool Rectangle::set_param(const String & param, const ValueBase &value) { - IMPORT(color); + IMPORT_PLUS(color, { if (color.get_a() == 0) if (converted_blend_) { + set_blend_method(Color::BLEND_ALPHA_OVER); + color.set_a(1); } else transparent_color_ = true; }); IMPORT(point1); IMPORT(point2); IMPORT(expand); diff --git a/synfig-core/trunk/src/synfig/layer_composite.cpp b/synfig-core/trunk/src/synfig/layer_composite.cpp index 2cd6a17..16f2c33 100644 --- a/synfig-core/trunk/src/synfig/layer_composite.cpp +++ b/synfig-core/trunk/src/synfig/layer_composite.cpp @@ -176,7 +176,16 @@ Layer_Composite::set_param(const String & param, const ValueBase &value) 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")); + } } } } diff --git a/synfig-core/trunk/src/synfig/layer_composite.h b/synfig-core/trunk/src/synfig/layer_composite.h index 1db98e2..50aeeff 100644 --- a/synfig-core/trunk/src/synfig/layer_composite.h +++ b/synfig-core/trunk/src/synfig/layer_composite.h @@ -60,9 +60,14 @@ protected: Color::BlendMethod blend_method=Color::BLEND_COMPOSITE ): amount_ (amount), - blend_method_ (blend_method) + blend_method_ (blend_method), + converted_blend_ (false), + transparent_color_ (false) { } + bool converted_blend_; + bool transparent_color_; + public: float get_amount()const { return amount_; } diff --git a/synfig-core/trunk/src/synfig/layer_shape.cpp b/synfig-core/trunk/src/synfig/layer_shape.cpp index 32dde4d..269eaf1 100644 --- a/synfig-core/trunk/src/synfig/layer_shape.cpp +++ b/synfig-core/trunk/src/synfig/layer_shape.cpp @@ -1149,7 +1149,9 @@ Layer_Shape::clear() bool Layer_Shape::set_param(const String & param, const ValueBase &value) { - IMPORT(color); + IMPORT_PLUS(color, { if (color.get_a() == 0) if (converted_blend_) { + set_blend_method(Color::BLEND_ALPHA_OVER); + color.set_a(1); } else transparent_color_ = true; }); IMPORT(offset); IMPORT(invert); IMPORT(antialias); -- 2.7.4