Revert "WIP: SVG import & rasterization"

This reverts commit 9b15908a47.
This commit is contained in:
bubnikv 2019-02-07 12:09:10 +01:00
parent a178a0ff7e
commit 34b14eb8fa
59 changed files with 3609 additions and 10669 deletions

View file

@ -1,25 +1,12 @@
//----------------------------------------------------------------------------
// Anti-Grain Geometry (AGG) - Version 2.5
// A high quality rendering engine for C++
// Copyright (C) 2002-2006 Maxim Shemanarev
// Contact: mcseem@antigrain.com
// mcseemagg@yahoo.com
// http://antigrain.com
//
// AGG is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// AGG is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with AGG; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
// MA 02110-1301, USA.
// 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.
// 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,
@ -27,6 +14,10 @@
// libray - in producing this work. See http://www.freetype.org for details.
//
//----------------------------------------------------------------------------
// Contact: mcseem@antigrain.com
// mcseemagg@yahoo.com
// http://www.antigrain.com
//----------------------------------------------------------------------------
//
// Adaptation for 32-bit screen coordinates has been sponsored by
// Liberty Technology Systems, Inc., visit http://lib-sys.com
@ -35,12 +26,12 @@
// PostScript and PDF technology for software developers.
//
//----------------------------------------------------------------------------
#ifndef AGG_RASTERIZER_CELLS_AA_INCLUDED
#define AGG_RASTERIZER_CELLS_AA_INCLUDED
#include <string.h>
#include <math.h>
#include <cstdlib>
#include <limits>
#include "agg_math.h"
#include "agg_array.h"
@ -160,10 +151,10 @@ namespace agg
m_curr_cell_ptr(0),
m_sorted_cells(),
m_sorted_y(),
m_min_x(0x7FFFFFFF),
m_min_y(0x7FFFFFFF),
m_max_x(-0x7FFFFFFF),
m_max_y(-0x7FFFFFFF),
m_min_x(std::numeric_limits<int>::max()),
m_min_y(std::numeric_limits<int>::max()),
m_max_x(std::numeric_limits<int>::min()),
m_max_y(std::numeric_limits<int>::min()),
m_sorted(false)
{
m_style_cell.initial();
@ -179,10 +170,10 @@ namespace agg
m_curr_cell.initial();
m_style_cell.initial();
m_sorted = false;
m_min_x = 0x7FFFFFFF;
m_min_y = 0x7FFFFFFF;
m_max_x = -0x7FFFFFFF;
m_max_y = -0x7FFFFFFF;
m_min_x = std::numeric_limits<int>::max();
m_min_y = std::numeric_limits<int>::max();
m_max_x = std::numeric_limits<int>::min();
m_max_y = std::numeric_limits<int>::min();
}
//------------------------------------------------------------------------
@ -227,7 +218,8 @@ namespace agg
int fx1 = x1 & poly_subpixel_mask;
int fx2 = x2 & poly_subpixel_mask;
int delta, p, first, dx;
int delta, p, first;
long long dx;
int incr, lift, mod, rem;
//trivial case. Happens often
@ -252,7 +244,7 @@ namespace agg
first = poly_subpixel_scale;
incr = 1;
dx = x2 - x1;
dx = (long long)x2 - (long long)x1;
if(dx < 0)
{
@ -262,13 +254,13 @@ namespace agg
dx = -dx;
}
delta = p / dx;
mod = p % dx;
delta = (int)(p / dx);
mod = (int)(p % dx);
if(mod < 0)
{
delta--;
mod += dx;
mod += static_cast<int>(dx);
}
m_curr_cell.cover += delta;
@ -281,16 +273,16 @@ namespace agg
if(ex1 != ex2)
{
p = poly_subpixel_scale * (y2 - y1 + delta);
lift = p / dx;
rem = p % dx;
lift = (int)(p / dx);
rem = (int)(p % dx);
if (rem < 0)
{
lift--;
rem += dx;
rem += static_cast<int>(dx);
}
mod -= dx;
mod -= static_cast<int>(dx);
while (ex1 != ex2)
{
@ -298,7 +290,7 @@ namespace agg
mod += rem;
if(mod >= 0)
{
mod -= dx;
mod -= static_cast<int>(dx);
delta++;
}
@ -327,17 +319,17 @@ namespace agg
{
enum dx_limit_e { dx_limit = 16384 << poly_subpixel_shift };
int dx = x2 - x1;
long long dx = (long long)x2 - (long long)x1;
if(dx >= dx_limit || dx <= -dx_limit)
{
int cx = (x1 + x2) >> 1;
int cy = (y1 + y2) >> 1;
int cx = (int)(((long long)x1 + (long long)x2) >> 1);
int cy = (int)(((long long)y1 + (long long)y2) >> 1);
line(x1, y1, cx, cy);
line(cx, cy, x2, y2);
}
int dy = y2 - y1;
long long dy = (long long)y2 - (long long)y1;
int ex1 = x1 >> poly_subpixel_shift;
int ex2 = x2 >> poly_subpixel_shift;
int ey1 = y1 >> poly_subpixel_shift;
@ -346,7 +338,8 @@ namespace agg
int fy2 = y2 & poly_subpixel_mask;
int x_from, x_to;
int p, rem, mod, lift, delta, first, incr;
int rem, mod, lift, delta, first, incr;
long long p;
if(ex1 < m_min_x) m_min_x = ex1;
if(ex1 > m_max_x) m_max_x = ex1;
@ -423,13 +416,13 @@ namespace agg
dy = -dy;
}
delta = p / dy;
mod = p % dy;
delta = (int)(p / dy);
mod = (int)(p % dy);
if(mod < 0)
{
delta--;
mod += dy;
mod += static_cast<int>(dy);
}
x_from = x1 + delta;
@ -441,15 +434,15 @@ namespace agg
if(ey1 != ey2)
{
p = poly_subpixel_scale * dx;
lift = p / dy;
rem = p % dy;
lift = (int)(p / dy);
rem = (int)(p % dy);
if(rem < 0)
{
lift--;
rem += dy;
rem += static_cast<int>(dy);
}
mod -= dy;
mod -= static_cast<int>(dy);
while(ey1 != ey2)
{
@ -457,7 +450,7 @@ namespace agg
mod += rem;
if (mod >= 0)
{
mod -= dy;
mod -= static_cast<int>(dy);
delta++;
}
@ -635,8 +628,8 @@ namespace agg
if(m_sorted) return; //Perform sort only the first time.
add_curr_cell();
m_curr_cell.x = 0x7FFFFFFF;
m_curr_cell.y = 0x7FFFFFFF;
m_curr_cell.x = std::numeric_limits<int>::max();
m_curr_cell.y = std::numeric_limits<int>::max();
m_curr_cell.cover = 0;
m_curr_cell.area = 0;
@ -664,12 +657,13 @@ namespace agg
// Create the Y-histogram (count the numbers of cells for each Y)
cell_type** block_ptr = m_cells;
cell_type* cell_ptr;
unsigned nb = m_num_cells >> cell_block_shift;
unsigned nb = m_num_cells;
unsigned i;
while(nb--)
while(nb)
{
cell_ptr = *block_ptr++;
i = cell_block_size;
i = (nb > cell_block_size) ? unsigned(cell_block_size) : nb;
nb -= i;
while(i--)
{
m_sorted_y[cell_ptr->y - m_min_y].start++;
@ -677,14 +671,6 @@ namespace agg
}
}
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;
}
// Convert the Y-histogram into the array of starting indexes
unsigned start = 0;
for(i = 0; i < m_sorted_y.size(); i++)
@ -696,12 +682,13 @@ namespace agg
// Fill the cell pointer array sorted by Y
block_ptr = m_cells;
nb = m_num_cells >> cell_block_shift;
while(nb--)
nb = m_num_cells;
while(nb)
{
cell_ptr = *block_ptr++;
i = cell_block_size;
while(i--)
i = (nb > cell_block_size) ? unsigned(cell_block_size) : nb;
nb -= 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;
@ -710,16 +697,6 @@ namespace agg
}
}
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;
}
// Finally arrange the X-arrays
for(i = 0; i < m_sorted_y.size(); i++)
{