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
