浏览代码

Merge branch 'dev_1.17.5' into siyaoH/1.17/android

/siyaoH-1.17-PlatformMessage
siyao 4 年前
当前提交
1fcce2b2
共有 5 个文件被更改,包括 509 次插入190 次删除
  1. 103
      com.unity.uiwidgets/Runtime/engine2/UIWidgetsPanel.cs
  2. 376
      engine/Build.bee.cs
  3. 213
      engine/README.md
  4. 3
      engine/src/shell/platform/unity/darwin/macos/uiwidgets_panel.mm
  5. 4
      engine/src/shell/platform/unity/windows/unity_surface_manager.cc

103
com.unity.uiwidgets/Runtime/engine2/UIWidgetsPanel.cs


}
}
enum UIWidgetsInputMode
{
Mouse,
Touch
}
public void OnDrag(PointerEventData eventData) {
var pos = _getPointerPosition(position: Input.mousePosition);
_wrapper.OnDrag(pos: pos, pointerId: eventData.pointerId);
}
public void OnPointerDown(PointerEventData eventData) {
var pos = _getPointerPosition(position: Input.mousePosition);
_wrapper.OnPointerDown(pos: pos, pointerId: eventData.pointerId);
}
public void OnPointerEnter(PointerEventData eventData) {
D.assert(eventData.pointerId < 0);
_isEntered = true;
_lastMousePosition = Input.mousePosition;
}
public void OnPointerExit(PointerEventData eventData) {
D.assert(eventData.pointerId < 0);
_isEntered = false;
_wrapper.OnPointerLeave();
}
UIWidgetsInputMode _inputMode;
public void OnPointerUp(PointerEventData eventData) {
var pos = _getPointerPosition(position: Input.mousePosition);
_wrapper.OnPointerUp(pos: pos, pointerId: eventData.pointerId);
void _convertPointerData(PointerEventData evt, out Vector2? position, out int pointerId) {
position = _inputMode == UIWidgetsInputMode.Mouse
? _getPointerPosition(Input.mousePosition)
: _getPointerPosition(evt);
pointerId = _inputMode == UIWidgetsInputMode.Mouse ? evt.pointerId : (-1 - evt.pointerId);
}
Vector2? _getPointerPosition(Vector2 position) {

}
return null;
}
Vector2? _getPointerPosition(PointerEventData eventData) {
//refer to: https://zhuanlan.zhihu.com/p/37127981
Camera eventCamera = null;
if (canvas.renderMode != RenderMode.ScreenSpaceOverlay) {
eventCamera = canvas.GetComponent<GraphicRaycaster>().eventCamera;
}
Vector2 localPoint;
RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, eventData.position,
eventCamera, out localPoint);
var scaleFactor = canvas.scaleFactor;
localPoint.x = (localPoint.x - rectTransform.rect.min.x) * scaleFactor;
localPoint.y = (rectTransform.rect.max.y - localPoint.y) * scaleFactor;
return localPoint;
_inputMode = Input.mousePresent ? UIWidgetsInputMode.Mouse : UIWidgetsInputMode.Touch;
}
void Input_OnDisable() {

if (Input.touchCount == 0 && Input.mousePresent) {
//we only process hover events for desktop applications
if (_inputMode == UIWidgetsInputMode.Mouse) {
if (_isEntered) {
if (!Input.GetMouseButton(0) && !Input.GetMouseButton(1) && !Input.GetMouseButton(2)) {
if (_lastMousePosition.x != Input.mousePosition.x ||

}
void _onMouseMove() {
var pos = _getPointerPosition(position: Input.mousePosition);
_wrapper.OnMouseMove(pos: pos);
if (_inputMode != UIWidgetsInputMode.Mouse) {
return;
}
var pos = _getPointerPosition(Input.mousePosition);
_wrapper.OnMouseMove(pos);
var pos = _getPointerPosition(position: Input.mousePosition);
_wrapper.OnMouseScroll(delta: Input.mouseScrollDelta, pos: pos);
if (_inputMode != UIWidgetsInputMode.Mouse) {
return;
}
var pos = _getPointerPosition(Input.mousePosition);
_wrapper.OnMouseScroll(Input.mouseScrollDelta, pos);
}
public void OnPointerEnter(PointerEventData eventData) {
if (_inputMode != UIWidgetsInputMode.Mouse) {
return;
}
D.assert(eventData.pointerId < 0);
_isEntered = true;
_lastMousePosition = Input.mousePosition;
}
public void OnPointerExit(PointerEventData eventData) {
if (_inputMode != UIWidgetsInputMode.Mouse) {
return;
}
D.assert(eventData.pointerId < 0);
_isEntered = false;
_wrapper.OnPointerLeave();
}
public void OnPointerDown(PointerEventData eventData) {
_convertPointerData(eventData, out var pos, out var pointerId);
_wrapper.OnPointerDown(pos, pointerId);
}
public void OnPointerUp(PointerEventData eventData) {
_convertPointerData(eventData, out var pos, out var pointerId);
_wrapper.OnPointerUp(pos, pointerId);
}
public void OnDrag(PointerEventData eventData) {
_convertPointerData(eventData, out var pos, out var pointerId);
_wrapper.OnDrag(pos, pointerId);
}
}
}

376
engine/Build.bee.cs


using Bee.Tools;
using NiceIO;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using RuntimeInformation = System.Runtime.InteropServices.RuntimeInformation;
using OSPlatform = System.Runtime.InteropServices.OSPlatform;
using Bee.Toolchain.GNU;
using Bee.Toolchain.IOS;
using System.Diagnostics;
class BuildUtils
enum UIWidgetsBuildTargetPlatform
{
windows,
mac,
ios,
android
}
static class BuildUtils
{
public static bool IsHostWindows()
{

}
}
/**
* How to add new target platform (taking iOS as the example)
* (1) add a new static void DeployIOS() {} in which we need call SetupLibUIWidgets() with UIWidgetsBuildTargetPlatform.ios as its
* first parameter. We should also generate the corresponding project file (i.e., XcodeProjectFile). Finally, we should call
* Backend.Current.AddAliasDependency("ios", dep) to add the alias "ios" to all the final output files for ios platform. By
* doing so, we can call "mono bee.exe ios" in command line to tell bee to process the specific subgraph for ios build only.
* (refer to the following session for the details on this: https://unity.slack.com/archives/C1RM0NBLY/p1615797377297800)
*
* (2) add the DeployIOS() function inside the available target platforms of MacOS in Main() since the dependencies on ios-platform
* , i.e., skia, flutter, etc. can only be built on Mac.
*
* (3) pick the corresponding toolchains for UIWidgetsBuildTargetPlatform.ios at the end of the function SetupLibUIWidgets() and setup
* the build targets.
*
* (4) change all the build settings (e.g., Defines, Includes, Source files) accordingly with platform-filters like IsMac, IsWindows,
* IsIosOrTvos inside bee for plaform-dependent settings.
*
* (5) finally, try call "mono bee.exe" with our predefined platform-dependent alias name "ios" in step (1), i.e., "mono bee.exe ios"
* to start the build
**/
static void Main()
//bee.exe win
static void DeployWindows()
skiaRoot = Environment.GetEnvironmentVariable("SKIA_ROOT");
if (string.IsNullOrEmpty(skiaRoot))
var libUIWidgets = SetupLibUIWidgets(UIWidgetsBuildTargetPlatform.windows, out var dependencies);
var builder = new VisualStudioNativeProjectFileBuilder(libUIWidgets);
builder = libUIWidgets.SetupConfigurations.Aggregate(
builder,
(current, c) => current.AddProjectConfiguration(c));
var sln = new VisualStudioSolution();
sln.Path = "libUIWidgets.gen.sln";
var deployed = builder.DeployTo("libUIWidgets.gen.vcxproj");
sln.Projects.Add(deployed);
Backend.Current.AddAliasDependency("ProjectFiles", sln.Setup());
Backend.Current.AddAliasDependency("win", deployed.Path);
foreach (var dep in dependencies)
{
Backend.Current.AddAliasDependency("win", dep);
}
}
//bee.exe mac
static void DeployMac()
{
if (buildAndroid)
{
var libUIWidgets = SetupLibUIWidgets(UIWidgetsBuildTargetPlatform.mac, out var dependencies);
var androidProject = AndroidNativeProgramExtensions.DynamicLinkerSettingsForAndroid(libUIWidgets);
}
else
skiaRoot = Environment.GetEnvironmentVariable("USERPROFILE") + "/skia_repo/skia";
var libUIWidgets = SetupLibUIWidgets(UIWidgetsBuildTargetPlatform.mac, out var dependencies);
var nativePrograms = new List<NativeProgram>();
nativePrograms.Add(libUIWidgets);
var xcodeProject = new XCodeProjectFile(nativePrograms, new NPath("libUIWidgetsMac.xcodeproj/project.pbxproj"));
Backend.Current.AddAliasDependency("mac", new NPath("libUIWidgetsMac.xcodeproj/project.pbxproj"));
foreach (var dep in dependencies)
{
Backend.Current.AddAliasDependency("mac", dep);
}
}
static void Main()
{
flutterRoot = Environment.GetEnvironmentVariable("FLUTTER_ROOT");
if (string.IsNullOrEmpty(flutterRoot))
{

var buildAndroidEnv = Environment.GetEnvironmentVariable("BUILD_ANDROID");
buildAndroid = true;
var libUIWidgets = SetupLibUIWidgets();
skiaRoot = flutterRoot + "/third_party/skia";
//create ide projects
//available target platforms of Windows
//create vs project
var builder = new VisualStudioNativeProjectFileBuilder(libUIWidgets);
builder = libUIWidgets.SetupConfigurations.Aggregate(
builder,
(current, c) => current.AddProjectConfiguration(c));
var sln = new VisualStudioSolution();
sln.Path = "libUIWidgets.gen.sln";
sln.Projects.Add(builder.DeployTo("libUIWidgets.gen.vcxproj"));
Backend.Current.AddAliasDependency("ProjectFiles", sln.Setup());
DeployWindows();
//available target platforms of MacOS
if (buildAndroid)
{
var androidProject = AndroidNativeProgramExtensions.DynamicLinkerSettingsForAndroid(libUIWidgets);
}
else
{
//create xcode project
var nativePrograms = new List<NativeProgram>();
nativePrograms.Add(libUIWidgets);
var xcodeProject = new XCodeProjectFile(nativePrograms, new NPath("libUIWidgets.xcodeproj/project.pbxproj"));
}
DeployMac();
}
}

static NativeProgram SetupLibUIWidgets()
static NativeProgram SetupLibUIWidgets(UIWidgetsBuildTargetPlatform platform, out List<NPath> dependencies)
{
var np = new NativeProgram("libUIWidgets")
{

np.Libraries.Add(c => IsWindows(c), new BagOfObjectFilesLibrary(
new NPath[]{
skiaRoot + "/third_party/externals/icu/flutter/icudtl.o"
flutterRoot + "/third_party/icu/flutter/icudtl.o"
np.Defines.Add(c => IsAndroid(c), new [] {
np.Defines.Add(c => IsAndroid(c), new[] {
"USE_OPENSSL=1",
"USE_OPENSSL_CERTS=1",
"ANDROID",

}
else
{
SetupFml(np);
SetupRadidJson(np);
SetupSkia(np);
SetupTxt(np);
SetupDependency(np);
//SetupFml(np);
//SetupSkia(np);
//SetupTxt(np);
dependencies = new List<NPath>();
if (BuildUtils.IsHostWindows())
if (platform == UIWidgetsBuildTargetPlatform.windows)
{
var toolchain = ToolChain.Store.Windows().VS2019().Sdk_17134().x64();

var builtNP = np.SetupSpecificConfiguration(config, toolchain.DynamicLibraryFormat)
.DeployTo("build");
dependencies.Add(builtNP.Path);
else if (BuildUtils.IsHostMac())
else if (platform == UIWidgetsBuildTargetPlatform.mac)
{
if (buildAndroid)
{

builtNP.DeployTo("../Samples/UIWidgetsSamples_2019_4/Assets/Plugins/Android");
builtNP.DeployTo("/Users/siyao/Documents/GitHub/untitled folder/unityLibrary/src/main/jniLibs/armeabi-v7a");
}
else
{

var config = new NativeProgramConfiguration(codegen, toolchain, lump: true);
validConfigurations.Add(config);
var builtNP = np.SetupSpecificConfiguration(config, toolchain.DynamicLibraryFormat).DeployTo("build");
builtNP.DeployTo("../Samples/UIWidgetsSamples_2019_4/Assets/Plugins/osx");
var buildProgram = np.SetupSpecificConfiguration(config, toolchain.DynamicLibraryFormat);
var buildNp = buildProgram.DeployTo("build");
var deployNp = buildProgram.DeployTo("../Samples/UIWidgetsSamples_2019_4/Assets/Plugins/osx");
dependencies.Add(buildNp.Path);
dependencies.Add(deployNp.Path);
}
return np;

});
}
static void SetupDependency(NativeProgram np)
{
SetupRadidJson(np);
// TODO: fix warning, there are some type mismatches
var ignoreWarnigs = new string[] { "4244", "4267", "5030", "4101", "4996", "4359", "4018", "4091", "4722", "4312", "4838", "4172", "4005", "4311", "4477" };
np.CompilerSettings().Add(c => IsWindows(c), s => s.WithWarningPolicies(ignoreWarnigs.Select((code) => new WarningAndPolicy(code, WarningPolicy.Silent)).ToArray()));
np.Defines.Add(c => IsMac(c), new[]
{
//lib flutter
"USE_OPENSSL=1",
"__STDC_CONSTANT_MACROS",
"__STDC_FORMAT_MACROS",
"_FORTIFY_SOURCE=2",
"_LIBCPP_DISABLE_AVAILABILITY=1",
"_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS",
"_DEBUG",
"FLUTTER_RUNTIME_MODE_DEBUG=1",
"FLUTTER_RUNTIME_MODE_PROFILE=2",
"FLUTTER_RUNTIME_MODE_RELEASE=3",
"FLUTTER_RUNTIME_MODE_JIT_RELEASE=4",
"FLUTTER_RUNTIME_MODE=1",
"FLUTTER_JIT_RUNTIME=1",
//lib skia
"SK_ENABLE_SPIRV_VALIDATION",
"SK_ASSUME_GL=1",
"SK_ENABLE_API_AVAILABLE",
"SK_GAMMA_APPLY_TO_A8",
"GR_OP_ALLOCATE_USE_NEW",
"SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=1",
"GR_TEST_UTILS=1",
"SKIA_IMPLEMENTATION=1",
"SK_GL",
"SK_ENABLE_DUMP_GPU",
"SK_SUPPORT_PDF",
"SK_CODEC_DECODES_JPEG",
"SK_ENCODE_JPEG",
"SK_ENABLE_ANDROID_UTILS",
"SK_USE_LIBGIFCODEC",
"SK_HAS_HEIF_LIBRARY",
"SK_CODEC_DECODES_PNG",
"SK_ENCODE_PNG",
"SK_CODEC_DECODES_RAW",
"SK_ENABLE_SKSL_INTERPRETER",
"SKVM_JIT_WHEN_POSSIBLE",
"SK_CODEC_DECODES_WEBP",
"SK_ENCODE_WEBP",
"SK_XML",
});
//lib txt
np.Defines.Add(c => IsMac(c), new[] {
"SK_USING_THIRD_PARTY_ICU", "U_USING_ICU_NAMESPACE=0",
"U_ENABLE_DYLOAD=0", "USE_CHROMIUM_ICU=1", "U_STATIC_IMPLEMENTATION",
"ICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_STATIC"
});
np.IncludeDirectories.Add(c => IsWindows(c), new NPath[] {
".",
"third_party",
"src",
flutterRoot,
flutterRoot + "/third_party/rapidjson/include",
flutterRoot +"/third_party/angle/include",
skiaRoot,
flutterRoot + "/flutter/third_party/txt/src",
flutterRoot + "/third_party/harfbuzz/src",
flutterRoot + "/third_party/icu/source/common",
flutterRoot + "/third_party/icu/source/common",
flutterRoot + "/third_party/icu/source/i18n",
});
np.CompilerSettings().Add(c => IsWindows(c), c => c.WithCustomFlags(new[] {
"-D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING",
"-DUSE_OPENSSL=1",
"-D__STD_C",
"-D_CRT_RAND_S",
"-D_CRT_SECURE_NO_DEPRECATE",
"-D_HAS_EXCEPTIONS=0",
"-D_SCL_SECURE_NO_DEPRECATE",
"-DWIN32_LEAN_AND_MEAN",
"-DNOMINMAX",
"-D_ATL_NO_OPENGL",
"-D_WINDOWS",
"-DCERT_CHAIN_PARA_HAS_EXTRA_FIELDS",
"-DNTDDI_VERSION=0x06030000",
"-DPSAPI_VERSION=1",
"-DWIN32",
"-D_SECURE_ATL",
"-D_USING_V110_SDK71_",
"-D_UNICODE",
"-DUNICODE",
"-D_WIN32_WINNT=0x0603",
"-DWINVER=0x0603",
"-D_DEBUG",
"-DU_USING_ICU_NAMESPACE=0",
"-DU_ENABLE_DYLOAD=0",
"-DUSE_CHROMIUM_ICU=1",
"-DU_STATIC_IMPLEMENTATION",
"-DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE",
"-DUCHAR_TYPE=wchar_t",
"-DFLUTTER_RUNTIME_MODE_DEBUG=1",
"-DFLUTTER_RUNTIME_MODE_PROFILE=2",
"-DFLUTTER_RUNTIME_MODE_RELEASE=3",
"-DFLUTTER_RUNTIME_MODE_JIT_RELEASE=4",
"-DFLUTTER_RUNTIME_MODE=1",
"-DFLUTTER_JIT_RUNTIME=1",
"-DSK_ENABLE_SPIRV_VALIDATION",
"-D_CRT_SECURE_NO_WARNINGS",
"-D_HAS_EXCEPTIONS=0",
"-DWIN32_LEAN_AND_MEAN",
"-DNOMINMAX",
"-DSK_GAMMA_APPLY_TO_A8",
"-DSK_ALLOW_STATIC_GLOBAL_INITIALIZERS=1",
// TODO: fix this by update txt_lib build setting, reference: https://github.com/microsoft/vcpkg/issues/12123
// "-DGR_TEST_UTILS=1",
"-DSKIA_IMPLEMENTATION=1",
"-DSK_GL",
"-DSK_ENABLE_DUMP_GPU",
"-DSK_SUPPORT_PDF",
"-DSK_CODEC_DECODES_JPEG",
"-DSK_ENCODE_JPEG",
"-DSK_SUPPORT_XPS",
"-DSK_ENABLE_ANDROID_UTILS",
"-DSK_USE_LIBGIFCODEC",
"-DSK_HAS_HEIF_LIBRARY",
"-DSK_CODEC_DECODES_PNG",
"-DSK_ENCODE_PNG",
"-DSK_ENABLE_SKSL_INTERPRETER",
"-DSK_CODEC_DECODES_WEBP",
"-DSK_ENCODE_WEBP",
"-DSK_XML",
"-DLIBEGL_IMPLEMENTATION",
"-D_CRT_SECURE_NO_WARNINGS",
"-D_HAS_EXCEPTIONS=0",
"-DWIN32_LEAN_AND_MEAN",
"-DNOMINMAX",
"-DANGLE_ENABLE_ESSL",
"-DANGLE_ENABLE_GLSL",
"-DANGLE_ENABLE_HLSL",
"-DANGLE_ENABLE_OPENGL",
"-DEGL_EGLEXT_PROTOTYPES",
"-DGL_GLEXT_PROTOTYPES",
"-DANGLE_ENABLE_D3D11",
"-DANGLE_ENABLE_D3D9",
"-DGL_APICALL=",
"-DGL_API=",
"-DEGLAPI=",
"/FS",
"/MTd",
"/Od",
"/Ob0",
"/RTC1",
"/Zi",
"/WX",
"/std:c++17",
"/GR-",
}));
np.CompilerSettings().Add(c => IsMac(c), c => c.WithCustomFlags(new[] {
"-MD",
"-MF",
"-I.",
"-Ithird_party",
"-Isrc",
"-I"+ flutterRoot,
"-I"+ flutterRoot+"/third_party/rapidjson/include",
"-I"+ skiaRoot,
"-I"+ flutterRoot+"/flutter/third_party/txt/src",
"-I" + flutterRoot + "/third_party/harfbuzz/src",
"-I" + skiaRoot + "/third_party/externals/icu/source/common",
// "-Igen",
"-I"+ flutterRoot+"/third_party/icu/source/common",
"-I"+ flutterRoot+"/third_party/icu/source/i18n",
"-fvisibility-inlines-hidden",
}));
var windowsSkiaBuild = skiaRoot + "/out/Debug";
np.Libraries.Add(IsWindows, c =>
{
return new PrecompiledLibrary[]
{
new StaticLibrary(flutterRoot+"/out/host_debug_unopt/obj/flutter/third_party/txt/txt_lib.lib"),
new StaticLibrary(windowsSkiaBuild+"/libEGL.dll.lib"),
new StaticLibrary(windowsSkiaBuild+"/libGLESv2.dll.lib"),
new SystemLibrary("Opengl32.lib"),
new SystemLibrary("User32.lib"),
new SystemLibrary("Rpcrt4.lib"),
};
});
np.SupportFiles.Add(c => IsWindows(c), new[] {
new DeployableFile(windowsSkiaBuild + "/libEGL.dll"),
new DeployableFile(windowsSkiaBuild + "/libEGL.dll.pdb"),
new DeployableFile(windowsSkiaBuild + "/libGLESv2.dll"),
new DeployableFile(windowsSkiaBuild + "/libGLESv2.dll.pdb"),
}
);
np.Libraries.Add(IsMac, c =>
{
return new PrecompiledLibrary[]
{
new StaticLibrary(flutterRoot+"/out/host_debug_unopt/obj/flutter/third_party/txt/libtxt_lib.a"),
new SystemFramework("Foundation"),
new SystemFramework("ApplicationServices"),
new SystemFramework("OpenGL"),
new SystemFramework("AppKit"),
new SystemFramework("CoreVideo"),
};
});
}
static void SetupSkia(NativeProgram np)
{
np.Defines.Add(c => IsWindows(c), new[]

var ignoreWarnigs = new string[] { "4091", "4722", "4312", "4838", "4172", "4005", "4311", "4477" }; // todo comparing the list with engine
txtLib.CompilerSettings().Add(s => s.WithWarningPolicies(ignoreWarnigs.Select((code) => new WarningAndPolicy(code, WarningPolicy.Silent)).ToArray()));
txtLib.CompilerSettings().Add(c => IsMac(c), c => c.WithCppLanguageVersion(CppLanguageVersion.Cpp17));
txtLib.CompilerSettings().Add(c => IsMac(c), c => c.WithCustomFlags(new []{"-Wno-c++11-narrowing"}));
txtLib.CompilerSettings().Add(c => IsMac(c), c => c.WithCustomFlags(new[] { "-Wno-c++11-narrowing" }));
txtLib.Defines.Add(c => c.CodeGen == CodeGen.Debug,
new[] { "_ITERATOR_DEBUG_LEVEL=2", "_HAS_ITERATOR_DEBUGGING=1", "_SECURE_SCL=1" });

213
engine/README.md


## How to Build (Windows)
### Build Skia
1. Install depot_tools
### Install depot_tools
2. Clone the skia Repo
```
git clone https://skia.googlesource.com/skia.git
cd skia
git checkout chrome/m85
python2 tools/git-sync-deps
```
3. Install LLVM
https://clang.llvm.org/get_started.html
4. Build skia
```
bin/gn gen out/Debug
```
Update out/Debug/args.gn with the following content:
```
clang_win = "C:\Program Files\LLVM"
win_vc = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC"
cc = "clang"
cxx = "clang++"
is_debug = true
skia_use_angle = true
skia_use_egl = true
extra_cflags = [
"/MTd",
"-I../../third_party/externals/angle2/include",
]
```
```
ninja -C out/Debug -k 0
```
Ignore this error: "lld-link: error: could not open 'EGL': no such file or directory"
convert icudtl.dat to object file in skia
```
cd SkiaRoot/third_party/externals/icu/flutter/
ld -r -b binary -o icudtl.o icudtl.dat
```
### Build flutter fml
### Build flutter txt
1. Setting up the Engine development environment

Apply the following diff:
```
diff --git a/fml/BUILD.gn b/fml/BUILD.gn
index 9b5626e78..da1322ce5 100644
--- a/fml/BUILD.gn
+++ b/fml/BUILD.gn
@@ -295,3 +295,10 @@ executable("fml_benchmarks") {
"//flutter/runtime:libdart",
--- a/third_party/txt/BUILD.gn
+++ b/third_party/txt/BUILD.gn
@@ -141,6 +141,7 @@ source_set("txt") {
"//third_party/harfbuzz",
"//third_party/icu",
"//third_party/skia",
+ "//third_party/skia/modules/skottie",
deps = [
@@ -339,3 +340,10 @@ executable("txt_benchmarks") {
deps += [ "//third_party/skia/modules/skparagraph" ]
}
+static_library("fml_lib") {
+static_library("txt_lib") {
+ "//flutter/fml",
+ ":txt",
update `out\host_debug_unopt\args.gn`
```
skia_use_angle = true
skia_use_egl = true
```
update skia
```
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -524,6 +524,7 @@ optional("gpu") {
if (skia_use_gl) {
public_defines += [ "SK_GL" ]
+ include_dirs = [ "//third_party/angle/include" ]
if (is_android) {
sources += [ "src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp" ]
```
ninja -C .\out\host_debug_unopt\ flutter/fml:fml_lib
ninja -C out\host_debug_unopt flutter/third_party/txt:txt_lib
### Create symbolic
### Build Skia
1. Install LLVM
https://clang.llvm.org/get_started.html
cmd
2. Build skia
cd <uiwidigets_dir>\engine
cd third_party   \\ create the directory if not exists
mklink /D skia <SKIA_ROOT>
cd $FLUTTER_ROOT/third_party/skia
python2 tools/git-sync-deps
bin/gn gen out/Debug
Flutter engine txt include skia header in this pattern 'third_party/skia/*', so without symbolic, the txt lib will include skia
header file in flutter engine, instead of headers in skia repo.
### Build Engine
Update out/Debug/args.gn with the following content:
```
clang_win = "C:\Program Files\LLVM/third_party/skia"
win_vc = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC"
cc = "clang"
cxx = "clang++"
is_debug = true
skia_use_angle = true
skia_use_egl = true
extra_cflags = [
"/MTd",
"-I../../third_party/externals/angle2/include",
]
cd <uiwidigets_dir>\engine
bee
## How to Build (Mac)
### Install Depot_tools
ninja -C out/Debug -k 0
git clone 'https://chromium.googlesource.com/chromium/tools/depot_tools.git'
Ignore this error: "lld-link: error: could not open 'EGL': no such file or directory"
export PATH="${PWD}/depot_tools:${PATH}"
convert icudtl.dat to object file in flutter
### Build Skia
cd flutterRoot/third_party/icu/flutter/
ld -r -b binary -o icudtl.o icudtl.dat
git clone https://skia.googlesource.com/skia.git
git checkout chrome/m85
### Build Engine
bin/gn gen out/Debug
python tools/git-sync-deps
ninja -C out/Debug -k 0
Please ensure that you are using python2 when executing "python tools/git-sync-deps".
cd <uiwidigets_dir>\engine
bee
```
## How to Build (Mac)
### Build Flutter Engine
### Build Dependencies
Setting up the Engine development environment

```
cd $FLUTTER_ROOT/flutter
Apply changes to BUILD.gn (src/flutter/fml/BUILD.gn)
Apply following to end of `flutter/third_party/txt/BUILD.gn`
diff --git a/fml/BUILD.gn b/fml/BUILD.gn
index 9b5626e78..da1322ce5 100644
--- a/fml/BUILD.gn
+++ b/fml/BUILD.gn
@@ -295,3 +295,10 @@ executable("fml_benchmarks") {
"//flutter/runtime:libdart",
diff --git a/third_party/txt/BUILD.gn b/third_party/txt/BUILD.gn
index 56b73a020..d42e88045 100644
--- a/third_party/txt/BUILD.gn
+++ b/third_party/txt/BUILD.gn
@@ -141,6 +141,7 @@ source_set("txt") {
"//third_party/harfbuzz",
"//third_party/icu",
"//third_party/skia",
+ "//third_party/skia/modules/skottie",
deps = [
@@ -339,3 +340,10 @@ executable("txt_benchmarks") {
deps += [ "//third_party/skia/modules/skparagraph" ]
}
+static_library("fml_lib") {
+static_library("txt_lib") {
+ "//flutter/fml",
+ ":txt",
Comiple engine:
Compile engine:
cd engine/src
cd $FLUTTER_ROOT
ninja -C ./out/host_debug_unopt/ flutter/fml:fml_lib
If the compilation fails because "no available Mac SDK is found" (in flutter-1.17 the build tool will only try to find Mac 10.XX SDKs), please modify the file "/src/build/Mac/find_sdk.py" under flutter root by setting "sdks" as your current sdk, e.g., ['11.0'].
### Build Lib
set SKIA_ROOT and FLUTTER_ROOT to your $PATH. SKIA_ROOT is the root folder of your skia repository. FLUTTER_ROOT is the root folder of your flutter engine repository.
Create symbolic as follows. Flutter engine txt include skia header in this pattern 'third_party/skia/*', so without symbolic, the txt lib will include skia
header file in flutter engine, instead of headers in skia repo.
add this line to the end of out/host_debug_unopt/args.gn:
```
icu_use_data_file=false
```
cmd
finally run ninja:
cd <uiwidigets_dir>\engine
cd third_party   \\ create the directory if not exists
ln -s <SKIA_ROOT> skia
ninja -C out/host_debug_unopt/ flutter/third_party/txt:txt_lib
If the compilation fails because "no available Mac SDK is found" (in flutter-1.17 the build tool will only try to find Mac 10.XX SDKs), please modify the file "/src/build/Mac/find_sdk.py" under flutter root by setting "sdks" as your current sdk, e.g., ['11.0'].
mono bee.exe
mono bee.exe mac
```

3
engine/src/shell/platform/unity/darwin/macos/uiwidgets_panel.mm


args.struct_size = sizeof(UIWidgetsProjectArgs);
args.assets_path = streaming_assets_path;
args.font_asset = settings;
//TODO: not support icu yet
//args.icu_mapper = GetICUStaticMapping;
args.command_line_argc = 0;
args.command_line_argv = nullptr;
args.platform_message_callback =

4
engine/src/shell/platform/unity/windows/unity_surface_manager.cc


EGLint displayAttribs[] = {EGL_PLATFORM_ANGLE_TYPE_ANGLE,
EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
EGL_PLATFORM_ANGLE_D3D_LUID_HIGH_ANGLE,
// EGL_PLATFORM_ANGLE_D3D_LUID_HIGH_ANGLE,
EGL_PLATFORM_ANGLE_D3D_LUID_LOW_ANGLE,
// EGL_PLATFORM_ANGLE_D3D_LUID_LOW_ANGLE,
adapter_desc.AdapterLuid.LowPart,
EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE,
EGL_TRUE,

正在加载...
取消
保存