X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Flayer_shape.cpp;h=269eaf18db3b7e4a71b5bdba2bc9e914b9561419;hb=998f0399992786d84246f56815c698f3a561c310;hp=3a9c52d9ae7c0303b074b179119cac5945d0e4e8;hpb=c3ad95144d148602f672e95ddda1f18fc35502f8;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/layer_shape.cpp b/synfig-core/trunk/src/synfig/layer_shape.cpp index 3a9c52d..269eaf1 100644 --- a/synfig-core/trunk/src/synfig/layer_shape.cpp +++ b/synfig-core/trunk/src/synfig/layer_shape.cpp @@ -1,11 +1,12 @@ /* === S Y N F I G ========================================================= */ /*! \file layer_shape.cpp -** \brief Template Header +** \brief Implementation of the "Shape" layer ** ** $Id$ ** ** \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 @@ -59,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$"); @@ -233,7 +234,7 @@ struct MonoSegment int intersect(Real x,Real y) const { - if((y < aabb.miny) || (y > aabb.maxy) || (x < aabb.minx)) return 0; + if((y < aabb.miny+EPSILON) || (y > aabb.maxy) || (x < aabb.minx)) return 0; if(x > aabb.maxx) return ydir; //int i = 0; @@ -712,7 +713,7 @@ struct Layer_Shape::Intersector { Rect aabb; - //! true iff aabb hasn't been initialised yet + //! true iff aabb hasn't been initialized yet bool initaabb; int flags; @@ -1148,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); @@ -1290,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); @@ -1327,7 +1330,7 @@ void Layer_Shape::PolySpan::line_to(Real x, Real y) //generate data for the ending clipped info if(y > window.maxy) { - //intial line to intersection (and degenerate) + //initial line to intersection (and degenerate) n[2] = x + (window.maxy - y) * dx / dy; //intersect coords @@ -1351,7 +1354,7 @@ void Layer_Shape::PolySpan::line_to(Real x, Real y) //generate data for the ending clipped info if(y < window.miny) { - //intial line to intersection (and degenerate) + //initial line to intersection (and degenerate) n[2] = x + (window.miny - y) * dx / dy; //intersect coords @@ -1401,7 +1404,7 @@ void Layer_Shape::PolySpan::line_to(Real x, Real y) //generate data for the ending clipped info if(x > window.maxx) { - //intial line to intersection (and degenerate) + //initial line to intersection (and degenerate) n[2] = y + (window.maxx - x) * dy / dx; n[0] = window.maxx; @@ -1430,7 +1433,7 @@ void Layer_Shape::PolySpan::line_to(Real x, Real y) //generate data for the ending clipped info if(x < window.minx) { - //intial line to intersection (and degenerate) + //initial line to intersection (and degenerate) n[2] = y + (window.minx - x) * dy / dx; n[0] = window.minx; @@ -1547,7 +1550,7 @@ void Layer_Shape::PolySpan::conic_to(Real x1, Real y1, Real x, Real y) { if(num >= MAX_SUBDIVISION_SIZE) { - warning("Curve subdivision somehow ran out of space while tesselating!"); + warning("Curve subdivision somehow ran out of space while tessellating!"); //do something... assert(0); @@ -1620,7 +1623,7 @@ void Layer_Shape::PolySpan::cubic_to(Real x1, Real y1, Real x2, Real y2, Real x, { if(num >= MAX_SUBDIVISION_SIZE) { - warning("Curve subdivision somehow ran out of space while tesselating!"); + warning("Curve subdivision somehow ran out of space while tessellating!"); //do something... assert(0); @@ -1698,7 +1701,7 @@ void Layer_Shape::PolySpan::draw_scanline(int y, Real x1, Real fy1, Real x2, Rea //case all in same pixel if(ix1 == ix2) //impossible for degenerate case (covered by the previous cases) { - current.addcover(dy,(fx1 + fx2)*dy/2); //horizontal trapazoid area + current.addcover(dy,(fx1 + fx2)*dy/2); //horizontal trapezoid area return; } @@ -1712,7 +1715,7 @@ void Layer_Shape::PolySpan::draw_scanline(int y, Real x1, Real fy1, Real x2, Rea mult = (1 - fx1)*dydx; //next y intersection diff value (at 1) //first pixel - current.addcover(mult,(1 + fx1)*mult/2); // fx1,fy1,1,fy@1 - starting trapazoidal area + current.addcover(mult,(1 + fx1)*mult/2); // fx1,fy1,1,fy@1 - starting trapezoidal area //move to the next pixel fy1 += mult; @@ -1748,7 +1751,7 @@ void Layer_Shape::PolySpan::draw_scanline(int y, Real x1, Real fy1, Real x2, Rea mult = fx1*dydx; //next y intersection diff value //first pixel - current.addcover(mult,fx1*mult/2); // fx1,fy1,0,fy@0 - starting trapazoidal area + current.addcover(mult,fx1*mult/2); // fx1,fy1,0,fy@0 - starting trapezoidal area //move to next pixel fy1 += mult; @@ -1876,7 +1879,7 @@ void Layer_Shape::PolySpan::draw_line(Real x1, Real y1, Real x2, Real y2) mult = (1 - fy1) * dxdy; - //x interset scanline + //x intersect scanline x_from = x1 + mult; draw_scanline(iy1,x1,fy1,x_from,1); @@ -1906,7 +1909,7 @@ void Layer_Shape::PolySpan::draw_line(Real x1, Real y1, Real x2, Real y2) mult = fy1 * dxdy; - //x interset scanline + //x intersect scanline x_from = x1 + mult; draw_scanline(iy1,x1,fy1,x_from,0); @@ -2476,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); @@ -2518,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 @@ -2639,7 +2642,11 @@ Layer_Shape::render_shape(Surface *surface,bool useblend,int /*quality*/, PolySpan span; - //optimization for tesselating only inside tiles + // 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; span.window.maxx = w; @@ -2854,7 +2861,7 @@ Layer_Shape::render_shape(Surface *surface,bool useblend,int /*quality*/, } bool -Layer_Shape::render_shape(surface *surface,int /*quality*/, +Layer_Shape::render_shape(etl::surface *surface,int /*quality*/, const RendDesc &renddesc, ProgressCallback */*cb*/)const { // If our amount is set to zero, no need to render anything @@ -2875,7 +2882,7 @@ Layer_Shape::render_shape(surface *surface,int /*quality*/, PolySpan span; - //optimization for tesselating only inside tiles + //optimization for tessellating only inside tiles span.window.minx = 0; span.window.miny = 0; span.window.maxx = w;