1# Copyright (c) 2024 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14import("//build/ohos.gni") 15import("//build/ohos_var.gni") 16import("//foundation/graphic/graphic_2d/ace_platforms.gni") 17import("//foundation/graphic/graphic_2d/frameworks/text/config.gni") 18import("//foundation/graphic/graphic_2d/graphic_config.gni") 19 20config("skia_libtxt_config") { 21 if (graphic_2d_feature_upgrade_skia) { 22 defines = [ 23 "ENABLE_TEXT_ENHANCE", 24 "ENABLE_DRAWING_ADAPTER", 25 ] 26 } else { 27 defines = [ 28 "OHOS_SUPPORT", 29 "USE_SKIA_TXT", 30 ] 31 } 32 33 if (rs_enable_gpu) { 34 defines += [ "RS_ENABLE_GPU" ] 35 } 36 37 include_dirs = [ 38 "$rosen_text_root", 39 "$rosen_text_root/interface/export", 40 "$rosen_text_root/interface/export/rosen_text", 41 ] 42 43 cflags_cc = [ 44 "-Wno-implicit-fallthrough", 45 "-fvisibility-inlines-hidden", 46 "-std=c++17", 47 ] 48} 49 50if (graphic_2d_feature_upgrade_skia) { 51 skia_root = "//third_party/skia/m133" 52} else { 53 skia_root = "//third_party/skia" 54} 55 56template("skia_libtxt") { 57 forward_variables_from(invoker, "*") 58 59 ohos_source_set(target_name) { 60 part_name = "graphic_2d" 61 subsystem_name = "graphic" 62 defines += invoker.defines 63 cflags_cc += invoker.cflags_cc 64 65 public_configs = [ ":skia_libtxt_config" ] 66 include_dirs = [ 67 "$rosen_root/modules/render_service_base/include", 68 "$graphic_2d_root/rosen/modules/2d_graphics/include", 69 "$graphic_2d_root/rosen/modules/2d_graphics/src", 70 "$graphic_2d_root/rosen/modules/2d_graphics/src/drawing", 71 "$graphic_2d_root/rosen/modules/2d_graphics/src/drawing/engine_adapter", 72 "$rosen_text_root", 73 "$rosen_text_root/service/skia_txt", 74 "$rosen_text_root/adapter/skia", 75 "$rosen_text_root/adapter/skia/txt", 76 "$rosen_text_root/service/texgine/src", 77 ] 78 79 sources = [ 80 "common_utils/string_util.cpp", 81 "impl/drawing_painter_impl.cpp", 82 "impl/paragraph_builder_impl.cpp", 83 "impl/paragraph_impl.cpp", 84 "impl/paragraph_line_fetcher_impl.cpp", 85 "impl/paragraph_relayout_impl.cpp", 86 "impl/run_impl.cpp", 87 "impl/text_font_utils.cpp", 88 "impl/text_line_impl.cpp", 89 "symbol_engine/hm_symbol_node_build.cpp", 90 "symbol_engine/hm_symbol_run.cpp", 91 "symbol_engine/hm_symbol_txt.cpp", 92 "symbol_engine/text_animation_config.cpp", 93 "symbol_resource/symbol_config_parser.cpp", 94 "txt/asset_font_manager.cpp", 95 "txt/font_asset_provider.cpp", 96 "txt/font_collection.cpp", 97 "txt/paragraph_builder.cpp", 98 "txt/paragraph_style.cpp", 99 "txt/placeholder_run.cpp", 100 "txt/platform.cpp", 101 "txt/text_bundle_config_parser.cpp", 102 "txt/text_style.cpp", 103 "txt/typeface_font_asset_provider.cpp", 104 ] 105 106 external_deps = [] 107 if (platform_is_ohos) { 108 external_deps += [ 109 "bundle_framework:appexecfwk_base", 110 "bundle_framework:appexecfwk_core", 111 "hitrace:hitrace_meter", 112 "init:libbegetutil", 113 "ipc:ipc_core", 114 "samgr:samgr_proxy", 115 ] 116 defines += [ 117 "ENABLE_OHOS_ENHANCE", 118 "HM_SYMBOL_TXT_ENABLE", 119 ] 120 } else { 121 defines += [ "MODULE_TEXTING" ] 122 } 123 124 if (is_arkui_x) { 125 include_dirs += [ "//base/hiviewdfx/hitrace/interfaces/native/innerkits/include/hitrace_meter" ] 126 defines += [ "CROSS_PLATFORM" ] 127 deps = [ 128 "//third_party/bounds_checking_function:libsec_static", 129 "//third_party/jsoncpp:jsoncpp_static", 130 "//third_party/skia:skia_$platform", 131 ] 132 if (graphic_2d_feature_upgrade_skia) { 133 deps += [ 134 "//third_party/skia/m133/modules/skparagraph:skia_paragraph_ohos_new", 135 ] 136 } else { 137 deps += [ "//third_party/skia/modules/skparagraph:skia_paragraph_ohos" ] 138 } 139 } else { 140 external_deps += [ 141 "bounds_checking_function:libsec_shared", 142 "hilog:libhilog", 143 "jsoncpp:jsoncpp", 144 "skia:skia_canvaskit", 145 ] 146 if (graphic_2d_feature_upgrade_skia) { 147 external_deps += [ "skia:skia_paragraph_ohos_new" ] 148 } else { 149 external_deps += [ "skia:skia_paragraph_ohos" ] 150 } 151 defines += [ "TEXT_SYSTEM_OHOS" ] 152 } 153 } 154} 155 156foreach(item, ace_platforms) { 157 skia_libtxt("skia_libtxt_" + item.name) { 158 defines = [] 159 cflags_cc = [] 160 config = { 161 } 162 163 if (defined(item.config)) { 164 config = item.config 165 } 166 167 if (defined(config.defines)) { 168 defines = config.defines 169 } 170 171 if (defined(config.cflags_cc)) { 172 cflags_cc = config.cflags_cc 173 } 174 } 175} 176 177ohos_static_library("font_asset") { 178 part_name = "graphic_2d" 179 subsystem_name = "graphic" 180 181 public_configs = [ ":skia_libtxt_config" ] 182 defines = [ "TEXT_SYSTEM_OHOS" ] 183 if (is_arkui_x) { 184 deps = [ 185 "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog_${target_os}", 186 "//third_party/bounds_checking_function:libsec_static", 187 "//third_party/cJSON:cjson_static", 188 "//third_party/skia:skia_$platform", 189 ] 190 } else { 191 external_deps = [ 192 "bounds_checking_function:libsec_shared", 193 "cJSON:cjson", 194 "hilog:libhilog", 195 "skia:skia_canvaskit", 196 ] 197 } 198 199 include_dirs = [ 200 "$rosen_text_root/service/skia_txt", 201 "$rosen_text_root/adapter/skia/txt", 202 "$rosen_text_root/adapter/skia", 203 "$rosen_text_root/service/texgine/src", 204 "$graphic_2d_root/rosen/modules/2d_graphics/include", 205 "$graphic_2d_root/rosen/modules/2d_graphics/src/drawing/engine_adapter", 206 ] 207 208 if (platform_is_ohos) { 209 sanitize = { 210 cfi = true 211 cfi_cross_dso = true 212 cfi_no_nvcall = true 213 cfi_vcall_icall_only = true 214 debug = false 215 } 216 external_deps += [ "init:libbegetutil" ] 217 defines += [ 218 "HM_SYMBOL_TXT_ENABLE", 219 "BUILD_NON_SDK_VER", 220 "ENABLE_OHOS_ENHANCE", 221 ] 222 } else { 223 defines += [ "MODULE_FONT" ] 224 } 225 226 sources = [ 227 "$rosen_text_root/adapter/skia/txt/asset_font_manager.cpp", 228 "$rosen_text_root/adapter/skia/txt/font_asset_provider.cpp", 229 "$rosen_text_root/adapter/skia/txt/platform.cpp", 230 "$rosen_text_root/adapter/skia/txt/typeface_font_asset_provider.cpp", 231 "$rosen_text_root/service/texgine/src/font_config.cpp", 232 ] 233} 234