From 83eed35765756d9f475f1428af72f159ade7eefb Mon Sep 17 00:00:00 2001 From: Ben Wagner Date: Fri, 5 Mar 2021 11:26:35 -0500 Subject: [PATCH] SkShaper_coretext correct dependencies. Adds proper framework dependencies and moves from using ArenaAlloc to header only SkAutoSTArray so it can be built in a shared build. Change-Id: I6467153915e00a28d5569869187aecc3dd1f0112 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/380318 Reviewed-by: Julia Lavrova Commit-Queue: Ben Wagner --- modules/skshaper/BUILD.gn | 10 ++++++++++ modules/skshaper/src/SkShaper_coretext.cpp | 18 ++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/modules/skshaper/BUILD.gn b/modules/skshaper/BUILD.gn index 2063f20a51..431f7af9f7 100644 --- a/modules/skshaper/BUILD.gn +++ b/modules/skshaper/BUILD.gn @@ -37,6 +37,16 @@ if (skia_enable_skshaper) { sources = skia_shaper_primitive_sources if (skia_use_fonthost_mac) { sources += skia_shaper_coretext_sources + if (is_mac) { + frameworks = [ "ApplicationServices.framework" ] + } + + if (is_ios) { + frameworks = [ + "CoreFoundation.framework", + "CoreText.framework", + ] + } } if (skia_use_icu && skia_use_harfbuzz) { sources += skia_shaper_icu_sources diff --git a/modules/skshaper/src/SkShaper_coretext.cpp b/modules/skshaper/src/SkShaper_coretext.cpp index a77036db6c..b8a8cf1e56 100644 --- a/modules/skshaper/src/SkShaper_coretext.cpp +++ b/modules/skshaper/src/SkShaper_coretext.cpp @@ -19,7 +19,7 @@ #endif #include "include/ports/SkTypeface_mac.h" -#include "src/core/SkArenaAlloc.h" +#include "include/private/SkTemplates.h" #include "src/utils/SkUTF.h" #include "src/utils/mac/SkCGBase.h" #include "src/utils/mac/SkUniqueCFRef.h" @@ -251,9 +251,8 @@ void SkShaper_CoreText::shape(const char* utf8, size_t utf8Bytes, SkASSERT(sizeof(CGGlyph) == sizeof(uint16_t)); - SkSTArenaAlloc<4096> arena; - CGSize* advances = arena.makeArrayDefault(runGlyphs); - CTRunGetAdvances(run, {0, runGlyphs}, advances); + SkAutoSTArray<4096, CGSize> advances(runGlyphs); + CTRunGetAdvances(run, {0, runGlyphs}, advances.data()); SkScalar adv = 0; for (CFIndex k = 0; k < runGlyphs; ++k) { adv += advances[k].width; @@ -286,13 +285,12 @@ void SkShaper_CoreText::shape(const char* utf8, size_t utf8Bytes, CTRunGetGlyphs(run, {0, runGlyphs}, buffer.glyphs); - SkSTArenaAlloc<4096> arena; - CGPoint* positions = arena.makeArrayDefault(runGlyphs); - CTRunGetPositions(run, {0, runGlyphs}, positions); - CFIndex* indices = nullptr; + SkAutoSTArray<4096, CGPoint> positions(runGlyphs); + CTRunGetPositions(run, {0, runGlyphs}, positions.data()); + SkAutoSTArray<4096, CFIndex> indices; if (buffer.clusters) { - indices = arena.makeArrayDefault(runGlyphs); - CTRunGetStringIndices(run, {0, runGlyphs}, indices); + indices.reset(runGlyphs); + CTRunGetStringIndices(run, {0, runGlyphs}, indices.data()); } for (CFIndex k = 0; k < runGlyphs; ++k) {