diff options
Diffstat (limited to 'third_party/agg23')
36 files changed, 889 insertions, 75 deletions
diff --git a/third_party/agg23/0000-bug-466.patch b/third_party/agg23/0000-bug-466.patch index e761198a4..5d62dcf0e 100644 --- a/third_party/agg23/0000-bug-466.patch +++ b/third_party/agg23/0000-bug-466.patch @@ -8,11 +8,11 @@ index 6d7ba8a..2b06b1b 100644 out_vertices.add(coord_type(x + dx1, y + dy1)); - if(!ccw) { - if(a1 > a2) { -- a2 += 2 * FX_PI; +- a2 += 2 * FXSYS_PI; + if (da > 0) { + if (!ccw) { + if (a1 > a2) { -+ a2 += 2 * FX_PI; ++ a2 += 2 * FXSYS_PI; } a2 -= da / 4; a1 += da; @@ -25,10 +25,10 @@ index 6d7ba8a..2b06b1b 100644 } - } else { - if(a1 < a2) { -- a2 -= 2 * FX_PI; +- a2 -= 2 * FXSYS_PI; + } else { + if (a1 < a2) { -+ a2 -= 2 * FX_PI; ++ a2 -= 2 * FXSYS_PI; } a2 += da / 4; a1 -= da; diff --git a/third_party/agg23/0008-namespace.patch b/third_party/agg23/0008-namespace.patch new file mode 100644 index 000000000..d2566fe6d --- /dev/null +++ b/third_party/agg23/0008-namespace.patch @@ -0,0 +1,508 @@ +diff --git a/third_party/agg23/agg_array.h b/third_party/agg23/agg_array.h +index fba41a7eb..b82d95296 100644 +--- a/third_party/agg23/agg_array.h ++++ b/third_party/agg23/agg_array.h +@@ -19,6 +19,8 @@ + #include "agg_basics.h" + #include "core/fxcrt/fx_memory.h" // For FXSYS_* macros. + ++namespace pdfium ++{ + namespace agg + { + template <class T> +@@ -499,4 +501,5 @@ template<class T> inline void swap_elements(T& a, T& b) + b = temp; + } + } ++} // namespace pdfium + #endif +diff --git a/third_party/agg23/agg_basics.h b/third_party/agg23/agg_basics.h +index 2a1c2af2f..eb6f35686 100644 +--- a/third_party/agg23/agg_basics.h ++++ b/third_party/agg23/agg_basics.h +@@ -43,6 +43,8 @@ + + #include "core/fxcrt/fx_system.h" + ++namespace pdfium ++{ + namespace agg + { + typedef AGG_INT8 int8; +@@ -274,4 +276,5 @@ struct vertex_type { + x(x_), y(y_), cmd(cmd_) {} + }; + } ++} // namespace pdfium + #endif +diff --git a/third_party/agg23/agg_clip_liang_barsky.h b/third_party/agg23/agg_clip_liang_barsky.h +index 31b35fe96..7b865fd20 100644 +--- a/third_party/agg23/agg_clip_liang_barsky.h ++++ b/third_party/agg23/agg_clip_liang_barsky.h +@@ -21,6 +21,8 @@ + #define AGG_CLIP_LIANG_BARSKY_INCLUDED + #include "agg_basics.h" + #include "third_party/base/numerics/safe_math.h" ++namespace pdfium ++{ + namespace agg + { + template<class T> +@@ -133,4 +135,5 @@ inline unsigned clip_liang_barsky(T x1, T y1, T x2, T y2, + return np; + } + } ++} // namespace pdfium + #endif +diff --git a/third_party/agg23/agg_color_gray.h b/third_party/agg23/agg_color_gray.h +index 5db7bcaf2..c1b6eabd0 100644 +--- a/third_party/agg23/agg_color_gray.h ++++ b/third_party/agg23/agg_color_gray.h +@@ -28,6 +28,8 @@ + #ifndef AGG_COLOR_GRAY_INCLUDED + #define AGG_COLOR_GRAY_INCLUDED + #include "agg_basics.h" ++namespace pdfium ++{ + namespace agg + { + struct gray8 { +@@ -47,4 +49,5 @@ struct gray8 { + v(int8u(v_)), a(int8u(a_)) {} + }; + } ++} // namespace pdfium + #endif +diff --git a/third_party/agg23/agg_conv_adaptor_vcgen.h b/third_party/agg23/agg_conv_adaptor_vcgen.h +index be4dc2d60..343c4e10b 100644 +--- a/third_party/agg23/agg_conv_adaptor_vcgen.h ++++ b/third_party/agg23/agg_conv_adaptor_vcgen.h +@@ -16,6 +16,8 @@ + #ifndef AGG_CONV_ADAPTOR_VCGEN_INCLUDED + #define AGG_CONV_ADAPTOR_VCGEN_INCLUDED + #include "agg_basics.h" ++namespace pdfium ++{ + namespace agg + { + struct null_markers { +@@ -135,4 +137,5 @@ unsigned conv_adaptor_vcgen<VertexSource, Generator, Markers>::vertex(float* x, + return cmd; + } + } ++} // namespace pdfium + #endif +diff --git a/third_party/agg23/agg_conv_dash.h b/third_party/agg23/agg_conv_dash.h +index f87eccc3b..3a45d5563 100644 +--- a/third_party/agg23/agg_conv_dash.h ++++ b/third_party/agg23/agg_conv_dash.h +@@ -22,6 +22,8 @@ + #include "agg_basics.h" + #include "agg_vcgen_dash.h" + #include "agg_conv_adaptor_vcgen.h" ++namespace pdfium ++{ + namespace agg + { + template<class VertexSource, class Markers = null_markers> +@@ -58,4 +60,5 @@ private: + operator = (const conv_dash<VertexSource, Markers>&); + }; + } ++} // namespace pdfium + #endif +diff --git a/third_party/agg23/agg_conv_stroke.h b/third_party/agg23/agg_conv_stroke.h +index 82268ddec..a65fe3e48 100644 +--- a/third_party/agg23/agg_conv_stroke.h ++++ b/third_party/agg23/agg_conv_stroke.h +@@ -22,6 +22,8 @@ + #include "agg_basics.h" + #include "agg_vcgen_stroke.h" + #include "agg_conv_adaptor_vcgen.h" ++namespace pdfium ++{ + namespace agg + { + template<class VertexSource, class Markers = null_markers> +@@ -107,4 +109,5 @@ private: + operator = (const conv_stroke<VertexSource, Markers>&); + }; + } ++} // namespace pdfium + #endif +diff --git a/third_party/agg23/agg_curves.cpp b/third_party/agg23/agg_curves.cpp +index 41900c81f..be89752e0 100644 +--- a/third_party/agg23/agg_curves.cpp ++++ b/third_party/agg23/agg_curves.cpp +@@ -22,6 +22,8 @@ + #include "agg_curves.h" + #include "agg_math.h" + ++namespace pdfium ++{ + namespace agg + { + const float curve_collinearity_epsilon = 1e-30f; +@@ -107,3 +109,4 @@ void curve4_div::bezier(float x1, float y1, + m_points.add(point_type(x4, y4)); + } + } ++} // namespace pdfium +diff --git a/third_party/agg23/agg_curves.h b/third_party/agg23/agg_curves.h +index 488db4a1f..908bd9a5a 100644 +--- a/third_party/agg23/agg_curves.h ++++ b/third_party/agg23/agg_curves.h +@@ -17,6 +17,8 @@ + #ifndef AGG_CURVES_INCLUDED + #define AGG_CURVES_INCLUDED + #include "agg_array.h" ++namespace pdfium ++{ + namespace agg + { + struct curve4_points { +@@ -185,4 +187,5 @@ private: + curve4_div m_curve_div; + }; + } ++} // namespace pdfium + #endif +diff --git a/third_party/agg23/agg_math.h b/third_party/agg23/agg_math.h +index 6d5e39ac3..15617b2e8 100644 +--- a/third_party/agg23/agg_math.h ++++ b/third_party/agg23/agg_math.h +@@ -19,6 +19,8 @@ + #ifndef AGG_MATH_INCLUDED + #define AGG_MATH_INCLUDED + #include "agg_basics.h" ++namespace pdfium ++{ + namespace agg + { + const float intersection_epsilon = 1.0e-30f; +@@ -60,4 +62,5 @@ AGG_INLINE bool calc_intersection(float ax, float ay, float bx, float by, + return true; + } + } ++} // namespace pdfium + #endif +diff --git a/third_party/agg23/agg_math_stroke.h b/third_party/agg23/agg_math_stroke.h +index 82df8080c..8515d2b16 100644 +--- a/third_party/agg23/agg_math_stroke.h ++++ b/third_party/agg23/agg_math_stroke.h +@@ -21,6 +21,8 @@ + #define AGG_STROKE_MATH_INCLUDED + #include "agg_math.h" + #include "agg_vertex_sequence.h" ++namespace pdfium ++{ + namespace agg + { + enum line_cap_e { +@@ -270,4 +272,5 @@ void stroke_calc_join(VertexConsumer& out_vertices, + } + } + } ++} // namespace pdfium + #endif +diff --git a/third_party/agg23/agg_path_storage.cpp b/third_party/agg23/agg_path_storage.cpp +index 063ece542..2cd0caed1 100644 +--- a/third_party/agg23/agg_path_storage.cpp ++++ b/third_party/agg23/agg_path_storage.cpp +@@ -28,6 +28,8 @@ + #include "agg_math.h" + #include "core/fxcrt/fx_memory.h" + ++namespace pdfium ++{ + namespace agg + { + path_storage::~path_storage() +@@ -95,3 +97,4 @@ void path_storage::end_poly() + } + } + } ++} // namespace pdfium +diff --git a/third_party/agg23/agg_path_storage.h b/third_party/agg23/agg_path_storage.h +index 17e82d73e..55d6df001 100644 +--- a/third_party/agg23/agg_path_storage.h ++++ b/third_party/agg23/agg_path_storage.h +@@ -16,6 +16,8 @@ + #ifndef AGG_PATH_STORAGE_INCLUDED + #define AGG_PATH_STORAGE_INCLUDED + #include "agg_basics.h" ++namespace pdfium ++{ + namespace agg + { + class path_storage +@@ -169,4 +171,5 @@ inline void path_storage::line_to(float x, float y) + add_vertex(x, y, path_cmd_line_to); + } + } ++} // namespace pdfium + #endif +diff --git a/third_party/agg23/agg_pixfmt_gray.h b/third_party/agg23/agg_pixfmt_gray.h +index 5a8093547..561bb7179 100644 +--- a/third_party/agg23/agg_pixfmt_gray.h ++++ b/third_party/agg23/agg_pixfmt_gray.h +@@ -26,6 +26,8 @@ + #include "agg_basics.h" + #include "agg_color_gray.h" + #include "agg_rendering_buffer.h" ++namespace pdfium ++{ + namespace agg + { + template<class ColorT> struct blender_gray { +@@ -174,4 +176,5 @@ private: + typedef blender_gray<gray8> blender_gray8; + typedef pixel_formats_gray<blender_gray8, 1, 0> pixfmt_gray8; + } ++} // namespace pdfium + #endif +diff --git a/third_party/agg23/agg_rasterizer_scanline_aa.cpp b/third_party/agg23/agg_rasterizer_scanline_aa.cpp +index 7850225d1..d2b6a46e4 100644 +--- a/third_party/agg23/agg_rasterizer_scanline_aa.cpp ++++ b/third_party/agg23/agg_rasterizer_scanline_aa.cpp +@@ -49,6 +49,8 @@ + #include <limits.h> + #include "agg_rasterizer_scanline_aa.h" + #include "third_party/base/numerics/safe_math.h" ++namespace pdfium ++{ + namespace agg + { + AGG_INLINE void cell_aa::set_cover(int c, int a) +@@ -515,3 +517,4 @@ bool rasterizer_scanline_aa::safe_add(int* op1, int op2) + return true; + } + } ++} // namespace pdfium +diff --git a/third_party/agg23/agg_rasterizer_scanline_aa.h b/third_party/agg23/agg_rasterizer_scanline_aa.h +index eade78333..133d66c4f 100644 +--- a/third_party/agg23/agg_rasterizer_scanline_aa.h ++++ b/third_party/agg23/agg_rasterizer_scanline_aa.h +@@ -38,6 +38,8 @@ + #include "core/fxcrt/fx_coordinates.h" + #include "core/fxcrt/fx_memory.h" + ++namespace pdfium ++{ + namespace agg + { + enum poly_base_scale_e { +@@ -495,4 +497,5 @@ private: + int m_cur_y; + }; + } ++} // namespace pdfium + #endif +diff --git a/third_party/agg23/agg_render_scanlines.h b/third_party/agg23/agg_render_scanlines.h +index 0dfd6d259..03ec683eb 100644 +--- a/third_party/agg23/agg_render_scanlines.h ++++ b/third_party/agg23/agg_render_scanlines.h +@@ -16,6 +16,8 @@ + #ifndef AGG_RENDER_SCANLINES_INCLUDED + #define AGG_RENDER_SCANLINES_INCLUDED + #include "agg_basics.h" ++namespace pdfium ++{ + namespace agg + { + template<class Rasterizer, class Scanline, class Renderer> +@@ -47,4 +49,5 @@ void render_all_paths(Rasterizer& ras, + } + } + } ++} // namespace pdfium + #endif +diff --git a/third_party/agg23/agg_renderer_base.h b/third_party/agg23/agg_renderer_base.h +index bd1b203b9..d637be262 100644 +--- a/third_party/agg23/agg_renderer_base.h ++++ b/third_party/agg23/agg_renderer_base.h +@@ -21,6 +21,8 @@ + #define AGG_RENDERER_BASE_INCLUDED + #include "agg_basics.h" + #include "agg_rendering_buffer.h" ++namespace pdfium ++{ + namespace agg + { + template<class PixelFormat> class renderer_base +@@ -160,4 +162,5 @@ private: + rect m_clip_box; + }; + } ++} // namespace pdfium + #endif +diff --git a/third_party/agg23/agg_renderer_scanline.h b/third_party/agg23/agg_renderer_scanline.h +index 62d104f7f..32db738d3 100644 +--- a/third_party/agg23/agg_renderer_scanline.h ++++ b/third_party/agg23/agg_renderer_scanline.h +@@ -18,6 +18,8 @@ + #include "agg_basics.h" + #include "agg_renderer_base.h" + #include "agg_render_scanlines.h" ++namespace pdfium ++{ + namespace agg + { + template<class BaseRenderer, class SpanGenerator> class renderer_scanline_aa +@@ -90,4 +92,5 @@ private: + SpanGenerator* m_span_gen; + }; + } ++} // namespace pdfium + #endif +diff --git a/third_party/agg23/agg_rendering_buffer.h b/third_party/agg23/agg_rendering_buffer.h +index 9c1c0c689..4c80160b7 100644 +--- a/third_party/agg23/agg_rendering_buffer.h ++++ b/third_party/agg23/agg_rendering_buffer.h +@@ -20,6 +20,8 @@ + #ifndef AGG_RENDERING_BUFFER_INCLUDED + #define AGG_RENDERING_BUFFER_INCLUDED + #include "agg_basics.h" ++namespace pdfium ++{ + namespace agg + { + class rendering_buffer +@@ -142,4 +144,5 @@ private: + unsigned m_max_height; + }; + } ++} // namespace pdfium + #endif +diff --git a/third_party/agg23/agg_scanline_u.h b/third_party/agg23/agg_scanline_u.h +index 844dc9aad..1db31c3e3 100644 +--- a/third_party/agg23/agg_scanline_u.h ++++ b/third_party/agg23/agg_scanline_u.h +@@ -24,6 +24,8 @@ + #ifndef AGG_SCANLINE_U_INCLUDED + #define AGG_SCANLINE_U_INCLUDED + #include "agg_array.h" ++namespace pdfium ++{ + namespace agg + { + template<class CoverT> class scanline_u +@@ -147,4 +149,5 @@ private: + }; + typedef scanline_u<int8u> scanline_u8; + } ++} // namespace pdfium + #endif +diff --git a/third_party/agg23/agg_shorten_path.h b/third_party/agg23/agg_shorten_path.h +index 2f62ec52d..280d1688e 100644 +--- a/third_party/agg23/agg_shorten_path.h ++++ b/third_party/agg23/agg_shorten_path.h +@@ -17,6 +17,8 @@ + #define AGG_SHORTEN_PATH_INCLUDED + #include "agg_basics.h" + #include "agg_vertex_sequence.h" ++namespace pdfium ++{ + namespace agg + { + template<class VertexSequence> +@@ -54,4 +56,5 @@ void shorten_path(VertexSequence& vs, float s, unsigned closed = 0) + } + } + } ++} // namespace pdfium + #endif +diff --git a/third_party/agg23/agg_vcgen_dash.cpp b/third_party/agg23/agg_vcgen_dash.cpp +index fdbd2aa7f..f690760b0 100644 +--- a/third_party/agg23/agg_vcgen_dash.cpp ++++ b/third_party/agg23/agg_vcgen_dash.cpp +@@ -21,6 +21,8 @@ + #include "agg_shorten_path.h" + #include "agg_vcgen_dash.h" + ++namespace pdfium ++{ + namespace agg + { + vcgen_dash::vcgen_dash() : +@@ -175,3 +177,4 @@ unsigned vcgen_dash::vertex(float* x, float* y) + return path_cmd_stop; + } + } ++} // namespace pdfium +diff --git a/third_party/agg23/agg_vcgen_dash.h b/third_party/agg23/agg_vcgen_dash.h +index 7702fa7ad..2a4c94eab 100644 +--- a/third_party/agg23/agg_vcgen_dash.h ++++ b/third_party/agg23/agg_vcgen_dash.h +@@ -21,6 +21,8 @@ + #define AGG_VCGEN_DASH_INCLUDED + #include "agg_basics.h" + #include "agg_vertex_sequence.h" ++namespace pdfium ++{ + namespace agg + { + class vcgen_dash +@@ -72,4 +74,5 @@ private: + unsigned m_src_vertex; + }; + } ++} // namespace pdfium + #endif +diff --git a/third_party/agg23/agg_vcgen_stroke.cpp b/third_party/agg23/agg_vcgen_stroke.cpp +index 3e97a3147..f65eac55f 100644 +--- a/third_party/agg23/agg_vcgen_stroke.cpp ++++ b/third_party/agg23/agg_vcgen_stroke.cpp +@@ -25,6 +25,8 @@ + + #include "agg_vcgen_stroke.h" + ++namespace pdfium ++{ + namespace agg + { + +@@ -212,3 +214,4 @@ unsigned vcgen_stroke::vertex(float* x, float* y) + return cmd; + } + } ++} // namespace pdfium +diff --git a/third_party/agg23/agg_vcgen_stroke.h b/third_party/agg23/agg_vcgen_stroke.h +index 23142d37f..ed9bb416f 100644 +--- a/third_party/agg23/agg_vcgen_stroke.h ++++ b/third_party/agg23/agg_vcgen_stroke.h +@@ -16,6 +16,8 @@ + #ifndef AGG_VCGEN_STROKE_INCLUDED + #define AGG_VCGEN_STROKE_INCLUDED + #include "agg_math_stroke.h" ++namespace pdfium ++{ + namespace agg + { + class vcgen_stroke +@@ -117,4 +119,5 @@ private: + unsigned m_out_vertex; + }; + } ++} // namespace pdfium + #endif +diff --git a/third_party/agg23/agg_vertex_sequence.h b/third_party/agg23/agg_vertex_sequence.h +index 80eabbb95..dc729d55c 100644 +--- a/third_party/agg23/agg_vertex_sequence.h ++++ b/third_party/agg23/agg_vertex_sequence.h +@@ -22,6 +22,8 @@ + #include "agg_basics.h" + #include "agg_array.h" + #include "agg_math.h" ++namespace pdfium ++{ + namespace agg + { + template<class T, unsigned S = 6> +@@ -97,4 +99,5 @@ struct vertex_dist_cmd : public vertex_dist { + } + }; + } ++} // namespace pdfium + #endif diff --git a/third_party/agg23/0009-infinite-loop.patch b/third_party/agg23/0009-infinite-loop.patch new file mode 100644 index 000000000..ffa540f03 --- /dev/null +++ b/third_party/agg23/0009-infinite-loop.patch @@ -0,0 +1,25 @@ +diff --git a/third_party/agg23/agg_math_stroke.h b/third_party/agg23/agg_math_stroke.h +index 8515d2b16..70d1f2cf9 100644 +--- a/third_party/agg23/agg_math_stroke.h ++++ b/third_party/agg23/agg_math_stroke.h +@@ -173,6 +173,9 @@ void stroke_calc_cap(VertexConsumer& out_vertices, + float a1 = atan2(dy1, -dx1); + float a2 = a1 + FXSYS_PI; + float da = acos(width / (width + ((1.0f / 8) / approximation_scale))) * 2; ++ if (da < stroke_theta) { ++ da = stroke_theta; ++ } + out_vertices.add(coord_type(v0.x - dx1, v0.y + dy1)); + a1 += da; + a2 -= da / 4; +@@ -180,8 +183,8 @@ void stroke_calc_cap(VertexConsumer& out_vertices, + out_vertices.add( + coord_type(v0.x + (width * cos(a1)), v0.y + (width * sin(a1)))); + a1 += da; +- } +- out_vertices.add(coord_type(v0.x + dx1, v0.y - dy1)); ++ } ++ out_vertices.add(coord_type(v0.x + dx1, v0.y - dy1)); + } + } + template<class VertexConsumer> diff --git a/third_party/agg23/0010-math.patch b/third_party/agg23/0010-math.patch new file mode 100644 index 000000000..ae5d6a338 --- /dev/null +++ b/third_party/agg23/0010-math.patch @@ -0,0 +1,12 @@ +diff --git a/third_party/agg23/agg_basics.h b/third_party/agg23/agg_basics.h +index eb6f35686..e7583e308 100644 +--- a/third_party/agg23/agg_basics.h ++++ b/third_party/agg23/agg_basics.h +@@ -41,6 +41,7 @@ + #endif + #define AGG_INLINE inline + ++#include <math.h> + #include "core/fxcrt/fx_system.h" + + namespace pdfium diff --git a/third_party/agg23/0011-path-storage-move-ctor.patch b/third_party/agg23/0011-path-storage-move-ctor.patch new file mode 100644 index 000000000..c0fbee54a --- /dev/null +++ b/third_party/agg23/0011-path-storage-move-ctor.patch @@ -0,0 +1,67 @@ +diff --git a/third_party/agg23/agg_path_storage.cpp b/third_party/agg23/agg_path_storage.cpp +index 2cd0caed1..1491e9e33 100644 +--- a/third_party/agg23/agg_path_storage.cpp ++++ b/third_party/agg23/agg_path_storage.cpp +@@ -43,14 +43,20 @@ path_storage::~path_storage() + FX_Free(m_coord_blocks); + } + } +-path_storage::path_storage() : +- m_total_vertices(0), +- m_total_blocks(0), +- m_max_blocks(0), +- m_coord_blocks(0), +- m_cmd_blocks(0), +- m_iterator(0) +-{ ++path_storage::path_storage() = default; ++path_storage::path_storage(path_storage&& other) { ++ m_total_vertices = other.m_total_vertices; ++ m_total_blocks = other.m_total_blocks; ++ m_max_blocks = other.m_max_blocks; ++ m_coord_blocks = other.m_coord_blocks; ++ m_cmd_blocks = other.m_cmd_blocks; ++ m_iterator = other.m_iterator; ++ other.m_total_vertices = 0; ++ other.m_total_blocks = 0; ++ other.m_max_blocks = 0; ++ other.m_coord_blocks = nullptr; ++ other.m_cmd_blocks = nullptr; ++ other.m_iterator = 0; + } + void path_storage::allocate_block(unsigned nb) + { +diff --git a/third_party/agg23/agg_path_storage.h b/third_party/agg23/agg_path_storage.h +index 55d6df001..8f10ff36d 100644 +--- a/third_party/agg23/agg_path_storage.h ++++ b/third_party/agg23/agg_path_storage.h +@@ -50,6 +50,10 @@ public: + }; + ~path_storage(); + path_storage(); ++ path_storage(path_storage&& other); ++ path_storage& operator=(path_storage&&) = delete; ++ path_storage(const path_storage&) = delete; ++ path_storage& operator=(const path_storage&) = delete; + unsigned last_vertex(float* x, float* y) const; + unsigned prev_vertex(float* x, float* y) const; + void move_to(float x, float y); +@@ -116,12 +120,12 @@ private: + void allocate_block(unsigned nb); + unsigned char* storage_ptrs(float** xy_ptr); + private: +- unsigned m_total_vertices; +- unsigned m_total_blocks; +- unsigned m_max_blocks; +- float** m_coord_blocks; +- unsigned char** m_cmd_blocks; +- unsigned m_iterator; ++ unsigned m_total_vertices = 0; ++ unsigned m_total_blocks = 0; ++ unsigned m_max_blocks = 0; ++ float** m_coord_blocks = nullptr; ++ unsigned char** m_cmd_blocks = nullptr; ++ unsigned m_iterator = 0; + }; + inline unsigned path_storage::vertex(float* x, float* y) + { diff --git a/third_party/agg23/0012-infinite-loop.patch b/third_party/agg23/0012-infinite-loop.patch new file mode 100644 index 000000000..ce1b690e7 --- /dev/null +++ b/third_party/agg23/0012-infinite-loop.patch @@ -0,0 +1,25 @@ +diff --git a/third_party/agg23/agg_vcgen_dash.cpp b/third_party/agg23/agg_vcgen_dash.cpp +index f690760b0..d44fca178 100644 +--- a/third_party/agg23/agg_vcgen_dash.cpp ++++ b/third_party/agg23/agg_vcgen_dash.cpp +@@ -18,8 +18,11 @@ + // + //---------------------------------------------------------------------------- + ++#include <cmath> ++ + #include "agg_shorten_path.h" + #include "agg_vcgen_dash.h" ++#include "third_party/base/check_op.h" + + namespace pdfium + { +@@ -60,6 +63,8 @@ void vcgen_dash::dash_start(float ds) + } + void vcgen_dash::calc_dash_start(float ds) + { ++ DCHECK_GT(m_total_dash_len, 0); ++ ds -= floor(ds / m_total_dash_len) * m_total_dash_len; + m_curr_dash = 0; + m_curr_dash_start = 0; + while(ds > 0) { diff --git a/third_party/agg23/0013-cxx20.patch b/third_party/agg23/0013-cxx20.patch new file mode 100644 index 000000000..1a77349a3 --- /dev/null +++ b/third_party/agg23/0013-cxx20.patch @@ -0,0 +1,56 @@ +diff --git a/third_party/agg23/agg_basics.h b/third_party/agg23/agg_basics.h +index e7583e308..84313db5b 100644 +--- a/third_party/agg23/agg_basics.h ++++ b/third_party/agg23/agg_basics.h +@@ -216,7 +216,7 @@ inline bool is_close(unsigned c) + { + c &= ~path_flags_jr; + return (c & ~(path_flags_cw | path_flags_ccw)) == +- (path_cmd_end_poly | path_flags_close); ++ (unsigned{path_cmd_end_poly} | path_flags_close); + } + inline bool is_next_poly(unsigned c) + { +diff --git a/third_party/agg23/agg_path_storage.cpp b/third_party/agg23/agg_path_storage.cpp +index 1491e9e33..2981e9c0c 100644 +--- a/third_party/agg23/agg_path_storage.cpp ++++ b/third_party/agg23/agg_path_storage.cpp +@@ -98,7 +98,7 @@ void path_storage::end_poly() + { + if(m_total_vertices) { + if(is_vertex(command(m_total_vertices - 1))) { +- add_vertex(0, 0, path_cmd_end_poly | path_flags_close); ++ add_vertex(0, 0, unsigned{path_cmd_end_poly} | path_flags_close); + } + } + } +diff --git a/third_party/agg23/agg_rasterizer_scanline_aa.h b/third_party/agg23/agg_rasterizer_scanline_aa.h +index 133d66c4f..dd0d00076 100644 +--- a/third_party/agg23/agg_rasterizer_scanline_aa.h ++++ b/third_party/agg23/agg_rasterizer_scanline_aa.h +@@ -49,7 +49,7 @@ enum poly_base_scale_e { + }; + inline int poly_coord(float c) + { +- return int(c * poly_base_size); ++ return int(c * float{poly_base_size}); + } + struct cell_aa { + int x; +diff --git a/third_party/agg23/agg_vcgen_stroke.cpp b/third_party/agg23/agg_vcgen_stroke.cpp +index f65eac55f..b0f8a50e2 100644 +--- a/third_party/agg23/agg_vcgen_stroke.cpp ++++ b/third_party/agg23/agg_vcgen_stroke.cpp +@@ -202,10 +202,10 @@ unsigned vcgen_stroke::vertex(float* x, float* y) + break; + case end_poly1: + m_status = m_prev_status; +- return path_cmd_end_poly | path_flags_close | path_flags_ccw; ++ return unsigned{path_cmd_end_poly} | path_flags_close | path_flags_ccw; + case end_poly2: + m_status = m_prev_status; +- return path_cmd_end_poly | path_flags_close | path_flags_cw; ++ return unsigned{path_cmd_end_poly} | path_flags_close | path_flags_cw; + case stop: + cmd = path_cmd_stop; + break; diff --git a/third_party/agg23/0014-ubsan-render-line.patch b/third_party/agg23/0014-ubsan-render-line.patch new file mode 100644 index 000000000..b766eb287 --- /dev/null +++ b/third_party/agg23/0014-ubsan-render-line.patch @@ -0,0 +1,35 @@ +diff --git a/third_party/agg23/agg_rasterizer_scanline_aa.cpp b/third_party/agg23/agg_rasterizer_scanline_aa.cpp +index d2b6a46e4..2f19a1816 100644 +--- a/third_party/agg23/agg_rasterizer_scanline_aa.cpp ++++ b/third_party/agg23/agg_rasterizer_scanline_aa.cpp +@@ -227,10 +227,27 @@ AGG_INLINE void outline_aa::render_hline(int ey, int x1, int y1, int x2, int y2) + void outline_aa::render_line(int x1, int y1, int x2, int y2) + { + enum dx_limit_e { dx_limit = 16384 << poly_base_shift }; +- int dx = x2 - x1; ++ pdfium::base::CheckedNumeric<int> safe_dx = x2; ++ safe_dx -= x1; ++ if (!safe_dx.IsValid()) ++ return; ++ ++ int dx = safe_dx.ValueOrDie(); + if(dx >= dx_limit || dx <= -dx_limit) { +- int cx = (x1 + x2) >> 1; +- int cy = (y1 + y2) >> 1; ++ pdfium::base::CheckedNumeric<int> safe_cx = x1; ++ safe_cx += x2; ++ safe_cx /= 2; ++ if (!safe_cx.IsValid()) ++ return; ++ ++ pdfium::base::CheckedNumeric<int> safe_cy = y1; ++ safe_cy += y2; ++ safe_cy /= 2; ++ if (!safe_cy.IsValid()) ++ return; ++ ++ int cx = safe_cx.ValueOrDie(); ++ int cy = safe_cy.ValueOrDie(); + render_line(x1, y1, cx, cy); + render_line(cx, cy, x2, y2); + } diff --git a/third_party/agg23/README.pdfium b/third_party/agg23/README.pdfium index 0319903a2..1b8393280 100644 --- a/third_party/agg23/README.pdfium +++ b/third_party/agg23/README.pdfium @@ -14,7 +14,7 @@ Various changes to use FX_ library functions. Possibly more? 0001-gcc-warning.patch: Fix a GCC warning about both enumeral and non-enumeral type in conditional. -0002-ubsan-error-fixes.path: Fix UBSan errors for overflows. +0002-ubsan-error-fixes.patch: Fix UBSan errors for overflows. 0003-ubsan-render-line-error.patch: Fix UBSan overflow error in render_line. 0004-ubsan-sweep-scanline-error.patch: Fix UBSan left shift of negative value error in sweep_scanline. @@ -24,3 +24,11 @@ agg_array.h. sweep_scanline. 0007-unused-struct.patch: Remove unused struct point_type_flag, which has a shadow variable. +0008-namespace.patch: Wrap all AGG code in namespace pdfium. +0009-infinite-loop.patch: avoid hang in agg_math_stroke.h +0010-math.patch: includes <math.h> +0011-path-storage-move-ctor.patch: Add a move ctor for path_storage. +0012-infinite-loop.patch: Fix an infinite loop in calc_dash_start(). +0013-cxx20.patch: C++20 support. +0014-ubsan-render-line.patch: Fix some integer overflows in +outline_aa::render_line(). diff --git a/third_party/agg23/agg_array.h b/third_party/agg23/agg_array.h index 8dcb0af51..b82d95296 100644 --- a/third_party/agg23/agg_array.h +++ b/third_party/agg23/agg_array.h @@ -19,6 +19,8 @@ #include "agg_basics.h" #include "core/fxcrt/fx_memory.h" // For FXSYS_* macros. +namespace pdfium +{ namespace agg { template <class T> @@ -126,7 +128,7 @@ void pod_array<T>::resize(unsigned new_size) { if(new_size > m_size) { if(new_size > m_capacity) { - T* data = FX_Alloc(T, new_size); + T* data = FX_AllocUninit(T, new_size); memcpy(data, m_array, m_size * sizeof(T)); FX_Free(m_array); m_array = data; @@ -318,7 +320,7 @@ pod_deque<T, S>::pod_deque(const pod_deque<T, S>& v) : { unsigned i; for(i = 0; i < v.m_num_blocks; ++i) { - m_blocks[i] = FX_Alloc(T, block_size); + m_blocks[i] = FX_AllocUninit(T, block_size); memcpy(m_blocks[i], v.m_blocks[i], block_size * sizeof(T)); } } @@ -499,4 +501,5 @@ template<class T> inline void swap_elements(T& a, T& b) b = temp; } } +} // namespace pdfium #endif diff --git a/third_party/agg23/agg_basics.h b/third_party/agg23/agg_basics.h index 2a1c2af2f..84313db5b 100644 --- a/third_party/agg23/agg_basics.h +++ b/third_party/agg23/agg_basics.h @@ -41,8 +41,11 @@ #endif #define AGG_INLINE inline +#include <math.h> #include "core/fxcrt/fx_system.h" +namespace pdfium +{ namespace agg { typedef AGG_INT8 int8; @@ -213,7 +216,7 @@ inline bool is_close(unsigned c) { c &= ~path_flags_jr; return (c & ~(path_flags_cw | path_flags_ccw)) == - (path_cmd_end_poly | path_flags_close); + (unsigned{path_cmd_end_poly} | path_flags_close); } inline bool is_next_poly(unsigned c) { @@ -274,4 +277,5 @@ struct vertex_type { x(x_), y(y_), cmd(cmd_) {} }; } +} // namespace pdfium #endif diff --git a/third_party/agg23/agg_clip_liang_barsky.h b/third_party/agg23/agg_clip_liang_barsky.h index 31b35fe96..7b865fd20 100644 --- a/third_party/agg23/agg_clip_liang_barsky.h +++ b/third_party/agg23/agg_clip_liang_barsky.h @@ -21,6 +21,8 @@ #define AGG_CLIP_LIANG_BARSKY_INCLUDED #include "agg_basics.h" #include "third_party/base/numerics/safe_math.h" +namespace pdfium +{ namespace agg { template<class T> @@ -133,4 +135,5 @@ inline unsigned clip_liang_barsky(T x1, T y1, T x2, T y2, return np; } } +} // namespace pdfium #endif diff --git a/third_party/agg23/agg_color_gray.h b/third_party/agg23/agg_color_gray.h index 5db7bcaf2..c1b6eabd0 100644 --- a/third_party/agg23/agg_color_gray.h +++ b/third_party/agg23/agg_color_gray.h @@ -28,6 +28,8 @@ #ifndef AGG_COLOR_GRAY_INCLUDED #define AGG_COLOR_GRAY_INCLUDED #include "agg_basics.h" +namespace pdfium +{ namespace agg { struct gray8 { @@ -47,4 +49,5 @@ struct gray8 { v(int8u(v_)), a(int8u(a_)) {} }; } +} // namespace pdfium #endif diff --git a/third_party/agg23/agg_conv_adaptor_vcgen.h b/third_party/agg23/agg_conv_adaptor_vcgen.h index be4dc2d60..343c4e10b 100644 --- a/third_party/agg23/agg_conv_adaptor_vcgen.h +++ b/third_party/agg23/agg_conv_adaptor_vcgen.h @@ -16,6 +16,8 @@ #ifndef AGG_CONV_ADAPTOR_VCGEN_INCLUDED #define AGG_CONV_ADAPTOR_VCGEN_INCLUDED #include "agg_basics.h" +namespace pdfium +{ namespace agg { struct null_markers { @@ -135,4 +137,5 @@ unsigned conv_adaptor_vcgen<VertexSource, Generator, Markers>::vertex(float* x, return cmd; } } +} // namespace pdfium #endif diff --git a/third_party/agg23/agg_conv_dash.h b/third_party/agg23/agg_conv_dash.h index f87eccc3b..3a45d5563 100644 --- a/third_party/agg23/agg_conv_dash.h +++ b/third_party/agg23/agg_conv_dash.h @@ -22,6 +22,8 @@ #include "agg_basics.h" #include "agg_vcgen_dash.h" #include "agg_conv_adaptor_vcgen.h" +namespace pdfium +{ namespace agg { template<class VertexSource, class Markers = null_markers> @@ -58,4 +60,5 @@ private: operator = (const conv_dash<VertexSource, Markers>&); }; } +} // namespace pdfium #endif diff --git a/third_party/agg23/agg_conv_stroke.h b/third_party/agg23/agg_conv_stroke.h index 82268ddec..a65fe3e48 100644 --- a/third_party/agg23/agg_conv_stroke.h +++ b/third_party/agg23/agg_conv_stroke.h @@ -22,6 +22,8 @@ #include "agg_basics.h" #include "agg_vcgen_stroke.h" #include "agg_conv_adaptor_vcgen.h" +namespace pdfium +{ namespace agg { template<class VertexSource, class Markers = null_markers> @@ -107,4 +109,5 @@ private: operator = (const conv_stroke<VertexSource, Markers>&); }; } +} // namespace pdfium #endif diff --git a/third_party/agg23/agg_curves.cpp b/third_party/agg23/agg_curves.cpp index 41900c81f..be89752e0 100644 --- a/third_party/agg23/agg_curves.cpp +++ b/third_party/agg23/agg_curves.cpp @@ -22,6 +22,8 @@ #include "agg_curves.h" #include "agg_math.h" +namespace pdfium +{ namespace agg { const float curve_collinearity_epsilon = 1e-30f; @@ -107,3 +109,4 @@ void curve4_div::bezier(float x1, float y1, m_points.add(point_type(x4, y4)); } } +} // namespace pdfium diff --git a/third_party/agg23/agg_curves.h b/third_party/agg23/agg_curves.h index 488db4a1f..205128a2b 100644 --- a/third_party/agg23/agg_curves.h +++ b/third_party/agg23/agg_curves.h @@ -17,6 +17,8 @@ #ifndef AGG_CURVES_INCLUDED #define AGG_CURVES_INCLUDED #include "agg_array.h" +namespace pdfium +{ namespace agg { struct curve4_points { @@ -105,21 +107,6 @@ public: *y = p.y; return (m_count == 1) ? path_cmd_move_to : path_cmd_line_to; } - unsigned vertex_flag(float* x, 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(float x1, float y1, float x2, float y2, @@ -173,16 +160,9 @@ public: { return m_curve_div.vertex(x, y); } - unsigned vertex_curve_flag(float* x, 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; }; } +} // namespace pdfium #endif diff --git a/third_party/agg23/agg_math.h b/third_party/agg23/agg_math.h index 6d5e39ac3..15617b2e8 100644 --- a/third_party/agg23/agg_math.h +++ b/third_party/agg23/agg_math.h @@ -19,6 +19,8 @@ #ifndef AGG_MATH_INCLUDED #define AGG_MATH_INCLUDED #include "agg_basics.h" +namespace pdfium +{ namespace agg { const float intersection_epsilon = 1.0e-30f; @@ -60,4 +62,5 @@ AGG_INLINE bool calc_intersection(float ax, float ay, float bx, float by, return true; } } +} // namespace pdfium #endif diff --git a/third_party/agg23/agg_math_stroke.h b/third_party/agg23/agg_math_stroke.h index 82df8080c..e1d5fda76 100644 --- a/third_party/agg23/agg_math_stroke.h +++ b/third_party/agg23/agg_math_stroke.h @@ -21,6 +21,8 @@ #define AGG_STROKE_MATH_INCLUDED #include "agg_math.h" #include "agg_vertex_sequence.h" +namespace pdfium +{ namespace agg { enum line_cap_e { @@ -54,7 +56,7 @@ void stroke_calc_arc(VertexConsumer& out_vertices, float a1 = atan2(dy1, dx1); float a2 = atan2(dy2, dx2); float da = a1 - a2; - bool ccw = da > 0 && da < FX_PI; + bool ccw = da > 0 && da < FXSYS_PI; if(width < 0) { width = -width; } @@ -63,7 +65,7 @@ void stroke_calc_arc(VertexConsumer& out_vertices, if (da > 0) { if (!ccw) { if (a1 > a2) { - a2 += 2 * FX_PI; + a2 += 2 * FXSYS_PI; } a2 -= da / 4; a1 += da; @@ -74,7 +76,7 @@ void stroke_calc_arc(VertexConsumer& out_vertices, } } else { if (a1 < a2) { - a2 -= 2 * FX_PI; + a2 -= 2 * FXSYS_PI; } a2 += da / 4; a1 -= da; @@ -169,8 +171,11 @@ void stroke_calc_cap(VertexConsumer& out_vertices, out_vertices.add(coord_type(v0.x + dx1 - dx2, v0.y - dy1 - dy2)); } else { float a1 = atan2(dy1, -dx1); - float a2 = a1 + FX_PI; + float a2 = a1 + FXSYS_PI; float da = acos(width / (width + ((1.0f / 8) / approximation_scale))) * 2; + if (da < stroke_theta) { + da = stroke_theta; + } out_vertices.add(coord_type(v0.x - dx1, v0.y + dy1)); a1 += da; a2 -= da / 4; @@ -178,8 +183,8 @@ void stroke_calc_cap(VertexConsumer& out_vertices, out_vertices.add( coord_type(v0.x + (width * cos(a1)), v0.y + (width * sin(a1)))); a1 += da; - } - out_vertices.add(coord_type(v0.x + dx1, v0.y - dy1)); + } + out_vertices.add(coord_type(v0.x + dx1, v0.y - dy1)); } } template<class VertexConsumer> @@ -270,4 +275,5 @@ void stroke_calc_join(VertexConsumer& out_vertices, } } } +} // namespace pdfium #endif diff --git a/third_party/agg23/agg_path_storage.cpp b/third_party/agg23/agg_path_storage.cpp index 063ece542..2981e9c0c 100644 --- a/third_party/agg23/agg_path_storage.cpp +++ b/third_party/agg23/agg_path_storage.cpp @@ -28,6 +28,8 @@ #include "agg_math.h" #include "core/fxcrt/fx_memory.h" +namespace pdfium +{ namespace agg { path_storage::~path_storage() @@ -41,14 +43,20 @@ path_storage::~path_storage() FX_Free(m_coord_blocks); } } -path_storage::path_storage() : - m_total_vertices(0), - m_total_blocks(0), - m_max_blocks(0), - m_coord_blocks(0), - m_cmd_blocks(0), - m_iterator(0) -{ +path_storage::path_storage() = default; +path_storage::path_storage(path_storage&& other) { + m_total_vertices = other.m_total_vertices; + m_total_blocks = other.m_total_blocks; + m_max_blocks = other.m_max_blocks; + m_coord_blocks = other.m_coord_blocks; + m_cmd_blocks = other.m_cmd_blocks; + m_iterator = other.m_iterator; + other.m_total_vertices = 0; + other.m_total_blocks = 0; + other.m_max_blocks = 0; + other.m_coord_blocks = nullptr; + other.m_cmd_blocks = nullptr; + other.m_iterator = 0; } void path_storage::allocate_block(unsigned nb) { @@ -90,8 +98,9 @@ void path_storage::end_poly() { if(m_total_vertices) { if(is_vertex(command(m_total_vertices - 1))) { - add_vertex(0, 0, path_cmd_end_poly | path_flags_close); + add_vertex(0, 0, unsigned{path_cmd_end_poly} | path_flags_close); } } } } +} // namespace pdfium diff --git a/third_party/agg23/agg_path_storage.h b/third_party/agg23/agg_path_storage.h index 17e82d73e..82148061a 100644 --- a/third_party/agg23/agg_path_storage.h +++ b/third_party/agg23/agg_path_storage.h @@ -16,6 +16,8 @@ #ifndef AGG_PATH_STORAGE_INCLUDED #define AGG_PATH_STORAGE_INCLUDED #include "agg_basics.h" +namespace pdfium +{ namespace agg { class path_storage @@ -48,6 +50,10 @@ public: }; ~path_storage(); path_storage(); + path_storage(path_storage&& other); + path_storage& operator=(path_storage&&) = delete; + path_storage(const path_storage&) = delete; + path_storage& operator=(const path_storage&) = delete; unsigned last_vertex(float* x, float* y) const; unsigned prev_vertex(float* x, float* y) const; void move_to(float x, float y); @@ -70,22 +76,6 @@ public: add_vertex(x, y, cmd); } } - template<class VertexSource> - void add_path_curve(VertexSource& vs, - unsigned path_id = 0, - bool solid_path = true) - { - float x, y; - unsigned cmd; - int flag; - vs.rewind(path_id); - while(!is_stop(cmd = vs.vertex_curve_flag(&x, &y, flag))) { - if(is_move_to(cmd) && solid_path && m_total_vertices) { - cmd = path_cmd_line_to | flag; - } - add_vertex(x, y, cmd | flag); - } - } unsigned total_vertices() const { return m_total_vertices; @@ -114,12 +104,12 @@ private: void allocate_block(unsigned nb); unsigned char* storage_ptrs(float** xy_ptr); private: - unsigned m_total_vertices; - unsigned m_total_blocks; - unsigned m_max_blocks; - float** m_coord_blocks; - unsigned char** m_cmd_blocks; - unsigned m_iterator; + unsigned m_total_vertices = 0; + unsigned m_total_blocks = 0; + unsigned m_max_blocks = 0; + float** m_coord_blocks = nullptr; + unsigned char** m_cmd_blocks = nullptr; + unsigned m_iterator = 0; }; inline unsigned path_storage::vertex(float* x, float* y) { @@ -169,4 +159,5 @@ inline void path_storage::line_to(float x, float y) add_vertex(x, y, path_cmd_line_to); } } +} // namespace pdfium #endif diff --git a/third_party/agg23/agg_pixfmt_gray.h b/third_party/agg23/agg_pixfmt_gray.h index 5a8093547..561bb7179 100644 --- a/third_party/agg23/agg_pixfmt_gray.h +++ b/third_party/agg23/agg_pixfmt_gray.h @@ -26,6 +26,8 @@ #include "agg_basics.h" #include "agg_color_gray.h" #include "agg_rendering_buffer.h" +namespace pdfium +{ namespace agg { template<class ColorT> struct blender_gray { @@ -174,4 +176,5 @@ private: typedef blender_gray<gray8> blender_gray8; typedef pixel_formats_gray<blender_gray8, 1, 0> pixfmt_gray8; } +} // namespace pdfium #endif diff --git a/third_party/agg23/agg_rasterizer_scanline_aa.cpp b/third_party/agg23/agg_rasterizer_scanline_aa.cpp index 9254d830d..392f30223 100644 --- a/third_party/agg23/agg_rasterizer_scanline_aa.cpp +++ b/third_party/agg23/agg_rasterizer_scanline_aa.cpp @@ -49,6 +49,8 @@ #include <limits.h> #include "agg_rasterizer_scanline_aa.h" #include "third_party/base/numerics/safe_math.h" +namespace pdfium +{ namespace agg { AGG_INLINE void cell_aa::set_cover(int c, int a) @@ -124,7 +126,7 @@ void outline_aa::allocate_block() m_cells = new_cells; m_max_blocks += cell_block_pool; } - m_cells[m_num_blocks++] = FX_Alloc(cell_aa, cell_block_size); + m_cells[m_num_blocks++] = FX_AllocUninit(cell_aa, cell_block_size); } m_cur_cell_ptr = m_cells[m_cur_block++]; } @@ -225,10 +227,27 @@ AGG_INLINE void outline_aa::render_hline(int ey, int x1, int y1, int x2, int y2) void outline_aa::render_line(int x1, int y1, int x2, int y2) { enum dx_limit_e { dx_limit = 16384 << poly_base_shift }; - int dx = x2 - x1; + pdfium::base::CheckedNumeric<int> safe_dx = x2; + safe_dx -= x1; + if (!safe_dx.IsValid()) + return; + + int dx = safe_dx.ValueOrDie(); if(dx >= dx_limit || dx <= -dx_limit) { - int cx = (x1 + x2) >> 1; - int cy = (y1 + y2) >> 1; + pdfium::base::CheckedNumeric<int> safe_cx = x1; + safe_cx += x2; + safe_cx /= 2; + if (!safe_cx.IsValid()) + return; + + pdfium::base::CheckedNumeric<int> safe_cy = y1; + safe_cy += y2; + safe_cy /= 2; + if (!safe_cy.IsValid()) + return; + + int cx = safe_cx.ValueOrDie(); + int cy = safe_cy.ValueOrDie(); render_line(x1, y1, cx, cy); render_line(cx, cy, x2, y2); } @@ -515,3 +534,4 @@ bool rasterizer_scanline_aa::safe_add(int* op1, int op2) return true; } } +} // namespace pdfium diff --git a/third_party/agg23/agg_rasterizer_scanline_aa.h b/third_party/agg23/agg_rasterizer_scanline_aa.h index eade78333..dd0d00076 100644 --- a/third_party/agg23/agg_rasterizer_scanline_aa.h +++ b/third_party/agg23/agg_rasterizer_scanline_aa.h @@ -38,6 +38,8 @@ #include "core/fxcrt/fx_coordinates.h" #include "core/fxcrt/fx_memory.h" +namespace pdfium +{ namespace agg { enum poly_base_scale_e { @@ -47,7 +49,7 @@ enum poly_base_scale_e { }; inline int poly_coord(float c) { - return int(c * poly_base_size); + return int(c * float{poly_base_size}); } struct cell_aa { int x; @@ -495,4 +497,5 @@ private: int m_cur_y; }; } +} // namespace pdfium #endif diff --git a/third_party/agg23/agg_render_scanlines.h b/third_party/agg23/agg_render_scanlines.h index 0dfd6d259..03ec683eb 100644 --- a/third_party/agg23/agg_render_scanlines.h +++ b/third_party/agg23/agg_render_scanlines.h @@ -16,6 +16,8 @@ #ifndef AGG_RENDER_SCANLINES_INCLUDED #define AGG_RENDER_SCANLINES_INCLUDED #include "agg_basics.h" +namespace pdfium +{ namespace agg { template<class Rasterizer, class Scanline, class Renderer> @@ -47,4 +49,5 @@ void render_all_paths(Rasterizer& ras, } } } +} // namespace pdfium #endif diff --git a/third_party/agg23/agg_renderer_base.h b/third_party/agg23/agg_renderer_base.h index bd1b203b9..d637be262 100644 --- a/third_party/agg23/agg_renderer_base.h +++ b/third_party/agg23/agg_renderer_base.h @@ -21,6 +21,8 @@ #define AGG_RENDERER_BASE_INCLUDED #include "agg_basics.h" #include "agg_rendering_buffer.h" +namespace pdfium +{ namespace agg { template<class PixelFormat> class renderer_base @@ -160,4 +162,5 @@ private: rect m_clip_box; }; } +} // namespace pdfium #endif diff --git a/third_party/agg23/agg_renderer_scanline.h b/third_party/agg23/agg_renderer_scanline.h index 62d104f7f..32db738d3 100644 --- a/third_party/agg23/agg_renderer_scanline.h +++ b/third_party/agg23/agg_renderer_scanline.h @@ -18,6 +18,8 @@ #include "agg_basics.h" #include "agg_renderer_base.h" #include "agg_render_scanlines.h" +namespace pdfium +{ namespace agg { template<class BaseRenderer, class SpanGenerator> class renderer_scanline_aa @@ -90,4 +92,5 @@ private: SpanGenerator* m_span_gen; }; } +} // namespace pdfium #endif diff --git a/third_party/agg23/agg_rendering_buffer.h b/third_party/agg23/agg_rendering_buffer.h index 9c1c0c689..4c80160b7 100644 --- a/third_party/agg23/agg_rendering_buffer.h +++ b/third_party/agg23/agg_rendering_buffer.h @@ -20,6 +20,8 @@ #ifndef AGG_RENDERING_BUFFER_INCLUDED #define AGG_RENDERING_BUFFER_INCLUDED #include "agg_basics.h" +namespace pdfium +{ namespace agg { class rendering_buffer @@ -142,4 +144,5 @@ private: unsigned m_max_height; }; } +} // namespace pdfium #endif diff --git a/third_party/agg23/agg_scanline_u.h b/third_party/agg23/agg_scanline_u.h index 844dc9aad..1db31c3e3 100644 --- a/third_party/agg23/agg_scanline_u.h +++ b/third_party/agg23/agg_scanline_u.h @@ -24,6 +24,8 @@ #ifndef AGG_SCANLINE_U_INCLUDED #define AGG_SCANLINE_U_INCLUDED #include "agg_array.h" +namespace pdfium +{ namespace agg { template<class CoverT> class scanline_u @@ -147,4 +149,5 @@ private: }; typedef scanline_u<int8u> scanline_u8; } +} // namespace pdfium #endif diff --git a/third_party/agg23/agg_shorten_path.h b/third_party/agg23/agg_shorten_path.h index 2f62ec52d..280d1688e 100644 --- a/third_party/agg23/agg_shorten_path.h +++ b/third_party/agg23/agg_shorten_path.h @@ -17,6 +17,8 @@ #define AGG_SHORTEN_PATH_INCLUDED #include "agg_basics.h" #include "agg_vertex_sequence.h" +namespace pdfium +{ namespace agg { template<class VertexSequence> @@ -54,4 +56,5 @@ void shorten_path(VertexSequence& vs, float s, unsigned closed = 0) } } } +} // namespace pdfium #endif diff --git a/third_party/agg23/agg_vcgen_dash.cpp b/third_party/agg23/agg_vcgen_dash.cpp index fdbd2aa7f..d44fca178 100644 --- a/third_party/agg23/agg_vcgen_dash.cpp +++ b/third_party/agg23/agg_vcgen_dash.cpp @@ -18,9 +18,14 @@ // //---------------------------------------------------------------------------- +#include <cmath> + #include "agg_shorten_path.h" #include "agg_vcgen_dash.h" +#include "third_party/base/check_op.h" +namespace pdfium +{ namespace agg { vcgen_dash::vcgen_dash() : @@ -58,6 +63,8 @@ void vcgen_dash::dash_start(float ds) } void vcgen_dash::calc_dash_start(float ds) { + DCHECK_GT(m_total_dash_len, 0); + ds -= floor(ds / m_total_dash_len) * m_total_dash_len; m_curr_dash = 0; m_curr_dash_start = 0; while(ds > 0) { @@ -175,3 +182,4 @@ unsigned vcgen_dash::vertex(float* x, float* y) return path_cmd_stop; } } +} // namespace pdfium diff --git a/third_party/agg23/agg_vcgen_dash.h b/third_party/agg23/agg_vcgen_dash.h index 7702fa7ad..2a4c94eab 100644 --- a/third_party/agg23/agg_vcgen_dash.h +++ b/third_party/agg23/agg_vcgen_dash.h @@ -21,6 +21,8 @@ #define AGG_VCGEN_DASH_INCLUDED #include "agg_basics.h" #include "agg_vertex_sequence.h" +namespace pdfium +{ namespace agg { class vcgen_dash @@ -72,4 +74,5 @@ private: unsigned m_src_vertex; }; } +} // namespace pdfium #endif diff --git a/third_party/agg23/agg_vcgen_stroke.cpp b/third_party/agg23/agg_vcgen_stroke.cpp index 3e97a3147..b0f8a50e2 100644 --- a/third_party/agg23/agg_vcgen_stroke.cpp +++ b/third_party/agg23/agg_vcgen_stroke.cpp @@ -25,6 +25,8 @@ #include "agg_vcgen_stroke.h" +namespace pdfium +{ namespace agg { @@ -200,10 +202,10 @@ unsigned vcgen_stroke::vertex(float* x, float* y) break; case end_poly1: m_status = m_prev_status; - return path_cmd_end_poly | path_flags_close | path_flags_ccw; + return unsigned{path_cmd_end_poly} | path_flags_close | path_flags_ccw; case end_poly2: m_status = m_prev_status; - return path_cmd_end_poly | path_flags_close | path_flags_cw; + return unsigned{path_cmd_end_poly} | path_flags_close | path_flags_cw; case stop: cmd = path_cmd_stop; break; @@ -212,3 +214,4 @@ unsigned vcgen_stroke::vertex(float* x, float* y) return cmd; } } +} // namespace pdfium diff --git a/third_party/agg23/agg_vcgen_stroke.h b/third_party/agg23/agg_vcgen_stroke.h index 23142d37f..ed9bb416f 100644 --- a/third_party/agg23/agg_vcgen_stroke.h +++ b/third_party/agg23/agg_vcgen_stroke.h @@ -16,6 +16,8 @@ #ifndef AGG_VCGEN_STROKE_INCLUDED #define AGG_VCGEN_STROKE_INCLUDED #include "agg_math_stroke.h" +namespace pdfium +{ namespace agg { class vcgen_stroke @@ -117,4 +119,5 @@ private: unsigned m_out_vertex; }; } +} // namespace pdfium #endif diff --git a/third_party/agg23/agg_vertex_sequence.h b/third_party/agg23/agg_vertex_sequence.h index 80eabbb95..dc729d55c 100644 --- a/third_party/agg23/agg_vertex_sequence.h +++ b/third_party/agg23/agg_vertex_sequence.h @@ -22,6 +22,8 @@ #include "agg_basics.h" #include "agg_array.h" #include "agg_math.h" +namespace pdfium +{ namespace agg { template<class T, unsigned S = 6> @@ -97,4 +99,5 @@ struct vertex_dist_cmd : public vertex_dist { } }; } +} // namespace pdfium #endif |