Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
10f9cab4
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,发现更多精彩内容 >>
未验证
提交
10f9cab4
编写于
10月 16, 2018
作者:
C
Chinmay Garde
提交者:
GitHub
10月 16, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Ensure that the platform view is created and destroyed when running the shell unittests. (#6560)
上级
df5f4207
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
162 addition
and
47 deletion
+162
-47
shell/common/BUILD.gn
shell/common/BUILD.gn
+10
-1
shell/common/shell_unittests.cc
shell/common/shell_unittests.cc
+101
-9
shell/gpu/BUILD.gn
shell/gpu/BUILD.gn
+46
-0
shell/gpu/gpu.gni
shell/gpu/gpu.gni
+5
-37
未找到文件。
shell/common/BUILD.gn
浏览文件 @
10f9cab4
...
...
@@ -3,6 +3,7 @@
# found in the LICENSE file.
import("$flutter_root/testing/testing.gni")
import("$flutter_root/shell/gpu/gpu.gni")
# Template to generate a dart embedder resource.cc file.
# Required invoker inputs:
...
...
@@ -107,8 +108,8 @@ source_set("common") {
public_deps = [
"$flutter_root/shell/version",
"$flutter_root/third_party/txt",
"//third_party/tonic",
"//third_party/rapidjson",
"//third_party/tonic",
]
public_configs = [ "$flutter_root:config" ]
...
...
@@ -139,12 +140,20 @@ template("shell_host_executable") {
}
}
shell_gpu_configuration("shell_unittests_gpu_configuration") {
enable_software = true
enable_vulkan = false
enable_gl = false
}
shell_host_executable("shell_unittests") {
sources = [
"shell_unittests.cc",
]
deps = [
":shell_unittests_gpu_configuration",
"$flutter_root/shell/",
"$flutter_root/testing",
]
}
...
...
shell/common/shell_unittests.cc
浏览文件 @
10f9cab4
...
...
@@ -14,6 +14,7 @@
#include "flutter/shell/common/rasterizer.h"
#include "flutter/shell/common/shell.h"
#include "flutter/shell/common/thread_host.h"
#include "flutter/shell/gpu/gpu_surface_software.h"
#include "gtest/gtest.h"
#define CURRENT_TEST_NAME \
...
...
@@ -23,6 +24,64 @@
namespace
shell
{
class
TestPlatformView
:
public
PlatformView
,
public
GPUSurfaceSoftwareDelegate
{
public:
TestPlatformView
(
PlatformView
::
Delegate
&
delegate
,
blink
::
TaskRunners
task_runners
)
:
PlatformView
(
delegate
,
std
::
move
(
task_runners
))
{}
private:
// |PlatformView|
std
::
unique_ptr
<
Surface
>
CreateRenderingSurface
()
override
{
return
std
::
make_unique
<
GPUSurfaceSoftware
>
(
this
);
}
// |GPUSurfaceSoftwareDelegate|
virtual
sk_sp
<
SkSurface
>
AcquireBackingStore
(
const
SkISize
&
size
)
override
{
return
SkSurface
::
MakeRasterN32Premul
(
size
.
width
(),
size
.
height
());
}
// |GPUSurfaceSoftwareDelegate|
virtual
bool
PresentBackingStore
(
sk_sp
<
SkSurface
>
backing_store
)
override
{
return
true
;
}
FML_DISALLOW_COPY_AND_ASSIGN
(
TestPlatformView
);
};
static
bool
ValidateShell
(
Shell
*
shell
)
{
if
(
!
shell
)
{
return
false
;
}
if
(
!
shell
->
IsSetup
())
{
return
false
;
}
{
fml
::
AutoResetWaitableEvent
latch
;
fml
::
TaskRunner
::
RunNowOrPostTask
(
shell
->
GetTaskRunners
().
GetPlatformTaskRunner
(),
[
shell
,
&
latch
]()
{
shell
->
GetPlatformView
()
->
NotifyCreated
();
latch
.
Signal
();
});
latch
.
Wait
();
}
{
fml
::
AutoResetWaitableEvent
latch
;
fml
::
TaskRunner
::
RunNowOrPostTask
(
shell
->
GetTaskRunners
().
GetPlatformTaskRunner
(),
[
shell
,
&
latch
]()
{
shell
->
GetPlatformView
()
->
NotifyDestroyed
();
latch
.
Signal
();
});
latch
.
Wait
();
}
return
true
;
}
TEST
(
ShellTest
,
InitializeWithInvalidThreads
)
{
blink
::
Settings
settings
=
{};
settings
.
task_observer_add
=
[](
intptr_t
,
fml
::
closure
)
{};
...
...
@@ -31,7 +90,8 @@ TEST(ShellTest, InitializeWithInvalidThreads) {
auto
shell
=
Shell
::
Create
(
std
::
move
(
task_runners
),
settings
,
[](
Shell
&
shell
)
{
return
std
::
make_unique
<
PlatformView
>
(
shell
,
shell
.
GetTaskRunners
());
return
std
::
make_unique
<
TestPlatformView
>
(
shell
,
shell
.
GetTaskRunners
());
},
[](
Shell
&
shell
)
{
return
std
::
make_unique
<
Rasterizer
>
(
shell
.
GetTaskRunners
());
...
...
@@ -54,12 +114,13 @@ TEST(ShellTest, InitializeWithDifferentThreads) {
auto
shell
=
Shell
::
Create
(
std
::
move
(
task_runners
),
settings
,
[](
Shell
&
shell
)
{
return
std
::
make_unique
<
PlatformView
>
(
shell
,
shell
.
GetTaskRunners
());
return
std
::
make_unique
<
TestPlatformView
>
(
shell
,
shell
.
GetTaskRunners
());
},
[](
Shell
&
shell
)
{
return
std
::
make_unique
<
Rasterizer
>
(
shell
.
GetTaskRunners
());
});
ASSERT_TRUE
(
shell
);
ASSERT_TRUE
(
ValidateShell
(
shell
.
get
())
);
}
TEST
(
ShellTest
,
InitializeWithSingleThread
)
{
...
...
@@ -74,12 +135,13 @@ TEST(ShellTest, InitializeWithSingleThread) {
auto
shell
=
Shell
::
Create
(
std
::
move
(
task_runners
),
settings
,
[](
Shell
&
shell
)
{
return
std
::
make_unique
<
PlatformView
>
(
shell
,
shell
.
GetTaskRunners
());
return
std
::
make_unique
<
TestPlatformView
>
(
shell
,
shell
.
GetTaskRunners
());
},
[](
Shell
&
shell
)
{
return
std
::
make_unique
<
Rasterizer
>
(
shell
.
GetTaskRunners
());
});
ASSERT_TRUE
(
shell
);
ASSERT_TRUE
(
ValidateShell
(
shell
.
get
())
);
}
TEST
(
ShellTest
,
InitializeWithSingleThreadWhichIsTheCallingThread
)
{
...
...
@@ -93,12 +155,13 @@ TEST(ShellTest, InitializeWithSingleThreadWhichIsTheCallingThread) {
auto
shell
=
Shell
::
Create
(
std
::
move
(
task_runners
),
settings
,
[](
Shell
&
shell
)
{
return
std
::
make_unique
<
PlatformView
>
(
shell
,
shell
.
GetTaskRunners
());
return
std
::
make_unique
<
TestPlatformView
>
(
shell
,
shell
.
GetTaskRunners
());
},
[](
Shell
&
shell
)
{
return
std
::
make_unique
<
Rasterizer
>
(
shell
.
GetTaskRunners
());
});
ASSERT_TRUE
(
shell
);
ASSERT_TRUE
(
ValidateShell
(
shell
.
get
())
);
}
TEST
(
ShellTest
,
InitializeWithMultipleThreadButCallingThreadAsPlatformThread
)
{
...
...
@@ -117,12 +180,41 @@ TEST(ShellTest, InitializeWithMultipleThreadButCallingThreadAsPlatformThread) {
auto
shell
=
Shell
::
Create
(
std
::
move
(
task_runners
),
settings
,
[](
Shell
&
shell
)
{
return
std
::
make_unique
<
PlatformView
>
(
shell
,
shell
.
GetTaskRunners
());
return
std
::
make_unique
<
TestPlatformView
>
(
shell
,
shell
.
GetTaskRunners
());
},
[](
Shell
&
shell
)
{
return
std
::
make_unique
<
Rasterizer
>
(
shell
.
GetTaskRunners
());
});
ASSERT_TRUE
(
ValidateShell
(
shell
.
get
()));
}
// Reported in Bug: Engine deadlocks when gpu and platforms threads are the same
// #21398 (https://github.com/flutter/flutter/issues/21398)
TEST
(
ShellTest
,
DISABLED_InitializeWithGPUAndPlatformThreadsTheSame
)
{
blink
::
Settings
settings
=
{};
settings
.
task_observer_add
=
[](
intptr_t
,
fml
::
closure
)
{};
settings
.
task_observer_remove
=
[](
intptr_t
)
{};
ThreadHost
thread_host
(
"io.flutter.test."
+
CURRENT_TEST_NAME
+
"."
,
ThreadHost
::
Type
::
Platform
|
ThreadHost
::
Type
::
IO
|
ThreadHost
::
Type
::
UI
);
blink
::
TaskRunners
task_runners
(
"test"
,
thread_host
.
platform_thread
->
GetTaskRunner
(),
// platform
thread_host
.
platform_thread
->
GetTaskRunner
(),
// gpu
thread_host
.
ui_thread
->
GetTaskRunner
(),
// ui
thread_host
.
io_thread
->
GetTaskRunner
()
// io
);
auto
shell
=
Shell
::
Create
(
std
::
move
(
task_runners
),
settings
,
[](
Shell
&
shell
)
{
return
std
::
make_unique
<
TestPlatformView
>
(
shell
,
shell
.
GetTaskRunners
());
},
[](
Shell
&
shell
)
{
return
std
::
make_unique
<
Rasterizer
>
(
shell
.
GetTaskRunners
());
});
ASSERT_TRUE
(
shell
);
ASSERT_TRUE
(
ValidateShell
(
shell
.
get
())
);
}
}
// namespace shell
shell/gpu/BUILD.gn
0 → 100644
浏览文件 @
10f9cab4
# Copyright 2018 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("$flutter_root/shell/config.gni")
gpu_dir = "$flutter_root/shell/gpu"
gpu_common_deps = [
"$flutter_root/common",
"$flutter_root/flow",
"$flutter_root/fml",
"$flutter_root/shell/common",
"$flutter_root/synchronization",
"//third_party/skia",
]
source_set("gpu_surface_software") {
sources = [
"$gpu_dir/gpu_surface_software.cc",
"$gpu_dir/gpu_surface_software.h",
]
deps = gpu_common_deps
}
source_set("gpu_surface_gl") {
sources = [
"$gpu_dir/gpu_surface_gl.cc",
"$gpu_dir/gpu_surface_gl.h",
]
deps = gpu_common_deps + [ "//third_party/skia:gpu" ]
}
source_set("gpu_surface_vulkan") {
sources = [
"$gpu_dir/gpu_surface_vulkan.cc",
"$gpu_dir/gpu_surface_vulkan.h",
]
deps = gpu_common_deps + [
"//third_party/skia:gpu",
"$flutter_root/vulkan",
]
}
shell/gpu/gpu.gni
浏览文件 @
10f9cab4
...
...
@@ -12,51 +12,19 @@ template("shell_gpu_configuration") {
assert(defined(invoker.enable_gl),
"Caller must declare if the Open GL backend must be enabled.")
source_set(target_name) {
# vulkan_backend_enabled = shell_enable_vulkan
# gl_backend_enabled = !is_fuchsia
# software_backend_enabled = true
sources = []
gpu_dir = "$flutter_root/shell/gpu"
group(target_name) {
public_deps = []
if (invoker.enable_software) {
sources += [
"$gpu_dir/gpu_surface_software.cc",
"$gpu_dir/gpu_surface_software.h",
]
public_deps += [ "$flutter_root/shell/gpu:gpu_surface_software" ]
}
if (invoker.enable_gl) {
sources += [
"$gpu_dir/gpu_surface_gl.cc",
"$gpu_dir/gpu_surface_gl.h",
]
}
if (invoker.enable_vulkan) {
sources += [
"$gpu_dir/gpu_surface_vulkan.cc",
"$gpu_dir/gpu_surface_vulkan.h",
]
}
deps = [
"$flutter_root/common",
"$flutter_root/flow",
"$flutter_root/fml",
"$flutter_root/shell/common",
"$flutter_root/synchronization",
"//third_party/skia",
]
if (invoker.enable_vulkan || invoker.enable_gl) {
deps += [ "//third_party/skia:gpu" ]
public_deps += [ "$flutter_root/shell/gpu:gpu_surface_gl" ]
}
if (invoker.enable_vulkan) {
deps += [ "$flutter_root/
vulkan" ]
public_deps += [ "$flutter_root/shell/gpu:gpu_surface_
vulkan" ]
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录