Make SkShaper more modular

Skottie depends on SkShaper::Make() and SkUnicode::Make(), which
rely on compile-time defines that do not play well with the modular
build. While we could get around this by making "skottie_harfbuzz_icu"
and "skottie_coretext" targets, this is a bit awkward in more complex
builds, and for clients that don't directly need to do text shaping
(or are fine with the smaller, primitive shaper).

While this CL does not remove the compile-time configuration of
Skottie, it does lay the groundwork for that by adding some
new headers and APIs for SkShaper to make a specific backend.
I put these in a namespace SkShapers and then added some nested
namespaces (HB, CT) since that made the names read nicer IMO.
While we could probably have a "core" SkShaper and break primitive
stuff out into its own header, I think for simplicity it is fine
to have primitive be a part of "core".

The following SkShaper functions have been moved or deprecated:
  - SkShaper::MakePrimitive() -> SkShapers::Primitive()
  - SkShaper::MakeShaperDrivenWrapper() -> SkShapers::HB::ShaperDrivenWrapper()
  - SkShaper::MakeShapeThenWrap() -> SkShapers::HB::ShapeThenWrap()
  - SkShaper::MakeShapeDontWrapOrReorder() -> SkShapers::HB::ShapeDontWrapOrReorder()
  - SkShaper::MakeCoreText() -> SkShapers::CT::CoreText()
  - SkShaper::Make() -> deleted, use one of the above directly,
  - SkShaper::MakeSkUnicodeBidiRunIterator() -> SkShapers::unicode::BidiRunIterator()
  - SkShaper::MakeBiDiRunIterator() -> deleted, use SkShapers::unicode::BidiRunIterator() or SkShapers::TrivialBiDiRunIterator()
  - SkShaper::MakeIcuBiDiRunIterator() -> deleted, use SkShapers::unicode::BidiRunIterator()
  - SkShaper::MakeSkUnicodeHbScriptRunIterator() -> SkShapers::HB::ScriptRunIterator()
  - SkShaper::MakeHbIcuScriptRunIterator() -> SkShapers::HB::ScriptRunIterator()
  - SkShaper::MakeScriptRunIterator() -> deleted, use SkShapers::HB::ScriptRunIterator() or SkShapers::TrivialScriptRunIterator

This also updates our internal callsites to use the new APIs
(the old ones can be disabled by a flag), some of which also need
#ifdefs (not quite sure if modules/svg should always be using
HarfBuzz or if it also needs to have a registration something).

A follow-up CL will try to remove the #ifdefs from skottie/TextShaper
by adding a codec-like registration or something similar. Another
follow-up CL will decouple SkUnicode in a similar way.

Change-Id: I791b8382817e3b7c2c7fb54c6e4a9b432c9d4f9d
Bug: b/40045064
Reviewed-by: Florin Malita <>
Commit-Queue: Kevin Lubick <>
29 files changed