Skip to content

Commit dc5b8c6

Browse files
committed
Speed up Gouraud shading in Agg backend.
svn path=/trunk/matplotlib/; revision=8464
1 parent dc89454 commit dc5b8c6

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

src/_backend_agg.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,19 +1824,15 @@ RendererAgg::draw_quad_mesh(const Py::Tuple& args)
18241824
}
18251825

18261826
void
1827-
RendererAgg::_draw_gouraud_triangle(const GCAgg& gc, const double* points,
1827+
RendererAgg::_draw_gouraud_triangle(const double* points,
18281828
const double* colors,
1829-
agg::trans_affine trans)
1829+
agg::trans_affine trans,
1830+
bool has_clippath)
18301831
{
18311832
typedef agg::rgba8 color_t;
18321833
typedef agg::span_gouraud_rgba<color_t> span_gen_t;
18331834
typedef agg::span_allocator<color_t> span_alloc_t;
18341835

1835-
theRasterizer.reset_clipping();
1836-
rendererBase.reset_clipping(true);
1837-
set_clipbox(gc.cliprect, theRasterizer);
1838-
bool has_clippath = render_clippath(gc.clippath, gc.clippath_trans);
1839-
18401836
trans *= agg::trans_affine_scaling(1.0, -1.0);
18411837
trans *= agg::trans_affine_translation(0.0, (double)height);
18421838

@@ -1897,6 +1893,11 @@ RendererAgg::draw_gouraud_triangle(const Py::Tuple& args)
18971893
PyArrayObject* points = NULL;
18981894
PyArrayObject* colors = NULL;
18991895

1896+
theRasterizer.reset_clipping();
1897+
rendererBase.reset_clipping(true);
1898+
set_clipbox(gc.cliprect, theRasterizer);
1899+
bool has_clippath = render_clippath(gc.clippath, gc.clippath_trans);
1900+
19001901
try
19011902
{
19021903
points = (PyArrayObject*)PyArray_ContiguousFromAny
@@ -1916,7 +1917,8 @@ RendererAgg::draw_gouraud_triangle(const Py::Tuple& args)
19161917
}
19171918

19181919
_draw_gouraud_triangle(
1919-
gc, (double*)PyArray_DATA(points), (double*)PyArray_DATA(colors), trans);
1920+
(double*)PyArray_DATA(points), (double*)PyArray_DATA(colors),
1921+
trans, has_clippath);
19201922
}
19211923
catch (...)
19221924
{
@@ -1951,6 +1953,11 @@ RendererAgg::draw_gouraud_triangles(const Py::Tuple& args)
19511953
PyArrayObject* points = NULL;
19521954
PyArrayObject* colors = NULL;
19531955

1956+
theRasterizer.reset_clipping();
1957+
rendererBase.reset_clipping(true);
1958+
set_clipbox(gc.cliprect, theRasterizer);
1959+
bool has_clippath = render_clippath(gc.clippath, gc.clippath_trans);
1960+
19541961
try
19551962
{
19561963
points = (PyArrayObject*)PyArray_ContiguousFromAny
@@ -1976,7 +1983,9 @@ RendererAgg::draw_gouraud_triangles(const Py::Tuple& args)
19761983

19771984
for (int i = 0; i < PyArray_DIM(points, 0); ++i)
19781985
{
1979-
_draw_gouraud_triangle(gc, (double*)PyArray_GETPTR1(points, i), (double*)PyArray_GETPTR1(colors, i), trans);
1986+
_draw_gouraud_triangle(
1987+
(double*)PyArray_GETPTR1(points, i),
1988+
(double*)PyArray_GETPTR1(colors, i), trans, has_clippath);
19801989
}
19811990
}
19821991
catch (...)

src/_backend_agg.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,8 @@ class RendererAgg: public Py::PythonExtension<RendererAgg>
263263

264264
void
265265
_draw_gouraud_triangle(
266-
const GCAgg& gc,
267-
const double* points, const double* colors, agg::trans_affine trans);
266+
const double* points, const double* colors,
267+
agg::trans_affine trans, bool has_clippath);
268268

269269
private:
270270
void create_alpha_buffers();

0 commit comments

Comments
 (0)