From 9ada2d83cbb629f286936ebc7a208a61164f873b Mon Sep 17 00:00:00 2001 From: npm Date: Wed, 10 Aug 2016 07:51:38 -0700 Subject: Move CFX_RenderDevice, CFX_FxgeDevice, and CFX_GraphStateData into their own files. This is the third CL to separate fx_ge into classes, one per file. All fx_ge.h includes had to be replaced with new includes The method definitions for CFX_FxgeDevice were not moved to a single file. These methods are defined in two folders different from fxge/ge, so they were left untouched for now. Review-Url: https://codereview.chromium.org/2223213002 --- BUILD.gn | 8 +- core/fpdfapi/cpdf_pagerendercontext.cpp | 2 +- core/fpdfapi/fpdf_font/cpdf_type1font.cpp | 1 - core/fpdfapi/fpdf_font/fpdf_font_cid.cpp | 1 - core/fpdfapi/fpdf_font/ttgsubtable.cpp | 1 - core/fpdfapi/fpdf_page/cpdf_allstates.cpp | 1 + core/fpdfapi/fpdf_page/cpdf_graphstate.h | 2 +- core/fpdfapi/fpdf_page/fpdf_page_parser.cpp | 1 + core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp | 2 + core/fpdfapi/fpdf_page/include/cpdf_path.h | 3 +- core/fpdfapi/fpdf_page/pageint.h | 2 +- core/fpdfapi/fpdf_render/fpdf_render.cpp | 4 +- core/fpdfapi/fpdf_render/fpdf_render_cache.cpp | 1 - core/fpdfapi/fpdf_render/fpdf_render_image.cpp | 2 +- core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp | 1 - core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp | 2 + core/fpdfapi/fpdf_render/fpdf_render_text.cpp | 4 +- core/fpdfapi/fpdf_render/render_int.h | 2 + core/fpdfdoc/cpdf_annot.cpp | 3 +- core/fpdfdoc/cpdf_annotlist.cpp | 1 + core/fpdfdoc/cpdf_formcontrol.cpp | 1 + core/fxge/agg/fx_agg_driver.cpp | 4 +- core/fxge/agg/fx_agg_driver.h | 1 + core/fxge/android/fx_android_imp.cpp | 1 - core/fxge/apple/apple_int.h | 2 + core/fxge/apple/cfx_quartzdevice.h | 2 +- core/fxge/apple/fx_apple_platform.cpp | 2 +- core/fxge/apple/fx_mac_imp.cpp | 1 - core/fxge/apple/fx_quartz_device.cpp | 3 +- core/fxge/dib/fx_dib_composite.cpp | 1 - core/fxge/dib/fx_dib_convert.cpp | 1 - core/fxge/dib/fx_dib_engine.cpp | 1 - core/fxge/dib/fx_dib_main.cpp | 1 - core/fxge/ge/cfx_graphstatedata.cpp | 52 + core/fxge/ge/cfx_pathdata.cpp | 1 - core/fxge/ge/cfx_renderdevice.cpp | 1072 ++++++++++++++++++++ core/fxge/ge/fx_ge_device.cpp | 504 --------- core/fxge/ge/fx_ge_fontmap.cpp | 1 - core/fxge/ge/fx_ge_path.cpp | 51 - core/fxge/ge/fx_ge_text.cpp | 588 ----------- core/fxge/ifx_renderdevicedriver.cpp | 1 + core/fxge/include/cfx_fxgedevice.h | 39 + core/fxge/include/cfx_graphstatedata.h | 38 + core/fxge/include/cfx_pathdata.h | 1 + core/fxge/include/cfx_renderdevice.h | 280 +++++ core/fxge/include/fx_ge.h | 334 ------ core/fxge/skia/fx_skia_device.cpp | 3 + core/fxge/skia/fx_skia_device.h | 1 + core/fxge/skia/fx_skia_device_unittest.cpp | 4 +- core/fxge/win32/fx_win32_device.cpp | 3 +- core/fxge/win32/fx_win32_dib.cpp | 2 +- core/fxge/win32/fx_win32_dwrite.cpp | 2 +- core/fxge/win32/fx_win32_gdipext.cpp | 3 +- core/fxge/win32/fx_win32_print.cpp | 3 +- core/fxge/win32/win32_int.h | 2 + fpdfsdk/formfiller/cffl_formfiller.cpp | 1 + fpdfsdk/formfiller/cffl_iformfiller.cpp | 3 +- fpdfsdk/fpdf_progressive.cpp | 3 +- fpdfsdk/fpdf_sysfontinfo.cpp | 1 - fpdfsdk/fpdfformfill.cpp | 2 +- fpdfsdk/fpdfview.cpp | 2 +- fpdfsdk/fsdk_annothandler.cpp | 1 + fpdfsdk/fsdk_baseannot.cpp | 1 + fpdfsdk/fsdk_baseform.cpp | 3 +- fpdfsdk/fsdk_mgr.cpp | 1 + fpdfsdk/fxedit/fxet_edit.cpp | 3 +- fpdfsdk/pdfwindow/PWL_Caret.cpp | 3 +- fpdfsdk/pdfwindow/PWL_ComboBox.cpp | 2 +- fpdfsdk/pdfwindow/PWL_Edit.cpp | 3 +- fpdfsdk/pdfwindow/PWL_ScrollBar.cpp | 2 +- fpdfsdk/pdfwindow/PWL_Utils.cpp | 3 +- pdfium.gyp | 8 +- xfa/fde/cfde_path.h | 2 +- xfa/fde/fde_gedevice.cpp | 2 + xfa/fde/fde_gedevice.h | 3 +- xfa/fde/fde_visualset.h | 2 + xfa/fde/tto/fde_textout.h | 4 +- xfa/fgas/font/fgas_stdfontmgr.cpp | 1 - xfa/fgas/layout/fgas_textbreak.h | 2 +- xfa/fxbarcode/BC_TwoDimWriter.cpp | 3 +- xfa/fxbarcode/oned/BC_OneDimWriter.cpp | 3 + xfa/fxbarcode/oned/BC_OneDimWriter.h | 2 +- xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp | 1 + xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp | 1 + xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp | 1 + xfa/fxfa/app/xfa_ffwidget.cpp | 1 + xfa/fxfa/include/xfa_ffwidget.h | 2 +- xfa/fxfa/parser/xfa_localemgr.cpp | 1 - xfa/fxgraphics/cfx_graphics.cpp | 2 + xfa/fxgraphics/cfx_path_generator.cpp | 1 + xfa/fxgraphics/cfx_path_generator.h | 1 - xfa/fxgraphics/include/cfx_graphics.h | 5 +- 92 files changed, 1595 insertions(+), 1537 deletions(-) create mode 100644 core/fxge/ge/cfx_graphstatedata.cpp create mode 100644 core/fxge/ge/cfx_renderdevice.cpp delete mode 100644 core/fxge/ge/fx_ge_device.cpp delete mode 100644 core/fxge/ge/fx_ge_path.cpp create mode 100644 core/fxge/include/cfx_fxgedevice.h create mode 100644 core/fxge/include/cfx_graphstatedata.h create mode 100644 core/fxge/include/cfx_renderdevice.h delete mode 100644 core/fxge/include/fx_ge.h diff --git a/BUILD.gn b/BUILD.gn index 87ee80f182..3ead13c849 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -735,25 +735,27 @@ static_library("fxge") { "core/fxge/ge/cfx_fontmapper.cpp", "core/fxge/ge/cfx_fontmgr.cpp", "core/fxge/ge/cfx_gemodule.cpp", + "core/fxge/ge/cfx_graphstatedata.cpp", "core/fxge/ge/cfx_pathdata.cpp", - "core/fxge/ge/fx_ge_device.cpp", + "core/fxge/ge/cfx_renderdevice.cpp", "core/fxge/ge/fx_ge_font.cpp", "core/fxge/ge/fx_ge_fontmap.cpp", "core/fxge/ge/fx_ge_linux.cpp", - "core/fxge/ge/fx_ge_path.cpp", "core/fxge/ge/fx_ge_text.cpp", "core/fxge/ge/fx_text_int.h", "core/fxge/ge/include/cfx_fontmapper.h", "core/fxge/ge/include/cfx_fontmgr.h", "core/fxge/ge/include/ifx_systemfontinfo.h", "core/fxge/ifx_renderdevicedriver.cpp", + "core/fxge/include/cfx_fxgedevice.h", "core/fxge/include/cfx_gemodule.h", + "core/fxge/include/cfx_graphstatedata.h", "core/fxge/include/cfx_pathdata.h", + "core/fxge/include/cfx_renderdevice.h", "core/fxge/include/cfx_windowsdevice.h", "core/fxge/include/fx_dib.h", "core/fxge/include/fx_font.h", "core/fxge/include/fx_freetype.h", - "core/fxge/include/fx_ge.h", "core/fxge/include/ifx_renderdevicedriver.h", "core/fxge/win32/cfx_windowsdib.h", ] diff --git a/core/fpdfapi/cpdf_pagerendercontext.cpp b/core/fpdfapi/cpdf_pagerendercontext.cpp index a82a460835..1b2eb76b35 100644 --- a/core/fpdfapi/cpdf_pagerendercontext.cpp +++ b/core/fpdfapi/cpdf_pagerendercontext.cpp @@ -11,7 +11,7 @@ #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" #include "core/fpdfdoc/include/cpdf_annotlist.h" #include "core/fpdfdoc/include/cpdf_occontext.h" -#include "core/fxge/include/fx_ge.h" +#include "core/fxge/include/cfx_renderdevice.h" CPDF_PageRenderContext::CPDF_PageRenderContext() {} diff --git a/core/fpdfapi/fpdf_font/cpdf_type1font.cpp b/core/fpdfapi/fpdf_font/cpdf_type1font.cpp index a7322b8f56..5f6eb1f662 100644 --- a/core/fpdfapi/fpdf_font/cpdf_type1font.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_type1font.cpp @@ -10,7 +10,6 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" #include "core/fxge/include/cfx_gemodule.h" #include "core/fxge/include/fx_freetype.h" -#include "core/fxge/include/fx_ge.h" #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ #include "core/fxge/apple/apple_int.h" diff --git a/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp index f6d3bdc711..cfcac364b9 100644 --- a/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp +++ b/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp @@ -15,7 +15,6 @@ #include "core/fpdfapi/include/cpdf_modulemgr.h" #include "core/fxcrt/include/fx_ext.h" #include "core/fxge/include/fx_freetype.h" -#include "core/fxge/include/fx_ge.h" namespace { diff --git a/core/fpdfapi/fpdf_font/ttgsubtable.cpp b/core/fpdfapi/fpdf_font/ttgsubtable.cpp index c5ad7cae16..fb6287ee28 100644 --- a/core/fpdfapi/fpdf_font/ttgsubtable.cpp +++ b/core/fpdfapi/fpdf_font/ttgsubtable.cpp @@ -7,7 +7,6 @@ #include "core/fpdfapi/fpdf_font/ttgsubtable.h" #include "core/fxge/include/fx_freetype.h" -#include "core/fxge/include/fx_ge.h" #include "third_party/base/stl_util.h" CFX_GlyphMap::CFX_GlyphMap() {} diff --git a/core/fpdfapi/fpdf_page/cpdf_allstates.cpp b/core/fpdfapi/fpdf_page/cpdf_allstates.cpp index 5230b3b206..ab69eb7488 100644 --- a/core/fpdfapi/fpdf_page/cpdf_allstates.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_allstates.cpp @@ -9,6 +9,7 @@ #include "core/fpdfapi/fpdf_page/pageint.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" +#include "core/fxge/include/cfx_graphstatedata.h" namespace { diff --git a/core/fpdfapi/fpdf_page/cpdf_graphstate.h b/core/fpdfapi/fpdf_page/cpdf_graphstate.h index 038ed15580..7748bb203d 100644 --- a/core/fpdfapi/fpdf_page/cpdf_graphstate.h +++ b/core/fpdfapi/fpdf_page/cpdf_graphstate.h @@ -7,7 +7,7 @@ #ifndef CORE_FPDFAPI_FPDF_PAGE_CPDF_GRAPHSTATE_H_ #define CORE_FPDFAPI_FPDF_PAGE_CPDF_GRAPHSTATE_H_ -#include "core/fxge/include/fx_ge.h" +#include "core/fxge/include/cfx_graphstatedata.h" class CPDF_GraphState : public CFX_CountRef {}; diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp index 991e4b1e9f..805d648a24 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp @@ -34,6 +34,7 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h" #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" #include "core/fxcrt/include/fx_safe_types.h" +#include "core/fxge/include/cfx_graphstatedata.h" #include "core/fxge/include/cfx_pathdata.h" namespace { diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp index 2639d7aa5c..2b7ac6fc2a 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp @@ -30,6 +30,8 @@ #include "core/fxcodec/include/fx_codec.h" #include "core/fxcrt/include/fx_ext.h" #include "core/fxcrt/include/fx_safe_types.h" +#include "core/fxge/include/cfx_fxgedevice.h" +#include "core/fxge/include/cfx_renderdevice.h" namespace { diff --git a/core/fpdfapi/fpdf_page/include/cpdf_path.h b/core/fpdfapi/fpdf_page/include/cpdf_path.h index bed40581fa..39cbd60bd3 100644 --- a/core/fpdfapi/fpdf_page/include/cpdf_path.h +++ b/core/fpdfapi/fpdf_page/include/cpdf_path.h @@ -8,8 +8,9 @@ #define CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_PATH_H_ #include "core/fxcrt/include/fx_system.h" +#include "core/fxge/include/cfx_fxgedevice.h" #include "core/fxge/include/cfx_pathdata.h" -#include "core/fxge/include/fx_ge.h" +#include "core/fxge/include/cfx_renderdevice.h" class CPDF_Path : public CFX_CountRef { public: diff --git a/core/fpdfapi/fpdf_page/pageint.h b/core/fpdfapi/fpdf_page/pageint.h index 655e02d9b2..72f3184529 100644 --- a/core/fpdfapi/fpdf_page/pageint.h +++ b/core/fpdfapi/fpdf_page/pageint.h @@ -17,7 +17,7 @@ #include "core/fpdfapi/fpdf_page/cpdf_countedobject.h" #include "core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h" #include "core/fxge/include/cfx_pathdata.h" -#include "core/fxge/include/fx_ge.h" +#include "core/fxge/include/cfx_renderdevice.h" class CPDF_AllStates; class CPDF_ColorSpace; diff --git a/core/fpdfapi/fpdf_render/fpdf_render.cpp b/core/fpdfapi/fpdf_render/fpdf_render.cpp index 350aa32e0b..b736a1fc78 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render.cpp @@ -30,8 +30,10 @@ #include "core/fpdfapi/fpdf_render/include/cpdf_textrenderer.h" #include "core/fpdfapi/include/cpdf_modulemgr.h" #include "core/fpdfdoc/include/cpdf_occontext.h" +#include "core/fxge/include/cfx_fxgedevice.h" +#include "core/fxge/include/cfx_graphstatedata.h" #include "core/fxge/include/cfx_pathdata.h" -#include "core/fxge/include/fx_ge.h" +#include "core/fxge/include/cfx_renderdevice.h" CPDF_DocRenderData::CPDF_DocRenderData(CPDF_Document* pPDFDoc) : m_pPDFDoc(pPDFDoc), m_pFontCache(new CFX_FontCache) {} diff --git a/core/fpdfapi/fpdf_render/fpdf_render_cache.cpp b/core/fpdfapi/fpdf_render/fpdf_render_cache.cpp index 055e2f03cb..332f0016ac 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_cache.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_cache.cpp @@ -11,7 +11,6 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "core/fpdfapi/fpdf_render/include/cpdf_rendercontext.h" #include "core/fpdfapi/fpdf_render/render_int.h" -#include "core/fxge/include/fx_ge.h" struct CACHEINFO { uint32_t time; diff --git a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp index e3dc7d8b33..c93600f2a1 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp @@ -26,8 +26,8 @@ #include "core/fpdfdoc/include/cpdf_occontext.h" #include "core/fxcodec/include/fx_codec.h" #include "core/fxcrt/include/fx_safe_types.h" +#include "core/fxge/include/cfx_fxgedevice.h" #include "core/fxge/include/cfx_pathdata.h" -#include "core/fxge/include/fx_ge.h" #ifdef _SKIA_SUPPORT_ #include "core/fxge/skia/fx_skia_device.h" diff --git a/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp index 2fe6730479..f02c59a9af 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp @@ -20,7 +20,6 @@ #include "core/fpdfapi/include/cpdf_modulemgr.h" #include "core/fxcodec/include/fx_codec.h" #include "core/fxcrt/include/fx_safe_types.h" -#include "core/fxge/include/fx_ge.h" namespace { diff --git a/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp b/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp index 4653dd355c..21af7686fc 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp @@ -21,7 +21,9 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" #include "core/fpdfapi/fpdf_render/include/cpdf_rendercontext.h" #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" +#include "core/fxge/include/cfx_fxgedevice.h" #include "core/fxge/include/cfx_pathdata.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "core/fxge/include/ifx_renderdevicedriver.h" namespace { diff --git a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp index 728521af11..222fbcb625 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp @@ -22,9 +22,11 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" #include "core/fpdfapi/fpdf_render/include/cpdf_textrenderer.h" +#include "core/fxge/include/cfx_fxgedevice.h" #include "core/fxge/include/cfx_gemodule.h" +#include "core/fxge/include/cfx_graphstatedata.h" #include "core/fxge/include/cfx_pathdata.h" -#include "core/fxge/include/fx_ge.h" +#include "core/fxge/include/cfx_renderdevice.h" namespace { diff --git a/core/fpdfapi/fpdf_render/render_int.h b/core/fpdfapi/fpdf_render/render_int.h index f487b46c18..a10dca5db8 100644 --- a/core/fpdfapi/fpdf_render/render_int.h +++ b/core/fpdfapi/fpdf_render/render_int.h @@ -16,6 +16,8 @@ #include "core/fpdfapi/fpdf_page/include/cpdf_clippath.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h" #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" +#include "core/fxge/include/cfx_fxgedevice.h" +#include "core/fxge/include/cfx_renderdevice.h" class CCodec_Jbig2Context; class CCodec_ScanlineDecoder; diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp index bff9131b46..2b9b936cd1 100644 --- a/core/fpdfdoc/cpdf_annot.cpp +++ b/core/fpdfdoc/cpdf_annot.cpp @@ -14,8 +14,9 @@ #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" #include "core/fpdfdoc/cpvt_generateap.h" #include "core/fxcrt/include/fx_memory.h" +#include "core/fxge/include/cfx_graphstatedata.h" #include "core/fxge/include/cfx_pathdata.h" -#include "core/fxge/include/fx_ge.h" +#include "core/fxge/include/cfx_renderdevice.h" CPDF_Annot::CPDF_Annot(CPDF_Dictionary* pDict, CPDF_Document* pDocument) : m_pAnnotDict(pDict), diff --git a/core/fpdfdoc/cpdf_annotlist.cpp b/core/fpdfdoc/cpdf_annotlist.cpp index 6a86d55e28..9dc0e9587d 100644 --- a/core/fpdfdoc/cpdf_annotlist.cpp +++ b/core/fpdfdoc/cpdf_annotlist.cpp @@ -14,6 +14,7 @@ #include "core/fpdfdoc/include/cpdf_annot.h" #include "core/fpdfdoc/include/cpdf_interform.h" #include "core/fpdfdoc/include/cpdf_occontext.h" +#include "core/fxge/include/cfx_renderdevice.h" CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage) : m_pDocument(pPage->m_pDocument) { diff --git a/core/fpdfdoc/cpdf_formcontrol.cpp b/core/fpdfdoc/cpdf_formcontrol.cpp index e6c505869c..9d134842fa 100644 --- a/core/fpdfdoc/cpdf_formcontrol.cpp +++ b/core/fpdfdoc/cpdf_formcontrol.cpp @@ -15,6 +15,7 @@ #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" #include "core/fpdfapi/fpdf_render/include/cpdf_rendercontext.h" #include "core/fpdfdoc/include/cpdf_interform.h" +#include "core/fxge/include/cfx_renderdevice.h" namespace { diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp index 80cde93747..c9f8bb4374 100644 --- a/core/fxge/agg/fx_agg_driver.cpp +++ b/core/fxge/agg/fx_agg_driver.cpp @@ -13,9 +13,11 @@ #include "core/fxge/dib/dib_int.h" #include "core/fxge/ge/cfx_cliprgn.h" #include "core/fxge/ge/fx_text_int.h" +#include "core/fxge/include/cfx_fxgedevice.h" #include "core/fxge/include/cfx_gemodule.h" +#include "core/fxge/include/cfx_graphstatedata.h" #include "core/fxge/include/cfx_pathdata.h" -#include "core/fxge/include/fx_ge.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "core/fxge/include/ifx_renderdevicedriver.h" #include "third_party/agg23/agg_conv_dash.h" #include "third_party/agg23/agg_conv_stroke.h" diff --git a/core/fxge/agg/fx_agg_driver.h b/core/fxge/agg/fx_agg_driver.h index ff02ec7251..8d6aec12dc 100644 --- a/core/fxge/agg/fx_agg_driver.h +++ b/core/fxge/agg/fx_agg_driver.h @@ -16,6 +16,7 @@ #include "third_party/agg23/agg_rasterizer_scanline_aa.h" class CFX_ClipRgn; +class CFX_GraphStateData; class CFX_Matrix; class CFX_PathData; diff --git a/core/fxge/android/fx_android_imp.cpp b/core/fxge/android/fx_android_imp.cpp index a6bddc7117..ebf98c488f 100644 --- a/core/fxge/android/fx_android_imp.cpp +++ b/core/fxge/android/fx_android_imp.cpp @@ -14,7 +14,6 @@ #include "core/fxge/android/fpf_skiamodule.h" #include "core/fxge/android/fx_android_font.h" #include "core/fxge/include/cfx_gemodule.h" -#include "core/fxge/include/fx_ge.h" void CFX_GEModule::InitPlatform() { CFPF_SkiaDeviceModule* pDeviceModule = CFPF_GetSkiaDeviceModule(); diff --git a/core/fxge/apple/apple_int.h b/core/fxge/apple/apple_int.h index 56e458bba7..b81f7835d8 100644 --- a/core/fxge/apple/apple_int.h +++ b/core/fxge/apple/apple_int.h @@ -11,7 +11,9 @@ #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ +#include "core/fxge/include/cfx_graphstatedata.h" #include "core/fxge/include/cfx_pathdata.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "core/fxge/include/fx_dib.h" #include "core/fxge/include/ifx_renderdevicedriver.h" diff --git a/core/fxge/apple/cfx_quartzdevice.h b/core/fxge/apple/cfx_quartzdevice.h index e9261d62b8..826309f3d7 100644 --- a/core/fxge/apple/cfx_quartzdevice.h +++ b/core/fxge/apple/cfx_quartzdevice.h @@ -9,7 +9,7 @@ #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ -#include "core/fxge/include/fx_ge.h" +#include "core/fxge/include/cfx_renderdevice.h" class CFX_QuartzDevice : public CFX_RenderDevice { public: diff --git a/core/fxge/apple/fx_apple_platform.cpp b/core/fxge/apple/fx_apple_platform.cpp index 744bc522d6..c02e8ae354 100644 --- a/core/fxge/apple/fx_apple_platform.cpp +++ b/core/fxge/apple/fx_apple_platform.cpp @@ -5,7 +5,6 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "core/fxcrt/include/fx_system.h" -#include "core/fxge/include/fx_ge.h" #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ @@ -19,6 +18,7 @@ #include "core/fxge/ge/cfx_cliprgn.h" #include "core/fxge/ge/fx_text_int.h" #include "core/fxge/include/cfx_gemodule.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "core/fxge/include/fx_freetype.h" #ifndef _SKIA_SUPPORT_ diff --git a/core/fxge/apple/fx_mac_imp.cpp b/core/fxge/apple/fx_mac_imp.cpp index a14bd022ab..78bb90fdc2 100644 --- a/core/fxge/apple/fx_mac_imp.cpp +++ b/core/fxge/apple/fx_mac_imp.cpp @@ -7,7 +7,6 @@ #include "core/fxge/apple/apple_int.h" #include "core/fxge/ge/cfx_folderfontinfo.h" #include "core/fxge/include/cfx_gemodule.h" -#include "core/fxge/include/fx_ge.h" #include "core/fxge/include/ifx_systemfontinfo.h" #if _FX_OS_ == _FX_MACOSX_ diff --git a/core/fxge/apple/fx_quartz_device.cpp b/core/fxge/apple/fx_quartz_device.cpp index 46d98e0a70..c877715d11 100644 --- a/core/fxge/apple/fx_quartz_device.cpp +++ b/core/fxge/apple/fx_quartz_device.cpp @@ -14,9 +14,10 @@ #include "core/fxge/dib/dib_int.h" #include "core/fxge/ge/fx_text_int.h" #include "core/fxge/include/cfx_gemodule.h" +#include "core/fxge/include/cfx_graphstatedata.h" #include "core/fxge/include/cfx_pathdata.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "core/fxge/include/fx_freetype.h" -#include "core/fxge/include/fx_ge.h" #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ #include "core/fxge/apple/apple_int.h" diff --git a/core/fxge/dib/fx_dib_composite.cpp b/core/fxge/dib/fx_dib_composite.cpp index 32de185f09..2ac455bfb5 100644 --- a/core/fxge/dib/fx_dib_composite.cpp +++ b/core/fxge/dib/fx_dib_composite.cpp @@ -8,7 +8,6 @@ #include "core/fxge/dib/dib_int.h" #include "core/fxge/ge/cfx_cliprgn.h" #include "core/fxge/include/cfx_gemodule.h" -#include "core/fxge/include/fx_ge.h" namespace { diff --git a/core/fxge/dib/fx_dib_convert.cpp b/core/fxge/dib/fx_dib_convert.cpp index 1faa44d81c..cb64960953 100644 --- a/core/fxge/dib/fx_dib_convert.cpp +++ b/core/fxge/dib/fx_dib_convert.cpp @@ -6,7 +6,6 @@ #include "core/fxcodec/include/fx_codec.h" #include "core/fxge/include/fx_dib.h" -#include "core/fxge/include/fx_ge.h" class CFX_Palette { public: diff --git a/core/fxge/dib/fx_dib_engine.cpp b/core/fxge/dib/fx_dib_engine.cpp index 697bbb7252..520148fc77 100644 --- a/core/fxge/dib/fx_dib_engine.cpp +++ b/core/fxge/dib/fx_dib_engine.cpp @@ -10,7 +10,6 @@ #include "core/fxge/dib/dib_int.h" #include "core/fxge/include/fx_dib.h" -#include "core/fxge/include/fx_ge.h" namespace { diff --git a/core/fxge/dib/fx_dib_main.cpp b/core/fxge/dib/fx_dib_main.cpp index 5c13c1d256..16106fec7f 100644 --- a/core/fxge/dib/fx_dib_main.cpp +++ b/core/fxge/dib/fx_dib_main.cpp @@ -13,7 +13,6 @@ #include "core/fxge/dib/dib_int.h" #include "core/fxge/ge/cfx_cliprgn.h" #include "core/fxge/include/cfx_gemodule.h" -#include "core/fxge/include/fx_ge.h" void CmykDecode(uint32_t cmyk, int& c, int& m, int& y, int& k) { c = FXSYS_GetCValue(cmyk); diff --git a/core/fxge/ge/cfx_graphstatedata.cpp b/core/fxge/ge/cfx_graphstatedata.cpp new file mode 100644 index 0000000000..0a5b5e301c --- /dev/null +++ b/core/fxge/ge/cfx_graphstatedata.cpp @@ -0,0 +1,52 @@ +// Copyright 2016 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. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#include "core/fxge/include/cfx_graphstatedata.h" + +#include "core/fxcrt/include/fx_memory.h" +#include "core/fxcrt/include/fx_system.h" + +CFX_GraphStateData::CFX_GraphStateData() + : m_LineCap(LineCapButt), + m_DashCount(0), + m_DashArray(nullptr), + m_DashPhase(0), + m_LineJoin(LineJoinMiter), + m_MiterLimit(10 * 1.0f), + m_LineWidth(1.0f) {} + +CFX_GraphStateData::CFX_GraphStateData(const CFX_GraphStateData& src) { + m_DashArray = nullptr; + Copy(src); +} + +void CFX_GraphStateData::Copy(const CFX_GraphStateData& src) { + m_LineCap = src.m_LineCap; + m_DashCount = src.m_DashCount; + FX_Free(m_DashArray); + m_DashArray = nullptr; + m_DashPhase = src.m_DashPhase; + m_LineJoin = src.m_LineJoin; + m_MiterLimit = src.m_MiterLimit; + m_LineWidth = src.m_LineWidth; + if (m_DashCount) { + m_DashArray = FX_Alloc(FX_FLOAT, m_DashCount); + FXSYS_memcpy(m_DashArray, src.m_DashArray, m_DashCount * sizeof(FX_FLOAT)); + } +} + +CFX_GraphStateData::~CFX_GraphStateData() { + FX_Free(m_DashArray); +} + +void CFX_GraphStateData::SetDashCount(int count) { + FX_Free(m_DashArray); + m_DashArray = nullptr; + m_DashCount = count; + if (count == 0) + return; + m_DashArray = FX_Alloc(FX_FLOAT, count); +} diff --git a/core/fxge/ge/cfx_pathdata.cpp b/core/fxge/ge/cfx_pathdata.cpp index 66792642f9..a538cadcaf 100644 --- a/core/fxge/ge/cfx_pathdata.cpp +++ b/core/fxge/ge/cfx_pathdata.cpp @@ -7,7 +7,6 @@ #include "core/fxge/include/cfx_pathdata.h" #include "core/fxcrt/include/fx_system.h" -#include "core/fxge/include/fx_ge.h" #include "third_party/base/numerics/safe_math.h" CFX_PathData::CFX_PathData() diff --git a/core/fxge/ge/cfx_renderdevice.cpp b/core/fxge/ge/cfx_renderdevice.cpp new file mode 100644 index 0000000000..f04f4bab9a --- /dev/null +++ b/core/fxge/ge/cfx_renderdevice.cpp @@ -0,0 +1,1072 @@ +// Copyright 2016 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. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#include "core/fxge/include/cfx_renderdevice.h" + +#include "core/fxge/include/cfx_fxgedevice.h" +#include "core/fxge/include/cfx_graphstatedata.h" +#include "core/fxge/include/cfx_pathdata.h" +#include "core/fxge/include/ifx_renderdevicedriver.h" + +#if defined _SKIA_SUPPORT_ +#include "third_party/skia/include/core/SkTypes.h" +#endif + +namespace { + +void AdjustGlyphSpace(std::vector* pGlyphAndPos) { + ASSERT(pGlyphAndPos->size() > 1); + std::vector& glyphs = *pGlyphAndPos; + bool bVertical = glyphs.back().m_OriginX == glyphs.front().m_OriginX; + if (!bVertical && (glyphs.back().m_OriginY != glyphs.front().m_OriginY)) + return; + + for (size_t i = glyphs.size() - 1; i > 1; --i) { + FXTEXT_GLYPHPOS& next = glyphs[i]; + int next_origin = bVertical ? next.m_OriginY : next.m_OriginX; + FX_FLOAT next_origin_f = bVertical ? next.m_fOriginY : next.m_fOriginX; + + FXTEXT_GLYPHPOS& current = glyphs[i - 1]; + int& current_origin = bVertical ? current.m_OriginY : current.m_OriginX; + FX_FLOAT current_origin_f = + bVertical ? current.m_fOriginY : current.m_fOriginX; + + int space = next_origin - current_origin; + FX_FLOAT space_f = next_origin_f - current_origin_f; + FX_FLOAT error = + FXSYS_fabs(space_f) - FXSYS_fabs(static_cast(space)); + if (error > 0.5f) + current_origin += space > 0 ? -1 : 1; + } +} + +const uint8_t g_TextGammaAdjust[256] = { + 0, 2, 3, 4, 6, 7, 8, 10, 11, 12, 13, 15, 16, 17, 18, + 19, 21, 22, 23, 24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, + 36, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, + 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, + 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, + 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, + 129, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 156, + 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, + 172, 173, 174, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, + 186, 187, 188, 189, 190, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + 200, 201, 202, 203, 204, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, + 214, 215, 216, 217, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, + 228, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 239, 240, + 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 250, 251, 252, 253, 254, + 255, +}; + +int TextGammaAdjust(int value) { + ASSERT(value >= 0); + ASSERT(value <= 255); + return g_TextGammaAdjust[value]; +} + +int CalcAlpha(int src, int alpha) { + return src * alpha / 255; +} + +void Merge(uint8_t src, int channel, int alpha, uint8_t* dest) { + *dest = FXDIB_ALPHA_MERGE(*dest, channel, CalcAlpha(src, alpha)); +} + +void MergeGammaAdjust(uint8_t src, int channel, int alpha, uint8_t* dest) { + *dest = + FXDIB_ALPHA_MERGE(*dest, channel, CalcAlpha(TextGammaAdjust(src), alpha)); +} + +void MergeGammaAdjustBgr(const uint8_t* src, + int r, + int g, + int b, + int a, + uint8_t* dest) { + MergeGammaAdjust(src[0], b, a, &dest[0]); + MergeGammaAdjust(src[1], g, a, &dest[1]); + MergeGammaAdjust(src[2], r, a, &dest[2]); +} + +void MergeGammaAdjustRgb(const uint8_t* src, + int r, + int g, + int b, + int a, + uint8_t* dest) { + MergeGammaAdjust(src[2], b, a, &dest[0]); + MergeGammaAdjust(src[1], g, a, &dest[1]); + MergeGammaAdjust(src[0], r, a, &dest[2]); +} + +int AverageRgb(const uint8_t* src) { + return (src[0] + src[1] + src[2]) / 3; +} + +uint8_t CalculateDestAlpha(uint8_t back_alpha, int src_alpha) { + return back_alpha + src_alpha - back_alpha * src_alpha / 255; +} + +void ApplyDestAlpha(uint8_t back_alpha, + int src_alpha, + int r, + int g, + int b, + uint8_t* dest) { + uint8_t dest_alpha = CalculateDestAlpha(back_alpha, src_alpha); + int alpha_ratio = src_alpha * 255 / dest_alpha; + dest[0] = FXDIB_ALPHA_MERGE(dest[0], b, alpha_ratio); + dest[1] = FXDIB_ALPHA_MERGE(dest[1], g, alpha_ratio); + dest[2] = FXDIB_ALPHA_MERGE(dest[2], r, alpha_ratio); + dest[3] = dest_alpha; +} + +void NormalizeRgbDst(int src_value, int r, int g, int b, int a, uint8_t* dest) { + int src_alpha = CalcAlpha(TextGammaAdjust(src_value), a); + dest[0] = FXDIB_ALPHA_MERGE(dest[0], b, src_alpha); + dest[1] = FXDIB_ALPHA_MERGE(dest[1], g, src_alpha); + dest[2] = FXDIB_ALPHA_MERGE(dest[2], r, src_alpha); +} + +void NormalizeRgbSrc(int src_value, int r, int g, int b, int a, uint8_t* dest) { + int src_alpha = CalcAlpha(TextGammaAdjust(src_value), a); + if (src_alpha == 0) + return; + + dest[0] = FXDIB_ALPHA_MERGE(dest[0], b, src_alpha); + dest[1] = FXDIB_ALPHA_MERGE(dest[1], g, src_alpha); + dest[2] = FXDIB_ALPHA_MERGE(dest[2], r, src_alpha); +} + +void NormalizeArgbDest(int src_value, + int r, + int g, + int b, + int a, + uint8_t* dest) { + int src_alpha = CalcAlpha(TextGammaAdjust(src_value), a); + uint8_t back_alpha = dest[3]; + if (back_alpha == 0) { + FXARGB_SETDIB(dest, FXARGB_MAKE(src_alpha, r, g, b)); + } else if (src_alpha != 0) { + ApplyDestAlpha(back_alpha, src_alpha, r, g, b, dest); + } +} + +void NormalizeArgbSrc(int src_value, + int r, + int g, + int b, + int a, + uint8_t* dest) { + int src_alpha = CalcAlpha(TextGammaAdjust(src_value), a); + if (src_alpha == 0) + return; + + uint8_t back_alpha = dest[3]; + if (back_alpha == 0) { + FXARGB_SETDIB(dest, FXARGB_MAKE(src_alpha, r, g, b)); + } else { + ApplyDestAlpha(back_alpha, src_alpha, r, g, b, dest); + } +} + +void NextPixel(uint8_t** src_scan, uint8_t** dst_scan, int bpp) { + *src_scan += 3; + *dst_scan += bpp; +} + +void SetAlpha(uint8_t* alpha) { + alpha[3] = 255; +} + +void SetAlphaDoNothing(uint8_t* alpha) {} + +void DrawNormalTextHelper(CFX_DIBitmap* bitmap, + const CFX_DIBitmap* pGlyph, + int nrows, + int left, + int top, + int start_col, + int end_col, + bool bNormal, + bool bBGRStripe, + int x_subpixel, + int a, + int r, + int g, + int b) { + const bool has_alpha = bitmap->GetFormat() == FXDIB_Argb; + uint8_t* src_buf = pGlyph->GetBuffer(); + int src_pitch = pGlyph->GetPitch(); + uint8_t* dest_buf = bitmap->GetBuffer(); + int dest_pitch = bitmap->GetPitch(); + const int Bpp = has_alpha ? 4 : bitmap->GetBPP() / 8; + auto* pNormalizeSrcFunc = has_alpha ? &NormalizeArgbSrc : &NormalizeRgbDst; + auto* pNormalizeDstFunc = has_alpha ? &NormalizeArgbDest : &NormalizeRgbSrc; + auto* pSetAlpha = has_alpha ? &SetAlpha : &SetAlphaDoNothing; + + for (int row = 0; row < nrows; row++) { + int dest_row = row + top; + if (dest_row < 0 || dest_row >= bitmap->GetHeight()) + continue; + + uint8_t* src_scan = src_buf + row * src_pitch + (start_col - left) * 3; + uint8_t* dest_scan = dest_buf + dest_row * dest_pitch + start_col * Bpp; + if (bBGRStripe) { + if (x_subpixel == 0) { + for (int col = start_col; col < end_col; col++) { + if (has_alpha) { + Merge(src_scan[2], r, a, &dest_scan[2]); + Merge(src_scan[1], g, a, &dest_scan[1]); + Merge(src_scan[0], b, a, &dest_scan[0]); + } else { + MergeGammaAdjustBgr(&src_scan[0], r, g, b, a, &dest_scan[0]); + } + pSetAlpha(dest_scan); + NextPixel(&src_scan, &dest_scan, Bpp); + } + } else if (x_subpixel == 1) { + MergeGammaAdjust(src_scan[1], r, a, &dest_scan[2]); + MergeGammaAdjust(src_scan[0], g, a, &dest_scan[1]); + if (start_col > left) + MergeGammaAdjust(src_scan[-1], b, a, &dest_scan[0]); + pSetAlpha(dest_scan); + NextPixel(&src_scan, &dest_scan, Bpp); + for (int col = start_col + 1; col < end_col - 1; col++) { + MergeGammaAdjustBgr(&src_scan[-1], r, g, b, a, &dest_scan[0]); + pSetAlpha(dest_scan); + NextPixel(&src_scan, &dest_scan, Bpp); + } + } else { + MergeGammaAdjust(src_scan[0], r, a, &dest_scan[2]); + if (start_col > left) { + MergeGammaAdjust(src_scan[-1], g, a, &dest_scan[1]); + MergeGammaAdjust(src_scan[-2], b, a, &dest_scan[0]); + } + pSetAlpha(dest_scan); + NextPixel(&src_scan, &dest_scan, Bpp); + for (int col = start_col + 1; col < end_col - 1; col++) { + MergeGammaAdjustBgr(&src_scan[-2], r, g, b, a, &dest_scan[0]); + pSetAlpha(dest_scan); + NextPixel(&src_scan, &dest_scan, Bpp); + } + } + } else { + if (x_subpixel == 0) { + for (int col = start_col; col < end_col; col++) { + if (bNormal) { + int src_value = AverageRgb(&src_scan[0]); + pNormalizeDstFunc(src_value, r, g, b, a, dest_scan); + } else { + MergeGammaAdjustRgb(&src_scan[0], r, g, b, a, &dest_scan[0]); + pSetAlpha(dest_scan); + } + NextPixel(&src_scan, &dest_scan, Bpp); + } + } else if (x_subpixel == 1) { + if (bNormal) { + int src_value = start_col > left ? AverageRgb(&src_scan[-1]) + : (src_scan[0] + src_scan[1]) / 3; + pNormalizeSrcFunc(src_value, r, g, b, a, dest_scan); + } else { + if (start_col > left) + MergeGammaAdjust(src_scan[-1], r, a, &dest_scan[2]); + MergeGammaAdjust(src_scan[0], g, a, &dest_scan[1]); + MergeGammaAdjust(src_scan[1], b, a, &dest_scan[0]); + pSetAlpha(dest_scan); + } + NextPixel(&src_scan, &dest_scan, Bpp); + for (int col = start_col + 1; col < end_col; col++) { + if (bNormal) { + int src_value = AverageRgb(&src_scan[-1]); + pNormalizeDstFunc(src_value, r, g, b, a, dest_scan); + } else { + MergeGammaAdjustRgb(&src_scan[-1], r, g, b, a, &dest_scan[0]); + pSetAlpha(dest_scan); + } + NextPixel(&src_scan, &dest_scan, Bpp); + } + } else { + if (bNormal) { + int src_value = + start_col > left ? AverageRgb(&src_scan[-2]) : src_scan[0] / 3; + pNormalizeSrcFunc(src_value, r, g, b, a, dest_scan); + } else { + if (start_col > left) { + MergeGammaAdjust(src_scan[-2], r, a, &dest_scan[2]); + MergeGammaAdjust(src_scan[-1], g, a, &dest_scan[1]); + } + MergeGammaAdjust(src_scan[0], b, a, &dest_scan[0]); + pSetAlpha(dest_scan); + } + NextPixel(&src_scan, &dest_scan, Bpp); + for (int col = start_col + 1; col < end_col; col++) { + if (bNormal) { + int src_value = AverageRgb(&src_scan[-2]); + pNormalizeDstFunc(src_value, r, g, b, a, dest_scan); + } else { + MergeGammaAdjustRgb(&src_scan[-2], r, g, b, a, &dest_scan[0]); + pSetAlpha(dest_scan); + } + NextPixel(&src_scan, &dest_scan, Bpp); + } + } + } + } +} + +bool ShouldDrawDeviceText(const CFX_Font* pFont, uint32_t text_flags) { +#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ + if (text_flags & FXFONT_CIDFONT) + return false; + + const CFX_ByteString bsPsName = pFont->GetPsName(); + if (bsPsName.Find("+ZJHL") != -1) + return false; + + if (bsPsName == "CNAAJI+cmex10") + return false; +#endif + return true; +} + +} // namespace + +CFX_RenderDevice::CFX_RenderDevice() + : m_pBitmap(nullptr), + m_Width(0), + m_Height(0), + m_bpp(0), + m_RenderCaps(0), + m_DeviceClass(0) {} + +CFX_RenderDevice::~CFX_RenderDevice() {} + +#ifdef _SKIA_SUPPORT_ +void CFX_RenderDevice::Flush() { + m_pDeviceDriver.reset(); +} +#endif + +void CFX_RenderDevice::SetDeviceDriver( + std::unique_ptr pDriver) { + m_pDeviceDriver = std::move(pDriver); + InitDeviceInfo(); +} + +void CFX_RenderDevice::InitDeviceInfo() { + m_Width = m_pDeviceDriver->GetDeviceCaps(FXDC_PIXEL_WIDTH); + m_Height = m_pDeviceDriver->GetDeviceCaps(FXDC_PIXEL_HEIGHT); + m_bpp = m_pDeviceDriver->GetDeviceCaps(FXDC_BITS_PIXEL); + m_RenderCaps = m_pDeviceDriver->GetDeviceCaps(FXDC_RENDER_CAPS); + m_DeviceClass = m_pDeviceDriver->GetDeviceCaps(FXDC_DEVICE_CLASS); + if (!m_pDeviceDriver->GetClipBox(&m_ClipBox)) { + m_ClipBox.left = 0; + m_ClipBox.top = 0; + m_ClipBox.right = m_Width; + m_ClipBox.bottom = m_Height; + } +} + +FX_BOOL CFX_RenderDevice::StartRendering() { + return m_pDeviceDriver->StartRendering(); +} + +void CFX_RenderDevice::EndRendering() { + m_pDeviceDriver->EndRendering(); +} + +void CFX_RenderDevice::SaveState() { + m_pDeviceDriver->SaveState(); +} + +void CFX_RenderDevice::RestoreState(bool bKeepSaved) { + m_pDeviceDriver->RestoreState(bKeepSaved); + UpdateClipBox(); +} + +int CFX_RenderDevice::GetDeviceCaps(int caps_id) const { + return m_pDeviceDriver->GetDeviceCaps(caps_id); +} +CFX_Matrix CFX_RenderDevice::GetCTM() const { + return m_pDeviceDriver->GetCTM(); +} + +FX_BOOL CFX_RenderDevice::CreateCompatibleBitmap(CFX_DIBitmap* pDIB, + int width, + int height) const { + if (m_RenderCaps & FXRC_CMYK_OUTPUT) { + return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT + ? FXDIB_Cmyka + : FXDIB_Cmyk); + } + if (m_RenderCaps & FXRC_BYTEMASK_OUTPUT) + return pDIB->Create(width, height, FXDIB_8bppMask); +#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ + return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT + ? FXDIB_Argb + : FXDIB_Rgb32); +#else + return pDIB->Create( + width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Argb : FXDIB_Rgb); +#endif +} + +FX_BOOL CFX_RenderDevice::SetClip_PathFill(const CFX_PathData* pPathData, + const CFX_Matrix* pObject2Device, + int fill_mode) { + if (!m_pDeviceDriver->SetClip_PathFill(pPathData, pObject2Device, + fill_mode)) { + return FALSE; + } + UpdateClipBox(); + return TRUE; +} + +FX_BOOL CFX_RenderDevice::SetClip_PathStroke( + const CFX_PathData* pPathData, + const CFX_Matrix* pObject2Device, + const CFX_GraphStateData* pGraphState) { + if (!m_pDeviceDriver->SetClip_PathStroke(pPathData, pObject2Device, + pGraphState)) { + return FALSE; + } + UpdateClipBox(); + return TRUE; +} + +FX_BOOL CFX_RenderDevice::SetClip_Rect(const FX_RECT& rect) { + CFX_PathData path; + path.AppendRect(rect.left, rect.bottom, rect.right, rect.top); + if (!SetClip_PathFill(&path, nullptr, FXFILL_WINDING)) + return FALSE; + + UpdateClipBox(); + return TRUE; +} + +void CFX_RenderDevice::UpdateClipBox() { + if (m_pDeviceDriver->GetClipBox(&m_ClipBox)) + return; + m_ClipBox.left = 0; + m_ClipBox.top = 0; + m_ClipBox.right = m_Width; + m_ClipBox.bottom = m_Height; +} + +FX_BOOL CFX_RenderDevice::DrawPathWithBlend( + const CFX_PathData* pPathData, + const CFX_Matrix* pObject2Device, + const CFX_GraphStateData* pGraphState, + uint32_t fill_color, + uint32_t stroke_color, + int fill_mode, + int blend_type) { + uint8_t stroke_alpha = pGraphState ? FXARGB_A(stroke_color) : 0; + uint8_t fill_alpha = (fill_mode & 3) ? FXARGB_A(fill_color) : 0; + if (stroke_alpha == 0 && pPathData->GetPointCount() == 2) { + FX_PATHPOINT* pPoints = pPathData->GetPoints(); + FX_FLOAT x1, x2, y1, y2; + if (pObject2Device) { + pObject2Device->Transform(pPoints[0].m_PointX, pPoints[0].m_PointY, x1, + y1); + pObject2Device->Transform(pPoints[1].m_PointX, pPoints[1].m_PointY, x2, + y2); + } else { + x1 = pPoints[0].m_PointX; + y1 = pPoints[0].m_PointY; + x2 = pPoints[1].m_PointX; + y2 = pPoints[1].m_PointY; + } + DrawCosmeticLineWithFillModeAndBlend(x1, y1, x2, y2, fill_color, fill_mode, + blend_type); + return TRUE; + } + if ((pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) && + stroke_alpha == 0) { + CFX_FloatRect rect_f; + if (!(fill_mode & FXFILL_RECT_AA) && + pPathData->IsRect(pObject2Device, &rect_f)) { + FX_RECT rect_i = rect_f.GetOuterRect(); + + // Depending on the top/bottom, left/right values of the rect it's + // possible to overflow the Width() and Height() calculations. Check that + // the rect will have valid dimension before continuing. + if (!rect_i.Valid()) + return FALSE; + + int width = (int)FXSYS_ceil(rect_f.right - rect_f.left); + if (width < 1) { + width = 1; + if (rect_i.left == rect_i.right) + rect_i.right++; + } + int height = (int)FXSYS_ceil(rect_f.top - rect_f.bottom); + if (height < 1) { + height = 1; + if (rect_i.bottom == rect_i.top) + rect_i.bottom++; + } + if (rect_i.Width() >= width + 1) { + if (rect_f.left - (FX_FLOAT)(rect_i.left) > + (FX_FLOAT)(rect_i.right) - rect_f.right) { + rect_i.left++; + } else { + rect_i.right--; + } + } + if (rect_i.Height() >= height + 1) { + if (rect_f.top - (FX_FLOAT)(rect_i.top) > + (FX_FLOAT)(rect_i.bottom) - rect_f.bottom) { + rect_i.top++; + } else { + rect_i.bottom--; + } + } + if (FillRectWithBlend(&rect_i, fill_color, blend_type)) + return TRUE; + } + } + if ((fill_mode & 3) && stroke_alpha == 0 && !(fill_mode & FX_FILL_STROKE) && + !(fill_mode & FX_FILL_TEXT_MODE)) { + CFX_PathData newPath; + FX_BOOL bThin = FALSE; + if (pPathData->GetZeroAreaPath(newPath, (CFX_Matrix*)pObject2Device, bThin, + m_pDeviceDriver->GetDriverType())) { + CFX_GraphStateData graphState; + graphState.m_LineWidth = 0.0f; + uint32_t strokecolor = fill_color; + if (bThin) + strokecolor = (((fill_alpha >> 2) << 24) | (strokecolor & 0x00ffffff)); + CFX_Matrix* pMatrix = nullptr; + if (pObject2Device && !pObject2Device->IsIdentity()) + pMatrix = (CFX_Matrix*)pObject2Device; + int smooth_path = FX_ZEROAREA_FILL; + if (fill_mode & FXFILL_NOPATHSMOOTH) + smooth_path |= FXFILL_NOPATHSMOOTH; + m_pDeviceDriver->DrawPath(&newPath, pMatrix, &graphState, 0, strokecolor, + smooth_path, blend_type); + } + } + if ((fill_mode & 3) && fill_alpha && stroke_alpha < 0xff && + (fill_mode & FX_FILL_STROKE)) { + if (m_RenderCaps & FXRC_FILLSTROKE_PATH) { + return m_pDeviceDriver->DrawPath(pPathData, pObject2Device, pGraphState, + fill_color, stroke_color, fill_mode, + blend_type); + } + return DrawFillStrokePath(pPathData, pObject2Device, pGraphState, + fill_color, stroke_color, fill_mode, blend_type); + } + return m_pDeviceDriver->DrawPath(pPathData, pObject2Device, pGraphState, + fill_color, stroke_color, fill_mode, + blend_type); +} + +// This can be removed once PDFium entirely relies on Skia +FX_BOOL CFX_RenderDevice::DrawFillStrokePath( + const CFX_PathData* pPathData, + const CFX_Matrix* pObject2Device, + const CFX_GraphStateData* pGraphState, + uint32_t fill_color, + uint32_t stroke_color, + int fill_mode, + int blend_type) { + if (!(m_RenderCaps & FXRC_GET_BITS)) + return FALSE; + CFX_FloatRect bbox; + if (pGraphState) { + bbox = pPathData->GetBoundingBox(pGraphState->m_LineWidth, + pGraphState->m_MiterLimit); + } else { + bbox = pPathData->GetBoundingBox(); + } + if (pObject2Device) + bbox.Transform(pObject2Device); + CFX_Matrix ctm = GetCTM(); + FX_FLOAT fScaleX = FXSYS_fabs(ctm.a); + FX_FLOAT fScaleY = FXSYS_fabs(ctm.d); + FX_RECT rect = bbox.GetOuterRect(); + CFX_DIBitmap bitmap, Backdrop; + if (!CreateCompatibleBitmap(&bitmap, FXSYS_round(rect.Width() * fScaleX), + FXSYS_round(rect.Height() * fScaleY))) { + return FALSE; + } + if (bitmap.HasAlpha()) { + bitmap.Clear(0); + Backdrop.Copy(&bitmap); + } else { + if (!m_pDeviceDriver->GetDIBits(&bitmap, rect.left, rect.top)) + return FALSE; + Backdrop.Copy(&bitmap); + } + CFX_FxgeDevice bitmap_device; + bitmap_device.Attach(&bitmap, false, &Backdrop, true); + CFX_Matrix matrix; + if (pObject2Device) + matrix = *pObject2Device; + matrix.TranslateI(-rect.left, -rect.top); + matrix.Concat(fScaleX, 0, 0, fScaleY, 0, 0); + if (!bitmap_device.GetDeviceDriver()->DrawPath( + pPathData, &matrix, pGraphState, fill_color, stroke_color, fill_mode, + blend_type)) { + return FALSE; + } + FX_RECT src_rect(0, 0, FXSYS_round(rect.Width() * fScaleX), + FXSYS_round(rect.Height() * fScaleY)); + return m_pDeviceDriver->SetDIBits(&bitmap, 0, &src_rect, rect.left, rect.top, + FXDIB_BLEND_NORMAL); +} + +FX_BOOL CFX_RenderDevice::SetPixel(int x, int y, uint32_t color) { + if (m_pDeviceDriver->SetPixel(x, y, color)) + return TRUE; + + FX_RECT rect(x, y, x + 1, y + 1); + return FillRectWithBlend(&rect, color, FXDIB_BLEND_NORMAL); +} + +FX_BOOL CFX_RenderDevice::FillRectWithBlend(const FX_RECT* pRect, + uint32_t fill_color, + int blend_type) { + if (m_pDeviceDriver->FillRectWithBlend(pRect, fill_color, blend_type)) + return TRUE; + + if (!(m_RenderCaps & FXRC_GET_BITS)) + return FALSE; + + CFX_DIBitmap bitmap; + if (!CreateCompatibleBitmap(&bitmap, pRect->Width(), pRect->Height())) + return FALSE; + + if (!m_pDeviceDriver->GetDIBits(&bitmap, pRect->left, pRect->top)) + return FALSE; + + if (!bitmap.CompositeRect(0, 0, pRect->Width(), pRect->Height(), fill_color, + 0, nullptr)) { + return FALSE; + } + FX_RECT src_rect(0, 0, pRect->Width(), pRect->Height()); + m_pDeviceDriver->SetDIBits(&bitmap, 0, &src_rect, pRect->left, pRect->top, + FXDIB_BLEND_NORMAL); + return TRUE; +} + +FX_BOOL CFX_RenderDevice::DrawCosmeticLineWithFillModeAndBlend(FX_FLOAT x1, + FX_FLOAT y1, + FX_FLOAT x2, + FX_FLOAT y2, + uint32_t color, + int fill_mode, + int blend_type) { + if ((color >= 0xff000000) && + m_pDeviceDriver->DrawCosmeticLine(x1, y1, x2, y2, color, blend_type)) { + return TRUE; + } + CFX_GraphStateData graph_state; + CFX_PathData path; + path.SetPointCount(2); + path.SetPoint(0, x1, y1, FXPT_MOVETO); + path.SetPoint(1, x2, y2, FXPT_LINETO); + return m_pDeviceDriver->DrawPath(&path, nullptr, &graph_state, 0, color, + fill_mode, blend_type); +} + +FX_BOOL CFX_RenderDevice::GetDIBits(CFX_DIBitmap* pBitmap, int left, int top) { + if (!(m_RenderCaps & FXRC_GET_BITS)) + return FALSE; + return m_pDeviceDriver->GetDIBits(pBitmap, left, top); +} + +CFX_DIBitmap* CFX_RenderDevice::GetBackDrop() { + return m_pDeviceDriver->GetBackDrop(); +} + +FX_BOOL CFX_RenderDevice::SetDIBitsWithBlend(const CFX_DIBSource* pBitmap, + int left, + int top, + int blend_mode) { + ASSERT(!pBitmap->IsAlphaMask()); + CFX_Matrix ctm = GetCTM(); + FX_FLOAT fScaleX = FXSYS_fabs(ctm.a); + FX_FLOAT fScaleY = FXSYS_fabs(ctm.d); + FX_RECT dest_rect(left, top, + FXSYS_round(left + pBitmap->GetWidth() / fScaleX), + FXSYS_round(top + pBitmap->GetHeight() / fScaleY)); + dest_rect.Intersect(m_ClipBox); + if (dest_rect.IsEmpty()) + return TRUE; + FX_RECT src_rect(dest_rect.left - left, dest_rect.top - top, + dest_rect.left - left + dest_rect.Width(), + dest_rect.top - top + dest_rect.Height()); + src_rect.left = FXSYS_round(src_rect.left * fScaleX); + src_rect.top = FXSYS_round(src_rect.top * fScaleY); + src_rect.right = FXSYS_round(src_rect.right * fScaleX); + src_rect.bottom = FXSYS_round(src_rect.bottom * fScaleY); + if ((blend_mode != FXDIB_BLEND_NORMAL && !(m_RenderCaps & FXRC_BLEND_MODE)) || + (pBitmap->HasAlpha() && !(m_RenderCaps & FXRC_ALPHA_IMAGE))) { + if (!(m_RenderCaps & FXRC_GET_BITS)) + return FALSE; + int bg_pixel_width = FXSYS_round(dest_rect.Width() * fScaleX); + int bg_pixel_height = FXSYS_round(dest_rect.Height() * fScaleY); + CFX_DIBitmap background; + if (!background.Create( + bg_pixel_width, bg_pixel_height, + (m_RenderCaps & FXRC_CMYK_OUTPUT) ? FXDIB_Cmyk : FXDIB_Rgb32)) { + return FALSE; + } + if (!m_pDeviceDriver->GetDIBits(&background, dest_rect.left, + dest_rect.top)) { + return FALSE; + } + if (!background.CompositeBitmap(0, 0, bg_pixel_width, bg_pixel_height, + pBitmap, src_rect.left, src_rect.top, + blend_mode, nullptr, FALSE, nullptr)) { + return FALSE; + } + FX_RECT rect(0, 0, bg_pixel_width, bg_pixel_height); + return m_pDeviceDriver->SetDIBits(&background, 0, &rect, dest_rect.left, + dest_rect.top, FXDIB_BLEND_NORMAL); + } + return m_pDeviceDriver->SetDIBits(pBitmap, 0, &src_rect, dest_rect.left, + dest_rect.top, blend_mode); +} + +FX_BOOL CFX_RenderDevice::StretchDIBitsWithFlagsAndBlend( + const CFX_DIBSource* pBitmap, + int left, + int top, + int dest_width, + int dest_height, + uint32_t flags, + int blend_mode) { + FX_RECT dest_rect(left, top, left + dest_width, top + dest_height); + FX_RECT clip_box = m_ClipBox; + clip_box.Intersect(dest_rect); + if (clip_box.IsEmpty()) + return TRUE; + return m_pDeviceDriver->StretchDIBits(pBitmap, 0, left, top, dest_width, + dest_height, &clip_box, flags, + blend_mode); +} + +FX_BOOL CFX_RenderDevice::SetBitMask(const CFX_DIBSource* pBitmap, + int left, + int top, + uint32_t argb) { + FX_RECT src_rect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()); + return m_pDeviceDriver->SetDIBits(pBitmap, argb, &src_rect, left, top, + FXDIB_BLEND_NORMAL); +} + +FX_BOOL CFX_RenderDevice::StretchBitMask(const CFX_DIBSource* pBitmap, + int left, + int top, + int dest_width, + int dest_height, + uint32_t color) { + return StretchBitMaskWithFlags(pBitmap, left, top, dest_width, dest_height, + color, 0); +} + +FX_BOOL CFX_RenderDevice::StretchBitMaskWithFlags(const CFX_DIBSource* pBitmap, + int left, + int top, + int dest_width, + int dest_height, + uint32_t argb, + uint32_t flags) { + FX_RECT dest_rect(left, top, left + dest_width, top + dest_height); + FX_RECT clip_box = m_ClipBox; + clip_box.Intersect(dest_rect); + return m_pDeviceDriver->StretchDIBits(pBitmap, argb, left, top, dest_width, + dest_height, &clip_box, flags, + FXDIB_BLEND_NORMAL); +} + +FX_BOOL CFX_RenderDevice::StartDIBitsWithBlend(const CFX_DIBSource* pBitmap, + int bitmap_alpha, + uint32_t argb, + const CFX_Matrix* pMatrix, + uint32_t flags, + void*& handle, + int blend_mode) { + return m_pDeviceDriver->StartDIBits(pBitmap, bitmap_alpha, argb, pMatrix, + flags, handle, blend_mode); +} + +FX_BOOL CFX_RenderDevice::ContinueDIBits(void* handle, IFX_Pause* pPause) { + return m_pDeviceDriver->ContinueDIBits(handle, pPause); +} + +void CFX_RenderDevice::CancelDIBits(void* handle) { + m_pDeviceDriver->CancelDIBits(handle); +} + +#ifdef _SKIA_SUPPORT_ + +void CFX_RenderDevice::DebugVerifyBitmapIsPreMultiplied() const { + SkASSERT(0); +} +#endif + +FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars, + const FXTEXT_CHARPOS* pCharPos, + CFX_Font* pFont, + CFX_FontCache* pCache, + FX_FLOAT font_size, + const CFX_Matrix* pText2Device, + uint32_t fill_color, + uint32_t text_flags) { + int nativetext_flags = text_flags; + if (m_DeviceClass != FXDC_DISPLAY) { + if (!(text_flags & FXTEXT_PRINTGRAPHICTEXT)) { + if (ShouldDrawDeviceText(pFont, text_flags) && + m_pDeviceDriver->DrawDeviceText(nChars, pCharPos, pFont, pCache, + pText2Device, font_size, + fill_color)) { + return TRUE; + } + } + if (FXARGB_A(fill_color) < 255) + return FALSE; + } else if (!(text_flags & FXTEXT_NO_NATIVETEXT)) { + if (ShouldDrawDeviceText(pFont, text_flags) && + m_pDeviceDriver->DrawDeviceText(nChars, pCharPos, pFont, pCache, + pText2Device, font_size, fill_color)) { + return TRUE; + } + } + CFX_Matrix char2device; + CFX_Matrix text2Device; + if (pText2Device) { + char2device = *pText2Device; + text2Device = *pText2Device; + } + char2device.Scale(font_size, -font_size); + if (FXSYS_fabs(char2device.a) + FXSYS_fabs(char2device.b) > 50 * 1.0f || + ((m_DeviceClass == FXDC_PRINTER) && + !(text_flags & FXTEXT_PRINTIMAGETEXT))) { + if (pFont->GetFace() || + (pFont->GetSubstFont()->m_SubstFlags & FXFONT_SUBST_GLYPHPATH)) { + int nPathFlags = + (text_flags & FXTEXT_NOSMOOTH) == 0 ? 0 : FXFILL_NOPATHSMOOTH; + return DrawTextPathWithFlags(nChars, pCharPos, pFont, pCache, font_size, + pText2Device, nullptr, nullptr, fill_color, + 0, nullptr, nPathFlags); + } + } + int anti_alias = FXFT_RENDER_MODE_MONO; + bool bNormal = false; + if ((text_flags & FXTEXT_NOSMOOTH) == 0) { + if (m_DeviceClass == FXDC_DISPLAY && m_bpp > 1) { + if (!CFX_GEModule::Get()->GetFontMgr()->FTLibrarySupportsHinting()) { + // Some Freetype implementations (like the one packaged with Fedora) do + // not support hinting due to patents 6219025, 6239783, 6307566, + // 6225973, 6243070, 6393145, 6421054, 6282327, and 6624828; the latest + // one expires 10/7/19. This makes LCD antialiasing very ugly, so we + // instead fall back on NORMAL antialiasing. + anti_alias = FXFT_RENDER_MODE_NORMAL; + } else if ((m_RenderCaps & (FXRC_ALPHA_OUTPUT | FXRC_CMYK_OUTPUT))) { + anti_alias = FXFT_RENDER_MODE_LCD; + bNormal = true; + } else if (m_bpp < 16) { + anti_alias = FXFT_RENDER_MODE_NORMAL; + } else { + anti_alias = FXFT_RENDER_MODE_LCD; + + bool bClearType = false; + if (pFont->GetFace() || + (pFont->GetSubstFont()->m_SubstFlags & FXFONT_SUBST_CLEARTYPE)) { + bClearType = !!(text_flags & FXTEXT_CLEARTYPE); + } + bNormal = !bClearType; + } + } + } + if (!pCache) + pCache = CFX_GEModule::Get()->GetFontCache(); + CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont); + CFX_AutoFontCache autoFontCache(pCache, pFont); + std::vector glyphs(nChars); + CFX_Matrix matrixCTM = GetCTM(); + FX_FLOAT scale_x = FXSYS_fabs(matrixCTM.a); + FX_FLOAT scale_y = FXSYS_fabs(matrixCTM.d); + CFX_Matrix deviceCtm = char2device; + deviceCtm.Concat(scale_x, 0, 0, scale_y, 0, 0); + text2Device.Concat(scale_x, 0, 0, scale_y, 0, 0); + for (size_t i = 0; i < glyphs.size(); ++i) { + FXTEXT_GLYPHPOS& glyph = glyphs[i]; + const FXTEXT_CHARPOS& charpos = pCharPos[i]; + glyph.m_fOriginX = charpos.m_OriginX; + glyph.m_fOriginY = charpos.m_OriginY; + text2Device.Transform(glyph.m_fOriginX, glyph.m_fOriginY); + if (anti_alias < FXFT_RENDER_MODE_LCD) + glyph.m_OriginX = FXSYS_round(glyph.m_fOriginX); + else + glyph.m_OriginX = (int)FXSYS_floor(glyph.m_fOriginX); + glyph.m_OriginY = FXSYS_round(glyph.m_fOriginY); + if (charpos.m_bGlyphAdjust) { + CFX_Matrix new_matrix( + charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1], + charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0); + new_matrix.Concat(deviceCtm); + glyph.m_pGlyph = pFaceCache->LoadGlyphBitmap( + pFont, charpos.m_GlyphIndex, charpos.m_bFontStyle, &new_matrix, + charpos.m_FontCharWidth, anti_alias, nativetext_flags); + } else { + glyph.m_pGlyph = pFaceCache->LoadGlyphBitmap( + pFont, charpos.m_GlyphIndex, charpos.m_bFontStyle, &deviceCtm, + charpos.m_FontCharWidth, anti_alias, nativetext_flags); + } + } + if (anti_alias < FXFT_RENDER_MODE_LCD && glyphs.size() > 1) + AdjustGlyphSpace(&glyphs); + + FX_RECT bmp_rect1 = FXGE_GetGlyphsBBox(glyphs, anti_alias); + if (scale_x > 1 && scale_y > 1) { + bmp_rect1.left--; + bmp_rect1.top--; + bmp_rect1.right++; + bmp_rect1.bottom++; + } + FX_RECT bmp_rect(FXSYS_round((FX_FLOAT)(bmp_rect1.left) / scale_x), + FXSYS_round((FX_FLOAT)(bmp_rect1.top) / scale_y), + FXSYS_round((FX_FLOAT)bmp_rect1.right / scale_x), + FXSYS_round((FX_FLOAT)bmp_rect1.bottom / scale_y)); + bmp_rect.Intersect(m_ClipBox); + if (bmp_rect.IsEmpty()) + return TRUE; + int pixel_width = FXSYS_round(bmp_rect.Width() * scale_x); + int pixel_height = FXSYS_round(bmp_rect.Height() * scale_y); + int pixel_left = FXSYS_round(bmp_rect.left * scale_x); + int pixel_top = FXSYS_round(bmp_rect.top * scale_y); + if (anti_alias == FXFT_RENDER_MODE_MONO) { + CFX_DIBitmap bitmap; + if (!bitmap.Create(pixel_width, pixel_height, FXDIB_1bppMask)) + return FALSE; + bitmap.Clear(0); + for (const FXTEXT_GLYPHPOS& glyph : glyphs) { + if (!glyph.m_pGlyph) + continue; + const CFX_DIBitmap* pGlyph = &glyph.m_pGlyph->m_Bitmap; + bitmap.TransferBitmap( + glyph.m_OriginX + glyph.m_pGlyph->m_Left - pixel_left, + glyph.m_OriginY - glyph.m_pGlyph->m_Top - pixel_top, + pGlyph->GetWidth(), pGlyph->GetHeight(), pGlyph, 0, 0); + } + return SetBitMask(&bitmap, bmp_rect.left, bmp_rect.top, fill_color); + } + CFX_DIBitmap bitmap; + if (m_bpp == 8) { + if (!bitmap.Create(pixel_width, pixel_height, FXDIB_8bppMask)) + return FALSE; + } else { + if (!CreateCompatibleBitmap(&bitmap, pixel_width, pixel_height)) + return FALSE; + } + if (!bitmap.HasAlpha() && !bitmap.IsAlphaMask()) { + bitmap.Clear(0xFFFFFFFF); + if (!GetDIBits(&bitmap, bmp_rect.left, bmp_rect.top)) + return FALSE; + } else { + bitmap.Clear(0); + if (bitmap.m_pAlphaMask) + bitmap.m_pAlphaMask->Clear(0); + } + int dest_width = pixel_width; + int a = 0; + int r = 0; + int g = 0; + int b = 0; + if (anti_alias == FXFT_RENDER_MODE_LCD) + ArgbDecode(fill_color, a, r, g, b); + for (const FXTEXT_GLYPHPOS& glyph : glyphs) { + if (!glyph.m_pGlyph) + continue; + const CFX_DIBitmap* pGlyph = &glyph.m_pGlyph->m_Bitmap; + int left = glyph.m_OriginX + glyph.m_pGlyph->m_Left - pixel_left; + int top = glyph.m_OriginY - glyph.m_pGlyph->m_Top - pixel_top; + int ncols = pGlyph->GetWidth(); + int nrows = pGlyph->GetHeight(); + if (anti_alias == FXFT_RENDER_MODE_NORMAL) { + if (!bitmap.CompositeMask(left, top, ncols, nrows, pGlyph, fill_color, 0, + 0, FXDIB_BLEND_NORMAL, nullptr, FALSE, 0, + nullptr)) { + return FALSE; + } + continue; + } + bool bBGRStripe = !!(text_flags & FXTEXT_BGR_STRIPE); + ncols /= 3; + int x_subpixel = (int)(glyph.m_fOriginX * 3) % 3; + int start_col = std::max(left, 0); + int end_col = std::min(left + ncols, dest_width); + if (start_col >= end_col) + continue; + DrawNormalTextHelper(&bitmap, pGlyph, nrows, left, top, start_col, end_col, + bNormal, bBGRStripe, x_subpixel, a, r, g, b); + } + if (bitmap.IsAlphaMask()) + SetBitMask(&bitmap, bmp_rect.left, bmp_rect.top, fill_color); + else + SetDIBits(&bitmap, bmp_rect.left, bmp_rect.top); + return TRUE; +} + +FX_BOOL CFX_RenderDevice::DrawTextPathWithFlags( + int nChars, + const FXTEXT_CHARPOS* pCharPos, + CFX_Font* pFont, + CFX_FontCache* pCache, + FX_FLOAT font_size, + const CFX_Matrix* pText2User, + const CFX_Matrix* pUser2Device, + const CFX_GraphStateData* pGraphState, + uint32_t fill_color, + FX_ARGB stroke_color, + CFX_PathData* pClippingPath, + int nFlag) { + if (!pCache) + pCache = CFX_GEModule::Get()->GetFontCache(); + CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont); + CFX_AutoFontCache autoFontCache(pCache, pFont); + for (int iChar = 0; iChar < nChars; iChar++) { + const FXTEXT_CHARPOS& charpos = pCharPos[iChar]; + CFX_Matrix matrix; + if (charpos.m_bGlyphAdjust) { + matrix.Set(charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1], + charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0); + } + matrix.Concat(font_size, 0, 0, font_size, charpos.m_OriginX, + charpos.m_OriginY); + const CFX_PathData* pPath = pFaceCache->LoadGlyphPath( + pFont, charpos.m_GlyphIndex, charpos.m_FontCharWidth); + if (!pPath) + continue; + matrix.Concat(*pText2User); + CFX_PathData TransformedPath(*pPath); + TransformedPath.Transform(&matrix); + if (fill_color || stroke_color) { + int fill_mode = nFlag; + if (fill_color) + fill_mode |= FXFILL_WINDING; + fill_mode |= FX_FILL_TEXT_MODE; + if (!DrawPathWithBlend(&TransformedPath, pUser2Device, pGraphState, + fill_color, stroke_color, fill_mode, + FXDIB_BLEND_NORMAL)) { + return FALSE; + } + } + if (pClippingPath) + pClippingPath->Append(&TransformedPath, pUser2Device); + } + return TRUE; +} diff --git a/core/fxge/ge/fx_ge_device.cpp b/core/fxge/ge/fx_ge_device.cpp deleted file mode 100644 index 1b4d9c8144..0000000000 --- a/core/fxge/ge/fx_ge_device.cpp +++ /dev/null @@ -1,504 +0,0 @@ -// Copyright 2014 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. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "core/fxge/include/cfx_pathdata.h" -#include "core/fxge/include/fx_ge.h" -#include "core/fxge/include/ifx_renderdevicedriver.h" - -#if defined _SKIA_SUPPORT_ -#include "third_party/skia/include/core/SkTypes.h" -#endif - -CFX_RenderDevice::CFX_RenderDevice() - : m_pBitmap(nullptr), - m_Width(0), - m_Height(0), - m_bpp(0), - m_RenderCaps(0), - m_DeviceClass(0) {} - -CFX_RenderDevice::~CFX_RenderDevice() {} - -#ifdef _SKIA_SUPPORT_ -void CFX_RenderDevice::Flush() { - m_pDeviceDriver.reset(); -} -#endif - -void CFX_RenderDevice::SetDeviceDriver( - std::unique_ptr pDriver) { - m_pDeviceDriver = std::move(pDriver); - InitDeviceInfo(); -} - -void CFX_RenderDevice::InitDeviceInfo() { - m_Width = m_pDeviceDriver->GetDeviceCaps(FXDC_PIXEL_WIDTH); - m_Height = m_pDeviceDriver->GetDeviceCaps(FXDC_PIXEL_HEIGHT); - m_bpp = m_pDeviceDriver->GetDeviceCaps(FXDC_BITS_PIXEL); - m_RenderCaps = m_pDeviceDriver->GetDeviceCaps(FXDC_RENDER_CAPS); - m_DeviceClass = m_pDeviceDriver->GetDeviceCaps(FXDC_DEVICE_CLASS); - if (!m_pDeviceDriver->GetClipBox(&m_ClipBox)) { - m_ClipBox.left = 0; - m_ClipBox.top = 0; - m_ClipBox.right = m_Width; - m_ClipBox.bottom = m_Height; - } -} - -FX_BOOL CFX_RenderDevice::StartRendering() { - return m_pDeviceDriver->StartRendering(); -} - -void CFX_RenderDevice::EndRendering() { - m_pDeviceDriver->EndRendering(); -} - -void CFX_RenderDevice::SaveState() { - m_pDeviceDriver->SaveState(); -} - -void CFX_RenderDevice::RestoreState(bool bKeepSaved) { - m_pDeviceDriver->RestoreState(bKeepSaved); - UpdateClipBox(); -} - -int CFX_RenderDevice::GetDeviceCaps(int caps_id) const { - return m_pDeviceDriver->GetDeviceCaps(caps_id); -} -CFX_Matrix CFX_RenderDevice::GetCTM() const { - return m_pDeviceDriver->GetCTM(); -} - -FX_BOOL CFX_RenderDevice::CreateCompatibleBitmap(CFX_DIBitmap* pDIB, - int width, - int height) const { - if (m_RenderCaps & FXRC_CMYK_OUTPUT) { - return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT - ? FXDIB_Cmyka - : FXDIB_Cmyk); - } - if (m_RenderCaps & FXRC_BYTEMASK_OUTPUT) { - return pDIB->Create(width, height, FXDIB_8bppMask); - } -#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ - return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT - ? FXDIB_Argb - : FXDIB_Rgb32); -#else - return pDIB->Create( - width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Argb : FXDIB_Rgb); -#endif -} - -FX_BOOL CFX_RenderDevice::SetClip_PathFill(const CFX_PathData* pPathData, - const CFX_Matrix* pObject2Device, - int fill_mode) { - if (!m_pDeviceDriver->SetClip_PathFill(pPathData, pObject2Device, - fill_mode)) { - return FALSE; - } - UpdateClipBox(); - return TRUE; -} - -FX_BOOL CFX_RenderDevice::SetClip_PathStroke( - const CFX_PathData* pPathData, - const CFX_Matrix* pObject2Device, - const CFX_GraphStateData* pGraphState) { - if (!m_pDeviceDriver->SetClip_PathStroke(pPathData, pObject2Device, - pGraphState)) { - return FALSE; - } - UpdateClipBox(); - return TRUE; -} - -FX_BOOL CFX_RenderDevice::SetClip_Rect(const FX_RECT& rect) { - CFX_PathData path; - path.AppendRect(rect.left, rect.bottom, rect.right, rect.top); - if (!SetClip_PathFill(&path, nullptr, FXFILL_WINDING)) - return FALSE; - - UpdateClipBox(); - return TRUE; -} - -void CFX_RenderDevice::UpdateClipBox() { - if (m_pDeviceDriver->GetClipBox(&m_ClipBox)) { - return; - } - m_ClipBox.left = 0; - m_ClipBox.top = 0; - m_ClipBox.right = m_Width; - m_ClipBox.bottom = m_Height; -} - -FX_BOOL CFX_RenderDevice::DrawPathWithBlend( - const CFX_PathData* pPathData, - const CFX_Matrix* pObject2Device, - const CFX_GraphStateData* pGraphState, - uint32_t fill_color, - uint32_t stroke_color, - int fill_mode, - int blend_type) { - uint8_t stroke_alpha = pGraphState ? FXARGB_A(stroke_color) : 0; - uint8_t fill_alpha = (fill_mode & 3) ? FXARGB_A(fill_color) : 0; - if (stroke_alpha == 0 && pPathData->GetPointCount() == 2) { - FX_PATHPOINT* pPoints = pPathData->GetPoints(); - FX_FLOAT x1, x2, y1, y2; - if (pObject2Device) { - pObject2Device->Transform(pPoints[0].m_PointX, pPoints[0].m_PointY, x1, - y1); - pObject2Device->Transform(pPoints[1].m_PointX, pPoints[1].m_PointY, x2, - y2); - } else { - x1 = pPoints[0].m_PointX; - y1 = pPoints[0].m_PointY; - x2 = pPoints[1].m_PointX; - y2 = pPoints[1].m_PointY; - } - DrawCosmeticLineWithFillModeAndBlend(x1, y1, x2, y2, fill_color, fill_mode, - blend_type); - return TRUE; - } - if ((pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) && - stroke_alpha == 0) { - CFX_FloatRect rect_f; - if (!(fill_mode & FXFILL_RECT_AA) && - pPathData->IsRect(pObject2Device, &rect_f)) { - FX_RECT rect_i = rect_f.GetOuterRect(); - - // Depending on the top/bottom, left/right values of the rect it's - // possible to overflow the Width() and Height() calculations. Check that - // the rect will have valid dimension before continuing. - if (!rect_i.Valid()) - return FALSE; - - int width = (int)FXSYS_ceil(rect_f.right - rect_f.left); - if (width < 1) { - width = 1; - if (rect_i.left == rect_i.right) { - rect_i.right++; - } - } - int height = (int)FXSYS_ceil(rect_f.top - rect_f.bottom); - if (height < 1) { - height = 1; - if (rect_i.bottom == rect_i.top) { - rect_i.bottom++; - } - } - if (rect_i.Width() >= width + 1) { - if (rect_f.left - (FX_FLOAT)(rect_i.left) > - (FX_FLOAT)(rect_i.right) - rect_f.right) { - rect_i.left++; - } else { - rect_i.right--; - } - } - if (rect_i.Height() >= height + 1) { - if (rect_f.top - (FX_FLOAT)(rect_i.top) > - (FX_FLOAT)(rect_i.bottom) - rect_f.bottom) { - rect_i.top++; - } else { - rect_i.bottom--; - } - } - if (FillRectWithBlend(&rect_i, fill_color, blend_type)) { - return TRUE; - } - } - } - if ((fill_mode & 3) && stroke_alpha == 0 && !(fill_mode & FX_FILL_STROKE) && - !(fill_mode & FX_FILL_TEXT_MODE)) { - CFX_PathData newPath; - FX_BOOL bThin = FALSE; - if (pPathData->GetZeroAreaPath(newPath, (CFX_Matrix*)pObject2Device, bThin, - m_pDeviceDriver->GetDriverType())) { - CFX_GraphStateData graphState; - graphState.m_LineWidth = 0.0f; - uint32_t strokecolor = fill_color; - if (bThin) { - strokecolor = (((fill_alpha >> 2) << 24) | (strokecolor & 0x00ffffff)); - } - CFX_Matrix* pMatrix = nullptr; - if (pObject2Device && !pObject2Device->IsIdentity()) { - pMatrix = (CFX_Matrix*)pObject2Device; - } - int smooth_path = FX_ZEROAREA_FILL; - if (fill_mode & FXFILL_NOPATHSMOOTH) { - smooth_path |= FXFILL_NOPATHSMOOTH; - } - m_pDeviceDriver->DrawPath(&newPath, pMatrix, &graphState, 0, strokecolor, - smooth_path, blend_type); - } - } - if ((fill_mode & 3) && fill_alpha && stroke_alpha < 0xff && - (fill_mode & FX_FILL_STROKE)) { - if (m_RenderCaps & FXRC_FILLSTROKE_PATH) { - return m_pDeviceDriver->DrawPath(pPathData, pObject2Device, pGraphState, - fill_color, stroke_color, fill_mode, - blend_type); - } - return DrawFillStrokePath(pPathData, pObject2Device, pGraphState, - fill_color, stroke_color, fill_mode, blend_type); - } - return m_pDeviceDriver->DrawPath(pPathData, pObject2Device, pGraphState, - fill_color, stroke_color, fill_mode, - blend_type); -} - -// This can be removed once PDFium entirely relies on Skia -FX_BOOL CFX_RenderDevice::DrawFillStrokePath( - const CFX_PathData* pPathData, - const CFX_Matrix* pObject2Device, - const CFX_GraphStateData* pGraphState, - uint32_t fill_color, - uint32_t stroke_color, - int fill_mode, - int blend_type) { - if (!(m_RenderCaps & FXRC_GET_BITS)) { - return FALSE; - } - CFX_FloatRect bbox; - if (pGraphState) { - bbox = pPathData->GetBoundingBox(pGraphState->m_LineWidth, - pGraphState->m_MiterLimit); - } else { - bbox = pPathData->GetBoundingBox(); - } - if (pObject2Device) { - bbox.Transform(pObject2Device); - } - CFX_Matrix ctm = GetCTM(); - FX_FLOAT fScaleX = FXSYS_fabs(ctm.a); - FX_FLOAT fScaleY = FXSYS_fabs(ctm.d); - FX_RECT rect = bbox.GetOuterRect(); - CFX_DIBitmap bitmap, Backdrop; - if (!CreateCompatibleBitmap(&bitmap, FXSYS_round(rect.Width() * fScaleX), - FXSYS_round(rect.Height() * fScaleY))) { - return FALSE; - } - if (bitmap.HasAlpha()) { - bitmap.Clear(0); - Backdrop.Copy(&bitmap); - } else { - if (!m_pDeviceDriver->GetDIBits(&bitmap, rect.left, rect.top)) - return FALSE; - Backdrop.Copy(&bitmap); - } - CFX_FxgeDevice bitmap_device; - bitmap_device.Attach(&bitmap, false, &Backdrop, true); - CFX_Matrix matrix; - if (pObject2Device) { - matrix = *pObject2Device; - } - matrix.TranslateI(-rect.left, -rect.top); - matrix.Concat(fScaleX, 0, 0, fScaleY, 0, 0); - if (!bitmap_device.GetDeviceDriver()->DrawPath( - pPathData, &matrix, pGraphState, fill_color, stroke_color, - fill_mode, blend_type)) { - return FALSE; - } - FX_RECT src_rect(0, 0, FXSYS_round(rect.Width() * fScaleX), - FXSYS_round(rect.Height() * fScaleY)); - return m_pDeviceDriver->SetDIBits(&bitmap, 0, &src_rect, rect.left, - rect.top, FXDIB_BLEND_NORMAL); -} - -FX_BOOL CFX_RenderDevice::SetPixel(int x, int y, uint32_t color) { - if (m_pDeviceDriver->SetPixel(x, y, color)) - return TRUE; - - FX_RECT rect(x, y, x + 1, y + 1); - return FillRectWithBlend(&rect, color, FXDIB_BLEND_NORMAL); -} - -FX_BOOL CFX_RenderDevice::FillRectWithBlend(const FX_RECT* pRect, - uint32_t fill_color, - int blend_type) { - if (m_pDeviceDriver->FillRectWithBlend(pRect, fill_color, blend_type)) - return TRUE; - - if (!(m_RenderCaps & FXRC_GET_BITS)) - return FALSE; - - CFX_DIBitmap bitmap; - if (!CreateCompatibleBitmap(&bitmap, pRect->Width(), pRect->Height())) - return FALSE; - - if (!m_pDeviceDriver->GetDIBits(&bitmap, pRect->left, pRect->top)) - return FALSE; - - if (!bitmap.CompositeRect(0, 0, pRect->Width(), pRect->Height(), fill_color, - 0, nullptr)) { - return FALSE; - } - FX_RECT src_rect(0, 0, pRect->Width(), pRect->Height()); - m_pDeviceDriver->SetDIBits(&bitmap, 0, &src_rect, pRect->left, pRect->top, - FXDIB_BLEND_NORMAL); - return TRUE; -} - -FX_BOOL CFX_RenderDevice::DrawCosmeticLineWithFillModeAndBlend(FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2, - uint32_t color, - int fill_mode, - int blend_type) { - if ((color >= 0xff000000) && - m_pDeviceDriver->DrawCosmeticLine(x1, y1, x2, y2, color, blend_type)) { - return TRUE; - } - CFX_GraphStateData graph_state; - CFX_PathData path; - path.SetPointCount(2); - path.SetPoint(0, x1, y1, FXPT_MOVETO); - path.SetPoint(1, x2, y2, FXPT_LINETO); - return m_pDeviceDriver->DrawPath(&path, nullptr, &graph_state, 0, color, - fill_mode, blend_type); -} - -FX_BOOL CFX_RenderDevice::GetDIBits(CFX_DIBitmap* pBitmap, int left, int top) { - if (!(m_RenderCaps & FXRC_GET_BITS)) - return FALSE; - return m_pDeviceDriver->GetDIBits(pBitmap, left, top); -} - -CFX_DIBitmap* CFX_RenderDevice::GetBackDrop() { - return m_pDeviceDriver->GetBackDrop(); -} - -FX_BOOL CFX_RenderDevice::SetDIBitsWithBlend(const CFX_DIBSource* pBitmap, - int left, - int top, - int blend_mode) { - ASSERT(!pBitmap->IsAlphaMask()); - CFX_Matrix ctm = GetCTM(); - FX_FLOAT fScaleX = FXSYS_fabs(ctm.a); - FX_FLOAT fScaleY = FXSYS_fabs(ctm.d); - FX_RECT dest_rect(left, top, - FXSYS_round(left + pBitmap->GetWidth() / fScaleX), - FXSYS_round(top + pBitmap->GetHeight() / fScaleY)); - dest_rect.Intersect(m_ClipBox); - if (dest_rect.IsEmpty()) { - return TRUE; - } - FX_RECT src_rect(dest_rect.left - left, dest_rect.top - top, - dest_rect.left - left + dest_rect.Width(), - dest_rect.top - top + dest_rect.Height()); - src_rect.left = FXSYS_round(src_rect.left * fScaleX); - src_rect.top = FXSYS_round(src_rect.top * fScaleY); - src_rect.right = FXSYS_round(src_rect.right * fScaleX); - src_rect.bottom = FXSYS_round(src_rect.bottom * fScaleY); - if ((blend_mode != FXDIB_BLEND_NORMAL && !(m_RenderCaps & FXRC_BLEND_MODE)) || - (pBitmap->HasAlpha() && !(m_RenderCaps & FXRC_ALPHA_IMAGE))) { - if (!(m_RenderCaps & FXRC_GET_BITS)) { - return FALSE; - } - int bg_pixel_width = FXSYS_round(dest_rect.Width() * fScaleX); - int bg_pixel_height = FXSYS_round(dest_rect.Height() * fScaleY); - CFX_DIBitmap background; - if (!background.Create( - bg_pixel_width, bg_pixel_height, - (m_RenderCaps & FXRC_CMYK_OUTPUT) ? FXDIB_Cmyk : FXDIB_Rgb32)) { - return FALSE; - } - if (!m_pDeviceDriver->GetDIBits(&background, dest_rect.left, - dest_rect.top)) { - return FALSE; - } - if (!background.CompositeBitmap(0, 0, bg_pixel_width, bg_pixel_height, - pBitmap, src_rect.left, src_rect.top, - blend_mode, nullptr, FALSE, nullptr)) { - return FALSE; - } - FX_RECT rect(0, 0, bg_pixel_width, bg_pixel_height); - return m_pDeviceDriver->SetDIBits(&background, 0, &rect, dest_rect.left, - dest_rect.top, FXDIB_BLEND_NORMAL); - } - return m_pDeviceDriver->SetDIBits(pBitmap, 0, &src_rect, dest_rect.left, - dest_rect.top, blend_mode); -} - -FX_BOOL CFX_RenderDevice::StretchDIBitsWithFlagsAndBlend( - const CFX_DIBSource* pBitmap, - int left, - int top, - int dest_width, - int dest_height, - uint32_t flags, - int blend_mode) { - FX_RECT dest_rect(left, top, left + dest_width, top + dest_height); - FX_RECT clip_box = m_ClipBox; - clip_box.Intersect(dest_rect); - if (clip_box.IsEmpty()) - return TRUE; - return m_pDeviceDriver->StretchDIBits(pBitmap, 0, left, top, dest_width, - dest_height, &clip_box, flags, - blend_mode); -} - -FX_BOOL CFX_RenderDevice::SetBitMask(const CFX_DIBSource* pBitmap, - int left, - int top, - uint32_t argb) { - FX_RECT src_rect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()); - return m_pDeviceDriver->SetDIBits(pBitmap, argb, &src_rect, left, top, - FXDIB_BLEND_NORMAL); -} - -FX_BOOL CFX_RenderDevice::StretchBitMask(const CFX_DIBSource* pBitmap, - int left, - int top, - int dest_width, - int dest_height, - uint32_t color) { - return StretchBitMaskWithFlags(pBitmap, left, top, dest_width, dest_height, - color, 0); -} - -FX_BOOL CFX_RenderDevice::StretchBitMaskWithFlags(const CFX_DIBSource* pBitmap, - int left, - int top, - int dest_width, - int dest_height, - uint32_t argb, - uint32_t flags) { - FX_RECT dest_rect(left, top, left + dest_width, top + dest_height); - FX_RECT clip_box = m_ClipBox; - clip_box.Intersect(dest_rect); - return m_pDeviceDriver->StretchDIBits(pBitmap, argb, left, top, dest_width, - dest_height, &clip_box, flags, - FXDIB_BLEND_NORMAL); -} - -FX_BOOL CFX_RenderDevice::StartDIBitsWithBlend(const CFX_DIBSource* pBitmap, - int bitmap_alpha, - uint32_t argb, - const CFX_Matrix* pMatrix, - uint32_t flags, - void*& handle, - int blend_mode) { - return m_pDeviceDriver->StartDIBits(pBitmap, bitmap_alpha, argb, pMatrix, - flags, handle, blend_mode); -} - -FX_BOOL CFX_RenderDevice::ContinueDIBits(void* handle, IFX_Pause* pPause) { - return m_pDeviceDriver->ContinueDIBits(handle, pPause); -} - -void CFX_RenderDevice::CancelDIBits(void* handle) { - m_pDeviceDriver->CancelDIBits(handle); -} - -#ifdef _SKIA_SUPPORT_ - -void CFX_RenderDevice::DebugVerifyBitmapIsPreMultiplied() const { - SkASSERT(0); -} -#endif diff --git a/core/fxge/ge/fx_ge_fontmap.cpp b/core/fxge/ge/fx_ge_fontmap.cpp index 70fcd88e2e..408f1e2689 100644 --- a/core/fxge/ge/fx_ge_fontmap.cpp +++ b/core/fxge/ge/fx_ge_fontmap.cpp @@ -6,7 +6,6 @@ #include "core/fxge/include/cfx_fontmapper.h" #include "core/fxge/include/ifx_systemfontinfo.h" -#include "core/fxge/include/fx_ge.h" CFX_SubstFont::CFX_SubstFont() { m_ExtHandle = nullptr; diff --git a/core/fxge/ge/fx_ge_path.cpp b/core/fxge/ge/fx_ge_path.cpp deleted file mode 100644 index e0e30b8870..0000000000 --- a/core/fxge/ge/fx_ge_path.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2014 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. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "core/fxcrt/include/fx_system.h" -#include "core/fxge/include/fx_ge.h" - -CFX_GraphStateData::CFX_GraphStateData() - : m_LineCap(LineCapButt), - m_DashCount(0), - m_DashArray(nullptr), - m_DashPhase(0), - m_LineJoin(LineJoinMiter), - m_MiterLimit(10 * 1.0f), - m_LineWidth(1.0f) {} - -CFX_GraphStateData::CFX_GraphStateData(const CFX_GraphStateData& src) { - m_DashArray = nullptr; - Copy(src); -} - -void CFX_GraphStateData::Copy(const CFX_GraphStateData& src) { - m_LineCap = src.m_LineCap; - m_DashCount = src.m_DashCount; - FX_Free(m_DashArray); - m_DashArray = nullptr; - m_DashPhase = src.m_DashPhase; - m_LineJoin = src.m_LineJoin; - m_MiterLimit = src.m_MiterLimit; - m_LineWidth = src.m_LineWidth; - if (m_DashCount) { - m_DashArray = FX_Alloc(FX_FLOAT, m_DashCount); - FXSYS_memcpy(m_DashArray, src.m_DashArray, m_DashCount * sizeof(FX_FLOAT)); - } -} - -CFX_GraphStateData::~CFX_GraphStateData() { - FX_Free(m_DashArray); -} - -void CFX_GraphStateData::SetDashCount(int count) { - FX_Free(m_DashArray); - m_DashArray = nullptr; - m_DashCount = count; - if (count == 0) { - return; - } - m_DashArray = FX_Alloc(FX_FLOAT, count); -} diff --git a/core/fxge/ge/fx_ge_text.cpp b/core/fxge/ge/fx_ge_text.cpp index 83655495b3..ac110b0291 100644 --- a/core/fxge/ge/fx_ge_text.cpp +++ b/core/fxge/ge/fx_ge_text.cpp @@ -13,7 +13,6 @@ #include "core/fxge/include/cfx_gemodule.h" #include "core/fxge/include/cfx_pathdata.h" #include "core/fxge/include/fx_freetype.h" -#include "core/fxge/include/fx_ge.h" #include "core/fxge/include/ifx_renderdevicedriver.h" #ifdef _SKIA_SUPPORT_ @@ -46,326 +45,6 @@ class ScopedFontTransform { FT_Face m_Face; }; -void AdjustGlyphSpace(std::vector* pGlyphAndPos) { - ASSERT(pGlyphAndPos->size() > 1); - std::vector& glyphs = *pGlyphAndPos; - bool bVertical = glyphs.back().m_OriginX == glyphs.front().m_OriginX; - if (!bVertical && (glyphs.back().m_OriginY != glyphs.front().m_OriginY)) - return; - - for (size_t i = glyphs.size() - 1; i > 1; --i) { - FXTEXT_GLYPHPOS& next = glyphs[i]; - int next_origin = bVertical ? next.m_OriginY : next.m_OriginX; - FX_FLOAT next_origin_f = bVertical ? next.m_fOriginY : next.m_fOriginX; - - FXTEXT_GLYPHPOS& current = glyphs[i - 1]; - int& current_origin = bVertical ? current.m_OriginY : current.m_OriginX; - FX_FLOAT current_origin_f = - bVertical ? current.m_fOriginY : current.m_fOriginX; - - int space = next_origin - current_origin; - FX_FLOAT space_f = next_origin_f - current_origin_f; - FX_FLOAT error = - FXSYS_fabs(space_f) - FXSYS_fabs(static_cast(space)); - if (error > 0.5f) - current_origin += space > 0 ? -1 : 1; - } -} - -const uint8_t g_TextGammaAdjust[256] = { - 0, 2, 3, 4, 6, 7, 8, 10, 11, 12, 13, 15, 16, 17, 18, - 19, 21, 22, 23, 24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, - 36, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, - 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, - 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, - 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, - 129, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, - 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 156, - 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, - 172, 173, 174, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, - 186, 187, 188, 189, 190, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, - 200, 201, 202, 203, 204, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, - 214, 215, 216, 217, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, - 228, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 239, 240, - 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 250, 251, 252, 253, 254, - 255, -}; - -int TextGammaAdjust(int value) { - ASSERT(value >= 0); - ASSERT(value <= 255); - return g_TextGammaAdjust[value]; -} - -int CalcAlpha(int src, int alpha) { - return src * alpha / 255; -} - -void Merge(uint8_t src, int channel, int alpha, uint8_t* dest) { - *dest = FXDIB_ALPHA_MERGE(*dest, channel, CalcAlpha(src, alpha)); -} - -void MergeGammaAdjust(uint8_t src, int channel, int alpha, uint8_t* dest) { - *dest = - FXDIB_ALPHA_MERGE(*dest, channel, CalcAlpha(TextGammaAdjust(src), alpha)); -} - -void MergeGammaAdjustBgr(const uint8_t* src, - int r, - int g, - int b, - int a, - uint8_t* dest) { - MergeGammaAdjust(src[0], b, a, &dest[0]); - MergeGammaAdjust(src[1], g, a, &dest[1]); - MergeGammaAdjust(src[2], r, a, &dest[2]); -} - -void MergeGammaAdjustRgb(const uint8_t* src, - int r, - int g, - int b, - int a, - uint8_t* dest) { - MergeGammaAdjust(src[2], b, a, &dest[0]); - MergeGammaAdjust(src[1], g, a, &dest[1]); - MergeGammaAdjust(src[0], r, a, &dest[2]); -} - -int AverageRgb(const uint8_t* src) { - return (src[0] + src[1] + src[2]) / 3; -} - -uint8_t CalculateDestAlpha(uint8_t back_alpha, int src_alpha) { - return back_alpha + src_alpha - back_alpha * src_alpha / 255; -} - -void ApplyDestAlpha(uint8_t back_alpha, - int src_alpha, - int r, - int g, - int b, - uint8_t* dest) { - uint8_t dest_alpha = CalculateDestAlpha(back_alpha, src_alpha); - int alpha_ratio = src_alpha * 255 / dest_alpha; - dest[0] = FXDIB_ALPHA_MERGE(dest[0], b, alpha_ratio); - dest[1] = FXDIB_ALPHA_MERGE(dest[1], g, alpha_ratio); - dest[2] = FXDIB_ALPHA_MERGE(dest[2], r, alpha_ratio); - dest[3] = dest_alpha; -} - -void NormalizeRgbDst(int src_value, int r, int g, int b, int a, uint8_t* dest) { - int src_alpha = CalcAlpha(TextGammaAdjust(src_value), a); - dest[0] = FXDIB_ALPHA_MERGE(dest[0], b, src_alpha); - dest[1] = FXDIB_ALPHA_MERGE(dest[1], g, src_alpha); - dest[2] = FXDIB_ALPHA_MERGE(dest[2], r, src_alpha); -} - -void NormalizeRgbSrc(int src_value, int r, int g, int b, int a, uint8_t* dest) { - int src_alpha = CalcAlpha(TextGammaAdjust(src_value), a); - if (src_alpha == 0) - return; - - dest[0] = FXDIB_ALPHA_MERGE(dest[0], b, src_alpha); - dest[1] = FXDIB_ALPHA_MERGE(dest[1], g, src_alpha); - dest[2] = FXDIB_ALPHA_MERGE(dest[2], r, src_alpha); -} - -void NormalizeArgbDest(int src_value, - int r, - int g, - int b, - int a, - uint8_t* dest) { - int src_alpha = CalcAlpha(TextGammaAdjust(src_value), a); - uint8_t back_alpha = dest[3]; - if (back_alpha == 0) { - FXARGB_SETDIB(dest, FXARGB_MAKE(src_alpha, r, g, b)); - } else if (src_alpha != 0) { - ApplyDestAlpha(back_alpha, src_alpha, r, g, b, dest); - } -} - -void NormalizeArgbSrc(int src_value, - int r, - int g, - int b, - int a, - uint8_t* dest) { - int src_alpha = CalcAlpha(TextGammaAdjust(src_value), a); - if (src_alpha == 0) - return; - - uint8_t back_alpha = dest[3]; - if (back_alpha == 0) { - FXARGB_SETDIB(dest, FXARGB_MAKE(src_alpha, r, g, b)); - } else { - ApplyDestAlpha(back_alpha, src_alpha, r, g, b, dest); - } -} - -void NextPixel(uint8_t** src_scan, uint8_t** dst_scan, int bpp) { - *src_scan += 3; - *dst_scan += bpp; -} - -void SetAlpha(uint8_t* alpha) { - alpha[3] = 255; -} - -void SetAlphaDoNothing(uint8_t* alpha) {} - -void DrawNormalTextHelper(CFX_DIBitmap* bitmap, - const CFX_DIBitmap* pGlyph, - int nrows, - int left, - int top, - int start_col, - int end_col, - bool bNormal, - bool bBGRStripe, - int x_subpixel, - int a, - int r, - int g, - int b) { - const bool has_alpha = bitmap->GetFormat() == FXDIB_Argb; - uint8_t* src_buf = pGlyph->GetBuffer(); - int src_pitch = pGlyph->GetPitch(); - uint8_t* dest_buf = bitmap->GetBuffer(); - int dest_pitch = bitmap->GetPitch(); - const int Bpp = has_alpha ? 4 : bitmap->GetBPP() / 8; - auto* pNormalizeSrcFunc = has_alpha ? &NormalizeArgbSrc : &NormalizeRgbDst; - auto* pNormalizeDstFunc = has_alpha ? &NormalizeArgbDest : &NormalizeRgbSrc; - auto* pSetAlpha = has_alpha ? &SetAlpha : &SetAlphaDoNothing; - - for (int row = 0; row < nrows; row++) { - int dest_row = row + top; - if (dest_row < 0 || dest_row >= bitmap->GetHeight()) - continue; - - uint8_t* src_scan = src_buf + row * src_pitch + (start_col - left) * 3; - uint8_t* dest_scan = dest_buf + dest_row * dest_pitch + start_col * Bpp; - if (bBGRStripe) { - if (x_subpixel == 0) { - for (int col = start_col; col < end_col; col++) { - if (has_alpha) { - Merge(src_scan[2], r, a, &dest_scan[2]); - Merge(src_scan[1], g, a, &dest_scan[1]); - Merge(src_scan[0], b, a, &dest_scan[0]); - } else { - MergeGammaAdjustBgr(&src_scan[0], r, g, b, a, &dest_scan[0]); - } - pSetAlpha(dest_scan); - NextPixel(&src_scan, &dest_scan, Bpp); - } - } else if (x_subpixel == 1) { - MergeGammaAdjust(src_scan[1], r, a, &dest_scan[2]); - MergeGammaAdjust(src_scan[0], g, a, &dest_scan[1]); - if (start_col > left) - MergeGammaAdjust(src_scan[-1], b, a, &dest_scan[0]); - pSetAlpha(dest_scan); - NextPixel(&src_scan, &dest_scan, Bpp); - for (int col = start_col + 1; col < end_col - 1; col++) { - MergeGammaAdjustBgr(&src_scan[-1], r, g, b, a, &dest_scan[0]); - pSetAlpha(dest_scan); - NextPixel(&src_scan, &dest_scan, Bpp); - } - } else { - MergeGammaAdjust(src_scan[0], r, a, &dest_scan[2]); - if (start_col > left) { - MergeGammaAdjust(src_scan[-1], g, a, &dest_scan[1]); - MergeGammaAdjust(src_scan[-2], b, a, &dest_scan[0]); - } - pSetAlpha(dest_scan); - NextPixel(&src_scan, &dest_scan, Bpp); - for (int col = start_col + 1; col < end_col - 1; col++) { - MergeGammaAdjustBgr(&src_scan[-2], r, g, b, a, &dest_scan[0]); - pSetAlpha(dest_scan); - NextPixel(&src_scan, &dest_scan, Bpp); - } - } - } else { - if (x_subpixel == 0) { - for (int col = start_col; col < end_col; col++) { - if (bNormal) { - int src_value = AverageRgb(&src_scan[0]); - pNormalizeDstFunc(src_value, r, g, b, a, dest_scan); - } else { - MergeGammaAdjustRgb(&src_scan[0], r, g, b, a, &dest_scan[0]); - pSetAlpha(dest_scan); - } - NextPixel(&src_scan, &dest_scan, Bpp); - } - } else if (x_subpixel == 1) { - if (bNormal) { - int src_value = start_col > left ? AverageRgb(&src_scan[-1]) - : (src_scan[0] + src_scan[1]) / 3; - pNormalizeSrcFunc(src_value, r, g, b, a, dest_scan); - } else { - if (start_col > left) - MergeGammaAdjust(src_scan[-1], r, a, &dest_scan[2]); - MergeGammaAdjust(src_scan[0], g, a, &dest_scan[1]); - MergeGammaAdjust(src_scan[1], b, a, &dest_scan[0]); - pSetAlpha(dest_scan); - } - NextPixel(&src_scan, &dest_scan, Bpp); - for (int col = start_col + 1; col < end_col; col++) { - if (bNormal) { - int src_value = AverageRgb(&src_scan[-1]); - pNormalizeDstFunc(src_value, r, g, b, a, dest_scan); - } else { - MergeGammaAdjustRgb(&src_scan[-1], r, g, b, a, &dest_scan[0]); - pSetAlpha(dest_scan); - } - NextPixel(&src_scan, &dest_scan, Bpp); - } - } else { - if (bNormal) { - int src_value = - start_col > left ? AverageRgb(&src_scan[-2]) : src_scan[0] / 3; - pNormalizeSrcFunc(src_value, r, g, b, a, dest_scan); - } else { - if (start_col > left) { - MergeGammaAdjust(src_scan[-2], r, a, &dest_scan[2]); - MergeGammaAdjust(src_scan[-1], g, a, &dest_scan[1]); - } - MergeGammaAdjust(src_scan[0], b, a, &dest_scan[0]); - pSetAlpha(dest_scan); - } - NextPixel(&src_scan, &dest_scan, Bpp); - for (int col = start_col + 1; col < end_col; col++) { - if (bNormal) { - int src_value = AverageRgb(&src_scan[-2]); - pNormalizeDstFunc(src_value, r, g, b, a, dest_scan); - } else { - MergeGammaAdjustRgb(&src_scan[-2], r, g, b, a, &dest_scan[0]); - pSetAlpha(dest_scan); - } - NextPixel(&src_scan, &dest_scan, Bpp); - } - } - } - } -} - -bool ShouldDrawDeviceText(const CFX_Font* pFont, uint32_t text_flags) { -#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ - if (text_flags & FXFONT_CIDFONT) - return false; - - const CFX_ByteString bsPsName = pFont->GetPsName(); - if (bsPsName.Find("+ZJHL") != -1) - return false; - - if (bsPsName == "CNAAJI+cmex10") - return false; -#endif - return true; -} - } // namespace FX_RECT FXGE_GetGlyphsBBox(const std::vector& glyphs, @@ -404,273 +83,6 @@ FX_RECT FXGE_GetGlyphsBBox(const std::vector& glyphs, return rect; } -FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars, - const FXTEXT_CHARPOS* pCharPos, - CFX_Font* pFont, - CFX_FontCache* pCache, - FX_FLOAT font_size, - const CFX_Matrix* pText2Device, - uint32_t fill_color, - uint32_t text_flags) { - int nativetext_flags = text_flags; - if (m_DeviceClass != FXDC_DISPLAY) { - if (!(text_flags & FXTEXT_PRINTGRAPHICTEXT)) { - if (ShouldDrawDeviceText(pFont, text_flags) && - m_pDeviceDriver->DrawDeviceText(nChars, pCharPos, pFont, pCache, - pText2Device, font_size, - fill_color)) { - return TRUE; - } - } - if (FXARGB_A(fill_color) < 255) - return FALSE; - } else if (!(text_flags & FXTEXT_NO_NATIVETEXT)) { - if (ShouldDrawDeviceText(pFont, text_flags) && - m_pDeviceDriver->DrawDeviceText(nChars, pCharPos, pFont, pCache, - pText2Device, font_size, fill_color)) { - return TRUE; - } - } - CFX_Matrix char2device; - CFX_Matrix text2Device; - if (pText2Device) { - char2device = *pText2Device; - text2Device = *pText2Device; - } - char2device.Scale(font_size, -font_size); - if (FXSYS_fabs(char2device.a) + FXSYS_fabs(char2device.b) > 50 * 1.0f || - ((m_DeviceClass == FXDC_PRINTER) && - !(text_flags & FXTEXT_PRINTIMAGETEXT))) { - if (pFont->GetFace() || - (pFont->GetSubstFont()->m_SubstFlags & FXFONT_SUBST_GLYPHPATH)) { - int nPathFlags = - (text_flags & FXTEXT_NOSMOOTH) == 0 ? 0 : FXFILL_NOPATHSMOOTH; - return DrawTextPathWithFlags(nChars, pCharPos, pFont, pCache, font_size, - pText2Device, nullptr, nullptr, fill_color, - 0, nullptr, nPathFlags); - } - } - int anti_alias = FXFT_RENDER_MODE_MONO; - bool bNormal = false; - if ((text_flags & FXTEXT_NOSMOOTH) == 0) { - if (m_DeviceClass == FXDC_DISPLAY && m_bpp > 1) { - if (!CFX_GEModule::Get()->GetFontMgr()->FTLibrarySupportsHinting()) { - // Some Freetype implementations (like the one packaged with Fedora) do - // not support hinting due to patents 6219025, 6239783, 6307566, - // 6225973, 6243070, 6393145, 6421054, 6282327, and 6624828; the latest - // one expires 10/7/19. This makes LCD antialiasing very ugly, so we - // instead fall back on NORMAL antialiasing. - anti_alias = FXFT_RENDER_MODE_NORMAL; - } else if ((m_RenderCaps & (FXRC_ALPHA_OUTPUT | FXRC_CMYK_OUTPUT))) { - anti_alias = FXFT_RENDER_MODE_LCD; - bNormal = true; - } else if (m_bpp < 16) { - anti_alias = FXFT_RENDER_MODE_NORMAL; - } else { - anti_alias = FXFT_RENDER_MODE_LCD; - - bool bClearType = false; - if (pFont->GetFace() || - (pFont->GetSubstFont()->m_SubstFlags & FXFONT_SUBST_CLEARTYPE)) { - bClearType = !!(text_flags & FXTEXT_CLEARTYPE); - } - bNormal = !bClearType; - } - } - } - if (!pCache) - pCache = CFX_GEModule::Get()->GetFontCache(); - - CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont); - CFX_AutoFontCache autoFontCache(pCache, pFont); - std::vector glyphs(nChars); - CFX_Matrix matrixCTM = GetCTM(); - FX_FLOAT scale_x = FXSYS_fabs(matrixCTM.a); - FX_FLOAT scale_y = FXSYS_fabs(matrixCTM.d); - CFX_Matrix deviceCtm = char2device; - deviceCtm.Concat(scale_x, 0, 0, scale_y, 0, 0); - text2Device.Concat(scale_x, 0, 0, scale_y, 0, 0); - for (size_t i = 0; i < glyphs.size(); ++i) { - FXTEXT_GLYPHPOS& glyph = glyphs[i]; - const FXTEXT_CHARPOS& charpos = pCharPos[i]; - glyph.m_fOriginX = charpos.m_OriginX; - glyph.m_fOriginY = charpos.m_OriginY; - text2Device.Transform(glyph.m_fOriginX, glyph.m_fOriginY); - if (anti_alias < FXFT_RENDER_MODE_LCD) { - glyph.m_OriginX = FXSYS_round(glyph.m_fOriginX); - } else { - glyph.m_OriginX = (int)FXSYS_floor(glyph.m_fOriginX); - } - glyph.m_OriginY = FXSYS_round(glyph.m_fOriginY); - if (charpos.m_bGlyphAdjust) { - CFX_Matrix new_matrix( - charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1], - charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0); - new_matrix.Concat(deviceCtm); - glyph.m_pGlyph = pFaceCache->LoadGlyphBitmap( - pFont, charpos.m_GlyphIndex, charpos.m_bFontStyle, &new_matrix, - charpos.m_FontCharWidth, anti_alias, nativetext_flags); - } else { - glyph.m_pGlyph = pFaceCache->LoadGlyphBitmap( - pFont, charpos.m_GlyphIndex, charpos.m_bFontStyle, &deviceCtm, - charpos.m_FontCharWidth, anti_alias, nativetext_flags); - } - } - if (anti_alias < FXFT_RENDER_MODE_LCD && glyphs.size() > 1) - AdjustGlyphSpace(&glyphs); - - FX_RECT bmp_rect1 = FXGE_GetGlyphsBBox(glyphs, anti_alias); - if (scale_x > 1 && scale_y > 1) { - bmp_rect1.left--; - bmp_rect1.top--; - bmp_rect1.right++; - bmp_rect1.bottom++; - } - FX_RECT bmp_rect(FXSYS_round((FX_FLOAT)(bmp_rect1.left) / scale_x), - FXSYS_round((FX_FLOAT)(bmp_rect1.top) / scale_y), - FXSYS_round((FX_FLOAT)bmp_rect1.right / scale_x), - FXSYS_round((FX_FLOAT)bmp_rect1.bottom / scale_y)); - bmp_rect.Intersect(m_ClipBox); - if (bmp_rect.IsEmpty()) - return TRUE; - - int pixel_width = FXSYS_round(bmp_rect.Width() * scale_x); - int pixel_height = FXSYS_round(bmp_rect.Height() * scale_y); - int pixel_left = FXSYS_round(bmp_rect.left * scale_x); - int pixel_top = FXSYS_round(bmp_rect.top * scale_y); - if (anti_alias == FXFT_RENDER_MODE_MONO) { - CFX_DIBitmap bitmap; - if (!bitmap.Create(pixel_width, pixel_height, FXDIB_1bppMask)) - return FALSE; - - bitmap.Clear(0); - for (const FXTEXT_GLYPHPOS& glyph : glyphs) { - if (!glyph.m_pGlyph) - continue; - - const CFX_DIBitmap* pGlyph = &glyph.m_pGlyph->m_Bitmap; - bitmap.TransferBitmap( - glyph.m_OriginX + glyph.m_pGlyph->m_Left - pixel_left, - glyph.m_OriginY - glyph.m_pGlyph->m_Top - pixel_top, - pGlyph->GetWidth(), pGlyph->GetHeight(), pGlyph, 0, 0); - } - return SetBitMask(&bitmap, bmp_rect.left, bmp_rect.top, fill_color); - } - CFX_DIBitmap bitmap; - if (m_bpp == 8) { - if (!bitmap.Create(pixel_width, pixel_height, FXDIB_8bppMask)) - return FALSE; - } else { - if (!CreateCompatibleBitmap(&bitmap, pixel_width, pixel_height)) - return FALSE; - } - - if (!bitmap.HasAlpha() && !bitmap.IsAlphaMask()) { - bitmap.Clear(0xFFFFFFFF); - if (!GetDIBits(&bitmap, bmp_rect.left, bmp_rect.top)) - return FALSE; - } else { - bitmap.Clear(0); - if (bitmap.m_pAlphaMask) { - bitmap.m_pAlphaMask->Clear(0); - } - } - - int dest_width = pixel_width; - int a = 0; - int r = 0; - int g = 0; - int b = 0; - if (anti_alias == FXFT_RENDER_MODE_LCD) - ArgbDecode(fill_color, a, r, g, b); - - for (const FXTEXT_GLYPHPOS& glyph : glyphs) { - if (!glyph.m_pGlyph) - continue; - - const CFX_DIBitmap* pGlyph = &glyph.m_pGlyph->m_Bitmap; - int left = glyph.m_OriginX + glyph.m_pGlyph->m_Left - pixel_left; - int top = glyph.m_OriginY - glyph.m_pGlyph->m_Top - pixel_top; - int ncols = pGlyph->GetWidth(); - int nrows = pGlyph->GetHeight(); - if (anti_alias == FXFT_RENDER_MODE_NORMAL) { - if (!bitmap.CompositeMask(left, top, ncols, nrows, pGlyph, fill_color, 0, - 0, FXDIB_BLEND_NORMAL, nullptr, FALSE, 0, - nullptr)) { - return FALSE; - } - continue; - } - - bool bBGRStripe = !!(text_flags & FXTEXT_BGR_STRIPE); - ncols /= 3; - int x_subpixel = (int)(glyph.m_fOriginX * 3) % 3; - int start_col = std::max(left, 0); - int end_col = std::min(left + ncols, dest_width); - if (start_col >= end_col) - continue; - - DrawNormalTextHelper(&bitmap, pGlyph, nrows, left, top, start_col, end_col, - bNormal, bBGRStripe, x_subpixel, a, r, g, b); - } - if (bitmap.IsAlphaMask()) - SetBitMask(&bitmap, bmp_rect.left, bmp_rect.top, fill_color); - else - SetDIBits(&bitmap, bmp_rect.left, bmp_rect.top); - return TRUE; -} - -FX_BOOL CFX_RenderDevice::DrawTextPathWithFlags( - int nChars, - const FXTEXT_CHARPOS* pCharPos, - CFX_Font* pFont, - CFX_FontCache* pCache, - FX_FLOAT font_size, - const CFX_Matrix* pText2User, - const CFX_Matrix* pUser2Device, - const CFX_GraphStateData* pGraphState, - uint32_t fill_color, - FX_ARGB stroke_color, - CFX_PathData* pClippingPath, - int nFlag) { - if (!pCache) - pCache = CFX_GEModule::Get()->GetFontCache(); - - CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont); - CFX_AutoFontCache autoFontCache(pCache, pFont); - for (int iChar = 0; iChar < nChars; iChar++) { - const FXTEXT_CHARPOS& charpos = pCharPos[iChar]; - CFX_Matrix matrix; - if (charpos.m_bGlyphAdjust) - matrix.Set(charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1], - charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0); - matrix.Concat(font_size, 0, 0, font_size, charpos.m_OriginX, - charpos.m_OriginY); - const CFX_PathData* pPath = pFaceCache->LoadGlyphPath( - pFont, charpos.m_GlyphIndex, charpos.m_FontCharWidth); - if (!pPath) - continue; - - matrix.Concat(*pText2User); - CFX_PathData TransformedPath(*pPath); - TransformedPath.Transform(&matrix); - if (fill_color || stroke_color) { - int fill_mode = nFlag; - if (fill_color) - fill_mode |= FXFILL_WINDING; - fill_mode |= FX_FILL_TEXT_MODE; - if (!DrawPathWithBlend(&TransformedPath, pUser2Device, pGraphState, - fill_color, stroke_color, fill_mode, - FXDIB_BLEND_NORMAL)) { - return FALSE; - } - } - if (pClippingPath) - pClippingPath->Append(&TransformedPath, pUser2Device); - } - return TRUE; -} - CFX_FontCache::CFX_FontCache() {} CFX_FontCache::~CFX_FontCache() { diff --git a/core/fxge/ifx_renderdevicedriver.cpp b/core/fxge/ifx_renderdevicedriver.cpp index 4fd685f996..9b7f985aee 100644 --- a/core/fxge/ifx_renderdevicedriver.cpp +++ b/core/fxge/ifx_renderdevicedriver.cpp @@ -8,6 +8,7 @@ #include "core/fxcrt/include/fx_coordinates.h" #include "core/fxge/include/cfx_pathdata.h" +#include "core/fxge/include/cfx_renderdevice.h" IFX_RenderDeviceDriver::~IFX_RenderDeviceDriver() {} diff --git a/core/fxge/include/cfx_fxgedevice.h b/core/fxge/include/cfx_fxgedevice.h new file mode 100644 index 0000000000..a5dba37c3e --- /dev/null +++ b/core/fxge/include/cfx_fxgedevice.h @@ -0,0 +1,39 @@ +// Copyright 2016 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. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FXGE_INCLUDE_CFX_FXGEDEVICE_H_ +#define CORE_FXGE_INCLUDE_CFX_FXGEDEVICE_H_ + +#include "core/fxge/include/cfx_renderdevice.h" +#include "core/fxge/include/fx_dib.h" + +class SkPictureRecorder; + +class CFX_FxgeDevice : public CFX_RenderDevice { + public: + CFX_FxgeDevice(); + ~CFX_FxgeDevice() override; + + bool Attach(CFX_DIBitmap* pBitmap, + bool bRgbByteOrder, + CFX_DIBitmap* pOriDevice, + bool bGroupKnockout); + bool Create(int width, + int height, + FXDIB_Format format, + CFX_DIBitmap* pOriDevice); + +#ifdef _SKIA_SUPPORT_ + bool AttachRecorder(SkPictureRecorder* recorder); + SkPictureRecorder* CreateRecorder(int size_x, int size_y); + void DebugVerifyBitmapIsPreMultiplied() const override; +#endif + + private: + bool m_bOwnedBitmap; +}; + +#endif // CORE_FXGE_INCLUDE_CFX_FXGEDEVICE_H_ diff --git a/core/fxge/include/cfx_graphstatedata.h b/core/fxge/include/cfx_graphstatedata.h new file mode 100644 index 0000000000..2e79698671 --- /dev/null +++ b/core/fxge/include/cfx_graphstatedata.h @@ -0,0 +1,38 @@ +// Copyright 2016 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. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FXGE_INCLUDE_CFX_GRAPHSTATEDATA_H_ +#define CORE_FXGE_INCLUDE_CFX_GRAPHSTATEDATA_H_ + +#include "core/fxcrt/include/fx_system.h" + +class CFX_GraphStateData { + public: + enum LineCap { LineCapButt = 0, LineCapRound = 1, LineCapSquare = 2 }; + + CFX_GraphStateData(); + CFX_GraphStateData(const CFX_GraphStateData& src); + ~CFX_GraphStateData(); + + void Copy(const CFX_GraphStateData& src); + void SetDashCount(int count); + + LineCap m_LineCap; + int m_DashCount; + FX_FLOAT* m_DashArray; + FX_FLOAT m_DashPhase; + + enum LineJoin { + LineJoinMiter = 0, + LineJoinRound = 1, + LineJoinBevel = 2, + }; + LineJoin m_LineJoin; + FX_FLOAT m_MiterLimit; + FX_FLOAT m_LineWidth; +}; + +#endif // CORE_FXGE_INCLUDE_CFX_GRAPHSTATEDATA_H_ diff --git a/core/fxge/include/cfx_pathdata.h b/core/fxge/include/cfx_pathdata.h index fe95631327..d77e1da05e 100644 --- a/core/fxge/include/cfx_pathdata.h +++ b/core/fxge/include/cfx_pathdata.h @@ -9,6 +9,7 @@ #include "core/fxcrt/include/fx_coordinates.h" #include "core/fxcrt/include/fx_system.h" +#include "core/fxge/include/cfx_renderdevice.h" struct FX_PATHPOINT { FX_FLOAT m_PointX; diff --git a/core/fxge/include/cfx_renderdevice.h b/core/fxge/include/cfx_renderdevice.h new file mode 100644 index 0000000000..fafa6260e1 --- /dev/null +++ b/core/fxge/include/cfx_renderdevice.h @@ -0,0 +1,280 @@ +// Copyright 2016 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. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FXGE_INCLUDE_CFX_RENDERDEVICE_H_ +#define CORE_FXGE_INCLUDE_CFX_RENDERDEVICE_H_ + +#include + +#include "core/fxge/include/cfx_gemodule.h" +#include "core/fxge/include/fx_dib.h" +#include "core/fxge/include/fx_font.h" + +class CFX_Font; +class CFX_FontCache; +class CFX_GraphStateData; +class IFX_RenderDeviceDriver; + +#define FXDC_DEVICE_CLASS 1 +#define FXDC_PIXEL_WIDTH 2 +#define FXDC_PIXEL_HEIGHT 3 +#define FXDC_BITS_PIXEL 4 +#define FXDC_HORZ_SIZE 5 +#define FXDC_VERT_SIZE 6 +#define FXDC_RENDER_CAPS 7 +#define FXDC_DISPLAY 1 +#define FXDC_PRINTER 2 + +#define FXPT_CLOSEFIGURE 0x01 +#define FXPT_LINETO 0x02 +#define FXPT_BEZIERTO 0x04 +#define FXPT_MOVETO 0x06 +#define FXPT_TYPE 0x06 + +#define FXRC_GET_BITS 0x01 +#define FXRC_BIT_MASK 0x02 +#define FXRC_ALPHA_MASK 0x04 +#define FXRC_ALPHA_PATH 0x10 +#define FXRC_ALPHA_IMAGE 0x20 +#define FXRC_ALPHA_OUTPUT 0x40 +#define FXRC_BLEND_MODE 0x80 +#define FXRC_SOFT_CLIP 0x100 +#define FXRC_CMYK_OUTPUT 0x200 +#define FXRC_BITMASK_OUTPUT 0x400 +#define FXRC_BYTEMASK_OUTPUT 0x800 +#define FXRENDER_IMAGE_LOSSY 0x1000 +#define FXRC_FILLSTROKE_PATH 0x2000 +#define FXRC_SHADING 0x4000 + +#define FXFILL_ALTERNATE 1 +#define FXFILL_WINDING 2 +#define FXFILL_FULLCOVER 4 +#define FXFILL_RECT_AA 8 +#define FX_FILL_STROKE 16 +#define FX_STROKE_ADJUST 32 +#define FX_STROKE_TEXT_MODE 64 +#define FX_FILL_TEXT_MODE 128 +#define FX_ZEROAREA_FILL 256 +#define FXFILL_NOPATHSMOOTH 512 + +#define FXTEXT_CLEARTYPE 0x01 +#define FXTEXT_BGR_STRIPE 0x02 +#define FXTEXT_PRINTGRAPHICTEXT 0x04 +#define FXTEXT_NO_NATIVETEXT 0x08 +#define FXTEXT_PRINTIMAGETEXT 0x10 +#define FXTEXT_NOSMOOTH 0x20 + +struct FXTEXT_CHARPOS { + uint32_t m_GlyphIndex; + FX_FLOAT m_OriginX; + FX_FLOAT m_OriginY; + int m_FontCharWidth; + FX_BOOL m_bGlyphAdjust; + FX_FLOAT m_AdjustMatrix[4]; +#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ + uint32_t m_ExtGID; +#endif + bool m_bFontStyle; +}; + +class CFX_RenderDevice { + public: + CFX_RenderDevice(); + virtual ~CFX_RenderDevice(); + + // Take ownership of |pDriver|. + void SetDeviceDriver(std::unique_ptr pDriver); + IFX_RenderDeviceDriver* GetDeviceDriver() const { + return m_pDeviceDriver.get(); + } + + FX_BOOL StartRendering(); + void EndRendering(); + void SaveState(); + void RestoreState(bool bKeepSaved); + + int GetWidth() const { return m_Width; } + int GetHeight() const { return m_Height; } + int GetDeviceClass() const { return m_DeviceClass; } + int GetBPP() const { return m_bpp; } + int GetRenderCaps() const { return m_RenderCaps; } + int GetDeviceCaps(int id) const; + CFX_Matrix GetCTM() const; + CFX_DIBitmap* GetBitmap() const { return m_pBitmap; } + void SetBitmap(CFX_DIBitmap* pBitmap) { m_pBitmap = pBitmap; } + FX_BOOL CreateCompatibleBitmap(CFX_DIBitmap* pDIB, + int width, + int height) const; + const FX_RECT& GetClipBox() const { return m_ClipBox; } + FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData, + const CFX_Matrix* pObject2Device, + int fill_mode); + FX_BOOL SetClip_Rect(const FX_RECT& pRect); + FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData, + const CFX_Matrix* pObject2Device, + const CFX_GraphStateData* pGraphState); + FX_BOOL DrawPath(const CFX_PathData* pPathData, + const CFX_Matrix* pObject2Device, + const CFX_GraphStateData* pGraphState, + uint32_t fill_color, + uint32_t stroke_color, + int fill_mode) { + return DrawPathWithBlend(pPathData, pObject2Device, pGraphState, fill_color, + stroke_color, fill_mode, FXDIB_BLEND_NORMAL); + } + FX_BOOL DrawPathWithBlend(const CFX_PathData* pPathData, + const CFX_Matrix* pObject2Device, + const CFX_GraphStateData* pGraphState, + uint32_t fill_color, + uint32_t stroke_color, + int fill_mode, + int blend_type); + FX_BOOL SetPixel(int x, int y, uint32_t color); + FX_BOOL FillRect(const FX_RECT* pRect, uint32_t color) { + return FillRectWithBlend(pRect, color, FXDIB_BLEND_NORMAL); + } + FX_BOOL FillRectWithBlend(const FX_RECT* pRect, + uint32_t color, + int blend_type); + FX_BOOL DrawCosmeticLine(FX_FLOAT x1, + FX_FLOAT y1, + FX_FLOAT x2, + FX_FLOAT y2, + uint32_t color) { + return DrawCosmeticLineWithFillModeAndBlend(x1, y1, x2, y2, color, 0, + FXDIB_BLEND_NORMAL); + } + FX_BOOL DrawCosmeticLineWithFillModeAndBlend(FX_FLOAT x1, + FX_FLOAT y1, + FX_FLOAT x2, + FX_FLOAT y2, + uint32_t color, + int fill_mode, + int blend_type); + + FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, int left, int top); + CFX_DIBitmap* GetBackDrop(); + FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, int left, int top) { + return SetDIBitsWithBlend(pBitmap, left, top, FXDIB_BLEND_NORMAL); + } + FX_BOOL SetDIBitsWithBlend(const CFX_DIBSource* pBitmap, + int left, + int top, + int blend_type); + FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, + int left, + int top, + int dest_width, + int dest_height) { + return StretchDIBitsWithFlagsAndBlend(pBitmap, left, top, dest_width, + dest_height, 0, FXDIB_BLEND_NORMAL); + } + FX_BOOL StretchDIBitsWithFlagsAndBlend(const CFX_DIBSource* pBitmap, + int left, + int top, + int dest_width, + int dest_height, + uint32_t flags, + int blend_type); + FX_BOOL SetBitMask(const CFX_DIBSource* pBitmap, + int left, + int top, + uint32_t color); + FX_BOOL StretchBitMask(const CFX_DIBSource* pBitmap, + int left, + int top, + int dest_width, + int dest_height, + uint32_t color); + FX_BOOL StretchBitMaskWithFlags(const CFX_DIBSource* pBitmap, + int left, + int top, + int dest_width, + int dest_height, + uint32_t color, + uint32_t flags); + FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap, + int bitmap_alpha, + uint32_t color, + const CFX_Matrix* pMatrix, + uint32_t flags, + void*& handle) { + return StartDIBitsWithBlend(pBitmap, bitmap_alpha, color, pMatrix, flags, + handle, FXDIB_BLEND_NORMAL); + } + FX_BOOL StartDIBitsWithBlend(const CFX_DIBSource* pBitmap, + int bitmap_alpha, + uint32_t color, + const CFX_Matrix* pMatrix, + uint32_t flags, + void*& handle, + int blend_type); + FX_BOOL ContinueDIBits(void* handle, IFX_Pause* pPause); + void CancelDIBits(void* handle); + + FX_BOOL DrawNormalText(int nChars, + const FXTEXT_CHARPOS* pCharPos, + CFX_Font* pFont, + CFX_FontCache* pCache, + FX_FLOAT font_size, + const CFX_Matrix* pText2Device, + uint32_t fill_color, + uint32_t text_flags); + FX_BOOL DrawTextPath(int nChars, + const FXTEXT_CHARPOS* pCharPos, + CFX_Font* pFont, + CFX_FontCache* pCache, + FX_FLOAT font_size, + const CFX_Matrix* pText2User, + const CFX_Matrix* pUser2Device, + const CFX_GraphStateData* pGraphState, + uint32_t fill_color, + uint32_t stroke_color, + CFX_PathData* pClippingPath) { + return DrawTextPathWithFlags(nChars, pCharPos, pFont, pCache, font_size, + pText2User, pUser2Device, pGraphState, + fill_color, stroke_color, pClippingPath, 0); + } + FX_BOOL DrawTextPathWithFlags(int nChars, + const FXTEXT_CHARPOS* pCharPos, + CFX_Font* pFont, + CFX_FontCache* pCache, + FX_FLOAT font_size, + const CFX_Matrix* pText2User, + const CFX_Matrix* pUser2Device, + const CFX_GraphStateData* pGraphState, + uint32_t fill_color, + uint32_t stroke_color, + CFX_PathData* pClippingPath, + int nFlag); + +#ifdef _SKIA_SUPPORT_ + virtual void DebugVerifyBitmapIsPreMultiplied() const; + void Flush(); +#endif + + private: + void InitDeviceInfo(); + void UpdateClipBox(); + FX_BOOL DrawFillStrokePath(const CFX_PathData* pPathData, + const CFX_Matrix* pObject2Device, + const CFX_GraphStateData* pGraphState, + uint32_t fill_color, + uint32_t stroke_color, + int fill_mode, + int blend_type); + + CFX_DIBitmap* m_pBitmap; + int m_Width; + int m_Height; + int m_bpp; + int m_RenderCaps; + int m_DeviceClass; + FX_RECT m_ClipBox; + std::unique_ptr m_pDeviceDriver; +}; + +#endif // CORE_FXGE_INCLUDE_CFX_RENDERDEVICE_H_ diff --git a/core/fxge/include/fx_ge.h b/core/fxge/include/fx_ge.h deleted file mode 100644 index fabcee41ad..0000000000 --- a/core/fxge/include/fx_ge.h +++ /dev/null @@ -1,334 +0,0 @@ -// Copyright 2014 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. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef CORE_FXGE_INCLUDE_FX_GE_H_ -#define CORE_FXGE_INCLUDE_FX_GE_H_ - -#include - -#include "core/fxge/include/cfx_fontmgr.h" -#include "core/fxge/include/fx_dib.h" -#include "core/fxge/include/fx_font.h" - -class CCodec_ModuleMgr; -class CFX_FaceCache; -class CFX_Font; -class CFX_FontCache; -class CFX_FontMgr; -class CPDF_ShadingPattern; -class IFX_RenderDeviceDriver; -class SkPictureRecorder; - -class CFX_GraphStateData { - public: - enum LineCap { LineCapButt = 0, LineCapRound = 1, LineCapSquare = 2 }; - - CFX_GraphStateData(); - CFX_GraphStateData(const CFX_GraphStateData& src); - ~CFX_GraphStateData(); - - void Copy(const CFX_GraphStateData& src); - void SetDashCount(int count); - - LineCap m_LineCap; - int m_DashCount; - FX_FLOAT* m_DashArray; - FX_FLOAT m_DashPhase; - - enum LineJoin { - LineJoinMiter = 0, - LineJoinRound = 1, - LineJoinBevel = 2, - }; - LineJoin m_LineJoin; - FX_FLOAT m_MiterLimit; - FX_FLOAT m_LineWidth; -}; - -#define FXDC_DEVICE_CLASS 1 -#define FXDC_PIXEL_WIDTH 2 -#define FXDC_PIXEL_HEIGHT 3 -#define FXDC_BITS_PIXEL 4 -#define FXDC_HORZ_SIZE 5 -#define FXDC_VERT_SIZE 6 -#define FXDC_RENDER_CAPS 7 -#define FXDC_DISPLAY 1 -#define FXDC_PRINTER 2 - -#define FXPT_CLOSEFIGURE 0x01 -#define FXPT_LINETO 0x02 -#define FXPT_BEZIERTO 0x04 -#define FXPT_MOVETO 0x06 -#define FXPT_TYPE 0x06 - -#define FXRC_GET_BITS 0x01 -#define FXRC_BIT_MASK 0x02 -#define FXRC_ALPHA_MASK 0x04 -#define FXRC_ALPHA_PATH 0x10 -#define FXRC_ALPHA_IMAGE 0x20 -#define FXRC_ALPHA_OUTPUT 0x40 -#define FXRC_BLEND_MODE 0x80 -#define FXRC_SOFT_CLIP 0x100 -#define FXRC_CMYK_OUTPUT 0x200 -#define FXRC_BITMASK_OUTPUT 0x400 -#define FXRC_BYTEMASK_OUTPUT 0x800 -#define FXRENDER_IMAGE_LOSSY 0x1000 -#define FXRC_FILLSTROKE_PATH 0x2000 -#define FXRC_SHADING 0x4000 - -#define FXFILL_ALTERNATE 1 -#define FXFILL_WINDING 2 -#define FXFILL_FULLCOVER 4 -#define FXFILL_RECT_AA 8 -#define FX_FILL_STROKE 16 -#define FX_STROKE_ADJUST 32 -#define FX_STROKE_TEXT_MODE 64 -#define FX_FILL_TEXT_MODE 128 -#define FX_ZEROAREA_FILL 256 -#define FXFILL_NOPATHSMOOTH 512 - -#define FXTEXT_CLEARTYPE 0x01 -#define FXTEXT_BGR_STRIPE 0x02 -#define FXTEXT_PRINTGRAPHICTEXT 0x04 -#define FXTEXT_NO_NATIVETEXT 0x08 -#define FXTEXT_PRINTIMAGETEXT 0x10 -#define FXTEXT_NOSMOOTH 0x20 - -struct FXTEXT_CHARPOS { - uint32_t m_GlyphIndex; - FX_FLOAT m_OriginX; - FX_FLOAT m_OriginY; - int m_FontCharWidth; - FX_BOOL m_bGlyphAdjust; - FX_FLOAT m_AdjustMatrix[4]; -#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ - uint32_t m_ExtGID; -#endif - bool m_bFontStyle; -}; - -class CFX_RenderDevice { - public: - CFX_RenderDevice(); - virtual ~CFX_RenderDevice(); - - // Take ownership of |pDriver|. - void SetDeviceDriver(std::unique_ptr pDriver); - IFX_RenderDeviceDriver* GetDeviceDriver() const { - return m_pDeviceDriver.get(); - } - - FX_BOOL StartRendering(); - void EndRendering(); - void SaveState(); - void RestoreState(bool bKeepSaved); - - int GetWidth() const { return m_Width; } - int GetHeight() const { return m_Height; } - int GetDeviceClass() const { return m_DeviceClass; } - int GetBPP() const { return m_bpp; } - int GetRenderCaps() const { return m_RenderCaps; } - int GetDeviceCaps(int id) const; - CFX_Matrix GetCTM() const; - CFX_DIBitmap* GetBitmap() const { return m_pBitmap; } - void SetBitmap(CFX_DIBitmap* pBitmap) { m_pBitmap = pBitmap; } - FX_BOOL CreateCompatibleBitmap(CFX_DIBitmap* pDIB, - int width, - int height) const; - const FX_RECT& GetClipBox() const { return m_ClipBox; } - FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData, - const CFX_Matrix* pObject2Device, - int fill_mode); - FX_BOOL SetClip_Rect(const FX_RECT& pRect); - FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData, - const CFX_Matrix* pObject2Device, - const CFX_GraphStateData* pGraphState); - FX_BOOL DrawPath(const CFX_PathData* pPathData, - const CFX_Matrix* pObject2Device, - const CFX_GraphStateData* pGraphState, - uint32_t fill_color, - uint32_t stroke_color, - int fill_mode) { - return DrawPathWithBlend(pPathData, pObject2Device, pGraphState, fill_color, - stroke_color, fill_mode, FXDIB_BLEND_NORMAL); - } - FX_BOOL DrawPathWithBlend(const CFX_PathData* pPathData, - const CFX_Matrix* pObject2Device, - const CFX_GraphStateData* pGraphState, - uint32_t fill_color, - uint32_t stroke_color, - int fill_mode, - int blend_type); - FX_BOOL SetPixel(int x, int y, uint32_t color); - FX_BOOL FillRect(const FX_RECT* pRect, uint32_t color) { - return FillRectWithBlend(pRect, color, FXDIB_BLEND_NORMAL); - } - FX_BOOL FillRectWithBlend(const FX_RECT* pRect, - uint32_t color, - int blend_type); - FX_BOOL DrawCosmeticLine(FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2, - uint32_t color) { - return DrawCosmeticLineWithFillModeAndBlend(x1, y1, x2, y2, color, 0, - FXDIB_BLEND_NORMAL); - } - FX_BOOL DrawCosmeticLineWithFillModeAndBlend(FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2, - uint32_t color, - int fill_mode, - int blend_type); - - FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, int left, int top); - CFX_DIBitmap* GetBackDrop(); - FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, int left, int top) { - return SetDIBitsWithBlend(pBitmap, left, top, FXDIB_BLEND_NORMAL); - } - FX_BOOL SetDIBitsWithBlend(const CFX_DIBSource* pBitmap, - int left, - int top, - int blend_type); - FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, - int left, - int top, - int dest_width, - int dest_height) { - return StretchDIBitsWithFlagsAndBlend(pBitmap, left, top, dest_width, - dest_height, 0, FXDIB_BLEND_NORMAL); - } - FX_BOOL StretchDIBitsWithFlagsAndBlend(const CFX_DIBSource* pBitmap, - int left, - int top, - int dest_width, - int dest_height, - uint32_t flags, - int blend_type); - FX_BOOL SetBitMask(const CFX_DIBSource* pBitmap, - int left, - int top, - uint32_t color); - FX_BOOL StretchBitMask(const CFX_DIBSource* pBitmap, - int left, - int top, - int dest_width, - int dest_height, - uint32_t color); - FX_BOOL StretchBitMaskWithFlags(const CFX_DIBSource* pBitmap, - int left, - int top, - int dest_width, - int dest_height, - uint32_t color, - uint32_t flags); - FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap, - int bitmap_alpha, - uint32_t color, - const CFX_Matrix* pMatrix, - uint32_t flags, - void*& handle) { - return StartDIBitsWithBlend(pBitmap, bitmap_alpha, color, pMatrix, flags, - handle, FXDIB_BLEND_NORMAL); - } - FX_BOOL StartDIBitsWithBlend(const CFX_DIBSource* pBitmap, - int bitmap_alpha, - uint32_t color, - const CFX_Matrix* pMatrix, - uint32_t flags, - void*& handle, - int blend_type); - FX_BOOL ContinueDIBits(void* handle, IFX_Pause* pPause); - void CancelDIBits(void* handle); - - FX_BOOL DrawNormalText(int nChars, - const FXTEXT_CHARPOS* pCharPos, - CFX_Font* pFont, - CFX_FontCache* pCache, - FX_FLOAT font_size, - const CFX_Matrix* pText2Device, - uint32_t fill_color, - uint32_t text_flags); - FX_BOOL DrawTextPath(int nChars, - const FXTEXT_CHARPOS* pCharPos, - CFX_Font* pFont, - CFX_FontCache* pCache, - FX_FLOAT font_size, - const CFX_Matrix* pText2User, - const CFX_Matrix* pUser2Device, - const CFX_GraphStateData* pGraphState, - uint32_t fill_color, - uint32_t stroke_color, - CFX_PathData* pClippingPath) { - return DrawTextPathWithFlags(nChars, pCharPos, pFont, pCache, font_size, - pText2User, pUser2Device, pGraphState, - fill_color, stroke_color, pClippingPath, 0); - } - FX_BOOL DrawTextPathWithFlags(int nChars, - const FXTEXT_CHARPOS* pCharPos, - CFX_Font* pFont, - CFX_FontCache* pCache, - FX_FLOAT font_size, - const CFX_Matrix* pText2User, - const CFX_Matrix* pUser2Device, - const CFX_GraphStateData* pGraphState, - uint32_t fill_color, - uint32_t stroke_color, - CFX_PathData* pClippingPath, - int nFlag); - -#ifdef _SKIA_SUPPORT_ - virtual void DebugVerifyBitmapIsPreMultiplied() const; - void Flush(); -#endif - - private: - void InitDeviceInfo(); - void UpdateClipBox(); - FX_BOOL DrawFillStrokePath(const CFX_PathData* pPathData, - const CFX_Matrix* pObject2Device, - const CFX_GraphStateData* pGraphState, - uint32_t fill_color, - uint32_t stroke_color, - int fill_mode, - int blend_type); - - CFX_DIBitmap* m_pBitmap; - int m_Width; - int m_Height; - int m_bpp; - int m_RenderCaps; - int m_DeviceClass; - FX_RECT m_ClipBox; - std::unique_ptr m_pDeviceDriver; -}; - -class CFX_FxgeDevice : public CFX_RenderDevice { - public: - CFX_FxgeDevice(); - ~CFX_FxgeDevice() override; - - bool Attach(CFX_DIBitmap* pBitmap, - bool bRgbByteOrder, - CFX_DIBitmap* pOriDevice, - bool bGroupKnockout); - bool Create(int width, - int height, - FXDIB_Format format, - CFX_DIBitmap* pOriDevice); - -#ifdef _SKIA_SUPPORT_ - bool AttachRecorder(SkPictureRecorder* recorder); - SkPictureRecorder* CreateRecorder(int size_x, int size_y); - void DebugVerifyBitmapIsPreMultiplied() const override; -#endif - - protected: - bool m_bOwnedBitmap; -}; - -#endif // CORE_FXGE_INCLUDE_FX_GE_H_ diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp index b6cf7c0f59..49c4639866 100644 --- a/core/fxge/skia/fx_skia_device.cpp +++ b/core/fxge/skia/fx_skia_device.cpp @@ -14,8 +14,11 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h" +#include "core/fxge/include/cfx_fxgedevice.h" #include "core/fxge/include/cfx_gemodule.h" +#include "core/fxge/include/cfx_graphstatedata.h" #include "core/fxge/include/cfx_pathdata.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "core/fxge/skia/fx_skia_device.h" #include "third_party/skia/include/core/SkCanvas.h" diff --git a/core/fxge/skia/fx_skia_device.h b/core/fxge/skia/fx_skia_device.h index 2169f54e87..661cf2e3b9 100644 --- a/core/fxge/skia/fx_skia_device.h +++ b/core/fxge/skia/fx_skia_device.h @@ -16,6 +16,7 @@ class SkPaint; class SkPath; class SkPictureRecorder; class SkiaState; +struct FXTEXT_CHARPOS; struct SkIRect; class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver { diff --git a/core/fxge/skia/fx_skia_device_unittest.cpp b/core/fxge/skia/fx_skia_device_unittest.cpp index fa46ea3031..456bea05ad 100644 --- a/core/fxge/skia/fx_skia_device_unittest.cpp +++ b/core/fxge/skia/fx_skia_device_unittest.cpp @@ -2,8 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "core/fxge/include/cfx_fxgedevice.h" +#include "core/fxge/include/cfx_graphstatedata.h" #include "core/fxge/include/cfx_pathdata.h" -#include "core/fxge/include/fx_ge.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "core/fxge/skia/fx_skia_device.h" #include "fpdfsdk/include/fsdk_define.h" #include "public/fpdfview.h" diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index 059a4c0c58..4885cd00cc 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -4,7 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "core/fxge/include/fx_ge.h" +#include "core/fxcrt/include/fx_system.h" #include #include @@ -25,6 +25,7 @@ #include "core/fxge/ge/fx_text_int.h" #include "core/fxge/include/cfx_fontmapper.h" #include "core/fxge/include/cfx_gemodule.h" +#include "core/fxge/include/cfx_graphstatedata.h" #include "core/fxge/include/cfx_pathdata.h" #include "core/fxge/include/cfx_windowsdevice.h" #include "core/fxge/include/ifx_systemfontinfo.h" diff --git a/core/fxge/win32/fx_win32_dib.cpp b/core/fxge/win32/fx_win32_dib.cpp index 20a84a2eb7..84f8abfca7 100644 --- a/core/fxge/win32/fx_win32_dib.cpp +++ b/core/fxge/win32/fx_win32_dib.cpp @@ -4,7 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "core/fxge/include/fx_ge.h" +#include "core/fxcrt/include/fx_system.h" #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ #include diff --git a/core/fxge/win32/fx_win32_dwrite.cpp b/core/fxge/win32/fx_win32_dwrite.cpp index 9c1d6c319e..fd1dd5c953 100644 --- a/core/fxge/win32/fx_win32_dwrite.cpp +++ b/core/fxge/win32/fx_win32_dwrite.cpp @@ -4,8 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include "core/fxcrt/include/fx_system.h" #include "core/fxge/ge/cfx_cliprgn.h" -#include "core/fxge/include/fx_ge.h" #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ #include diff --git a/core/fxge/win32/fx_win32_gdipext.cpp b/core/fxge/win32/fx_win32_gdipext.cpp index b9fc97af1a..99ccbd4763 100644 --- a/core/fxge/win32/fx_win32_gdipext.cpp +++ b/core/fxge/win32/fx_win32_gdipext.cpp @@ -4,7 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "core/fxge/include/fx_ge.h" +#include "core/fxcrt/include/fx_system.h" #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ #include @@ -18,6 +18,7 @@ using std::max; #include #include "core/fxge/include/cfx_gemodule.h" +#include "core/fxge/include/cfx_graphstatedata.h" #include "core/fxge/include/cfx_pathdata.h" #include "core/fxge/win32/cfx_windowsdib.h" #include "core/fxge/win32/win32_int.h" diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp index eea91bae93..16a429c636 100644 --- a/core/fxge/win32/fx_win32_print.cpp +++ b/core/fxge/win32/fx_win32_print.cpp @@ -4,7 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "core/fxge/include/fx_ge.h" +#include "core/fxcrt/include/fx_system.h" #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ @@ -15,6 +15,7 @@ #include "core/fxge/dib/dib_int.h" #include "core/fxge/ge/fx_text_int.h" #include "core/fxge/include/fx_freetype.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "core/fxge/include/cfx_windowsdevice.h" #include "core/fxge/win32/win32_int.h" diff --git a/core/fxge/win32/win32_int.h b/core/fxge/win32/win32_int.h index 3bfb2957e9..094e3efbb2 100644 --- a/core/fxge/win32/win32_int.h +++ b/core/fxge/win32/win32_int.h @@ -11,7 +11,9 @@ #include "core/fxge/include/ifx_renderdevicedriver.h" #include "core/fxge/win32/dwrite_int.h" +struct FXTEXT_CHARPOS; struct WINDIB_Open_Args_; + class CGdiplusExt { public: CGdiplusExt(); diff --git a/fpdfsdk/formfiller/cffl_formfiller.cpp b/fpdfsdk/formfiller/cffl_formfiller.cpp index b1c11af2b2..570654a877 100644 --- a/fpdfsdk/formfiller/cffl_formfiller.cpp +++ b/fpdfsdk/formfiller/cffl_formfiller.cpp @@ -7,6 +7,7 @@ #include "fpdfsdk/formfiller/cffl_formfiller.h" #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "fpdfsdk/formfiller/cba_fontmap.h" #include "fpdfsdk/include/fsdk_common.h" #include "fpdfsdk/include/fsdk_mgr.h" diff --git a/fpdfsdk/formfiller/cffl_iformfiller.cpp b/fpdfsdk/formfiller/cffl_iformfiller.cpp index a73f543c7c..e03fa73e2c 100644 --- a/fpdfsdk/formfiller/cffl_iformfiller.cpp +++ b/fpdfsdk/formfiller/cffl_iformfiller.cpp @@ -8,8 +8,9 @@ #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" +#include "core/fxge/include/cfx_graphstatedata.h" #include "core/fxge/include/cfx_pathdata.h" -#include "core/fxge/include/fx_ge.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "fpdfsdk/formfiller/cffl_checkbox.h" #include "fpdfsdk/formfiller/cffl_combobox.h" #include "fpdfsdk/formfiller/cffl_formfiller.h" diff --git a/fpdfsdk/fpdf_progressive.cpp b/fpdfsdk/fpdf_progressive.cpp index 2912e8b6c3..4ebeff646d 100644 --- a/fpdfsdk/fpdf_progressive.cpp +++ b/fpdfsdk/fpdf_progressive.cpp @@ -10,7 +10,8 @@ #include "core/fpdfapi/fpdf_render/include/cpdf_progressiverenderer.h" #include "core/fpdfapi/include/cpdf_pagerendercontext.h" #include "core/fxcrt/include/fx_memory.h" -#include "core/fxge/include/fx_ge.h" +#include "core/fxge/include/cfx_fxgedevice.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "fpdfsdk/include/fsdk_define.h" #include "fpdfsdk/include/fsdk_pauseadapter.h" #include "public/fpdfview.h" diff --git a/fpdfsdk/fpdf_sysfontinfo.cpp b/fpdfsdk/fpdf_sysfontinfo.cpp index 93d5d02b02..12253a932d 100644 --- a/fpdfsdk/fpdf_sysfontinfo.cpp +++ b/fpdfsdk/fpdf_sysfontinfo.cpp @@ -10,7 +10,6 @@ #include "core/fxge/include/ifx_systemfontinfo.h" #include "core/fxge/include/cfx_gemodule.h" #include "core/fxge/include/fx_font.h" -#include "core/fxge/include/fx_ge.h" #include "fpdfsdk/include/fsdk_define.h" #include "fpdfsdk/pdfwindow/PWL_FontMap.h" diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp index be652d028f..253091789c 100644 --- a/fpdfsdk/fpdfformfill.cpp +++ b/fpdfsdk/fpdfformfill.cpp @@ -15,7 +15,7 @@ #include "core/fpdfdoc/include/cpdf_formcontrol.h" #include "core/fpdfdoc/include/cpdf_formfield.h" #include "core/fpdfdoc/include/cpdf_interform.h" -#include "core/fxge/include/fx_ge.h" +#include "core/fxge/include/cfx_fxgedevice.h" #include "fpdfsdk/include/fsdk_define.h" #include "fpdfsdk/include/fsdk_mgr.h" #include "public/fpdfview.h" diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp index 5a1a0ce1d7..8aebb550ff 100644 --- a/fpdfsdk/fpdfview.cpp +++ b/fpdfsdk/fpdfview.cpp @@ -22,8 +22,8 @@ #include "core/fxcodec/include/fx_codec.h" #include "core/fxcrt/include/fx_memory.h" #include "core/fxcrt/include/fx_safe_types.h" +#include "core/fxge/include/cfx_fxgedevice.h" #include "core/fxge/include/cfx_gemodule.h" -#include "core/fxge/include/fx_ge.h" #include "fpdfsdk/include/fsdk_define.h" #include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/include/fsdk_pauseadapter.h" diff --git a/fpdfsdk/fsdk_annothandler.cpp b/fpdfsdk/fsdk_annothandler.cpp index 45bfcbad73..6216ab1c28 100644 --- a/fpdfsdk/fsdk_annothandler.cpp +++ b/fpdfsdk/fsdk_annothandler.cpp @@ -12,6 +12,7 @@ #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "core/fpdfdoc/include/cpdf_interform.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "fpdfsdk/formfiller/cffl_formfiller.h" #include "fpdfsdk/include/fsdk_define.h" #include "fpdfsdk/include/fsdk_mgr.h" diff --git a/fpdfsdk/fsdk_baseannot.cpp b/fpdfsdk/fsdk_baseannot.cpp index 37791ac343..21ba6a7a80 100644 --- a/fpdfsdk/fsdk_baseannot.cpp +++ b/fpdfsdk/fsdk_baseannot.cpp @@ -12,6 +12,7 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" #include "core/fxcrt/include/fx_ext.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "fpdfsdk/include/fsdk_baseannot.h" #include "fpdfsdk/include/fsdk_define.h" #include "fpdfsdk/include/fsdk_mgr.h" diff --git a/fpdfsdk/fsdk_baseform.cpp b/fpdfsdk/fsdk_baseform.cpp index 50d0eac8a8..1bd60b11e9 100644 --- a/fpdfsdk/fsdk_baseform.cpp +++ b/fpdfsdk/fsdk_baseform.cpp @@ -18,8 +18,9 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" #include "core/fpdfdoc/include/cpdf_actionfields.h" #include "core/fpdfdoc/include/cpdf_interform.h" +#include "core/fxge/include/cfx_graphstatedata.h" #include "core/fxge/include/cfx_pathdata.h" -#include "core/fxge/include/fx_ge.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "fpdfsdk/formfiller/cffl_formfiller.h" #include "fpdfsdk/fxedit/include/fxet_edit.h" #include "fpdfsdk/include/fsdk_actionhandler.h" diff --git a/fpdfsdk/fsdk_mgr.cpp b/fpdfsdk/fsdk_mgr.cpp index cf17d8f6f2..38ca5a1542 100644 --- a/fpdfsdk/fsdk_mgr.cpp +++ b/fpdfsdk/fsdk_mgr.cpp @@ -15,6 +15,7 @@ #include "core/fpdfdoc/include/cpdf_docjsactions.h" #include "core/fpdfdoc/include/cpdf_interform.h" #include "core/fxcrt/include/cfx_retain_ptr.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "fpdfsdk/formfiller/cffl_formfiller.h" #include "fpdfsdk/include/fsdk_define.h" #include "fpdfsdk/javascript/ijs_runtime.h" diff --git a/fpdfsdk/fxedit/fxet_edit.cpp b/fpdfsdk/fxedit/fxet_edit.cpp index 43646bd4ab..d21411f8a9 100644 --- a/fpdfsdk/fxedit/fxet_edit.cpp +++ b/fpdfsdk/fxedit/fxet_edit.cpp @@ -19,8 +19,9 @@ #include "core/fpdfdoc/include/cpvt_section.h" #include "core/fpdfdoc/include/cpvt_word.h" #include "core/fpdfdoc/include/ipvt_fontmap.h" +#include "core/fxge/include/cfx_graphstatedata.h" #include "core/fxge/include/cfx_pathdata.h" -#include "core/fxge/include/fx_ge.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "fpdfsdk/cfx_systemhandler.h" #include "fpdfsdk/fxedit/include/fx_edit.h" #include "fpdfsdk/fxedit/include/fxet_edit.h" diff --git a/fpdfsdk/pdfwindow/PWL_Caret.cpp b/fpdfsdk/pdfwindow/PWL_Caret.cpp index 8bc87a4491..98b2b3de86 100644 --- a/fpdfsdk/pdfwindow/PWL_Caret.cpp +++ b/fpdfsdk/pdfwindow/PWL_Caret.cpp @@ -6,8 +6,9 @@ #include "fpdfsdk/pdfwindow/PWL_Caret.h" +#include "core/fxge/include/cfx_graphstatedata.h" #include "core/fxge/include/cfx_pathdata.h" -#include "core/fxge/include/fx_ge.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "fpdfsdk/pdfwindow/PWL_Utils.h" #include "fpdfsdk/pdfwindow/PWL_Wnd.h" diff --git a/fpdfsdk/pdfwindow/PWL_ComboBox.cpp b/fpdfsdk/pdfwindow/PWL_ComboBox.cpp index 46c2e686e0..ebeb6751a0 100644 --- a/fpdfsdk/pdfwindow/PWL_ComboBox.cpp +++ b/fpdfsdk/pdfwindow/PWL_ComboBox.cpp @@ -7,7 +7,7 @@ #include "fpdfsdk/pdfwindow/PWL_ComboBox.h" #include "core/fxge/include/cfx_pathdata.h" -#include "core/fxge/include/fx_ge.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "fpdfsdk/fxedit/include/fxet_list.h" #include "fpdfsdk/pdfwindow/PWL_Edit.h" #include "fpdfsdk/pdfwindow/PWL_EditCtrl.h" diff --git a/fpdfsdk/pdfwindow/PWL_Edit.cpp b/fpdfsdk/pdfwindow/PWL_Edit.cpp index cd5868878b..1aa7b5eb5a 100644 --- a/fpdfsdk/pdfwindow/PWL_Edit.cpp +++ b/fpdfsdk/pdfwindow/PWL_Edit.cpp @@ -12,8 +12,9 @@ #include "core/fpdfdoc/include/cpvt_word.h" #include "core/fxcrt/include/fx_safe_types.h" #include "core/fxcrt/include/fx_xml.h" +#include "core/fxge/include/cfx_graphstatedata.h" #include "core/fxge/include/cfx_pathdata.h" -#include "core/fxge/include/fx_ge.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "fpdfsdk/fxedit/include/fxet_edit.h" #include "fpdfsdk/pdfwindow/PWL_Caret.h" #include "fpdfsdk/pdfwindow/PWL_EditCtrl.h" diff --git a/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp b/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp index ff5021e91e..1789d15764 100644 --- a/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp +++ b/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp @@ -7,7 +7,7 @@ #include "fpdfsdk/pdfwindow/PWL_ScrollBar.h" #include "core/fxge/include/cfx_pathdata.h" -#include "core/fxge/include/fx_ge.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "fpdfsdk/pdfwindow/PWL_Utils.h" #include "fpdfsdk/pdfwindow/PWL_Wnd.h" diff --git a/fpdfsdk/pdfwindow/PWL_Utils.cpp b/fpdfsdk/pdfwindow/PWL_Utils.cpp index c67b75a1cd..823873f19d 100644 --- a/fpdfsdk/pdfwindow/PWL_Utils.cpp +++ b/fpdfsdk/pdfwindow/PWL_Utils.cpp @@ -9,8 +9,9 @@ #include #include "core/fpdfdoc/include/cpvt_word.h" +#include "core/fxge/include/cfx_graphstatedata.h" #include "core/fxge/include/cfx_pathdata.h" -#include "core/fxge/include/fx_ge.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "fpdfsdk/fxedit/include/fxet_edit.h" #include "fpdfsdk/pdfwindow/PWL_Icon.h" #include "fpdfsdk/pdfwindow/PWL_Wnd.h" diff --git a/pdfium.gyp b/pdfium.gyp index 9b9e8cac40..3e415939d4 100644 --- a/pdfium.gyp +++ b/pdfium.gyp @@ -720,25 +720,27 @@ 'core/fxge/ge/cfx_fontmapper.cpp', 'core/fxge/ge/cfx_fontmgr.cpp', 'core/fxge/ge/cfx_gemodule.cpp', + 'core/fxge/ge/cfx_graphstatedata.cpp', 'core/fxge/ge/cfx_pathdata.cpp', + 'core/fxge/ge/cfx_renderdevice.cpp', 'core/fxge/ge/include/cfx_fontmapper.h', 'core/fxge/ge/include/cfx_fontmgr.h', 'core/fxge/ge/include/ifx_systemfontinfo.h', - 'core/fxge/ge/fx_ge_device.cpp', 'core/fxge/ge/fx_ge_font.cpp', 'core/fxge/ge/fx_ge_fontmap.cpp', 'core/fxge/ge/fx_ge_linux.cpp', - 'core/fxge/ge/fx_ge_path.cpp', 'core/fxge/ge/fx_ge_text.cpp', 'core/fxge/ge/fx_text_int.h', 'core/fxge/ifx_renderdevicedriver.cpp', + 'core/fxge/include/cfx_fxgedevice.h', 'core/fxge/include/cfx_gemodule.h', + 'core/fxge/include/cfx_graphstatedata.h', 'core/fxge/include/cfx_pathdata.h', + 'core/fxge/include/cfx_renderdevice.h', 'core/fxge/include/cfx_windowsdevice.h', 'core/fxge/include/fx_dib.h', 'core/fxge/include/fx_font.h', 'core/fxge/include/fx_freetype.h', - 'core/fxge/include/fx_ge.h', 'core/fxge/include/ifx_renderdevicedriver.h', 'core/fxge/win32/cfx_windowsdib.h', ], diff --git a/xfa/fde/cfde_path.h b/xfa/fde/cfde_path.h index fcf35cd5dd..54bebf3bc8 100644 --- a/xfa/fde/cfde_path.h +++ b/xfa/fde/cfde_path.h @@ -8,7 +8,7 @@ #define XFA_FDE_CFDE_PATH_H_ #include "core/fxge/include/cfx_pathdata.h" -#include "core/fxge/include/fx_ge.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "xfa/fgas/crt/fgas_memory.h" class CFDE_Path : public CFX_Target { diff --git a/xfa/fde/fde_gedevice.cpp b/xfa/fde/fde_gedevice.cpp index 6161bbc9e8..2579365245 100644 --- a/xfa/fde/fde_gedevice.cpp +++ b/xfa/fde/fde_gedevice.cpp @@ -9,6 +9,8 @@ #include #include "core/fxge/include/cfx_gemodule.h" +#include "core/fxge/include/cfx_graphstatedata.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "xfa/fde/cfde_path.h" #include "xfa/fde/fde_object.h" #include "xfa/fgas/font/fgas_font.h" diff --git a/xfa/fde/fde_gedevice.h b/xfa/fde/fde_gedevice.h index bb06cf6b53..e3b9208d93 100644 --- a/xfa/fde/fde_gedevice.h +++ b/xfa/fde/fde_gedevice.h @@ -7,13 +7,14 @@ #ifndef XFA_FDE_FDE_GEDEVICE_H_ #define XFA_FDE_FDE_GEDEVICE_H_ -#include "core/fxge/include/fx_ge.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "xfa/fgas/crt/fgas_memory.h" class CFDE_Brush; class CFDE_Path; class CFDE_Pen; class CFGAS_GEFont; +class CFX_GraphStateData; class CFDE_RenderDevice : public CFX_Target { public: diff --git a/xfa/fde/fde_visualset.h b/xfa/fde/fde_visualset.h index 2005f73f84..4ad24d7630 100644 --- a/xfa/fde/fde_visualset.h +++ b/xfa/fde/fde_visualset.h @@ -15,6 +15,8 @@ #include "xfa/fgas/crt/fgas_memory.h" #include "xfa/fgas/font/fgas_font.h" +struct FXTEXT_CHARPOS; + enum FDE_VISUALOBJTYPE { FDE_VISUALOBJ_Canvas = 0x00, FDE_VISUALOBJ_Text = 0x01 diff --git a/xfa/fde/tto/fde_textout.h b/xfa/fde/tto/fde_textout.h index 8d2c0fe8a0..6ce32d2fe8 100644 --- a/xfa/fde/tto/fde_textout.h +++ b/xfa/fde/tto/fde_textout.h @@ -10,8 +10,9 @@ #include #include +#include "core/fxge/include/cfx_fxgedevice.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "core/fxge/include/fx_dib.h" -#include "core/fxge/include/fx_ge.h" #include "xfa/fde/fde_object.h" #include "xfa/fgas/crt/fgas_utils.h" #include "xfa/fgas/font/fgas_font.h" @@ -42,6 +43,7 @@ #define FDE_TTOALIGNMENT_BottomAuto 11 class CFDE_RenderDevice; +class CFX_RenderDevice; class CFX_TxtBreak; struct FX_TXTRUN; diff --git a/xfa/fgas/font/fgas_stdfontmgr.cpp b/xfa/fgas/font/fgas_stdfontmgr.cpp index 3e8f28deb0..20a520414c 100644 --- a/xfa/fgas/font/fgas_stdfontmgr.cpp +++ b/xfa/fgas/font/fgas_stdfontmgr.cpp @@ -11,7 +11,6 @@ #include "core/fxge/include/cfx_fontmgr.h" #include "core/fxge/include/cfx_gemodule.h" #include "core/fxge/include/ifx_systemfontinfo.h" -#include "core/fxge/include/fx_ge.h" #include "xfa/fgas/crt/fgas_codepage.h" #include "xfa/fgas/font/fgas_fontutils.h" #include "xfa/fgas/font/fgas_gefont.h" diff --git a/xfa/fgas/layout/fgas_textbreak.h b/xfa/fgas/layout/fgas_textbreak.h index 366ba80cd0..b5f8ca1edc 100644 --- a/xfa/fgas/layout/fgas_textbreak.h +++ b/xfa/fgas/layout/fgas_textbreak.h @@ -10,7 +10,7 @@ #include #include "core/fxcrt/include/fx_ucd.h" -#include "core/fxge/include/fx_ge.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "xfa/fgas/crt/fgas_utils.h" #include "xfa/fgas/layout/fgas_unicode.h" diff --git a/xfa/fxbarcode/BC_TwoDimWriter.cpp b/xfa/fxbarcode/BC_TwoDimWriter.cpp index e4cc6e890a..cda0467fe1 100644 --- a/xfa/fxbarcode/BC_TwoDimWriter.cpp +++ b/xfa/fxbarcode/BC_TwoDimWriter.cpp @@ -6,8 +6,9 @@ #include +#include "core/fxge/include/cfx_graphstatedata.h" #include "core/fxge/include/cfx_pathdata.h" -#include "core/fxge/include/fx_ge.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "third_party/base/numerics/safe_math.h" #include "xfa/fxbarcode/BC_TwoDimWriter.h" #include "xfa/fxbarcode/BC_Writer.h" diff --git a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp index 9ab1aeb53e..6a914a91dc 100644 --- a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp +++ b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp @@ -25,8 +25,11 @@ #include #include +#include "core/fxge/include/cfx_fxgedevice.h" #include "core/fxge/include/cfx_gemodule.h" +#include "core/fxge/include/cfx_graphstatedata.h" #include "core/fxge/include/cfx_pathdata.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "xfa/fxbarcode/BC_Writer.h" #include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" diff --git a/xfa/fxbarcode/oned/BC_OneDimWriter.h b/xfa/fxbarcode/oned/BC_OneDimWriter.h index 1480b82df1..91763a90a8 100644 --- a/xfa/fxbarcode/oned/BC_OneDimWriter.h +++ b/xfa/fxbarcode/oned/BC_OneDimWriter.h @@ -9,7 +9,7 @@ #include -#include "core/fxge/include/fx_ge.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "xfa/fxbarcode/BC_Writer.h" #include "xfa/fxbarcode/include/BC_Library.h" diff --git a/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp b/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp index f4b0a6fdcb..e2bbfd5726 100644 --- a/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp +++ b/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp @@ -20,6 +20,7 @@ * limitations under the License. */ +#include "core/fxge/include/cfx_fxgedevice.h" #include "core/fxge/include/cfx_gemodule.h" #include "xfa/fxbarcode/BC_Writer.h" #include "xfa/fxbarcode/oned/BC_OneDimWriter.h" diff --git a/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp b/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp index 577654bd73..0a7f3a8a50 100644 --- a/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp +++ b/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp @@ -20,6 +20,7 @@ * limitations under the License. */ +#include "core/fxge/include/cfx_fxgedevice.h" #include "core/fxge/include/cfx_gemodule.h" #include "xfa/fxbarcode/BC_Writer.h" #include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" diff --git a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp index 8fd85fc6a1..01660b75c7 100644 --- a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp +++ b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp @@ -20,6 +20,7 @@ * limitations under the License. */ +#include "core/fxge/include/cfx_fxgedevice.h" #include "core/fxge/include/cfx_gemodule.h" #include "xfa/fxbarcode/BC_Writer.h" #include "xfa/fxbarcode/oned/BC_OneDimWriter.h" diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp index f4b6a8aeb9..ed42aa4825 100644 --- a/xfa/fxfa/app/xfa_ffwidget.cpp +++ b/xfa/fxfa/app/xfa_ffwidget.cpp @@ -14,6 +14,7 @@ #include "core/fxcodec/include/fx_codec.h" #include "core/fxge/include/cfx_gemodule.h" #include "core/fxge/include/cfx_pathdata.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "xfa/fxfa/app/xfa_textlayout.h" #include "xfa/fxfa/include/fxfa_widget.h" #include "xfa/fxfa/include/cxfa_eventparam.h" diff --git a/xfa/fxfa/include/xfa_ffwidget.h b/xfa/fxfa/include/xfa_ffwidget.h index bde247fab4..ca325ee33d 100644 --- a/xfa/fxfa/include/xfa_ffwidget.h +++ b/xfa/fxfa/include/xfa_ffwidget.h @@ -10,7 +10,7 @@ #include #include "core/fxcodec/include/fx_codec_def.h" -#include "core/fxge/include/fx_ge.h" +#include "core/fxge/include/cfx_graphstatedata.h" #include "xfa/fxfa/include/fxfa.h" #include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" diff --git a/xfa/fxfa/parser/xfa_localemgr.cpp b/xfa/fxfa/parser/xfa_localemgr.cpp index 2d2bddd44a..2d100746c9 100644 --- a/xfa/fxfa/parser/xfa_localemgr.cpp +++ b/xfa/fxfa/parser/xfa_localemgr.cpp @@ -9,7 +9,6 @@ #include "core/fxcodec/include/fx_codec.h" #include "core/fxcrt/include/fx_xml.h" #include "core/fxge/include/cfx_gemodule.h" -#include "core/fxge/include/fx_ge.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/xfa_locale.h" #include "xfa/fxfa/parser/xfa_object.h" diff --git a/xfa/fxgraphics/cfx_graphics.cpp b/xfa/fxgraphics/cfx_graphics.cpp index 0e18d65e2d..083ef7bff4 100644 --- a/xfa/fxgraphics/cfx_graphics.cpp +++ b/xfa/fxgraphics/cfx_graphics.cpp @@ -8,7 +8,9 @@ #include +#include "core/fxge/include/cfx_fxgedevice.h" #include "core/fxge/include/cfx_gemodule.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "xfa/fxgraphics/cagg_graphics.h" #include "xfa/fxgraphics/cfx_color.h" #include "xfa/fxgraphics/cfx_path.h" diff --git a/xfa/fxgraphics/cfx_path_generator.cpp b/xfa/fxgraphics/cfx_path_generator.cpp index aadaa85ad0..2af39c49d7 100644 --- a/xfa/fxgraphics/cfx_path_generator.cpp +++ b/xfa/fxgraphics/cfx_path_generator.cpp @@ -7,6 +7,7 @@ #include "xfa/fxgraphics/cfx_path_generator.h" #include "core/fxge/include/cfx_pathdata.h" +#include "core/fxge/include/cfx_renderdevice.h" CFX_PathGenerator::CFX_PathGenerator() : m_pPathData(new CFX_PathData) {} diff --git a/xfa/fxgraphics/cfx_path_generator.h b/xfa/fxgraphics/cfx_path_generator.h index 0fed30f93f..aa17a7e323 100644 --- a/xfa/fxgraphics/cfx_path_generator.h +++ b/xfa/fxgraphics/cfx_path_generator.h @@ -10,7 +10,6 @@ #include #include "core/fxge/include/cfx_pathdata.h" -#include "core/fxge/include/fx_ge.h" class CFX_PathGenerator { public: diff --git a/xfa/fxgraphics/include/cfx_graphics.h b/xfa/fxgraphics/include/cfx_graphics.h index e581089aec..129ae6e18b 100644 --- a/xfa/fxgraphics/include/cfx_graphics.h +++ b/xfa/fxgraphics/include/cfx_graphics.h @@ -10,8 +10,11 @@ #include #include "core/fxcrt/include/fx_system.h" +#include "core/fxge/include/cfx_fxgedevice.h" +#include "core/fxge/include/cfx_graphstatedata.h" +#include "core/fxge/include/cfx_renderdevice.h" #include "core/fxge/include/fx_dib.h" -#include "core/fxge/include/fx_ge.h" +#include "core/fxge/include/fx_font.h" #include "xfa/fwl/core/fwl_error.h" class CFX_Color; -- cgit v1.2.3