Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
faaf321b
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
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,发现更多精彩内容 >>
提交
faaf321b
编写于
10月 17, 2017
作者:
Z
Zachary Anderson
提交者:
GitHub
10月 17, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make Engine::RunBundle* reuse an existing RuntimeController (#4229)
上级
2528e533
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
48 addition
and
32 deletion
+48
-32
runtime/dart_controller.cc
runtime/dart_controller.cc
+27
-18
shell/common/engine.cc
shell/common/engine.cc
+10
-8
shell/platform/android/io/flutter/view/FlutterView.java
shell/platform/android/io/flutter/view/FlutterView.java
+11
-6
未找到文件。
runtime/dart_controller.cc
浏览文件 @
faaf321b
...
...
@@ -112,15 +112,18 @@ static void ReleaseFetchedBytes(uint8_t* buffer) {
tonic
::
DartErrorHandleType
DartController
::
RunFromKernel
(
const
std
::
vector
<
uint8_t
>&
kernel
)
{
tonic
::
DartState
::
Scope
scope
(
dart_state
());
// Copy kernel bytes and pass ownership of the copy to the Dart_LoadKernel,
// which is expected to release them.
uint8_t
*
kernel_bytes
=
nullptr
;
CopyVectorBytes
(
kernel
,
kernel_bytes
);
Dart_Handle
result
=
Dart_LoadKernel
(
Dart_ReadKernelBinary
(
kernel_bytes
,
kernel
.
size
(),
ReleaseFetchedBytes
));
LogIfError
(
result
);
tonic
::
DartErrorHandleType
error
=
tonic
::
GetErrorHandleType
(
result
);
tonic
::
DartErrorHandleType
error
=
tonic
::
kNoError
;
if
(
Dart_IsNull
(
Dart_RootLibrary
()))
{
// Copy kernel bytes and pass ownership of the copy to the Dart_LoadKernel,
// which is expected to release them.
uint8_t
*
kernel_bytes
=
nullptr
;
CopyVectorBytes
(
kernel
,
kernel_bytes
);
Dart_Handle
result
=
Dart_LoadKernel
(
Dart_ReadKernelBinary
(
kernel_bytes
,
kernel
.
size
(),
ReleaseFetchedBytes
));
LogIfError
(
result
);
error
=
tonic
::
GetErrorHandleType
(
result
);
}
if
(
SendStartMessage
(
Dart_RootLibrary
()))
{
return
tonic
::
kUnknownErrorType
;
}
...
...
@@ -141,9 +144,12 @@ tonic::DartErrorHandleType DartController::RunFromScriptSnapshot(
const
uint8_t
*
buffer
,
size_t
size
)
{
tonic
::
DartState
::
Scope
scope
(
dart_state
());
Dart_Handle
result
=
Dart_LoadScriptFromSnapshot
(
buffer
,
size
);
LogIfError
(
result
);
tonic
::
DartErrorHandleType
error
=
tonic
::
GetErrorHandleType
(
result
);
tonic
::
DartErrorHandleType
error
=
tonic
::
kNoError
;
if
(
Dart_IsNull
(
Dart_RootLibrary
()))
{
Dart_Handle
result
=
Dart_LoadScriptFromSnapshot
(
buffer
,
size
);
LogIfError
(
result
);
error
=
tonic
::
GetErrorHandleType
(
result
);
}
if
(
SendStartMessage
(
Dart_RootLibrary
()))
{
return
tonic
::
kUnknownErrorType
;
}
...
...
@@ -154,12 +160,15 @@ tonic::DartErrorHandleType DartController::RunFromSource(
const
std
::
string
&
main
,
const
std
::
string
&
packages
)
{
tonic
::
DartState
::
Scope
scope
(
dart_state
());
tonic
::
FileLoader
&
loader
=
dart_state
()
->
file_loader
();
if
(
!
packages
.
empty
()
&&
!
loader
.
LoadPackagesMap
(
ResolvePath
(
packages
)))
FXL_LOG
(
WARNING
)
<<
"Failed to load package map: "
<<
packages
;
Dart_Handle
result
=
loader
.
LoadScript
(
main
);
LogIfError
(
result
);
tonic
::
DartErrorHandleType
error
=
tonic
::
GetErrorHandleType
(
result
);
tonic
::
DartErrorHandleType
error
=
tonic
::
kNoError
;
if
(
Dart_IsNull
(
Dart_RootLibrary
()))
{
tonic
::
FileLoader
&
loader
=
dart_state
()
->
file_loader
();
if
(
!
packages
.
empty
()
&&
!
loader
.
LoadPackagesMap
(
ResolvePath
(
packages
)))
FXL_LOG
(
WARNING
)
<<
"Failed to load package map: "
<<
packages
;
Dart_Handle
result
=
loader
.
LoadScript
(
main
);
LogIfError
(
result
);
error
=
tonic
::
GetErrorHandleType
(
result
);
}
if
(
SendStartMessage
(
Dart_RootLibrary
()))
{
return
tonic
::
kCompilationErrorType
;
}
...
...
shell/common/engine.cc
浏览文件 @
faaf321b
...
...
@@ -496,14 +496,16 @@ void Engine::ConfigureAssetBundle(const std::string& path) {
void
Engine
::
ConfigureRuntime
(
const
std
::
string
&
script_uri
,
const
std
::
vector
<
uint8_t
>&
platform_kernel
)
{
runtime_
=
blink
::
RuntimeController
::
Create
(
this
);
runtime_
->
CreateDartController
(
std
::
move
(
script_uri
),
default_isolate_snapshot_data
,
default_isolate_snapshot_instr
,
platform_kernel
);
runtime_
->
SetViewportMetrics
(
viewport_metrics_
);
runtime_
->
SetLocale
(
language_code_
,
country_code_
);
runtime_
->
SetTextScaleFactor
(
text_scale_factor_
);
runtime_
->
SetSemanticsEnabled
(
semantics_enabled_
);
if
(
!
runtime_
)
{
runtime_
=
blink
::
RuntimeController
::
Create
(
this
);
runtime_
->
CreateDartController
(
std
::
move
(
script_uri
),
default_isolate_snapshot_data
,
default_isolate_snapshot_instr
,
platform_kernel
);
runtime_
->
SetViewportMetrics
(
viewport_metrics_
);
runtime_
->
SetLocale
(
language_code_
,
country_code_
);
runtime_
->
SetTextScaleFactor
(
text_scale_factor_
);
runtime_
->
SetSemanticsEnabled
(
semantics_enabled_
);
}
}
void
Engine
::
DidCreateMainIsolate
(
Dart_Isolate
isolate
)
{
...
...
shell/platform/android/io/flutter/view/FlutterView.java
浏览文件 @
faaf321b
...
...
@@ -173,11 +173,16 @@ public class FlutterView extends SurfaceView
StringCodec
.
INSTANCE
);
mFlutterSystemChannel
=
new
BasicMessageChannel
<>(
this
,
"flutter/system"
,
JSONMessageCodec
.
INSTANCE
);
PlatformPlugin
platformPlugin
=
new
PlatformPlugin
((
Activity
)
getContext
());
MethodChannel
flutterPlatformChannel
=
new
MethodChannel
(
this
,
"flutter/platform"
,
JSONMethodCodec
.
INSTANCE
);
flutterPlatformChannel
.
setMethodCallHandler
(
platformPlugin
);
addActivityLifecycleListener
(
platformPlugin
);
// TODO(plugins): Change PlatformPlugin to accept a Context. Disable the
// operations that require an Activity when a Context is passed.
if
(
getContext
()
instanceof
Activity
)
{
PlatformPlugin
platformPlugin
=
new
PlatformPlugin
((
Activity
)
getContext
());
MethodChannel
flutterPlatformChannel
=
new
MethodChannel
(
this
,
"flutter/platform"
,
JSONMethodCodec
.
INSTANCE
);
flutterPlatformChannel
.
setMethodCallHandler
(
platformPlugin
);
addActivityLifecycleListener
(
platformPlugin
);
}
mTextInputPlugin
=
new
TextInputPlugin
(
this
);
setLocale
(
getResources
().
getConfiguration
().
locale
);
...
...
@@ -285,7 +290,7 @@ public class FlutterView extends SurfaceView
message
.
put
(
"textScaleFactor"
,
textScaleFactor
);
mFlutterSystemChannel
.
send
(
message
);
}
private
void
setLocale
(
Locale
locale
)
{
mFlutterLocalizationChannel
.
invokeMethod
(
"setLocale"
,
Arrays
.
asList
(
locale
.
getLanguage
(),
locale
.
getCountry
()));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录