From 2ca8fcbc8a7a3ef6adfac154c47068c1696205d0 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 16 Jun 2015 16:29:44 -0700 Subject: Separate agg-authored code from fx-authored code. 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. --- third_party/agg23/agg_curves.h | 188 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100644 third_party/agg23/agg_curves.h (limited to 'third_party/agg23/agg_curves.h') 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 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 -- cgit v1.2.3