From: <md...@us...> - 2008-10-08 14:10:07
|
Revision: 6169 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6169&view=rev Author: mdboom Date: 2008-10-08 14:09:55 +0000 (Wed, 08 Oct 2008) Log Message: ----------- Increase rendering cell limit in Agg. Modified Paths: -------------- trunk/matplotlib/agg24/include/agg_rasterizer_cells_aa.h Modified: trunk/matplotlib/agg24/include/agg_rasterizer_cells_aa.h =================================================================== --- trunk/matplotlib/agg24/include/agg_rasterizer_cells_aa.h 2008-10-08 13:59:28 UTC (rev 6168) +++ trunk/matplotlib/agg24/include/agg_rasterizer_cells_aa.h 2008-10-08 14:09:55 UTC (rev 6169) @@ -2,15 +2,15 @@ // 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. // //---------------------------------------------------------------------------- // -// The author gratefully acknowleges the support of David Turner, -// Robert Wilhelm, and Werner Lemberg - the authors of the FreeType +// The author gratefully acknowleges the support of David Turner, +// Robert Wilhelm, and Werner Lemberg - the authors of the FreeType // libray - in producing this work. See http://www.freetype.org for details. // //---------------------------------------------------------------------------- @@ -19,12 +19,12 @@ // http://www.antigrain.com //---------------------------------------------------------------------------- // -// Adaptation for 32-bit screen coordinates has been sponsored by +// Adaptation for 32-bit screen coordinates 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_RASTERIZER_CELLS_AA_INCLUDED #define AGG_RASTERIZER_CELLS_AA_INCLUDED @@ -49,7 +49,7 @@ cell_block_size = 1 << cell_block_shift, cell_block_mask = cell_block_size - 1, cell_block_pool = 256, - cell_block_limit = 1024 + cell_block_limit = 4096 }; struct sorted_y @@ -76,19 +76,19 @@ void sort_cells(); - unsigned total_cells() const + unsigned total_cells() const { return m_num_cells; } - unsigned scanline_num_cells(unsigned y) const - { - return m_sorted_y[y - m_min_y].num; + unsigned scanline_num_cells(unsigned y) const + { + return m_sorted_y[y - m_min_y].num; } const cell_type* const* scanline_cells(unsigned y) const - { - return m_sorted_cells.data() + m_sorted_y[y - m_min_y].start; + { + return m_sorted_cells.data() + m_sorted_y[y - m_min_y].start; } bool sorted() const { return m_sorted; } @@ -101,7 +101,7 @@ void add_curr_cell(); void render_hline(int ey, int x1, int y1, int x2, int y2); void allocate_block(); - + private: unsigned m_num_blocks; unsigned m_max_blocks; @@ -124,7 +124,7 @@ //------------------------------------------------------------------------ - template<class Cell> + template<class Cell> rasterizer_cells_aa<Cell>::~rasterizer_cells_aa() { if(m_num_blocks) @@ -140,7 +140,7 @@ } //------------------------------------------------------------------------ - template<class Cell> + template<class Cell> rasterizer_cells_aa<Cell>::rasterizer_cells_aa() : m_num_blocks(0), m_max_blocks(0), @@ -161,10 +161,10 @@ } //------------------------------------------------------------------------ - template<class Cell> + template<class Cell> void rasterizer_cells_aa<Cell>::reset() { - m_num_cells = 0; + m_num_cells = 0; m_curr_block = 0; m_curr_cell.initial(); m_style_cell.initial(); @@ -176,7 +176,7 @@ } //------------------------------------------------------------------------ - template<class Cell> + template<class Cell> AGG_INLINE void rasterizer_cells_aa<Cell>::add_curr_cell() { if(m_curr_cell.area | m_curr_cell.cover) @@ -192,7 +192,7 @@ } //------------------------------------------------------------------------ - template<class Cell> + template<class Cell> AGG_INLINE void rasterizer_cells_aa<Cell>::set_curr_cell(int x, int y) { if(m_curr_cell.not_equal(x, y, m_style_cell)) @@ -207,9 +207,9 @@ } //------------------------------------------------------------------------ - template<class Cell> - AGG_INLINE void rasterizer_cells_aa<Cell>::render_hline(int ey, - int x1, int y1, + template<class Cell> + AGG_INLINE void rasterizer_cells_aa<Cell>::render_hline(int ey, + int x1, int y1, int x2, int y2) { int ex1 = x1 >> poly_subpixel_shift; @@ -305,14 +305,14 @@ } //------------------------------------------------------------------------ - template<class Cell> + template<class Cell> AGG_INLINE void rasterizer_cells_aa<Cell>::style(const cell_type& style_cell) - { - m_style_cell.style(style_cell); + { + m_style_cell.style(style_cell); } //------------------------------------------------------------------------ - template<class Cell> + template<class Cell> void rasterizer_cells_aa<Cell>::line(int x1, int y1, int x2, int y2) { enum dx_limit_e { dx_limit = 16384 << poly_subpixel_shift }; @@ -358,7 +358,7 @@ //Vertical line - we have to calculate start and end cells, //and then - the common values of the area and coverage for - //all cells of the line. We know exactly there's only one + //all cells of the line. We know exactly there's only one //cell, so, we don't have to call render_hline(). incr = 1; if(dx == 0) @@ -463,15 +463,15 @@ } //------------------------------------------------------------------------ - template<class Cell> + template<class Cell> void rasterizer_cells_aa<Cell>::allocate_block() { if(m_curr_block >= m_num_blocks) { if(m_num_blocks >= m_max_blocks) { - cell_type** new_cells = - pod_allocator<cell_type*>::allocate(m_max_blocks + + cell_type** new_cells = + pod_allocator<cell_type*>::allocate(m_max_blocks + cell_block_pool); if(m_cells) @@ -483,7 +483,7 @@ m_max_blocks += cell_block_pool; } - m_cells[m_num_blocks++] = + m_cells[m_num_blocks++] = pod_allocator<cell_type>::allocate(cell_block_size); } @@ -513,7 +513,7 @@ void qsort_cells(Cell** start, unsigned num) { Cell** stack[80]; - Cell*** top; + Cell*** top; Cell** limit; Cell** base; @@ -538,7 +538,7 @@ i = base + 1; j = limit - 1; - // now ensure that *i <= *base <= *j + // now ensure that *i <= *base <= *j if((*j)->x < (*i)->x) { swap_cells(i, j); @@ -619,7 +619,7 @@ //------------------------------------------------------------------------ - template<class Cell> + template<class Cell> void rasterizer_cells_aa<Cell>::sort_cells() { if(m_sorted) return; //Perform sort only the first time. @@ -636,9 +636,9 @@ //for(unsigned nc = 0; nc < m_num_cells; nc++) //{ // cell_type* cell = m_cells[nc >> cell_block_shift] + (nc & cell_block_mask); -// if(cell->x < m_min_x || -// cell->y < m_min_y || -// cell->x > m_max_x || +// if(cell->x < m_min_x || +// cell->y < m_min_y || +// cell->x > m_max_x || // cell->y > m_max_y) // { // cell = cell; // Breakpoint here @@ -660,19 +660,21 @@ { cell_ptr = *block_ptr++; i = cell_block_size; - while(i--) + while(i--) { m_sorted_y[cell_ptr->y - m_min_y].start++; ++cell_ptr; } } - cell_ptr = *block_ptr++; i = m_num_cells & cell_block_mask; - while(i--) - { - m_sorted_y[cell_ptr->y - m_min_y].start++; - ++cell_ptr; + if (i) { + cell_ptr = *block_ptr++; + while(i--) + { + m_sorted_y[cell_ptr->y - m_min_y].start++; + ++cell_ptr; + } } // Convert the Y-histogram into the array of starting indexes @@ -691,7 +693,7 @@ { cell_ptr = *block_ptr++; i = cell_block_size; - while(i--) + while(i--) { sorted_y& curr_y = m_sorted_y[cell_ptr->y - m_min_y]; m_sorted_cells[curr_y.start + curr_y.num] = cell_ptr; @@ -699,15 +701,17 @@ ++cell_ptr; } } - - cell_ptr = *block_ptr++; + i = m_num_cells & cell_block_mask; - while(i--) - { - sorted_y& curr_y = m_sorted_y[cell_ptr->y - m_min_y]; - m_sorted_cells[curr_y.start + curr_y.num] = cell_ptr; - ++curr_y.num; - ++cell_ptr; + if (i) { + cell_ptr = *block_ptr++; + while(i--) + { + sorted_y& curr_y = m_sorted_y[cell_ptr->y - m_min_y]; + m_sorted_cells[curr_y.start + curr_y.num] = cell_ptr; + ++curr_y.num; + ++cell_ptr; + } } // Finally arrange the X-arrays This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-10-08 18:16:51
|
Revision: 6172 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6172&view=rev Author: mdboom Date: 2008-10-08 18:16:49 +0000 (Wed, 08 Oct 2008) Log Message: ----------- More informative error message when data is too large for Agg to draw it. Modified Paths: -------------- trunk/matplotlib/agg24/include/agg_rasterizer_cells_aa.h Modified: trunk/matplotlib/agg24/include/agg_rasterizer_cells_aa.h =================================================================== --- trunk/matplotlib/agg24/include/agg_rasterizer_cells_aa.h 2008-10-08 16:37:15 UTC (rev 6171) +++ trunk/matplotlib/agg24/include/agg_rasterizer_cells_aa.h 2008-10-08 18:16:49 UTC (rev 6172) @@ -185,7 +185,10 @@ if((m_num_cells & cell_block_mask) == 0) { if(m_num_blocks >= cell_block_limit) { - throw "Agg rendering complexity exceeded."; + /* If this exception is thrown too often, one can + increase cell_block_limit */ + throw "Agg rendering complexity exceeded. " + "Consider downsampling or decimating your data."; } allocate_block(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2010-06-22 16:01:01
|
Revision: 8454 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8454&view=rev Author: mdboom Date: 2010-06-22 16:00:55 +0000 (Tue, 22 Jun 2010) Log Message: ----------- Debian Bug#585442: python-matplotlib: crashes when calling axis() after imshow() This allows the C++ exception raised when Agg rendering complexity is exceeded to percolate up correctly to a Python exception, rather than crashing the interpreter. Modified Paths: -------------- trunk/matplotlib/agg24/include/agg_rasterizer_cells_aa.h Modified: trunk/matplotlib/agg24/include/agg_rasterizer_cells_aa.h =================================================================== --- trunk/matplotlib/agg24/include/agg_rasterizer_cells_aa.h 2010-06-21 21:41:19 UTC (rev 8453) +++ trunk/matplotlib/agg24/include/agg_rasterizer_cells_aa.h 2010-06-22 16:00:55 UTC (rev 8454) @@ -29,16 +29,15 @@ #ifndef AGG_RASTERIZER_CELLS_AA_INCLUDED #define AGG_RASTERIZER_CELLS_AA_INCLUDED +#include "CXX/Exception.hxx" #include <exception> #include <string.h> #include <math.h> #include "agg_math.h" #include "agg_array.h" - namespace agg { - //-----------------------------------------------------rasterizer_cells_aa // An internal class that implements the main rasterization algorithm. // Used in the rasterizer. Should not be used direcly. @@ -180,6 +179,11 @@ template<class Cell> AGG_INLINE void rasterizer_cells_aa<Cell>::add_curr_cell() { + static Py::Exception e( + Py::OverflowError( + "Agg rendering complexity exceeded. Consider downsampling or decimating your data.")); + + if(m_curr_cell.area | m_curr_cell.cover) { if((m_num_cells & cell_block_mask) == 0) @@ -187,8 +191,7 @@ if(m_num_blocks >= cell_block_limit) { /* If this exception is thrown too often, one can increase cell_block_limit */ - throw "Agg rendering complexity exceeded. " - "Consider downsampling or decimating your data."; + throw e; } allocate_block(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2010-06-22 16:30:31
|
Revision: 8455 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8455&view=rev Author: mdboom Date: 2010-06-22 16:30:24 +0000 (Tue, 22 Jun 2010) Log Message: ----------- Debian Bug#585442: python-matplotlib: crashes when calling axis() after imshow() This allows the C++ exception raised when Agg rendering complexity is exceeded to percolate up correctly to a Python exception, rather than crashing the interpreter. Fixes problem in last commit. Modified Paths: -------------- trunk/matplotlib/agg24/include/agg_rasterizer_cells_aa.h Modified: trunk/matplotlib/agg24/include/agg_rasterizer_cells_aa.h =================================================================== --- trunk/matplotlib/agg24/include/agg_rasterizer_cells_aa.h 2010-06-22 16:00:55 UTC (rev 8454) +++ trunk/matplotlib/agg24/include/agg_rasterizer_cells_aa.h 2010-06-22 16:30:24 UTC (rev 8455) @@ -179,16 +179,15 @@ template<class Cell> AGG_INLINE void rasterizer_cells_aa<Cell>::add_curr_cell() { - static Py::Exception e( - Py::OverflowError( - "Agg rendering complexity exceeded. Consider downsampling or decimating your data.")); - - if(m_curr_cell.area | m_curr_cell.cover) { if((m_num_cells & cell_block_mask) == 0) { if(m_num_blocks >= cell_block_limit) { + static Py::Exception e( + Py::OverflowError( + "Agg rendering complexity exceeded. Consider downsampling or decimating your data.")); + /* If this exception is thrown too often, one can increase cell_block_limit */ throw e; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |