projects
/
synfig.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added copyright lines for files I've edited this year.
[synfig.git]
/
synfig-core
/
trunk
/
src
/
synfig
/
layer_shape.cpp
diff --git
a/synfig-core/trunk/src/synfig/layer_shape.cpp
b/synfig-core/trunk/src/synfig/layer_shape.cpp
index
d1e7aef
..
539d715
100644
(file)
--- a/
synfig-core/trunk/src/synfig/layer_shape.cpp
+++ b/
synfig-core/trunk/src/synfig/layer_shape.cpp
@@
-1,12
+1,12
@@
/* === S Y N F I G ========================================================= */
/*! \file layer_shape.cpp
/* === S Y N F I G ========================================================= */
/*! \file layer_shape.cpp
-** \brief
Template Head
er
+** \brief
Implementation of the "Shape" lay
er
**
** $Id$
**
** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
**
** $Id$
**
** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-** Copyright (c) 2007 Chris Moore
+** Copyright (c) 2007
, 2008
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
**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
@@
-60,8
+60,8
@@
using namespace etl;
SYNFIG_LAYER_INIT(Layer_Shape);
SYNFIG_LAYER_SET_NAME(Layer_Shape,"shape");
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$");
SYNFIG_LAYER_SET_VERSION(Layer_Shape,"0.1");
SYNFIG_LAYER_SET_CVS_ID(Layer_Shape,"$Id$");
@@
-245,11
+245,13
@@
struct MonoSegment
//assumes that the rect culled away anything that would be beyond the edges
if(ydir > 0)
{
//assumes that the rect culled away anything that would be beyond the edges
if(ydir > 0)
{
- while(y > (*++p)[1]);
+ while(y > (*++p)[1])
+ ;
}
else
{
}
else
{
- while(y < (*++p)[1]);
+ while(y < (*++p)[1])
+ ;
}
//for the loop to break there must have been a slope (straight line would do nothing)
}
//for the loop to break there must have been a slope (straight line would do nothing)
@@
-335,7
+337,7
@@
struct CurveArray
if( (y > ymax && y > p[1][1]) || (y < ymin && y < p[1][1]) ) return 0;
//degenerate line max
if( (y > ymax && y > p[1][1]) || (y < ymin && y < p[1][1]) ) return 0;
//degenerate line max
- if(ymin == ymax == p[1][1])
+ if(ymin == ymax
&& ymax
== p[1][1])
return 0;
//degenerate accept - to the right and crossing the base line
return 0;
//degenerate accept - to the right and crossing the base line
@@
-713,7
+715,7
@@
struct Layer_Shape::Intersector
{
Rect aabb;
{
Rect aabb;
- //! true iff aabb hasn't been initiali
s
ed yet
+ //! true iff aabb hasn't been initiali
z
ed yet
bool initaabb;
int flags;
bool initaabb;
int flags;
@@
-1149,7
+1151,9
@@
Layer_Shape::clear()
bool
Layer_Shape::set_param(const String & param, const ValueBase &value)
{
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);
IMPORT(offset);
IMPORT(invert);
IMPORT(antialias);
@@
-1187,7
+1191,7
@@
Layer_Shape::get_param_vocab()const
.set_description(_("Layer_Shape Color"))
);
ret.push_back(ParamDesc("offset")
.set_description(_("Layer_Shape Color"))
);
ret.push_back(ParamDesc("offset")
- .set_local_name(_("
Position
"))
+ .set_local_name(_("
Offset
"))
);
ret.push_back(ParamDesc("invert")
.set_local_name(_("Invert"))
);
ret.push_back(ParamDesc("invert")
.set_local_name(_("Invert"))
@@
-1291,7
+1295,7
@@
Layer_Shape::get_color(Context context, const Point &p)const
//************** SCANLINE RENDERING *********************
void Layer_Shape::PolySpan::line_to(Real x, Real y)
{
//************** 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);
bool afterx = false;
const Real xin(x), yin(y);
@@
-1548,7
+1552,7
@@
void Layer_Shape::PolySpan::conic_to(Real x1, Real y1, Real x, Real y)
{
if(num >= MAX_SUBDIVISION_SIZE)
{
{
if(num >= MAX_SUBDIVISION_SIZE)
{
- warning("Curve subdivision somehow ran out of space while tesselating!");
+ warning("Curve subdivision somehow ran out of space while tessel
l
ating!");
//do something...
assert(0);
//do something...
assert(0);
@@
-1621,7
+1625,7
@@
void Layer_Shape::PolySpan::cubic_to(Real x1, Real y1, Real x2, Real y2, Real x,
{
if(num >= MAX_SUBDIVISION_SIZE)
{
{
if(num >= MAX_SUBDIVISION_SIZE)
{
- warning("Curve subdivision somehow ran out of space while tesselating!");
+ warning("Curve subdivision somehow ran out of space while tessel
l
ating!");
//do something...
assert(0);
//do something...
assert(0);
@@
-1699,7
+1703,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)
{
//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 trap
a
zoid area
+ current.addcover(dy,(fx1 + fx2)*dy/2); //horizontal trap
e
zoid area
return;
}
return;
}
@@
-1713,7
+1717,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
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 trap
a
zoidal area
+ current.addcover(mult,(1 + fx1)*mult/2); // fx1,fy1,1,fy@1 - starting trap
e
zoidal area
//move to the next pixel
fy1 += mult;
//move to the next pixel
fy1 += mult;
@@
-1749,7
+1753,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
mult = fx1*dydx; //next y intersection diff value
//first pixel
- current.addcover(mult,fx1*mult/2); // fx1,fy1,0,fy@0 - starting trap
a
zoidal area
+ current.addcover(mult,fx1*mult/2); // fx1,fy1,0,fy@0 - starting trap
e
zoidal area
//move to next pixel
fy1 += mult;
//move to next pixel
fy1 += mult;
@@
-1877,7
+1881,7
@@
void Layer_Shape::PolySpan::draw_line(Real x1, Real y1, Real x2, Real y2)
mult = (1 - fy1) * dxdy;
mult = (1 - fy1) * dxdy;
- //x interset scanline
+ //x interse
c
t scanline
x_from = x1 + mult;
draw_scanline(iy1,x1,fy1,x_from,1);
x_from = x1 + mult;
draw_scanline(iy1,x1,fy1,x_from,1);
@@
-1907,7
+1911,7
@@
void Layer_Shape::PolySpan::draw_line(Real x1, Real y1, Real x2, Real y2)
mult = fy1 * dxdy;
mult = fy1 * dxdy;
- //x interset scanline
+ //x interse
c
t scanline
x_from = x1 + mult;
draw_scanline(iy1,x1,fy1,x_from,0);
x_from = x1 + mult;
draw_scanline(iy1,x1,fy1,x_from,0);
@@
-2477,8
+2481,8
@@
Layer_Shape::accelerated_render(Context context,Surface *surface,int quality, co
Rect nrect;
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);
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
+2523,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(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
{
//we have to blur rather than be crappy
@@
-2640,7
+2644,11
@@
Layer_Shape::render_shape(Surface *surface,bool useblend,int /*quality*/,
PolySpan span;
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;
span.window.minx = 0;
span.window.miny = 0;
span.window.maxx = w;
@@
-2855,7
+2863,7
@@
Layer_Shape::render_shape(Surface *surface,bool useblend,int /*quality*/,
}
bool
}
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
const RendDesc &renddesc, ProgressCallback */*cb*/)const
{
// If our amount is set to zero, no need to render anything
@@
-2876,7
+2884,7
@@
Layer_Shape::render_shape(surface<float> *surface,int /*quality*/,
PolySpan span;
PolySpan span;
- //optimization for tesselating only inside tiles
+ //optimization for tessel
l
ating only inside tiles
span.window.minx = 0;
span.window.miny = 0;
span.window.maxx = w;
span.window.minx = 0;
span.window.miny = 0;
span.window.maxx = w;