From fe714c62f9e883f645b88043a4bdd1c22f4728f7 Mon Sep 17 00:00:00 2001 From: changleipeng Date: Wed, 23 Aug 2023 09:14:14 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20c8ea832=20from=20https://gitee.com/chan?= =?UTF-8?q?gleipeng/graphic=5Fgraphic=5F2d=5Fsunsun1/pulls/5886=20graphic?= =?UTF-8?q?=5F2d=E6=A8=A1=E5=9D=97MAC/Windows=E4=B8=8Btextgine=E3=80=81txt?= =?UTF-8?q?=E3=80=81flutter=E4=B8=89=E4=B8=AA=E7=89=88=E6=9C=AC=E9=80=82?= =?UTF-8?q?=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: changleipeng --- rosen/build/flutter/harfbuzz/BUILD.gn | 3 + rosen/build/flutter/icu/BUILD.gn | 79 ++++++++++--------- rosen/modules/2d_engine/rosen_text/BUILD.gn | 13 ++- rosen/modules/2d_graphics/BUILD.gn | 3 +- rosen/modules/texgine/BUILD.gn | 56 ++++++------- rosen/modules/texgine/src/bidi_processer.cpp | 8 -- .../src/dynamic_file_font_provider.cpp | 9 --- rosen/modules/texgine/src/font_config.cpp | 8 +- rosen/modules/texgine/src/font_parser.cpp | 9 --- rosen/modules/texgine/src/init.cpp | 12 --- rosen/modules/texgine/src/line_breaker.cpp | 4 - rosen/modules/texgine/src/measurer_impl.cpp | 20 ----- rosen/modules/texgine/src/mock.cpp | 12 --- rosen/modules/texgine/src/mock.h | 4 - rosen/modules/texgine/src/shaper.cpp | 8 -- rosen/modules/texgine/src/text_breaker.cpp | 8 -- rosen/modules/texgine/src/text_merger.cpp | 8 -- rosen/modules/texgine/src/text_reverser.cpp | 12 --- rosen/modules/texgine/src/text_shaper.cpp | 8 -- rosen/modules/texgine/src/text_span.cpp | 2 - rosen/modules/texgine/src/typeface.cpp | 6 -- rosen/modules/texgine/src/typography_impl.cpp | 4 - rosen/modules/texgine/src/utils/logger.cpp | 30 ++++--- .../modules/texgine/src/utils/trace_ohos.cpp | 31 -------- .../modules/texgine/texgine_drawing/BUILD.gn | 15 ++-- 25 files changed, 97 insertions(+), 275 deletions(-) diff --git a/rosen/build/flutter/harfbuzz/BUILD.gn b/rosen/build/flutter/harfbuzz/BUILD.gn index 48d3edf74d..ab7e1fd363 100644 --- a/rosen/build/flutter/harfbuzz/BUILD.gn +++ b/rosen/build/flutter/harfbuzz/BUILD.gn @@ -137,6 +137,9 @@ template("rosen_libharfbuzz") { } deps = [ "//foundation/graphic/graphic_2d/rosen/build/flutter/icu:rosen_libicu_$platform" ] + + part_name = "graphic_2d" + subsystem_name = "graphic" } } diff --git a/rosen/build/flutter/icu/BUILD.gn b/rosen/build/flutter/icu/BUILD.gn index d815529d2e..db393c7a34 100644 --- a/rosen/build/flutter/icu/BUILD.gn +++ b/rosen/build/flutter/icu/BUILD.gn @@ -118,8 +118,6 @@ template("rosen_libicu") { ohos_source_set(target_name) { if (enable_text_gine) { - part_name = "graphic_2d" - subsystem_name = "graphic" defines += [ "USE_GRAPHIC_TEXT_GINE" ] } public_configs = [ ":icu_config_$platform" ] @@ -567,7 +565,43 @@ template("rosen_libicu") { ] if (enable_text_gine) { defines += [ "USE_GRAPHIC_TEXT_GINE" ] - sources += [ + } + sources += [ + "$skia_root/third_party/externals/icu/source/common/localebuilder.cpp", + "$skia_root/third_party/externals/icu/source/common/localematcher.cpp", + "$skia_root/third_party/externals/icu/source/common/localeprioritylist.cpp", + "$skia_root/third_party/externals/icu/source/common/locdistance.cpp", + "$skia_root/third_party/externals/icu/source/common/loclikelysubtags.cpp", + "$skia_root/third_party/externals/icu/source/common/lsr.cpp", + "$skia_root/third_party/externals/icu/source/common/restrace.cpp", + "$skia_root/third_party/externals/icu/source/i18n/double-conversion-double-to-string.cpp", + "$skia_root/third_party/externals/icu/source/i18n/double-conversion-string-to-double.cpp", + "$skia_root/third_party/externals/icu/source/i18n/formatted_string_builder.cpp", + "$skia_root/third_party/externals/icu/source/i18n/formattedval_iterimpl.cpp", + "$skia_root/third_party/externals/icu/source/i18n/formattedval_sbimpl.cpp", + "$skia_root/third_party/externals/icu/source/i18n/formattedvalue.cpp", + "$skia_root/third_party/externals/icu/source/i18n/measunit_extra.cpp", + "$skia_root/third_party/externals/icu/source/i18n/number_output.cpp", + "$skia_root/third_party/externals/icu/source/i18n/number_symbolswrapper.cpp", + "$skia_root/third_party/externals/icu/source/i18n/number_usageprefs.cpp", + "$skia_root/third_party/externals/icu/source/i18n/numrange_capi.cpp", + "$skia_root/third_party/externals/icu/source/i18n/pluralranges.cpp", + "$skia_root/third_party/externals/icu/source/i18n/string_segment.cpp", + "$skia_root/third_party/externals/icu/source/i18n/units_complexconverter.cpp", + "$skia_root/third_party/externals/icu/source/i18n/units_converter.cpp", + "$skia_root/third_party/externals/icu/source/i18n/units_data.cpp", + "$skia_root/third_party/externals/icu/source/i18n/units_router.cpp", + ] + if (defined(use_new_skia) && use_new_skia) { + sources -= [ + "$skia_root/third_party/externals/icu/source/i18n/double-conversion-diy-fp.cpp", + "$skia_root/third_party/externals/icu/source/i18n/double-conversion.cpp", + "$skia_root/third_party/externals/icu/source/i18n/nounit.cpp", + "$skia_root/third_party/externals/icu/source/i18n/number_stringbuilder.cpp", + "$skia_root/third_party/externals/icu/source/i18n/numparse_stringsegment.cpp", + ] + } else { + sources -= [ "$skia_root/third_party/externals/icu/source/common/localebuilder.cpp", "$skia_root/third_party/externals/icu/source/common/localematcher.cpp", "$skia_root/third_party/externals/icu/source/common/localeprioritylist.cpp", @@ -593,47 +627,14 @@ template("rosen_libicu") { "$skia_root/third_party/externals/icu/source/i18n/units_data.cpp", "$skia_root/third_party/externals/icu/source/i18n/units_router.cpp", ] - if (defined(use_new_skia) && use_new_skia) { - sources -= [ - "$skia_root/third_party/externals/icu/source/i18n/double-conversion-diy-fp.cpp", - "$skia_root/third_party/externals/icu/source/i18n/double-conversion.cpp", - "$skia_root/third_party/externals/icu/source/i18n/nounit.cpp", - "$skia_root/third_party/externals/icu/source/i18n/number_stringbuilder.cpp", - "$skia_root/third_party/externals/icu/source/i18n/numparse_stringsegment.cpp", - ] - } else { - sources -= [ - "$skia_root/third_party/externals/icu/source/common/localebuilder.cpp", - "$skia_root/third_party/externals/icu/source/common/localematcher.cpp", - "$skia_root/third_party/externals/icu/source/common/localeprioritylist.cpp", - "$skia_root/third_party/externals/icu/source/common/locdistance.cpp", - "$skia_root/third_party/externals/icu/source/common/loclikelysubtags.cpp", - "$skia_root/third_party/externals/icu/source/common/lsr.cpp", - "$skia_root/third_party/externals/icu/source/common/restrace.cpp", - "$skia_root/third_party/externals/icu/source/i18n/double-conversion-double-to-string.cpp", - "$skia_root/third_party/externals/icu/source/i18n/double-conversion-string-to-double.cpp", - "$skia_root/third_party/externals/icu/source/i18n/formatted_string_builder.cpp", - "$skia_root/third_party/externals/icu/source/i18n/formattedval_iterimpl.cpp", - "$skia_root/third_party/externals/icu/source/i18n/formattedval_sbimpl.cpp", - "$skia_root/third_party/externals/icu/source/i18n/formattedvalue.cpp", - "$skia_root/third_party/externals/icu/source/i18n/measunit_extra.cpp", - "$skia_root/third_party/externals/icu/source/i18n/number_output.cpp", - "$skia_root/third_party/externals/icu/source/i18n/number_symbolswrapper.cpp", - "$skia_root/third_party/externals/icu/source/i18n/number_usageprefs.cpp", - "$skia_root/third_party/externals/icu/source/i18n/numrange_capi.cpp", - "$skia_root/third_party/externals/icu/source/i18n/pluralranges.cpp", - "$skia_root/third_party/externals/icu/source/i18n/string_segment.cpp", - "$skia_root/third_party/externals/icu/source/i18n/units_complexconverter.cpp", - "$skia_root/third_party/externals/icu/source/i18n/units_converter.cpp", - "$skia_root/third_party/externals/icu/source/i18n/units_data.cpp", - "$skia_root/third_party/externals/icu/source/i18n/units_router.cpp", - ] - } } deps = [ "$ace_flutter_engine_root/icu:ace_icu_make_data_assembly_$platform", ] + + part_name = "graphic_2d" + subsystem_name = "graphic" } } } diff --git a/rosen/modules/2d_engine/rosen_text/BUILD.gn b/rosen/modules/2d_engine/rosen_text/BUILD.gn index 6845157cfe..9e9775889b 100755 --- a/rosen/modules/2d_engine/rosen_text/BUILD.gn +++ b/rosen/modules/2d_engine/rosen_text/BUILD.gn @@ -59,8 +59,7 @@ if (enable_text_gine) { public_configs = [ ":rosen_text_public_config" ] defines += [ "USE_GRAPHIC_TEXT_GINE" ] - cflags_cc = [ "-Wno-c++17-extensions" ] - cflags = [ "-Wno-c++17-extensions" ] + cflags = [ "-std=c++17" ] include_dirs = [ "$rosen_root/modules/render_service_base/include" ] @@ -89,14 +88,12 @@ if (enable_text_gine) { "$rosen_root/modules/render_service_base/include", ] - defines += [ "USE_GRAPHIC_TEXT_GINE" ] - cflags_cc = [ - "-Wno-c++17-extensions", - "-std=c++17", + defines += [ + "USE_GRAPHIC_TEXT_GINE", + "WINDOWS_PLATFORM", ] - defines += [ "WINDOWS_PLATFORM" ] + cflags = [ "-std=c++17" ] - cflags = [ "-Wno-c++17-extensions" ] if (defined(use_new_skia) && use_new_skia) { include_dirs += [ "$flutter_root/txt/src" ] } else { diff --git a/rosen/modules/2d_graphics/BUILD.gn b/rosen/modules/2d_graphics/BUILD.gn index 3598dbe902..ff5538282b 100755 --- a/rosen/modules/2d_graphics/BUILD.gn +++ b/rosen/modules/2d_graphics/BUILD.gn @@ -213,8 +213,7 @@ template("graphics2d_source_set") { include_dirs += [ "$flutter_root/engine/flutter/third_party/txt/src" ] } } else { - cflags = [ "-Wno-c++17-extensions" ] - + cflags = [ "-std=c++17" ] deps = [ "$ace_flutter_engine_root/libtxt:thirdparty_lib_txt_$platform" ] if (!is_cross_platform_build) { diff --git a/rosen/modules/texgine/BUILD.gn b/rosen/modules/texgine/BUILD.gn index a4a3db6e06..e196b5a5c3 100644 --- a/rosen/modules/texgine/BUILD.gn +++ b/rosen/modules/texgine/BUILD.gn @@ -24,17 +24,9 @@ config("libtexgine_config") { "-Wall", "-Werror", "-g3", + "-std=c++17", ] - if (enable_text_gine) { - defines = [ "USE_GRAPHIC_TEXT_GINE" ] - } else { - defines = [ - "LOGGER_ENABLE_SCOPE", - "TEXGINE_ENABLE_DEBUGLOG", - ] - } - include_dirs = [ "src", "export", @@ -112,44 +104,42 @@ ohos_shared_library("libtexgine") { public_deps = [ "texgine_drawing:libtexgine_drawing", - "//third_party/bounds_checking_function:libsec_static", "//third_party/jsoncpp:jsoncpp", ] + defines = [] if (enable_text_gine) { - cflags_cc = [ "-Wno-c++17-extensions" ] - cflags = [ "-Wno-c++17-extensions" ] - if (platform == "ohos") { - defines = [ - "BUILD_NON_SDK_VER", - "LOGGER_ENABLE_SCOPE", - "TEXGINE_ENABLE_DEBUGLOG", - ] + defines += [ "USE_GRAPHIC_TEXT_GINE" ] + } - external_deps = [ - "c_utils:utils", - "hilog:libhilog", - "hitrace:hitrace_meter", - ] - - public_deps += - [ "//third_party/flutter/build/icu:ace_libicu_$platform" ] - } else { - sources -= [ "src/utils/trace_ohos.cpp" ] - public_deps += [ "//third_party/skia/third_party/icu" ] - } - } else { - public_deps += - [ "$graphic_2d_root/rosen/build/flutter/icu:rosen_libicu_$platform" ] + if (platform == "ohos") { + defines += [ + "BUILD_NON_SDK_VER", + "LOGGER_ENABLE_SCOPE", + "TEXGINE_ENABLE_DEBUGLOG", + ] external_deps = [ "c_utils:utils", "hilog:libhilog", "hitrace:hitrace_meter", ] + + public_deps += [ "//third_party/flutter/build/icu:ace_libicu_$platform" ] + } else { + sources -= [ "src/utils/trace_ohos.cpp" ] + if (platform == "mac") { + defines += [ "BUILD_SDK_MAC" ] + public_deps += [ "$graphic_2d_root/rosen/build/flutter/harfbuzz:rosen_libharfbuzz_$platform" ] + } else { + public_deps += [ + "$graphic_2d_root/rosen/build/flutter/icu:rosen_libicu_$platform", + ] + } } } + innerapi_tags = [ "platformsdk" ] part_name = "graphic_2d" subsystem_name = "graphic" } diff --git a/rosen/modules/texgine/src/bidi_processer.cpp b/rosen/modules/texgine/src/bidi_processer.cpp index b1232e35cd..80b0213aa2 100644 --- a/rosen/modules/texgine/src/bidi_processer.cpp +++ b/rosen/modules/texgine/src/bidi_processer.cpp @@ -18,25 +18,17 @@ #include "texgine_exception.h" #include "texgine/utils/exlog.h" -#ifndef USE_GRAPHIC_TEXT_GINE -#include "texgine/utils/trace.h" -#else #ifdef LOGGER_ENABLE_SCOPE #include "texgine/utils/trace.h" #endif -#endif namespace OHOS { namespace Rosen { namespace TextEngine { std::vector BidiProcesser::ProcessBidiText(const std::vector &spans, const TextDirection dir) { -#ifndef USE_GRAPHIC_TEXT_GINE - ScopedTrace scope("BidiProcesser::ProcessBidiText"); -#else #ifdef LOGGER_ENABLE_SCOPE ScopedTrace scope("BidiProcesser::ProcessBidiText"); -#endif #endif LOGSCOPED(sl, LOGEX_FUNC_LINE_DEBUG(), "ProcessBidiText"); std::vector newSpans; diff --git a/rosen/modules/texgine/src/dynamic_file_font_provider.cpp b/rosen/modules/texgine/src/dynamic_file_font_provider.cpp index 60bd3d1346..3c1d6e80f3 100644 --- a/rosen/modules/texgine/src/dynamic_file_font_provider.cpp +++ b/rosen/modules/texgine/src/dynamic_file_font_provider.cpp @@ -32,14 +32,6 @@ std::shared_ptr DynamicFileFontProvider::Create() noexc int DynamicFileFontProvider::LoadFont(const std::string &familyName, const std::string &path) noexcept(true) { LOGEX_FUNC_LINE(DEBUG) << "loading font: '" << path << "'"; -#ifndef USE_GRAPHIC_TEXT_GINE - std::error_code ec; - auto ret = StdFilesystemExists(path, ec); - if (ec) { - LOGEX_FUNC_LINE(ERROR) << "open file failed: " << ec.message(); - return FAILED; - } -#else #ifdef BUILD_NON_SDK_VER std::error_code ec; auto ret = StdFilesystemExists(path, ec); @@ -49,7 +41,6 @@ int DynamicFileFontProvider::LoadFont(const std::string &familyName, const std:: } #else auto ret = StdFilesystemExists(path); -#endif #endif if (!ret) { diff --git a/rosen/modules/texgine/src/font_config.cpp b/rosen/modules/texgine/src/font_config.cpp index 3348fae32d..5c8f057941 100644 --- a/rosen/modules/texgine/src/font_config.cpp +++ b/rosen/modules/texgine/src/font_config.cpp @@ -22,7 +22,9 @@ #include #include +#ifdef BUILD_NON_SDK_VER #include "securec.h" +#endif #include "texgine/utils/exlog.h" namespace OHOS { @@ -43,11 +45,13 @@ FontConfig::FontConfig(const char* fname) char* FontConfig::GetFileData(const char* fname, int& size) { +#ifdef BUILD_NON_SDK_VER char realPath[PATH_MAX] = {0}; if (fname == nullptr || realpath(fname, realPath) == NULL) { LOGSO_FUNC_LINE(ERROR) << "path or realPath is NULL"; return nullptr; } +#endif std::ifstream file(fname); if (file.good()) { FILE* fp = fopen(fname, "r"); @@ -62,9 +66,7 @@ char* FontConfig::GetFileData(const char* fname, int& size) fclose(fp); return nullptr; } -#ifdef USE_GRAPHIC_TEXT_GINE #ifdef BUILD_NON_SDK_VER -#endif if (memset_s(data, size, 0, size) != EOK) { LOGSO_FUNC_LINE(ERROR) << "memset failed"; free(data); @@ -72,10 +74,8 @@ char* FontConfig::GetFileData(const char* fname, int& size) fclose(fp); return nullptr; } -#ifdef USE_GRAPHIC_TEXT_GINE #else memset(data, 0, size); -#endif #endif (void)fread(data, size, 1, fp); fclose(fp); diff --git a/rosen/modules/texgine/src/font_parser.cpp b/rosen/modules/texgine/src/font_parser.cpp index 9df0c3e9c9..b4b914daa2 100644 --- a/rosen/modules/texgine/src/font_parser.cpp +++ b/rosen/modules/texgine/src/font_parser.cpp @@ -116,14 +116,6 @@ int FontParser::ProcessNameTable(const struct NameTable* nameTable, FontParser:: if (buffer == nullptr) { return FAILED; } -#ifndef USE_GRAPHIC_TEXT_GINE - if (memcpy_s(buffer, len, data, len) != EOK) { - LOGSO_FUNC_LINE(ERROR) << "memcpy failed"; - delete[] buffer; - return FAILED; - } - const char16_t* strPtr = reinterpret_cast(buffer); -#else #ifdef BUILD_NON_SDK_VER if (memcpy_s(buffer, len, data, len) != EOK) { LOGSO_FUNC_LINE(ERROR) << "memcpy failed"; @@ -134,7 +126,6 @@ int FontParser::ProcessNameTable(const struct NameTable* nameTable, FontParser:: memcpy(buffer, data, len); #endif const char16_t *strPtr = reinterpret_cast(buffer); -#endif const std::u16string u16str(strPtr, strPtr + HALF(len)); std::wstring_convert, char16_t> converter; const std::string name = converter.to_bytes(u16str); diff --git a/rosen/modules/texgine/src/init.cpp b/rosen/modules/texgine/src/init.cpp index 08d24f202a..d505bf022e 100644 --- a/rosen/modules/texgine/src/init.cpp +++ b/rosen/modules/texgine/src/init.cpp @@ -15,27 +15,15 @@ #include -#ifndef USE_GRAPHIC_TEXT_GINE -#include "texgine/utils/trace.h" -#else #ifdef LOGGER_ENABLE_SCOPE #include "texgine/utils/trace.h" #endif -#endif static __attribute__((constructor)) void Init() { u_setDataDirectory("/system/usr/ohos_icu"); -#ifndef USE_GRAPHIC_TEXT_GINE -#ifndef TEXGINE_ENABLE_TRACE - OHOS::Rosen::TextEngine::Trace::Disable(); -#endif -#else #ifdef LOGGER_ENABLE_SCOPE -#ifndef TEXGINE_ENABLE_TRACE OHOS::Rosen::TextEngine::Trace::Disable(); #endif -#endif -#endif } diff --git a/rosen/modules/texgine/src/line_breaker.cpp b/rosen/modules/texgine/src/line_breaker.cpp index 858a66d83c..a6ada3398f 100644 --- a/rosen/modules/texgine/src/line_breaker.cpp +++ b/rosen/modules/texgine/src/line_breaker.cpp @@ -20,13 +20,9 @@ #include "texgine/any_span.h" #include "texgine_exception.h" #include "texgine/utils/exlog.h" -#ifndef USE_GRAPHIC_TEXT_GINE -#include "texgine/utils/trace.h" -#else #ifdef LOGGER_ENABLE_SCOPE #include "texgine/utils/trace.h" #endif -#endif #include "text_merger.h" #include "text_span.h" diff --git a/rosen/modules/texgine/src/measurer_impl.cpp b/rosen/modules/texgine/src/measurer_impl.cpp index a36ba68355..10557c8c32 100644 --- a/rosen/modules/texgine/src/measurer_impl.cpp +++ b/rosen/modules/texgine/src/measurer_impl.cpp @@ -17,13 +17,9 @@ #include "texgine_exception.h" #include "texgine/utils/exlog.h" -#ifndef USE_GRAPHIC_TEXT_GINE -#include "texgine/utils/trace.h" -#else #ifdef LOGGER_ENABLE_SCOPE #include "texgine/utils/trace.h" #endif -#endif #include "text_converter.h" namespace OHOS { @@ -120,12 +116,8 @@ const std::vector &MeasurerImpl::GetWordBoundary() const int MeasurerImpl::Measure(CharGroups &cgs) { -#ifndef USE_GRAPHIC_TEXT_GINE - ScopedTrace scope("MeasurerImpl::Measure"); -#else #ifdef LOGGER_ENABLE_SCOPE ScopedTrace scope("MeasurerImpl::Measure"); -#endif #endif LOGSCOPED(sl, LOGEX_FUNC_LINE_DEBUG(), "MeasurerImpl::Measure"); struct MeasurerCacheKey key = { @@ -172,12 +164,8 @@ int MeasurerImpl::Measure(CharGroups &cgs) void MeasurerImpl::SeekTypeface(std::list &runs) { -#ifndef USE_GRAPHIC_TEXT_GINE - ScopedTrace scope("MeasurerImpl::SeekTypeface"); -#else #ifdef LOGGER_ENABLE_SCOPE ScopedTrace scope("MeasurerImpl::SeekTypeface"); -#endif #endif LOGSCOPED(sl, LOGEX_FUNC_LINE_DEBUG(), "typeface"); int index = 0; @@ -226,12 +214,8 @@ void MeasurerImpl::SeekTypeface(std::list &runs) void MeasurerImpl::SeekScript(std::list &runs) { -#ifndef USE_GRAPHIC_TEXT_GINE - ScopedTrace scope("MeasurerImpl::SeekScript"); -#else #ifdef LOGGER_ENABLE_SCOPE ScopedTrace scope("MeasurerImpl::SeekScript"); -#endif #endif LOGSCOPED(sl, LOGEX_FUNC_LINE_DEBUG(), "script"); auto icuGetUnicodeFuncs = hb_unicode_funcs_create(hb_icu_get_unicode_funcs()); @@ -297,12 +281,8 @@ void MeasurerImpl::DoSeekScript(std::list &runs, hb_unicode int MeasurerImpl::Shape(CharGroups &cgs, std::list &runs, std::vector boundaries) { -#ifndef USE_GRAPHIC_TEXT_GINE - ScopedTrace scope("MeasurerImpl::Shape"); -#else #ifdef LOGGER_ENABLE_SCOPE ScopedTrace scope("MeasurerImpl::Shape"); -#endif #endif cgs = CharGroups::CreateEmpty(); LOGSCOPED(sl, LOGEX_FUNC_LINE_DEBUG(), "shape"); diff --git a/rosen/modules/texgine/src/mock.cpp b/rosen/modules/texgine/src/mock.cpp index 9b5d0ae699..a6dec39ab8 100644 --- a/rosen/modules/texgine/src/mock.cpp +++ b/rosen/modules/texgine/src/mock.cpp @@ -15,13 +15,9 @@ #include "mock.h" -#ifndef USE_GRAPHIC_TEXT_GINE -#include -#else #ifdef BUILD_NON_SDK_VER #include #endif -#endif namespace OHOS { namespace Rosen { @@ -59,12 +55,6 @@ void MockIFStream::StdFilestystemClose() std::ifstream::close(); } -#ifndef USE_GRAPHIC_TEXT_GINE -bool StdFilesystemExists(const std::string &p, std::error_code &ec) -{ - return std::filesystem::exists(p, ec); -} -#else #ifdef BUILD_NON_SDK_VER bool StdFilesystemExists(const std::string &p, std::error_code &ec) { @@ -77,8 +67,6 @@ bool StdFilesystemExists(const std::string &p) return f.good(); } #endif -#endif - } // namespace TextEngine } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/texgine/src/mock.h b/rosen/modules/texgine/src/mock.h index 16a35b2f1f..59f37db791 100644 --- a/rosen/modules/texgine/src/mock.h +++ b/rosen/modules/texgine/src/mock.h @@ -40,15 +40,11 @@ public: void StdFilestystemClose(); }; -#ifndef USE_GRAPHIC_TEXT_GINE -bool StdFilesystemExists(const std::string &p, std::error_code &ec); -#else #ifdef BUILD_NON_SDK_VER bool StdFilesystemExists(const std::string &p, std::error_code &ec); #else bool StdFilesystemExists(const std::string &p); #endif -#endif } // namespace TextEngine } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/texgine/src/shaper.cpp b/rosen/modules/texgine/src/shaper.cpp index 7dee73037f..0babc5fa07 100644 --- a/rosen/modules/texgine/src/shaper.cpp +++ b/rosen/modules/texgine/src/shaper.cpp @@ -24,13 +24,9 @@ #include "texgine/any_span.h" #include "texgine_exception.h" #include "texgine/utils/exlog.h" -#ifndef USE_GRAPHIC_TEXT_GINE -#include "texgine/utils/trace.h" -#else #ifdef LOGGER_ENABLE_SCOPE #include "texgine/utils/trace.h" #endif -#endif #include "text_breaker.h" #include "text_merger.h" #include "text_reverser.h" @@ -54,12 +50,8 @@ void DumpLineMetrics(const std::vector &lineMetrics) std::vector Shaper::DoShape(std::vector spans, const TypographyStyle &tstyle, const std::shared_ptr &fontProviders, const double widthLimit) { -#ifndef USE_GRAPHIC_TEXT_GINE - ScopedTrace scope("Shaper::DoShape"); -#else #ifdef LOGGER_ENABLE_SCOPE ScopedTrace scope("Shaper::DoShape"); -#endif #endif TextBreaker tb; auto ret = tb.WordBreak(spans, tstyle, fontProviders); diff --git a/rosen/modules/texgine/src/text_breaker.cpp b/rosen/modules/texgine/src/text_breaker.cpp index e6e9208ab8..673b2b297a 100644 --- a/rosen/modules/texgine/src/text_breaker.cpp +++ b/rosen/modules/texgine/src/text_breaker.cpp @@ -22,13 +22,9 @@ #include "texgine_exception.h" #include "text_span.h" #include "texgine/utils/exlog.h" -#ifndef USE_GRAPHIC_TEXT_GINE -#include "texgine/utils/trace.h" -#else #ifdef LOGGER_ENABLE_SCOPE #include "texgine/utils/trace.h" #endif -#endif #include "text_converter.h" #include "word_breaker.h" @@ -38,12 +34,8 @@ namespace TextEngine { int TextBreaker::WordBreak(std::vector &spans, const TypographyStyle &ys, const std::shared_ptr &fontProviders) { -#ifndef USE_GRAPHIC_TEXT_GINE - ScopedTrace scope("TextBreaker::WordBreak"); -#else #ifdef LOGGER_ENABLE_SCOPE ScopedTrace scope("TextBreaker::WordBreak"); -#endif #endif LOGSCOPED(sl, LOGEX_FUNC_LINE_DEBUG(), "WordBreak"); std::vector visitingSpans; diff --git a/rosen/modules/texgine/src/text_merger.cpp b/rosen/modules/texgine/src/text_merger.cpp index c00dcb0aae..41b30580a6 100644 --- a/rosen/modules/texgine/src/text_merger.cpp +++ b/rosen/modules/texgine/src/text_merger.cpp @@ -19,13 +19,9 @@ #include "texgine_exception.h" #include "texgine/utils/exlog.h" -#ifndef USE_GRAPHIC_TEXT_GINE -#include "texgine/utils/trace.h" -#else #ifdef LOGGER_ENABLE_SCOPE #include "texgine/utils/trace.h" #endif -#endif #include "text_span.h" namespace OHOS { @@ -54,12 +50,8 @@ std::ostream &operator <<(std::ostream &os, const MergeResult &result) std::vector TextMerger::MergeSpans(const std::vector &spans) { -#ifndef USE_GRAPHIC_TEXT_GINE - ScopedTrace scope("TextMerger::MergeSpans"); -#else #ifdef LOGGER_ENABLE_SCOPE ScopedTrace scope("TextMerger::MergeSpans"); -#endif #endif std::vector vss; auto it = spans.begin(); diff --git a/rosen/modules/texgine/src/text_reverser.cpp b/rosen/modules/texgine/src/text_reverser.cpp index 12ddb8a491..f824db8920 100644 --- a/rosen/modules/texgine/src/text_reverser.cpp +++ b/rosen/modules/texgine/src/text_reverser.cpp @@ -16,25 +16,17 @@ #include "text_reverser.h" #include "texgine/utils/exlog.h" -#ifndef USE_GRAPHIC_TEXT_GINE -#include "texgine/utils/trace.h" -#else #ifdef LOGGER_ENABLE_SCOPE #include "texgine/utils/trace.h" #endif -#endif namespace OHOS { namespace Rosen { namespace TextEngine { void TextReverser::ReverseRTLText(std::vector &lineSpans) { -#ifndef USE_GRAPHIC_TEXT_GINE - ScopedTrace scope("Shaper::ReverseRTLText"); -#else #ifdef LOGGER_ENABLE_SCOPE ScopedTrace scope("Shaper::ReverseRTLText"); -#endif #endif LOGSCOPED(sl, LOGEX_FUNC_LINE_DEBUG(), "ReverseRTLText"); const auto &endit = lineSpans.end(); @@ -105,12 +97,8 @@ void TextReverser::ReverseConDirectionText(std::vector &lineSpans, void TextReverser::ProcessTypoDirection(std::vector &lineSpans, const TextDirection dir) { -#ifndef USE_GRAPHIC_TEXT_GINE - ScopedTrace scope("ProcessTypoDirection"); -#else #ifdef LOGGER_ENABLE_SCOPE ScopedTrace scope("ProcessTypoDirection"); -#endif #endif LOGSCOPED(sl, LOGEX_FUNC_LINE_DEBUG(), "ProcessTypoDirection"); if (dir == TextDirection::LTR) { diff --git a/rosen/modules/texgine/src/text_shaper.cpp b/rosen/modules/texgine/src/text_shaper.cpp index 38a415a654..55b4ce6c0e 100644 --- a/rosen/modules/texgine/src/text_shaper.cpp +++ b/rosen/modules/texgine/src/text_shaper.cpp @@ -21,13 +21,9 @@ #include "texgine_text_blob_builder.h" #include "texgine/typography_types.h" #include "texgine/utils/exlog.h" -#ifndef USE_GRAPHIC_TEXT_GINE -#include "texgine/utils/trace.h" -#else #ifdef LOGGER_ENABLE_SCOPE #include "texgine/utils/trace.h" #endif -#endif namespace OHOS { namespace Rosen { @@ -37,12 +33,8 @@ namespace TextEngine { int TextShaper::Shape(const VariantSpan &span, const TypographyStyle &ys, const std::shared_ptr &fontProviders) const { -#ifndef USE_GRAPHIC_TEXT_GINE - ScopedTrace scope("TextShaper::ShapeLineSpans"); -#else #ifdef LOGGER_ENABLE_SCOPE ScopedTrace scope("TextShaper::ShapeLineSpans"); -#endif #endif LOGSCOPED(sl, LOGEX_FUNC_LINE_DEBUG(), "TextShaper::ShapeLineSpans"); if (span == nullptr) { diff --git a/rosen/modules/texgine/src/text_span.cpp b/rosen/modules/texgine/src/text_span.cpp index dca9b497c5..34f44bb850 100644 --- a/rosen/modules/texgine/src/text_span.cpp +++ b/rosen/modules/texgine/src/text_span.cpp @@ -31,10 +31,8 @@ #include "texgine_path_1d_path_effect.h" #include "texgine/utils/exlog.h" #ifdef LOGGER_ENABLE_SCOPE -#ifndef USE_GRAPHIC_TEXT_GINE #include "texgine/utils/trace.h" #endif -#endif #include "text_converter.h" #include "word_breaker.h" diff --git a/rosen/modules/texgine/src/typeface.cpp b/rosen/modules/texgine/src/typeface.cpp index bdf5b0acee..5b1a4490a7 100644 --- a/rosen/modules/texgine/src/typeface.cpp +++ b/rosen/modules/texgine/src/typeface.cpp @@ -20,10 +20,8 @@ #include "texgine_exception.h" #include "texgine/utils/exlog.h" #ifdef LOGGER_ENABLE_SCOPE -#ifndef USE_GRAPHIC_TEXT_GINE #include "texgine/utils/trace.h" #endif -#endif namespace OHOS { namespace Rosen { @@ -62,9 +60,7 @@ bool Typeface::ParseCmap(const std::shared_ptr &parser) { LOGEX_FUNC_LINE(DEBUG) << "Parse Cmap: " << GetName(); #ifdef LOGGER_ENABLE_SCOPE -#ifndef USE_GRAPHIC_TEXT_GINE ScopedTrace scope("Typeface::InitCmap"); -#endif #endif auto tag = HB_TAG('c', 'm', 'a', 'p'); if (typeface_ == nullptr || typeface_->GetTypeface() == nullptr) { @@ -93,10 +89,8 @@ bool Typeface::ParseCmap(const std::shared_ptr &parser) } #ifdef LOGGER_ENABLE_SCOPE -#ifndef USE_GRAPHIC_TEXT_GINE scope.Finish(); ScopedTrace scope2("Typeface::ParseCmap"); -#endif #endif auto retval = parser->Parse(hb_blob_get_data(hblob_, nullptr), hb_blob_get_length(hblob_)); return retval == 0; diff --git a/rosen/modules/texgine/src/typography_impl.cpp b/rosen/modules/texgine/src/typography_impl.cpp index 0072d09977..6203a8fcc8 100644 --- a/rosen/modules/texgine/src/typography_impl.cpp +++ b/rosen/modules/texgine/src/typography_impl.cpp @@ -29,10 +29,8 @@ #include "texgine/typography_types.h" #include "texgine/utils/exlog.h" #ifdef LOGGER_ENABLE_SCOPE -#ifndef USE_GRAPHIC_TEXT_GINE #include "texgine/utils/trace.h" #endif -#endif #include "word_breaker.h" namespace OHOS { @@ -287,9 +285,7 @@ void TypographyImpl::Layout(double maxWidth) boundariesCache_ = {}; try { #ifdef LOGGER_ENABLE_SCOPE -#ifndef USE_GRAPHIC_TEXT_GINE ScopedTrace scope("TypographyImpl::Layout"); -#endif #endif LOGSCOPED(sl, LOGEX_FUNC_LINE_DEBUG(), "TypographyImpl::Layout"); LOGEX_FUNC_LINE(INFO) << "Layout maxWidth: " << maxWidth << ", spans.size(): " << spans_.size(); diff --git a/rosen/modules/texgine/src/utils/logger.cpp b/rosen/modules/texgine/src/utils/logger.cpp index 20d7ce186e..33037caee6 100644 --- a/rosen/modules/texgine/src/utils/logger.cpp +++ b/rosen/modules/texgine/src/utils/logger.cpp @@ -18,18 +18,27 @@ #include #include #include -#ifndef USE_GRAPHIC_TEXT_GINE -#include -#endif #include -#ifdef USE_GRAPHIC_TEXT_GINE #ifdef BUILD_NON_SDK_VER #include +#define GET_TID() syscall(__NR_gettid) #else #ifdef _WIN32 #include -#define gettid GetCurrentThreadId +#define GET_TID GetCurrentThreadId +#endif + +#ifdef BUILD_SDK_MAC +#include +#include +#define GET_TID() syscall(SYS_thread_selfid) +#else +#ifdef __gnu_linux__ +#include +#include +#define GET_TID() syscall(SYS_gettid) +#endif #endif #ifdef __APPLE__ @@ -40,9 +49,6 @@ #undef ERROR #endif #endif -#endif - -#define GET_TID() syscall(__NR_gettid) #ifdef LOGGER_NO_COLOR #define IF_COLOR(x) @@ -189,15 +195,7 @@ void Logger::AppendFileFuncLine(Logger &logger, enum LOG_PHASE phase) void Logger::AppendPidTid(Logger &logger, enum LOG_PHASE phase) { if (phase == LOG_PHASE::BEGIN) { -#ifdef BUILD_NON_SDK_VER -#ifndef USE_GRAPHIC_TEXT_GINE logger << getpid() << ":" << GET_TID() << " "; -#endif -#else -#ifdef USE_GRAPHIC_TEXT_GINE - logger << getpid() << ":" << gettid() << " "; -#endif -#endif } } diff --git a/rosen/modules/texgine/src/utils/trace_ohos.cpp b/rosen/modules/texgine/src/utils/trace_ohos.cpp index f4bebdda9e..047462f9cc 100644 --- a/rosen/modules/texgine/src/utils/trace_ohos.cpp +++ b/rosen/modules/texgine/src/utils/trace_ohos.cpp @@ -13,36 +13,6 @@ * limitations under the License. */ -#ifndef USE_GRAPHIC_TEXT_GINE -#include "texgine/utils/trace.h" - -#include - -namespace OHOS { -namespace Rosen { -namespace TextEngine { -void Trace::Start(const std::string &proc) -{ - StartTrace(HITRACE_TAG_GRAPHIC_AGP, proc); -} - -void Trace::Finish() -{ - FinishTrace(HITRACE_TAG_GRAPHIC_AGP); -} - -void Trace::Count(const std::string &key, int val) -{ - CountTrace(HITRACE_TAG_GRAPHIC_AGP, key, val); -} - -void Trace::Disable() -{ -} -} // namespace TextEngine -} // namespace Rosen -} // namespace OHOS -#else #ifdef LOGGER_ENABLE_SCOPE #include "texgine/utils/trace.h" @@ -73,4 +43,3 @@ void Trace::Disable() } // namespace Rosen } // namespace OHOS #endif -#endif diff --git a/rosen/modules/texgine/texgine_drawing/BUILD.gn b/rosen/modules/texgine/texgine_drawing/BUILD.gn index 13db671c84..427b3dfa0d 100644 --- a/rosen/modules/texgine/texgine_drawing/BUILD.gn +++ b/rosen/modules/texgine/texgine_drawing/BUILD.gn @@ -18,14 +18,12 @@ is_ok = true config("texgine_drawing_public_config") { include_dirs = [ "./src" ] - if (enable_text_gine) { - cflags = [ - "-Wall", - "-Werror", - "-g3", - "-std=c++17", - ] - } + cflags = [ + "-Wall", + "-Werror", + "-g3", + "-std=c++17", + ] } ohos_shared_library("libtexgine_drawing") { @@ -69,6 +67,7 @@ ohos_shared_library("libtexgine_drawing") { deps = [] + innerapi_tags = [ "platformsdk" ] part_name = "graphic_2d" subsystem_name = "graphic" }