From 18b90d89a848e13d934211f356c845cba7f754e6 Mon Sep 17 00:00:00 2001 From: lixuchuang Date: Fri, 19 Aug 2022 11:32:39 +0800 Subject: [PATCH] preview code Signed-off-by: lixuchuang --- build/BUILD.gn | 12 +++++- build/glfw/BUILD.gn | 4 +- build/icu/BUILD.gn | 2 +- build/libjpeg/BUILD.gn | 2 +- build/libtxt/BUILD.gn | 8 ++++ build/libwebp/BUILD.gn | 2 +- build/skia/BUILD.gn | 37 +++++++++++++++++- engine/flutter/fml/logging.cc | 1 + engine/flutter/fml/message_loop_task_queues.h | 2 + .../flutter/fml/platform/posix/file_posix.cc | 1 + .../shell/common/vsync_waiter_fallback.cc | 2 +- engine/flutter/shell/gpu/gpu_surface_gl.cc | 2 +- .../shell/platform/embedder/embedder.h | 2 +- .../shell/platform/glfw/glfw_event_loop.h | 1 + .../shell/platform/glfw/public/flutter_glfw.h | 1 + .../txt/src/minikin/Hyphenator.cpp | 1 + .../txt/src/minikin/LineBreaker.cpp | 1 + .../third_party/txt/src/txt/font_collection.h | 1 + glfw/BUILD.gn | 38 +++++++++++++++++++ glfw/glfw_ace_config.gni | 1 + skia/include/core/SkFontMgr.h | 2 +- skia/src/ports/SkFontMgr_config_parser.cpp | 2 +- skia/src/ports/skia_ohos/FontConfig_ohos.cpp | 2 +- 23 files changed, 114 insertions(+), 13 deletions(-) diff --git a/build/BUILD.gn b/build/BUILD.gn index ac5858ff..a1b7320a 100644 --- a/build/BUILD.gn +++ b/build/BUILD.gn @@ -179,6 +179,16 @@ template("flutter_engine_fml") { "CoreFoundation.framework", "Foundation.framework", ] + } else if (platform == "linux") { + sources += [ + "$flutter_root/engine/flutter/fml/platform/linux/message_loop_linux.cc", + "$flutter_root/engine/flutter/fml/platform/linux/paths_linux.cc", + "$flutter_root/engine/flutter/fml/platform/linux/timerfd.cc", + "$flutter_root/engine/flutter/fml/platform/posix/file_posix.cc", + "$flutter_root/engine/flutter/fml/platform/posix/mapping_posix.cc", + "$flutter_root/engine/flutter/fml/platform/posix/native_library_posix.cc", + "$flutter_root/engine/flutter/fml/platform/posix/paths_posix.cc", + ] } else { sources += [ "$flutter_root/engine/flutter/fml/platform/linux/timerfd.cc", @@ -651,7 +661,7 @@ template("flutter_engine_lib_ui") { "$flutter_root/engine/flutter/lib/ui/window/window.cc", ] - if (platform == "mac" || platform == "windows" || platform == "ios") { + if (platform == "mac" || platform == "windows" || platform == "ios" || platform == "linux") { sources += [ "$flutter_root/engine/flutter/lib/ui/window/pointer_data.cc" ] } diff --git a/build/glfw/BUILD.gn b/build/glfw/BUILD.gn index 96914541..03869dd4 100644 --- a/build/glfw/BUILD.gn +++ b/build/glfw/BUILD.gn @@ -142,7 +142,7 @@ template("flutter_platform_glfw") { ] # wait for glfw enabled in standard system - if (!is_standard_system || use_mingw_win || use_mac) { + if (!is_standard_system || use_mingw_win || use_mac || use_linux) { deps += [ "$flutter_root/glfw:glfw_$platform" ] } } @@ -150,7 +150,7 @@ template("flutter_platform_glfw") { foreach(item, ace_platforms) { platform = item.name - if (platform == "windows" || platform == "mac") { + if (platform == "windows" || platform == "mac" || platform == "linux") { flutter_platform_glfw("flutter_glfw_preview_" + item.name) { platform = item.name defines = [] diff --git a/build/icu/BUILD.gn b/build/icu/BUILD.gn index 8d81f608..1e182cd9 100644 --- a/build/icu/BUILD.gn +++ b/build/icu/BUILD.gn @@ -82,7 +82,7 @@ template("ace_icu_make_data_assembly") { action(target_name) { script = "$flutter_root/skia/third_party/externals/icu/scripts/make_data_assembly.py" - if (platform == "windows" || platform == "mac") { + if (platform == "windows" || platform == "mac" || platform == "linux") { inputs = [ "$flutter_root/skia/third_party/externals/icu/common/icudtl.dat" ] } else if (platform == "android") { diff --git a/build/libjpeg/BUILD.gn b/build/libjpeg/BUILD.gn index 6471cf0d..f2bbedb6 100644 --- a/build/libjpeg/BUILD.gn +++ b/build/libjpeg/BUILD.gn @@ -88,7 +88,7 @@ ohos_source_set("ace_libjpeg") { "$flutter_root/skia/third_party/externals/libjpeg-turbo/jutils.c", ] - if (use_mingw_win || use_mac) { + if (use_mingw_win || use_mac || use_linux) { sources += [ "$flutter_root/skia/third_party/externals/libjpeg-turbo/jsimd_none.c", ] diff --git a/build/libtxt/BUILD.gn b/build/libtxt/BUILD.gn index b893af86..66369e96 100644 --- a/build/libtxt/BUILD.gn +++ b/build/libtxt/BUILD.gn @@ -114,6 +114,14 @@ template("thirdparty_lib_txt") { } } else if (platform == "android") { sources += [ "$flutter_root/engine/flutter/third_party/txt/src/txt/platform_android.cc" ] + } else if (platform == "linux") { + sources += [ "$flutter_root/engine/flutter/third_party/txt/src/txt/platform_linux.cc" ] + if (is_standard_system) { + defines += [ "OHOS_STANDARD_SYSTEM" ] + } + if (use_linux) { + defines += [ "SK_BUILD_FONT_MGR_FOR_PREVIEW_LINUX" ] + } } } } diff --git a/build/libwebp/BUILD.gn b/build/libwebp/BUILD.gn index c7c01172..6880949e 100644 --- a/build/libwebp/BUILD.gn +++ b/build/libwebp/BUILD.gn @@ -40,7 +40,7 @@ ohos_source_set("ace_libwebp") { configs = [ ":ace_libwebp_config" ] configs += [ "$ace_root/build:reduce_eh_frame_config" ] - if ((target_cpu == "x86_64" && !use_mingw_win) || use_mac) { + if ((target_cpu == "x86_64" && !use_mingw_win) || use_mac || use_linux) { deps = [ ":ace_libwebp_sse41" ] } diff --git a/build/skia/BUILD.gn b/build/skia/BUILD.gn index fd44e00f..021be9f8 100644 --- a/build/skia/BUILD.gn +++ b/build/skia/BUILD.gn @@ -353,7 +353,7 @@ template("ace_skia_opts") { sources = [] - if (target_cpu == "x86_64" || platform == "windows" || platform == "mac" || + if (target_cpu == "x86_64" || platform == "windows" || platform == "mac" || platform == "linux" || platform == "ios") { cflags -= [ "-march=armv8-a+crc" ] sources += [ @@ -369,6 +369,12 @@ template("ace_skia_opts") { "$flutter_root/skia/src/opts/SkOpts_sse42.cpp", "$flutter_root/skia/src/opts/SkOpts_ssse3.cpp", ] + } else if (platform == "linux") { + sources += [ + "$flutter_root/skia/src/opts/SkOpts_sse41.cpp", + "$flutter_root/skia/src/opts/SkOpts_sse42.cpp", + "$flutter_root/skia/src/opts/SkOpts_ssse3.cpp", + ] } else if (platform == "mac") { cflags += [ "-mavx", @@ -885,6 +891,9 @@ template("ace_skia_core") { # UIKit symbols UIFontWeightXXX may be dlsym'ed. "UIKit.framework", ] + } else if (platform == "linux") { + sources += [ "$flutter_root/skia/src/ports/SkDebug_stdio.cpp", ] + libs = [ "GL" ] } else { # Ohos and Android plarform if (target_cpu != "arm") { @@ -1514,6 +1523,14 @@ template("ace_gpu") { sources += [ "$flutter_root/skia/src/gpu/gl/mac/GrGLMakeNativeInterface_mac.cpp", ] + } else if (platform == "linux") { + defines += [ "SK_R32_SHIFT=16" ] + sources -= [ + "$flutter_root/skia/src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp", + ] + sources += [ + "$flutter_root/skia/src/gpu/gl/glx/GrGLMakeNativeInterface_glx.cpp", + ] } else if (platform == "ios") { defines += [ "SK_BUILD_FOR_IOS", @@ -1738,6 +1755,21 @@ template("ace_fontmgr") { "$flutter_root/skia/src/ports/SkFontMgr_preview.cpp", ] } + } else if (platform == "linux") { + if (defined(config.ohos_standard_fontmgr) && + config.ohos_standard_fontmgr) { + sources = [ + "$flutter_root/skia/src/ports/SkFontMgr_custom.cpp", + "$flutter_root/skia/src/ports/SkFontMgr_custom_directory.cpp" , + "$flutter_root/skia/src/ports/SkFontMgr_custom_directory_factory.cpp", + ] + deps = [ ":ace_fontmgr_standard" ] + } else { + sources = [ + "$flutter_root/skia/src/ports/SkFontMgr_config_parser.cpp", + "$flutter_root/skia/src/ports/SkFontMgr_preview.cpp", + ] + } } else { # Ohos or Android platform if (defined(config.ohos_standard_fontmgr) && @@ -1833,6 +1865,9 @@ ohos_source_set("ace_fontmgr_standard") { } else if (use_mac) { defines += [ "SK_BUILD_FONT_MGR_FOR_PREVIEW_MAC" ] defines -= [ "SK_BUILD_FONT_MGR_FOR_OHOS" ] + } else if (use_linux) { + defines += [ "SK_BUILD_FONT_MGR_FOR_PREVIEW_LINUX" ] + defines -= [ "SK_BUILD_FONT_MGR_FOR_OHOS" ] } } diff --git a/engine/flutter/fml/logging.cc b/engine/flutter/fml/logging.cc index 5cd38e1e..891faa68 100644 --- a/engine/flutter/fml/logging.cc +++ b/engine/flutter/fml/logging.cc @@ -4,6 +4,7 @@ #include #include +#include #include "flutter/fml/build_config.h" #include "flutter/fml/log_settings.h" diff --git a/engine/flutter/fml/message_loop_task_queues.h b/engine/flutter/fml/message_loop_task_queues.h index a2259438..c3e7caff 100644 --- a/engine/flutter/fml/message_loop_task_queues.h +++ b/engine/flutter/fml/message_loop_task_queues.h @@ -5,7 +5,9 @@ #ifndef FLUTTER_FML_MESSAGE_LOOP_TASK_QUEUES_H_ #define FLUTTER_FML_MESSAGE_LOOP_TASK_QUEUES_H_ +#include #include +#include #include #include diff --git a/engine/flutter/fml/platform/posix/file_posix.cc b/engine/flutter/fml/platform/posix/file_posix.cc index d30a9c2f..520db7fc 100644 --- a/engine/flutter/fml/platform/posix/file_posix.cc +++ b/engine/flutter/fml/platform/posix/file_posix.cc @@ -8,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/engine/flutter/shell/common/vsync_waiter_fallback.cc b/engine/flutter/shell/common/vsync_waiter_fallback.cc index c5c05c29..15f3fe39 100644 --- a/engine/flutter/shell/common/vsync_waiter_fallback.cc +++ b/engine/flutter/shell/common/vsync_waiter_fallback.cc @@ -30,7 +30,7 @@ VsyncWaiterFallback::~VsyncWaiterFallback() = default; // |VsyncWaiter| void VsyncWaiterFallback::AwaitVSync() { // ACE PC preview -#if defined(WINDOWS_PLATFORM) || defined(MAC_PLATFORM) +#if defined(WINDOWS_PLATFORM) || defined(MAC_PLATFORM) || defined(LINUX_PLATFORM) constexpr fml::TimeDelta kSingleFrameInterval = fml::TimeDelta::FromSecondsF(1.0 / 30.0); #else diff --git a/engine/flutter/shell/gpu/gpu_surface_gl.cc b/engine/flutter/shell/gpu/gpu_surface_gl.cc index 2c329c8d..815170da 100644 --- a/engine/flutter/shell/gpu/gpu_surface_gl.cc +++ b/engine/flutter/shell/gpu/gpu_surface_gl.cc @@ -292,7 +292,7 @@ bool GPUSurfaceGL::PresentSurface(SkCanvas* canvas) { onscreen_surface_->getCanvas()->flush(); // ACE PC preview -#if defined(WINDOWS_PLATFORM) or defined(MAC_PLATFORM) +#if defined(WINDOWS_PLATFORM) or defined(MAC_PLATFORM) or defined(LINUX_PLATFORM) int32_t width = onscreen_surface_->width(); int32_t height = onscreen_surface_->height(); SkImageInfo info = SkImageInfo::Make(width, height, kRGBA_8888_SkColorType, kOpaque_SkAlphaType); diff --git a/engine/flutter/shell/platform/embedder/embedder.h b/engine/flutter/shell/platform/embedder/embedder.h index cde957bb..4af3f57a 100644 --- a/engine/flutter/shell/platform/embedder/embedder.h +++ b/engine/flutter/shell/platform/embedder/embedder.h @@ -8,7 +8,7 @@ #include #include #include - +#include #if defined(__cplusplus) #include extern "C" { diff --git a/engine/flutter/shell/platform/glfw/glfw_event_loop.h b/engine/flutter/shell/platform/glfw/glfw_event_loop.h index 4c9185a6..7e6f320f 100644 --- a/engine/flutter/shell/platform/glfw/glfw_event_loop.h +++ b/engine/flutter/shell/platform/glfw/glfw_event_loop.h @@ -10,6 +10,7 @@ #include #include #include +#include #include "flutter/shell/platform/embedder/embedder.h" diff --git a/engine/flutter/shell/platform/glfw/public/flutter_glfw.h b/engine/flutter/shell/platform/glfw/public/flutter_glfw.h index a65ec5a5..0e45779e 100644 --- a/engine/flutter/shell/platform/glfw/public/flutter_glfw.h +++ b/engine/flutter/shell/platform/glfw/public/flutter_glfw.h @@ -7,6 +7,7 @@ #include #include +#include #include "flutter_export.h" diff --git a/engine/flutter/third_party/txt/src/minikin/Hyphenator.cpp b/engine/flutter/third_party/txt/src/minikin/Hyphenator.cpp index 321a0ec5..6e6f9757 100644 --- a/engine/flutter/third_party/txt/src/minikin/Hyphenator.cpp +++ b/engine/flutter/third_party/txt/src/minikin/Hyphenator.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include // HACK: for reading pattern file diff --git a/engine/flutter/third_party/txt/src/minikin/LineBreaker.cpp b/engine/flutter/third_party/txt/src/minikin/LineBreaker.cpp index de499929..c654e030 100644 --- a/engine/flutter/third_party/txt/src/minikin/LineBreaker.cpp +++ b/engine/flutter/third_party/txt/src/minikin/LineBreaker.cpp @@ -20,6 +20,7 @@ #include #include +#include #include diff --git a/engine/flutter/third_party/txt/src/txt/font_collection.h b/engine/flutter/third_party/txt/src/txt/font_collection.h index 78e7b7cd..4d533cb1 100644 --- a/engine/flutter/third_party/txt/src/txt/font_collection.h +++ b/engine/flutter/third_party/txt/src/txt/font_collection.h @@ -18,6 +18,7 @@ #define LIB_TXT_SRC_FONT_COLLECTION_H_ #include +#include #include #include #include diff --git a/glfw/BUILD.gn b/glfw/BUILD.gn index a9873566..44312a1e 100644 --- a/glfw/BUILD.gn +++ b/glfw/BUILD.gn @@ -81,6 +81,39 @@ template("glfw") { public_configs += [ ":glfw_config_mac" ] defines += [ "_GLFW_COCOA" ] } + if (platform == "linux") { + sources += [ + "src/egl_context.c", + "src/egl_context.h", + "src/glx_context.c", + "src/glx_context.h", + "src/linux_joystick.c", + "src/linux_joystick.h", + "src/posix_time.c", + "src/posix_time.h", + "src/posix_tls.c", + "src/posix_tls.h", + "src/x11_init.c", + "src/x11_monitor.c", + "src/x11_platform.h", + "src/x11_window.c", + "src/xkb_unicode.c", + "src/xkb_unicode.h", + ] + cflags_c = [ + "-Wno-sign-compare", + "-Wno-missing-field-initializers", + ] + libs = [ + "rt", + "dl", + "X11", + "Xcursor", + "Xinerama", + "Xrandr", + ] + defines += [ "_GLFW_X11" ] + } } } @@ -93,3 +126,8 @@ glfw("glfw_mac") { defines = ace_mac_defines platform = "mac" } + +glfw("glfw_linux") { + defines = ace_linux_defines + platform = "linux" +} diff --git a/glfw/glfw_ace_config.gni b/glfw/glfw_ace_config.gni index 5668821e..0f6fa860 100644 --- a/glfw/glfw_ace_config.gni +++ b/glfw/glfw_ace_config.gni @@ -2,3 +2,4 @@ # Defines ace_windows_defines = [ "WINDOWS_PLATFORM" ] ace_mac_defines = [ "MAC_PLATFORM" ] +ace_linux_defines = [ "LINUX_PLATFORM" ] diff --git a/skia/include/core/SkFontMgr.h b/skia/include/core/SkFontMgr.h index e9880d41..5b6e4552 100644 --- a/skia/include/core/SkFontMgr.h +++ b/skia/include/core/SkFontMgr.h @@ -41,7 +41,7 @@ public: void getFamilyName(int index, SkString* familyName) const; SkFontStyleSet* createStyleSet(int index) const; -#if defined(SK_BUILD_FONT_MGR_FOR_PREVIEW_WIN) or defined(SK_BUILD_FONT_MGR_FOR_PREVIEW_MAC) +#if defined(SK_BUILD_FONT_MGR_FOR_PREVIEW_WIN) or defined(SK_BUILD_FONT_MGR_FOR_PREVIEW_LINUX) /** * Whether to use the physical device font for previewer flag. * If true, use physical device font collecton. diff --git a/skia/src/ports/SkFontMgr_config_parser.cpp b/skia/src/ports/SkFontMgr_config_parser.cpp index 2a49fb37..08a23239 100644 --- a/skia/src/ports/SkFontMgr_config_parser.cpp +++ b/skia/src/ports/SkFontMgr_config_parser.cpp @@ -26,7 +26,7 @@ std::string g_lmpSystemFontsFile = "INVALID_FILE_PATH"; } #if defined(SK_BUILD_FONT_MGR_FOR_PREVIEW_WIN) std::string SkFontMgr_Config_Parser::basePath = "..\\..\\resources\\fonts\\"; -#elif defined(SK_BUILD_FONT_MGR_FOR_PREVIEW_MAC) +#elif defined(SK_BUILD_FONT_MGR_FOR_PREVIEW_MAC) || defined(SK_BUILD_FONT_MGR_FOR_PREVIEW_LINUX) std::string SkFontMgr_Config_Parser::basePath = "../../resources/fonts/"; #endif diff --git a/skia/src/ports/skia_ohos/FontConfig_ohos.cpp b/skia/src/ports/skia_ohos/FontConfig_ohos.cpp index 9356893b..8ddd5b34 100644 --- a/skia/src/ports/skia_ohos/FontConfig_ohos.cpp +++ b/skia/src/ports/skia_ohos/FontConfig_ohos.cpp @@ -16,7 +16,7 @@ #include "SkString.h" using namespace ErrorCode; -#if defined(SK_BUILD_FONT_MGR_FOR_PREVIEW_WIN) or defined(SK_BUILD_FONT_MGR_FOR_PREVIEW_MAC) +#if defined(SK_BUILD_FONT_MGR_FOR_PREVIEW_WIN) or defined(SK_BUILD_FONT_MGR_FOR_PREVIEW_MAC)or defined(SK_BUILD_FONT_MGR_FOR_PREVIEW_LINUX) static const char* OHOS_DEFAULT_CONFIG = "fontconfig.json"; #else static const char* OHOS_DEFAULT_CONFIG = "/system/etc/fontconfig.json"; -- Gitee