optimize svg rendering by moving bbox calc only needed by gradient rendering into gradient code
This commit is contained in:
parent
63a06a9aab
commit
bcf1454884
1 changed files with 8 additions and 19 deletions
|
@ -119,11 +119,12 @@ public:
|
||||||
void render_gradient(Rasterizer& ras,
|
void render_gradient(Rasterizer& ras,
|
||||||
Scanline& sl,
|
Scanline& sl,
|
||||||
Renderer& ren,
|
Renderer& ren,
|
||||||
const gradient &grad,
|
gradient const& grad,
|
||||||
agg::trans_affine const& mtx,
|
agg::trans_affine const& mtx,
|
||||||
double opacity,
|
double opacity,
|
||||||
const box2d<double> &symbol_bbox,
|
box2d<double> const& symbol_bbox,
|
||||||
const box2d<double> &path_bbox)
|
curved_trans_type & curved_trans,
|
||||||
|
unsigned path_id)
|
||||||
{
|
{
|
||||||
typedef agg::gamma_lut<agg::int8u, agg::int8u> gamma_lut_type;
|
typedef agg::gamma_lut<agg::int8u, agg::int8u> gamma_lut_type;
|
||||||
typedef agg::gradient_lut<agg::color_interpolator<agg::rgba8>, 1024> color_func_type;
|
typedef agg::gradient_lut<agg::color_interpolator<agg::rgba8>, 1024> color_func_type;
|
||||||
|
@ -165,17 +166,13 @@ public:
|
||||||
|
|
||||||
if (grad.get_units() == OBJECT_BOUNDING_BOX)
|
if (grad.get_units() == OBJECT_BOUNDING_BOX)
|
||||||
{
|
{
|
||||||
bx1=path_bbox.minx();
|
bounding_rect_single(curved_trans, path_id, &bx1, &by1, &bx2, &by2);
|
||||||
by1=path_bbox.miny();
|
|
||||||
bx2=path_bbox.maxx();
|
|
||||||
by2=path_bbox.maxy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
transform.translate(-bx1,-by1);
|
transform.translate(-bx1,-by1);
|
||||||
transform.scale(1.0/(bx2-bx1),1.0/(by2-by1));
|
transform.scale(1.0/(bx2-bx1),1.0/(by2-by1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (grad.get_gradient_type() == RADIAL)
|
if (grad.get_gradient_type() == RADIAL)
|
||||||
{
|
{
|
||||||
typedef agg::gradient_radial_focus gradient_adaptor_type;
|
typedef agg::gradient_radial_focus gradient_adaptor_type;
|
||||||
|
@ -261,10 +258,6 @@ public:
|
||||||
|
|
||||||
transform = attr.transform;
|
transform = attr.transform;
|
||||||
|
|
||||||
double bx1,by1,bx2,by2;
|
|
||||||
bounding_rect_single(curved_trans, attr.index, &bx1, &by1, &bx2, &by2);
|
|
||||||
box2d<double> path_bbox(bx1,by1,bx2,by2);
|
|
||||||
|
|
||||||
transform *= mtx;
|
transform *= mtx;
|
||||||
double scl = transform.scale();
|
double scl = transform.scale();
|
||||||
//curved_.approximation_method(curve_inc);
|
//curved_.approximation_method(curve_inc);
|
||||||
|
@ -290,7 +283,7 @@ public:
|
||||||
|
|
||||||
if(attr.fill_gradient.get_gradient_type() != NO_GRADIENT)
|
if(attr.fill_gradient.get_gradient_type() != NO_GRADIENT)
|
||||||
{
|
{
|
||||||
render_gradient(ras, sl, ren, attr.fill_gradient, transform, attr.fill_opacity * attr.opacity * opacity, symbol_bbox, path_bbox);
|
render_gradient(ras, sl, ren, attr.fill_gradient, transform, attr.fill_opacity * attr.opacity * opacity, symbol_bbox, curved_trans, attr.index);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -326,7 +319,7 @@ public:
|
||||||
|
|
||||||
if(attr.stroke_gradient.get_gradient_type() != NO_GRADIENT)
|
if(attr.stroke_gradient.get_gradient_type() != NO_GRADIENT)
|
||||||
{
|
{
|
||||||
render_gradient(ras, sl, ren, attr.stroke_gradient, transform, attr.stroke_opacity * attr.opacity * opacity, symbol_bbox, path_bbox);
|
render_gradient(ras, sl, ren, attr.stroke_gradient, transform, attr.stroke_opacity * attr.opacity * opacity, symbol_bbox, curved_trans, attr.index);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -349,7 +342,7 @@ public:
|
||||||
int feature_id,
|
int feature_id,
|
||||||
agg::trans_affine const& mtx,
|
agg::trans_affine const& mtx,
|
||||||
double opacity,
|
double opacity,
|
||||||
const box2d<double> &symbol_bbox)
|
box2d<double> const& symbol_bbox)
|
||||||
|
|
||||||
{
|
{
|
||||||
using namespace agg;
|
using namespace agg;
|
||||||
|
@ -369,10 +362,6 @@ public:
|
||||||
|
|
||||||
transform = attr.transform;
|
transform = attr.transform;
|
||||||
|
|
||||||
double bx1,by1,bx2,by2;
|
|
||||||
bounding_rect_single(curved_trans, attr.index, &bx1, &by1, &bx2, &by2);
|
|
||||||
box2d<double> path_bbox(bx1,by1,bx2,by2);
|
|
||||||
|
|
||||||
transform *= mtx;
|
transform *= mtx;
|
||||||
double scl = transform.scale();
|
double scl = transform.scale();
|
||||||
//curved_.approximation_method(curve_inc);
|
//curved_.approximation_method(curve_inc);
|
||||||
|
|
Loading…
Reference in a new issue