Created
November 19, 2012 19:09
-
-
Save mdboom/4112950 to your computer and use it in GitHub Desktop.
Patch against Agg-2.4 so overly-complex paths can be handled gracefully by matplotlib
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- agg-2.4/include/agg_rasterizer_cells_aa.h 2006-06-23 16:35:22.000000000 -0400 | |
+++ matplotlib/agg24/include/agg_rasterizer_cells_aa.h 2012-11-19 14:02:54.755434558 -0500 | |
@@ -29,15 +29,14 @@ | |
#ifndef AGG_RASTERIZER_CELLS_AA_INCLUDED | |
#define AGG_RASTERIZER_CELLS_AA_INCLUDED | |
+#include <stdexcept> | |
#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. | |
@@ -49,7 +48,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 | |
@@ -183,7 +182,10 @@ | |
{ | |
if((m_num_cells & cell_block_mask) == 0) | |
{ | |
- if(m_num_blocks >= cell_block_limit) return; | |
+ if (m_num_blocks >= cell_block_limit) | |
+ { | |
+ throw std::overflow_error("Allocated too many blocks"); | |
+ } | |
allocate_block(); | |
} | |
*m_curr_cell_ptr++ = m_curr_cell; | |
@@ -667,13 +669,15 @@ | |
} | |
} | |
- cell_ptr = *block_ptr++; | |
i = m_num_cells & cell_block_mask; | |
+ 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 | |
unsigned start = 0; | |
@@ -700,8 +704,9 @@ | |
} | |
} | |
- cell_ptr = *block_ptr++; | |
i = m_num_cells & cell_block_mask; | |
+ if (i) { | |
+ cell_ptr = *block_ptr++; | |
while(i--) | |
{ | |
sorted_y& curr_y = m_sorted_y[cell_ptr->y - m_min_y]; | |
@@ -709,6 +714,7 @@ | |
++curr_y.num; | |
++cell_ptr; | |
} | |
+ } | |
// Finally arrange the X-arrays | |
for(i = 0; i < m_sorted_y.size(); i++) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment