Quite a lot of the example canvases use the trick of blending a transparent shape...
[synfig.git] / synfig-core / trunk / src / synfig / layer_shape.cpp
index 8cb0884..269eaf1 100644 (file)
@@ -1,6 +1,6 @@
 /* === S Y N F I G ========================================================= */
 /*!    \file layer_shape.cpp
-**     \brief Template Header
+**     \brief Implementation of the "Shape" layer
 **
 **     $Id$
 **
@@ -60,8 +60,8 @@ using namespace etl;
 
 SYNFIG_LAYER_INIT(Layer_Shape);
 SYNFIG_LAYER_SET_NAME(Layer_Shape,"shape");
-SYNFIG_LAYER_SET_LOCAL_NAME(Layer_Shape,_("Shape"));
-SYNFIG_LAYER_SET_CATEGORY(Layer_Shape,_("Internal"));
+SYNFIG_LAYER_SET_LOCAL_NAME(Layer_Shape,N_("Shape"));
+SYNFIG_LAYER_SET_CATEGORY(Layer_Shape,N_("Internal"));
 SYNFIG_LAYER_SET_VERSION(Layer_Shape,"0.1");
 SYNFIG_LAYER_SET_CVS_ID(Layer_Shape,"$Id$");
 
@@ -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);
@@ -1291,7 +1293,7 @@ Layer_Shape::get_color(Context context, const Point &p)const
 //************** SCANLINE RENDERING *********************
 void Layer_Shape::PolySpan::line_to(Real x, Real y)
 {
-       Real n[4];
+       Real n[4] = {0,0,0,0};
        bool afterx = false;
 
        const Real xin(x), yin(y);
@@ -2477,8 +2479,8 @@ Layer_Shape::accelerated_render(Context context,Surface *surface,int quality, co
 
                Rect    nrect;
 
-               Real    pixelfeatherx = abs(feather/pw),
-                               pixelfeathery = abs(feather/ph);
+               Real    pixelfeatherx = quality == 10 ? 0 : abs(feather/pw),
+                               pixelfeathery = quality == 10 ? 0 : abs(feather/ph);
 
                nrect.set_point((aabb.minx - tl[0])/pw,(aabb.miny - tl[1])/ph);
                nrect.expand((aabb.maxx - tl[0])/pw,(aabb.maxy - tl[1])/ph);
@@ -2519,7 +2521,7 @@ Layer_Shape::accelerated_render(Context context,Surface *surface,int quality, co
 
        if(cb && !cb->amount_complete(10000,10001+renddesc.get_h())) return false;
 
-       if(feather)
+       if(feather && quality != 10)
        {
                //we have to blur rather than be crappy
 
@@ -2640,6 +2642,10 @@ Layer_Shape::render_shape(Surface *surface,bool useblend,int /*quality*/,
 
        PolySpan        span;
 
+       // if the pixels are zero sized then we're too zoomed out to see anything
+       if (pw == 0 || ph == 0)
+               return true;
+
        //optimization for tessellating only inside tiles
        span.window.minx = 0;
        span.window.miny = 0;
@@ -2855,7 +2861,7 @@ Layer_Shape::render_shape(Surface *surface,bool useblend,int /*quality*/,
 }
 
 bool
-Layer_Shape::render_shape(surface<float> *surface,int /*quality*/,
+Layer_Shape::render_shape(etl::surface<float> *surface,int /*quality*/,
                                                        const RendDesc &renddesc, ProgressCallback */*cb*/)const
 {
        // If our amount is set to zero, no need to render anything