Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
4e9459e0
E
engine
项目概览
weixin_43355755
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
4e9459e0
编写于
10月 30, 2020
作者:
G
gaaclarke
提交者:
GitHub
10月 30, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactored the FlutterEngine to make it easier to implement spawn functionality (#21890)
上级
9b34207a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
61 addition
and
39 deletion
+61
-39
shell/common/thread_host.cc
shell/common/thread_host.cc
+2
-1
shell/common/thread_host.h
shell/common/thread_host.h
+1
-0
shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
+58
-38
未找到文件。
shell/common/thread_host.cc
浏览文件 @
4e9459e0
...
...
@@ -10,7 +10,8 @@ ThreadHost::ThreadHost() = default;
ThreadHost
::
ThreadHost
(
ThreadHost
&&
)
=
default
;
ThreadHost
::
ThreadHost
(
std
::
string
name_prefix
,
uint64_t
mask
)
{
ThreadHost
::
ThreadHost
(
std
::
string
name_prefix_arg
,
uint64_t
mask
)
:
name_prefix
(
name_prefix_arg
)
{
if
(
mask
&
ThreadHost
::
Type
::
Platform
)
{
platform_thread
=
std
::
make_unique
<
fml
::
Thread
>
(
name_prefix
+
".platform"
);
}
...
...
shell/common/thread_host.h
浏览文件 @
4e9459e0
...
...
@@ -22,6 +22,7 @@ struct ThreadHost {
Profiler
=
1
<<
4
,
};
std
::
string
name_prefix
;
std
::
unique_ptr
<
fml
::
Thread
>
platform_thread
;
std
::
unique_ptr
<
fml
::
Thread
>
ui_thread
;
std
::
unique_ptr
<
fml
::
Thread
>
raster_thread
;
...
...
shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
浏览文件 @
4e9459e0
...
...
@@ -373,10 +373,11 @@ static constexpr int kNumProfilerSamplesPerSec = 5;
_keyEventChannel
.
reset
();
}
-
(
void
)
startProfiler
:(
NSString
*
)
threadLabel
{
-
(
void
)
startProfiler
{
FML_DCHECK
(
!
_threadHost
.
name_prefix
.
empty
());
_profiler_metrics
=
std
::
make_unique
<
flutter
::
ProfilerMetricsIOS
>
();
_profiler
=
std
::
make_unique
<
flutter
::
SamplingProfiler
>
(
threadLabel
.
UTF8String
,
_threadHost
.
profiler_thread
->
GetTaskRunner
(),
_threadHost
.
name_prefix
.
c_str
()
,
_threadHost
.
profiler_thread
->
GetTaskRunner
(),
[
self
]()
{
return
self
->
_profiler_metrics
->
GenerateSample
();
},
kNumProfilerSamplesPerSec
);
_profiler
->
Start
();
}
...
...
@@ -487,6 +488,46 @@ static constexpr int kNumProfilerSamplesPerSec = 5;
libraryOrNil:
libraryOrNil
]);
}
-
(
void
)
setupShell
:(
std
::
unique_ptr
<
flutter
::
Shell
>
)
shell
withObservatoryPublication
:(
BOOL
)
doesObservatoryPublication
{
_shell
=
std
::
move
(
shell
);
[
self
setupChannels
];
[
self
onLocaleUpdated
:
nil
];
[
self
initializeDisplays
];
_publisher
.
reset
([[
FlutterObservatoryPublisher
alloc
]
initWithEnableObservatoryPublication:
doesObservatoryPublication
]);
[
self
maybeSetupPlatformViewChannels
];
_shell
->
GetIsGpuDisabledSyncSwitch
()
->
SetSwitch
(
_isGpuDisabled
?
true
:
false
);
}
+
(
BOOL
)
isProfilerEnabled
{
bool
profilerEnabled
=
false
;
#if (FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG) || \
(FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_PROFILE)
profilerEnabled
=
true
;
#endif
return
profilerEnabled
;
}
+
(
NSString
*
)
generateThreadLabel
:(
NSString
*
)
labelPrefix
{
static
size_t
s_shellCount
=
0
;
return
[
NSString
stringWithFormat
:
@"%@.%zu"
,
labelPrefix
,
++
s_shellCount
];
}
+
(
flutter
::
ThreadHost
)
makeThreadHost
:(
NSString
*
)
threadLabel
{
// The current thread will be used as the platform thread. Ensure that the message loop is
// initialized.
fml
::
MessageLoop
::
EnsureInitializedForCurrentThread
();
uint32_t
threadHostType
=
flutter
::
ThreadHost
::
Type
::
UI
|
flutter
::
ThreadHost
::
Type
::
GPU
|
flutter
::
ThreadHost
::
Type
::
IO
;
if
([
FlutterEngine
isProfilerEnabled
])
{
threadHostType
=
threadHostType
|
flutter
::
ThreadHost
::
Type
::
Profiler
;
}
return
{
threadLabel
.
UTF8String
,
// label
threadHostType
};
}
-
(
BOOL
)
createShell
:(
NSString
*
)
entrypoint
libraryURI
:(
NSString
*
)
libraryURI
initialRoute
:(
NSString
*
)
initialRoute
{
...
...
@@ -495,7 +536,6 @@ static constexpr int kNumProfilerSamplesPerSec = 5;
return
NO
;
}
static
size_t
shellCount
=
1
;
self
.
initialRoute
=
initialRoute
;
auto
settings
=
[
_dartProject
.
get
()
settings
];
...
...
@@ -515,24 +555,8 @@ static constexpr int kNumProfilerSamplesPerSec = 5;
settings
.
advisory_script_uri
=
std
::
string
(
"main.dart"
);
}
const
auto
threadLabel
=
[
NSString
stringWithFormat
:
@"%@.%zu"
,
_labelPrefix
,
shellCount
++
];
// The current thread will be used as the platform thread. Ensure that the message loop is
// initialized.
fml
::
MessageLoop
::
EnsureInitializedForCurrentThread
();
uint32_t
threadHostType
=
flutter
::
ThreadHost
::
Type
::
UI
|
flutter
::
ThreadHost
::
Type
::
GPU
|
flutter
::
ThreadHost
::
Type
::
IO
;
bool
profilerEnabled
=
false
;
#if (FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG) || \
(FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_PROFILE)
profilerEnabled
=
true
;
#endif
if
(
profilerEnabled
)
{
threadHostType
=
threadHostType
|
flutter
::
ThreadHost
::
Type
::
Profiler
;
}
_threadHost
=
{
threadLabel
.
UTF8String
,
// label
threadHostType
};
NSString
*
threadLabel
=
[
FlutterEngine
generateThreadLabel
:
_labelPrefix
];
_threadHost
=
[
FlutterEngine
makeThreadHost
:
threadLabel
];
// Lambda captures by pointers to ObjC objects are fine here because the
// create call is synchronous.
...
...
@@ -554,26 +578,22 @@ static constexpr int kNumProfilerSamplesPerSec = 5;
);
// Create the shell. This is a blocking operation.
_shell
=
flutter
::
Shell
::
Create
(
std
::
move
(
task_runners
),
// task runners
std
::
move
(
platformData
),
// window data
std
::
move
(
settings
),
// settings
on_create_platform_view
,
// platform view creation
on_create_rasterizer
// rasterzier creation
);
if
(
_shell
==
nullptr
)
{
std
::
unique_ptr
<
flutter
::
Shell
>
shell
=
flutter
::
Shell
::
Create
(
std
::
move
(
task_runners
),
// task runners
std
::
move
(
platformData
),
// window data
std
::
move
(
settings
),
// settings
on_create_platform_view
,
// platform view creation
on_create_rasterizer
// rasterzier creation
);
if
(
shell
==
nullptr
)
{
FML_LOG
(
ERROR
)
<<
"Could not start a shell FlutterEngine with entrypoint: "
<<
entrypoint
.
UTF8String
;
}
else
{
[
self
setupChannels
];
[
self
onLocaleUpdated
:
nil
];
[
self
initializeDisplays
];
_publisher
.
reset
([[
FlutterObservatoryPublisher
alloc
]
initWithEnableObservatoryPublication:
settings
.
enable_observatory_publication
]);
[
self
maybeSetupPlatformViewChannels
];
_shell
->
GetIsGpuDisabledSyncSwitch
()
->
SetSwitch
(
_isGpuDisabled
?
true
:
false
);
if
(
profilerEnabled
)
{
[
self
startProfiler
:
threadLabel
];
[
self
setupShell
:
std
:
:
move
(
shell
)
withObservatoryPublication:
settings
.
enable_observatory_publication
];
if
([
FlutterEngine
isProfilerEnabled
])
{
[
self
startProfiler
];
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录