graphic_2d模块MAC/Windows下textgine、txt、flutter三个版本适配

Signed-off-by: changleipeng <changleipeng4@huawei.com>
This commit is contained in:
changleipeng 2023-08-23 09:09:46 +08:00
parent 533c83b25e
commit 6eb19d20de
7 changed files with 48 additions and 46 deletions

View File

@ -98,6 +98,21 @@ common_bin = [
subsystem_name = "graphic"
part_name = "graphic_2d"
},
{
label = "//foundation/graphic/graphic_2d/rosen/modules/texgine:libtexgine"
subsystem_name = "graphic"
part_name = "graphic_2d"
},
{
label = "//foundation/graphic/graphic_2d/rosen/modules/texgine/texgine_drawing:libtexgine_drawing"
subsystem_name = "graphic"
part_name = "graphic_2d"
},
{
label = "//third_party/jsoncpp:jsoncpp"
subsystem_name = "thirdparty"
part_name = "jsoncpp"
},
{
label = "//third_party/flutter/build/skia:skia_shared"
subsystem_name = "thirdparty"
@ -161,6 +176,16 @@ common_bin = [
subsystem_name = "arkui"
part_name = "ace_engine"
},
{
label = "//foundation/arkui/ace_engine/build:libace_compatible"
subsystem_name = "ace_engine_subsystem"
part_name = "ace_engine_part"
},
{
label = "//foundation/arkui/ace_engine/interfaces/inner_api/ace:ace_forward_compatibility"
subsystem_name = "ace_engine_subsystem"
part_name = "ace_engine_part"
}
]
if (enable_graphic_text_gine) {

View File

@ -427,10 +427,10 @@ template("ace_core_source_set") {
"common/rosen/rosen_convert_helper.cpp",
]
if (is_ohos) {
external_deps += [
"graphic_2d:libtexgine",
"graphic_2d:rosen_text",
]
external_deps += [ "graphic_2d:libtexgine" ]
if (enable_graphic_text_gine) {
external_deps += [ "graphic_2d:rosen_text" ]
}
defines += [ "TEXGINE_SUPPORT_FOR_OHOS" ]
}
if (is_cross_platform_build) {
@ -897,10 +897,10 @@ template("ace_core_ng_source_set") {
"//foundation/graphic/graphic_2d/rosen/modules/2d_graphics/src/drawing/engine_adapter",
]
if (is_ohos) {
external_deps += [
"graphic_2d:libtexgine",
"graphic_2d:rosen_text",
]
external_deps += [ "graphic_2d:libtexgine" ]
if (enable_graphic_text_gine) {
external_deps += [ "graphic_2d:rosen_text" ]
}
defines += [ "TEXGINE_SUPPORT_FOR_OHOS" ]
}
if (is_cross_platform_build) {

View File

@ -135,7 +135,9 @@ template("build_component") {
if (defined(config.enable_rosen_backend) && config.enable_rosen_backend &&
defined(invoker.rosen_sources)) {
sources += invoker.rosen_sources
external_deps += [ "graphic_2d:rosen_text" ]
if (enable_graphic_text_gine) {
external_deps += [ "graphic_2d:rosen_text" ]
}
if (is_cross_platform_build) {
deps += [ "//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client_static" ]
} else {

View File

@ -146,10 +146,9 @@ template("build_component_ng") {
"//third_party/openGLES:libGLES",
]
external_deps += [ "graphic_2d:2d_graphics" ]
external_deps += [
"graphic_2d:2d_graphics",
"graphic_2d:rosen_text",
]
if (enable_graphic_text_gine) {
external_deps += [ "graphic_2d:rosen_text" ]
}
} else {
deps += [ "//foundation/graphic/graphic_2d/rosen/modules/2d_graphics:2d_graphics_source_$platform" ]
}

View File

@ -295,9 +295,15 @@ std::optional<SizeF> TextFieldLayoutAlgorithm::MeasureContent(
if (textContent.empty() || showPlaceHolder) {
preferredHeight = pattern->PreferredLineHeight();
}
#ifndef USE_GRAPHIC_TEXT_GINE // support sigleline
if (isInlineStyle && pattern->IsSelected()) {
pattern->SetSingleLineHeight(preferredHeight);
}
#else // support multi-line
if (isInlineStyle && pattern->IsSelected() && paragraph_->GetLineCount() != 0) {
pattern->SetSingleLineHeight(preferredHeight / paragraph_->GetLineCount());
}
#endif
#ifndef USE_GRAPHIC_TEXT_GINE
paragraphWidth_ = paragraph_->GetLongestLine();
#else

View File

@ -218,17 +218,10 @@ private:
return;
}
#ifndef USE_GRAPHIC_TEXT_GINE
auto marker = EventMarker(
[this, f = std::forward<TFunc>(func), args = std::make_tuple(std::forward<Ts>(args)...)]() mutable {
std::apply(f, std::move(args));
});
#else
auto marker = EventMarker(
[f = std::forward<TFunc>(func), args = std::make_tuple(std::forward<Ts>(args)...)]() mutable {
std::apply(f, std::move(args));
});
#endif
ctx->FireAsyncEvent(std::move(marker));
}

View File

@ -251,29 +251,6 @@ std::shared_ptr<RSData> ImageCompressor::GpuCompress(std::string key, RSBitmap&
std::function<void()> ImageCompressor::ScheduleReleaseTask()
{
#ifndef USE_GRAPHIC_TEXT_GINE
std::function<void()> task = [this]() {
#ifdef ENABLE_OPENCL
if (refCount_ > 0 && clOk_) {
refCount_--;
if (refCount_ <= 0) {
this->ReleaseResource();
// save failed records
std::ofstream saveFile(recordsPath_);
if (!saveFile.is_open()) {
return;
}
std::lock_guard<std::mutex> mLock(recordsMutex_);
for (auto s : failedRecords_) {
saveFile << s << "\n";
}
saveFile.close();
}
}
#endif // ENABLE_OPENCL
};
#else
#ifdef ENABLE_OPENCL
std::function<void()> task = [this]() {
if (refCount_ > 0 && clOk_) {
@ -293,11 +270,11 @@ std::function<void()> ImageCompressor::ScheduleReleaseTask()
saveFile.close();
}
}
};
#else
std::function<void()> task = []() {};
std::function<void()> task = []() {
#endif // ENABLE_OPENCL
#endif
};
return task;
}