Reland "Fix compilation w/ "skia_enable_svg = false" (take 2)"
This reverts commit44b7568c8a
. Reason for revert: Google 3 CL has landed Original change's description: > Revert "Fix compilation w/ "skia_enable_svg = false" (take 2)" > > This reverts commit30a6b101f4
. > > 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 <fmalita@chromium.org> > > Commit-Queue: Robert Phillips <robertphillips@google.com> > > 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 <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> # Not skipping CQ checks because this is a reland. Change-Id: Idf73d864108067ee1c34e88ee4e5236847abd582 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/444501 Reviewed-by: Florin Malita <fmalita@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
0fc6bedf5a
commit
2af13c135b
@ -51,9 +51,10 @@
|
||||
#include "tools/trace/EventTracingPriv.h"
|
||||
#include "tools/trace/SkDebugfTracer.h"
|
||||
|
||||
#ifdef SK_XML
|
||||
#if defined(SK_ENABLE_SVG)
|
||||
#include "modules/svg/include/SkSVGDOM.h"
|
||||
#endif // SK_XML
|
||||
#include "modules/svg/include/SkSVGNode.h"
|
||||
#endif
|
||||
|
||||
#ifdef SK_ENABLE_ANDROID_UTILS
|
||||
#include "bench/BitmapRegionDecoderBench.h"
|
||||
@ -726,7 +727,7 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#ifdef SK_XML
|
||||
#if defined(SK_ENABLE_SVG)
|
||||
SkMemoryStream stream(std::move(data));
|
||||
sk_sp<SkSVGDOM> svgDom = SkSVGDOM::MakeFromStream(stream);
|
||||
if (!svgDom) {
|
||||
@ -746,7 +747,7 @@ public:
|
||||
return recorder.finishRecordingAsPicture();
|
||||
#else
|
||||
return nullptr;
|
||||
#endif // SK_XML
|
||||
#endif // defined(SK_ENABLE_SVG)
|
||||
}
|
||||
|
||||
Benchmark* next() {
|
||||
|
@ -877,7 +877,7 @@ static bool gather_srcs() {
|
||||
#if defined(SK_ENABLE_SKRIVE)
|
||||
gather_file_srcs<SkRiveSrc>(FLAGS_rives, "flr", "rive");
|
||||
#endif
|
||||
#if defined(SK_XML)
|
||||
#if defined(SK_ENABLE_SVG)
|
||||
gather_file_srcs<SVGSrc>(FLAGS_svgs, "svg");
|
||||
#endif
|
||||
if (!FLAGS_bisect.isEmpty()) {
|
||||
|
@ -72,9 +72,10 @@
|
||||
#include "experimental/skrive/include/SkRive.h"
|
||||
#endif
|
||||
|
||||
#if defined(SK_XML)
|
||||
#if defined(SK_ENABLE_SVG)
|
||||
#include "include/svg/SkSVGCanvas.h"
|
||||
#include "modules/svg/include/SkSVGDOM.h"
|
||||
#include "modules/svg/include/SkSVGNode.h"
|
||||
#include "src/xml/SkXMLWriter.h"
|
||||
#endif
|
||||
|
||||
@ -1304,7 +1305,7 @@ bool SkRiveSrc::veto(SinkFlags flags) const {
|
||||
#endif
|
||||
|
||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
||||
#if defined(SK_XML)
|
||||
#if defined(SK_ENABLE_SVG)
|
||||
// Used when the image doesn't have an intrinsic size.
|
||||
static const SkSize kDefaultSVGSize = {1000, 1000};
|
||||
|
||||
@ -1373,7 +1374,7 @@ bool SVGSrc::veto(SinkFlags flags) const {
|
||||
return !type_ok || flags.approach != SinkFlags::kDirect;
|
||||
}
|
||||
|
||||
#endif // defined(SK_XML)
|
||||
#endif // defined(SK_ENABLE_SVG)
|
||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
||||
|
||||
MSKPSrc::MSKPSrc(Path path) : fPath(path) {
|
||||
@ -2070,7 +2071,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_XML)
|
||||
#if defined(SK_ENABLE_SVG)
|
||||
if (src.pageCount() > 1) {
|
||||
int pageCount = src.pageCount();
|
||||
if (fPageIndex > pageCount - 1) {
|
||||
@ -2086,7 +2087,7 @@ Result SVGSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const
|
||||
#else
|
||||
(void)fPageIndex;
|
||||
return Result::Fatal("SVG sink is disabled.");
|
||||
#endif // SK_XML
|
||||
#endif // SK_ENABLE_SVG
|
||||
}
|
||||
|
||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
||||
|
@ -329,7 +329,7 @@ private:
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(SK_XML)
|
||||
#if defined(SK_ENABLE_SVG)
|
||||
} // namespace DM
|
||||
|
||||
class SkSVGDOM;
|
||||
@ -352,7 +352,7 @@ private:
|
||||
|
||||
using INHERITED = Src;
|
||||
};
|
||||
#endif // SK_XML
|
||||
#endif // SK_ENABLE_SVG
|
||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
||||
|
||||
class MSKPSrc : public Src {
|
||||
|
@ -93,11 +93,14 @@ static void fuzz_sksl2glsl(sk_sp<SkData>);
|
||||
static void fuzz_sksl2metal(sk_sp<SkData>);
|
||||
static void fuzz_sksl2pipeline(sk_sp<SkData>);
|
||||
static void fuzz_sksl2spirv(sk_sp<SkData>);
|
||||
static void fuzz_svg_dom(sk_sp<SkData>);
|
||||
static void fuzz_textblob_deserialize(sk_sp<SkData>);
|
||||
|
||||
static void print_api_names();
|
||||
|
||||
#if defined(SK_ENABLE_SVG)
|
||||
static void fuzz_svg_dom(sk_sp<SkData>);
|
||||
#endif
|
||||
|
||||
#if defined(SK_ENABLE_SKOTTIE)
|
||||
static void fuzz_skottie_json(sk_sp<SkData>);
|
||||
#endif
|
||||
@ -249,10 +252,12 @@ 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;
|
||||
@ -304,7 +309,9 @@ static std::map<std::string, std::string> 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"}
|
||||
};
|
||||
|
||||
@ -355,11 +362,14 @@ static void fuzz_skottie_json(sk_sp<SkData> bytes){
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SK_ENABLE_SVG)
|
||||
void FuzzSVG(sk_sp<SkData> bytes);
|
||||
|
||||
static void fuzz_svg_dom(sk_sp<SkData> 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
|
||||
|
@ -9,6 +9,9 @@
|
||||
#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<SkData> bytes) {
|
||||
uint8_t w = 100;
|
||||
@ -41,3 +44,5 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // SK_ENABLE_SVG
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
import("../../gn/skia.gni")
|
||||
|
||||
if (skia_enable_svg) {
|
||||
if (skia_enable_svg && skia_use_expat) {
|
||||
config("public_config") {
|
||||
defines = [ "SK_ENABLE_SVG" ]
|
||||
include_dirs = [ "include" ]
|
||||
|
@ -10,6 +10,7 @@
|
||||
#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) {
|
||||
|
@ -7,12 +7,13 @@
|
||||
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
#ifdef SK_XML
|
||||
#if defined(SK_ENABLE_SVG)
|
||||
|
||||
#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"
|
||||
@ -119,4 +120,4 @@ private:
|
||||
|
||||
DEF_SAMPLE( return new AnimatedSVGSample("Cowboy.svg", "SampleCowboy"); )
|
||||
|
||||
#endif // SK_XML
|
||||
#endif // defined(SK_ENABLE_SVG)
|
||||
|
@ -7,11 +7,12 @@
|
||||
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
#ifdef SK_XML
|
||||
#if defined(SK_ENABLE_SVG)
|
||||
|
||||
#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"
|
||||
@ -69,4 +70,4 @@ Sample* CreateSampleSVGFileView(const SkString& filename);
|
||||
Sample* CreateSampleSVGFileView(const SkString& filename) {
|
||||
return new SVGFileView(filename);
|
||||
}
|
||||
#endif // SK_XML
|
||||
#endif // defined(SK_ENABLE_SVG)
|
||||
|
@ -12,7 +12,6 @@
|
||||
#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"
|
||||
@ -38,6 +37,11 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#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"
|
||||
@ -186,6 +190,7 @@ static void init(Source* source, std::shared_ptr<SkCodec> codec) {
|
||||
};
|
||||
}
|
||||
|
||||
#if defined(SK_ENABLE_SVG)
|
||||
static void init(Source* source, sk_sp<SkSVGDOM> svg) {
|
||||
if (svg->containerSize().isEmpty()) {
|
||||
svg->setContainerSize({1000,1000});
|
||||
@ -196,6 +201,7 @@ static void init(Source* source, sk_sp<SkSVGDOM> svg) {
|
||||
return ok;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SK_ENABLE_SKOTTIE)
|
||||
static void init(Source* source, sk_sp<skottie::Animation> animation) {
|
||||
@ -454,13 +460,16 @@ int main(int argc, char** argv) {
|
||||
init(source, pic);
|
||||
continue;
|
||||
}
|
||||
} else if (name.endsWith(".svg")) {
|
||||
}
|
||||
#if defined(SK_ENABLE_SVG)
|
||||
else if (name.endsWith(".svg")) {
|
||||
SkMemoryStream stream{blob};
|
||||
if (sk_sp<SkSVGDOM> 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());
|
||||
|
@ -95,7 +95,7 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef SK_XML
|
||||
#if defined(SK_ENABLE_SVG)
|
||||
fFamilies.emplace_back(sk_make_sp<FontStyleSet>("Emoji"));
|
||||
fFamilies.back()->fTypefaces.emplace_back(
|
||||
TestSVGTypeface::Default(), SkFontStyle::Normal(), "Normal");
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "tools/fonts/TestSVGTypeface.h"
|
||||
|
||||
#ifdef SK_XML
|
||||
#if defined(SK_ENABLE_SVG)
|
||||
|
||||
#include "include/core/SkBitmap.h"
|
||||
#include "include/core/SkCanvas.h"
|
||||
@ -30,6 +30,7 @@
|
||||
#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"
|
||||
@ -1434,4 +1435,4 @@ void TestSVGTypeface::exportTtxColr(SkWStream* out) const {
|
||||
|
||||
out->writeText("</ttFont>\n");
|
||||
}
|
||||
#endif // SK_XML
|
||||
#endif // SK_ENABLE_SVG
|
||||
|
@ -40,6 +40,8 @@ struct SkAdvancedTypefaceMetrics;
|
||||
struct SkScalerContextEffects;
|
||||
struct SkScalerContextRec;
|
||||
|
||||
#ifdef SK_ENABLE_SVG
|
||||
|
||||
struct SkSVGTestTypefaceGlyphData {
|
||||
const char* fSvgResourcePath;
|
||||
SkPoint fOrigin; // y-down
|
||||
@ -157,4 +159,6 @@ private:
|
||||
friend class SkTestSVGScalerContext;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // SK_ENABLE_SVG
|
||||
|
||||
#endif // TestSVGTypeface_DEFINED
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include "tools/flags/CommandLineFlags.h"
|
||||
#include "tools/fonts/TestSVGTypeface.h"
|
||||
|
||||
#if defined(SK_ENABLE_SVG)
|
||||
|
||||
static void export_ttx(sk_sp<TestSVGTypeface> typeface,
|
||||
SkString prefix,
|
||||
SkSpan<unsigned> cbdtStrikeSizes,
|
||||
@ -49,3 +51,12 @@ 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
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "tools/gpu/GpuTimer.h"
|
||||
#include "tools/gpu/GrContextFactory.h"
|
||||
|
||||
#ifdef SK_XML
|
||||
#if defined(SK_ENABLE_SVG)
|
||||
#include "modules/svg/include/SkSVGDOM.h"
|
||||
#include "src/xml/SkDOM.h"
|
||||
#endif
|
||||
@ -699,7 +699,7 @@ static sk_sp<SkPicture> create_warmup_skp() {
|
||||
}
|
||||
|
||||
static sk_sp<SkPicture> create_skp_from_svg(SkStream* stream, const char* filename) {
|
||||
#ifdef SK_XML
|
||||
#if defined(SK_ENABLE_SVG)
|
||||
sk_sp<SkSVGDOM> 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<SkPicture> create_skp_from_svg(SkStream* stream, const char* filena
|
||||
|
||||
return recorder.finishRecordingAsPicture();
|
||||
#endif
|
||||
exitf(ExitErr::kData, "SK_XML is disabled; cannot open svg file %s", filename);
|
||||
exitf(ExitErr::kData, "SK_ENABLE_SVG is disabled; cannot open svg file %s", filename);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -13,8 +13,9 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
#ifdef SK_XML
|
||||
#if defined(SK_ENABLE_SVG)
|
||||
#include "modules/svg/include/SkSVGDOM.h"
|
||||
#include "modules/svg/include/SkSVGNode.h"
|
||||
#include "src/xml/SkDOM.h"
|
||||
#endif
|
||||
|
||||
@ -27,7 +28,7 @@ sk_sp<BisectSlide> BisectSlide::Create(const char filepath[]) {
|
||||
|
||||
sk_sp<BisectSlide> bisect(new BisectSlide(filepath));
|
||||
if (bisect->fFilePath.endsWith(".svg")) {
|
||||
#ifdef SK_XML
|
||||
#if defined(SK_ENABLE_SVG)
|
||||
sk_sp<SkSVGDOM> svg = SkSVGDOM::MakeFromStream(stream);
|
||||
if (!svg) {
|
||||
SkDebugf("BISECT: couldn't load svg at \"%s\"\n", filepath);
|
||||
|
@ -7,12 +7,13 @@
|
||||
|
||||
#include "tools/viewer/SvgSlide.h"
|
||||
|
||||
#if defined(SK_XML)
|
||||
#if defined(SK_ENABLE_SVG)
|
||||
|
||||
#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)
|
||||
@ -63,4 +64,4 @@ void SvgSlide::draw(SkCanvas* canvas) {
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SK_XML
|
||||
#endif // defined(SK_ENABLE_SVG)
|
||||
|
@ -764,7 +764,7 @@ void Viewer::initSlides() {
|
||||
return sk_make_sp<SkRiveSlide>(name, path);}
|
||||
},
|
||||
#endif
|
||||
#if defined(SK_XML)
|
||||
#if defined(SK_ENABLE_SVG)
|
||||
{ ".svg", "svg-dir", FLAGS_svgs,
|
||||
[](const SkString& name, const SkString& path) -> sk_sp<Slide> {
|
||||
return sk_make_sp<SvgSlide>(name, path);}
|
||||
|
Loading…
Reference in New Issue
Block a user