From 811b8a4f4482bb5c11ac7610e70a4c8fd34c2907 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 17 Mar 2016 08:59:42 -0400 Subject: Move xfa/include/fxgraphics/fx_graphics.h to xfa/fxgraphics. This Cl moves and splits apart the fx_graphics.h file into individual classes. The .cpp files are renamed to match the .h files. pre.h was removed at the same time and its contents moved to the correct places as needed. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1810563002 . --- BUILD.gn | 23 +- fpdfsdk/DEPS | 1 + fpdfsdk/fsdk_annothandler.cpp | 2 +- fpdfsdk/fsdk_mgr.cpp | 2 +- third_party/skia | 1 + xfa.gyp | 19 +- xfa/fwl/basewidget/fwl_caretimp.h | 1 + xfa/fwl/basewidget/fwl_editimp.cpp | 1 + xfa/fwl/core/fwl_gridimp.cpp | 2 + xfa/fwl/lightwidget/caret.cpp | 1 + xfa/fwl/theme/carettp.cpp | 2 + xfa/fwl/theme/checkboxtp.cpp | 2 + xfa/fwl/theme/comboboxtp.cpp | 2 + xfa/fwl/theme/edittp.cpp | 2 + xfa/fwl/theme/formtp.cpp | 2 + xfa/fwl/theme/listboxtp.cpp | 2 + xfa/fwl/theme/monthcalendartp.cpp | 2 + xfa/fwl/theme/pushbuttontp.cpp | 2 + xfa/fwl/theme/scrollbartp.cpp | 2 + xfa/fwl/theme/widgettp.cpp | 6 +- xfa/fxfa/app/xfa_fffield.cpp | 2 + xfa/fxfa/app/xfa_ffpath.cpp | 3 +- xfa/fxfa/app/xfa_ffpushbutton.cpp | 2 + xfa/fxfa/app/xfa_fftext.cpp | 2 +- xfa/fxfa/app/xfa_ffwidget.cpp | 26 +- xfa/fxfa/app/xfa_fwltheme.cpp | 1 + xfa/fxfa/app/xfa_rendercontext.cpp | 2 +- xfa/fxgraphics/cagg_graphics.cpp | 32 + xfa/fxgraphics/cagg_graphics.h | 29 + xfa/fxgraphics/cfx_color.cpp | 49 ++ xfa/fxgraphics/cfx_color.h | 45 + xfa/fxgraphics/cfx_graphics.cpp | 1566 +++++++++++++++++++++++++++++++++ xfa/fxgraphics/cfx_path.cpp | 179 ++++ xfa/fxgraphics/cfx_path.h | 78 ++ xfa/fxgraphics/cfx_path_generator.cpp | 199 +++++ xfa/fxgraphics/cfx_path_generator.h | 67 ++ xfa/fxgraphics/cfx_pattern.cpp | 26 + xfa/fxgraphics/cfx_pattern.h | 36 + xfa/fxgraphics/cfx_shading.cpp | 78 ++ xfa/fxgraphics/cfx_shading.h | 56 ++ xfa/fxgraphics/fx_graphics.cpp | 1394 ----------------------------- xfa/fxgraphics/fx_path_generator.cpp | 201 ----- xfa/fxgraphics/fx_path_generator.h | 64 -- xfa/fxgraphics/include/cfx_graphics.h | 253 ++++++ xfa/fxgraphics/pre.h | 586 ------------ xfa/include/fwl/core/fwl_note.h | 4 +- xfa/include/fwl/core/fwl_theme.h | 6 +- xfa/include/fwl/core/fwl_widget.h | 1 - xfa/include/fwl/lightwidget/theme.h | 1 + xfa/include/fxgraphics/fx_graphics.h | 435 --------- 50 files changed, 2785 insertions(+), 2715 deletions(-) create mode 160000 third_party/skia create mode 100644 xfa/fxgraphics/cagg_graphics.cpp create mode 100644 xfa/fxgraphics/cagg_graphics.h create mode 100644 xfa/fxgraphics/cfx_color.cpp create mode 100644 xfa/fxgraphics/cfx_color.h create mode 100644 xfa/fxgraphics/cfx_graphics.cpp create mode 100644 xfa/fxgraphics/cfx_path.cpp create mode 100644 xfa/fxgraphics/cfx_path.h create mode 100644 xfa/fxgraphics/cfx_path_generator.cpp create mode 100644 xfa/fxgraphics/cfx_path_generator.h create mode 100644 xfa/fxgraphics/cfx_pattern.cpp create mode 100644 xfa/fxgraphics/cfx_pattern.h create mode 100644 xfa/fxgraphics/cfx_shading.cpp create mode 100644 xfa/fxgraphics/cfx_shading.h delete mode 100644 xfa/fxgraphics/fx_graphics.cpp delete mode 100644 xfa/fxgraphics/fx_path_generator.cpp delete mode 100644 xfa/fxgraphics/fx_path_generator.h create mode 100644 xfa/fxgraphics/include/cfx_graphics.h delete mode 100644 xfa/fxgraphics/pre.h delete mode 100644 xfa/include/fxgraphics/fx_graphics.h diff --git a/BUILD.gn b/BUILD.gn index 5058b5b0a9..9430dc3a67 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1354,10 +1354,20 @@ if (pdf_enable_xfa) { "xfa/fxfa/parser/xfa_script_signaturepseudomodel.h", "xfa/fxfa/parser/xfa_utils.h", "xfa/fxfa/parser/xfa_utils_imp.cpp", - "xfa/fxgraphics/fx_graphics.cpp", - "xfa/fxgraphics/fx_path_generator.cpp", - "xfa/fxgraphics/fx_path_generator.h", - "xfa/fxgraphics/pre.h", + "xfa/fxgraphics/cagg_graphics.cpp", + "xfa/fxgraphics/cagg_graphics.h", + "xfa/fxgraphics/cfx_color.cpp", + "xfa/fxgraphics/cfx_color.h", + "xfa/fxgraphics/cfx_graphics.cpp", + "xfa/fxgraphics/cfx_path.cpp", + "xfa/fxgraphics/cfx_path.h", + "xfa/fxgraphics/cfx_path_generator.cpp", + "xfa/fxgraphics/cfx_path_generator.h", + "xfa/fxgraphics/cfx_pattern.cpp", + "xfa/fxgraphics/cfx_pattern.h", + "xfa/fxgraphics/cfx_shading.cpp", + "xfa/fxgraphics/cfx_shading.h", + "xfa/fxgraphics/include/cfx_graphics.h", "xfa/fxjse/include/fxjse.h", "xfa/include/fwl/adapter/fwl_adapternative.h", "xfa/include/fwl/adapter/fwl_adapterthreadmgr.h", @@ -1426,7 +1436,6 @@ if (pdf_enable_xfa) { "xfa/include/fxfa/fxfa_basic.h", "xfa/include/fxfa/fxfa_objectacc.h", "xfa/include/fxfa/fxfa_widget.h", - "xfa/include/fxgraphics/fx_graphics.h", ] include_dirs = [ "." ] if (pdf_enable_v8) { @@ -1499,9 +1508,7 @@ test("pdfium_unittests") { ] } if (pdf_enable_v8) { - sources += [ - "fpdfsdk/javascript/public_methods_unittest.cpp", - ] + sources += [ "fpdfsdk/javascript/public_methods_unittest.cpp" ] include_dirs += [ "//v8", "//v8/include", diff --git a/fpdfsdk/DEPS b/fpdfsdk/DEPS index d81d04b1c4..f04eb7a34b 100644 --- a/fpdfsdk/DEPS +++ b/fpdfsdk/DEPS @@ -10,4 +10,5 @@ include_rules = [ '+public', '+v8', '+xfa/include', + '+xfa/fxgraphics/include', ] diff --git a/fpdfsdk/fsdk_annothandler.cpp b/fpdfsdk/fsdk_annothandler.cpp index 725679dd14..6683284953 100644 --- a/fpdfsdk/fsdk_annothandler.cpp +++ b/fpdfsdk/fsdk_annothandler.cpp @@ -19,7 +19,7 @@ #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" #include "fpdfsdk/include/fpdfxfa/fpdfxfa_page.h" #include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h" -#include "xfa/include/fxgraphics/fx_graphics.h" +#include "xfa/fxgraphics/include/cfx_graphics.h" #endif // PDF_ENABLE_XFA CPDFSDK_AnnotHandlerMgr::CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp) { diff --git a/fpdfsdk/fsdk_mgr.cpp b/fpdfsdk/fsdk_mgr.cpp index 57eba21194..423bb8263a 100644 --- a/fpdfsdk/fsdk_mgr.cpp +++ b/fpdfsdk/fsdk_mgr.cpp @@ -23,7 +23,7 @@ #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" #include "fpdfsdk/include/fpdfxfa/fpdfxfa_page.h" #include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h" -#include "xfa/include/fxgraphics/fx_graphics.h" +#include "xfa/fxgraphics/include/cfx_graphics.h" #endif // PDF_ENABLE_XFA #if _FX_OS_ == _FX_ANDROID_ diff --git a/third_party/skia b/third_party/skia new file mode 160000 index 0000000000..ed854fb897 --- /dev/null +++ b/third_party/skia @@ -0,0 +1 @@ +Subproject commit ed854fb897fa134f2f64738a75293502fdcf1af2 diff --git a/xfa.gyp b/xfa.gyp index 80ece87d1a..6e4c420049 100644 --- a/xfa.gyp +++ b/xfa.gyp @@ -102,7 +102,6 @@ "xfa/include/fxfa/fxfa_basic.h", "xfa/include/fxfa/fxfa_objectacc.h", "xfa/include/fxfa/fxfa_widget.h", - "xfa/include/fxgraphics/fx_graphics.h", "xfa/fde/css/fde_css.h", "xfa/fde/css/fde_csscache.cpp", "xfa/fde/css/fde_csscache.h", @@ -637,10 +636,20 @@ "xfa/fxfa/parser/xfa_script_signaturepseudomodel.h", "xfa/fxfa/parser/xfa_utils.h", "xfa/fxfa/parser/xfa_utils_imp.cpp", - "xfa/fxgraphics/fx_graphics.cpp", - "xfa/fxgraphics/fx_path_generator.cpp", - "xfa/fxgraphics/fx_path_generator.h", - "xfa/fxgraphics/pre.h", + "xfa/fxgraphics/cagg_graphics.cpp", + "xfa/fxgraphics/cagg_graphics.h", + "xfa/fxgraphics/cfx_color.cpp", + "xfa/fxgraphics/cfx_color.h", + "xfa/fxgraphics/cfx_graphics.cpp", + "xfa/fxgraphics/cfx_path.cpp", + "xfa/fxgraphics/cfx_path.h", + "xfa/fxgraphics/cfx_path_generator.cpp", + "xfa/fxgraphics/cfx_path_generator.h", + "xfa/fxgraphics/cfx_pattern.cpp", + "xfa/fxgraphics/cfx_pattern.h", + "xfa/fxgraphics/cfx_shading.cpp", + "xfa/fxgraphics/cfx_shading.h", + "xfa/fxgraphics/include/cfx_graphics.h", "xfa/fxjse/include/fxjse.h", ], "conditions": [ diff --git a/xfa/fwl/basewidget/fwl_caretimp.h b/xfa/fwl/basewidget/fwl_caretimp.h index d123e15b58..dee4dd855d 100644 --- a/xfa/fwl/basewidget/fwl_caretimp.h +++ b/xfa/fwl/basewidget/fwl_caretimp.h @@ -8,6 +8,7 @@ #define XFA_FWL_BASEWIDGET_FWL_CARETIMP_H_ #include "xfa/fwl/core/fwl_widgetimp.h" +#include "xfa/fxgraphics/cfx_color.h" #include "xfa/include/fwl/core/fwl_timer.h" class CFWL_WidgetImpProperties; diff --git a/xfa/fwl/basewidget/fwl_editimp.cpp b/xfa/fwl/basewidget/fwl_editimp.cpp index 6975f50787..a0d707438e 100644 --- a/xfa/fwl/basewidget/fwl_editimp.cpp +++ b/xfa/fwl/basewidget/fwl_editimp.cpp @@ -21,6 +21,7 @@ #include "xfa/fwl/core/fwl_threadimp.h" #include "xfa/fwl/core/fwl_widgetimp.h" #include "xfa/fwl/core/fwl_widgetmgrimp.h" +#include "xfa/fxgraphics/cfx_path.h" #include "xfa/include/fwl/basewidget/fwl_caret.h" #include "xfa/include/fwl/basewidget/fwl_datetimepicker.h" #include "xfa/include/fwl/core/fwl_theme.h" diff --git a/xfa/fwl/core/fwl_gridimp.cpp b/xfa/fwl/core/fwl_gridimp.cpp index b3b8d5aa8d..a898bea838 100644 --- a/xfa/fwl/core/fwl_gridimp.cpp +++ b/xfa/fwl/core/fwl_gridimp.cpp @@ -11,6 +11,8 @@ #include "xfa/fwl/core/fwl_targetimp.h" #include "xfa/fwl/core/fwl_threadimp.h" #include "xfa/fwl/core/fwl_widgetimp.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_path.h" // static IFWL_Grid* IFWL_Grid::Create(const CFWL_WidgetImpProperties& properties) { diff --git a/xfa/fwl/lightwidget/caret.cpp b/xfa/fwl/lightwidget/caret.cpp index 279ea2d6f9..b81c6c2b08 100644 --- a/xfa/fwl/lightwidget/caret.cpp +++ b/xfa/fwl/lightwidget/caret.cpp @@ -9,6 +9,7 @@ #include #include "xfa/fwl/core/fwl_targetimp.h" +#include "xfa/fxgraphics/cfx_color.h" #include "xfa/include/fwl/basewidget/fwl_caret.h" #include "xfa/include/fwl/lightwidget/edit.h" diff --git a/xfa/fwl/theme/carettp.cpp b/xfa/fwl/theme/carettp.cpp index 88b01d9f3d..7b165f9b68 100644 --- a/xfa/fwl/theme/carettp.cpp +++ b/xfa/fwl/theme/carettp.cpp @@ -6,6 +6,8 @@ #include "xfa/include/fwl/theme/carettp.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_path.h" #include "xfa/include/fwl/basewidget/fwl_caret.h" #include "xfa/include/fwl/core/fwl_widget.h" diff --git a/xfa/fwl/theme/checkboxtp.cpp b/xfa/fwl/theme/checkboxtp.cpp index b65a550936..b039609826 100644 --- a/xfa/fwl/theme/checkboxtp.cpp +++ b/xfa/fwl/theme/checkboxtp.cpp @@ -7,6 +7,8 @@ #include "xfa/include/fwl/theme/checkboxtp.h" #include "xfa/fde/tto/fde_textout.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_path.h" #include "xfa/include/fwl/basewidget/fwl_checkbox.h" #include "xfa/include/fwl/core/fwl_widget.h" diff --git a/xfa/fwl/theme/comboboxtp.cpp b/xfa/fwl/theme/comboboxtp.cpp index 33be07d44c..c3824ec703 100644 --- a/xfa/fwl/theme/comboboxtp.cpp +++ b/xfa/fwl/theme/comboboxtp.cpp @@ -6,6 +6,8 @@ #include "xfa/include/fwl/theme/comboboxtp.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_path.h" #include "xfa/include/fwl/basewidget/fwl_combobox.h" #include "xfa/include/fwl/core/fwl_widget.h" diff --git a/xfa/fwl/theme/edittp.cpp b/xfa/fwl/theme/edittp.cpp index a206faffe8..61a28ef78a 100644 --- a/xfa/fwl/theme/edittp.cpp +++ b/xfa/fwl/theme/edittp.cpp @@ -6,6 +6,8 @@ #include "xfa/include/fwl/theme/edittp.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_path.h" #include "xfa/include/fwl/basewidget/fwl_edit.h" #include "xfa/include/fwl/core/fwl_widget.h" diff --git a/xfa/fwl/theme/formtp.cpp b/xfa/fwl/theme/formtp.cpp index 5f75535f3b..d07902d2c7 100644 --- a/xfa/fwl/theme/formtp.cpp +++ b/xfa/fwl/theme/formtp.cpp @@ -7,6 +7,8 @@ #include "xfa/include/fwl/theme/formtp.h" #include "xfa/fde/tto/fde_textout.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_path.h" #include "xfa/include/fwl/core/fwl_form.h" #include "xfa/include/fwl/core/fwl_widget.h" diff --git a/xfa/fwl/theme/listboxtp.cpp b/xfa/fwl/theme/listboxtp.cpp index 8ffe669835..72979db02c 100644 --- a/xfa/fwl/theme/listboxtp.cpp +++ b/xfa/fwl/theme/listboxtp.cpp @@ -6,6 +6,8 @@ #include "xfa/include/fwl/theme/listboxtp.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_path.h" #include "xfa/include/fwl/basewidget/fwl_listbox.h" #include "xfa/include/fwl/core/fwl_widget.h" diff --git a/xfa/fwl/theme/monthcalendartp.cpp b/xfa/fwl/theme/monthcalendartp.cpp index 6ab99ae439..5a2f3afe4d 100644 --- a/xfa/fwl/theme/monthcalendartp.cpp +++ b/xfa/fwl/theme/monthcalendartp.cpp @@ -7,6 +7,8 @@ #include "xfa/include/fwl/theme/monthcalendartp.h" #include "xfa/fde/tto/fde_textout.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_path.h" #include "xfa/include/fwl/basewidget/fwl_monthcalendar.h" #include "xfa/include/fwl/core/fwl_widget.h" diff --git a/xfa/fwl/theme/pushbuttontp.cpp b/xfa/fwl/theme/pushbuttontp.cpp index 76e0eab7dc..456199e877 100644 --- a/xfa/fwl/theme/pushbuttontp.cpp +++ b/xfa/fwl/theme/pushbuttontp.cpp @@ -6,6 +6,8 @@ #include "xfa/include/fwl/theme/pushbuttontp.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_path.h" #include "xfa/include/fwl/basewidget/fwl_pushbutton.h" #include "xfa/include/fwl/core/fwl_widget.h" diff --git a/xfa/fwl/theme/scrollbartp.cpp b/xfa/fwl/theme/scrollbartp.cpp index 424ff549e5..7a794050cb 100644 --- a/xfa/fwl/theme/scrollbartp.cpp +++ b/xfa/fwl/theme/scrollbartp.cpp @@ -6,6 +6,8 @@ #include "xfa/include/fwl/theme/scrollbartp.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_path.h" #include "xfa/include/fwl/basewidget/fwl_scrollbar.h" #include "xfa/include/fwl/core/fwl_widget.h" diff --git a/xfa/fwl/theme/widgettp.cpp b/xfa/fwl/theme/widgettp.cpp index 04b67b3310..61b505f8d3 100644 --- a/xfa/fwl/theme/widgettp.cpp +++ b/xfa/fwl/theme/widgettp.cpp @@ -9,6 +9,9 @@ #include #include "xfa/fde/tto/fde_textout.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_path.h" +#include "xfa/fxgraphics/cfx_shading.h" #include "xfa/include/fwl/core/fwl_widgetmgr.h" static void FWL_SetChildThemeID(IFWL_Widget* pParent, FX_DWORD dwThemeID) { @@ -451,8 +454,7 @@ void CFWL_WidgetTP::DrawAxialShading(CFX_Graphics* pGraphics, CFX_PointF begPoint(fx1, fy1); CFX_PointF endPoint(fx2, fy2); - CFX_Shading shading; - shading.CreateAxial(begPoint, endPoint, FALSE, FALSE, beginColor, endColor); + CFX_Shading shading(begPoint, endPoint, FALSE, FALSE, beginColor, endColor); pGraphics->SaveGraphState(); CFX_Color color1(&shading); pGraphics->SetFillColor(&color1); diff --git a/xfa/fxfa/app/xfa_fffield.cpp b/xfa/fxfa/app/xfa_fffield.cpp index 39e7ee5d8f..cc8f7ed2a4 100644 --- a/xfa/fxfa/app/xfa_fffield.cpp +++ b/xfa/fxfa/app/xfa_fffield.cpp @@ -13,6 +13,8 @@ #include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/fxfa/app/xfa_fwltheme.h" #include "xfa/fxfa/app/xfa_textlayout.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_path.h" #include "xfa/include/fwl/basewidget/fwl_edit.h" #include "xfa/include/fwl/core/fwl_widgetmgr.h" #include "xfa/include/fwl/lightwidget/edit.h" diff --git a/xfa/fxfa/app/xfa_ffpath.cpp b/xfa/fxfa/app/xfa_ffpath.cpp index f082232905..e0f6825a03 100644 --- a/xfa/fxfa/app/xfa_ffpath.cpp +++ b/xfa/fxfa/app/xfa_ffpath.cpp @@ -11,7 +11,8 @@ #include "xfa/fxfa/app/xfa_ffdraw.h" #include "xfa/fxfa/app/xfa_ffpageview.h" #include "xfa/fxfa/app/xfa_ffwidget.h" -#include "xfa/include/fxgraphics/fx_graphics.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_path.h" CXFA_FFLine::CXFA_FFLine(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) : CXFA_FFDraw(pPageView, pDataAcc) {} diff --git a/xfa/fxfa/app/xfa_ffpushbutton.cpp b/xfa/fxfa/app/xfa_ffpushbutton.cpp index 718853e5e2..bf18387af8 100644 --- a/xfa/fxfa/app/xfa_ffpushbutton.cpp +++ b/xfa/fxfa/app/xfa_ffpushbutton.cpp @@ -12,6 +12,8 @@ #include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/fxfa/app/xfa_ffwidgetacc.h" #include "xfa/fxfa/app/xfa_textlayout.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_path.h" #include "xfa/include/fwl/core/fwl_widgetmgr.h" #include "xfa/include/fwl/lightwidget/pushbutton.h" diff --git a/xfa/fxfa/app/xfa_fftext.cpp b/xfa/fxfa/app/xfa_fftext.cpp index aba8d162b0..d87815856d 100644 --- a/xfa/fxfa/app/xfa_fftext.cpp +++ b/xfa/fxfa/app/xfa_fftext.cpp @@ -12,8 +12,8 @@ #include "xfa/fxfa/app/xfa_ffpageview.h" #include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/fxfa/app/xfa_textlayout.h" +#include "xfa/fxgraphics/include/cfx_graphics.h" #include "xfa/include/fwl/core/fwl_widgetdef.h" -#include "xfa/include/fxgraphics/fx_graphics.h" CXFA_FFText::CXFA_FFText(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) : CXFA_FFDraw(pPageView, pDataAcc) {} diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp index 450c4ed6a0..93c1a3e349 100644 --- a/xfa/fxfa/app/xfa_ffwidget.cpp +++ b/xfa/fxfa/app/xfa_ffwidget.cpp @@ -15,7 +15,11 @@ #include "xfa/fxfa/app/xfa_ffdocview.h" #include "xfa/fxfa/app/xfa_ffpageview.h" #include "xfa/fxfa/app/xfa_textlayout.h" -#include "xfa/include/fxgraphics/fx_graphics.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_path.h" +#include "xfa/fxgraphics/cfx_pattern.h" +#include "xfa/fxgraphics/cfx_shading.h" +#include "xfa/fxgraphics/include/cfx_graphics.h" CXFA_FFWidget::CXFA_FFWidget(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) @@ -1456,17 +1460,16 @@ static void XFA_BOX_Fill_Radial(CXFA_Box box, FX_ARGB crStart, crEnd; crStart = fill.GetColor(); int32_t iType = fill.GetRadial(crEnd); - CFX_Shading shading; if (iType != XFA_ATTRIBUTEENUM_ToEdge) { FX_ARGB temp = crEnd; crEnd = crStart; crStart = temp; } - shading.CreateRadial(rtFill.Center(), rtFill.Center(), 0, - FXSYS_sqrt(rtFill.Width() * rtFill.Width() + - rtFill.Height() * rtFill.Height()) / - 2, - TRUE, TRUE, crStart, crEnd); + CFX_Shading shading(rtFill.Center(), rtFill.Center(), 0, + FXSYS_sqrt(rtFill.Width() * rtFill.Width() + + rtFill.Height() * rtFill.Height()) / + 2, + TRUE, TRUE, crStart, crEnd); CFX_Color cr(&shading); pGS->SetFillColor(&cr); pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); @@ -1480,7 +1483,7 @@ static void XFA_BOX_Fill_Pattern(CXFA_Box box, FX_ARGB crStart, crEnd; crStart = fill.GetColor(); int32_t iType = fill.GetPattern(crEnd); - int32_t iHatch = FX_HATCHSTYLE_Cross; + FX_HatchStyle iHatch = FX_HATCHSTYLE_Cross; switch (iType) { case XFA_ATTRIBUTEENUM_CrossDiagonal: iHatch = FX_HATCHSTYLE_DiagonalCross; @@ -1500,8 +1503,8 @@ static void XFA_BOX_Fill_Pattern(CXFA_Box box, default: break; } - CFX_Pattern pattern; - pattern.Create(iHatch, crEnd, crStart); + + CFX_Pattern pattern(iHatch, crEnd, crStart); CFX_Color cr(&pattern); pGS->SetFillColor(&cr); pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); @@ -1537,8 +1540,7 @@ static void XFA_BOX_Fill_Linear(CXFA_Box box, default: break; } - CFX_Shading shading; - shading.CreateAxial(ptStart, ptEnd, FALSE, FALSE, crStart, crEnd); + CFX_Shading shading(ptStart, ptEnd, FALSE, FALSE, crStart, crEnd); CFX_Color cr(&shading); pGS->SetFillColor(&cr); pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); diff --git a/xfa/fxfa/app/xfa_fwltheme.cpp b/xfa/fxfa/app/xfa_fwltheme.cpp index b0657ee8e4..6ebf4e3f41 100644 --- a/xfa/fxfa/app/xfa_fwltheme.cpp +++ b/xfa/fxfa/app/xfa_fwltheme.cpp @@ -10,6 +10,7 @@ #include "xfa/fgas/crt/fgas_codepage.h" #include "xfa/fxfa/app/xfa_ffapp.h" #include "xfa/fxfa/app/xfa_ffwidget.h" +#include "xfa/fxgraphics/cfx_color.h" #include "xfa/include/fwl/basewidget/fwl_barcode.h" #include "xfa/include/fwl/basewidget/fwl_caret.h" #include "xfa/include/fwl/basewidget/fwl_checkbox.h" diff --git a/xfa/fxfa/app/xfa_rendercontext.cpp b/xfa/fxfa/app/xfa_rendercontext.cpp index 5b5cf48a87..c9ca92bd6c 100644 --- a/xfa/fxfa/app/xfa_rendercontext.cpp +++ b/xfa/fxfa/app/xfa_rendercontext.cpp @@ -7,7 +7,7 @@ #include "xfa/fxfa/app/xfa_rendercontext.h" #include "xfa/fxfa/app/xfa_ffwidget.h" -#include "xfa/include/fxgraphics/fx_graphics.h" +#include "xfa/fxgraphics/include/cfx_graphics.h" #define XFA_RENDERCONTEXT_MaxCount 30 diff --git a/xfa/fxgraphics/cagg_graphics.cpp b/xfa/fxgraphics/cagg_graphics.cpp new file mode 100644 index 0000000000..4c9e41fea3 --- /dev/null +++ b/xfa/fxgraphics/cagg_graphics.cpp @@ -0,0 +1,32 @@ +// 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 "xfa/fxgraphics/cagg_graphics.h" + +CAGG_Graphics::CAGG_Graphics() : m_owner(nullptr) {} + +FX_ERR CAGG_Graphics::Create(CFX_Graphics* owner, + int32_t width, + int32_t height, + FXDIB_Format format) { + if (owner->m_renderDevice) + return FX_ERR_Parameter_Invalid; + if (m_owner) + return FX_ERR_Property_Invalid; + + CFX_FxgeDevice* device = new CFX_FxgeDevice; + device->Create(width, height, format); + m_owner = owner; + m_owner->m_renderDevice = device; + m_owner->m_renderDevice->GetBitmap()->Clear(0xFFFFFFFF); + return FX_ERR_Succeeded; +} + +CAGG_Graphics::~CAGG_Graphics() { + if (m_owner->m_renderDevice) + delete (CFX_FxgeDevice*)m_owner->m_renderDevice; + m_owner = nullptr; +} diff --git a/xfa/fxgraphics/cagg_graphics.h b/xfa/fxgraphics/cagg_graphics.h new file mode 100644 index 0000000000..d19773a42b --- /dev/null +++ b/xfa/fxgraphics/cagg_graphics.h @@ -0,0 +1,29 @@ +// 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 XFA_FXGRAPHICS_CAGG_GRAPHICS_H_ +#define XFA_FXGRAPHICS_CAGG_GRAPHICS_H_ + +#include "core/include/fxge/fx_dib.h" +#include "xfa/fxgraphics/include/cfx_graphics.h" + +class CFX_Graphics; + +class CAGG_Graphics { + public: + CAGG_Graphics(); + virtual ~CAGG_Graphics(); + + FX_ERR Create(CFX_Graphics* owner, + int32_t width, + int32_t height, + FXDIB_Format format); + + private: + CFX_Graphics* m_owner; +}; + +#endif // XFA_FXGRAPHICS_CAGG_GRAPHICS_H_ diff --git a/xfa/fxgraphics/cfx_color.cpp b/xfa/fxgraphics/cfx_color.cpp new file mode 100644 index 0000000000..9cc9c14bbd --- /dev/null +++ b/xfa/fxgraphics/cfx_color.cpp @@ -0,0 +1,49 @@ +// 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 "xfa/fxgraphics/cfx_color.h" + +CFX_Color::CFX_Color() : m_type(FX_COLOR_None) {} + +CFX_Color::CFX_Color(const FX_ARGB argb) { + Set(argb); +} + +CFX_Color::CFX_Color(CFX_Pattern* pattern, const FX_ARGB argb) { + Set(pattern, argb); +} + +CFX_Color::CFX_Color(CFX_Shading* shading) { + Set(shading); +} + +CFX_Color::~CFX_Color() { + m_type = FX_COLOR_None; +} + +FX_ERR CFX_Color::Set(const FX_ARGB argb) { + m_type = FX_COLOR_Solid; + m_info.argb = argb; + m_info.pattern = nullptr; + return FX_ERR_Succeeded; +} + +FX_ERR CFX_Color::Set(CFX_Pattern* pattern, const FX_ARGB argb) { + if (!pattern) + return FX_ERR_Parameter_Invalid; + m_type = FX_COLOR_Pattern; + m_info.argb = argb; + m_info.pattern = pattern; + return FX_ERR_Succeeded; +} + +FX_ERR CFX_Color::Set(CFX_Shading* shading) { + if (!shading) + return FX_ERR_Parameter_Invalid; + m_type = FX_COLOR_Shading; + m_shading = shading; + return FX_ERR_Succeeded; +} diff --git a/xfa/fxgraphics/cfx_color.h b/xfa/fxgraphics/cfx_color.h new file mode 100644 index 0000000000..5ab99d8d87 --- /dev/null +++ b/xfa/fxgraphics/cfx_color.h @@ -0,0 +1,45 @@ +// 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 XFA_FXGRAPHICS_CFX_COLOR_H_ +#define XFA_FXGRAPHICS_CFX_COLOR_H_ + +#include "core/include/fxge/fx_dib.h" +#include "xfa/fxgraphics/include/cfx_graphics.h" + +class CFX_Pattern; +class CFX_Shading; + +enum { FX_COLOR_None = 0, FX_COLOR_Solid, FX_COLOR_Pattern, FX_COLOR_Shading }; + +class CFX_Color { + public: + CFX_Color(); + // TODO(weili): Remove implicit conversions. Make this explicit. + CFX_Color(const FX_ARGB argb); + + explicit CFX_Color(CFX_Pattern* pattern, const FX_ARGB argb = 0x0); + explicit CFX_Color(CFX_Shading* shading); + virtual ~CFX_Color(); + + FX_ERR Set(const FX_ARGB argb); + FX_ERR Set(CFX_Pattern* pattern, const FX_ARGB argb = 0x0); + FX_ERR Set(CFX_Shading* shading); + + private: + friend class CFX_Graphics; + + int32_t m_type; + union { + struct { + FX_ARGB argb; + CFX_Pattern* pattern; + } m_info; + CFX_Shading* m_shading; + }; +}; + +#endif // XFA_FXGRAPHICS_CFX_COLOR_H_ diff --git a/xfa/fxgraphics/cfx_graphics.cpp b/xfa/fxgraphics/cfx_graphics.cpp new file mode 100644 index 0000000000..a0b1b07bca --- /dev/null +++ b/xfa/fxgraphics/cfx_graphics.cpp @@ -0,0 +1,1566 @@ +// 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 "xfa/fxgraphics/include/cfx_graphics.h" + +#include + +#include "xfa/fxgraphics/cagg_graphics.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_path.h" +#include "xfa/fxgraphics/cfx_path_generator.h" +#include "xfa/fxgraphics/cfx_pattern.h" +#include "xfa/fxgraphics/cfx_shading.h" + +namespace { + +enum { + FX_CONTEXT_None = 0, + FX_CONTEXT_Device, +}; + +#define FX_HATCHSTYLE_Total 53 + +struct FX_HATCHDATA { + int32_t width; + int32_t height; + uint8_t maskBits[64]; +}; + +const FX_HATCHDATA hatchBitmapData[FX_HATCHSTYLE_Total] = { + {16, + 16, + { + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + }}, + {16, + 16, + { + 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, + 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, + 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, + 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, + 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, + 0x80, 0x80, 0x00, 0x00, + }}, + {16, + 16, + { + 0x80, 0x80, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x20, 0x20, 0x00, 0x00, + 0x10, 0x10, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, + 0x40, 0x40, 0x00, 0x00, 0x20, 0x20, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, + 0x08, 0x08, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, + 0x01, 0x01, 0x00, 0x00, + }}, + {16, + 16, + { + 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, + 0x08, 0x08, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x20, 0x20, 0x00, 0x00, + 0x40, 0x40, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, + 0x02, 0x02, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, + 0x10, 0x10, 0x00, 0x00, 0x20, 0x20, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, + 0x80, 0x80, 0x00, 0x00, + }}, + {16, + 16, + { + 0xff, 0xff, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, + 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, + 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, + 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, + 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, + 0x80, 0x80, 0x00, 0x00, + }}, + {16, + 16, + { + 0x81, 0x81, 0x00, 0x00, 0x42, 0x42, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00, + 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00, + 0x42, 0x42, 0x00, 0x00, 0x81, 0x81, 0x00, 0x00, 0x81, 0x81, 0x00, 0x00, + 0x42, 0x42, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, + 0x18, 0x18, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00, 0x42, 0x42, 0x00, 0x00, + 0x81, 0x81, 0x00, 0x00, + }}, + {16, + 16, + { + 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + }}, + {16, + 16, + { + 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + }}, + {16, + 16, + { + 0x88, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x88, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + }}, + {16, + 16, + { + 0x88, 0x88, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, + 0x22, 0x22, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, + 0x88, 0x88, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, + 0x22, 0x22, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, + 0x88, 0x88, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, + 0x22, 0x22, 0x00, 0x00, + }}, + {16, + 16, + { + 0xaa, 0xaa, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, + 0x11, 0x11, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, + 0xaa, 0xaa, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, + 0x44, 0x44, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, + 0xaa, 0xaa, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, + 0x11, 0x11, 0x00, 0x00, + }}, + {16, + 16, + { + 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, + 0x51, 0x51, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, + 0xaa, 0xaa, 0x00, 0x00, 0x15, 0x15, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, + 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x51, 0x51, 0x00, 0x00, + 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, + 0x15, 0x15, 0x00, 0x00, + }}, + {16, + 16, + { + 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, + 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, + 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, + 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, + 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, + 0x55, 0x55, 0x00, 0x00, + }}, + {16, + 16, + { + 0xee, 0xee, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xbb, 0xbb, 0x00, 0x00, + 0x55, 0x55, 0x00, 0x00, 0xee, 0xee, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, + 0xbb, 0xbb, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xee, 0xee, 0x00, 0x00, + 0x55, 0x55, 0x00, 0x00, 0xbb, 0xbb, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, + 0xee, 0xee, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xbb, 0xbb, 0x00, 0x00, + 0x55, 0x55, 0x00, 0x00, + }}, + {16, + 16, + { + 0x77, 0x77, 0x00, 0x00, 0xdd, 0xdd, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00, + 0xdd, 0xdd, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00, 0xdd, 0xdd, 0x00, 0x00, + 0x77, 0x77, 0x00, 0x00, 0xdd, 0xdd, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00, + 0xdd, 0xdd, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00, 0xdd, 0xdd, 0x00, 0x00, + 0x77, 0x77, 0x00, 0x00, 0xdd, 0xdd, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00, + 0xdd, 0xdd, 0x00, 0x00, + }}, + {16, + 16, + { + 0x77, 0x77, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xdd, 0xdd, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, + 0xdd, 0xdd, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x00, 0xdd, 0xdd, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, + 0x77, 0x77, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xdd, 0xdd, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x00, + }}, + {16, + 16, + { + 0xef, 0xef, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xfe, 0xfe, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x00, 0xef, 0xef, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, + 0xfe, 0xfe, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xef, 0xef, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x00, 0xfe, 0xfe, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, + 0xef, 0xef, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xfe, 0xfe, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x00, + }}, + {16, + 16, + { + 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, + 0xf7, 0xf7, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x00, 0x7f, 0x7f, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xf7, 0xf7, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, + 0x7f, 0x7f, 0x00, 0x00, + }}, + {16, + 16, + { + 0x88, 0x88, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, + 0x11, 0x11, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, + 0x22, 0x22, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, + 0x44, 0x44, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, + 0x88, 0x88, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, + 0x11, 0x11, 0x00, 0x00, + }}, + {16, + 16, + { + 0x11, 0x11, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, + 0x88, 0x88, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, + 0x44, 0x44, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, + 0x22, 0x22, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, + 0x11, 0x11, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, + 0x88, 0x88, 0x00, 0x00, + }}, + {16, + 16, + { + 0xcc, 0xcc, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x33, 0x33, 0x00, 0x00, + 0x99, 0x99, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, + 0x33, 0x33, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, + 0x66, 0x66, 0x00, 0x00, 0x33, 0x33, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00, + 0xcc, 0xcc, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x33, 0x33, 0x00, 0x00, + 0x99, 0x99, 0x00, 0x00, + }}, + {16, + 16, + { + 0x33, 0x33, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, + 0x99, 0x99, 0x00, 0x00, 0x33, 0x33, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, + 0xcc, 0xcc, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00, 0x33, 0x33, 0x00, 0x00, + 0x66, 0x66, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00, + 0x33, 0x33, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, + 0x99, 0x99, 0x00, 0x00, + }}, + {16, + 16, + { + 0xc1, 0xc1, 0x00, 0x00, 0xe0, 0xe0, 0x00, 0x00, 0x70, 0x70, 0x00, 0x00, + 0x38, 0x38, 0x00, 0x00, 0x1c, 0x1c, 0x00, 0x00, 0x0e, 0x0e, 0x00, 0x00, + 0x07, 0x07, 0x00, 0x00, 0x83, 0x83, 0x00, 0x00, 0xc1, 0xc1, 0x00, 0x00, + 0xe0, 0xe0, 0x00, 0x00, 0x70, 0x70, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, + 0x1c, 0x1c, 0x00, 0x00, 0x0e, 0x0e, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x83, 0x83, 0x00, 0x00, + }}, + {16, + 16, + { + 0x83, 0x83, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, 0x0e, 0x0e, 0x00, 0x00, + 0x1c, 0x1c, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, 0x70, 0x70, 0x00, 0x00, + 0xe0, 0xe0, 0x00, 0x00, 0xc1, 0xc1, 0x00, 0x00, 0x83, 0x83, 0x00, 0x00, + 0x07, 0x07, 0x00, 0x00, 0x0e, 0x0e, 0x00, 0x00, 0x1c, 0x1c, 0x00, 0x00, + 0x38, 0x38, 0x00, 0x00, 0x70, 0x70, 0x00, 0x00, 0xe0, 0xe0, 0x00, 0x00, + 0xc1, 0xc1, 0x00, 0x00, + }}, + {16, + 16, + { + 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, + 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, + 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, + 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, + 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, + 0x88, 0x88, 0x00, 0x00, + }}, + {16, + 16, + { + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + }}, + {16, + 16, + { + 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, + 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, + 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, + 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, + 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, + 0x55, 0x55, 0x00, 0x00, + }}, + {16, + 16, + { + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + }}, + {16, + 16, + { + 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, + 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, + 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, + 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, + 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, + 0xcc, 0xcc, 0x00, 0x00, + }}, + {16, + 16, + { + 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + }}, + {16, + 16, + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, + 0x44, 0x44, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, + 0x22, 0x22, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + }}, + {16, + 16, + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, + 0x22, 0x22, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, + 0x44, 0x44, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + }}, + {16, + 16, + { + 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + }}, + {16, + 16, + { + 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, + 0x80, 0x80, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, + 0x08, 0x08, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, + 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, + 0x08, 0x08, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, + 0x08, 0x08, 0x00, 0x00, + }}, + {16, + 16, + { + 0x80, 0x80, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, + 0x02, 0x02, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, + 0x20, 0x20, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, + 0x08, 0x08, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, + 0x10, 0x10, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x20, 0x20, 0x00, 0x00, + 0x04, 0x04, 0x00, 0x00, + }}, + {16, + 16, + { + 0xb1, 0xb1, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, + 0x1b, 0x1b, 0x00, 0x00, 0xd8, 0xd8, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, + 0x0c, 0x0c, 0x00, 0x00, 0x8d, 0x8d, 0x00, 0x00, 0xb1, 0xb1, 0x00, 0x00, + 0x30, 0x30, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x1b, 0x1b, 0x00, 0x00, + 0xd8, 0xd8, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x00, + 0x8d, 0x8d, 0x00, 0x00, + }}, + {16, + 16, + { + 0x81, 0x81, 0x00, 0x00, 0x42, 0x42, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00, + 0x18, 0x18, 0x00, 0x00, 0x81, 0x81, 0x00, 0x00, 0x42, 0x42, 0x00, 0x00, + 0x24, 0x24, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x81, 0x81, 0x00, 0x00, + 0x42, 0x42, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, + 0x81, 0x81, 0x00, 0x00, 0x42, 0x42, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00, + 0x18, 0x18, 0x00, 0x00, + }}, + {16, + 16, + { + 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x25, 0x25, 0x00, 0x00, + 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, + 0x25, 0x25, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x00, 0x00, 0x25, 0x25, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x25, 0x25, 0x00, 0x00, + 0xc0, 0xc0, 0x00, 0x00, + }}, + {16, + 16, + { + 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, + 0x08, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00, + 0x42, 0x42, 0x00, 0x00, 0x81, 0x81, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, + 0x02, 0x02, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, + 0x18, 0x18, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00, 0x42, 0x42, 0x00, 0x00, + 0x81, 0x81, 0x00, 0x00, + }}, + {16, + 16, + { + 0xff, 0xff, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, + 0x80, 0x80, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, + 0x08, 0x08, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, + 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, + 0x08, 0x08, 0x00, 0x00, + }}, + {16, + 16, + { + 0x88, 0x88, 0x00, 0x00, 0x54, 0x54, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, + 0x45, 0x45, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x14, 0x14, 0x00, 0x00, + 0x22, 0x22, 0x00, 0x00, 0x51, 0x51, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, + 0x54, 0x54, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x45, 0x45, 0x00, 0x00, + 0x88, 0x88, 0x00, 0x00, 0x14, 0x14, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, + 0x51, 0x51, 0x00, 0x00, + }}, + {16, + 16, + { + 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, + 0x55, 0x55, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, + 0xf0, 0xf0, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, + 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, + 0xf0, 0xf0, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, + 0xf0, 0xf0, 0x00, 0x00, + }}, + {16, + 16, + { + 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, + 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, + 0x01, 0x01, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x10, 0x10, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, + 0x80, 0x80, 0x00, 0x00, + }}, + {16, + 16, + { + 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + }}, + {16, + 16, + { + 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + }}, + {16, + 16, + { + 0x03, 0x03, 0x00, 0x00, 0x84, 0x84, 0x00, 0x00, 0x48, 0x48, 0x00, 0x00, + 0x30, 0x30, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, + 0x84, 0x84, 0x00, 0x00, 0x48, 0x48, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, + 0x0c, 0x0c, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, + 0x01, 0x01, 0x00, 0x00, + }}, + {16, + 16, + { + 0xff, 0xff, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, + 0x99, 0x99, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, + 0x66, 0x66, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, + 0x99, 0x99, 0x00, 0x00, + }}, + {16, + 16, + { + 0x77, 0x77, 0x00, 0x00, 0x89, 0x89, 0x00, 0x00, 0x8f, 0x8f, 0x00, 0x00, + 0x8f, 0x8f, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00, 0x98, 0x98, 0x00, 0x00, + 0xf8, 0xf8, 0x00, 0x00, 0xf8, 0xf8, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00, + 0x89, 0x89, 0x00, 0x00, 0x8f, 0x8f, 0x00, 0x00, 0x8f, 0x8f, 0x00, 0x00, + 0x77, 0x77, 0x00, 0x00, 0x98, 0x98, 0x00, 0x00, 0xf8, 0xf8, 0x00, 0x00, + 0xf8, 0xf8, 0x00, 0x00, + }}, + {16, + 16, + { + 0xff, 0xff, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, + 0x88, 0x88, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, + 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, + 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, + 0x88, 0x88, 0x00, 0x00, + }}, + {16, + 16, + { + 0x99, 0x99, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, + 0x99, 0x99, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, + 0x66, 0x66, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00, + 0x66, 0x66, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00, + 0x99, 0x99, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, + 0x99, 0x99, 0x00, 0x00, + }}, + {16, + 16, + { + 0xf0, 0xf0, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, + 0xf0, 0xf0, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, + 0x0f, 0x0f, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, + 0xf0, 0xf0, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, + 0x0f, 0x0f, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, + 0x0f, 0x0f, 0x00, 0x00, + }}, + {16, + 16, + { + 0x82, 0x82, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x28, 0x28, 0x00, 0x00, + 0x10, 0x10, 0x00, 0x00, 0x28, 0x28, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, + 0x82, 0x82, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x82, 0x82, 0x00, 0x00, + 0x44, 0x44, 0x00, 0x00, 0x28, 0x28, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, + 0x28, 0x28, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x82, 0x82, 0x00, 0x00, + 0x01, 0x01, 0x00, 0x00, + }}, + {16, + 16, + { + 0x10, 0x10, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, 0x7c, 0x7c, 0x00, 0x00, + 0xfe, 0xfe, 0x00, 0x00, 0x7c, 0x7c, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, + 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, + 0x38, 0x38, 0x00, 0x00, 0x7c, 0x7c, 0x00, 0x00, 0xfe, 0xfe, 0x00, 0x00, + 0x7c, 0x7c, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + }}, +}; + +} // namespace + +CFX_Graphics::CFX_Graphics() + : m_renderDevice(nullptr), m_aggGraphics(nullptr) {} + +FX_ERR CFX_Graphics::Create(CFX_RenderDevice* renderDevice, + FX_BOOL isAntialiasing) { + if (!renderDevice) + return FX_ERR_Parameter_Invalid; + if (m_type != FX_CONTEXT_None) + return FX_ERR_Property_Invalid; + + m_type = FX_CONTEXT_Device; + m_info.isAntialiasing = isAntialiasing; + m_renderDevice = renderDevice; + if (m_renderDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP) + return FX_ERR_Succeeded; + return FX_ERR_Indefinite; +} + +FX_ERR CFX_Graphics::Create(int32_t width, + int32_t height, + FXDIB_Format format, + FX_BOOL isNative, + FX_BOOL isAntialiasing) { + if (m_type != FX_CONTEXT_None) + return FX_ERR_Property_Invalid; + + m_type = FX_CONTEXT_Device; + m_info.isAntialiasing = isAntialiasing; + m_aggGraphics = new CAGG_Graphics; + return m_aggGraphics->Create(this, width, height, format); +} + +CFX_Graphics::~CFX_Graphics() { + delete m_aggGraphics; +} + +FX_ERR CFX_Graphics::GetDeviceCap(const int32_t capID, FX_DeviceCap& capVal) { + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + capVal = m_renderDevice->GetDeviceCaps(capID); + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::IsPrinterDevice(FX_BOOL& isPrinter) { + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + isPrinter = m_renderDevice->GetDeviceClass() == FXDC_PRINTER; + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::EnableAntialiasing(FX_BOOL isAntialiasing) { + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + m_info.isAntialiasing = isAntialiasing; + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::SaveGraphState() { + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + m_renderDevice->SaveState(); + m_infoStack.Add(new TInfo(m_info)); + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::RestoreGraphState() { + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + m_renderDevice->RestoreState(); + int32_t size = m_infoStack.GetSize(); + if (size <= 0) { + return FX_ERR_Intermediate_Value_Invalid; + } + int32_t topIndex = size - 1; + std::unique_ptr info( + reinterpret_cast(m_infoStack.GetAt(topIndex))); + if (!info) + return FX_ERR_Intermediate_Value_Invalid; + m_info = *info; + m_infoStack.RemoveAt(topIndex); + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::GetLineCap(CFX_GraphStateData::LineCap& lineCap) const { + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + lineCap = m_info.graphState.m_LineCap; + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::SetLineCap(CFX_GraphStateData::LineCap lineCap) { + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + m_info.graphState.m_LineCap = lineCap; + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::GetDashCount(int32_t& dashCount) const { + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + dashCount = m_info.graphState.m_DashCount; + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::GetLineDash(FX_FLOAT& dashPhase, + FX_FLOAT* dashArray) const { + if (!dashArray) + return FX_ERR_Parameter_Invalid; + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + dashPhase = m_info.graphState.m_DashPhase; + FXSYS_memcpy(dashArray, m_info.graphState.m_DashArray, + m_info.graphState.m_DashCount * sizeof(FX_FLOAT)); + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::SetLineDash(FX_FLOAT dashPhase, + FX_FLOAT* dashArray, + int32_t dashCount) { + if (dashCount > 0 && !dashArray) + return FX_ERR_Parameter_Invalid; + + dashCount = dashCount < 0 ? 0 : dashCount; + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + FX_FLOAT scale = 1.0; + if (m_info.isActOnDash) { + scale = m_info.graphState.m_LineWidth; + } + m_info.graphState.m_DashPhase = dashPhase; + m_info.graphState.SetDashCount(dashCount); + for (int32_t i = 0; i < dashCount; i++) { + m_info.graphState.m_DashArray[i] = dashArray[i] * scale; + } + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::SetLineDash(FX_DashStyle dashStyle) { + if (m_type == FX_CONTEXT_Device && m_renderDevice) + return RenderDeviceSetLineDash(dashStyle); + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::GetLineJoin(CFX_GraphStateData::LineJoin& lineJoin) const { + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + lineJoin = m_info.graphState.m_LineJoin; + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::SetLineJoin(CFX_GraphStateData::LineJoin lineJoin) { + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + m_info.graphState.m_LineJoin = lineJoin; + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::GetMiterLimit(FX_FLOAT& miterLimit) const { + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + miterLimit = m_info.graphState.m_MiterLimit; + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::SetMiterLimit(FX_FLOAT miterLimit) { + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + m_info.graphState.m_MiterLimit = miterLimit; + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::GetLineWidth(FX_FLOAT& lineWidth) const { + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + lineWidth = m_info.graphState.m_LineWidth; + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::SetLineWidth(FX_FLOAT lineWidth, FX_BOOL isActOnDash) { + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + m_info.graphState.m_LineWidth = lineWidth; + m_info.isActOnDash = isActOnDash; + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::GetStrokeAlignment( + FX_StrokeAlignment& strokeAlignment) const { + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + strokeAlignment = m_info.strokeAlignment; + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::SetStrokeAlignment(FX_StrokeAlignment strokeAlignment) { + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + m_info.strokeAlignment = strokeAlignment; + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::SetStrokeColor(CFX_Color* color) { + if (!color) + return FX_ERR_Parameter_Invalid; + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + m_info.strokeColor = color; + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::SetFillColor(CFX_Color* color) { + if (!color) + return FX_ERR_Parameter_Invalid; + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + m_info.fillColor = color; + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::StrokePath(CFX_Path* path, CFX_Matrix* matrix) { + if (!path) + return FX_ERR_Parameter_Invalid; + if (m_type == FX_CONTEXT_Device && m_renderDevice) + return RenderDeviceStrokePath(path, matrix); + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::FillPath(CFX_Path* path, + FX_FillMode fillMode, + CFX_Matrix* matrix) { + if (!path) + return FX_ERR_Parameter_Invalid; + if (m_type == FX_CONTEXT_Device && m_renderDevice) + return RenderDeviceFillPath(path, fillMode, matrix); + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::ClipPath(CFX_Path* path, + FX_FillMode fillMode, + CFX_Matrix* matrix) { + if (!path) + return FX_ERR_Parameter_Invalid; + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + FX_BOOL result = m_renderDevice->SetClip_PathFill( + path->GetPathData(), (CFX_Matrix*)matrix, fillMode); + if (!result) + return FX_ERR_Indefinite; + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::DrawImage(CFX_DIBSource* source, + const CFX_PointF& point, + CFX_Matrix* matrix) { + if (!source) + return FX_ERR_Parameter_Invalid; + if (m_type == FX_CONTEXT_Device && m_renderDevice) + return RenderDeviceDrawImage(source, point, matrix); + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::StretchImage(CFX_DIBSource* source, + const CFX_RectF& rect, + CFX_Matrix* matrix) { + if (!source) + return FX_ERR_Parameter_Invalid; + if (m_type == FX_CONTEXT_Device && m_renderDevice) + return RenderDeviceStretchImage(source, rect, matrix); + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::ConcatMatrix(const CFX_Matrix* matrix) { + if (!matrix) + return FX_ERR_Parameter_Invalid; + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + m_info.CTM.Concat(*matrix); + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +CFX_Matrix* CFX_Graphics::GetMatrix() { + if (m_type == FX_CONTEXT_Device && m_renderDevice) + return &m_info.CTM; + return nullptr; +} + +FX_ERR CFX_Graphics::GetClipRect(CFX_RectF& rect) const { + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + FX_RECT r = m_renderDevice->GetClipBox(); + rect.left = (FX_FLOAT)r.left; + rect.top = (FX_FLOAT)r.top; + rect.width = (FX_FLOAT)r.Width(); + rect.height = (FX_FLOAT)r.Height(); + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::SetClipRect(const CFX_RectF& rect) { + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + if (!m_renderDevice->SetClip_Rect( + FX_RECT(FXSYS_round(rect.left), FXSYS_round(rect.top), + FXSYS_round(rect.right()), FXSYS_round(rect.bottom())))) { + return FX_ERR_Method_Not_Supported; + } + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::ClearClip() { + if (m_type == FX_CONTEXT_Device && m_renderDevice) + return FX_ERR_Succeeded; + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::SetFont(CFX_Font* font) { + if (!font) + return FX_ERR_Parameter_Invalid; + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + m_info.font = font; + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::SetFontSize(const FX_FLOAT size) { + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + m_info.fontSize = size <= 0 ? 1.0f : size; + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::SetFontHScale(const FX_FLOAT scale) { + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + m_info.fontHScale = scale <= 0 ? 1.0f : scale; + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::SetCharSpacing(const FX_FLOAT spacing) { + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + m_info.fontSpacing = spacing < 0 ? 0 : spacing; + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::SetTextDrawingMode(const int32_t mode) { + if (m_type == FX_CONTEXT_Device && m_renderDevice) + return FX_ERR_Succeeded; + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::ShowText(const CFX_PointF& point, + const CFX_WideString& text, + CFX_Matrix* matrix) { + if (m_type == FX_CONTEXT_Device && m_renderDevice) + return RenderDeviceShowText(point, text, matrix); + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::CalcTextRect(CFX_RectF& rect, + const CFX_WideString& text, + FX_BOOL isMultiline, + CFX_Matrix* matrix) { + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + int32_t length = text.GetLength(); + FX_DWORD* charCodes = FX_Alloc(FX_DWORD, length); + FXTEXT_CHARPOS* charPos = FX_Alloc(FXTEXT_CHARPOS, length); + CalcTextInfo(text, charCodes, charPos, rect); + FX_Free(charPos); + FX_Free(charCodes); + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::Transfer(CFX_Graphics* graphics, + const CFX_Matrix* matrix) { + if (!graphics || !graphics->m_renderDevice) + return FX_ERR_Parameter_Invalid; + CFX_Matrix m; + m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, + m_info.CTM.f); + if (matrix) { + m.Concat(*matrix); + } + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + CFX_DIBitmap* bitmap = graphics->m_renderDevice->GetBitmap(); + FX_BOOL result = m_renderDevice->SetDIBits(bitmap, 0, 0); + if (!result) + return FX_ERR_Method_Not_Supported; + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +FX_ERR CFX_Graphics::Transfer(CFX_Graphics* graphics, + FX_FLOAT srcLeft, + FX_FLOAT srcTop, + const CFX_RectF& dstRect, + const CFX_Matrix* matrix) { + if (!graphics || !graphics->m_renderDevice) + return FX_ERR_Parameter_Invalid; + CFX_Matrix m; + m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, + m_info.CTM.f); + if (matrix) { + m.Concat(*matrix); + } + if (m_type == FX_CONTEXT_Device && m_renderDevice) { + CFX_DIBitmap bmp; + FX_BOOL result = + bmp.Create((int32_t)dstRect.width, (int32_t)dstRect.height, + graphics->m_renderDevice->GetBitmap()->GetFormat()); + if (!result) + return FX_ERR_Intermediate_Value_Invalid; + result = graphics->m_renderDevice->GetDIBits(&bmp, (int32_t)srcLeft, + (int32_t)srcTop); + if (!result) + return FX_ERR_Method_Not_Supported; + result = m_renderDevice->SetDIBits(&bmp, (int32_t)dstRect.left, + (int32_t)dstRect.top); + if (!result) + return FX_ERR_Method_Not_Supported; + return FX_ERR_Succeeded; + } + return FX_ERR_Property_Invalid; +} + +CFX_RenderDevice* CFX_Graphics::GetRenderDevice() { + return m_renderDevice; +} + +FX_ERR CFX_Graphics::InverseRect(const CFX_RectF& rect) { + if (!m_renderDevice) + return FX_ERR_Property_Invalid; + CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap(); + if (!bitmap) + return FX_ERR_Property_Invalid; + CFX_RectF temp(rect); + m_info.CTM.TransformRect(temp); + CFX_RectF r; + r.Set(0, 0, (FX_FLOAT)bitmap->GetWidth(), (FX_FLOAT)bitmap->GetWidth()); + r.Intersect(temp); + if (r.IsEmpty()) { + return FX_ERR_Parameter_Invalid; + } + FX_ARGB* pBuf = + (FX_ARGB*)(bitmap->GetBuffer() + int32_t(r.top) * bitmap->GetPitch()); + int32_t bottom = (int32_t)r.bottom(); + int32_t right = (int32_t)r.right(); + for (int32_t i = (int32_t)r.top; i < bottom; i++) { + FX_ARGB* pLine = pBuf + (int32_t)r.left; + for (int32_t j = (int32_t)r.left; j < right; j++) { + FX_ARGB c = *pLine; + *pLine++ = (c & 0xFF000000) | (0xFFFFFF - (c & 0x00FFFFFF)); + } + pBuf = (FX_ARGB*)((uint8_t*)pBuf + bitmap->GetPitch()); + } + return FX_ERR_Succeeded; +} + +FX_ERR CFX_Graphics::XorDIBitmap(const CFX_DIBitmap* srcBitmap, + const CFX_RectF& rect) { + if (!m_renderDevice) + return FX_ERR_Property_Invalid; + CFX_DIBitmap* dst = m_renderDevice->GetBitmap(); + if (!dst) + return FX_ERR_Property_Invalid; + CFX_RectF temp(rect); + m_info.CTM.TransformRect(temp); + CFX_RectF r; + r.Set(0, 0, (FX_FLOAT)dst->GetWidth(), (FX_FLOAT)dst->GetWidth()); + r.Intersect(temp); + if (r.IsEmpty()) { + return FX_ERR_Parameter_Invalid; + } + FX_ARGB* pSrcBuf = (FX_ARGB*)(srcBitmap->GetBuffer() + + int32_t(r.top) * srcBitmap->GetPitch()); + FX_ARGB* pDstBuf = + (FX_ARGB*)(dst->GetBuffer() + int32_t(r.top) * dst->GetPitch()); + int32_t bottom = (int32_t)r.bottom(); + int32_t right = (int32_t)r.right(); + for (int32_t i = (int32_t)r.top; i < bottom; i++) { + FX_ARGB* pSrcLine = pSrcBuf + (int32_t)r.left; + FX_ARGB* pDstLine = pDstBuf + (int32_t)r.left; + for (int32_t j = (int32_t)r.left; j < right; j++) { + FX_ARGB c = *pDstLine; + *pDstLine++ = + ArgbEncode(FXARGB_A(c), (c & 0xFFFFFF) ^ (*pSrcLine & 0xFFFFFF)); + pSrcLine++; + } + pSrcBuf = (FX_ARGB*)((uint8_t*)pSrcBuf + srcBitmap->GetPitch()); + pDstBuf = (FX_ARGB*)((uint8_t*)pDstBuf + dst->GetPitch()); + } + return FX_ERR_Succeeded; +} + +FX_ERR CFX_Graphics::EqvDIBitmap(const CFX_DIBitmap* srcBitmap, + const CFX_RectF& rect) { + if (!m_renderDevice) + return FX_ERR_Property_Invalid; + CFX_DIBitmap* dst = m_renderDevice->GetBitmap(); + if (!dst) + return FX_ERR_Property_Invalid; + CFX_RectF temp(rect); + m_info.CTM.TransformRect(temp); + CFX_RectF r; + r.Set(0, 0, (FX_FLOAT)dst->GetWidth(), (FX_FLOAT)dst->GetWidth()); + r.Intersect(temp); + if (r.IsEmpty()) { + return FX_ERR_Parameter_Invalid; + } + FX_ARGB* pSrcBuf = (FX_ARGB*)(srcBitmap->GetBuffer() + + int32_t(r.top) * srcBitmap->GetPitch()); + FX_ARGB* pDstBuf = + (FX_ARGB*)(dst->GetBuffer() + int32_t(r.top) * dst->GetPitch()); + int32_t bottom = (int32_t)r.bottom(); + int32_t right = (int32_t)r.right(); + for (int32_t i = (int32_t)r.top; i < bottom; i++) { + FX_ARGB* pSrcLine = pSrcBuf + (int32_t)r.left; + FX_ARGB* pDstLine = pDstBuf + (int32_t)r.left; + for (int32_t j = (int32_t)r.left; j < right; j++) { + FX_ARGB c = *pDstLine; + *pDstLine++ = + ArgbEncode(FXARGB_A(c), ~((c & 0xFFFFFF) ^ (*pSrcLine & 0xFFFFFF))); + pSrcLine++; + } + pSrcBuf = (FX_ARGB*)((uint8_t*)pSrcBuf + srcBitmap->GetPitch()); + pDstBuf = (FX_ARGB*)((uint8_t*)pDstBuf + dst->GetPitch()); + } + return FX_ERR_Succeeded; +} + +FX_ERR CFX_Graphics::RenderDeviceSetLineDash(FX_DashStyle dashStyle) { + switch (dashStyle) { + case FX_DASHSTYLE_Solid: { + m_info.graphState.SetDashCount(0); + return FX_ERR_Succeeded; + } + case FX_DASHSTYLE_Dash: { + FX_FLOAT dashArray[] = {3, 1}; + SetLineDash(0, dashArray, 2); + return FX_ERR_Succeeded; + } + case FX_DASHSTYLE_Dot: { + FX_FLOAT dashArray[] = {1, 1}; + SetLineDash(0, dashArray, 2); + return FX_ERR_Succeeded; + } + case FX_DASHSTYLE_DashDot: { + FX_FLOAT dashArray[] = {3, 1, 1, 1}; + SetLineDash(0, dashArray, 4); + return FX_ERR_Succeeded; + } + case FX_DASHSTYLE_DashDotDot: { + FX_FLOAT dashArray[] = {4, 1, 2, 1, 2, 1}; + SetLineDash(0, dashArray, 6); + return FX_ERR_Succeeded; + } + default: + return FX_ERR_Parameter_Invalid; + } +} + +FX_ERR CFX_Graphics::RenderDeviceStrokePath(CFX_Path* path, + CFX_Matrix* matrix) { + if (!m_info.strokeColor) + return FX_ERR_Property_Invalid; + CFX_Matrix m; + m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, + m_info.CTM.f); + if (matrix) { + m.Concat(*matrix); + } + switch (m_info.strokeColor->m_type) { + case FX_COLOR_Solid: { + FX_BOOL result = m_renderDevice->DrawPath( + path->GetPathData(), (CFX_Matrix*)&m, &m_info.graphState, 0x0, + m_info.strokeColor->m_info.argb, 0); + if (!result) + return FX_ERR_Indefinite; + return FX_ERR_Succeeded; + } + case FX_COLOR_Pattern: + return StrokePathWithPattern(path, &m); + case FX_COLOR_Shading: + return StrokePathWithShading(path, &m); + default: + return FX_ERR_Property_Invalid; + } +} + +FX_ERR CFX_Graphics::RenderDeviceFillPath(CFX_Path* path, + FX_FillMode fillMode, + CFX_Matrix* matrix) { + if (!m_info.fillColor) + return FX_ERR_Property_Invalid; + CFX_Matrix m; + m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, + m_info.CTM.f); + if (matrix) { + m.Concat(*matrix); + } + switch (m_info.fillColor->m_type) { + case FX_COLOR_Solid: { + FX_BOOL result = m_renderDevice->DrawPath( + path->GetPathData(), (CFX_Matrix*)&m, &m_info.graphState, + m_info.fillColor->m_info.argb, 0x0, fillMode); + if (!result) + return FX_ERR_Indefinite; + return FX_ERR_Succeeded; + } + case FX_COLOR_Pattern: + return FillPathWithPattern(path, fillMode, &m); + case FX_COLOR_Shading: + return FillPathWithShading(path, fillMode, &m); + default: + return FX_ERR_Property_Invalid; + } +} + +FX_ERR CFX_Graphics::RenderDeviceDrawImage(CFX_DIBSource* source, + const CFX_PointF& point, + CFX_Matrix* matrix) { + CFX_Matrix m1; + m1.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, + m_info.CTM.f); + if (matrix) { + m1.Concat(*matrix); + } + CFX_Matrix m2; + m2.Set((FX_FLOAT)source->GetWidth(), 0.0, 0.0, (FX_FLOAT)source->GetHeight(), + point.x, point.y); + m2.Concat(m1); + int32_t left, top; + std::unique_ptr bmp1(source->FlipImage(FALSE, TRUE)); + std::unique_ptr bmp2( + bmp1->TransformTo((CFX_Matrix*)&m2, left, top)); + CFX_RectF r; + GetClipRect(r); + CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap(); + CFX_DIBitmap bmp; + if (bmp.Create(bitmap->GetWidth(), bitmap->GetHeight(), FXDIB_Argb) && + m_renderDevice->GetDIBits(&bmp, 0, 0) && + bmp.TransferBitmap(FXSYS_round(r.left), FXSYS_round(r.top), + FXSYS_round(r.Width()), FXSYS_round(r.Height()), + bmp2.get(), FXSYS_round(r.left - left), + FXSYS_round(r.top - top)) && + m_renderDevice->SetDIBits(&bmp, 0, 0)) { + return FX_ERR_Succeeded; + } + return FX_ERR_Indefinite; +} + +FX_ERR CFX_Graphics::RenderDeviceStretchImage(CFX_DIBSource* source, + const CFX_RectF& rect, + CFX_Matrix* matrix) { + CFX_Matrix m1; + m1.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, + m_info.CTM.f); + if (matrix) { + m1.Concat(*matrix); + } + std::unique_ptr bmp1( + source->StretchTo((int32_t)rect.Width(), (int32_t)rect.Height())); + CFX_Matrix m2; + m2.Set(rect.Width(), 0.0, 0.0, rect.Height(), rect.left, rect.top); + m2.Concat(m1); + int32_t left, top; + std::unique_ptr bmp2(bmp1->FlipImage(FALSE, TRUE)); + std::unique_ptr bmp3( + bmp2->TransformTo((CFX_Matrix*)&m2, left, top)); + CFX_RectF r; + GetClipRect(r); + CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap(); + if (bitmap->CompositeBitmap(FXSYS_round(r.left), FXSYS_round(r.top), + FXSYS_round(r.Width()), FXSYS_round(r.Height()), + bmp3.get(), FXSYS_round(r.left - left), + FXSYS_round(r.top - top))) { + return FX_ERR_Succeeded; + } + return FX_ERR_Indefinite; +} + +FX_ERR CFX_Graphics::RenderDeviceShowText(const CFX_PointF& point, + const CFX_WideString& text, + CFX_Matrix* matrix) { + int32_t length = text.GetLength(); + FX_DWORD* charCodes = FX_Alloc(FX_DWORD, length); + FXTEXT_CHARPOS* charPos = FX_Alloc(FXTEXT_CHARPOS, length); + CFX_RectF rect; + rect.Set(point.x, point.y, 0, 0); + CalcTextInfo(text, charCodes, charPos, rect); + CFX_Matrix m; + m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, + m_info.CTM.f); + m.Translate(0, m_info.fontSize * m_info.fontHScale); + if (matrix) { + m.Concat(*matrix); + } + FX_BOOL result = m_renderDevice->DrawNormalText( + length, charPos, m_info.font, CFX_GEModule::Get()->GetFontCache(), + -m_info.fontSize * m_info.fontHScale, (CFX_Matrix*)&m, + m_info.fillColor->m_info.argb, FXTEXT_CLEARTYPE); + if (!result) + return FX_ERR_Indefinite; + FX_Free(charPos); + FX_Free(charCodes); + return FX_ERR_Succeeded; +} + +FX_ERR CFX_Graphics::StrokePathWithPattern(CFX_Path* path, CFX_Matrix* matrix) { + return FX_ERR_Method_Not_Supported; +} + +FX_ERR CFX_Graphics::StrokePathWithShading(CFX_Path* path, CFX_Matrix* matrix) { + return FX_ERR_Method_Not_Supported; +} + +FX_ERR CFX_Graphics::FillPathWithPattern(CFX_Path* path, + FX_FillMode fillMode, + CFX_Matrix* matrix) { + CFX_Pattern* pattern = m_info.fillColor->m_info.pattern; + CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap(); + int32_t width = bitmap->GetWidth(); + int32_t height = bitmap->GetHeight(); + CFX_DIBitmap bmp; + bmp.Create(width, height, FXDIB_Argb); + m_renderDevice->GetDIBits(&bmp, 0, 0); + + FX_HatchStyle hatchStyle = m_info.fillColor->m_info.pattern->m_hatchStyle; + if (hatchStyle < FX_HATCHSTYLE_Horizontal || + hatchStyle > FX_HATCHSTYLE_SolidDiamond) { + return FX_ERR_Intermediate_Value_Invalid; + } + const FX_HATCHDATA& data = hatchBitmapData[hatchStyle]; + CFX_DIBitmap mask; + mask.Create(data.width, data.height, FXDIB_1bppMask); + FXSYS_memcpy(mask.GetBuffer(), data.maskBits, mask.GetPitch() * data.height); + CFX_FloatRect rectf = path->GetPathData()->GetBoundingBox(); + if (matrix) { + rectf.Transform((const CFX_Matrix*)matrix); + } + FX_RECT rect(FXSYS_round(rectf.left), FXSYS_round(rectf.top), + FXSYS_round(rectf.right), FXSYS_round(rectf.bottom)); + CFX_FxgeDevice device; + device.Attach(&bmp); + device.FillRect(&rect, m_info.fillColor->m_info.pattern->m_backArgb); + for (int32_t j = rect.bottom; j < rect.top; j += mask.GetHeight()) { + for (int32_t i = rect.left; i < rect.right; i += mask.GetWidth()) { + device.SetBitMask(&mask, i, j, + m_info.fillColor->m_info.pattern->m_foreArgb); + } + } + + m_renderDevice->SaveState(); + m_renderDevice->SetClip_PathFill(path->GetPathData(), (CFX_Matrix*)matrix, + fillMode); + SetDIBitsWithMatrix(&bmp, &pattern->m_matrix); + m_renderDevice->RestoreState(); + return FX_ERR_Succeeded; +} + +FX_ERR CFX_Graphics::FillPathWithShading(CFX_Path* path, + FX_FillMode fillMode, + CFX_Matrix* matrix) { + CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap(); + int32_t width = bitmap->GetWidth(); + int32_t height = bitmap->GetHeight(); + FX_FLOAT start_x = m_info.fillColor->m_shading->m_beginPoint.x; + FX_FLOAT start_y = m_info.fillColor->m_shading->m_beginPoint.y; + FX_FLOAT end_x = m_info.fillColor->m_shading->m_endPoint.x; + FX_FLOAT end_y = m_info.fillColor->m_shading->m_endPoint.y; + CFX_DIBitmap bmp; + bmp.Create(width, height, FXDIB_Argb); + m_renderDevice->GetDIBits(&bmp, 0, 0); + int32_t pitch = bmp.GetPitch(); + FX_BOOL result = FALSE; + switch (m_info.fillColor->m_shading->m_type) { + case FX_SHADING_Axial: { + FX_FLOAT x_span = end_x - start_x; + FX_FLOAT y_span = end_y - start_y; + FX_FLOAT axis_len_square = (x_span * x_span) + (y_span * y_span); + for (int32_t row = 0; row < height; row++) { + FX_DWORD* dib_buf = (FX_DWORD*)(bmp.GetBuffer() + row * pitch); + for (int32_t column = 0; column < width; column++) { + FX_FLOAT x = (FX_FLOAT)(column); + FX_FLOAT y = (FX_FLOAT)(row); + FX_FLOAT scale = + (((x - start_x) * x_span) + ((y - start_y) * y_span)) / + axis_len_square; + if (scale < 0) { + if (!m_info.fillColor->m_shading->m_isExtendedBegin) { + continue; + } + scale = 0; + } else if (scale > 1.0f) { + if (!m_info.fillColor->m_shading->m_isExtendedEnd) { + continue; + } + scale = 1.0f; + } + int32_t index = (int32_t)(scale * (FX_SHADING_Steps - 1)); + dib_buf[column] = m_info.fillColor->m_shading->m_argbArray[index]; + } + } + result = TRUE; + break; + } + case FX_SHADING_Radial: { + FX_FLOAT start_r = m_info.fillColor->m_shading->m_beginRadius; + FX_FLOAT end_r = m_info.fillColor->m_shading->m_endRadius; + FX_FLOAT a = ((start_x - end_x) * (start_x - end_x)) + + ((start_y - end_y) * (start_y - end_y)) - + ((start_r - end_r) * (start_r - end_r)); + for (int32_t row = 0; row < height; row++) { + FX_DWORD* dib_buf = (FX_DWORD*)(bmp.GetBuffer() + row * pitch); + for (int32_t column = 0; column < width; column++) { + FX_FLOAT x = (FX_FLOAT)(column); + FX_FLOAT y = (FX_FLOAT)(row); + FX_FLOAT b = -2 * (((x - start_x) * (end_x - start_x)) + + ((y - start_y) * (end_y - start_y)) + + (start_r * (end_r - start_r))); + FX_FLOAT c = ((x - start_x) * (x - start_x)) + + ((y - start_y) * (y - start_y)) - (start_r * start_r); + FX_FLOAT s; + if (a == 0) { + s = -c / b; + } else { + FX_FLOAT b2_4ac = (b * b) - 4 * (a * c); + if (b2_4ac < 0) { + continue; + } + FX_FLOAT root = (FXSYS_sqrt(b2_4ac)); + FX_FLOAT s1, s2; + if (a > 0) { + s1 = (-b - root) / (2 * a); + s2 = (-b + root) / (2 * a); + } else { + s2 = (-b - root) / (2 * a); + s1 = (-b + root) / (2 * a); + } + if (s2 <= 1.0f || m_info.fillColor->m_shading->m_isExtendedEnd) { + s = (s2); + } else { + s = (s1); + } + if ((start_r) + s * (end_r - start_r) < 0) { + continue; + } + } + if (s < 0) { + if (!m_info.fillColor->m_shading->m_isExtendedBegin) { + continue; + } + s = 0; + } + if (s > 1.0f) { + if (!m_info.fillColor->m_shading->m_isExtendedEnd) { + continue; + } + s = 1.0f; + } + int index = (int32_t)(s * (FX_SHADING_Steps - 1)); + dib_buf[column] = m_info.fillColor->m_shading->m_argbArray[index]; + } + } + result = TRUE; + break; + } + default: { result = FALSE; } + } + if (result) { + m_renderDevice->SaveState(); + m_renderDevice->SetClip_PathFill(path->GetPathData(), (CFX_Matrix*)matrix, + fillMode); + SetDIBitsWithMatrix(&bmp, matrix); + m_renderDevice->RestoreState(); + } + return result; +} + +FX_ERR CFX_Graphics::SetDIBitsWithMatrix(CFX_DIBSource* source, + CFX_Matrix* matrix) { + if (matrix->IsIdentity()) { + m_renderDevice->SetDIBits(source, 0, 0); + } else { + CFX_Matrix m; + m.Set((FX_FLOAT)source->GetWidth(), 0, 0, (FX_FLOAT)source->GetHeight(), 0, + 0); + m.Concat(*matrix); + int32_t left, top; + std::unique_ptr bmp1(source->FlipImage(FALSE, TRUE)); + std::unique_ptr bmp2( + bmp1->TransformTo((CFX_Matrix*)&m, left, top)); + m_renderDevice->SetDIBits(bmp2.get(), left, top); + } + return FX_ERR_Succeeded; +} + +FX_ERR CFX_Graphics::CalcTextInfo(const CFX_WideString& text, + FX_DWORD* charCodes, + FXTEXT_CHARPOS* charPos, + CFX_RectF& rect) { + std::unique_ptr encoding( + new CFX_UnicodeEncoding(m_info.font)); + int32_t length = text.GetLength(); + FX_FLOAT penX = (FX_FLOAT)rect.left; + FX_FLOAT penY = (FX_FLOAT)rect.top; + FX_FLOAT left = (FX_FLOAT)(0); + FX_FLOAT top = (FX_FLOAT)(0); + charCodes[0] = text.GetAt(0); + charPos[0].m_OriginX = penX + left; + charPos[0].m_OriginY = penY + top; + charPos[0].m_GlyphIndex = encoding->GlyphFromCharCode(charCodes[0]); + charPos[0].m_FontCharWidth = FXSYS_round( + m_info.font->GetGlyphWidth(charPos[0].m_GlyphIndex) * m_info.fontHScale); + charPos[0].m_bGlyphAdjust = TRUE; + charPos[0].m_AdjustMatrix[0] = -1; + charPos[0].m_AdjustMatrix[1] = 0; + charPos[0].m_AdjustMatrix[2] = 0; + charPos[0].m_AdjustMatrix[3] = 1; + penX += (FX_FLOAT)(charPos[0].m_FontCharWidth) * m_info.fontSize / 1000 + + m_info.fontSpacing; + for (int32_t i = 1; i < length; i++) { + charCodes[i] = text.GetAt(i); + charPos[i].m_OriginX = penX + left; + charPos[i].m_OriginY = penY + top; + charPos[i].m_GlyphIndex = encoding->GlyphFromCharCode(charCodes[i]); + charPos[i].m_FontCharWidth = + FXSYS_round(m_info.font->GetGlyphWidth(charPos[i].m_GlyphIndex) * + m_info.fontHScale); + charPos[i].m_bGlyphAdjust = TRUE; + charPos[i].m_AdjustMatrix[0] = -1; + charPos[i].m_AdjustMatrix[1] = 0; + charPos[i].m_AdjustMatrix[2] = 0; + charPos[i].m_AdjustMatrix[3] = 1; + penX += (FX_FLOAT)(charPos[i].m_FontCharWidth) * m_info.fontSize / 1000 + + m_info.fontSpacing; + } + rect.width = (FX_FLOAT)penX - rect.left; + rect.height = rect.top + m_info.fontSize * m_info.fontHScale - rect.top; + return FX_ERR_Succeeded; +} + +CFX_Graphics::TInfo::TInfo(const TInfo& info) + : graphState(info.graphState), + isAntialiasing(info.isAntialiasing), + strokeAlignment(info.strokeAlignment), + CTM(info.CTM), + isActOnDash(info.isActOnDash), + strokeColor(info.strokeColor), + fillColor(info.fillColor), + font(info.font), + fontSize(info.fontSize), + fontHScale(info.fontHScale), + fontSpacing(info.fontSpacing) {} + +CFX_Graphics::TInfo& CFX_Graphics::TInfo::operator=(const TInfo& other) { + graphState.Copy(other.graphState); + isAntialiasing = other.isAntialiasing; + strokeAlignment = other.strokeAlignment; + CTM = other.CTM; + isActOnDash = other.isActOnDash; + strokeColor = other.strokeColor; + fillColor = other.fillColor; + font = other.font; + fontSize = other.fontSize; + fontHScale = other.fontHScale; + fontSpacing = other.fontSpacing; + return *this; +} diff --git a/xfa/fxgraphics/cfx_path.cpp b/xfa/fxgraphics/cfx_path.cpp new file mode 100644 index 0000000000..2acdc3eac2 --- /dev/null +++ b/xfa/fxgraphics/cfx_path.cpp @@ -0,0 +1,179 @@ +// 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 "xfa/fxgraphics/cfx_path.h" + +#include "xfa/fxgraphics/cfx_path_generator.h" + +CFX_Path::CFX_Path() { + m_generator = nullptr; +} + +FX_ERR CFX_Path::Create() { + if (m_generator) + return FX_ERR_Property_Invalid; + + m_generator = new CFX_PathGenerator; + m_generator->Create(); + return FX_ERR_Succeeded; +} + +CFX_Path::~CFX_Path() { + delete m_generator; +} + +FX_ERR CFX_Path::MoveTo(FX_FLOAT x, FX_FLOAT y) { + if (!m_generator) + return FX_ERR_Property_Invalid; + m_generator->MoveTo(x, y); + return FX_ERR_Succeeded; +} + +FX_ERR CFX_Path::LineTo(FX_FLOAT x, FX_FLOAT y) { + if (!m_generator) + return FX_ERR_Property_Invalid; + m_generator->LineTo(x, y); + return FX_ERR_Succeeded; +} + +FX_ERR CFX_Path::BezierTo(FX_FLOAT ctrlX1, + FX_FLOAT ctrlY1, + FX_FLOAT ctrlX2, + FX_FLOAT ctrlY2, + FX_FLOAT toX, + FX_FLOAT toY) { + if (!m_generator) + return FX_ERR_Property_Invalid; + m_generator->BezierTo(ctrlX1, ctrlY1, ctrlX2, ctrlY2, toX, toY); + return FX_ERR_Succeeded; +} + +FX_ERR CFX_Path::ArcTo(FX_FLOAT left, + FX_FLOAT top, + FX_FLOAT width, + FX_FLOAT height, + FX_FLOAT startAngle, + FX_FLOAT sweepAngle) { + if (!m_generator) + return FX_ERR_Property_Invalid; + m_generator->ArcTo(left + width / 2, top + height / 2, width / 2, height / 2, + startAngle, sweepAngle); + return FX_ERR_Succeeded; +} + +FX_ERR CFX_Path::Close() { + if (!m_generator) + return FX_ERR_Property_Invalid; + m_generator->Close(); + return FX_ERR_Succeeded; +} + +FX_ERR CFX_Path::AddLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2) { + if (!m_generator) + return FX_ERR_Property_Invalid; + m_generator->AddLine(x1, y1, x2, y2); + return FX_ERR_Succeeded; +} + +FX_ERR CFX_Path::AddBezier(FX_FLOAT startX, + FX_FLOAT startY, + FX_FLOAT ctrlX1, + FX_FLOAT ctrlY1, + FX_FLOAT ctrlX2, + FX_FLOAT ctrlY2, + FX_FLOAT endX, + FX_FLOAT endY) { + if (!m_generator) + return FX_ERR_Property_Invalid; + m_generator->AddBezier(startX, startY, ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, + endY); + return FX_ERR_Succeeded; +} + +FX_ERR CFX_Path::AddRectangle(FX_FLOAT left, + FX_FLOAT top, + FX_FLOAT width, + FX_FLOAT height) { + if (!m_generator) + return FX_ERR_Property_Invalid; + m_generator->AddRectangle(left, top, left + width, top + height); + return FX_ERR_Succeeded; +} + +FX_ERR CFX_Path::AddEllipse(FX_FLOAT left, + FX_FLOAT top, + FX_FLOAT width, + FX_FLOAT height) { + if (!m_generator) + return FX_ERR_Property_Invalid; + m_generator->AddEllipse(left + width / 2, top + height / 2, width / 2, + height / 2); + return FX_ERR_Succeeded; +} + +FX_ERR CFX_Path::AddEllipse(const CFX_RectF& rect) { + if (!m_generator) + return FX_ERR_Property_Invalid; + m_generator->AddEllipse(rect.left + rect.Width() / 2, + rect.top + rect.Height() / 2, rect.Width() / 2, + rect.Height() / 2); + return FX_ERR_Succeeded; +} + +FX_ERR CFX_Path::AddArc(FX_FLOAT left, + FX_FLOAT top, + FX_FLOAT width, + FX_FLOAT height, + FX_FLOAT startAngle, + FX_FLOAT sweepAngle) { + if (!m_generator) + return FX_ERR_Property_Invalid; + m_generator->AddArc(left + width / 2, top + height / 2, width / 2, height / 2, + startAngle, sweepAngle); + return FX_ERR_Succeeded; +} + +FX_ERR CFX_Path::AddPie(FX_FLOAT left, + FX_FLOAT top, + FX_FLOAT width, + FX_FLOAT height, + FX_FLOAT startAngle, + FX_FLOAT sweepAngle) { + if (!m_generator) + return FX_ERR_Property_Invalid; + m_generator->AddPie(left + width / 2, top + height / 2, width / 2, height / 2, + startAngle, sweepAngle); + return FX_ERR_Succeeded; +} + +FX_ERR CFX_Path::AddSubpath(CFX_Path* path) { + if (!m_generator) + return FX_ERR_Property_Invalid; + m_generator->AddPathData(path->GetPathData()); + return FX_ERR_Succeeded; +} + +FX_ERR CFX_Path::Clear() { + if (!m_generator) + return FX_ERR_Property_Invalid; + m_generator->GetPathData()->SetPointCount(0); + return FX_ERR_Succeeded; +} + +FX_BOOL CFX_Path::IsEmpty() { + if (!m_generator) + return FX_ERR_Property_Invalid; + if (m_generator->GetPathData()->GetPointCount() == 0) { + return TRUE; + } + return FALSE; +} + +CFX_PathData* CFX_Path::GetPathData() { + if (!m_generator) + return nullptr; + return m_generator->GetPathData(); +} diff --git a/xfa/fxgraphics/cfx_path.h b/xfa/fxgraphics/cfx_path.h new file mode 100644 index 0000000000..e8e31b3876 --- /dev/null +++ b/xfa/fxgraphics/cfx_path.h @@ -0,0 +1,78 @@ +// 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 XFA_FXGRAPHICS_CFX_PATH_H_ +#define XFA_FXGRAPHICS_CFX_PATH_H_ + +#include "core/include/fxcrt/fx_system.h" +#include "xfa/fxgraphics/include/cfx_graphics.h" + +class CFX_PathData; +class CFX_PathGenerator; + +class CFX_Path { + public: + CFX_Path(); + virtual ~CFX_Path(); + + FX_ERR Create(); + FX_ERR MoveTo(FX_FLOAT x, FX_FLOAT y); + FX_ERR LineTo(FX_FLOAT x, FX_FLOAT y); + FX_ERR BezierTo(FX_FLOAT ctrlX1, + FX_FLOAT ctrlY1, + FX_FLOAT ctrlX2, + FX_FLOAT ctrlY2, + FX_FLOAT toX, + FX_FLOAT toY); + FX_ERR ArcTo(FX_FLOAT left, + FX_FLOAT top, + FX_FLOAT width, + FX_FLOAT height, + FX_FLOAT startAngle, + FX_FLOAT sweepAngle); + FX_ERR Close(); + + FX_ERR AddLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2); + FX_ERR AddBezier(FX_FLOAT startX, + FX_FLOAT startY, + FX_FLOAT ctrlX1, + FX_FLOAT ctrlY1, + FX_FLOAT ctrlX2, + FX_FLOAT ctrlY2, + FX_FLOAT endX, + FX_FLOAT endY); + FX_ERR AddRectangle(FX_FLOAT left, + FX_FLOAT top, + FX_FLOAT width, + FX_FLOAT height); + FX_ERR AddEllipse(FX_FLOAT left, + FX_FLOAT top, + FX_FLOAT width, + FX_FLOAT height); + FX_ERR AddEllipse(const CFX_RectF& rect); + FX_ERR AddArc(FX_FLOAT left, + FX_FLOAT top, + FX_FLOAT width, + FX_FLOAT height, + FX_FLOAT startAngle, + FX_FLOAT sweepAngle); + FX_ERR AddPie(FX_FLOAT left, + FX_FLOAT top, + FX_FLOAT width, + FX_FLOAT height, + FX_FLOAT startAngle, + FX_FLOAT sweepAngle); + FX_ERR AddSubpath(CFX_Path* path); + FX_ERR Clear(); + + FX_BOOL IsEmpty(); + CFX_PathData* GetPathData(); + + private: + CFX_PathGenerator* m_generator; +}; + +#endif // XFA_FXGRAPHICS_CFX_PATH_H_ diff --git a/xfa/fxgraphics/cfx_path_generator.cpp b/xfa/fxgraphics/cfx_path_generator.cpp new file mode 100644 index 0000000000..ace3da154f --- /dev/null +++ b/xfa/fxgraphics/cfx_path_generator.cpp @@ -0,0 +1,199 @@ +// 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 "xfa/fxgraphics/cfx_path_generator.h" + +CFX_PathGenerator::CFX_PathGenerator() { + m_pPathData = NULL; +} +void CFX_PathGenerator::Create() { + m_pPathData = new CFX_PathData; +} +CFX_PathGenerator::~CFX_PathGenerator() { + if (m_pPathData) { + delete m_pPathData; + m_pPathData = NULL; + } +} +void CFX_PathGenerator::AddPathData(CFX_PathData* pPathData) { + if (pPathData && pPathData->GetPointCount() > 0) { + int nCount = pPathData->GetPointCount(); + FX_PATHPOINT* pPoints = pPathData->GetPoints(); + AddPathData(pPoints, nCount); + } +} +void CFX_PathGenerator::AddPathData(FX_PATHPOINT* pPoints, int nCount) { + if (pPoints && nCount > 0) { + int nOldCount = m_pPathData->GetPointCount(); + m_pPathData->AddPointCount(nCount); + FX_PATHPOINT* pDstPoints = m_pPathData->GetPoints(); + FXSYS_memcpy(pDstPoints + nOldCount, pPoints, + sizeof(FX_PATHPOINT) * nCount); + } +} +void CFX_PathGenerator::MoveTo(FX_FLOAT x, FX_FLOAT y) { + m_pPathData->AddPointCount(1); + m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, x, y, FXPT_MOVETO); +} +void CFX_PathGenerator::LineTo(FX_FLOAT x, FX_FLOAT y) { + m_pPathData->AddPointCount(1); + m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, x, y, FXPT_LINETO); +} +void CFX_PathGenerator::BezierTo(FX_FLOAT ctrl_x1, + FX_FLOAT ctrl_y1, + FX_FLOAT ctrl_x2, + FX_FLOAT ctrl_y2, + FX_FLOAT to_x, + FX_FLOAT to_y) { + int old_count = m_pPathData->GetPointCount(); + m_pPathData->AddPointCount(3); + m_pPathData->SetPoint(old_count, ctrl_x1, ctrl_y1, FXPT_BEZIERTO); + m_pPathData->SetPoint(old_count + 1, ctrl_x2, ctrl_y2, FXPT_BEZIERTO); + m_pPathData->SetPoint(old_count + 2, to_x, to_y, FXPT_BEZIERTO); +} +void CFX_PathGenerator::Close() { + if (m_pPathData->GetPointCount() > 0) { + int index = m_pPathData->GetPointCount() - 1; + FX_PATHPOINT* pPoints = m_pPathData->GetPoints(); + pPoints[index].m_Flag |= FXPT_CLOSEFIGURE; + } +} +void CFX_PathGenerator::AddLine(FX_FLOAT x1, + FX_FLOAT y1, + FX_FLOAT x2, + FX_FLOAT y2) { + int old_count = m_pPathData->GetPointCount(); + m_pPathData->AddPointCount(2); + m_pPathData->SetPoint(old_count, x1, y1, FXPT_MOVETO); + m_pPathData->SetPoint(old_count + 1, x2, y2, FXPT_LINETO); +} +void CFX_PathGenerator::AddBezier(FX_FLOAT start_x, + FX_FLOAT start_y, + FX_FLOAT ctrl_x1, + FX_FLOAT ctrl_y1, + FX_FLOAT ctrl_x2, + FX_FLOAT ctrl_y2, + FX_FLOAT end_x, + FX_FLOAT end_y) { + int old_count = m_pPathData->GetPointCount(); + m_pPathData->AddPointCount(4); + m_pPathData->SetPoint(old_count, start_x, start_y, FXPT_MOVETO); + m_pPathData->SetPoint(old_count + 1, ctrl_x1, ctrl_y1, FXPT_BEZIERTO); + m_pPathData->SetPoint(old_count + 2, ctrl_x2, ctrl_y2, FXPT_BEZIERTO); + m_pPathData->SetPoint(old_count + 3, end_x, end_y, FXPT_BEZIERTO); +} +void CFX_PathGenerator::AddRectangle(FX_FLOAT x1, + FX_FLOAT y1, + FX_FLOAT x2, + FX_FLOAT y2) { + m_pPathData->AppendRect(x1, y1, x2, y2); +} +void CFX_PathGenerator::AddEllipse(FX_FLOAT x, + FX_FLOAT y, + FX_FLOAT width, + FX_FLOAT height) { + AddArc(x, y, width, height, 0, FX_PI * 2); +} +void CFX_PathGenerator::ArcTo(FX_FLOAT x, + FX_FLOAT y, + FX_FLOAT width, + FX_FLOAT height, + FX_FLOAT start_angle, + FX_FLOAT sweep_angle) { + FX_FLOAT x0 = FXSYS_cos(sweep_angle / 2); + FX_FLOAT y0 = FXSYS_sin(sweep_angle / 2); + FX_FLOAT tx = ((1.0f - x0) * 4) / (3 * 1.0f); + FX_FLOAT ty = y0 - ((tx * x0) / y0); + FX_FLOAT px[3], py[3]; + px[0] = x0 + tx; + py[0] = -ty; + px[1] = x0 + tx; + py[1] = ty; + FX_FLOAT sn = FXSYS_sin(start_angle + sweep_angle / 2); + FX_FLOAT cs = FXSYS_cos(start_angle + sweep_angle / 2); + int old_count = m_pPathData->GetPointCount(); + m_pPathData->AddPointCount(3); + FX_FLOAT bezier_x, bezier_y; + bezier_x = x + (width * ((px[0] * cs) - (py[0] * sn))); + bezier_y = y + (height * ((px[0] * sn) + (py[0] * cs))); + m_pPathData->SetPoint(old_count, bezier_x, bezier_y, FXPT_BEZIERTO); + bezier_x = x + (width * ((px[1] * cs) - (py[1] * sn))); + bezier_y = y + (height * ((px[1] * sn) + (py[1] * cs))); + m_pPathData->SetPoint(old_count + 1, bezier_x, bezier_y, FXPT_BEZIERTO); + bezier_x = x + (width * FXSYS_cos(start_angle + sweep_angle)); + bezier_y = y + (height * FXSYS_sin(start_angle + sweep_angle)); + m_pPathData->SetPoint(old_count + 2, bezier_x, bezier_y, FXPT_BEZIERTO); +} +void CFX_PathGenerator::AddArc(FX_FLOAT x, + FX_FLOAT y, + FX_FLOAT width, + FX_FLOAT height, + FX_FLOAT start_angle, + FX_FLOAT sweep_angle) { + if (sweep_angle == 0) { + return; + } + + const FX_FLOAT bezier_arc_angle_epsilon = 0.01f; + while (start_angle > FX_PI * 2) { + start_angle -= FX_PI * 2; + } + while (start_angle < 0) { + start_angle += FX_PI * 2; + } + if (sweep_angle >= FX_PI * 2) { + sweep_angle = FX_PI * 2; + } + if (sweep_angle <= -FX_PI * 2) { + sweep_angle = -FX_PI * 2; + } + m_pPathData->AddPointCount(1); + m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, + x + (width * FXSYS_cos(start_angle)), + y + (height * FXSYS_sin(start_angle)), FXPT_MOVETO); + FX_FLOAT total_sweep = 0, local_sweep = 0, prev_sweep = 0; + FX_BOOL done = FALSE; + do { + if (sweep_angle < 0) { + prev_sweep = total_sweep; + local_sweep = -FX_PI / 2; + total_sweep -= FX_PI / 2; + if (total_sweep <= sweep_angle + bezier_arc_angle_epsilon) { + local_sweep = sweep_angle - prev_sweep; + done = TRUE; + } + } else { + prev_sweep = total_sweep; + local_sweep = FX_PI / 2; + total_sweep += FX_PI / 2; + if (total_sweep >= sweep_angle - bezier_arc_angle_epsilon) { + local_sweep = sweep_angle - prev_sweep; + done = TRUE; + } + } + ArcTo(x, y, width, height, start_angle, local_sweep); + start_angle += local_sweep; + } while (!done); +} +void CFX_PathGenerator::AddPie(FX_FLOAT x, + FX_FLOAT y, + FX_FLOAT width, + FX_FLOAT height, + FX_FLOAT start_angle, + FX_FLOAT sweep_angle) { + if (sweep_angle == 0) { + int old_count = m_pPathData->GetPointCount(); + m_pPathData->AddPointCount(2); + m_pPathData->SetPoint(old_count, x, y, FXPT_MOVETO); + m_pPathData->SetPoint(old_count + 1, x + (width * FXSYS_cos(start_angle)), + y + (height * FXSYS_sin(start_angle)), FXPT_LINETO); + return; + } + AddArc(x, y, width, height, start_angle, sweep_angle); + m_pPathData->AddPointCount(1); + m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, x, y, + FXPT_LINETO | FXPT_CLOSEFIGURE); +} diff --git a/xfa/fxgraphics/cfx_path_generator.h b/xfa/fxgraphics/cfx_path_generator.h new file mode 100644 index 0000000000..efe316697d --- /dev/null +++ b/xfa/fxgraphics/cfx_path_generator.h @@ -0,0 +1,67 @@ +// 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 XFA_FXGRAPHICS_CFX_PATH_GENERATOR_H_ +#define XFA_FXGRAPHICS_CFX_PATH_GENERATOR_H_ + +#include "core/include/fxge/fx_ge.h" + +class CFX_PathGenerator { + public: + CFX_PathGenerator(); + ~CFX_PathGenerator(); + + void Create(); + CFX_PathData* GetPathData() const { return m_pPathData; } + + void AddPathData(CFX_PathData* path_data); + void AddPathData(FX_PATHPOINT* points, int count); + + void MoveTo(FX_FLOAT x, FX_FLOAT y); + void LineTo(FX_FLOAT x, FX_FLOAT y); + void BezierTo(FX_FLOAT ctrl_x1, + FX_FLOAT ctrl_y1, + FX_FLOAT ctrl_x2, + FX_FLOAT ctrl_y2, + FX_FLOAT to_x, + FX_FLOAT to_y); + void Close(); + void ArcTo(FX_FLOAT x, + FX_FLOAT y, + FX_FLOAT width, + FX_FLOAT height, + FX_FLOAT start_angle, + FX_FLOAT sweep_angle); + + void AddLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2); + void AddBezier(FX_FLOAT start_x, + FX_FLOAT start_y, + FX_FLOAT ctrl_x1, + FX_FLOAT ctrl_y1, + FX_FLOAT ctrl_x2, + FX_FLOAT ctrl_y2, + FX_FLOAT end_x, + FX_FLOAT end_y); + void AddRectangle(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2); + void AddEllipse(FX_FLOAT x, FX_FLOAT y, FX_FLOAT width, FX_FLOAT height); + void AddArc(FX_FLOAT x, + FX_FLOAT y, + FX_FLOAT width, + FX_FLOAT height, + FX_FLOAT start_angle, + FX_FLOAT sweep_angle); + void AddPie(FX_FLOAT x, + FX_FLOAT y, + FX_FLOAT width, + FX_FLOAT height, + FX_FLOAT start_angle, + FX_FLOAT sweep_angle); + + protected: + CFX_PathData* m_pPathData; +}; + +#endif // XFA_FXGRAPHICS_CFX_PATH_GENERATOR_H_ diff --git a/xfa/fxgraphics/cfx_pattern.cpp b/xfa/fxgraphics/cfx_pattern.cpp new file mode 100644 index 0000000000..f70a78d566 --- /dev/null +++ b/xfa/fxgraphics/cfx_pattern.cpp @@ -0,0 +1,26 @@ +// 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 "xfa/fxgraphics/cfx_pattern.h" + +CFX_Pattern::CFX_Pattern(FX_HatchStyle hatchStyle, + const FX_ARGB foreArgb, + const FX_ARGB backArgb, + CFX_Matrix* matrix) + : m_hatchStyle(hatchStyle), m_foreArgb(foreArgb), m_backArgb(backArgb) { + ASSERT(m_hatchStyle >= FX_HATCHSTYLE_Horizontal && + m_hatchStyle <= FX_HATCHSTYLE_SolidDiamond); + + if (matrix) { + // TODO(dsinclair): Add a Set(const CFX_Matrix&) method. pdfium:436 + m_matrix.Set(matrix->a, matrix->b, matrix->c, matrix->d, matrix->e, + matrix->f); + } else { + m_matrix.SetIdentity(); + } +} + +CFX_Pattern::~CFX_Pattern() {} diff --git a/xfa/fxgraphics/cfx_pattern.h b/xfa/fxgraphics/cfx_pattern.h new file mode 100644 index 0000000000..e4c1b096f6 --- /dev/null +++ b/xfa/fxgraphics/cfx_pattern.h @@ -0,0 +1,36 @@ +// 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 XFA_FXGRAPHICS_CFX_PATTERN_H_ +#define XFA_FXGRAPHICS_CFX_PATTERN_H_ + +#include "core/include/fxcrt/fx_coordinates.h" +#include "core/include/fxcrt/fx_system.h" +#include "xfa/fxgraphics/include/cfx_graphics.h" + +class CFX_DIBitmap; +class CFX_Matrix; + +class CFX_Pattern { + public: + CFX_Pattern(FX_HatchStyle hatchStyle, + const FX_ARGB foreArgb, + const FX_ARGB backArgb, + CFX_Matrix* matrix = nullptr); + + virtual ~CFX_Pattern(); + + private: + friend class CFX_Graphics; + + CFX_Matrix m_matrix; + + const FX_HatchStyle m_hatchStyle; + const FX_ARGB m_foreArgb; + const FX_ARGB m_backArgb; +}; + +#endif // XFA_FXGRAPHICS_CFX_PATTERN_H_ diff --git a/xfa/fxgraphics/cfx_shading.cpp b/xfa/fxgraphics/cfx_shading.cpp new file mode 100644 index 0000000000..8be8b03e26 --- /dev/null +++ b/xfa/fxgraphics/cfx_shading.cpp @@ -0,0 +1,78 @@ +// 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 "xfa/fxgraphics/cfx_shading.h" + +CFX_Shading::CFX_Shading(const CFX_PointF& beginPoint, + const CFX_PointF& endPoint, + FX_BOOL isExtendedBegin, + FX_BOOL isExtendedEnd, + const FX_ARGB beginArgb, + const FX_ARGB endArgb) + : m_type(FX_SHADING_Axial), + m_beginPoint(beginPoint), + m_endPoint(endPoint), + m_beginRadius(0), + m_endRadius(0), + m_isExtendedBegin(isExtendedBegin), + m_isExtendedEnd(isExtendedEnd), + m_beginArgb(beginArgb), + m_endArgb(endArgb) { + InitArgbArray(); +} + +CFX_Shading::CFX_Shading(const CFX_PointF& beginPoint, + const CFX_PointF& endPoint, + const FX_FLOAT beginRadius, + const FX_FLOAT endRadius, + FX_BOOL isExtendedBegin, + FX_BOOL isExtendedEnd, + const FX_ARGB beginArgb, + const FX_ARGB endArgb) + : m_type(FX_SHADING_Radial), + m_beginPoint(beginPoint), + m_endPoint(endPoint), + m_beginRadius(beginRadius), + m_endRadius(endRadius), + m_isExtendedBegin(isExtendedBegin), + m_isExtendedEnd(isExtendedEnd), + m_beginArgb(beginArgb), + m_endArgb(endArgb) { + InitArgbArray(); +} + +CFX_Shading::~CFX_Shading() {} + +void CFX_Shading::InitArgbArray() { + int32_t a1; + int32_t r1; + int32_t g1; + int32_t b1; + ArgbDecode(m_beginArgb, a1, r1, g1, b1); + + int32_t a2; + int32_t r2; + int32_t g2; + int32_t b2; + ArgbDecode(m_endArgb, a2, r2, g2, b2); + + FX_FLOAT f = (FX_FLOAT)(FX_SHADING_Steps - 1); + FX_FLOAT aScale = 1.0 * (a2 - a1) / f; + FX_FLOAT rScale = 1.0 * (r2 - r1) / f; + FX_FLOAT gScale = 1.0 * (g2 - g1) / f; + FX_FLOAT bScale = 1.0 * (b2 - b1) / f; + + for (int32_t i = 0; i < FX_SHADING_Steps; i++) { + int32_t a3 = static_cast(i * aScale); + int32_t r3 = static_cast(i * rScale); + int32_t g3 = static_cast(i * gScale); + int32_t b3 = static_cast(i * bScale); + + // TODO(dsinclair): Add overloads for FX_ARGB. pdfium:437 + m_argbArray[i] = + FXARGB_TODIB(FXARGB_MAKE(a1 + a3, r1 + r3, g1 + g3, b1 + b3)); + } +} diff --git a/xfa/fxgraphics/cfx_shading.h b/xfa/fxgraphics/cfx_shading.h new file mode 100644 index 0000000000..d56807616a --- /dev/null +++ b/xfa/fxgraphics/cfx_shading.h @@ -0,0 +1,56 @@ +// 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 XFA_FXGRAPHICS_CFX_SHADING_H_ +#define XFA_FXGRAPHICS_CFX_SHADING_H_ + +#include "core/include/fxcrt/fx_coordinates.h" +#include "core/include/fxcrt/fx_system.h" +#include "core/include/fxge/fx_dib.h" + +#define FX_SHADING_Steps 256 + +enum CFX_Shading_Type { FX_SHADING_Axial = 1, FX_SHADING_Radial }; + +class CFX_Shading { + public: + // Axial shading. + CFX_Shading(const CFX_PointF& beginPoint, + const CFX_PointF& endPoint, + FX_BOOL isExtendedBegin, + FX_BOOL isExtendedEnd, + const FX_ARGB beginArgb, + const FX_ARGB endArgb); + + // Radial shading. + CFX_Shading(const CFX_PointF& beginPoint, + const CFX_PointF& endPoint, + const FX_FLOAT beginRadius, + const FX_FLOAT endRadius, + FX_BOOL isExtendedBegin, + FX_BOOL isExtendedEnd, + const FX_ARGB beginArgb, + const FX_ARGB endArgb); + virtual ~CFX_Shading(); + + private: + friend class CFX_Graphics; + + void InitArgbArray(); + + const CFX_Shading_Type m_type; + const CFX_PointF m_beginPoint; + const CFX_PointF m_endPoint; + const FX_FLOAT m_beginRadius; + const FX_FLOAT m_endRadius; + const FX_BOOL m_isExtendedBegin; + const FX_BOOL m_isExtendedEnd; + const FX_ARGB m_beginArgb; + const FX_ARGB m_endArgb; + FX_ARGB m_argbArray[FX_SHADING_Steps]; +}; + +#endif // XFA_FXGRAPHICS_CFX_SHADING_H_ diff --git a/xfa/fxgraphics/fx_graphics.cpp b/xfa/fxgraphics/fx_graphics.cpp deleted file mode 100644 index 3247246c79..0000000000 --- a/xfa/fxgraphics/fx_graphics.cpp +++ /dev/null @@ -1,1394 +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 "xfa/include/fxgraphics/fx_graphics.h" - -#include - -#include "xfa/fxgraphics/fx_path_generator.h" -#include "xfa/fxgraphics/pre.h" - -CFX_Graphics::CFX_Graphics() - : m_renderDevice(nullptr), m_aggGraphics(nullptr) {} - -FX_ERR CFX_Graphics::Create(CFX_RenderDevice* renderDevice, - FX_BOOL isAntialiasing) { - if (!renderDevice) - return FX_ERR_Parameter_Invalid; - if (m_type != FX_CONTEXT_None) - return FX_ERR_Property_Invalid; - - m_type = FX_CONTEXT_Device; - m_info.isAntialiasing = isAntialiasing; - m_renderDevice = renderDevice; - if (m_renderDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP) - return FX_ERR_Succeeded; - return FX_ERR_Indefinite; -} - -FX_ERR CFX_Graphics::Create(int32_t width, - int32_t height, - FXDIB_Format format, - FX_BOOL isNative, - FX_BOOL isAntialiasing) { - if (m_type != FX_CONTEXT_None) - return FX_ERR_Property_Invalid; - - m_type = FX_CONTEXT_Device; - m_info.isAntialiasing = isAntialiasing; - m_aggGraphics = new CAGG_Graphics; - return m_aggGraphics->Create(this, width, height, format); -} - -CFX_Graphics::~CFX_Graphics() { - delete m_aggGraphics; -} - -FX_ERR CFX_Graphics::GetDeviceCap(const int32_t capID, FX_DeviceCap& capVal) { - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - capVal = m_renderDevice->GetDeviceCaps(capID); - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::IsPrinterDevice(FX_BOOL& isPrinter) { - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - isPrinter = m_renderDevice->GetDeviceClass() == FXDC_PRINTER; - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::EnableAntialiasing(FX_BOOL isAntialiasing) { - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - m_info.isAntialiasing = isAntialiasing; - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::SaveGraphState() { - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - m_renderDevice->SaveState(); - m_infoStack.Add(new TInfo(m_info)); - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::RestoreGraphState() { - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - m_renderDevice->RestoreState(); - int32_t size = m_infoStack.GetSize(); - if (size <= 0) { - return FX_ERR_Intermediate_Value_Invalid; - } - int32_t topIndex = size - 1; - std::unique_ptr info( - reinterpret_cast(m_infoStack.GetAt(topIndex))); - if (!info) - return FX_ERR_Intermediate_Value_Invalid; - m_info = *info; - m_infoStack.RemoveAt(topIndex); - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::GetLineCap(CFX_GraphStateData::LineCap& lineCap) const { - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - lineCap = m_info.graphState.m_LineCap; - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::SetLineCap(CFX_GraphStateData::LineCap lineCap) { - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - m_info.graphState.m_LineCap = lineCap; - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::GetDashCount(int32_t& dashCount) const { - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - dashCount = m_info.graphState.m_DashCount; - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::GetLineDash(FX_FLOAT& dashPhase, - FX_FLOAT* dashArray) const { - if (!dashArray) - return FX_ERR_Parameter_Invalid; - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - dashPhase = m_info.graphState.m_DashPhase; - FXSYS_memcpy(dashArray, m_info.graphState.m_DashArray, - m_info.graphState.m_DashCount * sizeof(FX_FLOAT)); - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::SetLineDash(FX_FLOAT dashPhase, - FX_FLOAT* dashArray, - int32_t dashCount) { - if (dashCount > 0 && !dashArray) - return FX_ERR_Parameter_Invalid; - - dashCount = dashCount < 0 ? 0 : dashCount; - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - FX_FLOAT scale = 1.0; - if (m_info.isActOnDash) { - scale = m_info.graphState.m_LineWidth; - } - m_info.graphState.m_DashPhase = dashPhase; - m_info.graphState.SetDashCount(dashCount); - for (int32_t i = 0; i < dashCount; i++) { - m_info.graphState.m_DashArray[i] = dashArray[i] * scale; - } - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::SetLineDash(FX_DashStyle dashStyle) { - if (m_type == FX_CONTEXT_Device && m_renderDevice) - return RenderDeviceSetLineDash(dashStyle); - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::GetLineJoin(CFX_GraphStateData::LineJoin& lineJoin) const { - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - lineJoin = m_info.graphState.m_LineJoin; - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::SetLineJoin(CFX_GraphStateData::LineJoin lineJoin) { - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - m_info.graphState.m_LineJoin = lineJoin; - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::GetMiterLimit(FX_FLOAT& miterLimit) const { - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - miterLimit = m_info.graphState.m_MiterLimit; - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::SetMiterLimit(FX_FLOAT miterLimit) { - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - m_info.graphState.m_MiterLimit = miterLimit; - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::GetLineWidth(FX_FLOAT& lineWidth) const { - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - lineWidth = m_info.graphState.m_LineWidth; - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::SetLineWidth(FX_FLOAT lineWidth, FX_BOOL isActOnDash) { - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - m_info.graphState.m_LineWidth = lineWidth; - m_info.isActOnDash = isActOnDash; - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::GetStrokeAlignment( - FX_StrokeAlignment& strokeAlignment) const { - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - strokeAlignment = m_info.strokeAlignment; - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::SetStrokeAlignment(FX_StrokeAlignment strokeAlignment) { - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - m_info.strokeAlignment = strokeAlignment; - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::SetStrokeColor(CFX_Color* color) { - if (!color) - return FX_ERR_Parameter_Invalid; - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - m_info.strokeColor = color; - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::SetFillColor(CFX_Color* color) { - if (!color) - return FX_ERR_Parameter_Invalid; - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - m_info.fillColor = color; - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::StrokePath(CFX_Path* path, CFX_Matrix* matrix) { - if (!path) - return FX_ERR_Parameter_Invalid; - if (m_type == FX_CONTEXT_Device && m_renderDevice) - return RenderDeviceStrokePath(path, matrix); - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::FillPath(CFX_Path* path, - FX_FillMode fillMode, - CFX_Matrix* matrix) { - if (!path) - return FX_ERR_Parameter_Invalid; - if (m_type == FX_CONTEXT_Device && m_renderDevice) - return RenderDeviceFillPath(path, fillMode, matrix); - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::ClipPath(CFX_Path* path, - FX_FillMode fillMode, - CFX_Matrix* matrix) { - if (!path) - return FX_ERR_Parameter_Invalid; - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - FX_BOOL result = m_renderDevice->SetClip_PathFill( - path->GetPathData(), (CFX_Matrix*)matrix, fillMode); - if (!result) - return FX_ERR_Indefinite; - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::DrawImage(CFX_DIBSource* source, - const CFX_PointF& point, - CFX_Matrix* matrix) { - if (!source) - return FX_ERR_Parameter_Invalid; - if (m_type == FX_CONTEXT_Device && m_renderDevice) - return RenderDeviceDrawImage(source, point, matrix); - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::StretchImage(CFX_DIBSource* source, - const CFX_RectF& rect, - CFX_Matrix* matrix) { - if (!source) - return FX_ERR_Parameter_Invalid; - if (m_type == FX_CONTEXT_Device && m_renderDevice) - return RenderDeviceStretchImage(source, rect, matrix); - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::ConcatMatrix(const CFX_Matrix* matrix) { - if (!matrix) - return FX_ERR_Parameter_Invalid; - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - m_info.CTM.Concat(*matrix); - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -CFX_Matrix* CFX_Graphics::GetMatrix() { - if (m_type == FX_CONTEXT_Device && m_renderDevice) - return &m_info.CTM; - return nullptr; -} - -FX_ERR CFX_Graphics::GetClipRect(CFX_RectF& rect) const { - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - FX_RECT r = m_renderDevice->GetClipBox(); - rect.left = (FX_FLOAT)r.left; - rect.top = (FX_FLOAT)r.top; - rect.width = (FX_FLOAT)r.Width(); - rect.height = (FX_FLOAT)r.Height(); - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::SetClipRect(const CFX_RectF& rect) { - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - if (!m_renderDevice->SetClip_Rect( - FX_RECT(FXSYS_round(rect.left), FXSYS_round(rect.top), - FXSYS_round(rect.right()), FXSYS_round(rect.bottom())))) { - return FX_ERR_Method_Not_Supported; - } - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::ClearClip() { - if (m_type == FX_CONTEXT_Device && m_renderDevice) - return FX_ERR_Succeeded; - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::SetFont(CFX_Font* font) { - if (!font) - return FX_ERR_Parameter_Invalid; - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - m_info.font = font; - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::SetFontSize(const FX_FLOAT size) { - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - m_info.fontSize = size <= 0 ? 1.0f : size; - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::SetFontHScale(const FX_FLOAT scale) { - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - m_info.fontHScale = scale <= 0 ? 1.0f : scale; - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::SetCharSpacing(const FX_FLOAT spacing) { - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - m_info.fontSpacing = spacing < 0 ? 0 : spacing; - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::SetTextDrawingMode(const int32_t mode) { - if (m_type == FX_CONTEXT_Device && m_renderDevice) - return FX_ERR_Succeeded; - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::ShowText(const CFX_PointF& point, - const CFX_WideString& text, - CFX_Matrix* matrix) { - if (m_type == FX_CONTEXT_Device && m_renderDevice) - return RenderDeviceShowText(point, text, matrix); - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::CalcTextRect(CFX_RectF& rect, - const CFX_WideString& text, - FX_BOOL isMultiline, - CFX_Matrix* matrix) { - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - int32_t length = text.GetLength(); - FX_DWORD* charCodes = FX_Alloc(FX_DWORD, length); - FXTEXT_CHARPOS* charPos = FX_Alloc(FXTEXT_CHARPOS, length); - CalcTextInfo(text, charCodes, charPos, rect); - FX_Free(charPos); - FX_Free(charCodes); - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::Transfer(CFX_Graphics* graphics, - const CFX_Matrix* matrix) { - if (!graphics || !graphics->m_renderDevice) - return FX_ERR_Parameter_Invalid; - CFX_Matrix m; - m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, - m_info.CTM.f); - if (matrix) { - m.Concat(*matrix); - } - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - CFX_DIBitmap* bitmap = graphics->m_renderDevice->GetBitmap(); - FX_BOOL result = m_renderDevice->SetDIBits(bitmap, 0, 0); - if (!result) - return FX_ERR_Method_Not_Supported; - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -FX_ERR CFX_Graphics::Transfer(CFX_Graphics* graphics, - FX_FLOAT srcLeft, - FX_FLOAT srcTop, - const CFX_RectF& dstRect, - const CFX_Matrix* matrix) { - if (!graphics || !graphics->m_renderDevice) - return FX_ERR_Parameter_Invalid; - CFX_Matrix m; - m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, - m_info.CTM.f); - if (matrix) { - m.Concat(*matrix); - } - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - CFX_DIBitmap bmp; - FX_BOOL result = - bmp.Create((int32_t)dstRect.width, (int32_t)dstRect.height, - graphics->m_renderDevice->GetBitmap()->GetFormat()); - if (!result) - return FX_ERR_Intermediate_Value_Invalid; - result = graphics->m_renderDevice->GetDIBits(&bmp, (int32_t)srcLeft, - (int32_t)srcTop); - if (!result) - return FX_ERR_Method_Not_Supported; - result = m_renderDevice->SetDIBits(&bmp, (int32_t)dstRect.left, - (int32_t)dstRect.top); - if (!result) - return FX_ERR_Method_Not_Supported; - return FX_ERR_Succeeded; - } - return FX_ERR_Property_Invalid; -} - -CFX_RenderDevice* CFX_Graphics::GetRenderDevice() { - return m_renderDevice; -} - -FX_ERR CFX_Graphics::InverseRect(const CFX_RectF& rect) { - if (!m_renderDevice) - return FX_ERR_Property_Invalid; - CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap(); - if (!bitmap) - return FX_ERR_Property_Invalid; - CFX_RectF temp(rect); - m_info.CTM.TransformRect(temp); - CFX_RectF r; - r.Set(0, 0, (FX_FLOAT)bitmap->GetWidth(), (FX_FLOAT)bitmap->GetWidth()); - r.Intersect(temp); - if (r.IsEmpty()) { - return FX_ERR_Parameter_Invalid; - } - FX_ARGB* pBuf = - (FX_ARGB*)(bitmap->GetBuffer() + int32_t(r.top) * bitmap->GetPitch()); - int32_t bottom = (int32_t)r.bottom(); - int32_t right = (int32_t)r.right(); - for (int32_t i = (int32_t)r.top; i < bottom; i++) { - FX_ARGB* pLine = pBuf + (int32_t)r.left; - for (int32_t j = (int32_t)r.left; j < right; j++) { - FX_ARGB c = *pLine; - *pLine++ = (c & 0xFF000000) | (0xFFFFFF - (c & 0x00FFFFFF)); - } - pBuf = (FX_ARGB*)((uint8_t*)pBuf + bitmap->GetPitch()); - } - return FX_ERR_Succeeded; -} - -FX_ERR CFX_Graphics::XorDIBitmap(const CFX_DIBitmap* srcBitmap, - const CFX_RectF& rect) { - if (!m_renderDevice) - return FX_ERR_Property_Invalid; - CFX_DIBitmap* dst = m_renderDevice->GetBitmap(); - if (!dst) - return FX_ERR_Property_Invalid; - CFX_RectF temp(rect); - m_info.CTM.TransformRect(temp); - CFX_RectF r; - r.Set(0, 0, (FX_FLOAT)dst->GetWidth(), (FX_FLOAT)dst->GetWidth()); - r.Intersect(temp); - if (r.IsEmpty()) { - return FX_ERR_Parameter_Invalid; - } - FX_ARGB* pSrcBuf = (FX_ARGB*)(srcBitmap->GetBuffer() + - int32_t(r.top) * srcBitmap->GetPitch()); - FX_ARGB* pDstBuf = - (FX_ARGB*)(dst->GetBuffer() + int32_t(r.top) * dst->GetPitch()); - int32_t bottom = (int32_t)r.bottom(); - int32_t right = (int32_t)r.right(); - for (int32_t i = (int32_t)r.top; i < bottom; i++) { - FX_ARGB* pSrcLine = pSrcBuf + (int32_t)r.left; - FX_ARGB* pDstLine = pDstBuf + (int32_t)r.left; - for (int32_t j = (int32_t)r.left; j < right; j++) { - FX_ARGB c = *pDstLine; - *pDstLine++ = - ArgbEncode(FXARGB_A(c), (c & 0xFFFFFF) ^ (*pSrcLine & 0xFFFFFF)); - pSrcLine++; - } - pSrcBuf = (FX_ARGB*)((uint8_t*)pSrcBuf + srcBitmap->GetPitch()); - pDstBuf = (FX_ARGB*)((uint8_t*)pDstBuf + dst->GetPitch()); - } - return FX_ERR_Succeeded; -} - -FX_ERR CFX_Graphics::EqvDIBitmap(const CFX_DIBitmap* srcBitmap, - const CFX_RectF& rect) { - if (!m_renderDevice) - return FX_ERR_Property_Invalid; - CFX_DIBitmap* dst = m_renderDevice->GetBitmap(); - if (!dst) - return FX_ERR_Property_Invalid; - CFX_RectF temp(rect); - m_info.CTM.TransformRect(temp); - CFX_RectF r; - r.Set(0, 0, (FX_FLOAT)dst->GetWidth(), (FX_FLOAT)dst->GetWidth()); - r.Intersect(temp); - if (r.IsEmpty()) { - return FX_ERR_Parameter_Invalid; - } - FX_ARGB* pSrcBuf = (FX_ARGB*)(srcBitmap->GetBuffer() + - int32_t(r.top) * srcBitmap->GetPitch()); - FX_ARGB* pDstBuf = - (FX_ARGB*)(dst->GetBuffer() + int32_t(r.top) * dst->GetPitch()); - int32_t bottom = (int32_t)r.bottom(); - int32_t right = (int32_t)r.right(); - for (int32_t i = (int32_t)r.top; i < bottom; i++) { - FX_ARGB* pSrcLine = pSrcBuf + (int32_t)r.left; - FX_ARGB* pDstLine = pDstBuf + (int32_t)r.left; - for (int32_t j = (int32_t)r.left; j < right; j++) { - FX_ARGB c = *pDstLine; - *pDstLine++ = - ArgbEncode(FXARGB_A(c), ~((c & 0xFFFFFF) ^ (*pSrcLine & 0xFFFFFF))); - pSrcLine++; - } - pSrcBuf = (FX_ARGB*)((uint8_t*)pSrcBuf + srcBitmap->GetPitch()); - pDstBuf = (FX_ARGB*)((uint8_t*)pDstBuf + dst->GetPitch()); - } - return FX_ERR_Succeeded; -} - -FX_ERR CFX_Graphics::RenderDeviceSetLineDash(FX_DashStyle dashStyle) { - switch (dashStyle) { - case FX_DASHSTYLE_Solid: { - m_info.graphState.SetDashCount(0); - return FX_ERR_Succeeded; - } - case FX_DASHSTYLE_Dash: { - FX_FLOAT dashArray[] = {3, 1}; - SetLineDash(0, dashArray, 2); - return FX_ERR_Succeeded; - } - case FX_DASHSTYLE_Dot: { - FX_FLOAT dashArray[] = {1, 1}; - SetLineDash(0, dashArray, 2); - return FX_ERR_Succeeded; - } - case FX_DASHSTYLE_DashDot: { - FX_FLOAT dashArray[] = {3, 1, 1, 1}; - SetLineDash(0, dashArray, 4); - return FX_ERR_Succeeded; - } - case FX_DASHSTYLE_DashDotDot: { - FX_FLOAT dashArray[] = {4, 1, 2, 1, 2, 1}; - SetLineDash(0, dashArray, 6); - return FX_ERR_Succeeded; - } - default: - return FX_ERR_Parameter_Invalid; - } -} - -FX_ERR CFX_Graphics::RenderDeviceStrokePath(CFX_Path* path, - CFX_Matrix* matrix) { - if (!m_info.strokeColor) - return FX_ERR_Property_Invalid; - CFX_Matrix m; - m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, - m_info.CTM.f); - if (matrix) { - m.Concat(*matrix); - } - switch (m_info.strokeColor->m_type) { - case FX_COLOR_Solid: { - FX_BOOL result = m_renderDevice->DrawPath( - path->GetPathData(), (CFX_Matrix*)&m, &m_info.graphState, 0x0, - m_info.strokeColor->m_info.argb, 0); - if (!result) - return FX_ERR_Indefinite; - return FX_ERR_Succeeded; - } - case FX_COLOR_Pattern: - return StrokePathWithPattern(path, &m); - case FX_COLOR_Shading: - return StrokePathWithShading(path, &m); - default: - return FX_ERR_Property_Invalid; - } -} - -FX_ERR CFX_Graphics::RenderDeviceFillPath(CFX_Path* path, - FX_FillMode fillMode, - CFX_Matrix* matrix) { - if (!m_info.fillColor) - return FX_ERR_Property_Invalid; - CFX_Matrix m; - m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, - m_info.CTM.f); - if (matrix) { - m.Concat(*matrix); - } - switch (m_info.fillColor->m_type) { - case FX_COLOR_Solid: { - FX_BOOL result = m_renderDevice->DrawPath( - path->GetPathData(), (CFX_Matrix*)&m, &m_info.graphState, - m_info.fillColor->m_info.argb, 0x0, fillMode); - if (!result) - return FX_ERR_Indefinite; - return FX_ERR_Succeeded; - } - case FX_COLOR_Pattern: - return FillPathWithPattern(path, fillMode, &m); - case FX_COLOR_Shading: - return FillPathWithShading(path, fillMode, &m); - default: - return FX_ERR_Property_Invalid; - } -} - -FX_ERR CFX_Graphics::RenderDeviceDrawImage(CFX_DIBSource* source, - const CFX_PointF& point, - CFX_Matrix* matrix) { - CFX_Matrix m1; - m1.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, - m_info.CTM.f); - if (matrix) { - m1.Concat(*matrix); - } - CFX_Matrix m2; - m2.Set((FX_FLOAT)source->GetWidth(), 0.0, 0.0, (FX_FLOAT)source->GetHeight(), - point.x, point.y); - m2.Concat(m1); - int32_t left, top; - std::unique_ptr bmp1(source->FlipImage(FALSE, TRUE)); - std::unique_ptr bmp2( - bmp1->TransformTo((CFX_Matrix*)&m2, left, top)); - CFX_RectF r; - GetClipRect(r); - CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap(); - CFX_DIBitmap bmp; - if (bmp.Create(bitmap->GetWidth(), bitmap->GetHeight(), FXDIB_Argb) && - m_renderDevice->GetDIBits(&bmp, 0, 0) && - bmp.TransferBitmap(FXSYS_round(r.left), FXSYS_round(r.top), - FXSYS_round(r.Width()), FXSYS_round(r.Height()), - bmp2.get(), FXSYS_round(r.left - left), - FXSYS_round(r.top - top)) && - m_renderDevice->SetDIBits(&bmp, 0, 0)) { - return FX_ERR_Succeeded; - } - return FX_ERR_Indefinite; -} - -FX_ERR CFX_Graphics::RenderDeviceStretchImage(CFX_DIBSource* source, - const CFX_RectF& rect, - CFX_Matrix* matrix) { - CFX_Matrix m1; - m1.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, - m_info.CTM.f); - if (matrix) { - m1.Concat(*matrix); - } - std::unique_ptr bmp1( - source->StretchTo((int32_t)rect.Width(), (int32_t)rect.Height())); - CFX_Matrix m2; - m2.Set(rect.Width(), 0.0, 0.0, rect.Height(), rect.left, rect.top); - m2.Concat(m1); - int32_t left, top; - std::unique_ptr bmp2(bmp1->FlipImage(FALSE, TRUE)); - std::unique_ptr bmp3( - bmp2->TransformTo((CFX_Matrix*)&m2, left, top)); - CFX_RectF r; - GetClipRect(r); - CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap(); - if (bitmap->CompositeBitmap(FXSYS_round(r.left), FXSYS_round(r.top), - FXSYS_round(r.Width()), FXSYS_round(r.Height()), - bmp3.get(), FXSYS_round(r.left - left), - FXSYS_round(r.top - top))) { - return FX_ERR_Succeeded; - } - return FX_ERR_Indefinite; -} - -FX_ERR CFX_Graphics::RenderDeviceShowText(const CFX_PointF& point, - const CFX_WideString& text, - CFX_Matrix* matrix) { - int32_t length = text.GetLength(); - FX_DWORD* charCodes = FX_Alloc(FX_DWORD, length); - FXTEXT_CHARPOS* charPos = FX_Alloc(FXTEXT_CHARPOS, length); - CFX_RectF rect; - rect.Set(point.x, point.y, 0, 0); - CalcTextInfo(text, charCodes, charPos, rect); - CFX_Matrix m; - m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, - m_info.CTM.f); - m.Translate(0, m_info.fontSize * m_info.fontHScale); - if (matrix) { - m.Concat(*matrix); - } - FX_BOOL result = m_renderDevice->DrawNormalText( - length, charPos, m_info.font, CFX_GEModule::Get()->GetFontCache(), - -m_info.fontSize * m_info.fontHScale, (CFX_Matrix*)&m, - m_info.fillColor->m_info.argb, FXTEXT_CLEARTYPE); - if (!result) - return FX_ERR_Indefinite; - FX_Free(charPos); - FX_Free(charCodes); - return FX_ERR_Succeeded; -} - -FX_ERR CFX_Graphics::StrokePathWithPattern(CFX_Path* path, CFX_Matrix* matrix) { - return FX_ERR_Method_Not_Supported; -} - -FX_ERR CFX_Graphics::StrokePathWithShading(CFX_Path* path, CFX_Matrix* matrix) { - return FX_ERR_Method_Not_Supported; -} - -FX_ERR CFX_Graphics::FillPathWithPattern(CFX_Path* path, - FX_FillMode fillMode, - CFX_Matrix* matrix) { - CFX_Pattern* pattern = m_info.fillColor->m_info.pattern; - CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap(); - int32_t width = bitmap->GetWidth(); - int32_t height = bitmap->GetHeight(); - CFX_DIBitmap bmp; - bmp.Create(width, height, FXDIB_Argb); - m_renderDevice->GetDIBits(&bmp, 0, 0); - switch (pattern->m_type) { - case FX_PATTERN_Bitmap: { - int32_t xStep = FXSYS_round(pattern->m_bitmapInfo.x1Step); - int32_t yStep = FXSYS_round(pattern->m_bitmapInfo.y1Step); - int32_t xCount = width / xStep + 1; - int32_t yCount = height / yStep + 1; - for (int32_t i = 0; i <= yCount; i++) { - for (int32_t j = 0; j <= xCount; j++) { - bmp.TransferBitmap(j * xStep, i * yStep, xStep, yStep, - pattern->m_bitmapInfo.bitmap, 0, 0); - } - } - break; - } - case FX_PATTERN_Hatch: { - FX_HatchStyle hatchStyle = - m_info.fillColor->m_info.pattern->m_hatchInfo.hatchStyle; - if (hatchStyle < FX_HATCHSTYLE_Horizontal || - hatchStyle > FX_HATCHSTYLE_SolidDiamond) { - return FX_ERR_Intermediate_Value_Invalid; - } - const FX_HATCHDATA& data = hatchBitmapData[hatchStyle]; - CFX_DIBitmap mask; - mask.Create(data.width, data.height, FXDIB_1bppMask); - FXSYS_memcpy(mask.GetBuffer(), data.maskBits, - mask.GetPitch() * data.height); - CFX_FloatRect rectf = path->GetPathData()->GetBoundingBox(); - if (matrix) { - rectf.Transform((const CFX_Matrix*)matrix); - } - FX_RECT rect(FXSYS_round(rectf.left), FXSYS_round(rectf.top), - FXSYS_round(rectf.right), FXSYS_round(rectf.bottom)); - CFX_FxgeDevice device; - device.Attach(&bmp); - device.FillRect(&rect, - m_info.fillColor->m_info.pattern->m_hatchInfo.backArgb); - for (int32_t j = rect.bottom; j < rect.top; j += mask.GetHeight()) { - for (int32_t i = rect.left; i < rect.right; i += mask.GetWidth()) { - device.SetBitMask( - &mask, i, j, - m_info.fillColor->m_info.pattern->m_hatchInfo.foreArgb); - } - } - break; - } - } - m_renderDevice->SaveState(); - m_renderDevice->SetClip_PathFill(path->GetPathData(), (CFX_Matrix*)matrix, - fillMode); - SetDIBitsWithMatrix(&bmp, &pattern->m_matrix); - m_renderDevice->RestoreState(); - return FX_ERR_Succeeded; -} - -FX_ERR CFX_Graphics::FillPathWithShading(CFX_Path* path, - FX_FillMode fillMode, - CFX_Matrix* matrix) { - CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap(); - int32_t width = bitmap->GetWidth(); - int32_t height = bitmap->GetHeight(); - FX_FLOAT start_x = m_info.fillColor->m_shading->m_beginPoint.x; - FX_FLOAT start_y = m_info.fillColor->m_shading->m_beginPoint.y; - FX_FLOAT end_x = m_info.fillColor->m_shading->m_endPoint.x; - FX_FLOAT end_y = m_info.fillColor->m_shading->m_endPoint.y; - CFX_DIBitmap bmp; - bmp.Create(width, height, FXDIB_Argb); - m_renderDevice->GetDIBits(&bmp, 0, 0); - int32_t pitch = bmp.GetPitch(); - FX_BOOL result = FALSE; - switch (m_info.fillColor->m_shading->m_type) { - case FX_SHADING_Axial: { - FX_FLOAT x_span = end_x - start_x; - FX_FLOAT y_span = end_y - start_y; - FX_FLOAT axis_len_square = (x_span * x_span) + (y_span * y_span); - for (int32_t row = 0; row < height; row++) { - FX_DWORD* dib_buf = (FX_DWORD*)(bmp.GetBuffer() + row * pitch); - for (int32_t column = 0; column < width; column++) { - FX_FLOAT x = (FX_FLOAT)(column); - FX_FLOAT y = (FX_FLOAT)(row); - FX_FLOAT scale = - (((x - start_x) * x_span) + ((y - start_y) * y_span)) / - axis_len_square; - if (scale < 0) { - if (!m_info.fillColor->m_shading->m_isExtendedBegin) { - continue; - } - scale = 0; - } else if (scale > 1.0f) { - if (!m_info.fillColor->m_shading->m_isExtendedEnd) { - continue; - } - scale = 1.0f; - } - int32_t index = (int32_t)(scale * (FX_SHADING_Steps - 1)); - dib_buf[column] = m_info.fillColor->m_shading->m_argbArray[index]; - } - } - result = TRUE; - break; - } - case FX_SHADING_Radial: { - FX_FLOAT start_r = m_info.fillColor->m_shading->m_beginRadius; - FX_FLOAT end_r = m_info.fillColor->m_shading->m_endRadius; - FX_FLOAT a = ((start_x - end_x) * (start_x - end_x)) + - ((start_y - end_y) * (start_y - end_y)) - - ((start_r - end_r) * (start_r - end_r)); - for (int32_t row = 0; row < height; row++) { - FX_DWORD* dib_buf = (FX_DWORD*)(bmp.GetBuffer() + row * pitch); - for (int32_t column = 0; column < width; column++) { - FX_FLOAT x = (FX_FLOAT)(column); - FX_FLOAT y = (FX_FLOAT)(row); - FX_FLOAT b = -2 * (((x - start_x) * (end_x - start_x)) + - ((y - start_y) * (end_y - start_y)) + - (start_r * (end_r - start_r))); - FX_FLOAT c = ((x - start_x) * (x - start_x)) + - ((y - start_y) * (y - start_y)) - (start_r * start_r); - FX_FLOAT s; - if (a == 0) { - s = -c / b; - } else { - FX_FLOAT b2_4ac = (b * b) - 4 * (a * c); - if (b2_4ac < 0) { - continue; - } - FX_FLOAT root = (FXSYS_sqrt(b2_4ac)); - FX_FLOAT s1, s2; - if (a > 0) { - s1 = (-b - root) / (2 * a); - s2 = (-b + root) / (2 * a); - } else { - s2 = (-b - root) / (2 * a); - s1 = (-b + root) / (2 * a); - } - if (s2 <= 1.0f || m_info.fillColor->m_shading->m_isExtendedEnd) { - s = (s2); - } else { - s = (s1); - } - if ((start_r) + s * (end_r - start_r) < 0) { - continue; - } - } - if (s < 0) { - if (!m_info.fillColor->m_shading->m_isExtendedBegin) { - continue; - } - s = 0; - } - if (s > 1.0f) { - if (!m_info.fillColor->m_shading->m_isExtendedEnd) { - continue; - } - s = 1.0f; - } - int index = (int32_t)(s * (FX_SHADING_Steps - 1)); - dib_buf[column] = m_info.fillColor->m_shading->m_argbArray[index]; - } - } - result = TRUE; - break; - } - default: { result = FALSE; } - } - if (result) { - m_renderDevice->SaveState(); - m_renderDevice->SetClip_PathFill(path->GetPathData(), (CFX_Matrix*)matrix, - fillMode); - SetDIBitsWithMatrix(&bmp, matrix); - m_renderDevice->RestoreState(); - } - return result; -} - -FX_ERR CFX_Graphics::SetDIBitsWithMatrix(CFX_DIBSource* source, - CFX_Matrix* matrix) { - if (matrix->IsIdentity()) { - m_renderDevice->SetDIBits(source, 0, 0); - } else { - CFX_Matrix m; - m.Set((FX_FLOAT)source->GetWidth(), 0, 0, (FX_FLOAT)source->GetHeight(), 0, - 0); - m.Concat(*matrix); - int32_t left, top; - std::unique_ptr bmp1(source->FlipImage(FALSE, TRUE)); - std::unique_ptr bmp2( - bmp1->TransformTo((CFX_Matrix*)&m, left, top)); - m_renderDevice->SetDIBits(bmp2.get(), left, top); - } - return FX_ERR_Succeeded; -} - -FX_ERR CFX_Graphics::CalcTextInfo(const CFX_WideString& text, - FX_DWORD* charCodes, - FXTEXT_CHARPOS* charPos, - CFX_RectF& rect) { - std::unique_ptr encoding( - new CFX_UnicodeEncoding(m_info.font)); - int32_t length = text.GetLength(); - FX_FLOAT penX = (FX_FLOAT)rect.left; - FX_FLOAT penY = (FX_FLOAT)rect.top; - FX_FLOAT left = (FX_FLOAT)(0); - FX_FLOAT top = (FX_FLOAT)(0); - charCodes[0] = text.GetAt(0); - charPos[0].m_OriginX = penX + left; - charPos[0].m_OriginY = penY + top; - charPos[0].m_GlyphIndex = encoding->GlyphFromCharCode(charCodes[0]); - charPos[0].m_FontCharWidth = FXSYS_round( - m_info.font->GetGlyphWidth(charPos[0].m_GlyphIndex) * m_info.fontHScale); - charPos[0].m_bGlyphAdjust = TRUE; - charPos[0].m_AdjustMatrix[0] = -1; - charPos[0].m_AdjustMatrix[1] = 0; - charPos[0].m_AdjustMatrix[2] = 0; - charPos[0].m_AdjustMatrix[3] = 1; - penX += (FX_FLOAT)(charPos[0].m_FontCharWidth) * m_info.fontSize / 1000 + - m_info.fontSpacing; - for (int32_t i = 1; i < length; i++) { - charCodes[i] = text.GetAt(i); - charPos[i].m_OriginX = penX + left; - charPos[i].m_OriginY = penY + top; - charPos[i].m_GlyphIndex = encoding->GlyphFromCharCode(charCodes[i]); - charPos[i].m_FontCharWidth = - FXSYS_round(m_info.font->GetGlyphWidth(charPos[i].m_GlyphIndex) * - m_info.fontHScale); - charPos[i].m_bGlyphAdjust = TRUE; - charPos[i].m_AdjustMatrix[0] = -1; - charPos[i].m_AdjustMatrix[1] = 0; - charPos[i].m_AdjustMatrix[2] = 0; - charPos[i].m_AdjustMatrix[3] = 1; - penX += (FX_FLOAT)(charPos[i].m_FontCharWidth) * m_info.fontSize / 1000 + - m_info.fontSpacing; - } - rect.width = (FX_FLOAT)penX - rect.left; - rect.height = rect.top + m_info.fontSize * m_info.fontHScale - rect.top; - return FX_ERR_Succeeded; -} - -CFX_Graphics::TInfo::TInfo(const TInfo& info) - : graphState(info.graphState), - isAntialiasing(info.isAntialiasing), - strokeAlignment(info.strokeAlignment), - CTM(info.CTM), - isActOnDash(info.isActOnDash), - strokeColor(info.strokeColor), - fillColor(info.fillColor), - font(info.font), - fontSize(info.fontSize), - fontHScale(info.fontHScale), - fontSpacing(info.fontSpacing) {} - -CFX_Graphics::TInfo& CFX_Graphics::TInfo::operator=(const TInfo& other) { - graphState.Copy(other.graphState); - isAntialiasing = other.isAntialiasing; - strokeAlignment = other.strokeAlignment; - CTM = other.CTM; - isActOnDash = other.isActOnDash; - strokeColor = other.strokeColor; - fillColor = other.fillColor; - font = other.font; - fontSize = other.fontSize; - fontHScale = other.fontHScale; - fontSpacing = other.fontSpacing; - return *this; -} - -CAGG_Graphics::CAGG_Graphics() { - m_owner = nullptr; -} - -FX_ERR CAGG_Graphics::Create(CFX_Graphics* owner, - int32_t width, - int32_t height, - FXDIB_Format format) { - if (owner->m_renderDevice) - return FX_ERR_Parameter_Invalid; - if (m_owner) - return FX_ERR_Property_Invalid; - - CFX_FxgeDevice* device = new CFX_FxgeDevice; - device->Create(width, height, format); - m_owner = owner; - m_owner->m_renderDevice = device; - m_owner->m_renderDevice->GetBitmap()->Clear(0xFFFFFFFF); - return FX_ERR_Succeeded; -} - -CAGG_Graphics::~CAGG_Graphics() { - if (m_owner->m_renderDevice) - delete (CFX_FxgeDevice*)m_owner->m_renderDevice; - m_owner = nullptr; -} - -CFX_Path::CFX_Path() { - m_generator = nullptr; -} - -FX_ERR CFX_Path::Create() { - if (m_generator) - return FX_ERR_Property_Invalid; - - m_generator = new CFX_PathGenerator; - m_generator->Create(); - return FX_ERR_Succeeded; -} - -CFX_Path::~CFX_Path() { - delete m_generator; -} - -FX_ERR CFX_Path::MoveTo(FX_FLOAT x, FX_FLOAT y) { - if (!m_generator) - return FX_ERR_Property_Invalid; - m_generator->MoveTo(x, y); - return FX_ERR_Succeeded; -} - -FX_ERR CFX_Path::LineTo(FX_FLOAT x, FX_FLOAT y) { - if (!m_generator) - return FX_ERR_Property_Invalid; - m_generator->LineTo(x, y); - return FX_ERR_Succeeded; -} - -FX_ERR CFX_Path::BezierTo(FX_FLOAT ctrlX1, - FX_FLOAT ctrlY1, - FX_FLOAT ctrlX2, - FX_FLOAT ctrlY2, - FX_FLOAT toX, - FX_FLOAT toY) { - if (!m_generator) - return FX_ERR_Property_Invalid; - m_generator->BezierTo(ctrlX1, ctrlY1, ctrlX2, ctrlY2, toX, toY); - return FX_ERR_Succeeded; -} - -FX_ERR CFX_Path::ArcTo(FX_FLOAT left, - FX_FLOAT top, - FX_FLOAT width, - FX_FLOAT height, - FX_FLOAT startAngle, - FX_FLOAT sweepAngle) { - if (!m_generator) - return FX_ERR_Property_Invalid; - m_generator->ArcTo(left + width / 2, top + height / 2, width / 2, height / 2, - startAngle, sweepAngle); - return FX_ERR_Succeeded; -} - -FX_ERR CFX_Path::Close() { - if (!m_generator) - return FX_ERR_Property_Invalid; - m_generator->Close(); - return FX_ERR_Succeeded; -} - -FX_ERR CFX_Path::AddLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2) { - if (!m_generator) - return FX_ERR_Property_Invalid; - m_generator->AddLine(x1, y1, x2, y2); - return FX_ERR_Succeeded; -} - -FX_ERR CFX_Path::AddBezier(FX_FLOAT startX, - FX_FLOAT startY, - FX_FLOAT ctrlX1, - FX_FLOAT ctrlY1, - FX_FLOAT ctrlX2, - FX_FLOAT ctrlY2, - FX_FLOAT endX, - FX_FLOAT endY) { - if (!m_generator) - return FX_ERR_Property_Invalid; - m_generator->AddBezier(startX, startY, ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, - endY); - return FX_ERR_Succeeded; -} - -FX_ERR CFX_Path::AddRectangle(FX_FLOAT left, - FX_FLOAT top, - FX_FLOAT width, - FX_FLOAT height) { - if (!m_generator) - return FX_ERR_Property_Invalid; - m_generator->AddRectangle(left, top, left + width, top + height); - return FX_ERR_Succeeded; -} - -FX_ERR CFX_Path::AddEllipse(FX_FLOAT left, - FX_FLOAT top, - FX_FLOAT width, - FX_FLOAT height) { - if (!m_generator) - return FX_ERR_Property_Invalid; - m_generator->AddEllipse(left + width / 2, top + height / 2, width / 2, - height / 2); - return FX_ERR_Succeeded; -} - -FX_ERR CFX_Path::AddEllipse(const CFX_RectF& rect) { - if (!m_generator) - return FX_ERR_Property_Invalid; - m_generator->AddEllipse(rect.left + rect.Width() / 2, - rect.top + rect.Height() / 2, rect.Width() / 2, - rect.Height() / 2); - return FX_ERR_Succeeded; -} - -FX_ERR CFX_Path::AddArc(FX_FLOAT left, - FX_FLOAT top, - FX_FLOAT width, - FX_FLOAT height, - FX_FLOAT startAngle, - FX_FLOAT sweepAngle) { - if (!m_generator) - return FX_ERR_Property_Invalid; - m_generator->AddArc(left + width / 2, top + height / 2, width / 2, height / 2, - startAngle, sweepAngle); - return FX_ERR_Succeeded; -} - -FX_ERR CFX_Path::AddPie(FX_FLOAT left, - FX_FLOAT top, - FX_FLOAT width, - FX_FLOAT height, - FX_FLOAT startAngle, - FX_FLOAT sweepAngle) { - if (!m_generator) - return FX_ERR_Property_Invalid; - m_generator->AddPie(left + width / 2, top + height / 2, width / 2, height / 2, - startAngle, sweepAngle); - return FX_ERR_Succeeded; -} - -FX_ERR CFX_Path::AddSubpath(CFX_Path* path) { - if (!m_generator) - return FX_ERR_Property_Invalid; - m_generator->AddPathData(path->GetPathData()); - return FX_ERR_Succeeded; -} - -FX_ERR CFX_Path::Clear() { - if (!m_generator) - return FX_ERR_Property_Invalid; - m_generator->GetPathData()->SetPointCount(0); - return FX_ERR_Succeeded; -} - -FX_BOOL CFX_Path::IsEmpty() { - if (!m_generator) - return FX_ERR_Property_Invalid; - if (m_generator->GetPathData()->GetPointCount() == 0) { - return TRUE; - } - return FALSE; -} - -CFX_PathData* CFX_Path::GetPathData() { - if (!m_generator) - return nullptr; - return m_generator->GetPathData(); -} - -CFX_Color::CFX_Color() : m_type(FX_COLOR_None) {} - -CFX_Color::CFX_Color(const FX_ARGB argb) { - Set(argb); -} - -CFX_Color::CFX_Color(CFX_Pattern* pattern, const FX_ARGB argb) { - Set(pattern, argb); -} - -CFX_Color::CFX_Color(CFX_Shading* shading) { - Set(shading); -} - -CFX_Color::~CFX_Color() { - m_type = FX_COLOR_None; -} - -FX_ERR CFX_Color::Set(const FX_ARGB argb) { - m_type = FX_COLOR_Solid; - m_info.argb = argb; - m_info.pattern = nullptr; - return FX_ERR_Succeeded; -} - -FX_ERR CFX_Color::Set(CFX_Pattern* pattern, const FX_ARGB argb) { - if (!pattern) - return FX_ERR_Parameter_Invalid; - m_type = FX_COLOR_Pattern; - m_info.argb = argb; - m_info.pattern = pattern; - return FX_ERR_Succeeded; -} - -FX_ERR CFX_Color::Set(CFX_Shading* shading) { - if (!shading) - return FX_ERR_Parameter_Invalid; - m_type = FX_COLOR_Shading; - m_shading = shading; - return FX_ERR_Succeeded; -} - -CFX_Pattern::CFX_Pattern() { - m_type = FX_PATTERN_None; - m_matrix.SetIdentity(); -} - -FX_ERR CFX_Pattern::Create(CFX_DIBitmap* bitmap, - const FX_FLOAT xStep, - const FX_FLOAT yStep, - CFX_Matrix* matrix) { - if (!bitmap) - return FX_ERR_Parameter_Invalid; - if (m_type != FX_PATTERN_None) { - return FX_ERR_Property_Invalid; - } - m_type = FX_PATTERN_Bitmap; - m_bitmapInfo.bitmap = bitmap; - m_bitmapInfo.x1Step = xStep; - m_bitmapInfo.y1Step = yStep; - if (matrix) { - m_matrix.Set(matrix->a, matrix->b, matrix->c, matrix->d, matrix->e, - matrix->f); - } - return FX_ERR_Succeeded; -} - -FX_ERR CFX_Pattern::Create(FX_HatchStyle hatchStyle, - const FX_ARGB foreArgb, - const FX_ARGB backArgb, - CFX_Matrix* matrix) { - if (hatchStyle < FX_HATCHSTYLE_Horizontal || - hatchStyle > FX_HATCHSTYLE_SolidDiamond) { - return FX_ERR_Parameter_Invalid; - } - if (m_type != FX_PATTERN_None) { - return FX_ERR_Property_Invalid; - } - m_type = FX_PATTERN_Hatch; - m_hatchInfo.hatchStyle = hatchStyle; - m_hatchInfo.foreArgb = foreArgb; - m_hatchInfo.backArgb = backArgb; - if (matrix) { - m_matrix.Set(matrix->a, matrix->b, matrix->c, matrix->d, matrix->e, - matrix->f); - } - return FX_ERR_Succeeded; -} - -CFX_Pattern::~CFX_Pattern() { - m_type = FX_PATTERN_None; -} - -CFX_Shading::CFX_Shading() { - m_type = FX_SHADING_None; -} - -FX_ERR CFX_Shading::CreateAxial(const CFX_PointF& beginPoint, - const CFX_PointF& endPoint, - FX_BOOL isExtendedBegin, - FX_BOOL isExtendedEnd, - const FX_ARGB beginArgb, - const FX_ARGB endArgb) { - if (m_type != FX_SHADING_None) { - return FX_ERR_Property_Invalid; - } - m_type = FX_SHADING_Axial; - m_beginPoint = beginPoint; - m_endPoint = endPoint; - m_isExtendedBegin = isExtendedBegin; - m_isExtendedEnd = isExtendedEnd; - m_beginArgb = beginArgb; - m_endArgb = endArgb; - return InitArgbArray(); -} - -FX_ERR CFX_Shading::CreateRadial(const CFX_PointF& beginPoint, - const CFX_PointF& endPoint, - const FX_FLOAT beginRadius, - const FX_FLOAT endRadius, - FX_BOOL isExtendedBegin, - FX_BOOL isExtendedEnd, - const FX_ARGB beginArgb, - const FX_ARGB endArgb) { - if (m_type != FX_SHADING_None) { - return FX_ERR_Property_Invalid; - } - m_type = FX_SHADING_Radial; - m_beginPoint = beginPoint; - m_endPoint = endPoint; - m_beginRadius = beginRadius; - m_endRadius = endRadius; - m_isExtendedBegin = isExtendedBegin; - m_isExtendedEnd = isExtendedEnd; - m_beginArgb = beginArgb; - m_endArgb = endArgb; - return InitArgbArray(); -} - -CFX_Shading::~CFX_Shading() { - m_type = FX_SHADING_None; -} - -FX_ERR CFX_Shading::InitArgbArray() { - int32_t a1, r1, g1, b1; - ArgbDecode(m_beginArgb, a1, r1, g1, b1); - int32_t a2, r2, g2, b2; - ArgbDecode(m_endArgb, a2, r2, g2, b2); - FX_FLOAT f = (FX_FLOAT)(FX_SHADING_Steps - 1); - FX_FLOAT aScale = (FX_FLOAT)(1.0 * (a2 - a1) / f); - FX_FLOAT rScale = (FX_FLOAT)(1.0 * (r2 - r1) / f); - FX_FLOAT gScale = (FX_FLOAT)(1.0 * (g2 - g1) / f); - FX_FLOAT bScale = (FX_FLOAT)(1.0 * (b2 - b1) / f); - int32_t a3, r3, g3, b3; - for (int32_t i = 0; i < FX_SHADING_Steps; i++) { - a3 = (int32_t)(i * aScale); - r3 = (int32_t)(i * rScale); - g3 = (int32_t)(i * gScale); - b3 = (int32_t)(i * bScale); - m_argbArray[i] = - FXARGB_TODIB(FXARGB_MAKE((a1 + a3), (r1 + r3), (g1 + g3), (b1 + b3))); - } - return FX_ERR_Succeeded; -} diff --git a/xfa/fxgraphics/fx_path_generator.cpp b/xfa/fxgraphics/fx_path_generator.cpp deleted file mode 100644 index cbe0f29239..0000000000 --- a/xfa/fxgraphics/fx_path_generator.cpp +++ /dev/null @@ -1,201 +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 "xfa/fxgraphics/fx_path_generator.h" - -#include "xfa/fxgraphics/pre.h" - -CFX_PathGenerator::CFX_PathGenerator() { - m_pPathData = NULL; -} -void CFX_PathGenerator::Create() { - m_pPathData = new CFX_PathData; -} -CFX_PathGenerator::~CFX_PathGenerator() { - if (m_pPathData) { - delete m_pPathData; - m_pPathData = NULL; - } -} -void CFX_PathGenerator::AddPathData(CFX_PathData* pPathData) { - if (pPathData && pPathData->GetPointCount() > 0) { - int nCount = pPathData->GetPointCount(); - FX_PATHPOINT* pPoints = pPathData->GetPoints(); - AddPathData(pPoints, nCount); - } -} -void CFX_PathGenerator::AddPathData(FX_PATHPOINT* pPoints, int nCount) { - if (pPoints && nCount > 0) { - int nOldCount = m_pPathData->GetPointCount(); - m_pPathData->AddPointCount(nCount); - FX_PATHPOINT* pDstPoints = m_pPathData->GetPoints(); - FXSYS_memcpy(pDstPoints + nOldCount, pPoints, - sizeof(FX_PATHPOINT) * nCount); - } -} -void CFX_PathGenerator::MoveTo(FX_FLOAT x, FX_FLOAT y) { - m_pPathData->AddPointCount(1); - m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, x, y, FXPT_MOVETO); -} -void CFX_PathGenerator::LineTo(FX_FLOAT x, FX_FLOAT y) { - m_pPathData->AddPointCount(1); - m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, x, y, FXPT_LINETO); -} -void CFX_PathGenerator::BezierTo(FX_FLOAT ctrl_x1, - FX_FLOAT ctrl_y1, - FX_FLOAT ctrl_x2, - FX_FLOAT ctrl_y2, - FX_FLOAT to_x, - FX_FLOAT to_y) { - int old_count = m_pPathData->GetPointCount(); - m_pPathData->AddPointCount(3); - m_pPathData->SetPoint(old_count, ctrl_x1, ctrl_y1, FXPT_BEZIERTO); - m_pPathData->SetPoint(old_count + 1, ctrl_x2, ctrl_y2, FXPT_BEZIERTO); - m_pPathData->SetPoint(old_count + 2, to_x, to_y, FXPT_BEZIERTO); -} -void CFX_PathGenerator::Close() { - if (m_pPathData->GetPointCount() > 0) { - int index = m_pPathData->GetPointCount() - 1; - FX_PATHPOINT* pPoints = m_pPathData->GetPoints(); - pPoints[index].m_Flag |= FXPT_CLOSEFIGURE; - } -} -void CFX_PathGenerator::AddLine(FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2) { - int old_count = m_pPathData->GetPointCount(); - m_pPathData->AddPointCount(2); - m_pPathData->SetPoint(old_count, x1, y1, FXPT_MOVETO); - m_pPathData->SetPoint(old_count + 1, x2, y2, FXPT_LINETO); -} -void CFX_PathGenerator::AddBezier(FX_FLOAT start_x, - FX_FLOAT start_y, - FX_FLOAT ctrl_x1, - FX_FLOAT ctrl_y1, - FX_FLOAT ctrl_x2, - FX_FLOAT ctrl_y2, - FX_FLOAT end_x, - FX_FLOAT end_y) { - int old_count = m_pPathData->GetPointCount(); - m_pPathData->AddPointCount(4); - m_pPathData->SetPoint(old_count, start_x, start_y, FXPT_MOVETO); - m_pPathData->SetPoint(old_count + 1, ctrl_x1, ctrl_y1, FXPT_BEZIERTO); - m_pPathData->SetPoint(old_count + 2, ctrl_x2, ctrl_y2, FXPT_BEZIERTO); - m_pPathData->SetPoint(old_count + 3, end_x, end_y, FXPT_BEZIERTO); -} -void CFX_PathGenerator::AddRectangle(FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2) { - m_pPathData->AppendRect(x1, y1, x2, y2); -} -void CFX_PathGenerator::AddEllipse(FX_FLOAT x, - FX_FLOAT y, - FX_FLOAT width, - FX_FLOAT height) { - AddArc(x, y, width, height, 0, FX_PI * 2); -} -void CFX_PathGenerator::ArcTo(FX_FLOAT x, - FX_FLOAT y, - FX_FLOAT width, - FX_FLOAT height, - FX_FLOAT start_angle, - FX_FLOAT sweep_angle) { - FX_FLOAT x0 = FXSYS_cos(sweep_angle / 2); - FX_FLOAT y0 = FXSYS_sin(sweep_angle / 2); - FX_FLOAT tx = ((1.0f - x0) * 4) / (3 * 1.0f); - FX_FLOAT ty = y0 - ((tx * x0) / y0); - FX_FLOAT px[3], py[3]; - px[0] = x0 + tx; - py[0] = -ty; - px[1] = x0 + tx; - py[1] = ty; - FX_FLOAT sn = FXSYS_sin(start_angle + sweep_angle / 2); - FX_FLOAT cs = FXSYS_cos(start_angle + sweep_angle / 2); - int old_count = m_pPathData->GetPointCount(); - m_pPathData->AddPointCount(3); - FX_FLOAT bezier_x, bezier_y; - bezier_x = x + (width * ((px[0] * cs) - (py[0] * sn))); - bezier_y = y + (height * ((px[0] * sn) + (py[0] * cs))); - m_pPathData->SetPoint(old_count, bezier_x, bezier_y, FXPT_BEZIERTO); - bezier_x = x + (width * ((px[1] * cs) - (py[1] * sn))); - bezier_y = y + (height * ((px[1] * sn) + (py[1] * cs))); - m_pPathData->SetPoint(old_count + 1, bezier_x, bezier_y, FXPT_BEZIERTO); - bezier_x = x + (width * FXSYS_cos(start_angle + sweep_angle)); - bezier_y = y + (height * FXSYS_sin(start_angle + sweep_angle)); - m_pPathData->SetPoint(old_count + 2, bezier_x, bezier_y, FXPT_BEZIERTO); -} -void CFX_PathGenerator::AddArc(FX_FLOAT x, - FX_FLOAT y, - FX_FLOAT width, - FX_FLOAT height, - FX_FLOAT start_angle, - FX_FLOAT sweep_angle) { - if (sweep_angle == 0) { - return; - } - - const FX_FLOAT bezier_arc_angle_epsilon = 0.01f; - while (start_angle > FX_PI * 2) { - start_angle -= FX_PI * 2; - } - while (start_angle < 0) { - start_angle += FX_PI * 2; - } - if (sweep_angle >= FX_PI * 2) { - sweep_angle = FX_PI * 2; - } - if (sweep_angle <= -FX_PI * 2) { - sweep_angle = -FX_PI * 2; - } - m_pPathData->AddPointCount(1); - m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, - x + (width * FXSYS_cos(start_angle)), - y + (height * FXSYS_sin(start_angle)), FXPT_MOVETO); - FX_FLOAT total_sweep = 0, local_sweep = 0, prev_sweep = 0; - FX_BOOL done = FALSE; - do { - if (sweep_angle < 0) { - prev_sweep = total_sweep; - local_sweep = -FX_PI / 2; - total_sweep -= FX_PI / 2; - if (total_sweep <= sweep_angle + bezier_arc_angle_epsilon) { - local_sweep = sweep_angle - prev_sweep; - done = TRUE; - } - } else { - prev_sweep = total_sweep; - local_sweep = FX_PI / 2; - total_sweep += FX_PI / 2; - if (total_sweep >= sweep_angle - bezier_arc_angle_epsilon) { - local_sweep = sweep_angle - prev_sweep; - done = TRUE; - } - } - ArcTo(x, y, width, height, start_angle, local_sweep); - start_angle += local_sweep; - } while (!done); -} -void CFX_PathGenerator::AddPie(FX_FLOAT x, - FX_FLOAT y, - FX_FLOAT width, - FX_FLOAT height, - FX_FLOAT start_angle, - FX_FLOAT sweep_angle) { - if (sweep_angle == 0) { - int old_count = m_pPathData->GetPointCount(); - m_pPathData->AddPointCount(2); - m_pPathData->SetPoint(old_count, x, y, FXPT_MOVETO); - m_pPathData->SetPoint(old_count + 1, x + (width * FXSYS_cos(start_angle)), - y + (height * FXSYS_sin(start_angle)), FXPT_LINETO); - return; - } - AddArc(x, y, width, height, start_angle, sweep_angle); - m_pPathData->AddPointCount(1); - m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, x, y, - FXPT_LINETO | FXPT_CLOSEFIGURE); -} diff --git a/xfa/fxgraphics/fx_path_generator.h b/xfa/fxgraphics/fx_path_generator.h deleted file mode 100644 index 3087a64366..0000000000 --- a/xfa/fxgraphics/fx_path_generator.h +++ /dev/null @@ -1,64 +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 XFA_FXGRAPHICS_FX_PATH_GENERATOR_H_ -#define XFA_FXGRAPHICS_FX_PATH_GENERATOR_H_ - -#include "core/include/fxge/fx_ge.h" - -class CFX_PathGenerator { - public: - CFX_PathGenerator(); - void Create(); - ~CFX_PathGenerator(); - CFX_PathData* GetPathData() const { return m_pPathData; } - void AddPathData(CFX_PathData* path_data); - void AddPathData(FX_PATHPOINT* points, int count); - void MoveTo(FX_FLOAT x, FX_FLOAT y); - void LineTo(FX_FLOAT x, FX_FLOAT y); - void BezierTo(FX_FLOAT ctrl_x1, - FX_FLOAT ctrl_y1, - FX_FLOAT ctrl_x2, - FX_FLOAT ctrl_y2, - FX_FLOAT to_x, - FX_FLOAT to_y); - void Close(); - void ArcTo(FX_FLOAT x, - FX_FLOAT y, - FX_FLOAT width, - FX_FLOAT height, - FX_FLOAT start_angle, - FX_FLOAT sweep_angle); - - void AddLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2); - void AddBezier(FX_FLOAT start_x, - FX_FLOAT start_y, - FX_FLOAT ctrl_x1, - FX_FLOAT ctrl_y1, - FX_FLOAT ctrl_x2, - FX_FLOAT ctrl_y2, - FX_FLOAT end_x, - FX_FLOAT end_y); - void AddRectangle(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2); - void AddEllipse(FX_FLOAT x, FX_FLOAT y, FX_FLOAT width, FX_FLOAT height); - void AddArc(FX_FLOAT x, - FX_FLOAT y, - FX_FLOAT width, - FX_FLOAT height, - FX_FLOAT start_angle, - FX_FLOAT sweep_angle); - void AddPie(FX_FLOAT x, - FX_FLOAT y, - FX_FLOAT width, - FX_FLOAT height, - FX_FLOAT start_angle, - FX_FLOAT sweep_angle); - - protected: - CFX_PathData* m_pPathData; -}; - -#endif // XFA_FXGRAPHICS_FX_PATH_GENERATOR_H_ diff --git a/xfa/fxgraphics/include/cfx_graphics.h b/xfa/fxgraphics/include/cfx_graphics.h new file mode 100644 index 0000000000..121ae3a744 --- /dev/null +++ b/xfa/fxgraphics/include/cfx_graphics.h @@ -0,0 +1,253 @@ +// 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 XFA_FXGRAPHICS_INCLUDE_CFX_GRAPHICS_H_ +#define XFA_FXGRAPHICS_INCLUDE_CFX_GRAPHICS_H_ + +#include "core/include/fxcrt/fx_system.h" +#include "core/include/fxge/fx_dib.h" +#include "core/include/fxge/fx_ge.h" + +class CFX_Color; +class CFX_Path; +class CAGG_Graphics; + +#define FX_ERR_Succeeded 0 +#define FX_ERR_Indefinite -1 +#define FX_ERR_Parameter_Invalid -100 +#define FX_ERR_Property_Invalid -200 +#define FX_ERR_Intermediate_Value_Invalid -300 +#define FX_ERR_Method_Not_Supported -400 +#define FX_ERR_Out_Of_Memory -500 + +using FX_ERR = int; +using FX_DeviceCap = int32_t; +using FX_FillMode = int32_t; + +enum FX_DashStyle { + FX_DASHSTYLE_Solid = 0, + FX_DASHSTYLE_Dash = 1, + FX_DASHSTYLE_Dot = 2, + FX_DASHSTYLE_DashDot = 3, + FX_DASHSTYLE_DashDotDot = 4 +}; + +enum FX_StrokeAlignment { + FX_STROKEALIGNMENT_Center = 0, + FX_STROKEALIGNMENT_Inset = 1, + FX_STROKEALIGNMENT_Outset = 2, + FX_STROKEALIGNMENT_Left = 3, + FX_STROKEALIGNMENT_Right = 4 +}; + +enum FX_HatchStyle { + FX_HATCHSTYLE_Horizontal = 0, + FX_HATCHSTYLE_Vertical = 1, + FX_HATCHSTYLE_ForwardDiagonal = 2, + FX_HATCHSTYLE_BackwardDiagonal = 3, + FX_HATCHSTYLE_Cross = 4, + FX_HATCHSTYLE_DiagonalCross = 5, + FX_HATCHSTYLE_05Percent = 6, + FX_HATCHSTYLE_10Percent = 7, + FX_HATCHSTYLE_20Percent = 8, + FX_HATCHSTYLE_25Percent = 9, + FX_HATCHSTYLE_30Percent = 10, + FX_HATCHSTYLE_40Percent = 11, + FX_HATCHSTYLE_50Percent = 12, + FX_HATCHSTYLE_60Percent = 13, + FX_HATCHSTYLE_70Percent = 14, + FX_HATCHSTYLE_75Percent = 15, + FX_HATCHSTYLE_80Percent = 16, + FX_HATCHSTYLE_90Percent = 17, + FX_HATCHSTYLE_LightDownwardDiagonal = 18, + FX_HATCHSTYLE_LightUpwardDiagonal = 19, + FX_HATCHSTYLE_DarkDownwardDiagonal = 20, + FX_HATCHSTYLE_DarkUpwardDiagonal = 21, + FX_HATCHSTYLE_WideDownwardDiagonal = 22, + FX_HATCHSTYLE_WideUpwardDiagonal = 23, + FX_HATCHSTYLE_LightVertical = 24, + FX_HATCHSTYLE_LightHorizontal = 25, + FX_HATCHSTYLE_NarrowVertical = 26, + FX_HATCHSTYLE_NarrowHorizontal = 27, + FX_HATCHSTYLE_DarkVertical = 28, + FX_HATCHSTYLE_DarkHorizontal = 29, + FX_HATCHSTYLE_DashedDownwardDiagonal = 30, + FX_HATCHSTYLE_DashedUpwardDiagonal = 31, + FX_HATCHSTYLE_DashedHorizontal = 32, + FX_HATCHSTYLE_DashedVertical = 33, + FX_HATCHSTYLE_SmallConfetti = 34, + FX_HATCHSTYLE_LargeConfetti = 35, + FX_HATCHSTYLE_ZigZag = 36, + FX_HATCHSTYLE_Wave = 37, + FX_HATCHSTYLE_DiagonalBrick = 38, + FX_HATCHSTYLE_HorizontalBrick = 39, + FX_HATCHSTYLE_Weave = 40, + FX_HATCHSTYLE_Plaid = 41, + FX_HATCHSTYLE_Divot = 42, + FX_HATCHSTYLE_DottedGrid = 43, + FX_HATCHSTYLE_DottedDiamond = 44, + FX_HATCHSTYLE_Shingle = 45, + FX_HATCHSTYLE_Trellis = 46, + FX_HATCHSTYLE_Sphere = 47, + FX_HATCHSTYLE_SmallGrid = 48, + FX_HATCHSTYLE_SmallCheckerBoard = 49, + FX_HATCHSTYLE_LargeCheckerBoard = 50, + FX_HATCHSTYLE_OutlinedDiamond = 51, + FX_HATCHSTYLE_SolidDiamond = 52 +}; + +class CFX_RenderDevice; + +class CFX_Graphics { + public: + CFX_Graphics(); + virtual ~CFX_Graphics(); + + FX_ERR Create(CFX_RenderDevice* renderDevice, FX_BOOL isAntialiasing = TRUE); + FX_ERR Create(int32_t width, + int32_t height, + FXDIB_Format format, + FX_BOOL isNative = TRUE, + FX_BOOL isAntialiasing = TRUE); + + FX_ERR GetDeviceCap(const int32_t capID, FX_DeviceCap& capVal); + FX_ERR IsPrinterDevice(FX_BOOL& isPrinter); + FX_ERR EnableAntialiasing(FX_BOOL isAntialiasing); + + FX_ERR SaveGraphState(); + FX_ERR RestoreGraphState(); + + FX_ERR GetLineCap(CFX_GraphStateData::LineCap& lineCap) const; + FX_ERR GetDashCount(int32_t& dashCount) const; + FX_ERR GetLineDash(FX_FLOAT& dashPhase, FX_FLOAT* dashArray) const; + FX_ERR GetLineJoin(CFX_GraphStateData::LineJoin& lineJoin) const; + FX_ERR GetMiterLimit(FX_FLOAT& miterLimit) const; + FX_ERR GetLineWidth(FX_FLOAT& lineWidth) const; + FX_ERR GetStrokeAlignment(FX_StrokeAlignment& strokeAlignment) const; + FX_ERR GetClipRect(CFX_RectF& rect) const; + CFX_Matrix* GetMatrix(); + CFX_RenderDevice* GetRenderDevice(); + + FX_ERR SetLineCap(CFX_GraphStateData::LineCap lineCap); + FX_ERR SetLineDash(FX_FLOAT dashPhase, + FX_FLOAT* dashArray, + int32_t dashCount); + FX_ERR SetLineDash(FX_DashStyle dashStyle); + FX_ERR SetLineJoin(CFX_GraphStateData::LineJoin lineJoin); + FX_ERR SetMiterLimit(FX_FLOAT miterLimit); + FX_ERR SetLineWidth(FX_FLOAT lineWidth, FX_BOOL isActOnDash = FALSE); + FX_ERR SetStrokeAlignment(FX_StrokeAlignment strokeAlignment); + FX_ERR SetStrokeColor(CFX_Color* color); + FX_ERR SetFillColor(CFX_Color* color); + FX_ERR SetClipRect(const CFX_RectF& rect); + FX_ERR SetFont(CFX_Font* font); + FX_ERR SetFontSize(const FX_FLOAT size); + FX_ERR SetFontHScale(const FX_FLOAT scale); + FX_ERR SetCharSpacing(const FX_FLOAT spacing); + FX_ERR SetTextDrawingMode(const int32_t mode); + + FX_ERR StrokePath(CFX_Path* path, CFX_Matrix* matrix = NULL); + FX_ERR FillPath(CFX_Path* path, + FX_FillMode fillMode = FXFILL_WINDING, + CFX_Matrix* matrix = NULL); + FX_ERR ClipPath(CFX_Path* path, + FX_FillMode fillMode = FXFILL_WINDING, + CFX_Matrix* matrix = NULL); + FX_ERR DrawImage(CFX_DIBSource* source, + const CFX_PointF& point, + CFX_Matrix* matrix = NULL); + FX_ERR StretchImage(CFX_DIBSource* source, + const CFX_RectF& rect, + CFX_Matrix* matrix = NULL); + FX_ERR ConcatMatrix(const CFX_Matrix* matrix); + FX_ERR ClearClip(); + FX_ERR ShowText(const CFX_PointF& point, + const CFX_WideString& text, + CFX_Matrix* matrix = NULL); + FX_ERR CalcTextRect(CFX_RectF& rect, + const CFX_WideString& text, + FX_BOOL isMultiline = FALSE, + CFX_Matrix* matrix = NULL); + FX_ERR Transfer(CFX_Graphics* graphics, const CFX_Matrix* matrix); + FX_ERR Transfer(CFX_Graphics* graphics, + FX_FLOAT srcLeft, + FX_FLOAT srcTop, + const CFX_RectF& dstRect, + const CFX_Matrix* matrix); + + FX_ERR InverseRect(const CFX_RectF& rect); + FX_ERR XorDIBitmap(const CFX_DIBitmap* srcBitmap, const CFX_RectF& rect); + FX_ERR EqvDIBitmap(const CFX_DIBitmap* srcBitmap, const CFX_RectF& rect); + + protected: + int32_t m_type; + + private: + struct TInfo { + TInfo() + : isAntialiasing(TRUE), + strokeAlignment(FX_STROKEALIGNMENT_Center), + isActOnDash(FALSE), + strokeColor(nullptr), + fillColor(nullptr), + font(nullptr), + fontSize(40.0), + fontHScale(1.0), + fontSpacing(0.0) {} + explicit TInfo(const TInfo& info); + TInfo& operator=(const TInfo& other); + + CFX_GraphStateData graphState; + FX_BOOL isAntialiasing; + FX_StrokeAlignment strokeAlignment; + CFX_Matrix CTM; + FX_BOOL isActOnDash; + CFX_Color* strokeColor; + CFX_Color* fillColor; + CFX_Font* font; + FX_FLOAT fontSize; + FX_FLOAT fontHScale; + FX_FLOAT fontSpacing; + } m_info; + + FX_ERR RenderDeviceSetLineDash(FX_DashStyle dashStyle); + FX_ERR RenderDeviceStrokePath(CFX_Path* path, CFX_Matrix* matrix); + FX_ERR RenderDeviceFillPath(CFX_Path* path, + FX_FillMode fillMode, + CFX_Matrix* matrix); + FX_ERR RenderDeviceDrawImage(CFX_DIBSource* source, + const CFX_PointF& point, + CFX_Matrix* matrix); + FX_ERR RenderDeviceStretchImage(CFX_DIBSource* source, + const CFX_RectF& rect, + CFX_Matrix* matrix); + FX_ERR RenderDeviceShowText(const CFX_PointF& point, + const CFX_WideString& text, + CFX_Matrix* matrix); + + FX_ERR StrokePathWithPattern(CFX_Path* path, CFX_Matrix* matrix); + FX_ERR StrokePathWithShading(CFX_Path* path, CFX_Matrix* matrix); + + FX_ERR FillPathWithPattern(CFX_Path* path, + FX_FillMode fillMode, + CFX_Matrix* matrix); + FX_ERR FillPathWithShading(CFX_Path* path, + FX_FillMode fillMode, + CFX_Matrix* matrix); + + FX_ERR SetDIBitsWithMatrix(CFX_DIBSource* source, CFX_Matrix* matrix); + FX_ERR CalcTextInfo(const CFX_WideString& text, + FX_DWORD* charCodes, + FXTEXT_CHARPOS* charPos, + CFX_RectF& rect); + + CFX_RenderDevice* m_renderDevice; + CFX_PtrArray m_infoStack; + CAGG_Graphics* m_aggGraphics; + friend class CAGG_Graphics; +}; + +#endif // XFA_FXGRAPHICS_INCLUDE_CFX_GRAPHICS_H_ diff --git a/xfa/fxgraphics/pre.h b/xfa/fxgraphics/pre.h deleted file mode 100644 index fb0ac55839..0000000000 --- a/xfa/fxgraphics/pre.h +++ /dev/null @@ -1,586 +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 XFA_FXGRAPHICS_PRE_H_ -#define XFA_FXGRAPHICS_PRE_H_ - -enum { - FX_CONTEXT_None = 0, - FX_CONTEXT_Device, -}; -enum { FX_COLOR_None = 0, FX_COLOR_Solid, FX_COLOR_Pattern, FX_COLOR_Shading }; -enum { FX_PATTERN_None = 0, FX_PATTERN_Bitmap, FX_PATTERN_Hatch }; -enum { FX_SHADING_None = 0, FX_SHADING_Axial, FX_SHADING_Radial }; - -#define FX_HATCHSTYLE_Total 53 - -struct FX_HATCHDATA { - int32_t width; - int32_t height; - uint8_t maskBits[64]; -}; -typedef FX_HATCHDATA const* FX_LPCHATCHDATA; - -static const FX_HATCHDATA hatchBitmapData[FX_HATCHSTYLE_Total] = { - {16, - 16, - { - 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - }}, - {16, - 16, - { - 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, - 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, - 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, - 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, - 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, - 0x80, 0x80, 0x00, 0x00, - }}, - {16, - 16, - { - 0x80, 0x80, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x20, 0x20, 0x00, 0x00, - 0x10, 0x10, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, - 0x40, 0x40, 0x00, 0x00, 0x20, 0x20, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, - 0x08, 0x08, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, - 0x01, 0x01, 0x00, 0x00, - }}, - {16, - 16, - { - 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, - 0x08, 0x08, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x20, 0x20, 0x00, 0x00, - 0x40, 0x40, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, - 0x02, 0x02, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, - 0x10, 0x10, 0x00, 0x00, 0x20, 0x20, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, - 0x80, 0x80, 0x00, 0x00, - }}, - {16, - 16, - { - 0xff, 0xff, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, - 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, - 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, - 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, - 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, - 0x80, 0x80, 0x00, 0x00, - }}, - {16, - 16, - { - 0x81, 0x81, 0x00, 0x00, 0x42, 0x42, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00, - 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00, - 0x42, 0x42, 0x00, 0x00, 0x81, 0x81, 0x00, 0x00, 0x81, 0x81, 0x00, 0x00, - 0x42, 0x42, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x18, 0x18, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00, 0x42, 0x42, 0x00, 0x00, - 0x81, 0x81, 0x00, 0x00, - }}, - {16, - 16, - { - 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - }}, - {16, - 16, - { - 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - }}, - {16, - 16, - { - 0x88, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x88, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - }}, - {16, - 16, - { - 0x88, 0x88, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, - 0x22, 0x22, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, - 0x88, 0x88, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, - 0x22, 0x22, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, - 0x88, 0x88, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, - 0x22, 0x22, 0x00, 0x00, - }}, - {16, - 16, - { - 0xaa, 0xaa, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, - 0x11, 0x11, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, - 0xaa, 0xaa, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, - 0x44, 0x44, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, - 0xaa, 0xaa, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, - 0x11, 0x11, 0x00, 0x00, - }}, - {16, - 16, - { - 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, - 0x51, 0x51, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, - 0xaa, 0xaa, 0x00, 0x00, 0x15, 0x15, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, - 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x51, 0x51, 0x00, 0x00, - 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, - 0x15, 0x15, 0x00, 0x00, - }}, - {16, - 16, - { - 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, - 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, - 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, - 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, - 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, - 0x55, 0x55, 0x00, 0x00, - }}, - {16, - 16, - { - 0xee, 0xee, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xbb, 0xbb, 0x00, 0x00, - 0x55, 0x55, 0x00, 0x00, 0xee, 0xee, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, - 0xbb, 0xbb, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xee, 0xee, 0x00, 0x00, - 0x55, 0x55, 0x00, 0x00, 0xbb, 0xbb, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, - 0xee, 0xee, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xbb, 0xbb, 0x00, 0x00, - 0x55, 0x55, 0x00, 0x00, - }}, - {16, - 16, - { - 0x77, 0x77, 0x00, 0x00, 0xdd, 0xdd, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00, - 0xdd, 0xdd, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00, 0xdd, 0xdd, 0x00, 0x00, - 0x77, 0x77, 0x00, 0x00, 0xdd, 0xdd, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00, - 0xdd, 0xdd, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00, 0xdd, 0xdd, 0x00, 0x00, - 0x77, 0x77, 0x00, 0x00, 0xdd, 0xdd, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00, - 0xdd, 0xdd, 0x00, 0x00, - }}, - {16, - 16, - { - 0x77, 0x77, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xdd, 0xdd, 0x00, 0x00, - 0xff, 0xff, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, - 0xdd, 0xdd, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00, - 0xff, 0xff, 0x00, 0x00, 0xdd, 0xdd, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, - 0x77, 0x77, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xdd, 0xdd, 0x00, 0x00, - 0xff, 0xff, 0x00, 0x00, - }}, - {16, - 16, - { - 0xef, 0xef, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xfe, 0xfe, 0x00, 0x00, - 0xff, 0xff, 0x00, 0x00, 0xef, 0xef, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, - 0xfe, 0xfe, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xef, 0xef, 0x00, 0x00, - 0xff, 0xff, 0x00, 0x00, 0xfe, 0xfe, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, - 0xef, 0xef, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xfe, 0xfe, 0x00, 0x00, - 0xff, 0xff, 0x00, 0x00, - }}, - {16, - 16, - { - 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, - 0xf7, 0xf7, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, - 0xff, 0xff, 0x00, 0x00, 0x7f, 0x7f, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, - 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xf7, 0xf7, 0x00, 0x00, - 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, - 0x7f, 0x7f, 0x00, 0x00, - }}, - {16, - 16, - { - 0x88, 0x88, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, - 0x11, 0x11, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, - 0x22, 0x22, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, - 0x44, 0x44, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, - 0x88, 0x88, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, - 0x11, 0x11, 0x00, 0x00, - }}, - {16, - 16, - { - 0x11, 0x11, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, - 0x88, 0x88, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, - 0x44, 0x44, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, - 0x22, 0x22, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, - 0x11, 0x11, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, - 0x88, 0x88, 0x00, 0x00, - }}, - {16, - 16, - { - 0xcc, 0xcc, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x33, 0x33, 0x00, 0x00, - 0x99, 0x99, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, - 0x33, 0x33, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, - 0x66, 0x66, 0x00, 0x00, 0x33, 0x33, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00, - 0xcc, 0xcc, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x33, 0x33, 0x00, 0x00, - 0x99, 0x99, 0x00, 0x00, - }}, - {16, - 16, - { - 0x33, 0x33, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, - 0x99, 0x99, 0x00, 0x00, 0x33, 0x33, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, - 0xcc, 0xcc, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00, 0x33, 0x33, 0x00, 0x00, - 0x66, 0x66, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00, - 0x33, 0x33, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, - 0x99, 0x99, 0x00, 0x00, - }}, - {16, - 16, - { - 0xc1, 0xc1, 0x00, 0x00, 0xe0, 0xe0, 0x00, 0x00, 0x70, 0x70, 0x00, 0x00, - 0x38, 0x38, 0x00, 0x00, 0x1c, 0x1c, 0x00, 0x00, 0x0e, 0x0e, 0x00, 0x00, - 0x07, 0x07, 0x00, 0x00, 0x83, 0x83, 0x00, 0x00, 0xc1, 0xc1, 0x00, 0x00, - 0xe0, 0xe0, 0x00, 0x00, 0x70, 0x70, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, - 0x1c, 0x1c, 0x00, 0x00, 0x0e, 0x0e, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x83, 0x83, 0x00, 0x00, - }}, - {16, - 16, - { - 0x83, 0x83, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, 0x0e, 0x0e, 0x00, 0x00, - 0x1c, 0x1c, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, 0x70, 0x70, 0x00, 0x00, - 0xe0, 0xe0, 0x00, 0x00, 0xc1, 0xc1, 0x00, 0x00, 0x83, 0x83, 0x00, 0x00, - 0x07, 0x07, 0x00, 0x00, 0x0e, 0x0e, 0x00, 0x00, 0x1c, 0x1c, 0x00, 0x00, - 0x38, 0x38, 0x00, 0x00, 0x70, 0x70, 0x00, 0x00, 0xe0, 0xe0, 0x00, 0x00, - 0xc1, 0xc1, 0x00, 0x00, - }}, - {16, - 16, - { - 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, - 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, - 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, - 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, - 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, - 0x88, 0x88, 0x00, 0x00, - }}, - {16, - 16, - { - 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - }}, - {16, - 16, - { - 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, - 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, - 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, - 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, - 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, - 0x55, 0x55, 0x00, 0x00, - }}, - {16, - 16, - { - 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - }}, - {16, - 16, - { - 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, - 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, - 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, - 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, - 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, - 0xcc, 0xcc, 0x00, 0x00, - }}, - {16, - 16, - { - 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, - 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - }}, - {16, - 16, - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, - 0x44, 0x44, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, - 0x22, 0x22, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - }}, - {16, - 16, - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, - 0x22, 0x22, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, - 0x44, 0x44, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - }}, - {16, - 16, - { - 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - }}, - {16, - 16, - { - 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, - 0x80, 0x80, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, - 0x08, 0x08, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, - 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, - 0x08, 0x08, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, - 0x08, 0x08, 0x00, 0x00, - }}, - {16, - 16, - { - 0x80, 0x80, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, - 0x02, 0x02, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, - 0x20, 0x20, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, - 0x08, 0x08, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, - 0x10, 0x10, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x20, 0x20, 0x00, 0x00, - 0x04, 0x04, 0x00, 0x00, - }}, - {16, - 16, - { - 0xb1, 0xb1, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, - 0x1b, 0x1b, 0x00, 0x00, 0xd8, 0xd8, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, - 0x0c, 0x0c, 0x00, 0x00, 0x8d, 0x8d, 0x00, 0x00, 0xb1, 0xb1, 0x00, 0x00, - 0x30, 0x30, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x1b, 0x1b, 0x00, 0x00, - 0xd8, 0xd8, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x00, - 0x8d, 0x8d, 0x00, 0x00, - }}, - {16, - 16, - { - 0x81, 0x81, 0x00, 0x00, 0x42, 0x42, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00, - 0x18, 0x18, 0x00, 0x00, 0x81, 0x81, 0x00, 0x00, 0x42, 0x42, 0x00, 0x00, - 0x24, 0x24, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x81, 0x81, 0x00, 0x00, - 0x42, 0x42, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x81, 0x81, 0x00, 0x00, 0x42, 0x42, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00, - 0x18, 0x18, 0x00, 0x00, - }}, - {16, - 16, - { - 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x25, 0x25, 0x00, 0x00, - 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x25, 0x25, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x18, 0x18, 0x00, 0x00, 0x25, 0x25, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x25, 0x25, 0x00, 0x00, - 0xc0, 0xc0, 0x00, 0x00, - }}, - {16, - 16, - { - 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, - 0x08, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00, - 0x42, 0x42, 0x00, 0x00, 0x81, 0x81, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, - 0x02, 0x02, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, - 0x18, 0x18, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00, 0x42, 0x42, 0x00, 0x00, - 0x81, 0x81, 0x00, 0x00, - }}, - {16, - 16, - { - 0xff, 0xff, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, - 0x80, 0x80, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, - 0x08, 0x08, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, - 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, - 0xff, 0xff, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, - 0x08, 0x08, 0x00, 0x00, - }}, - {16, - 16, - { - 0x88, 0x88, 0x00, 0x00, 0x54, 0x54, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, - 0x45, 0x45, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x14, 0x14, 0x00, 0x00, - 0x22, 0x22, 0x00, 0x00, 0x51, 0x51, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, - 0x54, 0x54, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x45, 0x45, 0x00, 0x00, - 0x88, 0x88, 0x00, 0x00, 0x14, 0x14, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, - 0x51, 0x51, 0x00, 0x00, - }}, - {16, - 16, - { - 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, - 0x55, 0x55, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, - 0xf0, 0xf0, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, - 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, - 0xf0, 0xf0, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, - 0xf0, 0xf0, 0x00, 0x00, - }}, - {16, - 16, - { - 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, - 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, - 0x01, 0x01, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x10, 0x10, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, - 0x80, 0x80, 0x00, 0x00, - }}, - {16, - 16, - { - 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - }}, - {16, - 16, - { - 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - }}, - {16, - 16, - { - 0x03, 0x03, 0x00, 0x00, 0x84, 0x84, 0x00, 0x00, 0x48, 0x48, 0x00, 0x00, - 0x30, 0x30, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, - 0x84, 0x84, 0x00, 0x00, 0x48, 0x48, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, - 0x0c, 0x0c, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, - 0x01, 0x01, 0x00, 0x00, - }}, - {16, - 16, - { - 0xff, 0xff, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, - 0x99, 0x99, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, - 0xff, 0xff, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, - 0x66, 0x66, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00, - 0xff, 0xff, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, - 0x99, 0x99, 0x00, 0x00, - }}, - {16, - 16, - { - 0x77, 0x77, 0x00, 0x00, 0x89, 0x89, 0x00, 0x00, 0x8f, 0x8f, 0x00, 0x00, - 0x8f, 0x8f, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00, 0x98, 0x98, 0x00, 0x00, - 0xf8, 0xf8, 0x00, 0x00, 0xf8, 0xf8, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00, - 0x89, 0x89, 0x00, 0x00, 0x8f, 0x8f, 0x00, 0x00, 0x8f, 0x8f, 0x00, 0x00, - 0x77, 0x77, 0x00, 0x00, 0x98, 0x98, 0x00, 0x00, 0xf8, 0xf8, 0x00, 0x00, - 0xf8, 0xf8, 0x00, 0x00, - }}, - {16, - 16, - { - 0xff, 0xff, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, - 0x88, 0x88, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, - 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, - 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, - 0xff, 0xff, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, - 0x88, 0x88, 0x00, 0x00, - }}, - {16, - 16, - { - 0x99, 0x99, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, - 0x99, 0x99, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, - 0x66, 0x66, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00, - 0x66, 0x66, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00, - 0x99, 0x99, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, - 0x99, 0x99, 0x00, 0x00, - }}, - {16, - 16, - { - 0xf0, 0xf0, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, - 0xf0, 0xf0, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, - 0x0f, 0x0f, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, - 0xf0, 0xf0, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, - 0x0f, 0x0f, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, - 0x0f, 0x0f, 0x00, 0x00, - }}, - {16, - 16, - { - 0x82, 0x82, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x28, 0x28, 0x00, 0x00, - 0x10, 0x10, 0x00, 0x00, 0x28, 0x28, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, - 0x82, 0x82, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x82, 0x82, 0x00, 0x00, - 0x44, 0x44, 0x00, 0x00, 0x28, 0x28, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, - 0x28, 0x28, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x82, 0x82, 0x00, 0x00, - 0x01, 0x01, 0x00, 0x00, - }}, - {16, - 16, - { - 0x10, 0x10, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, 0x7c, 0x7c, 0x00, 0x00, - 0xfe, 0xfe, 0x00, 0x00, 0x7c, 0x7c, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, - 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, - 0x38, 0x38, 0x00, 0x00, 0x7c, 0x7c, 0x00, 0x00, 0xfe, 0xfe, 0x00, 0x00, - 0x7c, 0x7c, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - }}, -}; -#if defined(__WIN32__) || defined(_WIN32) -#define FX_START_TIMER \ - SYSTEMTIME start, stop; \ - ::GetLocalTime(&start); -#define FX_STOP_TIMER \ - ::GetLocalTime(&stop); \ - WORD wSecond = stop.wSecond - start.wSecond; \ - WORD wMilliseconds = stop.wMilliseconds - start.wMilliseconds; \ - char buf[256]; \ - memset(buf, 0, sizeof(buf)); \ - snprintf(buf, sizeof(buf) - 1, "duration is %d millisecond\n", \ - wSecond * 1000 + wMilliseconds); \ - ::OutputDebugString(buf); -#elif defined(__linux) || defined(linux) -#define FX_START_TIMER -#define FX_STOP_TIMER -#elif defined(__APPLE__) || defined(__MACOSX__) -#define FX_START_TIMER \ - NSTimeInterval start, stop; \ - start = [NSDate timeIntervalSinceReferenceDate]; -#define FX_STOP_TIMER \ - stop = [NSDate timeIntervalSinceReferenceDate]; \ - NSTimeInterval duration = stop - start; \ - printf("duration is %f millisecond\n", duration * 1000); -#else -#endif - -#endif // XFA_FXGRAPHICS_PRE_H_ diff --git a/xfa/include/fwl/core/fwl_note.h b/xfa/include/fwl/core/fwl_note.h index 182c56fe3c..e41cf1dcef 100644 --- a/xfa/include/fwl/core/fwl_note.h +++ b/xfa/include/fwl/core/fwl_note.h @@ -7,8 +7,9 @@ #ifndef XFA_INCLUDE_FWL_CORE_FWL_NOTE_H_ #define XFA_INCLUDE_FWL_CORE_FWL_NOTE_H_ +#include "core/include/fxcrt/fx_coordinates.h" +#include "xfa/fxgraphics/include/cfx_graphics.h" #include "xfa/include/fwl/core/fwl_error.h" -#include "xfa/include/fxgraphics/fx_graphics.h" class IFWL_Widget; class IFWL_NoteThread; @@ -44,6 +45,7 @@ class CFWL_EvtSizeChanged; class CFWL_EvtIdle; class IFWL_NoteDriver; class IFWL_NoteLoop; + #define FWL_MSG_Activate L"FWL_MESSAGE_Activate" #define FWL_MSG_Deactivate L"FWL_MESSAGE_Deactivate" #define FWL_MSG_SetFocus L"FWL_MESSAGE_SetFocus" diff --git a/xfa/include/fwl/core/fwl_theme.h b/xfa/include/fwl/core/fwl_theme.h index 8f9f9a6c36..69783c740a 100644 --- a/xfa/include/fwl/core/fwl_theme.h +++ b/xfa/include/fwl/core/fwl_theme.h @@ -7,10 +7,14 @@ #ifndef XFA_INCLUDE_FWL_CORE_FWL_THEME_H_ #define XFA_INCLUDE_FWL_CORE_FWL_THEME_H_ +#include "core/include/fxcrt/fx_coordinates.h" +#include "core/include/fxcrt/fx_system.h" #include "xfa/include/fwl/core/fwl_error.h" -#include "xfa/include/fxgraphics/fx_graphics.h" class IFWL_Widget; +class CFX_Graphics; +class CFX_DIBitmap; +class CFX_Path; #define FWL_WGTCAPACITY_CXBorder 1 #define FWL_WGTCAPACITY_CYBorder 2 diff --git a/xfa/include/fwl/core/fwl_widget.h b/xfa/include/fwl/core/fwl_widget.h index afee2d8272..5588efe95e 100644 --- a/xfa/include/fwl/core/fwl_widget.h +++ b/xfa/include/fwl/core/fwl_widget.h @@ -10,7 +10,6 @@ #include "xfa/include/fwl/core/fwl_note.h" #include "xfa/include/fwl/core/fwl_target.h" #include "xfa/include/fwl/core/fwl_widgetdef.h" -#include "xfa/include/fxgraphics/fx_graphics.h" class IFWL_ThemeProvider; class CFWL_WidgetImpProperties; diff --git a/xfa/include/fwl/lightwidget/theme.h b/xfa/include/fwl/lightwidget/theme.h index 824cacebc7..f47725b8ae 100644 --- a/xfa/include/fwl/lightwidget/theme.h +++ b/xfa/include/fwl/lightwidget/theme.h @@ -10,6 +10,7 @@ #include #include +#include "core/include/fxge/fx_dib.h" #include "xfa/include/fwl/core/fwl_theme.h" class CFWL_WidgetTP; diff --git a/xfa/include/fxgraphics/fx_graphics.h b/xfa/include/fxgraphics/fx_graphics.h deleted file mode 100644 index c2d22719d9..0000000000 --- a/xfa/include/fxgraphics/fx_graphics.h +++ /dev/null @@ -1,435 +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 XFA_INCLUDE_FXGRAPHICS_FX_GRAPHICS_H_ -#define XFA_INCLUDE_FXGRAPHICS_FX_GRAPHICS_H_ - -#include "core/include/fpdfapi/fpdf_pageobj.h" - -typedef int FX_ERR; -#define FX_ERR_Succeeded 0 -#define FX_ERR_Indefinite -1 -#define FX_ERR_Parameter_Invalid -100 -#define FX_ERR_Property_Invalid -200 -#define FX_ERR_Intermediate_Value_Invalid -300 -#define FX_ERR_Method_Not_Supported -400 -#define FX_ERR_Out_Of_Memory -500 - -#define FX_SHADING_Steps 256 -typedef int32_t FX_DashStyle; -enum { - FX_DASHSTYLE_Solid = 0, - FX_DASHSTYLE_Dash = 1, - FX_DASHSTYLE_Dot = 2, - FX_DASHSTYLE_DashDot = 3, - FX_DASHSTYLE_DashDotDot = 4 -}; -typedef int32_t FX_StrokeAlignment; -enum { - FX_STROKEALIGNMENT_Center = 0, - FX_STROKEALIGNMENT_Inset = 1, - FX_STROKEALIGNMENT_Outset = 2, - FX_STROKEALIGNMENT_Left = 3, - FX_STROKEALIGNMENT_Right = 4 -}; -typedef int32_t FX_HatchStyle; -enum { - FX_HATCHSTYLE_Horizontal = 0, - FX_HATCHSTYLE_Vertical = 1, - FX_HATCHSTYLE_ForwardDiagonal = 2, - FX_HATCHSTYLE_BackwardDiagonal = 3, - FX_HATCHSTYLE_Cross = 4, - FX_HATCHSTYLE_DiagonalCross = 5, - FX_HATCHSTYLE_05Percent = 6, - FX_HATCHSTYLE_10Percent = 7, - FX_HATCHSTYLE_20Percent = 8, - FX_HATCHSTYLE_25Percent = 9, - FX_HATCHSTYLE_30Percent = 10, - FX_HATCHSTYLE_40Percent = 11, - FX_HATCHSTYLE_50Percent = 12, - FX_HATCHSTYLE_60Percent = 13, - FX_HATCHSTYLE_70Percent = 14, - FX_HATCHSTYLE_75Percent = 15, - FX_HATCHSTYLE_80Percent = 16, - FX_HATCHSTYLE_90Percent = 17, - FX_HATCHSTYLE_LightDownwardDiagonal = 18, - FX_HATCHSTYLE_LightUpwardDiagonal = 19, - FX_HATCHSTYLE_DarkDownwardDiagonal = 20, - FX_HATCHSTYLE_DarkUpwardDiagonal = 21, - FX_HATCHSTYLE_WideDownwardDiagonal = 22, - FX_HATCHSTYLE_WideUpwardDiagonal = 23, - FX_HATCHSTYLE_LightVertical = 24, - FX_HATCHSTYLE_LightHorizontal = 25, - FX_HATCHSTYLE_NarrowVertical = 26, - FX_HATCHSTYLE_NarrowHorizontal = 27, - FX_HATCHSTYLE_DarkVertical = 28, - FX_HATCHSTYLE_DarkHorizontal = 29, - FX_HATCHSTYLE_DashedDownwardDiagonal = 30, - FX_HATCHSTYLE_DashedUpwardDiagonal = 31, - FX_HATCHSTYLE_DashedHorizontal = 32, - FX_HATCHSTYLE_DashedVertical = 33, - FX_HATCHSTYLE_SmallConfetti = 34, - FX_HATCHSTYLE_LargeConfetti = 35, - FX_HATCHSTYLE_ZigZag = 36, - FX_HATCHSTYLE_Wave = 37, - FX_HATCHSTYLE_DiagonalBrick = 38, - FX_HATCHSTYLE_HorizontalBrick = 39, - FX_HATCHSTYLE_Weave = 40, - FX_HATCHSTYLE_Plaid = 41, - FX_HATCHSTYLE_Divot = 42, - FX_HATCHSTYLE_DottedGrid = 43, - FX_HATCHSTYLE_DottedDiamond = 44, - FX_HATCHSTYLE_Shingle = 45, - FX_HATCHSTYLE_Trellis = 46, - FX_HATCHSTYLE_Sphere = 47, - FX_HATCHSTYLE_SmallGrid = 48, - FX_HATCHSTYLE_SmallCheckerBoard = 49, - FX_HATCHSTYLE_LargeCheckerBoard = 50, - FX_HATCHSTYLE_OutlinedDiamond = 51, - FX_HATCHSTYLE_SolidDiamond = 52 -}; -typedef int32_t FX_DeviceCap; -typedef int32_t FX_FillMode; -class CFX_RenderDevice; -class CFX_GraphStateData; -class CFX_Matrix; -class CFX_DIBSource; -class CFX_DIBitmap; -class CFX_Font; -class CFX_WideString; -class CFX_PathGenerator; -class CFX_Graphics; -class CFX_Color; -class CFX_Path; -class CFX_Pattern; -class CFX_Shading; - -class CAGG_Graphics { - public: - CAGG_Graphics(); - virtual ~CAGG_Graphics(); - - FX_ERR Create(CFX_Graphics* owner, - int32_t width, - int32_t height, - FXDIB_Format format); - - private: - CFX_Graphics* m_owner; -}; - -class CFX_Graphics { - public: - CFX_Graphics(); - virtual ~CFX_Graphics(); - - FX_ERR Create(CFX_RenderDevice* renderDevice, FX_BOOL isAntialiasing = TRUE); - FX_ERR Create(int32_t width, - int32_t height, - FXDIB_Format format, - FX_BOOL isNative = TRUE, - FX_BOOL isAntialiasing = TRUE); - - FX_ERR GetDeviceCap(const int32_t capID, FX_DeviceCap& capVal); - FX_ERR IsPrinterDevice(FX_BOOL& isPrinter); - FX_ERR EnableAntialiasing(FX_BOOL isAntialiasing); - - FX_ERR SaveGraphState(); - FX_ERR RestoreGraphState(); - - FX_ERR GetLineCap(CFX_GraphStateData::LineCap& lineCap) const; - FX_ERR GetDashCount(int32_t& dashCount) const; - FX_ERR GetLineDash(FX_FLOAT& dashPhase, FX_FLOAT* dashArray) const; - FX_ERR GetLineJoin(CFX_GraphStateData::LineJoin& lineJoin) const; - FX_ERR GetMiterLimit(FX_FLOAT& miterLimit) const; - FX_ERR GetLineWidth(FX_FLOAT& lineWidth) const; - FX_ERR GetStrokeAlignment(FX_StrokeAlignment& strokeAlignment) const; - FX_ERR GetClipRect(CFX_RectF& rect) const; - CFX_Matrix* GetMatrix(); - CFX_RenderDevice* GetRenderDevice(); - - FX_ERR SetLineCap(CFX_GraphStateData::LineCap lineCap); - FX_ERR SetLineDash(FX_FLOAT dashPhase, - FX_FLOAT* dashArray, - int32_t dashCount); - FX_ERR SetLineDash(FX_DashStyle dashStyle); - FX_ERR SetLineJoin(CFX_GraphStateData::LineJoin lineJoin); - FX_ERR SetMiterLimit(FX_FLOAT miterLimit); - FX_ERR SetLineWidth(FX_FLOAT lineWidth, FX_BOOL isActOnDash = FALSE); - FX_ERR SetStrokeAlignment(FX_StrokeAlignment strokeAlignment); - FX_ERR SetStrokeColor(CFX_Color* color); - FX_ERR SetFillColor(CFX_Color* color); - FX_ERR SetClipRect(const CFX_RectF& rect); - FX_ERR SetFont(CFX_Font* font); - FX_ERR SetFontSize(const FX_FLOAT size); - FX_ERR SetFontHScale(const FX_FLOAT scale); - FX_ERR SetCharSpacing(const FX_FLOAT spacing); - FX_ERR SetTextDrawingMode(const int32_t mode); - - FX_ERR StrokePath(CFX_Path* path, CFX_Matrix* matrix = NULL); - FX_ERR FillPath(CFX_Path* path, - FX_FillMode fillMode = FXFILL_WINDING, - CFX_Matrix* matrix = NULL); - FX_ERR ClipPath(CFX_Path* path, - FX_FillMode fillMode = FXFILL_WINDING, - CFX_Matrix* matrix = NULL); - FX_ERR DrawImage(CFX_DIBSource* source, - const CFX_PointF& point, - CFX_Matrix* matrix = NULL); - FX_ERR StretchImage(CFX_DIBSource* source, - const CFX_RectF& rect, - CFX_Matrix* matrix = NULL); - FX_ERR ConcatMatrix(const CFX_Matrix* matrix); - FX_ERR ClearClip(); - FX_ERR ShowText(const CFX_PointF& point, - const CFX_WideString& text, - CFX_Matrix* matrix = NULL); - FX_ERR CalcTextRect(CFX_RectF& rect, - const CFX_WideString& text, - FX_BOOL isMultiline = FALSE, - CFX_Matrix* matrix = NULL); - FX_ERR Transfer(CFX_Graphics* graphics, const CFX_Matrix* matrix); - FX_ERR Transfer(CFX_Graphics* graphics, - FX_FLOAT srcLeft, - FX_FLOAT srcTop, - const CFX_RectF& dstRect, - const CFX_Matrix* matrix); - - FX_ERR InverseRect(const CFX_RectF& rect); - FX_ERR XorDIBitmap(const CFX_DIBitmap* srcBitmap, const CFX_RectF& rect); - FX_ERR EqvDIBitmap(const CFX_DIBitmap* srcBitmap, const CFX_RectF& rect); - - private: - FX_ERR RenderDeviceSetLineDash(FX_DashStyle dashStyle); - FX_ERR RenderDeviceStrokePath(CFX_Path* path, CFX_Matrix* matrix); - FX_ERR RenderDeviceFillPath(CFX_Path* path, - FX_FillMode fillMode, - CFX_Matrix* matrix); - FX_ERR RenderDeviceDrawImage(CFX_DIBSource* source, - const CFX_PointF& point, - CFX_Matrix* matrix); - FX_ERR RenderDeviceStretchImage(CFX_DIBSource* source, - const CFX_RectF& rect, - CFX_Matrix* matrix); - FX_ERR RenderDeviceShowText(const CFX_PointF& point, - const CFX_WideString& text, - CFX_Matrix* matrix); - - FX_ERR StrokePathWithPattern(CFX_Path* path, CFX_Matrix* matrix); - FX_ERR StrokePathWithShading(CFX_Path* path, CFX_Matrix* matrix); - - FX_ERR FillPathWithPattern(CFX_Path* path, - FX_FillMode fillMode, - CFX_Matrix* matrix); - FX_ERR FillPathWithShading(CFX_Path* path, - FX_FillMode fillMode, - CFX_Matrix* matrix); - - FX_ERR SetDIBitsWithMatrix(CFX_DIBSource* source, CFX_Matrix* matrix); - FX_ERR CalcTextInfo(const CFX_WideString& text, - FX_DWORD* charCodes, - FXTEXT_CHARPOS* charPos, - CFX_RectF& rect); - - protected: - int32_t m_type; - - private: - struct TInfo { - TInfo() - : isAntialiasing(TRUE), - strokeAlignment(FX_STROKEALIGNMENT_Center), - isActOnDash(FALSE), - strokeColor(nullptr), - fillColor(nullptr), - font(nullptr), - fontSize(40.0), - fontHScale(1.0), - fontSpacing(0.0) {} - explicit TInfo(const TInfo& info); - TInfo& operator=(const TInfo& other); - - CFX_GraphStateData graphState; - FX_BOOL isAntialiasing; - FX_StrokeAlignment strokeAlignment; - CFX_Matrix CTM; - FX_BOOL isActOnDash; - CFX_Color* strokeColor; - CFX_Color* fillColor; - CFX_Font* font; - FX_FLOAT fontSize; - FX_FLOAT fontHScale; - FX_FLOAT fontSpacing; - } m_info; - CFX_RenderDevice* m_renderDevice; - CFX_PtrArray m_infoStack; - CAGG_Graphics* m_aggGraphics; - friend class CAGG_Graphics; -}; - -class CFX_Path { - public: - CFX_Path(); - virtual ~CFX_Path(); - - FX_ERR Create(); - FX_ERR MoveTo(FX_FLOAT x, FX_FLOAT y); - FX_ERR LineTo(FX_FLOAT x, FX_FLOAT y); - FX_ERR BezierTo(FX_FLOAT ctrlX1, - FX_FLOAT ctrlY1, - FX_FLOAT ctrlX2, - FX_FLOAT ctrlY2, - FX_FLOAT toX, - FX_FLOAT toY); - FX_ERR ArcTo(FX_FLOAT left, - FX_FLOAT top, - FX_FLOAT width, - FX_FLOAT height, - FX_FLOAT startAngle, - FX_FLOAT sweepAngle); - FX_ERR Close(); - - FX_ERR AddLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2); - FX_ERR AddBezier(FX_FLOAT startX, - FX_FLOAT startY, - FX_FLOAT ctrlX1, - FX_FLOAT ctrlY1, - FX_FLOAT ctrlX2, - FX_FLOAT ctrlY2, - FX_FLOAT endX, - FX_FLOAT endY); - FX_ERR AddRectangle(FX_FLOAT left, - FX_FLOAT top, - FX_FLOAT width, - FX_FLOAT height); - FX_ERR AddEllipse(FX_FLOAT left, - FX_FLOAT top, - FX_FLOAT width, - FX_FLOAT height); - FX_ERR AddEllipse(const CFX_RectF& rect); - FX_ERR AddArc(FX_FLOAT left, - FX_FLOAT top, - FX_FLOAT width, - FX_FLOAT height, - FX_FLOAT startAngle, - FX_FLOAT sweepAngle); - FX_ERR AddPie(FX_FLOAT left, - FX_FLOAT top, - FX_FLOAT width, - FX_FLOAT height, - FX_FLOAT startAngle, - FX_FLOAT sweepAngle); - FX_ERR AddSubpath(CFX_Path* path); - FX_ERR Clear(); - - FX_BOOL IsEmpty(); - CFX_PathData* GetPathData(); - - private: - CFX_PathGenerator* m_generator; -}; - -class CFX_Color { - public: - CFX_Color(); - // TODO(weili): Remove implicit conversions. Make this explicit. - CFX_Color(const FX_ARGB argb); - explicit CFX_Color(CFX_Pattern* pattern, const FX_ARGB argb = 0x0); - explicit CFX_Color(CFX_Shading* shading); - virtual ~CFX_Color(); - - FX_ERR Set(const FX_ARGB argb); - FX_ERR Set(CFX_Pattern* pattern, const FX_ARGB argb = 0x0); - FX_ERR Set(CFX_Shading* shading); - - private: - int32_t m_type; - union { - struct { - FX_ARGB argb; - CFX_Pattern* pattern; - } m_info; - CFX_Shading* m_shading; - }; - - friend class CFX_Graphics; -}; - -class CFX_Pattern { - public: - CFX_Pattern(); - virtual ~CFX_Pattern(); - - FX_ERR Create(CFX_DIBitmap* bitmap, - const FX_FLOAT xStep, - const FX_FLOAT yStep, - CFX_Matrix* matrix = NULL); - FX_ERR Create(FX_HatchStyle hatchStyle, - const FX_ARGB foreArgb, - const FX_ARGB backArgb, - CFX_Matrix* matrix = NULL); - - private: - int32_t m_type; - CFX_Matrix m_matrix; - union { - struct { - CFX_RectF rect; - FX_FLOAT xStep; - FX_FLOAT yStep; - FX_BOOL isColored; - } m_rectInfo; - struct { - CFX_DIBitmap* bitmap; - FX_FLOAT x1Step; - FX_FLOAT y1Step; - } m_bitmapInfo; - struct { - FX_HatchStyle hatchStyle; - FX_ARGB foreArgb; - FX_ARGB backArgb; - } m_hatchInfo; - }; - friend class CFX_Graphics; -}; - -class CFX_Shading { - public: - CFX_Shading(); - virtual ~CFX_Shading(); - - FX_ERR CreateAxial(const CFX_PointF& beginPoint, - const CFX_PointF& endPoint, - FX_BOOL isExtendedBegin, - FX_BOOL isExtendedEnd, - const FX_ARGB beginArgb, - const FX_ARGB endArgb); - FX_ERR CreateRadial(const CFX_PointF& beginPoint, - const CFX_PointF& endPoint, - const FX_FLOAT beginRadius, - const FX_FLOAT endRadius, - FX_BOOL isExtendedBegin, - FX_BOOL isExtendedEnd, - const FX_ARGB beginArgb, - const FX_ARGB endArgb); - - private: - FX_ERR InitArgbArray(); - - int32_t m_type; - CFX_PointF m_beginPoint; - CFX_PointF m_endPoint; - FX_FLOAT m_beginRadius; - FX_FLOAT m_endRadius; - FX_BOOL m_isExtendedBegin; - FX_BOOL m_isExtendedEnd; - FX_ARGB m_beginArgb; - FX_ARGB m_endArgb; - FX_ARGB m_argbArray[FX_SHADING_Steps]; - friend class CFX_Graphics; -}; - -#endif // XFA_INCLUDE_FXGRAPHICS_FX_GRAPHICS_H_ -- cgit v1.2.3