diff options
-rw-r--r-- | BUILD.gn | 17 | ||||
-rw-r--r-- | core/fxge/apple/fx_apple_platform.cpp | 3 | ||||
-rw-r--r-- | core/fxge/apple/fx_quartz_device.cpp | 4 | ||||
-rw-r--r-- | core/fxge/ge/fx_ge_linux.cpp | 3 | ||||
-rw-r--r-- | core/fxge/skia/fx_skia_device.cpp | 2 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_device.cpp | 122 | ||||
-rw-r--r-- | pdfium.gyp | 7 | ||||
-rw-r--r-- | third_party/BUILD.gn | 64 | ||||
-rw-r--r-- | third_party/third_party.gyp | 70 |
9 files changed, 219 insertions, 73 deletions
@@ -647,12 +647,7 @@ static_library("fxcrt") { } static_library("fxge") { - deps = [ - "third_party:fx_agg", - ] sources = [ - "core/fxge/agg/fx_agg_driver.cpp", - "core/fxge/agg/fx_agg_driver.h", "core/fxge/android/fpf_skiafont.cpp", "core/fxge/android/fpf_skiafont.h", "core/fxge/android/fpf_skiafontmgr.cpp", @@ -714,7 +709,17 @@ static_library("fxge") { if (pdf_use_skia) { sources += [ "core/fxge/skia/fx_skia_device.cpp" ] - deps += [ "//skia" ] + deps = [ + "//skia", + ] + } else { + sources += [ + "core/fxge/agg/fx_agg_driver.cpp", + "core/fxge/agg/fx_agg_driver.h", + ] + deps = [ + "third_party:fx_agg", + ] } if (is_win) { diff --git a/core/fxge/apple/fx_apple_platform.cpp b/core/fxge/apple/fx_apple_platform.cpp index e45b238cb5..a641ad5f85 100644 --- a/core/fxge/apple/fx_apple_platform.cpp +++ b/core/fxge/apple/fx_apple_platform.cpp @@ -9,7 +9,10 @@ #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ +#ifndef _SKIA_SUPPORT_ #include "core/fxge/agg/fx_agg_driver.h" +#endif + #include "core/fxge/apple/apple_int.h" #include "core/fxge/dib/dib_int.h" #include "core/fxge/ge/fx_text_int.h" diff --git a/core/fxge/apple/fx_quartz_device.cpp b/core/fxge/apple/fx_quartz_device.cpp index f3a4428ecc..6669899300 100644 --- a/core/fxge/apple/fx_quartz_device.cpp +++ b/core/fxge/apple/fx_quartz_device.cpp @@ -5,7 +5,11 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "core/fxcrt/include/fx_ext.h" + +#ifndef _SKIA_SUPPORT_ #include "core/fxge/agg/fx_agg_driver.h" +#endif + #include "core/fxge/dib/dib_int.h" #include "core/fxge/ge/fx_text_int.h" #include "core/fxge/include/fx_freetype.h" diff --git a/core/fxge/ge/fx_ge_linux.cpp b/core/fxge/ge/fx_ge_linux.cpp index 0bd67b01be..0d5aff75fa 100644 --- a/core/fxge/ge/fx_ge_linux.cpp +++ b/core/fxge/ge/fx_ge_linux.cpp @@ -4,7 +4,10 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#ifndef _SKIA_SUPPORT_ #include "core/fxge/agg/fx_agg_driver.h" +#endif + #include "core/fxge/ge/fx_text_int.h" #include "core/fxge/include/fx_ge.h" diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp index 7f47d855c9..d6d8218d57 100644 --- a/core/fxge/skia/fx_skia_device.cpp +++ b/core/fxge/skia/fx_skia_device.cpp @@ -233,7 +233,7 @@ bool AddSamples(const CPDF_Function* pFunc, return false; uint32_t sampleSize = sampledFunc->m_nBitsPerSample; uint32_t sampleCount = encodeInfo.sizes; - if (sampleCount != 1 << sampleSize) + if (sampleCount != 1U << sampleSize) return false; if (sampledFunc->m_pSampleStream->GetSize() < sampleCount * 3 * sampleSize / 8) { diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index 3d96deb9e4..caf271dff3 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -10,7 +10,11 @@ #include <crtdbg.h> #include "core/fxcodec/include/fx_codec.h" + +#ifndef _SKIA_SUPPORT_ #include "core/fxge/agg/fx_agg_driver.h" +#endif + #include "core/fxge/dib/dib_int.h" #include "core/fxge/ge/fx_text_int.h" #include "core/fxge/include/fx_font.h" @@ -807,6 +811,112 @@ static void _SetPathToDC(HDC hDC, } EndPath(hDC); } + +#ifdef _SKIA_SUPPORT_ +// TODO(caryclark) This antigrain function is duplicated here to permit +// removing the last remaining dependency. Eventually, this will be elminiated +// altogether and replace by Skia code. + +struct rect_base { + FX_FLOAT x1; + FX_FLOAT y1; + FX_FLOAT x2; + FX_FLOAT y2; +}; + +static unsigned clip_liang_barsky(FX_FLOAT x1, + FX_FLOAT y1, + FX_FLOAT x2, + FX_FLOAT y2, + const rect_base& clip_box, + FX_FLOAT* x, + FX_FLOAT* y) { + const FX_FLOAT nearzero = 1e-30f; + FX_FLOAT deltax = x2 - x1; + FX_FLOAT deltay = y2 - y1; + unsigned np = 0; + if (deltax == 0) + deltax = (x1 > clip_box.x1) ? -nearzero : nearzero; + FX_FLOAT xin, xout; + if (deltax > 0) { + xin = clip_box.x1; + xout = clip_box.x2; + } else { + xin = clip_box.x2; + xout = clip_box.x1; + } + FX_FLOAT tinx = (xin - x1) / deltax; + if (deltay == 0) + deltay = (y1 > clip_box.y1) ? -nearzero : nearzero; + FX_FLOAT yin, yout; + if (deltay > 0) { + yin = clip_box.y1; + yout = clip_box.y2; + } else { + yin = clip_box.y2; + yout = clip_box.y1; + } + FX_FLOAT tiny = (yin - y1) / deltay; + FX_FLOAT tin1, tin2; + if (tinx < tiny) { + tin1 = tinx; + tin2 = tiny; + } else { + tin1 = tiny; + tin2 = tinx; + } + if (tin1 <= 1.0f) { + if (0 < tin1) { + *x++ = xin; + *y++ = yin; + ++np; + } + if (tin2 <= 1.0f) { + FX_FLOAT toutx = (xout - x1) / deltax; + FX_FLOAT touty = (yout - y1) / deltay; + FX_FLOAT tout1 = (toutx < touty) ? toutx : touty; + if (tin2 > 0 || tout1 > 0) { + if (tin2 <= tout1) { + if (tin2 > 0) { + if (tinx > tiny) { + *x++ = xin; + *y++ = y1 + (deltay * tinx); + } else { + *x++ = x1 + (deltax * tiny); + *y++ = yin; + } + ++np; + } + if (tout1 < 1.0f) { + if (toutx < touty) { + *x++ = xout; + *y++ = y1 + (deltay * toutx); + } else { + *x++ = x1 + (deltax * touty); + *y++ = yout; + } + } else { + *x++ = x2; + *y++ = y2; + } + ++np; + } else { + if (tinx > tiny) { + *x++ = xin; + *y++ = yout; + } else { + *x++ = xout; + *y++ = yin; + } + ++np; + } + } + } + } + return np; +} +#endif + void CGdiDeviceDriver::DrawLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, @@ -819,10 +929,18 @@ void CGdiDeviceDriver::DrawLine(FX_FLOAT x1, return; } if (flag1 || flag2) { + FX_FLOAT x[2], y[2]; + int np; +#ifdef _SKIA_SUPPORT_ + // TODO(caryclark) temporary replacement of antigrain in line function + // to permit removing antigrain altogether + rect_base rect = {0.0f, 0.0f, (FX_FLOAT)(m_Width), (FX_FLOAT)(m_Height)}; + np = clip_liang_barsky(x1, y1, x2, y2, rect, x, y); +#else agg::rect_base<FX_FLOAT> rect(0.0f, 0.0f, (FX_FLOAT)(m_Width), (FX_FLOAT)(m_Height)); - FX_FLOAT x[2], y[2]; - int np = agg::clip_liang_barsky<FX_FLOAT>(x1, y1, x2, y2, rect, x, y); + np = agg::clip_liang_barsky<FX_FLOAT>(x1, y1, x2, y2, rect, x, y); +#endif if (np == 0) { return; } diff --git a/pdfium.gyp b/pdfium.gyp index 310fec5bf4..54d4058eec 100644 --- a/pdfium.gyp +++ b/pdfium.gyp @@ -732,9 +732,16 @@ 'sources': [ 'core/fxge/skia/fx_skia_device.cpp', ], + 'sources!': [ + 'core/fxge/agg/fx_agg_driver.h', + 'core/fxge/agg/fx_agg_driver.cpp', + ], 'dependencies': [ '<(DEPTH)/skia/skia.gyp:skia', ], + 'dependencies!': [ + 'third_party/third_party.gyp:fx_agg', + ], }], ['OS=="win"', { 'defines!': [ diff --git a/third_party/BUILD.gn b/third_party/BUILD.gn index b97a7858ad..6a070f7074 100644 --- a/third_party/BUILD.gn +++ b/third_party/BUILD.gn @@ -86,40 +86,42 @@ static_library("fx_freetype") { ] } -config("fx_agg_warnings") { - visibility = [ ":*" ] - if (is_clang) { - # calc_butt_cap() in agg_vcgen_stroke.cpp is unused. - cflags = [ "-Wno-unused-function" ] +if (!pdf_use_skia) { + config("fx_agg_warnings") { + visibility = [ ":*" ] + if (is_clang) { + # calc_butt_cap() in agg_vcgen_stroke.cpp is unused. + cflags = [ "-Wno-unused-function" ] + } } -} -source_set("fx_agg") { - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ - "//build/config/compiler:no_chromium_code", - "../:pdfium_config", + source_set("fx_agg") { + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ + "//build/config/compiler:no_chromium_code", + "../:pdfium_config", - # Must be after no_chromium_code for warning flags to be ordered correctly. - ":fx_agg_warnings", - ] - sources = [ - "agg23/agg_basics.h", - "agg23/agg_clip_liang_barsky.h", - "agg23/agg_conv_dash.h", - "agg23/agg_conv_stroke.h", - "agg23/agg_curves.cpp", - "agg23/agg_curves.h", - "agg23/agg_path_storage.cpp", - "agg23/agg_path_storage.h", - "agg23/agg_rasterizer_scanline_aa.cpp", - "agg23/agg_rasterizer_scanline_aa.h", - "agg23/agg_renderer_scanline.h", - "agg23/agg_rendering_buffer.h", - "agg23/agg_scanline_u.h", - "agg23/agg_vcgen_dash.cpp", - "agg23/agg_vcgen_stroke.cpp", - ] + # Must be after no_chromium_code for warning flags to be ordered correctly. + ":fx_agg_warnings", + ] + sources = [ + "agg23/agg_basics.h", + "agg23/agg_clip_liang_barsky.h", + "agg23/agg_conv_dash.h", + "agg23/agg_conv_stroke.h", + "agg23/agg_curves.cpp", + "agg23/agg_curves.h", + "agg23/agg_path_storage.cpp", + "agg23/agg_path_storage.h", + "agg23/agg_rasterizer_scanline_aa.cpp", + "agg23/agg_rasterizer_scanline_aa.h", + "agg23/agg_renderer_scanline.h", + "agg23/agg_rendering_buffer.h", + "agg23/agg_scanline_u.h", + "agg23/agg_vcgen_dash.cpp", + "agg23/agg_vcgen_stroke.cpp", + ] + } } config("fx_lcms2_warnings") { diff --git a/third_party/third_party.gyp b/third_party/third_party.gyp index 41db3b28db..fae4c8f1f4 100644 --- a/third_party/third_party.gyp +++ b/third_party/third_party.gyp @@ -107,39 +107,6 @@ ], }, { - 'target_name': 'fx_agg', - 'type': 'static_library', - 'sources': [ - 'agg23/agg_basics.h', - 'agg23/agg_clip_liang_barsky.h', - 'agg23/agg_conv_dash.h', - 'agg23/agg_conv_stroke.h', - 'agg23/agg_curves.cpp', - 'agg23/agg_curves.h', - 'agg23/agg_path_storage.cpp', - 'agg23/agg_path_storage.h', - 'agg23/agg_rasterizer_scanline_aa.cpp', - 'agg23/agg_rasterizer_scanline_aa.h', - 'agg23/agg_renderer_scanline.h', - 'agg23/agg_rendering_buffer.h', - 'agg23/agg_scanline_u.h', - 'agg23/agg_vcgen_dash.cpp', - 'agg23/agg_vcgen_stroke.cpp', - ], - 'conditions': [ - ['os_posix==1', { - # library contains several enum vs non-enum conditionals. - 'cflags': [ '-Wno-extra' ], - }], - ], - 'variables': { - 'clang_warning_flags': [ - # calc_butt_cap() in agg_vcgen_stroke.cpp is unused. - '-Wno-unused-function', - ], - }, - }, - { 'target_name': 'fx_lcms2', 'type': 'static_library', 'sources': [ @@ -439,5 +406,42 @@ }, ], }], + ['pdf_use_skia!=1', { + 'targets': [ + { + 'target_name': 'fx_agg', + 'type': 'static_library', + 'sources': [ + 'agg23/agg_basics.h', + 'agg23/agg_clip_liang_barsky.h', + 'agg23/agg_conv_dash.h', + 'agg23/agg_conv_stroke.h', + 'agg23/agg_curves.cpp', + 'agg23/agg_curves.h', + 'agg23/agg_path_storage.cpp', + 'agg23/agg_path_storage.h', + 'agg23/agg_rasterizer_scanline_aa.cpp', + 'agg23/agg_rasterizer_scanline_aa.h', + 'agg23/agg_renderer_scanline.h', + 'agg23/agg_rendering_buffer.h', + 'agg23/agg_scanline_u.h', + 'agg23/agg_vcgen_dash.cpp', + 'agg23/agg_vcgen_stroke.cpp', + ], + 'conditions': [ + ['os_posix==1', { + # library contains several enum vs non-enum conditionals. + 'cflags': [ '-Wno-extra', ], + }], + ], + 'variables': { + 'clang_warning_flags': [ + # calc_butt_cap() in agg_vcgen_stroke.cpp is unused. + '-Wno-unused-function', + ], + }, + }, + ], + }], ], } |