diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-06-16 16:29:44 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-06-16 16:29:44 -0700 |
commit | 2ca8fcbc8a7a3ef6adfac154c47068c1696205d0 (patch) | |
tree | de3f825c75b1b92908825f68af8a4e7146cf97fd /third_party/agg23/agg_curves.h | |
parent | ea44bd064a86679a47a7265020f997d6e3b88336 (diff) | |
download | pdfium-2ca8fcbc8a7a3ef6adfac154c47068c1696205d0.tar.xz |
Separate agg-authored code from fx-authored code.chromium/2439chromium/2438chromium/2437chromium/2436chromium/2435
Creates a separate library so we can apply less-strict warnings to
the code we can't change from upstream vs. the code we can change,
reducing noise in the standalone build.
Remove needless foo.{cpp,h} files that merely perform indirection
via #include "some_other_path/foo.{cpp,h}".
BUG=pdfium:166
R=brucedawson@chromium.org, thestig@chromium.org
Review URL: https://codereview.chromium.org/1152743007.
Diffstat (limited to 'third_party/agg23/agg_curves.h')
-rw-r--r-- | third_party/agg23/agg_curves.h | 188 |
1 files changed, 188 insertions, 0 deletions
diff --git a/third_party/agg23/agg_curves.h b/third_party/agg23/agg_curves.h new file mode 100644 index 0000000000..495f7a6a8f --- /dev/null +++ b/third_party/agg23/agg_curves.h @@ -0,0 +1,188 @@ + +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.3 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// Copyright (C) 2005 Tony Juricic (tonygeek@yahoo.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. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- +#ifndef AGG_CURVES_INCLUDED +#define AGG_CURVES_INCLUDED +#include "agg_array.h" +namespace agg +{ +struct curve4_points { + FX_FLOAT cp[8]; + curve4_points() {} + curve4_points(FX_FLOAT x1, FX_FLOAT y1, + FX_FLOAT x2, FX_FLOAT y2, + FX_FLOAT x3, FX_FLOAT y3, + FX_FLOAT x4, FX_FLOAT y4) + { + cp[0] = x1; + cp[1] = y1; + cp[2] = x2; + cp[3] = y2; + cp[4] = x3; + cp[5] = y3; + cp[6] = x4; + cp[7] = y4; + } + void init(FX_FLOAT x1, FX_FLOAT y1, + FX_FLOAT x2, FX_FLOAT y2, + FX_FLOAT x3, FX_FLOAT y3, + FX_FLOAT x4, FX_FLOAT y4) + { + cp[0] = x1; + cp[1] = y1; + cp[2] = x2; + cp[3] = y2; + cp[4] = x3; + cp[5] = y3; + cp[6] = x4; + cp[7] = y4; + } + FX_FLOAT operator [] (unsigned i) const + { + return cp[i]; + } + FX_FLOAT& operator [] (unsigned i) + { + return cp[i]; + } +}; +class curve4_div +{ +public: + curve4_div() : + m_count(0) + {} + curve4_div(FX_FLOAT x1, FX_FLOAT y1, + FX_FLOAT x2, FX_FLOAT y2, + FX_FLOAT x3, FX_FLOAT y3, + FX_FLOAT x4, FX_FLOAT y4) : + m_count(0) + { + init(x1, y1, x2, y2, x3, y3, x4, y4); + } + curve4_div(const curve4_points& cp) : + m_count(0) + { + init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); + } + void reset() + { + m_points.remove_all(); + m_count = 0; + } + void init(FX_FLOAT x1, FX_FLOAT y1, + FX_FLOAT x2, FX_FLOAT y2, + FX_FLOAT x3, FX_FLOAT y3, + FX_FLOAT x4, FX_FLOAT y4); + void init(const curve4_points& cp) + { + init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); + } + void rewind(unsigned) + { + m_count = 0; + } + unsigned vertex(FX_FLOAT* x, FX_FLOAT* y) + { + if(m_count >= m_points.size()) { + return path_cmd_stop; + } + const point_type& p = m_points[m_count++]; + *x = p.x; + *y = p.y; + return (m_count == 1) ? path_cmd_move_to : path_cmd_line_to; + } + unsigned vertex_flag(FX_FLOAT* x, FX_FLOAT* y, int& flag) + { + if(m_count >= m_points.size()) { + return path_cmd_stop; + } + const point_type& p = m_points[m_count++]; + *x = p.x; + *y = p.y; + flag = p.flag; + return (m_count == 1) ? path_cmd_move_to : path_cmd_line_to; + } + int count() + { + return m_points.size(); + } +private: + void bezier(FX_FLOAT x1, FX_FLOAT y1, + FX_FLOAT x2, FX_FLOAT y2, + FX_FLOAT x3, FX_FLOAT y3, + FX_FLOAT x4, FX_FLOAT y4); + void recursive_bezier(FX_FLOAT x1, FX_FLOAT y1, + FX_FLOAT x2, FX_FLOAT y2, + FX_FLOAT x3, FX_FLOAT y3, + FX_FLOAT x4, FX_FLOAT y4, + unsigned level); + FX_FLOAT m_distance_tolerance_square; + FX_FLOAT m_distance_tolerance_manhattan; + unsigned m_count; + pod_deque<point_type> m_points; +}; +class curve4 +{ +public: + curve4() {} + curve4(FX_FLOAT x1, FX_FLOAT y1, + FX_FLOAT x2, FX_FLOAT y2, + FX_FLOAT x3, FX_FLOAT y3, + FX_FLOAT x4, FX_FLOAT y4) + { + init(x1, y1, x2, y2, x3, y3, x4, y4); + } + curve4(const curve4_points& cp) + { + init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); + } + void reset() + { + m_curve_div.reset(); + } + void init(FX_FLOAT x1, FX_FLOAT y1, + FX_FLOAT x2, FX_FLOAT y2, + FX_FLOAT x3, FX_FLOAT y3, + FX_FLOAT x4, FX_FLOAT y4) + { + m_curve_div.init(x1, y1, x2, y2, x3, y3, x4, y4); + } + void init(const curve4_points& cp) + { + init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); + } + void rewind(unsigned path_id) + { + m_curve_div.rewind(path_id); + } + unsigned vertex(FX_FLOAT* x, FX_FLOAT* y) + { + return m_curve_div.vertex(x, y); + } + unsigned vertex_curve_flag(FX_FLOAT* x, FX_FLOAT* y, int& flag) + { + return m_curve_div.vertex_flag(x, y, flag); + } + int count() + { + return m_curve_div.count(); + } +private: + curve4_div m_curve_div; +}; +} +#endif |