Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
296c1c90
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,发现更多精彩内容 >>
提交
296c1c90
编写于
3月 10, 2016
作者:
C
Chinmay Garde
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2484 from chinmaygarde/master
Allow PlatformMacMain to be called multiple times
上级
d1515e67
d1376fc9
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
75 addition
and
92 deletion
+75
-92
BUILD.gn
BUILD.gn
+7
-1
sky/shell/platform/ios/flutter_view_controller.mm
sky/shell/platform/ios/flutter_view_controller.mm
+5
-5
sky/shell/platform/ios/main_ios.mm
sky/shell/platform/ios/main_ios.mm
+5
-4
sky/shell/platform/mac/main_mac.mm
sky/shell/platform/mac/main_mac.mm
+17
-17
sky/shell/platform/mac/platform_mac.h
sky/shell/platform/mac/platform_mac.h
+1
-6
sky/shell/platform/mac/platform_mac.mm
sky/shell/platform/mac/platform_mac.mm
+40
-59
未找到文件。
BUILD.gn
浏览文件 @
296c1c90
...
@@ -7,8 +7,14 @@ group("default") {
...
@@ -7,8 +7,14 @@ group("default") {
testonly = true
testonly = true
deps = [
deps = [
"//sky",
"//sky",
"//sky/services/dynamic:sdk_lib",
]
]
if (is_ios) {
deps += [
"//sky/services/dynamic:sdk_lib",
"//sky/shell:flutter_framework",
]
}
}
}
group("dist") {
group("dist") {
...
...
sky/shell/platform/ios/flutter_view_controller.mm
浏览文件 @
296c1c90
...
@@ -40,11 +40,6 @@
...
@@ -40,11 +40,6 @@
if
(
self
)
{
if
(
self
)
{
_dartBundle
=
[
dartBundleOrNil
retain
];
_dartBundle
=
[
dartBundleOrNil
retain
];
NSBundle
*
bundle
=
[
NSBundle
bundleForClass
:[
self
class
]];
NSString
*
icuDataPath
=
[
bundle
pathForResource
:
@"icudtl"
ofType
:
@"dat"
];
sky
::
shell
::
PlatformMacMain
(
0
,
nullptr
,
icuDataPath
.
UTF8String
,
nullptr
);
[
self
performCommonViewControllerInitialization
];
[
self
performCommonViewControllerInitialization
];
}
}
...
@@ -75,6 +70,11 @@
...
@@ -75,6 +70,11 @@
_initialized
=
YES
;
_initialized
=
YES
;
NSBundle
*
bundle
=
[
NSBundle
bundleForClass
:[
self
class
]];
NSString
*
icuDataPath
=
[
bundle
pathForResource
:
@"icudtl"
ofType
:
@"dat"
];
sky
::
shell
::
PlatformMacMain
(
0
,
nullptr
,
icuDataPath
.
UTF8String
);
_orientationPreferences
=
UIInterfaceOrientationMaskAll
;
_orientationPreferences
=
UIInterfaceOrientationMaskAll
;
_dynamicServiceLoader
=
[[
FlutterDynamicServiceLoader
alloc
]
init
];
_dynamicServiceLoader
=
[[
FlutterDynamicServiceLoader
alloc
]
init
];
_viewportMetrics
=
sky
::
ViewportMetrics
::
New
();
_viewportMetrics
=
sky
::
ViewportMetrics
::
New
();
...
...
sky/shell/platform/ios/main_ios.mm
浏览文件 @
296c1c90
...
@@ -8,8 +8,9 @@
...
@@ -8,8 +8,9 @@
#include "sky/shell/platform/mac/platform_mac.h"
#include "sky/shell/platform/mac/platform_mac.h"
int
main
(
int
argc
,
const
char
*
argv
[])
{
int
main
(
int
argc
,
const
char
*
argv
[])
{
return
sky
::
shell
::
PlatformMacMain
(
argc
,
argv
,
""
,
^
()
{
// iOS does use the FlutterViewController that initializes the platform but
return
UIApplicationMain
(
argc
,
(
char
**
)
argv
,
nil
,
// we have the command line args here. So call it now.
NSStringFromClass
([
FlutterAppDelegate
class
]));
sky
::
shell
::
PlatformMacMain
(
argc
,
argv
,
""
);
});
return
UIApplicationMain
(
argc
,
(
char
**
)
argv
,
nil
,
NSStringFromClass
([
FlutterAppDelegate
class
]));
}
}
sky/shell/platform/mac/main_mac.mm
浏览文件 @
296c1c90
...
@@ -32,21 +32,21 @@ void AttachMessageLoopToMainRunLoop(void) {
...
@@ -32,21 +32,21 @@ void AttachMessageLoopToMainRunLoop(void) {
int
main
(
int
argc
,
const
char
*
argv
[])
{
int
main
(
int
argc
,
const
char
*
argv
[])
{
[
SkyApplication
sharedApplication
];
[
SkyApplication
sharedApplication
];
return
sky
::
shell
::
PlatformMacMain
(
argc
,
argv
,
""
,
^
()
{
sky
::
shell
::
PlatformMacMain
(
argc
,
argv
,
""
);
base
::
CommandLine
&
command_line
=
*
base
::
CommandLine
::
ForCurrentProcess
();
if
(
command_line
.
HasSwitch
(
sky
::
shell
::
switches
::
kHelp
))
{
base
::
CommandLine
&
command_line
=
*
base
::
CommandLine
::
ForCurrentProcess
();
sky
::
shell
::
switches
::
PrintUsage
(
"SkyShell"
);
if
(
command_line
.
HasSwitch
(
sky
::
shell
::
switches
::
kHelp
))
{
return
EXIT_SUCCESS
;
sky
::
shell
::
switches
::
PrintUsage
(
"SkyShell"
)
;
}
return
EXIT_SUCCESS
;
}
if
(
command_line
.
HasSwitch
(
sky
::
shell
::
switches
::
kNonInteractive
))
{
if
(
!
sky
::
shell
::
InitForTesting
())
if
(
command_line
.
HasSwitch
(
sky
::
shell
::
switches
::
kNonInteractive
))
{
return
1
;
if
(
!
sky
::
shell
::
InitForTesting
())
base
::
MessageLoop
::
current
()
->
Run
()
;
return
1
;
return
EXIT_SUCCESS
;
base
::
MessageLoop
::
current
()
->
Run
()
;
}
return
EXIT_SUCCESS
;
}
sky
::
shell
::
AttachMessageLoopToMainRunLoop
();
return
NSApplicationMain
(
argc
,
argv
);
sky
::
shell
::
AttachMessageLoopToMainRunLoop
(
);
}
);
return
NSApplicationMain
(
argc
,
argv
);
}
}
sky/shell/platform/mac/platform_mac.h
浏览文件 @
296c1c90
...
@@ -10,12 +10,7 @@
...
@@ -10,12 +10,7 @@
namespace
sky
{
namespace
sky
{
namespace
shell
{
namespace
shell
{
typedef
int
(
^
PlatformMacMainCallback
)(
void
);
void
PlatformMacMain
(
int
argc
,
const
char
*
argv
[],
std
::
string
icu_data_path
);
int
PlatformMacMain
(
int
argc
,
const
char
*
argv
[],
std
::
string
icu_data_path
,
PlatformMacMainCallback
callback
);
bool
AttemptLaunchFromCommandLineSwitches
(
sky
::
SkyEnginePtr
&
engine
);
bool
AttemptLaunchFromCommandLineSwitches
(
sky
::
SkyEnginePtr
&
engine
);
...
...
sky/shell/platform/mac/platform_mac.mm
浏览文件 @
296c1c90
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop.h"
#include "mojo/edk/embedder/embedder.h"
#include "mojo/edk/embedder/embedder.h"
#include "mojo/edk/embedder/simple_platform_support.h"
#include "mojo/edk/embedder/simple_platform_support.h"
#include "sky/engine/wtf/MakeUnique.h"
#include "sky/shell/shell.h"
#include "sky/shell/shell.h"
#include "sky/shell/switches.h"
#include "sky/shell/switches.h"
#include "sky/shell/tracing_controller.h"
#include "sky/shell/tracing_controller.h"
...
@@ -45,80 +46,60 @@ static void RedirectIOConnectionsToSyslog() {
...
@@ -45,80 +46,60 @@ static void RedirectIOConnectionsToSyslog() {
#endif
#endif
}
}
int
PlatformMacMainOnce
(
int
argc
,
class
EmbedderState
{
const
char
*
argv
[],
public:
std
::
string
icu_data_path
,
EmbedderState
(
int
argc
,
const
char
*
argv
[],
std
::
string
icu_data_path
)
{
PlatformMacMainCallback
callback
)
{
RedirectIOConnectionsToSyslog
();
CHECK
([
NSThread
currentThread
]
==
[
NSThread
mainThread
])
<<
"Platform initialization must occur on the main platform thread"
;
base
::
mac
::
ScopedNSAutoreleasePool
pool
;
base
::
CommandLine
::
Init
(
argc
,
argv
)
;
base
::
PlatformThread
::
SetName
(
"platform_main"
);
InitializeLogging
(
);
base
::
AtExitManager
exit_manager
;
base
::
CommandLine
&
command_line
=
*
base
::
CommandLine
::
ForCurrentProcess
();
if
(
command_line
.
HasSwitch
(
sky
::
shell
::
switches
::
kTraceStartup
))
{
// Usually, all tracing within flutter is managed via the tracing
// controller
// The tracing controller is accessed via the shell instance. This means
// that tracing can only be enabled once that instance is created. Traces
// early in startup are lost. This enables tracing only in base manually
// till the tracing controller takes over.
sky
::
shell
::
TracingController
::
StartBaseTracing
();
}
RedirectIOConnectionsToSyslog
();
// This is about as early as tracing of any kind can start. Add an instant
// marker that can be used as a reference for startup.
TRACE_EVENT_INSTANT0
(
"flutter"
,
"main"
,
TRACE_EVENT_SCOPE_PROCESS
);
bool
result
=
false
;
#if TARGET_OS_IPHONE
// One cannot start the message loop on the platform main thread. Instead,
// we attach to the CFRunLoop
embedder_message_loop_
.
Attach
();
#endif
result
=
base
::
CommandLine
::
Init
(
argc
,
argv
);
mojo
::
embedder
::
Init
(
mojo
::
embedder
::
CreateSimplePlatformSupport
());
DLOG_ASSERT
(
result
);
InitializeLogging
(
);
CHECK
(
gfx
::
GLSurface
::
InitializeOneOff
()
);
base
::
CommandLine
&
command_line
=
*
base
::
CommandLine
::
ForCurrentProcess
();
sky
::
shell
::
Shell
::
InitStandalone
(
icu_data_path
);
if
(
command_line
.
HasSwitch
(
sky
::
shell
::
switches
::
kTraceStartup
))
{
// Usually, all tracing within flutter is managed via the tracing controller
// The tracing controller is accessed via the shell instance. This means
// that tracing can only be enabled once that instance is created. Traces
// early in startup are lost. This enables tracing only in base manually
// till the tracing controller takes over.
sky
::
shell
::
TracingController
::
StartBaseTracing
();
}
}
// This is about as early as tracing of any kind can start. Add an instant
private:
// marker that can be used as a reference for startup.
base
::
AtExitManager
exit_manager_
;
TRACE_EVENT_INSTANT0
(
"flutter"
,
"main"
,
TRACE_EVENT_SCOPE_PROCESS
);
base
::
MessageLoopForUI
embedder_message_loop_
;
std
::
unique_ptr
<
base
::
MessageLoopForUI
>
message_loop
(
new
base
::
MessageLoopForUI
());
#if TARGET_OS_IPHONE
// One cannot start the message loop on the platform main thread. Instead,
// we attach to the CFRunLoop
message_loop
->
Attach
();
#endif
mojo
::
embedder
::
Init
(
mojo
::
embedder
::
CreateSimplePlatformSupport
());
CHECK
(
gfx
::
GLSurface
::
InitializeOneOff
());
sky
::
shell
::
Shell
::
InitStandalone
(
icu_data_path
);
int
exit_code
=
callback
!=
nullptr
?
callback
()
:
EXIT_SUCCESS
;
DISALLOW_COPY_AND_ASSIGN
(
EmbedderState
);
};
#if !TARGET_OS_IPHONE
void
PlatformMacMain
(
int
argc
,
const
char
*
argv
[],
std
::
string
icu_data_path
)
{
if
(
callback
!=
nullptr
)
{
CHECK
([
NSThread
isMainThread
])
// If we control the embedder, the callback is what we use to wrap
<<
"Embedder initialization must occur on the main platform thread"
;
// UIApplicationMain. If we are here, it means that that method has returned
// and we need to perform cleanup.
message_loop
->
QuitNow
();
}
#endif
return
exit_code
;
static
std
::
unique_ptr
<
EmbedderState
>
g_embedder
;
}
static
std
::
once_flag
once_main
;
int
PlatformMacMain
(
int
argc
,
std
::
call_once
(
once_main
,
[
&
]()
{
const
char
*
argv
[],
g_embedder
=
WTF
::
MakeUnique
<
EmbedderState
>
(
argc
,
argv
,
icu_data_path
);
std
::
string
icu_data_path
,
PlatformMacMainCallback
callback
)
{
__block
int
result
=
EXIT_SUCCESS
;
static
dispatch_once_t
onceToken
;
dispatch_once
(
&
onceToken
,
^
{
result
=
PlatformMacMainOnce
(
argc
,
argv
,
icu_data_path
,
callback
);
});
});
return
result
;
}
}
static
bool
FlagsValidForCommandLineLaunch
(
const
std
::
string
&
dart_main
,
static
bool
FlagsValidForCommandLineLaunch
(
const
std
::
string
&
dart_main
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录