From 44b7568c8a4ef6bbdba8f892902b751afc19bf7d Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Tue, 31 Aug 2021 22:30:44 +0000 Subject: [PATCH] Revert "Fix compilation w/ "skia_enable_svg = false" (take 2)" This reverts commit 30a6b101f43935f6016c0af5fdd70b078161709f. Reason for revert: Maybe blocking G3 roll? Original change's description: > Fix compilation w/ "skia_enable_svg = false" (take 2) > > Change-Id: I036ae171809af56cc9594704b44705ebd095ec80 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/443898 > Reviewed-by: Florin Malita > Commit-Queue: Robert Phillips TBR=robertphillips@google.com,fmalita@chromium.org,fmalita@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com Change-Id: Ibee3819e073b04efdf9736058c1f9b288249620c No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/c/skia/+/444216 Reviewed-by: Robert Phillips Commit-Queue: Robert Phillips --- bench/nanobench.cpp | 9 ++++----- dm/DM.cpp | 2 +- dm/DMSrcSink.cpp | 11 +++++------ dm/DMSrcSink.h | 4 ++-- fuzz/FuzzMain.cpp | 12 +----------- fuzz/oss_fuzz/FuzzSVG.cpp | 5 ----- modules/svg/BUILD.gn | 2 +- modules/svg/tests/Filters.cpp | 1 - samplecode/SampleCowboy.cpp | 5 ++--- samplecode/SampleSVGFile.cpp | 5 ++--- tools/fm/fm.cpp | 13 ++----------- tools/fonts/TestFontMgr.cpp | 2 +- tools/fonts/TestSVGTypeface.cpp | 5 ++--- tools/fonts/TestSVGTypeface.h | 6 +----- tools/fonts/create_test_font_color.cpp | 11 ----------- tools/skpbench/skpbench.cpp | 6 +++--- tools/viewer/BisectSlide.cpp | 5 ++--- tools/viewer/SvgSlide.cpp | 5 ++--- tools/viewer/Viewer.cpp | 2 +- 19 files changed, 32 insertions(+), 79 deletions(-) diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp index b9e5632592..65a2d8700d 100644 --- a/bench/nanobench.cpp +++ b/bench/nanobench.cpp @@ -51,10 +51,9 @@ #include "tools/trace/EventTracingPriv.h" #include "tools/trace/SkDebugfTracer.h" -#if defined(SK_ENABLE_SVG) +#ifdef SK_XML #include "modules/svg/include/SkSVGDOM.h" -#include "modules/svg/include/SkSVGNode.h" -#endif +#endif // SK_XML #ifdef SK_ENABLE_ANDROID_UTILS #include "bench/BitmapRegionDecoderBench.h" @@ -727,7 +726,7 @@ public: return nullptr; } -#if defined(SK_ENABLE_SVG) +#ifdef SK_XML SkMemoryStream stream(std::move(data)); sk_sp svgDom = SkSVGDOM::MakeFromStream(stream); if (!svgDom) { @@ -747,7 +746,7 @@ public: return recorder.finishRecordingAsPicture(); #else return nullptr; -#endif // defined(SK_ENABLE_SVG) +#endif // SK_XML } Benchmark* next() { diff --git a/dm/DM.cpp b/dm/DM.cpp index 7ae0c06f74..10cd5db922 100644 --- a/dm/DM.cpp +++ b/dm/DM.cpp @@ -877,7 +877,7 @@ static bool gather_srcs() { #if defined(SK_ENABLE_SKRIVE) gather_file_srcs(FLAGS_rives, "flr", "rive"); #endif -#if defined(SK_ENABLE_SVG) +#if defined(SK_XML) gather_file_srcs(FLAGS_svgs, "svg"); #endif if (!FLAGS_bisect.isEmpty()) { diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp index da31524b3b..4014415967 100644 --- a/dm/DMSrcSink.cpp +++ b/dm/DMSrcSink.cpp @@ -72,10 +72,9 @@ #include "experimental/skrive/include/SkRive.h" #endif -#if defined(SK_ENABLE_SVG) +#if defined(SK_XML) #include "include/svg/SkSVGCanvas.h" #include "modules/svg/include/SkSVGDOM.h" - #include "modules/svg/include/SkSVGNode.h" #include "src/xml/SkXMLWriter.h" #endif @@ -1305,7 +1304,7 @@ bool SkRiveSrc::veto(SinkFlags flags) const { #endif /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ -#if defined(SK_ENABLE_SVG) +#if defined(SK_XML) // Used when the image doesn't have an intrinsic size. static const SkSize kDefaultSVGSize = {1000, 1000}; @@ -1374,7 +1373,7 @@ bool SVGSrc::veto(SinkFlags flags) const { return !type_ok || flags.approach != SinkFlags::kDirect; } -#endif // defined(SK_ENABLE_SVG) +#endif // defined(SK_XML) /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ MSKPSrc::MSKPSrc(Path path) : fPath(path) { @@ -2071,7 +2070,7 @@ Result DebugSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) con SVGSink::SVGSink(int pageIndex) : fPageIndex(pageIndex) {} Result SVGSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const { -#if defined(SK_ENABLE_SVG) +#if defined(SK_XML) if (src.pageCount() > 1) { int pageCount = src.pageCount(); if (fPageIndex > pageCount - 1) { @@ -2087,7 +2086,7 @@ Result SVGSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const #else (void)fPageIndex; return Result::Fatal("SVG sink is disabled."); -#endif // SK_ENABLE_SVG +#endif // SK_XML } /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ diff --git a/dm/DMSrcSink.h b/dm/DMSrcSink.h index 85c71ee2fc..05449efe1b 100644 --- a/dm/DMSrcSink.h +++ b/dm/DMSrcSink.h @@ -329,7 +329,7 @@ private: }; #endif -#if defined(SK_ENABLE_SVG) +#if defined(SK_XML) } // namespace DM class SkSVGDOM; @@ -352,7 +352,7 @@ private: using INHERITED = Src; }; -#endif // SK_ENABLE_SVG +#endif // SK_XML /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ class MSKPSrc : public Src { diff --git a/fuzz/FuzzMain.cpp b/fuzz/FuzzMain.cpp index 09b9a9a4f2..1a9e7fae9d 100644 --- a/fuzz/FuzzMain.cpp +++ b/fuzz/FuzzMain.cpp @@ -93,14 +93,11 @@ static void fuzz_sksl2glsl(sk_sp); static void fuzz_sksl2metal(sk_sp); static void fuzz_sksl2pipeline(sk_sp); static void fuzz_sksl2spirv(sk_sp); +static void fuzz_svg_dom(sk_sp); static void fuzz_textblob_deserialize(sk_sp); static void print_api_names(); -#if defined(SK_ENABLE_SVG) -static void fuzz_svg_dom(sk_sp); -#endif - #if defined(SK_ENABLE_SKOTTIE) static void fuzz_skottie_json(sk_sp); #endif @@ -252,12 +249,10 @@ static int fuzz_file(SkString path, SkString type) { fuzz_sksl2pipeline(bytes); return 0; } -#if defined(SK_ENABLE_SVG) if (type.equals("svg_dom")) { fuzz_svg_dom(bytes); return 0; } -#endif if (type.equals("textblob")) { fuzz_textblob_deserialize(bytes); return 0; @@ -309,9 +304,7 @@ static std::map cf_map = { #if defined(SK_ENABLE_SKOTTIE) {"skottie_json", "skottie_json"}, #endif -#if defined(SK_ENABLE_SVG) {"svg_dom", "svg_dom"}, -#endif {"textblob_deserialize", "textblob"} }; @@ -362,14 +355,11 @@ static void fuzz_skottie_json(sk_sp bytes){ } #endif -#if defined(SK_ENABLE_SVG) void FuzzSVG(sk_sp bytes); - static void fuzz_svg_dom(sk_sp bytes){ FuzzSVG(bytes); SkDebugf("[terminated] Done DOM!\n"); } -#endif // This adds up the first 1024 bytes and returns it as an 8 bit integer. This allows afl-fuzz to // deterministically excercise different paths, or *options* (such as different scaling sizes or diff --git a/fuzz/oss_fuzz/FuzzSVG.cpp b/fuzz/oss_fuzz/FuzzSVG.cpp index 30d27a4777..1750630737 100644 --- a/fuzz/oss_fuzz/FuzzSVG.cpp +++ b/fuzz/oss_fuzz/FuzzSVG.cpp @@ -9,9 +9,6 @@ #include "include/core/SkStream.h" #include "include/core/SkSurface.h" #include "modules/svg/include/SkSVGDOM.h" -#include "modules/svg/include/SkSVGNode.h" - -#if defined(SK_ENABLE_SVG) void FuzzSVG(sk_sp bytes) { uint8_t w = 100; @@ -44,5 +41,3 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { return 0; } #endif - -#endif // SK_ENABLE_SVG diff --git a/modules/svg/BUILD.gn b/modules/svg/BUILD.gn index c5888c34ae..a4bed30c6d 100644 --- a/modules/svg/BUILD.gn +++ b/modules/svg/BUILD.gn @@ -5,7 +5,7 @@ import("../../gn/skia.gni") -if (skia_enable_svg && skia_use_expat) { +if (skia_enable_svg) { config("public_config") { defines = [ "SK_ENABLE_SVG" ] include_dirs = [ "include" ] diff --git a/modules/svg/tests/Filters.cpp b/modules/svg/tests/Filters.cpp index b7ee21d48e..15b31b182e 100644 --- a/modules/svg/tests/Filters.cpp +++ b/modules/svg/tests/Filters.cpp @@ -10,7 +10,6 @@ #include "include/core/SkStream.h" #include "include/utils/SkNoDrawCanvas.h" #include "modules/svg/include/SkSVGDOM.h" -#include "modules/svg/include/SkSVGNode.h" #include "tests/Test.h" DEF_TEST(Svg_Filters_NonePaintInputs, r) { diff --git a/samplecode/SampleCowboy.cpp b/samplecode/SampleCowboy.cpp index 9c9a20aa93..62a72f28ce 100644 --- a/samplecode/SampleCowboy.cpp +++ b/samplecode/SampleCowboy.cpp @@ -7,13 +7,12 @@ #include "include/core/SkTypes.h" -#if defined(SK_ENABLE_SVG) +#ifdef SK_XML #include "include/core/SkCanvas.h" #include "include/core/SkRect.h" #include "include/core/SkStream.h" #include "modules/svg/include/SkSVGDOM.h" -#include "modules/svg/include/SkSVGNode.h" #include "samplecode/Sample.h" #include "src/core/SkOSFile.h" #include "src/utils/SkOSPath.h" @@ -120,4 +119,4 @@ private: DEF_SAMPLE( return new AnimatedSVGSample("Cowboy.svg", "SampleCowboy"); ) -#endif // defined(SK_ENABLE_SVG) +#endif // SK_XML diff --git a/samplecode/SampleSVGFile.cpp b/samplecode/SampleSVGFile.cpp index b607d9a02e..8b3444226e 100644 --- a/samplecode/SampleSVGFile.cpp +++ b/samplecode/SampleSVGFile.cpp @@ -7,12 +7,11 @@ #include "include/core/SkTypes.h" -#if defined(SK_ENABLE_SVG) +#ifdef SK_XML #include "include/core/SkCanvas.h" #include "include/core/SkStream.h" #include "modules/svg/include/SkSVGDOM.h" -#include "modules/svg/include/SkSVGNode.h" #include "samplecode/Sample.h" #include "src/core/SkOSFile.h" #include "src/utils/SkOSPath.h" @@ -70,4 +69,4 @@ Sample* CreateSampleSVGFileView(const SkString& filename); Sample* CreateSampleSVGFileView(const SkString& filename) { return new SVGFileView(filename); } -#endif // defined(SK_ENABLE_SVG) +#endif // SK_XML diff --git a/tools/fm/fm.cpp b/tools/fm/fm.cpp index dc54caeb52..67624eb74e 100644 --- a/tools/fm/fm.cpp +++ b/tools/fm/fm.cpp @@ -12,6 +12,7 @@ #include "include/gpu/GrContextOptions.h" #include "include/gpu/GrDirectContext.h" #include "include/private/SkTHash.h" +#include "modules/svg/include/SkSVGDOM.h" #include "src/core/SkColorSpacePriv.h" #include "src/core/SkMD5.h" #include "src/core/SkOSFile.h" @@ -37,11 +38,6 @@ #include #include -#if defined(SK_ENABLE_SVG) -#include "modules/svg/include/SkSVGDOM.h" -#include "modules/svg/include/SkSVGNode.h" -#endif - #if defined(SK_ENABLE_SKOTTIE) #include "modules/skottie/include/Skottie.h" #include "modules/skresources/include/SkResources.h" @@ -190,7 +186,6 @@ static void init(Source* source, std::shared_ptr codec) { }; } -#if defined(SK_ENABLE_SVG) static void init(Source* source, sk_sp svg) { if (svg->containerSize().isEmpty()) { svg->setContainerSize({1000,1000}); @@ -201,7 +196,6 @@ static void init(Source* source, sk_sp svg) { return ok; }; } -#endif #if defined(SK_ENABLE_SKOTTIE) static void init(Source* source, sk_sp animation) { @@ -460,16 +454,13 @@ int main(int argc, char** argv) { init(source, pic); continue; } - } -#if defined(SK_ENABLE_SVG) - else if (name.endsWith(".svg")) { + } else if (name.endsWith(".svg")) { SkMemoryStream stream{blob}; if (sk_sp svg = SkSVGDOM::MakeFromStream(stream)) { init(source, svg); continue; } } -#endif #if defined(SK_ENABLE_SKOTTIE) else if (name.endsWith(".json")) { const SkString dir = SkOSPath::Dirname(name.c_str()); diff --git a/tools/fonts/TestFontMgr.cpp b/tools/fonts/TestFontMgr.cpp index aba8e0eb3a..023e43cae5 100644 --- a/tools/fonts/TestFontMgr.cpp +++ b/tools/fonts/TestFontMgr.cpp @@ -95,7 +95,7 @@ public: } } } -#if defined(SK_ENABLE_SVG) +#ifdef SK_XML fFamilies.emplace_back(sk_make_sp("Emoji")); fFamilies.back()->fTypefaces.emplace_back( TestSVGTypeface::Default(), SkFontStyle::Normal(), "Normal"); diff --git a/tools/fonts/TestSVGTypeface.cpp b/tools/fonts/TestSVGTypeface.cpp index 5ab2b188dd..c32a380d72 100644 --- a/tools/fonts/TestSVGTypeface.cpp +++ b/tools/fonts/TestSVGTypeface.cpp @@ -7,7 +7,7 @@ #include "tools/fonts/TestSVGTypeface.h" -#if defined(SK_ENABLE_SVG) +#ifdef SK_XML #include "include/core/SkBitmap.h" #include "include/core/SkCanvas.h" @@ -30,7 +30,6 @@ #include "include/private/SkTemplates.h" #include "include/utils/SkNoDrawCanvas.h" #include "modules/svg/include/SkSVGDOM.h" -#include "modules/svg/include/SkSVGNode.h" #include "src/core/SkAdvancedTypefaceMetrics.h" #include "src/core/SkFontDescriptor.h" #include "src/core/SkFontPriv.h" @@ -1435,4 +1434,4 @@ void TestSVGTypeface::exportTtxColr(SkWStream* out) const { out->writeText("\n"); } -#endif // SK_ENABLE_SVG +#endif // SK_XML diff --git a/tools/fonts/TestSVGTypeface.h b/tools/fonts/TestSVGTypeface.h index c6de9795c6..487d17306f 100644 --- a/tools/fonts/TestSVGTypeface.h +++ b/tools/fonts/TestSVGTypeface.h @@ -40,8 +40,6 @@ struct SkAdvancedTypefaceMetrics; struct SkScalerContextEffects; struct SkScalerContextRec; -#ifdef SK_ENABLE_SVG - struct SkSVGTestTypefaceGlyphData { const char* fSvgResourcePath; SkPoint fOrigin; // y-down @@ -159,6 +157,4 @@ private: friend class SkTestSVGScalerContext; }; -#endif // SK_ENABLE_SVG - -#endif // TestSVGTypeface_DEFINED +#endif diff --git a/tools/fonts/create_test_font_color.cpp b/tools/fonts/create_test_font_color.cpp index 6b1a0a6bca..06d7431f5c 100644 --- a/tools/fonts/create_test_font_color.cpp +++ b/tools/fonts/create_test_font_color.cpp @@ -14,8 +14,6 @@ #include "tools/flags/CommandLineFlags.h" #include "tools/fonts/TestSVGTypeface.h" -#if defined(SK_ENABLE_SVG) - static void export_ttx(sk_sp typeface, SkString prefix, SkSpan cbdtStrikeSizes, @@ -51,12 +49,3 @@ int main(int argc, char** argv) { return 0; } - -#else - -int main(int argc, char** argv) { - SkDebugf("compile with SVG enabled\n"); - return 1; -} - -#endif // SK_ENABLE_SVG diff --git a/tools/skpbench/skpbench.cpp b/tools/skpbench/skpbench.cpp index c7e04c1f0f..977ad53399 100644 --- a/tools/skpbench/skpbench.cpp +++ b/tools/skpbench/skpbench.cpp @@ -33,7 +33,7 @@ #include "tools/gpu/GpuTimer.h" #include "tools/gpu/GrContextFactory.h" -#if defined(SK_ENABLE_SVG) +#ifdef SK_XML #include "modules/svg/include/SkSVGDOM.h" #include "src/xml/SkDOM.h" #endif @@ -699,7 +699,7 @@ static sk_sp create_warmup_skp() { } static sk_sp create_skp_from_svg(SkStream* stream, const char* filename) { -#if defined(SK_ENABLE_SVG) +#ifdef SK_XML sk_sp svg = SkSVGDOM::MakeFromStream(*stream); if (!svg) { exitf(ExitErr::kData, "failed to build svg dom from file %s", filename); @@ -714,7 +714,7 @@ static sk_sp create_skp_from_svg(SkStream* stream, const char* filena return recorder.finishRecordingAsPicture(); #endif - exitf(ExitErr::kData, "SK_ENABLE_SVG is disabled; cannot open svg file %s", filename); + exitf(ExitErr::kData, "SK_XML is disabled; cannot open svg file %s", filename); return nullptr; } diff --git a/tools/viewer/BisectSlide.cpp b/tools/viewer/BisectSlide.cpp index 475dfb928f..b845338840 100644 --- a/tools/viewer/BisectSlide.cpp +++ b/tools/viewer/BisectSlide.cpp @@ -13,9 +13,8 @@ #include -#if defined(SK_ENABLE_SVG) +#ifdef SK_XML #include "modules/svg/include/SkSVGDOM.h" -#include "modules/svg/include/SkSVGNode.h" #include "src/xml/SkDOM.h" #endif @@ -28,7 +27,7 @@ sk_sp BisectSlide::Create(const char filepath[]) { sk_sp bisect(new BisectSlide(filepath)); if (bisect->fFilePath.endsWith(".svg")) { -#if defined(SK_ENABLE_SVG) +#ifdef SK_XML sk_sp svg = SkSVGDOM::MakeFromStream(stream); if (!svg) { SkDebugf("BISECT: couldn't load svg at \"%s\"\n", filepath); diff --git a/tools/viewer/SvgSlide.cpp b/tools/viewer/SvgSlide.cpp index 7f918bb9cb..2bab0ae8c0 100644 --- a/tools/viewer/SvgSlide.cpp +++ b/tools/viewer/SvgSlide.cpp @@ -7,13 +7,12 @@ #include "tools/viewer/SvgSlide.h" -#if defined(SK_ENABLE_SVG) +#if defined(SK_XML) #include "include/core/SkCanvas.h" #include "include/core/SkStream.h" #include "modules/skresources/include/SkResources.h" #include "modules/svg/include/SkSVGDOM.h" -#include "modules/svg/include/SkSVGNode.h" #include "src/utils/SkOSPath.h" SvgSlide::SvgSlide(const SkString& name, const SkString& path) @@ -64,4 +63,4 @@ void SvgSlide::draw(SkCanvas* canvas) { } } -#endif // defined(SK_ENABLE_SVG) +#endif // SK_XML diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp index 5731e14665..5274211cdc 100644 --- a/tools/viewer/Viewer.cpp +++ b/tools/viewer/Viewer.cpp @@ -764,7 +764,7 @@ void Viewer::initSlides() { return sk_make_sp(name, path);} }, #endif -#if defined(SK_ENABLE_SVG) +#if defined(SK_XML) { ".svg", "svg-dir", FLAGS_svgs, [](const SkString& name, const SkString& path) -> sk_sp { return sk_make_sp(name, path);}