Wrap AGG code in namespace pdfium.
This helps make PDFium's copy of AGG unique, so embedders can avoid
conflicts when linking PDFium together with another library that comes
with a different copy of AGG.
To make this compile, wrap CFX_AggDeviceDriver in namespace pdfium as
well. Also fix some nits in fx_agg_driver.cpp along the way.
Bug: pdfium:1595
Change-Id: I6c34f28e6c07d09aef55722c430e0647826fd81d
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/74374
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp
index 20d72b5..6f87e92 100644
--- a/core/fxge/agg/fx_agg_driver.cpp
+++ b/core/fxge/agg/fx_agg_driver.cpp
@@ -38,6 +38,7 @@
#pragma GCC diagnostic pop
#endif
+namespace pdfium {
namespace {
const float kMaxPos = 32000.0f;
@@ -251,8 +252,8 @@
}
width = std::max(width, unit);
if (!pGraphState->m_DashArray.empty()) {
- typedef agg::conv_dash<agg::path_storage> dash_converter;
- dash_converter dash(*path_data);
+ using DashConverter = agg::conv_dash<agg::path_storage>;
+ DashConverter dash(*path_data);
for (size_t i = 0; i < (pGraphState->m_DashArray.size() + 1) / 2; i++) {
float on = pGraphState->m_DashArray[i * 2];
if (on <= 0.000001f)
@@ -264,8 +265,8 @@
dash.add_dash(on * scale, off * scale);
}
dash.dash_start(pGraphState->m_DashPhase * scale);
- typedef agg::conv_stroke<dash_converter> dash_stroke;
- dash_stroke stroke(dash);
+ using DashStroke = agg::conv_stroke<DashConverter>;
+ DashStroke stroke(dash);
stroke.line_join(join);
stroke.line_cap(cap);
stroke.miter_limit(pGraphState->m_MiterLimit);
@@ -997,16 +998,12 @@
}
}
-} // namespace
-
-namespace agg {
-
template <class BaseRenderer>
-class renderer_scanline_aa_offset {
+class RendererScanLineAaOffset {
public:
typedef BaseRenderer base_ren_type;
typedef typename base_ren_type::color_type color_type;
- renderer_scanline_aa_offset(base_ren_type& ren, unsigned left, unsigned top)
+ RendererScanLineAaOffset(base_ren_type& ren, unsigned left, unsigned top)
: m_ren(&ren), m_left(left), m_top(top) {}
void color(const color_type& c) { m_color = c; }
const color_type& color() const { return m_color; }
@@ -1035,10 +1032,11 @@
private:
base_ren_type* m_ren;
color_type m_color;
- unsigned m_left, m_top;
+ unsigned m_left;
+ unsigned m_top;
};
-} // namespace agg
+} // namespace
void CAgg_PathData::BuildPath(const CFX_PathData* pPathData,
const CFX_Matrix* pObject2Device) {
@@ -1191,8 +1189,8 @@
pThisLayer->GetPitch());
agg::pixfmt_gray8 pixel_buf(raw_buf);
agg::renderer_base<agg::pixfmt_gray8> base_buf(pixel_buf);
- agg::renderer_scanline_aa_offset<agg::renderer_base<agg::pixfmt_gray8> >
- final_render(base_buf, path_rect.left, path_rect.top);
+ RendererScanLineAaOffset<agg::renderer_base<agg::pixfmt_gray8>> final_render(
+ base_buf, path_rect.left, path_rect.top);
final_render.color(agg::gray8(255));
agg::scanline_u8 scanline;
agg::render_scanlines(rasterizer, scanline, final_render,
@@ -1506,6 +1504,8 @@
return !m_pBitmap->GetBuffer() || pHandle->Continue(pPause);
}
+} // namespace pdfium
+
#if !defined(_SKIA_SUPPORT_)
CFX_DefaultRenderDevice::CFX_DefaultRenderDevice() {}
@@ -1520,7 +1520,7 @@
return false;
SetBitmap(pBitmap);
- SetDeviceDriver(std::make_unique<CFX_AggDeviceDriver>(
+ SetDeviceDriver(std::make_unique<pdfium::CFX_AggDeviceDriver>(
pBitmap, bRgbByteOrder, pBackdropBitmap, bGroupKnockout));
return true;
}
@@ -1535,7 +1535,7 @@
return false;
SetBitmap(pBitmap);
- SetDeviceDriver(std::make_unique<CFX_AggDeviceDriver>(
+ SetDeviceDriver(std::make_unique<pdfium::CFX_AggDeviceDriver>(
pBitmap, false, pBackdropBitmap, false));
return true;
}
diff --git a/core/fxge/agg/fx_agg_driver.h b/core/fxge/agg/fx_agg_driver.h
index 35acf0c..5806aef 100644
--- a/core/fxge/agg/fx_agg_driver.h
+++ b/core/fxge/agg/fx_agg_driver.h
@@ -22,6 +22,8 @@
class CFX_Matrix;
class CFX_PathData;
+namespace pdfium {
+
class CAgg_PathData {
public:
CAgg_PathData() {}
@@ -29,7 +31,7 @@
void BuildPath(const CFX_PathData* pPathData,
const CFX_Matrix* pObject2Device);
- agg::path_storage m_PathData;
+ pdfium::agg::path_storage m_PathData;
};
class CFX_AggDeviceDriver final : public RenderDeviceDriverIface {
@@ -102,12 +104,12 @@
const CFX_TextRenderOptions& options) override;
int GetDriverType() const override;
- bool RenderRasterizer(agg::rasterizer_scanline_aa& rasterizer,
+ bool RenderRasterizer(pdfium::agg::rasterizer_scanline_aa& rasterizer,
uint32_t color,
bool bFullCover,
bool bGroupKnockout);
- void SetClipMask(agg::rasterizer_scanline_aa& rasterizer);
+ void SetClipMask(pdfium::agg::rasterizer_scanline_aa& rasterizer);
virtual uint8_t* GetBuffer() const;
@@ -124,4 +126,6 @@
RetainPtr<CFX_DIBitmap> m_pBackdropBitmap;
};
+} // namespace pdfium
+
#endif // CORE_FXGE_AGG_FX_AGG_DRIVER_H_
diff --git a/core/fxge/apple/fx_apple_platform.cpp b/core/fxge/apple/fx_apple_platform.cpp
index 309afb4..93d5bdf 100644
--- a/core/fxge/apple/fx_apple_platform.cpp
+++ b/core/fxge/apple/fx_apple_platform.cpp
@@ -85,6 +85,8 @@
} // namespace
+namespace pdfium {
+
void CFX_AggDeviceDriver::InitPlatform() {
CQuartz2D& quartz2d =
static_cast<CApplePlatform*>(CFX_GEModule::Get()->GetPlatform())
@@ -163,6 +165,8 @@
return ret;
}
+} // namespace pdfium
+
#endif // !defined(_SKIA_SUPPORT_)
void CFX_GlyphCache::InitPlatform() {}
diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp
index 6d3ddee..e362832 100644
--- a/core/fxge/win32/fx_win32_device.cpp
+++ b/core/fxge/win32/fx_win32_device.cpp
@@ -939,9 +939,9 @@
rect_base rect = {0.0f, 0.0f, (float)(m_Width), (float)(m_Height)};
np = clip_liang_barsky(x1, y1, x2, y2, rect, x, y);
#else
- agg::rect_base<float> rect(0.0f, 0.0f, (float)(m_Width),
- (float)(m_Height));
- np = agg::clip_liang_barsky<float>(x1, y1, x2, y2, rect, x, y);
+ pdfium::agg::rect_base<float> rect(0.0f, 0.0f, (float)(m_Width),
+ (float)(m_Height));
+ np = pdfium::agg::clip_liang_barsky<float>(x1, y1, x2, y2, rect, x, y);
#endif
if (np == 0)
return;
diff --git a/third_party/agg23/0008-namespace.patch b/third_party/agg23/0008-namespace.patch
new file mode 100644
index 0000000..d2566fe
--- /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/README.pdfium b/third_party/agg23/README.pdfium
index 0319903..55319e7 100644
--- a/third_party/agg23/README.pdfium
+++ b/third_party/agg23/README.pdfium
@@ -24,3 +24,4 @@
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.
diff --git a/third_party/agg23/agg_array.h b/third_party/agg23/agg_array.h
index fba41a7..b82d952 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 @@
b = temp;
}
}
+} // namespace pdfium
#endif
diff --git a/third_party/agg23/agg_basics.h b/third_party/agg23/agg_basics.h
index 2a1c2af..eb6f356 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 @@
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 31b35fe..7b865fd 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 @@
return np;
}
}
+} // namespace pdfium
#endif
diff --git a/third_party/agg23/agg_color_gray.h b/third_party/agg23/agg_color_gray.h
index 5db7bca..c1b6eab 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 @@
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 be4dc2d..343c4e1 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 @@
return cmd;
}
}
+} // namespace pdfium
#endif
diff --git a/third_party/agg23/agg_conv_dash.h b/third_party/agg23/agg_conv_dash.h
index f87eccc..3a45d55 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 @@
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 82268dd..a65fe3e 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 @@
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 41900c8..be89752 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 @@
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 488db4a..908bd9a 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 @@
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 6d5e39a..15617b2 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 @@
return true;
}
}
+} // namespace pdfium
#endif
diff --git a/third_party/agg23/agg_math_stroke.h b/third_party/agg23/agg_math_stroke.h
index 82df808..8515d2b 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 @@
}
}
}
+} // namespace pdfium
#endif
diff --git a/third_party/agg23/agg_path_storage.cpp b/third_party/agg23/agg_path_storage.cpp
index 063ece5..2cd0cae 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 @@
}
}
}
+} // namespace pdfium
diff --git a/third_party/agg23/agg_path_storage.h b/third_party/agg23/agg_path_storage.h
index 17e82d7..55d6df0 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 @@
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 5a80935..561bb71 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 @@
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 7850225..d2b6a46 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 @@
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 eade783..133d66c 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 @@
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 0dfd6d2..03ec683 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 @@
}
}
}
+} // namespace pdfium
#endif
diff --git a/third_party/agg23/agg_renderer_base.h b/third_party/agg23/agg_renderer_base.h
index bd1b203..d637be2 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 @@
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 62d104f..32db738 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 @@
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 9c1c0c6..4c80160 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 @@
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 844dc9a..1db31c3 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 @@
};
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 2f62ec5..280d168 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 @@
}
}
}
+} // namespace pdfium
#endif
diff --git a/third_party/agg23/agg_vcgen_dash.cpp b/third_party/agg23/agg_vcgen_dash.cpp
index fdbd2aa..f690760 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 @@
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 7702fa7..2a4c94e 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 @@
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 3e97a31..f65eac5 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 @@
return cmd;
}
}
+} // namespace pdfium
diff --git a/third_party/agg23/agg_vcgen_stroke.h b/third_party/agg23/agg_vcgen_stroke.h
index 23142d3..ed9bb41 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 @@
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 80eabbb..dc729d5 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 @@
}
};
}
+} // namespace pdfium
#endif