You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(115) |
Aug
(120) |
Sep
(137) |
Oct
(170) |
Nov
(461) |
Dec
(263) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(120) |
Feb
(74) |
Mar
(35) |
Apr
(74) |
May
(245) |
Jun
(356) |
Jul
(240) |
Aug
(115) |
Sep
(78) |
Oct
(225) |
Nov
(98) |
Dec
(271) |
2009 |
Jan
(132) |
Feb
(84) |
Mar
(74) |
Apr
(56) |
May
(90) |
Jun
(79) |
Jul
(83) |
Aug
(296) |
Sep
(214) |
Oct
(76) |
Nov
(82) |
Dec
(66) |
2010 |
Jan
(46) |
Feb
(58) |
Mar
(51) |
Apr
(77) |
May
(58) |
Jun
(126) |
Jul
(128) |
Aug
(64) |
Sep
(50) |
Oct
(44) |
Nov
(48) |
Dec
(54) |
2011 |
Jan
(68) |
Feb
(52) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
|
1
(10) |
2
(6) |
3
|
4
(10) |
5
(5) |
6
(5) |
7
(6) |
8
(2) |
9
(5) |
10
(7) |
11
(5) |
12
(8) |
13
(5) |
14
(7) |
15
(3) |
16
(1) |
17
(1) |
18
|
19
(1) |
20
(6) |
21
(6) |
22
(3) |
23
(3) |
24
(7) |
25
|
26
(5) |
27
(1) |
28
(3) |
29
(2) |
30
(3) |
|
|
|
Revision: 8466 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8466&view=rev Author: efiring Date: 2010年06月24日 21:17:30 +0000 (2010年6月24日) Log Message: ----------- backend_gtk: don't use idle events for draw_rubberband. Use of idle events for draw_rubberband was a peculiarity of backend_gtk. When using zoom-to-rect, it often caused a rubberband draw event to occur after the canvas redraw at the end of the zoom, leaving the canvas showing the state before the zoom action instead of showing the result of the action. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2010年06月24日 18:25:16 UTC (rev 8465) +++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2010年06月24日 21:17:30 UTC (rev 8466) @@ -611,11 +611,9 @@ self.win = window gtk.Toolbar.__init__(self) NavigationToolbar2.__init__(self, canvas) - self._idle_draw_id = 0 def set_message(self, s): - if self._idle_draw_id == 0: - self.message.set_label(s) + self.message.set_label(s) def set_cursor(self, cursor): self.canvas.window.set_cursor(cursord[cursor]) @@ -644,7 +642,8 @@ h = abs(y1 - y0) rect = [int(val)for val in min(x0,x1), min(y0, y1), w, h] - try: lastrect, imageBack = self._imageBack + try: + lastrect, imageBack = self._imageBack except AttributeError: #snap image back if event.inaxes is None: @@ -655,16 +654,9 @@ b = int(height)-(b+h) axrect = l,b,w,h self._imageBack = axrect, drawable.get_image(*axrect) - drawable.draw_rectangle(gc, False, *rect) - self._idle_draw_id = 0 else: - def idle_draw(*args): - drawable.draw_image(gc, imageBack, 0, 0, *lastrect) - drawable.draw_rectangle(gc, False, *rect) - self._idle_draw_id = 0 - return False - if self._idle_draw_id == 0: - self._idle_draw_id = gobject.idle_add(idle_draw) + drawable.draw_image(gc, imageBack, 0, 0, *lastrect) + drawable.draw_rectangle(gc, False, *rect) def _init_toolbar(self): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8465 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8465&view=rev Author: mdboom Date: 2010年06月24日 18:25:16 +0000 (2010年6月24日) Log Message: ----------- [3018198] Fixing the build with clang Typo in agg causes a template instantiation bug on compilers that actually instantiate everything. Modified Paths: -------------- trunk/matplotlib/agg24/include/agg_scanline_u.h Modified: trunk/matplotlib/agg24/include/agg_scanline_u.h =================================================================== --- trunk/matplotlib/agg24/include/agg_scanline_u.h 2010年06月24日 17:59:48 UTC (rev 8464) +++ trunk/matplotlib/agg24/include/agg_scanline_u.h 2010年06月24日 18:25:16 UTC (rev 8465) @@ -2,8 +2,8 @@ // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // @@ -13,12 +13,12 @@ // http://www.antigrain.com //---------------------------------------------------------------------------- // -// Adaptation for 32-bit screen coordinates (scanline32_u) has been sponsored by +// Adaptation for 32-bit screen coordinates (scanline32_u) has been sponsored by // Liberty Technology Systems, Inc., visit http://lib-sys.com // // Liberty Technology Systems, Inc. is the provider of // PostScript and PDF technology for software developers. -// +// //---------------------------------------------------------------------------- #ifndef AGG_SCANLINE_U_INCLUDED @@ -32,22 +32,22 @@ // // Unpacked scanline container class // - // This class is used to transfer data from a scanline rasterizer - // to the rendering buffer. It's organized very simple. The class stores - // information of horizontal spans to render it into a pixel-map buffer. - // Each span has staring X, length, and an array of bytes that determine the - // cover-values for each pixel. - // Before using this class you should know the minimal and maximal pixel + // This class is used to transfer data from a scanline rasterizer + // to the rendering buffer. It's organized very simple. The class stores + // information of horizontal spans to render it into a pixel-map buffer. + // Each span has staring X, length, and an array of bytes that determine the + // cover-values for each pixel. + // Before using this class you should know the minimal and maximal pixel // coordinates of your scanline. The protocol of using is: // 1. reset(min_x, max_x) - // 2. add_cell() / add_span() - accumulate scanline. + // 2. add_cell() / add_span() - accumulate scanline. // When forming one scanline the next X coordinate must be always greater // than the last stored one, i.e. it works only with ordered coordinates. // 3. Call finalize(y) and render the scanline. // 3. Call reset_spans() to prepare for the new scanline. - // + // // 4. Rendering: - // + // // Scanline provides an iterator class that allows you to extract // the spans and the cover values for each pixel. Be aware that clipping // has not been done yet, so you should perform it yourself. @@ -61,10 +61,10 @@ // ************************************ // // scanline_u8::const_iterator span = sl.begin(); - // - // unsigned char* row = m_rbuf->row(y); // The the address of the beginning + // + // unsigned char* row = m_rbuf->row(y); // The the address of the beginning // // of the current row - // + // // unsigned num_spans = sl.num_spans(); // Number of spans. It's guaranteed that // // num_spans is always greater than 0. // @@ -75,7 +75,7 @@ // // int num_pix = span->len; // Number of pixels of the span. // // Always greater than 0, still it's - // // better to use "int" instead of + // // better to use "int" instead of // // "unsigned" because it's more // // convenient for clipping // int x = span->x; @@ -86,24 +86,24 @@ // ************************************** // // unsigned char* dst = row + x; // Calculate the start address of the row. - // // In this case we assume a simple + // // In this case we assume a simple // // grayscale image 1-byte per pixel. // do // { - // *dst++ = *covers++; // Hypotetical rendering. + // *dst++ = *covers++; // Hypotetical rendering. // } // while(--num_pix); // // ++span; - // } + // } // while(--num_spans); // num_spans cannot be 0, so this loop is quite safe //------------------------------------------------------------------------ // // The question is: why should we accumulate the whole scanline when we // could render just separate spans when they're ready? - // That's because using the scanline is generally faster. When is consists + // That's because using the scanline is generally faster. When is consists // of more than one span the conditions for the processor cash system - // are better, because switching between two different areas of memory + // are better, because switching between two different areas of memory // (that can be very large) occurs less frequently. //------------------------------------------------------------------------ class scanline_u8 @@ -203,9 +203,9 @@ } //-------------------------------------------------------------------- - void finalize(int y) - { - m_y = y; + void finalize(int y) + { + m_y = y; } //-------------------------------------------------------------------- @@ -238,11 +238,11 @@ //==========================================================scanline_u8_am - // + // // The scanline container with alpha-masking - // + // //------------------------------------------------------------------------ - template<class AlphaMask> + template<class AlphaMask> class scanline_u8_am : public scanline_u8 { public: @@ -264,9 +264,9 @@ unsigned count = base_type::num_spans(); do { - m_alpha_mask->combine_hspan(span->x, - base_type::y(), - span->covers, + m_alpha_mask->combine_hspan(span->x, + base_type::y(), + span->covers, span->len); ++span; } @@ -390,8 +390,8 @@ } else { - m_spans.add(span(coord_type(x + m_min_x), - coord_type(len), + m_spans.add(span(coord_type(x + m_min_x), + coord_type(len), &m_covers[x])); } m_last_x = x + len - 1; @@ -408,17 +408,17 @@ } else { - m_spans.add(span(coord_type(x + m_min_x), - coord_type(len), + m_spans.add(span(coord_type(x + m_min_x), + coord_type(len), &m_covers[x])); } m_last_x = x + len - 1; } //-------------------------------------------------------------------- - void finalize(int y) - { - m_y = y; + void finalize(int y) + { + m_y = y; } //-------------------------------------------------------------------- @@ -450,15 +450,15 @@ //========================================================scanline32_u8_am - // + // // The scanline container with alpha-masking - // + // //------------------------------------------------------------------------ - template<class AlphaMask> + template<class AlphaMask> class scanline32_u8_am : public scanline32_u8 { public: - typedef scanline_u8 base_type; + typedef scanline32_u8 base_type; typedef AlphaMask alpha_mask_type; typedef base_type::cover_type cover_type; typedef base_type::coord_type coord_type; @@ -477,9 +477,9 @@ unsigned count = base_type::num_spans(); do { - m_alpha_mask->combine_hspan(span->x, - base_type::y(), - span->covers, + m_alpha_mask->combine_hspan(span->x, + base_type::y(), + span->covers, span->len); ++span; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8464 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8464&view=rev Author: mdboom Date: 2010年06月24日 17:59:48 +0000 (2010年6月24日) Log Message: ----------- Speed up Gouraud shading in Agg backend. Modified Paths: -------------- trunk/matplotlib/src/_backend_agg.cpp trunk/matplotlib/src/_backend_agg.h Modified: trunk/matplotlib/src/_backend_agg.cpp =================================================================== --- trunk/matplotlib/src/_backend_agg.cpp 2010年06月24日 17:12:26 UTC (rev 8463) +++ trunk/matplotlib/src/_backend_agg.cpp 2010年06月24日 17:59:48 UTC (rev 8464) @@ -1824,19 +1824,15 @@ } void -RendererAgg::_draw_gouraud_triangle(const GCAgg& gc, const double* points, +RendererAgg::_draw_gouraud_triangle(const double* points, const double* colors, - agg::trans_affine trans) + agg::trans_affine trans, + bool has_clippath) { typedef agg::rgba8 color_t; typedef agg::span_gouraud_rgba<color_t> span_gen_t; typedef agg::span_allocator<color_t> span_alloc_t; - theRasterizer.reset_clipping(); - rendererBase.reset_clipping(true); - set_clipbox(gc.cliprect, theRasterizer); - bool has_clippath = render_clippath(gc.clippath, gc.clippath_trans); - trans *= agg::trans_affine_scaling(1.0, -1.0); trans *= agg::trans_affine_translation(0.0, (double)height); @@ -1897,6 +1893,11 @@ PyArrayObject* points = NULL; PyArrayObject* colors = NULL; + theRasterizer.reset_clipping(); + rendererBase.reset_clipping(true); + set_clipbox(gc.cliprect, theRasterizer); + bool has_clippath = render_clippath(gc.clippath, gc.clippath_trans); + try { points = (PyArrayObject*)PyArray_ContiguousFromAny @@ -1916,7 +1917,8 @@ } _draw_gouraud_triangle( - gc, (double*)PyArray_DATA(points), (double*)PyArray_DATA(colors), trans); + (double*)PyArray_DATA(points), (double*)PyArray_DATA(colors), + trans, has_clippath); } catch (...) { @@ -1951,6 +1953,11 @@ PyArrayObject* points = NULL; PyArrayObject* colors = NULL; + theRasterizer.reset_clipping(); + rendererBase.reset_clipping(true); + set_clipbox(gc.cliprect, theRasterizer); + bool has_clippath = render_clippath(gc.clippath, gc.clippath_trans); + try { points = (PyArrayObject*)PyArray_ContiguousFromAny @@ -1976,7 +1983,9 @@ for (int i = 0; i < PyArray_DIM(points, 0); ++i) { - _draw_gouraud_triangle(gc, (double*)PyArray_GETPTR1(points, i), (double*)PyArray_GETPTR1(colors, i), trans); + _draw_gouraud_triangle( + (double*)PyArray_GETPTR1(points, i), + (double*)PyArray_GETPTR1(colors, i), trans, has_clippath); } } catch (...) Modified: trunk/matplotlib/src/_backend_agg.h =================================================================== --- trunk/matplotlib/src/_backend_agg.h 2010年06月24日 17:12:26 UTC (rev 8463) +++ trunk/matplotlib/src/_backend_agg.h 2010年06月24日 17:59:48 UTC (rev 8464) @@ -263,8 +263,8 @@ void _draw_gouraud_triangle( - const GCAgg& gc, - const double* points, const double* colors, agg::trans_affine trans); + const double* points, const double* colors, + agg::trans_affine trans, bool has_clippath); private: void create_alpha_buffers(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8463 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8463&view=rev Author: mdboom Date: 2010年06月24日 17:12:26 +0000 (2010年6月24日) Log Message: ----------- Clipping to the figure rectangle doesn't work on curves, so turn it off in that case. Modified Paths: -------------- trunk/matplotlib/src/_backend_agg.cpp Modified: trunk/matplotlib/src/_backend_agg.cpp =================================================================== --- trunk/matplotlib/src/_backend_agg.cpp 2010年06月24日 17:05:49 UTC (rev 8462) +++ trunk/matplotlib/src/_backend_agg.cpp 2010年06月24日 17:12:26 UTC (rev 8463) @@ -1304,7 +1304,7 @@ trans *= agg::trans_affine_scaling(1.0, -1.0); trans *= agg::trans_affine_translation(0.0, (double)height); - bool clip = !face.first && gc.hatchpath.isNone(); + bool clip = !face.first && gc.hatchpath.isNone() && !path.has_curves(); bool simplify = path.should_simplify() && clip; transformed_path_t tpath(path, trans); @@ -1498,7 +1498,7 @@ } } - bool do_clip = !face.first && gc.hatchpath.isNone(); + bool do_clip = !face.first && gc.hatchpath.isNone() && !has_curves; if (check_snap) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8462 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8462&view=rev Author: mdboom Date: 2010年06月24日 17:05:49 +0000 (2010年6月24日) Log Message: ----------- Use the more standard term "pop" rather than "flush" for removing the next item from the queue. Modified Paths: -------------- trunk/matplotlib/src/path_converters.h Modified: trunk/matplotlib/src/path_converters.h =================================================================== --- trunk/matplotlib/src/path_converters.h 2010年06月24日 14:48:00 UTC (rev 8461) +++ trunk/matplotlib/src/path_converters.h 2010年06月24日 17:05:49 UTC (rev 8462) @@ -88,7 +88,7 @@ } inline bool - queue_flush(unsigned *cmd, double *x, double *y) + queue_pop(unsigned *cmd, double *x, double *y) { if (queue_nonempty()) { @@ -159,7 +159,7 @@ if (m_has_curves) { /* This is the slow method for when there might be curves. */ - if (queue_flush(&code, x, y)) + if (queue_pop(&code, x, y)) { return code; } @@ -216,7 +216,7 @@ } } - if (queue_flush(&code, x, y)) + if (queue_pop(&code, x, y)) { return code; } @@ -567,7 +567,7 @@ the queue before proceeding to the main loop below. -- Michael Droettboom */ - if (queue_flush(&cmd, x, y)) + if (queue_pop(&cmd, x, y)) { return cmd; } @@ -740,7 +740,7 @@ /* Return the first item in the queue, if any, otherwise indicate that we're done. */ - if (queue_flush(&cmd, x, y)) + if (queue_pop(&cmd, x, y)) { return cmd; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8461 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8461&view=rev Author: mdboom Date: 2010年06月24日 14:48:00 +0000 (2010年6月24日) Log Message: ----------- [3020704] set_xlim() problem Bug in PathClipper when vertices fall precisely on the clipping edge. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/tests/test_simplification.py trunk/matplotlib/src/path_converters.h Added Paths: ----------- trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_simplification/clipper_edge.pdf trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_simplification/clipper_edge.png trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_simplification/clipper_edge.svg Added: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_simplification/clipper_edge.pdf =================================================================== (Binary files differ) Property changes on: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_simplification/clipper_edge.pdf ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_simplification/clipper_edge.png =================================================================== (Binary files differ) Property changes on: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_simplification/clipper_edge.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_simplification/clipper_edge.svg =================================================================== --- trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_simplification/clipper_edge.svg (rev 0) +++ trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_simplification/clipper_edge.svg 2010年06月24日 14:48:00 UTC (rev 8461) @@ -0,0 +1,104 @@ +<?xml version="1.0" standalone="no"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" + "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<!-- Created with matplotlib (http://matplotlib.sourceforge.net/) --> +<svg width="144pt" height="72pt" viewBox="0 0 144 72" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + version="1.1" + id="svg1"> +<filter id="colorAdd"><feComposite in="SourceGraphic" in2="BackgroundImage" operator="arithmetic" k2="1" k3="1"/></filter> +<g id="figure1"> +<g id="patch1"> +<path style="fill: #ffffff; stroke: #ffffff; stroke-width: 1.000000; stroke-linejoin: round; stroke-linecap: square; opacity: 1.000000" d="M0.000000 72.000000L144.000000 72.000000L144.000000 0.000000 +L0.000000 0.000000L0.000000 72.000000"/> +</g> +<g id="axes1"> +<g id="patch2"> +<path style="fill: #ffffff; opacity: 1.000000" d="M0.000000 72.000000L144.000000 72.000000L144.000000 0.000000 +L0.000000 0.000000L0.000000 72.000000"/> +</g> +<g id="line2d1"> +<defs> + <clipPath id="p7a7a30041bcd0eda414889f4295b8ec2"> +<rect x="0.000000" y="0.000000" width="144.000000" height="72.000000"/> + </clipPath> +</defs><path style="fill: none; stroke: #0000ff; stroke-width: 1.000000; stroke-linejoin: round; stroke-linecap: square; opacity: 1.000000" clip-path="url(#p7a7a30041bcd0eda414889f4295b8ec2)" d="M-180.000000 72.000000L36.000000 72.000000L72.000000 14.400000 +L108.000000 72.000000L144.000000 0.000000"/> +</g> +<g id="matplotlib.axis1"> +<g id="xtick1"> +<g id="line2d2"> +<defs><path id="m30e32995789d870ad79a2e54c91cf9c6" d="M0.000000 0.000000L0.000000 -4.000000"/></defs> +<g ><use style="fill: none; stroke: #000000; stroke-width: 0.500000; stroke-linejoin: round; stroke-linecap: butt; opacity: 1.000000" xlink:href="#m30e32995789d870ad79a2e54c91cf9c6" x="0.000000" y="72.000000"/> +</g></g> +</g> +<g id="xtick2"> +<g id="line2d3"> +<g ><use style="fill: none; stroke: #000000; stroke-width: 0.500000; stroke-linejoin: round; stroke-linecap: butt; opacity: 1.000000" xlink:href="#m30e32995789d870ad79a2e54c91cf9c6" x="36.000000" y="72.000000"/> +</g></g> +</g> +<g id="xtick3"> +<g id="line2d4"> +<g ><use style="fill: none; stroke: #000000; stroke-width: 0.500000; stroke-linejoin: round; stroke-linecap: butt; opacity: 1.000000" xlink:href="#m30e32995789d870ad79a2e54c91cf9c6" x="72.000000" y="72.000000"/> +</g></g> +</g> +<g id="xtick4"> +<g id="line2d5"> +<g ><use style="fill: none; stroke: #000000; stroke-width: 0.500000; stroke-linejoin: round; stroke-linecap: butt; opacity: 1.000000" xlink:href="#m30e32995789d870ad79a2e54c91cf9c6" x="108.000000" y="72.000000"/> +</g></g> +</g> +<g id="xtick5"> +<g id="line2d6"> +<g ><use style="fill: none; stroke: #000000; stroke-width: 0.500000; stroke-linejoin: round; stroke-linecap: butt; opacity: 1.000000" xlink:href="#m30e32995789d870ad79a2e54c91cf9c6" x="144.000000" y="72.000000"/> +</g></g> +</g> +</g> +<g id="matplotlib.axis2"> +<g id="ytick1"> +<g id="line2d7"> +<defs><path id="m3400efa6b1638b3fea9e19e898273957" d="M0.000000 0.000000L4.000000 0.000000"/></defs> +<g ><use style="fill: none; stroke: #000000; stroke-width: 0.500000; stroke-linejoin: round; stroke-linecap: butt; opacity: 1.000000" xlink:href="#m3400efa6b1638b3fea9e19e898273957" x="0.000000" y="72.000000"/> +</g></g> +</g> +<g id="ytick2"> +<g id="line2d8"> +<g ><use style="fill: none; stroke: #000000; stroke-width: 0.500000; stroke-linejoin: round; stroke-linecap: butt; opacity: 1.000000" xlink:href="#m3400efa6b1638b3fea9e19e898273957" x="0.000000" y="57.600000"/> +</g></g> +</g> +<g id="ytick3"> +<g id="line2d9"> +<g ><use style="fill: none; stroke: #000000; stroke-width: 0.500000; stroke-linejoin: round; stroke-linecap: butt; opacity: 1.000000" xlink:href="#m3400efa6b1638b3fea9e19e898273957" x="0.000000" y="43.200000"/> +</g></g> +</g> +<g id="ytick4"> +<g id="line2d10"> +<g ><use style="fill: none; stroke: #000000; stroke-width: 0.500000; stroke-linejoin: round; stroke-linecap: butt; opacity: 1.000000" xlink:href="#m3400efa6b1638b3fea9e19e898273957" x="0.000000" y="28.800000"/> +</g></g> +</g> +<g id="ytick5"> +<g id="line2d11"> +<g ><use style="fill: none; stroke: #000000; stroke-width: 0.500000; stroke-linejoin: round; stroke-linecap: butt; opacity: 1.000000" xlink:href="#m3400efa6b1638b3fea9e19e898273957" x="0.000000" y="14.400000"/> +</g></g> +</g> +<g id="ytick6"> +<g id="line2d12"> +<g ><use style="fill: none; stroke: #000000; stroke-width: 0.500000; stroke-linejoin: round; stroke-linecap: butt; opacity: 1.000000" xlink:href="#m3400efa6b1638b3fea9e19e898273957" x="0.000000" y="0.000000"/> +</g></g> +</g> +</g> +<g id="patch3"> +<path style="fill: none; stroke: #000000; stroke-width: 1.000000; stroke-linejoin: round; stroke-linecap: square; opacity: 1.000000" d="M0.000000 0.000000L144.000000 0.000000"/> +</g> +<g id="patch4"> +<path style="fill: none; stroke: #000000; stroke-width: 1.000000; stroke-linejoin: round; stroke-linecap: square; opacity: 1.000000" d="M144.000000 72.000000L144.000000 0.000000"/> +</g> +<g id="patch5"> +<path style="fill: none; stroke: #000000; stroke-width: 1.000000; stroke-linejoin: round; stroke-linecap: square; opacity: 1.000000" d="M0.000000 72.000000L144.000000 72.000000"/> +</g> +<g id="patch6"> +<path style="fill: none; stroke: #000000; stroke-width: 1.000000; stroke-linejoin: round; stroke-linecap: square; opacity: 1.000000" d="M0.000000 72.000000L0.000000 0.000000"/> +</g> +</g> +</g> +</svg> Modified: trunk/matplotlib/lib/matplotlib/tests/test_simplification.py =================================================================== --- trunk/matplotlib/lib/matplotlib/tests/test_simplification.py 2010年06月24日 13:06:03 UTC (rev 8460) +++ trunk/matplotlib/lib/matplotlib/tests/test_simplification.py 2010年06月24日 14:48:00 UTC (rev 8461) @@ -186,7 +186,24 @@ else: rcParams['path.simplify'] = True +@image_comparison(baseline_images=['clipper_edge']) +def test_clipper(): + dat = (0, 1, 0, 2, 0, 3, 0, 4, 0, 5) + fig = plt.figure(figsize=(2, 1)) + fig.subplots_adjust(left = 0, bottom = 0, wspace = 0, hspace = 0) + ax = fig.add_axes((0, 0, 1.0, 1.0), ylim = (0, 5), autoscale_on = False) + ax.plot(dat) + ax.xaxis.set_major_locator(plt.MultipleLocator(1)) + ax.xaxis.set_major_formatter(plt.NullFormatter()) + ax.yaxis.set_major_locator(plt.MultipleLocator(1)) + ax.yaxis.set_major_formatter(plt.NullFormatter()) + ax.xaxis.set_ticks_position('bottom') + ax.yaxis.set_ticks_position('left') + + ax.set_xlim(5, 9) + fig.savefig('clipper_edge') + if __name__=='__main__': import nose nose.runmodule(argv=['-s','--with-doctest'], exit=False) Modified: trunk/matplotlib/src/path_converters.h =================================================================== --- trunk/matplotlib/src/path_converters.h 2010年06月24日 13:06:03 UTC (rev 8460) +++ trunk/matplotlib/src/path_converters.h 2010年06月24日 14:48:00 UTC (rev 8461) @@ -288,7 +288,7 @@ PathClipper(VertexSource& source, bool do_clipping, double width, double height) : m_source(&source), m_do_clipping(do_clipping), - m_cliprect(0.0, 0.0, width, height), m_moveto(true), + m_cliprect(-1.0, -1.0, width + 1.0, height + 1.0), m_moveto(true), m_has_next(false) { // empty @@ -296,10 +296,13 @@ PathClipper(VertexSource& source, bool do_clipping, const agg::rect_base<double>& rect) : - m_source(&source), m_do_clipping(do_clipping), - m_cliprect(rect), m_moveto(true), m_has_next(false) + m_source(&source), m_do_clipping(do_clipping), + m_cliprect(rect), m_moveto(true), m_has_next(false) { - // empty + m_cliprect.x1 -= 1.0; + m_cliprect.y1 -= 1.0; + m_cliprect.x2 += 1.0; + m_cliprect.y2 += 1.0; } inline void This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8460 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8460&view=rev Author: mdboom Date: 2010年06月24日 13:06:03 +0000 (2010年6月24日) Log Message: ----------- Standardizing formatting of C/C++ code. Modified Paths: -------------- trunk/matplotlib/src/_backend_agg.cpp trunk/matplotlib/src/_backend_agg.h trunk/matplotlib/src/_gtkagg.cpp trunk/matplotlib/src/_image.cpp trunk/matplotlib/src/_image.h trunk/matplotlib/src/_path.cpp trunk/matplotlib/src/_png.cpp trunk/matplotlib/src/_tkagg.cpp trunk/matplotlib/src/_ttconv.cpp trunk/matplotlib/src/_windowing.cpp trunk/matplotlib/src/_wxagg.cpp trunk/matplotlib/src/agg_py_path_iterator.h trunk/matplotlib/src/ft2font.cpp trunk/matplotlib/src/ft2font.h trunk/matplotlib/src/mplutils.cpp trunk/matplotlib/src/mplutils.h trunk/matplotlib/src/path_cleanup.cpp trunk/matplotlib/src/path_converters.h Modified: trunk/matplotlib/src/_backend_agg.cpp =================================================================== --- trunk/matplotlib/src/_backend_agg.cpp 2010年06月23日 14:44:32 UTC (rev 8459) +++ trunk/matplotlib/src/_backend_agg.cpp 2010年06月24日 13:06:03 UTC (rev 8460) @@ -54,57 +54,82 @@ /* Convert dashes from the Python representation as nested sequences to the C++ representation as a std::vector<std::pair<double, double> > - (GCAgg::dash_t) -*/ -void convert_dashes(const Py::Tuple& dashes, double dpi, GCAgg::dash_t& dashes_out, - double& dashOffset_out) { - if (dashes.length()!=2) - throw Py::ValueError(Printf("Dash descriptor must be a length 2 tuple; found %d", dashes.length()).str()); + (GCAgg::dash_t) */ +void +convert_dashes(const Py::Tuple& dashes, double dpi, + GCAgg::dash_t& dashes_out, double& dashOffset_out) +{ + if (dashes.length() != 2) + { + throw Py::ValueError( + Printf("Dash descriptor must be a length 2 tuple; found %d", + dashes.length()).str() + ); + } - dashes_out.clear(); - dashOffset_out = 0.0; - if (dashes[0].ptr() == Py_None) - return; + dashes_out.clear(); + dashOffset_out = 0.0; + if (dashes[0].ptr() == Py_None) + { + return; + } - dashOffset_out = double(Py::Float(dashes[0])) * dpi/72.0; + dashOffset_out = double(Py::Float(dashes[0])) * dpi / 72.0; - Py::SeqBase<Py::Object> dashSeq = dashes[1]; + Py::SeqBase<Py::Object> dashSeq = dashes[1]; - size_t Ndash = dashSeq.length(); - if (Ndash % 2 != 0) - throw Py::ValueError(Printf("Dash sequence must be an even length sequence; found %d", Ndash).str()); + size_t Ndash = dashSeq.length(); + if (Ndash % 2 != 0) + { + throw Py::ValueError( + Printf("Dash sequence must be an even length sequence; found %d", Ndash).str() + ); + } - dashes_out.clear(); - dashes_out.reserve(Ndash / 2); + dashes_out.clear(); + dashes_out.reserve(Ndash / 2); - double val0, val1; - for (size_t i = 0; i < Ndash; i += 2) { - val0 = double(Py::Float(dashSeq[i])) * dpi/72.0; - val1 = double(Py::Float(dashSeq[i+1])) * dpi/72.0; - dashes_out.push_back(std::make_pair(val0, val1)); - } + double val0, val1; + for (size_t i = 0; i < Ndash; i += 2) + { + val0 = double(Py::Float(dashSeq[i])) * dpi / 72.0; + val1 = double(Py::Float(dashSeq[i+1])) * dpi / 72.0; + dashes_out.push_back(std::make_pair(val0, val1)); + } } -Py::Object BufferRegion::to_string(const Py::Tuple &args) { - // owned=true to prevent memory leak - return Py::String(PyString_FromStringAndSize((const char*)data, height*stride), true); + +Py::Object +BufferRegion::to_string(const Py::Tuple &args) +{ + // owned=true to prevent memory leak + return Py::String(PyString_FromStringAndSize((const char*)data, height*stride), true); } -Py::Object BufferRegion::set_x(const Py::Tuple &args) { + +Py::Object +BufferRegion::set_x(const Py::Tuple &args) +{ args.verify_length(1); - size_t x = Py::Int( args[0] ); + size_t x = Py::Int(args[0]); rect.x1 = x; return Py::Object(); } -Py::Object BufferRegion::set_y(const Py::Tuple &args) { + +Py::Object +BufferRegion::set_y(const Py::Tuple &args) +{ args.verify_length(1); - size_t y = Py::Int( args[0] ); + size_t y = Py::Int(args[0]); rect.y1 = y; return Py::Object(); } -Py::Object BufferRegion::get_extents(const Py::Tuple &args) { + +Py::Object +BufferRegion::get_extents(const Py::Tuple &args) +{ args.verify_length(0); Py::Tuple extents(4); @@ -116,562 +141,673 @@ return extents; } -Py::Object BufferRegion::to_string_argb(const Py::Tuple &args) { - // owned=true to prevent memory leak - Py_ssize_t length; - unsigned char* pix; - unsigned char* begin; - unsigned char* end; - unsigned char tmp; - size_t i, j; - PyObject* str = PyString_FromStringAndSize((const char*)data, height*stride); - if (PyString_AsStringAndSize(str, (char**)&begin, &length)) { - throw Py::TypeError("Could not create memory for blit"); - } +Py::Object +BufferRegion::to_string_argb(const Py::Tuple &args) +{ + // owned=true to prevent memory leak + Py_ssize_t length; + unsigned char* pix; + unsigned char* begin; + unsigned char* end; + unsigned char tmp; + size_t i, j; - pix = begin; - end = begin + (height * stride); - for (i = 0; i < (size_t)height; ++i) { - pix = begin + i * stride; - for (j = 0; j < (size_t)width; ++j) { - // Convert rgba to argb - tmp = pix[2]; - pix[2] = pix[0]; - pix[0] = tmp; - pix += 4; + PyObject* str = PyString_FromStringAndSize( + (const char*)data, height * stride); + if (PyString_AsStringAndSize(str, (char**)&begin, &length)) + { + throw Py::TypeError("Could not create memory for blit"); } - } - return Py::String(str, true); + pix = begin; + end = begin + (height * stride); + for (i = 0; i < (size_t)height; ++i) + { + pix = begin + i * stride; + for (j = 0; j < (size_t)width; ++j) + { + // Convert rgba to argb + tmp = pix[2]; + pix[2] = pix[0]; + pix[0] = tmp; + pix += 4; + } + } + + return Py::String(str, true); } + GCAgg::GCAgg(const Py::Object &gc, double dpi) : - dpi(dpi), isaa(true), dashOffset(0.0) + dpi(dpi), isaa(true), dashOffset(0.0) { - _VERBOSE("GCAgg::GCAgg"); - linewidth = points_to_pixels ( gc.getAttr("_linewidth") ) ; - alpha = Py::Float( gc.getAttr("_alpha") ); - color = get_color(gc); - _set_antialiased(gc); - _set_linecap(gc); - _set_joinstyle(gc); - _set_dashes(gc); - _set_clip_rectangle(gc); - _set_clip_path(gc); - _set_snap(gc); - _set_hatch_path(gc); + _VERBOSE("GCAgg::GCAgg"); + linewidth = points_to_pixels(gc.getAttr("_linewidth")) ; + alpha = Py::Float(gc.getAttr("_alpha")); + color = get_color(gc); + _set_antialiased(gc); + _set_linecap(gc); + _set_joinstyle(gc); + _set_dashes(gc); + _set_clip_rectangle(gc); + _set_clip_path(gc); + _set_snap(gc); + _set_hatch_path(gc); } + void -GCAgg::_set_antialiased(const Py::Object& gc) { - _VERBOSE("GCAgg::antialiased"); - isaa = Py::Int( gc.getAttr( "_antialiased") ); +GCAgg::_set_antialiased(const Py::Object& gc) +{ + _VERBOSE("GCAgg::antialiased"); + isaa = Py::Int(gc.getAttr("_antialiased")); } + agg::rgba -GCAgg::get_color(const Py::Object& gc) { - _VERBOSE("GCAgg::get_color"); - Py::Tuple rgb = Py::Tuple( gc.getAttr("_rgb") ); +GCAgg::get_color(const Py::Object& gc) +{ + _VERBOSE("GCAgg::get_color"); + Py::Tuple rgb = Py::Tuple(gc.getAttr("_rgb")); - double alpha = Py::Float( gc.getAttr("_alpha") ); + double alpha = Py::Float(gc.getAttr("_alpha")); - double r = Py::Float(rgb[0]); - double g = Py::Float(rgb[1]); - double b = Py::Float(rgb[2]); - return agg::rgba(r, g, b, alpha); + double r = Py::Float(rgb[0]); + double g = Py::Float(rgb[1]); + double b = Py::Float(rgb[2]); + return agg::rgba(r, g, b, alpha); } + double -GCAgg::points_to_pixels( const Py::Object& points) { - _VERBOSE("GCAgg::points_to_pixels"); - double p = Py::Float( points ) ; - return p * dpi/72.0; +GCAgg::points_to_pixels(const Py::Object& points) +{ + _VERBOSE("GCAgg::points_to_pixels"); + double p = Py::Float(points) ; + return p * dpi / 72.0; } + void -GCAgg::_set_linecap(const Py::Object& gc) { - _VERBOSE("GCAgg::_set_linecap"); +GCAgg::_set_linecap(const Py::Object& gc) +{ + _VERBOSE("GCAgg::_set_linecap"); - std::string capstyle = Py::String( gc.getAttr( "_capstyle" ) ); + std::string capstyle = Py::String(gc.getAttr("_capstyle")); - if (capstyle=="butt") - cap = agg::butt_cap; - else if (capstyle=="round") - cap = agg::round_cap; - else if(capstyle=="projecting") - cap = agg::square_cap; - else - throw Py::ValueError(Printf("GC _capstyle attribute must be one of butt, round, projecting; found %s", capstyle.c_str()).str()); + if (capstyle == "butt") + { + cap = agg::butt_cap; + } + else if (capstyle == "round") + { + cap = agg::round_cap; + } + else if (capstyle == "projecting") + { + cap = agg::square_cap; + } + else + { + throw Py::ValueError(Printf("GC _capstyle attribute must be one of butt, round, projecting; found %s", capstyle.c_str()).str()); + } } + void -GCAgg::_set_joinstyle(const Py::Object& gc) { - _VERBOSE("GCAgg::_set_joinstyle"); +GCAgg::_set_joinstyle(const Py::Object& gc) +{ + _VERBOSE("GCAgg::_set_joinstyle"); - std::string joinstyle = Py::String( gc.getAttr("_joinstyle") ); + std::string joinstyle = Py::String(gc.getAttr("_joinstyle")); - if (joinstyle == "miter") - join = agg::miter_join_revert; - else if (joinstyle == "round") - join = agg::round_join; - else if (joinstyle == "bevel") - join = agg::bevel_join; - else - throw Py::ValueError(Printf("GC _joinstyle attribute must be one of butt, round, projecting; found %s", joinstyle.c_str()).str()); + if (joinstyle == "miter") + { + join = agg::miter_join_revert; + } + else if (joinstyle == "round") + { + join = agg::round_join; + } + else if (joinstyle == "bevel") + { + join = agg::bevel_join; + } + else + { + throw Py::ValueError(Printf("GC _joinstyle attribute must be one of butt, round, projecting; found %s", joinstyle.c_str()).str()); + } } + void -GCAgg::_set_dashes(const Py::Object& gc) { - //return the dashOffset, dashes sequence tuple. - _VERBOSE("GCAgg::_set_dashes"); +GCAgg::_set_dashes(const Py::Object& gc) +{ + //return the dashOffset, dashes sequence tuple. + _VERBOSE("GCAgg::_set_dashes"); - Py::Object dash_obj( gc.getAttr( "_dashes" ) ); - if (dash_obj.ptr() == Py_None) { - dashes.clear(); - return; - } + Py::Object dash_obj(gc.getAttr("_dashes")); + if (dash_obj.ptr() == Py_None) + { + dashes.clear(); + return; + } - convert_dashes(dash_obj, dpi, dashes, dashOffset); + convert_dashes(dash_obj, dpi, dashes, dashOffset); } + void -GCAgg::_set_clip_rectangle( const Py::Object& gc) { - //set the clip rectangle from the gc +GCAgg::_set_clip_rectangle(const Py::Object& gc) +{ + //set the clip rectangle from the gc - _VERBOSE("GCAgg::_set_clip_rectangle"); + _VERBOSE("GCAgg::_set_clip_rectangle"); - Py::Object o ( gc.getAttr( "_cliprect" ) ); - cliprect = o; + Py::Object o(gc.getAttr("_cliprect")); + cliprect = o; } + void -GCAgg::_set_clip_path( const Py::Object& gc) { - //set the clip path from the gc +GCAgg::_set_clip_path(const Py::Object& gc) +{ + //set the clip path from the gc - _VERBOSE("GCAgg::_set_clip_path"); + _VERBOSE("GCAgg::_set_clip_path"); - Py::Object method_obj = gc.getAttr("get_clip_path"); - Py::Callable method(method_obj); - Py::Tuple path_and_transform = method.apply(Py::Tuple()); - if (path_and_transform[0].ptr() != Py_None) { - clippath = path_and_transform[0]; - clippath_trans = py_to_agg_transformation_matrix(path_and_transform[1].ptr()); - } + Py::Object method_obj = gc.getAttr("get_clip_path"); + Py::Callable method(method_obj); + Py::Tuple path_and_transform = method.apply(Py::Tuple()); + if (path_and_transform[0].ptr() != Py_None) + { + clippath = path_and_transform[0]; + clippath_trans = py_to_agg_transformation_matrix(path_and_transform[1].ptr()); + } } + void -GCAgg::_set_snap( const Py::Object& gc) { - //set the snap setting +GCAgg::_set_snap(const Py::Object& gc) +{ + //set the snap setting - _VERBOSE("GCAgg::_set_snap"); + _VERBOSE("GCAgg::_set_snap"); - Py::Object method_obj = gc.getAttr("get_snap"); - Py::Callable method(method_obj); - Py::Object py_snap = method.apply(Py::Tuple()); - if (py_snap.isNone()) { - snap_mode = SNAP_AUTO; - } else if (py_snap.isTrue()) { - snap_mode = SNAP_TRUE; - } else { - snap_mode = SNAP_FALSE; - } + Py::Object method_obj = gc.getAttr("get_snap"); + Py::Callable method(method_obj); + Py::Object py_snap = method.apply(Py::Tuple()); + if (py_snap.isNone()) + { + snap_mode = SNAP_AUTO; + } + else if (py_snap.isTrue()) + { + snap_mode = SNAP_TRUE; + } + else + { + snap_mode = SNAP_FALSE; + } } + void -GCAgg::_set_hatch_path( const Py::Object& gc) { - _VERBOSE("GCAgg::_set_hatch_path"); +GCAgg::_set_hatch_path(const Py::Object& gc) +{ + _VERBOSE("GCAgg::_set_hatch_path"); - Py::Object method_obj = gc.getAttr("get_hatch_path"); - Py::Callable method(method_obj); - hatchpath = method.apply(Py::Tuple()); + Py::Object method_obj = gc.getAttr("get_hatch_path"); + Py::Callable method(method_obj); + hatchpath = method.apply(Py::Tuple()); } + const size_t RendererAgg::PIXELS_PER_INCH(96); + RendererAgg::RendererAgg(unsigned int width, unsigned int height, double dpi, int debug) : - width(width), - height(height), - dpi(dpi), - NUMBYTES(width*height*4), - pixBuffer(NULL), - renderingBuffer(), - alphaBuffer(NULL), - alphaMaskRenderingBuffer(), - alphaMask(alphaMaskRenderingBuffer), - pixfmtAlphaMask(alphaMaskRenderingBuffer), - rendererBaseAlphaMask(), - rendererAlphaMask(), - scanlineAlphaMask(), - slineP8(), - slineBin(), - pixFmt(), - rendererBase(), - rendererAA(), - rendererBin(), - theRasterizer(), - debug(debug) + width(width), + height(height), + dpi(dpi), + NUMBYTES(width*height*4), + pixBuffer(NULL), + renderingBuffer(), + alphaBuffer(NULL), + alphaMaskRenderingBuffer(), + alphaMask(alphaMaskRenderingBuffer), + pixfmtAlphaMask(alphaMaskRenderingBuffer), + rendererBaseAlphaMask(), + rendererAlphaMask(), + scanlineAlphaMask(), + slineP8(), + slineBin(), + pixFmt(), + rendererBase(), + rendererAA(), + rendererBin(), + theRasterizer(), + debug(debug) { - _VERBOSE("RendererAgg::RendererAgg"); - unsigned stride(width*4); + _VERBOSE("RendererAgg::RendererAgg"); + unsigned stride(width*4); - pixBuffer = new agg::int8u[NUMBYTES]; - renderingBuffer.attach(pixBuffer, width, height, stride); - pixFmt.attach(renderingBuffer); - rendererBase.attach(pixFmt); - rendererBase.clear(agg::rgba(1, 1, 1, 0)); - rendererAA.attach(rendererBase); - rendererBin.attach(rendererBase); - hatchRenderingBuffer.attach(hatchBuffer, HATCH_SIZE, HATCH_SIZE, HATCH_SIZE*4); + pixBuffer = new agg::int8u[NUMBYTES]; + renderingBuffer.attach(pixBuffer, width, height, stride); + pixFmt.attach(renderingBuffer); + rendererBase.attach(pixFmt); + rendererBase.clear(agg::rgba(1, 1, 1, 0)); + rendererAA.attach(rendererBase); + rendererBin.attach(rendererBase); + hatchRenderingBuffer.attach(hatchBuffer, HATCH_SIZE, HATCH_SIZE, + HATCH_SIZE*4); } -void RendererAgg::create_alpha_buffers() { - if (!alphaBuffer) { - unsigned stride(width*4); - alphaBuffer = new agg::int8u[NUMBYTES]; - alphaMaskRenderingBuffer.attach(alphaBuffer, width, height, stride); - rendererBaseAlphaMask.attach(pixfmtAlphaMask); - rendererAlphaMask.attach(rendererBaseAlphaMask); - } + +void +RendererAgg::create_alpha_buffers() +{ + if (!alphaBuffer) + { + unsigned stride(width*4); + alphaBuffer = new agg::int8u[NUMBYTES]; + alphaMaskRenderingBuffer.attach(alphaBuffer, width, height, stride); + rendererBaseAlphaMask.attach(pixfmtAlphaMask); + rendererAlphaMask.attach(rendererBaseAlphaMask); + } } + template<class R> void -RendererAgg::set_clipbox(const Py::Object& cliprect, R& rasterizer) { - //set the clip rectangle from the gc +RendererAgg::set_clipbox(const Py::Object& cliprect, R& rasterizer) +{ + //set the clip rectangle from the gc - _VERBOSE("RendererAgg::set_clipbox"); + _VERBOSE("RendererAgg::set_clipbox"); - double l, b, r, t; - if (py_convert_bbox(cliprect.ptr(), l, b, r, t)) { - rasterizer.clip_box(int(mpl_round(l)), height - int(mpl_round(b)), - int(mpl_round(r)), height - int(mpl_round(t))); - } + double l, b, r, t; + if (py_convert_bbox(cliprect.ptr(), l, b, r, t)) + { + rasterizer.clip_box(int(mpl_round(l)), height - int(mpl_round(b)), + int(mpl_round(r)), height - int(mpl_round(t))); + } - _VERBOSE("RendererAgg::set_clipbox done"); + _VERBOSE("RendererAgg::set_clipbox done"); } + std::pair<bool, agg::rgba> -RendererAgg::_get_rgba_face(const Py::Object& rgbFace, double alpha) { - _VERBOSE("RendererAgg::_get_rgba_face"); - std::pair<bool, agg::rgba> face; +RendererAgg::_get_rgba_face(const Py::Object& rgbFace, double alpha) +{ + _VERBOSE("RendererAgg::_get_rgba_face"); + std::pair<bool, agg::rgba> face; - if (rgbFace.ptr() == Py_None) { - face.first = false; - } - else { - face.first = true; - Py::Tuple rgb = Py::Tuple(rgbFace); - face.second = rgb_to_color(rgb, alpha); - } - return face; + if (rgbFace.ptr() == Py_None) + { + face.first = false; + } + else + { + face.first = true; + Py::Tuple rgb = Py::Tuple(rgbFace); + face.second = rgb_to_color(rgb, alpha); + } + return face; } + Py::Object -RendererAgg::copy_from_bbox(const Py::Tuple& args) { - //copy region in bbox to buffer and return swig/agg buffer object - args.verify_length(1); +RendererAgg::copy_from_bbox(const Py::Tuple& args) +{ + //copy region in bbox to buffer and return swig/agg buffer object + args.verify_length(1); - Py::Object box_obj = args[0]; - double l, b, r, t; - if (!py_convert_bbox(box_obj.ptr(), l, b, r, t)) - throw Py::TypeError("Invalid bbox provided to copy_from_bbox"); + Py::Object box_obj = args[0]; + double l, b, r, t; + if (!py_convert_bbox(box_obj.ptr(), l, b, r, t)) + { + throw Py::TypeError("Invalid bbox provided to copy_from_bbox"); + } - // std::cout << l << " " << b << " " << r << " " << t << " " << (height - (int)b) << " " << height - (int)t << std::endl; - agg::rect_i rect((int)l, height - (int)t, (int)r, height - (int)b); + agg::rect_i rect((int)l, height - (int)t, (int)r, height - (int)b); - BufferRegion* reg = NULL; - try { - reg = new BufferRegion(rect, true); - } catch (...) { - throw Py::MemoryError("RendererAgg::copy_from_bbox could not allocate memory for buffer"); - } + BufferRegion* reg = NULL; + try + { + reg = new BufferRegion(rect, true); + } + catch (...) + { + throw Py::MemoryError( + "RendererAgg::copy_from_bbox could not allocate memory for buffer"); + } - if (!reg) { - throw Py::MemoryError("RendererAgg::copy_from_bbox could not allocate memory for buffer"); - } + if (!reg) + { + throw Py::MemoryError( + "RendererAgg::copy_from_bbox could not allocate memory for buffer"); + } - try { - agg::rendering_buffer rbuf; - rbuf.attach(reg->data, reg->width, reg->height, reg->stride); + try + { + agg::rendering_buffer rbuf; + rbuf.attach(reg->data, reg->width, reg->height, reg->stride); - pixfmt pf(rbuf); - renderer_base rb(pf); - rb.copy_from(renderingBuffer, &rect, -rect.x1, -rect.y1); - } catch (...) { - delete reg; - throw Py::RuntimeError("An unknown error occurred in copy_from_bbox"); - } - return Py::asObject(reg); + pixfmt pf(rbuf); + renderer_base rb(pf); + rb.copy_from(renderingBuffer, &rect, -rect.x1, -rect.y1); + } + catch (...) + { + delete reg; + throw Py::RuntimeError("An unknown error occurred in copy_from_bbox"); + } + return Py::asObject(reg); } + Py::Object -RendererAgg::restore_region(const Py::Tuple& args) { - //copy BufferRegion to buffer - args.verify_length(1); - BufferRegion* region = static_cast<BufferRegion*>(args[0].ptr()); +RendererAgg::restore_region(const Py::Tuple& args) +{ + //copy BufferRegion to buffer + args.verify_length(1); + BufferRegion* region = static_cast<BufferRegion*>(args[0].ptr()); - if (region->data==NULL) - throw Py::ValueError("Cannot restore_region from NULL data"); - //return Py::Object(); + if (region->data == NULL) + { + throw Py::ValueError("Cannot restore_region from NULL data"); + } - //std::cout << "restoring " << region->width << " " << region->height << " " << region->stride << " " << region->rect.x1 << " " << region->rect.y1 << std::endl; + agg::rendering_buffer rbuf; + rbuf.attach(region->data, + region->width, + region->height, + region->stride); - agg::rendering_buffer rbuf; - rbuf.attach(region->data, - region->width, - region->height, - region->stride); + rendererBase.copy_from(rbuf, 0, region->rect.x1, region->rect.y1); - rendererBase.copy_from(rbuf, 0, region->rect.x1, region->rect.y1); - - return Py::Object(); + return Py::Object(); } + // Restore the part of the saved region with offsets Py::Object -RendererAgg::restore_region2(const Py::Tuple& args) { - //copy BufferRegion to buffer - args.verify_length(7); +RendererAgg::restore_region2(const Py::Tuple& args) +{ + //copy BufferRegion to buffer + args.verify_length(7); + int x(0), y(0), xx1(0), yy1(0), xx2(0), yy2(0); + try + { + xx1 = Py::Int(args[1]); + yy1 = Py::Int(args[2]); + xx2 = Py::Int(args[3]); + yy2 = Py::Int(args[4]); + x = Py::Int(args[5]); + y = Py::Int(args[6]); + } + catch (Py::TypeError) + { + throw Py::TypeError("Invalid input arguments to draw_text_image"); + } - int x(0),y(0), xx1(0),yy1(0), xx2(0), yy2(0); - try { - xx1 = Py::Int( args[1] ); - yy1 = Py::Int( args[2] ); - xx2 = Py::Int( args[3] ); - yy2 = Py::Int( args[4] ); - x = Py::Int( args[5] ); - y = Py::Int( args[6] ); - } - catch (Py::TypeError) { - throw Py::TypeError("Invalid input arguments to draw_text_image"); - } + BufferRegion* region = static_cast<BufferRegion*>(args[0].ptr()); + if (region->data == NULL) + { + throw Py::ValueError("Cannot restore_region from NULL data"); + } - BufferRegion* region = static_cast<BufferRegion*>(args[0].ptr()); + agg::rect_i rect(xx1 - region->rect.x1, (yy1 - region->rect.y1), + xx2 - region->rect.x1, (yy2 - region->rect.y1)); - if (region->data==NULL) - throw Py::ValueError("Cannot restore_region from NULL data"); + agg::rendering_buffer rbuf; + rbuf.attach(region->data, + region->width, + region->height, + region->stride); - agg::rect_i rect(xx1-region->rect.x1, (yy1-region->rect.y1), - xx2-region->rect.x1, (yy2-region->rect.y1)); + rendererBase.copy_from(rbuf, &rect, x, y); - - agg::rendering_buffer rbuf; - rbuf.attach(region->data, - region->width, - region->height, - region->stride); - - rendererBase.copy_from(rbuf, &rect, x, y); - - return Py::Object(); + return Py::Object(); } -bool RendererAgg::render_clippath(const Py::Object& clippath, const agg::trans_affine& clippath_trans) { - typedef agg::conv_transform<PathIterator> transformed_path_t; - typedef agg::conv_curve<transformed_path_t> curve_t; +bool +RendererAgg::render_clippath(const Py::Object& clippath, + const agg::trans_affine& clippath_trans) +{ + typedef agg::conv_transform<PathIterator> transformed_path_t; + typedef agg::conv_curve<transformed_path_t> curve_t; - bool has_clippath = (clippath.ptr() != Py_None); + bool has_clippath = (clippath.ptr() != Py_None); - if (has_clippath && - (clippath.ptr() != lastclippath.ptr() || - clippath_trans != lastclippath_transform)) { - create_alpha_buffers(); - agg::trans_affine trans(clippath_trans); - trans *= agg::trans_affine_scaling(1.0, -1.0); - trans *= agg::trans_affine_translation(0.0, (double)height); + if (has_clippath && + (clippath.ptr() != lastclippath.ptr() || + clippath_trans != lastclippath_transform)) + { + create_alpha_buffers(); + agg::trans_affine trans(clippath_trans); + trans *= agg::trans_affine_scaling(1.0, -1.0); + trans *= agg::trans_affine_translation(0.0, (double)height); - PathIterator clippath_iter(clippath); - rendererBaseAlphaMask.clear(agg::gray8(0, 0)); - transformed_path_t transformed_clippath(clippath_iter, trans); - agg::conv_curve<transformed_path_t> curved_clippath(transformed_clippath); - theRasterizer.add_path(curved_clippath); - rendererAlphaMask.color(agg::gray8(255, 255)); - agg::render_scanlines(theRasterizer, scanlineAlphaMask, rendererAlphaMask); - lastclippath = clippath; - lastclippath_transform = clippath_trans; - } + PathIterator clippath_iter(clippath); + rendererBaseAlphaMask.clear(agg::gray8(0, 0)); + transformed_path_t transformed_clippath(clippath_iter, trans); + agg::conv_curve<transformed_path_t> curved_clippath(transformed_clippath); + theRasterizer.add_path(curved_clippath); + rendererAlphaMask.color(agg::gray8(255, 255)); + agg::render_scanlines(theRasterizer, scanlineAlphaMask, rendererAlphaMask); + lastclippath = clippath; + lastclippath_transform = clippath_trans; + } - return has_clippath; + return has_clippath; } #define MARKER_CACHE_SIZE 512 + Py::Object -RendererAgg::draw_markers(const Py::Tuple& args) { - typedef agg::conv_transform<PathIterator> transformed_path_t; - typedef PathSnapper<transformed_path_t> snap_t; - typedef agg::conv_curve<snap_t> curve_t; - typedef agg::conv_stroke<curve_t> stroke_t; - typedef agg::pixfmt_amask_adaptor<pixfmt, alpha_mask_type> pixfmt_amask_type; - typedef agg::renderer_base<pixfmt_amask_type> amask_ren_type; - typedef agg::renderer_scanline_aa_solid<amask_ren_type> amask_aa_renderer_type; - typedef agg::renderer_scanline_bin_solid<amask_ren_type> amask_bin_renderer_type; - args.verify_length(5, 6); +RendererAgg::draw_markers(const Py::Tuple& args) +{ + typedef agg::conv_transform<PathIterator> transformed_path_t; + typedef PathSnapper<transformed_path_t> snap_t; + typedef agg::conv_curve<snap_t> curve_t; + typedef agg::conv_stroke<curve_t> stroke_t; + typedef agg::pixfmt_amask_adaptor<pixfmt, alpha_mask_type> pixfmt_amask_type; + typedef agg::renderer_base<pixfmt_amask_type> amask_ren_type; + typedef agg::renderer_scanline_aa_solid<amask_ren_type> amask_aa_renderer_type; + typedef agg::renderer_scanline_bin_solid<amask_ren_type> amask_bin_renderer_type; + args.verify_length(5, 6); - Py::Object gc_obj = args[0]; - Py::Object marker_path_obj = args[1]; - agg::trans_affine marker_trans = py_to_agg_transformation_matrix(args[2].ptr()); - Py::Object path_obj = args[3]; - agg::trans_affine trans = py_to_agg_transformation_matrix(args[4].ptr()); - Py::Object face_obj; - if (args.size() == 6) - face_obj = args[5]; + Py::Object gc_obj = args[0]; + Py::Object marker_path_obj = args[1]; + agg::trans_affine marker_trans = py_to_agg_transformation_matrix(args[2].ptr()); + Py::Object path_obj = args[3]; + agg::trans_affine trans = py_to_agg_transformation_matrix(args[4].ptr()); + Py::Object face_obj; + if (args.size() == 6) + { + face_obj = args[5]; + } - GCAgg gc(gc_obj, dpi); + GCAgg gc(gc_obj, dpi); - // Deal with the difference in y-axis direction - marker_trans *= agg::trans_affine_scaling(1.0, -1.0); - trans *= agg::trans_affine_scaling(1.0, -1.0); - trans *= agg::trans_affine_translation(0.0, (double)height); + // Deal with the difference in y-axis direction + marker_trans *= agg::trans_affine_scaling(1.0, -1.0); + trans *= agg::trans_affine_scaling(1.0, -1.0); + trans *= agg::trans_affine_translation(0.0, (double)height); - PathIterator marker_path(marker_path_obj); - transformed_path_t marker_path_transformed(marker_path, marker_trans); - snap_t marker_path_snapped(marker_path_transformed, - gc.snap_mode, - marker_path.total_vertices(), - gc.linewidth); - curve_t marker_path_curve(marker_path_snapped); + PathIterator marker_path(marker_path_obj); + transformed_path_t marker_path_transformed(marker_path, marker_trans); + snap_t marker_path_snapped(marker_path_transformed, + gc.snap_mode, + marker_path.total_vertices(), + gc.linewidth); + curve_t marker_path_curve(marker_path_snapped); - PathIterator path(path_obj); - transformed_path_t path_transformed(path, trans); - snap_t path_snapped(path_transformed, - gc.snap_mode, - path.total_vertices(), - 1.0); - curve_t path_curve(path_snapped); - path_curve.rewind(0); + PathIterator path(path_obj); + transformed_path_t path_transformed(path, trans); + snap_t path_snapped(path_transformed, + gc.snap_mode, + path.total_vertices(), + 1.0); + curve_t path_curve(path_snapped); + path_curve.rewind(0); - facepair_t face = _get_rgba_face(face_obj, gc.alpha); + facepair_t face = _get_rgba_face(face_obj, gc.alpha); - //maxim's suggestions for cached scanlines - agg::scanline_storage_aa8 scanlines; - theRasterizer.reset(); - theRasterizer.reset_clipping(); - rendererBase.reset_clipping(true); + //maxim's suggestions for cached scanlines + agg::scanline_storage_aa8 scanlines; + theRasterizer.reset(); + theRasterizer.reset_clipping(); + rendererBase.reset_clipping(true); - agg::int8u staticFillCache[MARKER_CACHE_SIZE]; - agg::int8u staticStrokeCache[MARKER_CACHE_SIZE]; - agg::int8u* fillCache = staticFillCache; - agg::int8u* strokeCache = staticStrokeCache; + agg::int8u staticFillCache[MARKER_CACHE_SIZE]; + agg::int8u staticStrokeCache[MARKER_CACHE_SIZE]; + agg::int8u* fillCache = staticFillCache; + agg::int8u* strokeCache = staticStrokeCache; - try { - unsigned fillSize = 0; - if (face.first) { - theRasterizer.add_path(marker_path_curve); - agg::render_scanlines(theRasterizer, slineP8, scanlines); - fillSize = scanlines.byte_size(); - if (fillSize >= MARKER_CACHE_SIZE) - fillCache = new agg::int8u[fillSize]; - scanlines.serialize(fillCache); - } + try + { + unsigned fillSize = 0; + if (face.first) + { + theRasterizer.add_path(marker_path_curve); + agg::render_scanlines(theRasterizer, slineP8, scanlines); + fillSize = scanlines.byte_size(); + if (fillSize >= MARKER_CACHE_SIZE) + { + fillCache = new agg::int8u[fillSize]; + } + scanlines.serialize(fillCache); + } - stroke_t stroke(marker_path_curve); - stroke.width(gc.linewidth); - stroke.line_cap(gc.cap); - stroke.line_join(gc.join); - theRasterizer.reset(); - theRasterizer.add_path(stroke); - agg::render_scanlines(theRasterizer, slineP8, scanlines); - unsigned strokeSize = scanlines.byte_size(); - if (strokeSize >= MARKER_CACHE_SIZE) - strokeCache = new agg::int8u[strokeSize]; - scanlines.serialize(strokeCache); + stroke_t stroke(marker_path_curve); + stroke.width(gc.linewidth); + stroke.line_cap(gc.cap); + stroke.line_join(gc.join); + theRasterizer.reset(); + theRasterizer.add_path(stroke); + agg::render_scanlines(theRasterizer, slineP8, scanlines); + unsigned strokeSize = scanlines.byte_size(); + if (strokeSize >= MARKER_CACHE_SIZE) + { + strokeCache = new agg::int8u[strokeSize]; + } + scanlines.serialize(strokeCache); - theRasterizer.reset_clipping(); - rendererBase.reset_clipping(true); - set_clipbox(gc.cliprect, rendererBase); - bool has_clippath = render_clippath(gc.clippath, gc.clippath_trans); + theRasterizer.reset_clipping(); + rendererBase.reset_clipping(true); + set_clipbox(gc.cliprect, rendererBase); + bool has_clippath = render_clippath(gc.clippath, gc.clippath_trans); - double x, y; + double x, y; - agg::serialized_scanlines_adaptor_aa8 sa; - agg::serialized_scanlines_adaptor_aa8::embedded_scanline sl; + agg::serialized_scanlines_adaptor_aa8 sa; + agg::serialized_scanlines_adaptor_aa8::embedded_scanline sl; - agg::rect_d clipping_rect( - -(scanlines.min_x() + 1.0), - -(scanlines.min_y() + 1.0), - width + scanlines.max_x() + 1.0, - height + scanlines.max_y() + 1.0); + agg::rect_d clipping_rect( + -(scanlines.min_x() + 1.0), + -(scanlines.min_y() + 1.0), + width + scanlines.max_x() + 1.0, + height + scanlines.max_y() + 1.0); - if (has_clippath) { - while (path_curve.vertex(&x, &y) != agg::path_cmd_stop) { - if (MPL_notisfinite64(x) || MPL_notisfinite64(y)) { - continue; - } + if (has_clippath) + { + while (path_curve.vertex(&x, &y) != agg::path_cmd_stop) + { + if (MPL_notisfinite64(x) || MPL_notisfinite64(y)) + { + continue; + } - x = (double)(int)x; y = (double)(int)y; + x = (double)(int)x; + y = (double)(int)y; - // Cull points outside the boundary of the image. Values - // that are too large may overflow and create segfaults. - // because they can create segfaults of they overflow; eg - // http://sourceforge.net/tracker/?func=detail&aid=2865490&group_id=80706&atid=560720 - if (!clipping_rect.hit_test(x, y)) { - continue; - } + // Cull points outside the boundary of the image. + // Values that are too large may overflow and create + // segfaults. + // http://sourceforge.net/tracker/?func=detail&aid=2865490&group_id=80706&atid=560720 + if (!clipping_rect.hit_test(x, y)) + { + continue; + } - pixfmt_amask_type pfa(pixFmt, alphaMask); - amask_ren_type r(pfa); - amask_aa_renderer_type ren(r); + pixfmt_amask_type pfa(pixFmt, alphaMask); + amask_ren_type r(pfa); + amask_aa_renderer_type ren(r); - if (face.first) { - ren.color(face.second); - sa.init(fillCache, fillSize, x, y); - agg::render_scanlines(sa, sl, ren); + if (face.first) + { + ren.color(face.second); + sa.init(fillCache, fillSize, x, y); + agg::render_scanlines(sa, sl, ren); + } + ren.color(gc.color); + sa.init(strokeCache, strokeSize, x, y); + agg::render_scanlines(sa, sl, ren); + } } - ren.color(gc.color); - sa.init(strokeCache, strokeSize, x, y); - agg::render_scanlines(sa, sl, ren); - } - } else { - while (path_curve.vertex(&x, &y) != agg::path_cmd_stop) { - if (MPL_notisfinite64(x) || MPL_notisfinite64(y)) { - continue; - } + else + { + while (path_curve.vertex(&x, &y) != agg::path_cmd_stop) + { + if (MPL_notisfinite64(x) || MPL_notisfinite64(y)) + { + continue; + } - x = (double)(int)x; y = (double)(int)y; + x = (double)(int)x; + y = (double)(int)y; - // Cull points outside the boundary of the image. Values - // that are too large may overflow and create segfaults. - // because they can create segfaults of they overflow; eg - // http://sourceforge.net/tracker/?func=detail&aid=2865490&group_id=80706&atid=560720 - if (!clipping_rect.hit_test(x, y)) { - continue; - } + // Cull points outside the boundary of the image. + // Values that are too large may overflow and create + // segfaults. + // http://sourceforge.net/tracker/?func=detail&aid=2865490&group_id=80706&atid=560720 + if (!clipping_rect.hit_test(x, y)) + { + continue; + } - if (face.first) { - rendererAA.color(face.second); - sa.init(fillCache, fillSize, x, y); - agg::render_scanlines(sa, sl, rendererAA); + if (face.first) + { + rendererAA.color(face.second); + sa.init(fillCache, fillSize, x, y); + agg::render_scanlines(sa, sl, rendererAA); + } + + rendererAA.color(gc.color); + sa.init(strokeCache, strokeSize, x, y); + agg::render_scanlines(sa, sl, rendererAA); + } } + } + catch (...) + { + if (fillCache != staticFillCache) + delete[] fillCache; + if (strokeCache != staticStrokeCache) + delete[] strokeCache; + throw; + } - rendererAA.color(gc.color); - sa.init(strokeCache, strokeSize, x, y); - agg::render_scanlines(sa, sl, rendererAA); - } - } - } catch(...) { if (fillCache != staticFillCache) - delete[] fillCache; + delete[] fillCache; if (strokeCache != staticStrokeCache) - delete[] strokeCache; - throw; - } + delete[] strokeCache; - if (fillCache != staticFillCache) - delete[] fillCache; - if (strokeCache != staticStrokeCache) - delete[] strokeCache; - - return Py::Object(); + return Py::Object(); } + /** * This is a custom span generator that converts spans in the * 8-bit inverted greyscale font buffer to rgba that agg can use. @@ -680,1380 +816,1626 @@ class font_to_rgba { public: - typedef ChildGenerator child_type; - typedef agg::rgba8 color_type; - typedef typename child_type::color_type child_color_type; - typedef agg::span_allocator<child_color_type> span_alloc_type; + typedef ChildGenerator child_type; + typedef agg::rgba8 color_type; + typedef typename child_type::color_type child_color_type; + typedef agg::span_allocator<child_color_type> span_alloc_type; private: - child_type* _gen; - color_type _color; - span_alloc_type _allocator; + child_type* _gen; + color_type _color; + span_alloc_type _allocator; public: - font_to_rgba(child_type* gen, color_type color) : - _gen(gen), - _color(color) { - } + font_to_rgba(child_type* gen, color_type color) : + _gen(gen), + _color(color) + { - inline void generate(color_type* output_span, int x, int y, unsigned len) - { - _allocator.allocate(len); - child_color_type* input_span = _allocator.span(); - _gen->generate(input_span, x, y, len); + } - do { - *output_span = _color; - output_span->a = ((unsigned int)_color.a * (unsigned int)input_span->v) >> 8; - ++output_span; - ++input_span; - } while (--len); - } + inline void + generate(color_type* output_span, int x, int y, unsigned len) + { + _allocator.allocate(len); + child_color_type* input_span = _allocator.span(); + _gen->generate(input_span, x, y, len); - void prepare() - { - _gen->prepare(); - } + do + { + *output_span = _color; + output_span->a = ((unsigned int)_color.a * + (unsigned int)input_span->v) >> 8; + ++output_span; + ++input_span; + } + while (--len); + } + void + prepare() + { + _gen->prepare(); + } }; + // MGDTODO: Support clip paths Py::Object -RendererAgg::draw_text_image(const Py::Tuple& args) { - _VERBOSE("RendererAgg::draw_text"); +RendererAgg::draw_text_image(const Py::Tuple& args) +{ + _VERBOSE("RendererAgg::draw_text"); - typedef agg::span_allocator<agg::gray8> gray_span_alloc_type; - typedef agg::span_allocator<agg::rgba8> color_span_alloc_type; - typedef agg::span_interpolator_linear<> interpolator_type; - typedef agg::image_accessor_clip<agg::pixfmt_gray8> image_accessor_type; - //typedef agg::span_image_filter_gray_2x2<image_accessor_type, interpolator_type> - // image_span_gen_type; - typedef agg::span_image_filter_gray<image_accessor_type, interpolator_type> - image_span_gen_type; + typedef agg::span_allocator<agg::gray8> gray_span_alloc_type; + typedef agg::span_allocator<agg::rgba8> color_span_alloc_type; + typedef agg::span_interpolator_linear<> interpolator_type; + typedef agg::image_accessor_clip<agg::pixfmt_gray8> image_accessor_type; + typedef agg::span_image_filter_gray<image_accessor_type, + interpolator_type> image_span_gen_type; + typedef font_to_rgba<image_span_gen_type> span_gen_type; + typedef agg::renderer_scanline_aa<renderer_base, color_span_alloc_type, + span_gen_type> renderer_type; - typedef font_to_rgba<image_span_gen_type> span_gen_type; - typedef agg::renderer_scanline_aa<renderer_base, color_span_alloc_type, span_gen_type> - renderer_type; + args.verify_length(5); - args.verify_length(5); + const unsigned char* buffer = NULL; + int width, height; + Py::Object image_obj = args[0]; + PyArrayObject* image_array = NULL; - const unsigned char* buffer = NULL; - int width, height; - Py::Object image_obj = args[0]; - PyArrayObject* image_array = NULL; - if (PyArray_Check(image_obj.ptr())) { - image_array = (PyArrayObject*)PyArray_FromObject(image_obj.ptr(), PyArray_UBYTE, 2, 2); - if (!image_array) - throw Py::ValueError("First argument to draw_text_image must be a FT2Font.Image object or a Nx2 uint8 numpy array."); - buffer = (unsigned char *)PyArray_DATA(image_array); - width = PyArray_DIM(image_array, 1); - height = PyArray_DIM(image_array, 0); - } else { - FT2Image *image = static_cast<FT2Image*>(args[0].ptr()); - if (!image->get_buffer()) - throw Py::ValueError("First argument to draw_text_image must be a FT2Font.Image object or a Nx2 uint8 numpy array."); - buffer = image->get_buffer(); - width = image->get_width(); - height = image->get_height(); - } + if (PyArray_Check(image_obj.ptr())) + { + image_array = (PyArrayObject*)PyArray_FromObject(image_obj.ptr(), PyArray_UBYTE, 2, 2); + if (!image_array) + { + throw Py::ValueError( + "First argument to draw_text_image must be a FT2Font.Image object or a Nx2 uint8 numpy array."); + } + buffer = (unsigned char *)PyArray_DATA(image_array); + width = PyArray_DIM(image_array, 1); + height = PyArray_DIM(image_array, 0); + } + else + { + FT2Image *image = static_cast<FT2Image*>(args[0].ptr()); + if (!image->get_buffer()) + { + throw Py::ValueError( + "First argument to draw_text_image must be a FT2Font.Image object or a Nx2 uint8 numpy array."); + } + buffer = image->get_buffer(); + width = image->get_width(); + height = image->get_height(); + } - int x(0),y(0); - try { - x = Py::Int( args[1] ); - y = Py::Int( args[2] ); - } - catch (Py::TypeError) { - Py_XDECREF(image_array); - throw Py::TypeError("Invalid input arguments to draw_text_image"); - } + int x(0), y(0); + try + { + x = Py::Int(args[1]); + y = Py::Int(args[2]); + } + catch (Py::TypeError) + { + Py_XDECREF(image_array); + throw Py::TypeError("Invalid input arguments to draw_text_image"); + } - double angle = Py::Float( args[3] ); + double angle = Py::Float(args[3]); - GCAgg gc(args[4], dpi); + GCAgg gc(args[4], dpi); - theRasterizer.reset_clipping(); - rendererBase.reset_clipping(true); - set_clipbox(gc.cliprect, theRasterizer); + theRasterizer.reset_clipping(); + rendererBase.reset_clipping(true); + set_clipbox(gc.cliprect, theRasterizer); - agg::rendering_buffer srcbuf((agg::int8u*)buffer, width, height, width); - agg::pixfmt_gray8 pixf_img(srcbuf); + agg::rendering_buffer srcbuf((agg::int8u*)buffer, width, height, width); + agg::pixfmt_gray8 pixf_img(srcbuf); - agg::trans_affine mtx; - mtx *= agg::trans_affine_translation(0, -height); - mtx *= agg::trans_affine_rotation(-angle * agg::pi / 180.0); - mtx *= agg::trans_affine_translation(x, y); + agg::trans_affine mtx; + mtx *= agg::trans_affine_translation(0, -height); + mtx *= agg::trans_affine_rotation(-angle * agg::pi / 180.0); + mtx *= agg::trans_affine_translation(x, y); - agg::path_storage rect; - rect.move_to(0, 0); - rect.line_to(width, 0); - rect.line_to(width, height); - rect.line_to(0, height); - rect.line_to(0, 0); - agg::conv_transform<agg::path_storage> rect2(rect, mtx); + agg::path_storage rect; + rect.move_to(0, 0); + rect.line_to(width, 0); + rect.line_to(width, height); + rect.line_to(0, height); + rect.line_to(0, 0); + agg::conv_transform<agg::path_storage> rect2(rect, mtx); - agg::trans_affine inv_mtx(mtx); - inv_mtx.invert(); + agg::trans_affine inv_mtx(mtx); + inv_mtx.invert(); - agg::image_filter_lut filter; - filter.calculate(agg::image_filter_spline36()); - interpolator_type interpolator(inv_mtx); - color_span_alloc_type sa; - image_accessor_type ia(pixf_img, 0); - image_span_gen_type image_span_generator(ia, interpolator, filter); - span_gen_type output_span_generator(&image_span_generator, gc.color); - renderer_type ri(rendererBase, sa, output_span_generator); + agg::image_filter_lut filter; + filter.calculate(agg::image_filter_spline36()); + interpolator_type interpolator(inv_mtx); + color_span_alloc_type sa; + image_accessor_type ia(pixf_img, 0); + image_span_gen_type image_span_generator(ia, interpolator, filter); + span_gen_type output_span_generator(&image_span_generator, gc.color); + renderer_type ri(rendererBase, sa, output_span_generator); - theRasterizer.add_path(rect2); - agg::render_scanlines(theRasterizer, slineP8, ri); + theRasterizer.add_path(rect2); + agg::render_scanlines(theRasterizer, slineP8, ri); - Py_XDECREF(image_array); + Py_XDECREF(image_array); - return Py::Object(); + return Py::Object(); } Py::Object -RendererAgg::draw_image(const Py::Tuple& args) { - _VERBOSE("RendererAgg::draw_image"); +RendererAgg::draw_image(const Py::Tuple& args) +{ + _VERBOSE("RendererAgg::draw_image"); - args.verify_length(4, 7); // 7 if affine matrix if given + args.verify_length(4, 7); // 7 if affine matrix if given - GCAgg gc(args[0], dpi); - Image *image = static_cast<Image*>(args[3].ptr()); - bool has_clippath = false; - agg::trans_affine affine_trans; - bool has_affine = false; - double x, y, w, h; + GCAgg gc(args[0], dpi); + Image *image = static_cast<Image*>(args[3].ptr()); + bool has_clippath = false; + agg::trans_affine affine_trans; + bool has_affine = false; + double x, y, w, h; - - if (args.size() == 7) { - has_affine = true; - x = Py::Float(args[1]); - y = Py::Float(args[2]); - w = Py::Float(args[4]); - h = Py::Float(args[5]); - affine_trans = py_to_agg_transformation_matrix(args[6].ptr()); - } else { - x = mpl_round(Py::Float(args[1])); - y = mpl_round(Py::Float(args[2])); - w = h = 0; /* w and h not used in this case, but assign to prevent + if (args.size() == 7) + { + has_affine = true; + x = Py::Float(args[1]); + y = Py::Float(args[2]); + w = Py::Float(args[4]); + h = Py::Float(args[5]); + affine_trans = py_to_agg_transformation_matrix(args[6].ptr()); + } + else + { + x = mpl_round(Py::Float(args[1])); + y = mpl_round(Py::Float(args[2])); + w = h = 0; /* w and h not used in this case, but assign to prevent warnings from the compiler */ - } + } + theRasterizer.reset_clipping(); + rendererBase.reset_clipping(true); + set_clipbox(gc.cliprect, theRasterizer); + has_clippath = render_clippath(gc.clippath, gc.clippath_trans); - theRasterizer.reset_clipping(); - rendererBase.reset_clipping(true); - set_clipbox(gc.cliprect, theRasterizer); - has_clippath = render_clippath(gc.clippath, gc.clippath_trans); + Py::Tuple empty; + image->flipud_out(empty); + pixfmt pixf(*(image->rbufOut)); - Py::Tuple empty; - image->flipud_out(empty); - pixfmt pixf(*(image->rbufOut)); + if (has_affine | has_clippath) + { + agg::trans_affine mtx; + agg::path_storage rect; - if (has_affine | has_clippath) { - agg::trans_affine mtx; - agg::path_storage rect; + if (has_affine) + { + mtx *= agg::trans_affine_scaling(1, -1); + mtx *= agg::trans_affine_translation(0, image->rowsOut); + mtx *= agg::trans_affine_scaling(w / (image->colsOut), + h / (image->rowsOut)); + mtx *= agg::trans_affine_translation(x, y); + mtx *= affine_trans; + mtx *= agg::trans_affine_scaling(1.0, -1.0); + mtx *= agg::trans_affine_translation(0.0, (double) height); + } + else + { + mtx *= agg::trans_affine_translation( + (int)x, + (int)(height - (y + image->rowsOut))); + } - if (has_affine) { - mtx *= agg::trans_affine_scaling(1, -1); - mtx *= agg::trans_affine_translation(0, image->rowsOut); - mtx *= agg::trans_affine_scaling(w/(image->colsOut), h/(image->rowsOut)); - mtx *= agg::trans_affine_translation(x, y); - mtx *= affine_trans; - mtx *= agg::trans_affine_scaling(1.0, -1.0); - mtx *= agg::trans_affine_translation(0.0, (double) height); - } else { - mtx *= agg::trans_affine_translation((int)x, (int)(height-(y+image->rowsOut))); - } + rect.move_to(0, 0); + rect.line_to(image->colsOut, 0); + rect.line_to(image->colsOut, image->rowsOut); + rect.line_to(0, image->rowsOut); + rect.line_to(0, 0); - rect.move_to(0, 0); - rect.line_to(image->colsOut, 0); - rect.line_to(image->colsOut, image->rowsOut); - rect.line_to(0, image->rowsOut); - rect.line_to(0, 0); + agg::conv_transform<agg::path_storage> rect2(rect, mtx); - agg::conv_transform<agg::path_storage> rect2(rect, mtx); + agg::trans_affine inv_mtx(mtx); + inv_mtx.invert(); - agg::trans_affine inv_mtx(mtx); - inv_mtx.invert(); + typedef agg::span_allocator<agg::rgba8> color_span_alloc_type; + typedef agg::image_accessor_clip<agg::pixfmt_rgba32> + image_accessor_type; + typedef agg::span_interpolator_linear<> interpolator_type; + typedef agg::span_image_filter_rgba_nn<image_accessor_type, + interpolator_type> image_span_gen_type; + color_span_alloc_type sa; + image_accessor_type ia(pixf, agg::rgba8(0, 0, 0, 0)); + interpolator_type interpolator(inv_mtx); + image_span_gen_type image_span_generator(ia, interpolator); - typedef agg::span_allocator<agg::rgba8> color_span_alloc_type; - typedef agg::image_accessor_clip<agg::pixfmt_rgba32> image_accessor_type; - typedef agg::span_interpolator_linear<> interpolator_type; - typedef agg::span_image_filter_rgba_nn<image_accessor_type, interpolator_type> image_span_gen_type; + if (has_clippath) + { + typedef agg::pixfmt_amask_adaptor<pixfmt, alpha_mask_type> + pixfmt_amask_type; + typedef agg::renderer_base<pixfmt_amask_type> amask_ren_type; + typedef agg::renderer_scanline_aa<amask_ren_type, + color_span_alloc_type, + image_span_gen_type> + renderer_type_alpha; + pixfmt_amask_type pfa(pixFmt, alphaMask); + amask_ren_type r(pfa); + renderer_type_alpha ri(r, sa, image_span_generator); - color_span_alloc_type sa; - image_accessor_type ia(pixf, agg::rgba8(0, 0, 0, 0)); - interpolator_type interpolator(inv_mtx); - image_span_gen_type image_span_generator(ia, interpolator); + theRasterizer.add_path(rect2); + agg::render_scanlines(theRasterizer, slineP8, ri); + } + else + { + typedef agg::renderer_base<pixfmt> ren_type; + typedef agg::renderer_scanline_aa<ren_type, + color_span_alloc_type, + image_span_gen_type> + renderer_type; + ren_type r(pixFmt); + renderer_type ri(r, sa, image_span_generator); - if (has_clippath) { - typedef agg::pixfmt_amask_adaptor<pixfmt, alpha_mask_type> pixfmt_amask_type; - typedef agg::renderer_base<pixfmt_amask_type> amask_ren_type; - typedef agg::renderer_scanline_aa<amask_ren_type, color_span_alloc_type, image_span_gen_type> renderer_type_alpha; + theRasterizer.add_path(rect2); + agg::render_scanlines(theRasterizer, slineP8, ri); + } - pixfmt_amask_type pfa(pixFmt, alphaMask); - amask_ren_type r(pfa); - renderer_type_alpha ri(r, sa, image_span_generator); - - theRasterizer.add_path(rect2); - agg::render_scanlines(theRasterizer, slineP8, ri); - } else { - typedef agg::renderer_base<pixfmt> ren_type; - typedef agg::renderer_scanline_aa<ren_type, color_span_alloc_type, image_span_gen_type> renderer_type; - ren_type r(pixFmt); - renderer_type ri(r, sa, image_span_generator); - - theRasterizer.add_path(rect2); - agg::render_scanlines(theRasterizer, slineP8, ri); } + else + { + set_clipbox(gc.cliprect, rendererBase); + rendererBase.blend_from(pixf, 0, (int)x, (int)(height - (y + image->rowsOut))); + } - } else { - set_clipbox(gc.cliprect, rendererBase); - rendererBase.blend_from(pixf, 0, (int)x, (int)(height-(y+image->rowsOut))); - } + image->flipud_out(empty); - image->flipud_out(empty); - - return Py::Object(); + return Py::Object(); } - - template<class path_t> void RendererAgg::_draw_path(path_t& path, bool has_clippath, - const facepair_t& face, const GCAgg& gc) { - typedef agg::conv_stroke<path_t> stroke_t; - typedef agg::conv_dash<path_t> dash_t; - typedef agg::conv_stroke<dash_t> stroke_dash_t; - typedef agg::pixfmt_amask_adaptor<pixfmt, alpha_mask_type> pixfmt_amask_type; - typedef agg::renderer_base<pixfmt_amask_type> amask_ren_type; - typedef agg::renderer_scanline_aa_solid<amask_ren_type> amask_aa_renderer_type; - typedef agg::renderer_scanline_bin_solid<amask_ren_type> amask_bin_renderer_type; + const facepair_t& face, const GCAgg& gc) +{ + typedef agg::conv_stroke<path_t> stroke_t; + typedef agg::conv_dash<path_t> dash_t; + typedef agg::conv_stroke<dash_t> stroke_dash_t; + typedef agg::pixfmt_amask_adaptor<pixfmt, alpha_mask_type> pixfmt_amask_type; + typedef agg::renderer_base<pixfmt_amask_type> amask_ren_type; + typedef agg::renderer_scanline_aa_solid<amask_ren_type> amask_aa_renderer_type; + typedef agg::renderer_scanline_bin_solid<amask_ren_type> amask_bin_renderer_type; - // Render face - if (face.first) { - theRasterizer.add_path(path); + // Render face + if (face.first) + { + theRasterizer.add_path(path); - if (gc.isaa) { - if (has_clippath) { - pixfmt_amask_type pfa(pixFmt, alphaMask); - amask_ren_type r(pfa); - amask_aa_renderer_type ren(r); - ren.color(face.second); - agg::render_scanlines(theRasterizer, slineP8, ren); - } else { - rendererAA.color(face.second); - agg::render_scanlines(theRasterizer, slineP8, rendererAA); - } - } else { - if (has_clippath) { - pixfmt_amask_type pfa(pixFmt, alphaMask); - amask_ren_type r(pfa); - amask_bin_renderer_type ren(r); - ren.color(face.second); - agg::render_scanlines(theRasterizer, slineP8, ren); - } else { - rendererBin.color(face.second); - agg::render_scanlines(theRasterizer, slineP8, rendererBin); - } + if (gc.isaa) + { + if (has_clippath) + { + pixfmt_amask_type pfa(pixFmt, alphaMask); + amask_ren_type r(pfa); + amask_aa_renderer_type ren(r); + ren.color(face.second); + agg::render_scanlines(theRasterizer, slineP8, ren); + } + else + { + rendererAA.color(face.second); + agg::render_scanlines(theRasterizer, slineP8, rendererAA); + } + } + else + { + if (has_clippath) + { + pixfmt_amask_type pfa(pixFmt, alphaMask); + amask_ren_type r(pfa); + amask_bin_renderer_type ren(r); + ren.color(face.second); + agg::render_scanlines(theRasterizer, slineP8, ren); + } + else + { + rendererBin.color(face.second); + agg::render_scanlines(theRasterizer, slineP8, rendererBin); + } + } } - } - // Render hatch - if (!gc.hatchpath.isNone()) { - // Reset any clipping that may be in effect, since we'll be - // drawing the hatch in a scratch buffer at origin (0, 0) - theRasterizer.reset_clipping(); - rendererBase.reset_clipping(true); + // Render hatch + if (!gc.hatchpath.isNone()) + { + // Reset any clipping that may be in effect, since we'll be + // drawing the hatch in a scratch buffer at origin (0, 0) + theRasterizer.reset_clipping(); + rendererBase.reset_clipping(true); - // Create and transform the path - typedef agg::conv_transform<PathIterator> hatch_p... [truncated message content]