Revision: 4488
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4488&view=rev
Author: mdboom
Date: 2007-11-28 10:26:40 -0800 (Wed, 28 Nov 2007)
Log Message:
-----------
Increase performance of draw_markers in Agg backend
Modified Paths:
--------------
branches/transforms/src/_backend_agg.cpp
branches/transforms/src/agg_py_path_iterator.h
Modified: branches/transforms/src/_backend_agg.cpp
===================================================================
--- branches/transforms/src/_backend_agg.cpp 2007-11-28 18:18:11 UTC (rev
4487)
+++ branches/transforms/src/_backend_agg.cpp 2007-11-28 18:26:40 UTC (rev
4488)
@@ -549,8 +549,8 @@
agg::serialized_scanlines_adaptor_aa8 sa;
agg::serialized_scanlines_adaptor_aa8::embedded_scanline sl;
- while (path_quantized.vertex(&x, &y) != agg::path_cmd_stop) {
- if (has_clippath) {
+ if (has_clippath) {
+ while (path_quantized.vertex(&x, &y) != agg::path_cmd_stop) {
pixfmt_amask_type pfa(*pixFmt, *alphaMask);
amask_ren_type r(pfa);
amask_aa_renderer_type ren(r);
@@ -563,7 +563,9 @@
ren.color(gc.color);
sa.init(strokeCache, strokeSize, x, y);
agg::render_scanlines(sa, sl, ren);
- } else {
+ }
+ } else {
+ while (path_quantized.vertex(&x, &y) != agg::path_cmd_stop) {
if (face.first) {
rendererAA->color(face.second);
sa.init(fillCache, fillSize, x, y);
@@ -1139,6 +1141,7 @@
m_iterator(0), m_m(m), m_n(n), m_coordinates(coordinates) {
}
+ private:
inline unsigned vertex(unsigned idx, double* x, double* y) {
size_t m = (idx & 0x2) ? (m_m + 1) : m_m;
size_t n = (idx+1 & 0x2) ? (m_n + 1) : m_n;
@@ -1148,8 +1151,9 @@
return (idx) ? agg::path_cmd_line_to : agg::path_cmd_move_to;
}
+ public:
inline unsigned vertex(double* x, double* y) {
- if (m_iterator >= total_vertices())
+ if (m_iterator >= total_vertices())
return agg::path_cmd_stop;
return vertex(m_iterator++, x, y);
}
@@ -1496,7 +1500,7 @@
int ymin = height;
int xmax = 0;
int ymax = 0;
-
+
// Looks at the alpha channel to find the minimum extents of the image
unsigned char* pixel = pixBuffer + 3;
for (int y = 0; y < (int)height; ++y) {
@@ -1520,11 +1524,11 @@
ymin = std::max(0, ymin - 1);
xmax = std::min(xmax, (int)width);
ymax = std::min(ymax, (int)height);
-
+
newwidth = xmax - xmin;
newheight = ymax - ymin;
int newsize = newwidth * newheight * 4;
-
+
unsigned char* buf = new unsigned char[newsize];
unsigned int* dst = (unsigned int*)buf;
unsigned int* src = (unsigned int*)pixBuffer;
@@ -1540,7 +1544,7 @@
bounds[1] = Py::Int(ymin);
bounds[2] = Py::Int(newwidth);
bounds[3] = Py::Int(newheight);
-
+
Py::Tuple result(2);
result[0] = data;
result[1] = bounds;
Modified: branches/transforms/src/agg_py_path_iterator.h
===================================================================
--- branches/transforms/src/agg_py_path_iterator.h 2007-11-28 18:18:11 UTC
(rev 4487)
+++ branches/transforms/src/agg_py_path_iterator.h 2007-11-28 18:26:40 UTC
(rev 4488)
@@ -17,7 +17,7 @@
m_vertices(NULL), m_codes(NULL), m_iterator(0) {
Py::Object vertices_obj = path_obj.getAttr("vertices");
Py::Object codes_obj = path_obj.getAttr("codes");
-
+
m_vertices = (PyArrayObject*)PyArray_FromObject
(vertices_obj.ptr(), PyArray_DOUBLE, 2, 2);
if (!m_vertices || PyArray_NDIM(m_vertices) != 2 ||
PyArray_DIM(m_vertices, 1) != 2)
@@ -26,7 +26,7 @@
if (codes_obj.ptr() != Py_None) {
m_codes = (PyArrayObject*)PyArray_FromObject
(codes_obj.ptr(), PyArray_UINT8, 1, 1);
- if (!m_codes)
+ if (!m_codes)
throw Py::ValueError("Invalid codes array.");
}
@@ -40,11 +40,11 @@
static const char code_map[];
+ private:
inline unsigned vertex(unsigned idx, double* x, double* y) {
- if (idx > m_total_vertices)
- throw Py::RuntimeError("Requested vertex past end");
- *x = *(double*)PyArray_GETPTR2(m_vertices, idx, 0);
- *y = *(double*)PyArray_GETPTR2(m_vertices, idx, 1);
+ char* pair = (char*)PyArray_GETPTR2(m_vertices, idx, 0);
+ *x = *(double*)pair;
+ *y = *(double*)(pair + PyArray_STRIDE(m_vertices, 1));
if (m_codes) {
return code_map[(int)*(char *)PyArray_GETPTR1(m_codes, idx)];
} else {
@@ -52,6 +52,7 @@
}
}
+ public:
inline unsigned vertex(double* x, double* y) {
if (m_iterator >= m_total_vertices) return agg::path_cmd_stop;
return vertex(m_iterator++, x, y);
@@ -71,10 +72,10 @@
};
// Maps path codes on the Python side to agg path commands
-const char PathIterator::code_map[] =
- {0,
- agg::path_cmd_move_to,
- agg::path_cmd_line_to,
+const char PathIterator::code_map[] =
+ {0,
+ agg::path_cmd_move_to,
+ agg::path_cmd_line_to,
agg::path_cmd_curve3,
agg::path_cmd_curve4,
agg::path_cmd_end_poly | agg::path_flags_close};
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins