From 2cae3e26526a8aeef5744665589d1bfaf5efe6f3 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 26 Oct 2018 20:25:18 +0000 Subject: Forward declare a bunch of classes. Then do IWYU to fix up build errors. Move some implementations out of headers to allow more forward declarations. Change-Id: Idbeb978705a21cd6fb710ca9f5e99b4ea7d93ec5 Reviewed-on: https://pdfium-review.googlesource.com/c/44632 Reviewed-by: Tom Sepez Commit-Queue: Lei Zhang --- core/fxge/BUILD.gn | 1 + core/fxge/agg/fx_agg_driver.cpp | 1 + core/fxge/apple/apple_int.h | 1 - core/fxge/apple/fx_apple_platform.cpp | 9 +++++---- core/fxge/cfx_color.h | 4 +++- core/fxge/cfx_facecache.cpp | 1 + core/fxge/cfx_renderdevice.cpp | 1 + core/fxge/cfx_renderdevice.h | 16 ++++++++-------- core/fxge/cfx_unicodeencodingex.h | 1 - core/fxge/dib/cfx_bitmapstorer.cpp | 1 + core/fxge/dib/cfx_bitmapstorer.h | 3 ++- core/fxge/dib/cfx_dibextractor.cpp | 1 + core/fxge/dib/cfx_dibextractor.h | 2 +- core/fxge/dib/cfx_imagerenderer.cpp | 1 + core/fxge/dib/cfx_imagerenderer.h | 6 +++--- core/fxge/dib/cfx_imagestretcher.cpp | 4 ++++ core/fxge/dib/cfx_imagestretcher.h | 3 ++- core/fxge/dib/cfx_imagetransformer.cpp | 1 + core/fxge/dib/cfx_imagetransformer.h | 5 +++-- core/fxge/dib/cfx_scanlinecompositor.h | 1 - core/fxge/dib/cstretchengine.h | 1 + core/fxge/fx_dib.h | 4 ---- core/fxge/fx_font.cpp | 13 +++++++++++++ core/fxge/fx_font.h | 22 +++++++++------------- core/fxge/fx_ge_text.cpp | 1 + core/fxge/skia/fx_skia_device.cpp | 1 + core/fxge/skia/fx_skia_device.h | 1 + core/fxge/win32/cfx_psrenderer.cpp | 1 + core/fxge/win32/fx_win32_print.cpp | 1 + 29 files changed, 67 insertions(+), 41 deletions(-) create mode 100644 core/fxge/fx_font.cpp (limited to 'core/fxge') diff --git a/core/fxge/BUILD.gn b/core/fxge/BUILD.gn index 6475dc35d5..1f2680954d 100644 --- a/core/fxge/BUILD.gn +++ b/core/fxge/BUILD.gn @@ -105,6 +105,7 @@ jumbo_source_set("fxge") { "fontdata/chromefontdata/chromefontdata.h", "freetype/fx_freetype.cpp", "fx_dib.h", + "fx_font.cpp", "fx_font.h", "fx_freetype.h", "fx_ge_fontmap.cpp", diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp index 55710763e5..10293d865c 100644 --- a/core/fxge/agg/fx_agg_driver.cpp +++ b/core/fxge/agg/fx_agg_driver.cpp @@ -13,6 +13,7 @@ #include "core/fxge/cfx_defaultrenderdevice.h" #include "core/fxge/cfx_graphstatedata.h" #include "core/fxge/cfx_pathdata.h" +#include "core/fxge/dib/cfx_dibitmap.h" #include "core/fxge/dib/cfx_imagerenderer.h" #include "core/fxge/dib/cfx_imagestretcher.h" #include "third_party/base/ptr_util.h" diff --git a/core/fxge/apple/apple_int.h b/core/fxge/apple/apple_int.h index a53b91b00b..e91b1e1b81 100644 --- a/core/fxge/apple/apple_int.h +++ b/core/fxge/apple/apple_int.h @@ -13,7 +13,6 @@ #include "core/fxge/cfx_graphstatedata.h" #include "core/fxge/cfx_pathdata.h" -#include "core/fxge/cfx_renderdevice.h" #include "core/fxge/fx_dib.h" #include "core/fxge/renderdevicedriver_iface.h" diff --git a/core/fxge/apple/fx_apple_platform.cpp b/core/fxge/apple/fx_apple_platform.cpp index aad97ee4cb..a56f2a910c 100644 --- a/core/fxge/apple/fx_apple_platform.cpp +++ b/core/fxge/apple/fx_apple_platform.cpp @@ -9,19 +9,20 @@ #include "core/fxcrt/fx_system.h" -#ifndef _SKIA_SUPPORT_ -#include "core/fxge/agg/fx_agg_driver.h" -#endif - #include "core/fxge/apple/apple_int.h" #include "core/fxge/cfx_cliprgn.h" #include "core/fxge/cfx_facecache.h" #include "core/fxge/cfx_font.h" #include "core/fxge/cfx_gemodule.h" #include "core/fxge/cfx_renderdevice.h" +#include "core/fxge/dib/cfx_dibitmap.h" #include "core/fxge/fx_freetype.h" #include "third_party/base/span.h" +#ifndef _SKIA_SUPPORT_ +#include "core/fxge/agg/fx_agg_driver.h" +#endif + #ifndef _SKIA_SUPPORT_ namespace { diff --git a/core/fxge/cfx_color.h b/core/fxge/cfx_color.h index 1dd512a42d..251962a0d5 100644 --- a/core/fxge/cfx_color.h +++ b/core/fxge/cfx_color.h @@ -7,9 +7,11 @@ #ifndef CORE_FXGE_CFX_COLOR_H_ #define CORE_FXGE_CFX_COLOR_H_ -#include "core/fpdfapi/parser/cpdf_array.h" +#include "core/fxcrt/fx_string.h" #include "core/fxge/fx_dib.h" +class CPDF_Array; + struct CFX_Color { static CFX_Color ParseColor(const CPDF_Array& array); static CFX_Color ParseColor(const ByteString& str); diff --git a/core/fxge/cfx_facecache.cpp b/core/fxge/cfx_facecache.cpp index 08d95a0cb8..9829755b69 100644 --- a/core/fxge/cfx_facecache.cpp +++ b/core/fxge/cfx_facecache.cpp @@ -17,6 +17,7 @@ #include "core/fxge/cfx_gemodule.h" #include "core/fxge/cfx_pathdata.h" #include "core/fxge/cfx_substfont.h" +#include "core/fxge/dib/cfx_dibitmap.h" #include "core/fxge/fx_freetype.h" #include "third_party/base/numerics/safe_math.h" #include "third_party/base/ptr_util.h" diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp index 4b082a3349..90e80be28e 100644 --- a/core/fxge/cfx_renderdevice.cpp +++ b/core/fxge/cfx_renderdevice.cpp @@ -18,6 +18,7 @@ #include "core/fxge/cfx_gemodule.h" #include "core/fxge/cfx_graphstatedata.h" #include "core/fxge/cfx_pathdata.h" +#include "core/fxge/dib/cfx_dibitmap.h" #include "core/fxge/dib/cfx_imagerenderer.h" #include "core/fxge/renderdevicedriver_iface.h" diff --git a/core/fxge/cfx_renderdevice.h b/core/fxge/cfx_renderdevice.h index 18ce7a8608..5eede11636 100644 --- a/core/fxge/cfx_renderdevice.h +++ b/core/fxge/cfx_renderdevice.h @@ -12,16 +12,8 @@ #include "core/fpdfdoc/cpdf_defaultappearance.h" #include "core/fxcrt/unowned_ptr.h" -#include "core/fxge/cfx_color.h" #include "core/fxge/fx_dib.h" -class CFX_DIBitmap; -class CFX_Font; -class CFX_GraphStateData; -class CFX_ImageRenderer; -class PauseIndicatorIface; -class RenderDeviceDriverIface; - #define FXDC_DEVICE_CLASS 1 #define FXDC_PIXEL_WIDTH 2 #define FXDC_PIXEL_HEIGHT 3 @@ -64,7 +56,15 @@ class RenderDeviceDriverIface; #define FXTEXT_PRINTIMAGETEXT 0x10 #define FXTEXT_NOSMOOTH 0x20 +class CFX_DIBBase; +class CFX_DIBitmap; +class CFX_Font; +class CFX_GraphStateData; +class CFX_ImageRenderer; class CFX_PathData; +class PauseIndicatorIface; +class RenderDeviceDriverIface; +struct CFX_Color; enum class FXPT_TYPE : uint8_t { LineTo, BezierTo, MoveTo }; diff --git a/core/fxge/cfx_unicodeencodingex.h b/core/fxge/cfx_unicodeencodingex.h index 9d5ec18fa6..ab624b9a27 100644 --- a/core/fxge/cfx_unicodeencodingex.h +++ b/core/fxge/cfx_unicodeencodingex.h @@ -11,7 +11,6 @@ #include "core/fxcrt/fx_system.h" #include "core/fxge/cfx_unicodeencoding.h" -#include "core/fxge/fx_dib.h" class CFX_UnicodeEncodingEx final : public CFX_UnicodeEncoding { public: diff --git a/core/fxge/dib/cfx_bitmapstorer.cpp b/core/fxge/dib/cfx_bitmapstorer.cpp index 2d85a2ed7b..97ddf6f0b3 100644 --- a/core/fxge/dib/cfx_bitmapstorer.cpp +++ b/core/fxge/dib/cfx_bitmapstorer.cpp @@ -8,6 +8,7 @@ #include +#include "core/fxge/dib/cfx_dibitmap.h" CFX_BitmapStorer::CFX_BitmapStorer() {} diff --git a/core/fxge/dib/cfx_bitmapstorer.h b/core/fxge/dib/cfx_bitmapstorer.h index 86f7f8719f..c8158a3d9a 100644 --- a/core/fxge/dib/cfx_bitmapstorer.h +++ b/core/fxge/dib/cfx_bitmapstorer.h @@ -9,9 +9,10 @@ #include "core/fxcrt/fx_coordinates.h" #include "core/fxcrt/retain_ptr.h" -#include "core/fxge/dib/cfx_dibitmap.h" #include "core/fxge/dib/scanlinecomposer_iface.h" +class CFX_DIBitmap; + class CFX_BitmapStorer final : public ScanlineComposerIface { public: CFX_BitmapStorer(); diff --git a/core/fxge/dib/cfx_dibextractor.cpp b/core/fxge/dib/cfx_dibextractor.cpp index 8211dc725a..f6f31e8f73 100644 --- a/core/fxge/dib/cfx_dibextractor.cpp +++ b/core/fxge/dib/cfx_dibextractor.cpp @@ -7,6 +7,7 @@ #include "core/fxge/dib/cfx_dibextractor.h" #include "core/fxge/dib/cfx_dibbase.h" +#include "core/fxge/dib/cfx_dibitmap.h" CFX_DIBExtractor::CFX_DIBExtractor(const RetainPtr& pSrc) { if (!pSrc->GetBuffer()) { diff --git a/core/fxge/dib/cfx_dibextractor.h b/core/fxge/dib/cfx_dibextractor.h index cd97f20aac..eff96b1217 100644 --- a/core/fxge/dib/cfx_dibextractor.h +++ b/core/fxge/dib/cfx_dibextractor.h @@ -8,9 +8,9 @@ #define CORE_FXGE_DIB_CFX_DIBEXTRACTOR_H_ #include "core/fxcrt/retain_ptr.h" -#include "core/fxge/dib/cfx_dibitmap.h" class CFX_DIBBase; +class CFX_DIBitmap; class CFX_DIBExtractor { public: diff --git a/core/fxge/dib/cfx_imagerenderer.cpp b/core/fxge/dib/cfx_imagerenderer.cpp index 9641bc0ad0..6eadb05997 100644 --- a/core/fxge/dib/cfx_imagerenderer.cpp +++ b/core/fxge/dib/cfx_imagerenderer.cpp @@ -9,6 +9,7 @@ #include #include "core/fxge/cfx_cliprgn.h" +#include "core/fxge/dib/cfx_dibitmap.h" #include "core/fxge/dib/cfx_imagestretcher.h" #include "core/fxge/dib/cfx_imagetransformer.h" #include "third_party/base/ptr_util.h" diff --git a/core/fxge/dib/cfx_imagerenderer.h b/core/fxge/dib/cfx_imagerenderer.h index 2a16d2d18b..01eec3a947 100644 --- a/core/fxge/dib/cfx_imagerenderer.h +++ b/core/fxge/dib/cfx_imagerenderer.h @@ -13,12 +13,12 @@ #include "core/fxcrt/retain_ptr.h" #include "core/fxcrt/unowned_ptr.h" #include "core/fxge/dib/cfx_bitmapcomposer.h" -#include "core/fxge/dib/cfx_dibbase.h" -#include "core/fxge/dib/cfx_dibitmap.h" -#include "core/fxge/fx_dib.h" +class CFX_DIBBase; +class CFX_DIBitmap; class CFX_ImageTransformer; class CFX_ImageStretcher; +class PauseIndicatorIface; class CFX_ImageRenderer { public: diff --git a/core/fxge/dib/cfx_imagestretcher.cpp b/core/fxge/dib/cfx_imagestretcher.cpp index 53c47c996e..763c1db5d2 100644 --- a/core/fxge/dib/cfx_imagestretcher.cpp +++ b/core/fxge/dib/cfx_imagestretcher.cpp @@ -131,6 +131,10 @@ bool CFX_ImageStretcher::Continue(PauseIndicatorIface* pPause) { return ContinueStretch(pPause); } +RetainPtr CFX_ImageStretcher::source() { + return m_pSource; +} + bool CFX_ImageStretcher::StartStretch() { m_pStretchEngine = pdfium::MakeUnique( m_pDest.Get(), m_DestFormat, m_DestWidth, m_DestHeight, m_ClipRect, diff --git a/core/fxge/dib/cfx_imagestretcher.h b/core/fxge/dib/cfx_imagestretcher.h index 8e866620fd..9f4e44b0d0 100644 --- a/core/fxge/dib/cfx_imagestretcher.h +++ b/core/fxge/dib/cfx_imagestretcher.h @@ -17,6 +17,7 @@ #include "core/fxge/fx_dib.h" class CFX_DIBBase; +class CStretchEngine; class PauseIndicatorIface; class CFX_ImageStretcher { @@ -32,7 +33,7 @@ class CFX_ImageStretcher { bool Start(); bool Continue(PauseIndicatorIface* pPause); - RetainPtr source() { return m_pSource; } + RetainPtr source(); private: bool StartQuickStretch(); diff --git a/core/fxge/dib/cfx_imagetransformer.cpp b/core/fxge/dib/cfx_imagetransformer.cpp index 96249750ee..29d22f4f77 100644 --- a/core/fxge/dib/cfx_imagetransformer.cpp +++ b/core/fxge/dib/cfx_imagetransformer.cpp @@ -10,6 +10,7 @@ #include #include +#include "core/fxge/dib/cfx_dibitmap.h" #include "core/fxge/dib/cfx_imagestretcher.h" #include "core/fxge/fx_dib.h" #include "third_party/base/compiler_specific.h" diff --git a/core/fxge/dib/cfx_imagetransformer.h b/core/fxge/dib/cfx_imagetransformer.h index ecd91872c0..052df941d4 100644 --- a/core/fxge/dib/cfx_imagetransformer.h +++ b/core/fxge/dib/cfx_imagetransformer.h @@ -13,10 +13,11 @@ #include "core/fxcrt/retain_ptr.h" #include "core/fxcrt/unowned_ptr.h" #include "core/fxge/dib/cfx_bitmapstorer.h" -#include "core/fxge/dib/cfx_dibbase.h" -#include "core/fxge/dib/cfx_dibitmap.h" +class CFX_DIBBase; +class CFX_DIBitmap; class CFX_ImageStretcher; +class PauseIndicatorIface; class CFX_ImageTransformer { public: diff --git a/core/fxge/dib/cfx_scanlinecompositor.h b/core/fxge/dib/cfx_scanlinecompositor.h index fc86299032..b9625d9b12 100644 --- a/core/fxge/dib/cfx_scanlinecompositor.h +++ b/core/fxge/dib/cfx_scanlinecompositor.h @@ -9,7 +9,6 @@ #include -#include "core/fxge/dib/cfx_dibbase.h" #include "core/fxge/fx_dib.h" class CFX_ScanlineCompositor { diff --git a/core/fxge/dib/cstretchengine.h b/core/fxge/dib/cstretchengine.h index db7a2be56d..6bb07c662c 100644 --- a/core/fxge/dib/cstretchengine.h +++ b/core/fxge/dib/cstretchengine.h @@ -14,6 +14,7 @@ #include "core/fxcrt/unowned_ptr.h" #include "core/fxge/fx_dib.h" +class CFX_DIBBase; class PauseIndicatorIface; class ScanlineComposerIface; diff --git a/core/fxge/fx_dib.h b/core/fxge/fx_dib.h index 96cd82a66b..221a05278f 100644 --- a/core/fxge/fx_dib.h +++ b/core/fxge/fx_dib.h @@ -44,10 +44,6 @@ using FX_COLORREF = uint32_t; using FX_CMYK = uint32_t; -class CFX_ClipRgn; -class CFX_DIBBase; -class CStretchEngine; - extern const int16_t SDP_Table[513]; #define FXDIB_DOWNSAMPLE 0x04 diff --git a/core/fxge/fx_font.cpp b/core/fxge/fx_font.cpp new file mode 100644 index 0000000000..29c55dd0e6 --- /dev/null +++ b/core/fxge/fx_font.cpp @@ -0,0 +1,13 @@ +// Copyright 2018 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "core/fxge/fx_font.h" + +#include "core/fxge/dib/cfx_dibitmap.h" +#include "core/fxge/dib/cfx_imagestretcher.h" + +CFX_GlyphBitmap::CFX_GlyphBitmap() + : m_pBitmap(pdfium::MakeRetain()) {} + +CFX_GlyphBitmap::~CFX_GlyphBitmap() = default; diff --git a/core/fxge/fx_font.h b/core/fxge/fx_font.h index 3a68c2251b..204655ab79 100644 --- a/core/fxge/fx_font.h +++ b/core/fxge/fx_font.h @@ -9,18 +9,11 @@ #include +#include "core/fxcrt/fx_coordinates.h" #include "core/fxcrt/fx_system.h" #include "core/fxge/cfx_substfont.h" -#include "core/fxge/dib/cfx_dibitmap.h" -#include "core/fxge/fx_dib.h" #include "core/fxge/fx_freetype.h" -#if defined _SKIA_SUPPORT_ || defined _SKIA_SUPPORT_PATHS_ -class SkTypeface; - -using CFX_TypeFace = SkTypeface; -#endif - /* Font pitch and family flags */ #define FXFONT_FF_FIXEDPITCH (1 << 0) #define FXFONT_FF_ROMAN (1 << 4) @@ -51,6 +44,14 @@ using CFX_TypeFace = SkTypeface; #define GET_TT_LONG(w) \ (uint32_t)(((w)[0] << 24) | ((w)[1] << 16) | ((w)[2] << 8) | (w)[3]) +class CFX_DIBitmap; + +#if defined _SKIA_SUPPORT_ || defined _SKIA_SUPPORT_PATHS_ +class SkTypeface; + +using CFX_TypeFace = SkTypeface; +#endif + // Sets the given transform on the font, and resets it to the identity when it // goes out of scope. class ScopedFontTransform { @@ -72,11 +73,6 @@ class CFX_GlyphBitmap { RetainPtr m_pBitmap; }; -inline CFX_GlyphBitmap::CFX_GlyphBitmap() - : m_pBitmap(pdfium::MakeRetain()) {} - -inline CFX_GlyphBitmap::~CFX_GlyphBitmap() = default; - class FXTEXT_GLYPHPOS { public: FXTEXT_GLYPHPOS(); diff --git a/core/fxge/fx_ge_text.cpp b/core/fxge/fx_ge_text.cpp index a74b8fb9b9..d355058029 100644 --- a/core/fxge/fx_ge_text.cpp +++ b/core/fxge/fx_ge_text.cpp @@ -10,6 +10,7 @@ #include "core/fxcrt/fx_safe_types.h" #include "core/fxge/cfx_pathdata.h" +#include "core/fxge/dib/cfx_dibitmap.h" #include "core/fxge/fx_font.h" #include "core/fxge/fx_freetype.h" #include "core/fxge/renderdevicedriver_iface.h" diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp index e0010cdf78..2067243c04 100644 --- a/core/fxge/skia/fx_skia_device.cpp +++ b/core/fxge/skia/fx_skia_device.cpp @@ -25,6 +25,7 @@ #include "core/fxge/cfx_pathdata.h" #include "core/fxge/cfx_renderdevice.h" #include "core/fxge/dib/cfx_bitmapcomposer.h" +#include "core/fxge/dib/cfx_dibitmap.h" #include "core/fxge/dib/cfx_imagerenderer.h" #include "core/fxge/dib/cfx_imagestretcher.h" #include "third_party/base/logging.h" diff --git a/core/fxge/skia/fx_skia_device.h b/core/fxge/skia/fx_skia_device.h index 7c9dfeccbd..ea3477882d 100644 --- a/core/fxge/skia/fx_skia_device.h +++ b/core/fxge/skia/fx_skia_device.h @@ -13,6 +13,7 @@ #include "core/fxge/cfx_pathdata.h" #include "core/fxge/renderdevicedriver_iface.h" +class CFX_ClipRgn; class FXTEXT_CHARPOS; class SkCanvas; class SkMatrix; diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp index becf99b52d..9e01bd2d06 100644 --- a/core/fxge/win32/cfx_psrenderer.cpp +++ b/core/fxge/win32/cfx_psrenderer.cpp @@ -24,6 +24,7 @@ #include "core/fxge/cfx_pathdata.h" #include "core/fxge/cfx_renderdevice.h" #include "core/fxge/dib/cfx_dibextractor.h" +#include "core/fxge/dib/cfx_dibitmap.h" #include "core/fxge/win32/cpsoutput.h" #include "third_party/base/ptr_util.h" diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp index aeec161bf5..2f99f88e68 100644 --- a/core/fxge/win32/fx_win32_print.cpp +++ b/core/fxge/win32/fx_win32_print.cpp @@ -14,6 +14,7 @@ #include "core/fxge/cfx_font.h" #include "core/fxge/cfx_windowsrenderdevice.h" #include "core/fxge/dib/cfx_dibextractor.h" +#include "core/fxge/dib/cfx_dibitmap.h" #include "core/fxge/dib/cfx_imagerenderer.h" #include "core/fxge/dib/cstretchengine.h" #include "core/fxge/fx_freetype.h" -- cgit v1.2.3