Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3e1705a

Browse files
committed
Minor speed improvements in Agg backend.
svn path=/trunk/matplotlib/; revision=4888
1 parent a061681 commit 3e1705a

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/_backend_agg.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,10 @@ bool should_snap(Path& path, const agg::trans_affine& trans) {
343343
return false;
344344

345345
code = path.vertex(&x0, &y0);
346+
if (code == agg::path_cmd_stop) {
347+
path.rewind(0);
348+
return false;
349+
}
346350
trans.transform(&x0, &y0);
347351

348352
while ((code = path.vertex(&x1, &y1)) != agg::path_cmd_stop) {
@@ -1602,7 +1606,6 @@ RendererAgg::rgb_to_color(const Py::SeqBase<Py::Object>& rgb, double alpha) {
16021606
double g = Py::Float(rgb[1]);
16031607
double b = Py::Float(rgb[2]);
16041608
return agg::rgba(r, g, b, alpha);
1605-
16061609
}
16071610

16081611

@@ -1615,8 +1618,6 @@ RendererAgg::points_to_pixels_snapto(const Py::Object& points) {
16151618
double p = Py::Float( points ) ;
16161619
//return (int)(p*PIXELS_PER_INCH/72.0*dpi/72.0)+0.5;
16171620
return (int)(p*dpi/72.0)+0.5;
1618-
1619-
16201621
}
16211622

16221623
double

src/agg_py_path_iterator.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class SimplifyPath
118118
SimplifyPath(VertexSource& source, bool quantize, bool simplify,
119119
double width = 0.0, double height = 0.0) :
120120
m_source(&source), m_quantize(quantize), m_simplify(simplify),
121-
m_width(width), m_height(height), m_queue_read(0), m_queue_write(0),
121+
m_width(width + 1.0), m_height(height + 1.0), m_queue_read(0), m_queue_write(0),
122122
m_moveto(true), m_lastx(0.0), m_lasty(0.0), m_clipped(false),
123123
m_do_clipping(width > 0.0 && height > 0.0),
124124
m_origdx(0.0), m_origdy(0.0),
@@ -246,9 +246,9 @@ class SimplifyPath
246246
//could be clipped, but a more involved calculation would be needed
247247
if (m_do_clipping &&
248248
((*x < -1.0 && m_lastx < -1.0) ||
249-
(*x > m_width + 1.0 && m_lastx > m_width + 1.0) ||
249+
(*x > m_width && m_lastx > m_width) ||
250250
(*y < -1.0 && m_lasty < -1.0) ||
251-
(*y > m_height + 1.0 && m_lasty > m_height + 1.0)))
251+
(*y > m_height && m_lasty > m_height)))
252252
{
253253
m_lastx = *x;
254254
m_lasty = *y;

0 commit comments

Comments
 (0)