diff --git a/ios/browser/svg/BUILD.gn b/ios/browser/svg/BUILD.gn index 3d157f9ee247..3b3c861e85de 100644 --- a/ios/browser/svg/BUILD.gn +++ b/ios/browser/svg/BUILD.gn @@ -3,9 +3,23 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this file, # You can obtain one at http://mozilla.org/MPL/2.0/. +import("//brave/ios/browser/svg/svg.gni") +import("//third_party/skia/modules/skottie/skottie.gni") +import("//third_party/skia/modules/skresources/skresources.gni") +import("//third_party/skia/modules/sksg/sksg.gni") +import("//third_party/skia/modules/skshaper/skshaper.gni") import("//third_party/skia/modules/svg/svg.gni") source_set("svg") { + # //skia:skia does the same thing + # There is no other way to include the skia/module files + check_includes = false + + defines = [ + "SK_SHAPER_CORETEXT_AVAILABLE", + "SK_SHAPER_PRIMITIVE_AVAILABLE", + ] + cflags_cc = [ "-Wno-extra-semi", "-Wno-unreachable-code-aggressive", @@ -17,32 +31,6 @@ source_set("svg") { ] sources += [ - "//third_party/skia/src/codec/SkBmpBaseCodec.cpp", - "//third_party/skia/src/codec/SkBmpCodec.cpp", - "//third_party/skia/src/codec/SkBmpMaskCodec.cpp", - "//third_party/skia/src/codec/SkBmpRLECodec.cpp", - "//third_party/skia/src/codec/SkBmpStandardCodec.cpp", - "//third_party/skia/src/codec/SkCodec.cpp", - "//third_party/skia/src/codec/SkCodecImageGenerator.cpp", - "//third_party/skia/src/codec/SkCodecImageGenerator.h", - "//third_party/skia/src/codec/SkCodecPriv.h", - "//third_party/skia/src/codec/SkColorPalette.cpp", - "//third_party/skia/src/codec/SkColorPalette.h", - "//third_party/skia/src/codec/SkEncodedInfo.cpp", - "//third_party/skia/src/codec/SkFrameHolder.h", - "//third_party/skia/src/codec/SkIcoCodec.cpp", - "//third_party/skia/src/codec/SkMaskSwizzler.cpp", - "//third_party/skia/src/codec/SkMaskSwizzler.h", - "//third_party/skia/src/codec/SkParseEncodedOrigin.cpp", - "//third_party/skia/src/codec/SkPixmapUtils.cpp", - "//third_party/skia/src/codec/SkPixmapUtilsPriv.h", - "//third_party/skia/src/codec/SkPngCodec.cpp", - "//third_party/skia/src/codec/SkSampler.cpp", - "//third_party/skia/src/codec/SkSampler.h", - "//third_party/skia/src/codec/SkSwizzler.cpp", - "//third_party/skia/src/codec/SkSwizzler.h", - "//third_party/skia/src/codec/SkWbmpCodec.cpp", - "//third_party/skia/src/codec/SkWebpCodec.cpp", "//third_party/skia/src/ports/SkImageGenerator_skia.cpp", "//third_party/skia/src/utils/SkOSPath.h", "//third_party/skia/src/utils/SkParsePath.cpp", @@ -56,6 +44,16 @@ source_set("svg") { sources += skia_svg_public sources += skia_svg_sources + sources += skia_skottie_sources + sources += skia_skresources_sources + sources += skia_sksg_sources + sources += skia_shaper_primitive_sources + sources += skia_shaper_coretext_sources + + include_dirs = [ + "//third_party/skia", + "$root_gen_dir/third_party/skia", + ] deps = [ "//base", @@ -66,4 +64,9 @@ source_set("svg") { "//third_party/libwebp:libwebp_webp", "//ui/gfx", ] + + frameworks = [ + "CoreFoundation.framework", + "CoreText.framework", + ] } diff --git a/ios/browser/svg/DEPS b/ios/browser/svg/DEPS index 1ecb32ff2a0c..47288bc3c09d 100644 --- a/ios/browser/svg/DEPS +++ b/ios/browser/svg/DEPS @@ -1,11 +1,6 @@ include_rules = [ - "+skia/ext/skia_utils_ios.h", - "+third_party/skia/include/core/SkBitmap.h", - "+third_party/skia/include/core/SkCanvas.h", - "+third_party/skia/include/core/SkRefCnt.h", - "+third_party/skia/include/core/SkStream.h", - "+third_party/skia/modules/svg/include/SkSVGDOM.h", - "+third_party/skia/modules/svg/include/SkSVGRenderContext.h", - "+third_party/skia/modules/svg/include/SkSVGSVG.h", + "+skia/ext/font_utils.h", + "+third_party/skia/include/core/SkFontMgr.h", + "+third_party/skia/include/core/SkSurface.h", "+ui/gfx", ] diff --git a/ios/browser/svg/svg.gni b/ios/browser/svg/svg.gni new file mode 100644 index 000000000000..fedc1ab91e42 --- /dev/null +++ b/ios/browser/svg/svg.gni @@ -0,0 +1,8 @@ +# Copyright (c) 2024 The Brave Authors. All rights reserved. +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this file, +# You can obtain one at https://mozilla.org/MPL/2.0/. + +declare_args() { + skia_use_fonthost_mac = true +} diff --git a/ios/browser/svg/svg_image.mm b/ios/browser/svg/svg_image.mm index 303785d9caa2..da97e408dde3 100644 --- a/ios/browser/svg/svg_image.mm +++ b/ios/browser/svg/svg_image.mm @@ -5,8 +5,10 @@ #import "brave/ios/browser/svg/svg_image.h" +#include "skia/ext/font_utils.h" #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkCanvas.h" +#include "third_party/skia/include/core/SkFontMgr.h" #include "third_party/skia/include/core/SkRefCnt.h" #include "third_party/skia/include/core/SkStream.h" #include "third_party/skia/modules/svg/include/SkSVGDOM.h" @@ -14,6 +16,8 @@ #include "third_party/skia/modules/svg/include/SkSVGSVG.h" #include "ui/gfx/image/image.h" +#include "third_party/skia/include/core/SkSurface.h" + #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." #endif @@ -68,7 +72,8 @@ SkBitmap MakeFromData(const NSData* data, return SkBitmap(); } - sk_sp document = SkSVGDOM::MakeFromStream(*stream); + sk_sp document = + SkSVGDOM::Builder().setFontManager(skia::DefaultFontMgr()).make(*stream); if (!document || !document->getRoot()) { return SkBitmap(); }