Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
693645e4
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,发现更多精彩内容 >>
未验证
提交
693645e4
编写于
2月 09, 2019
作者:
D
Dan Field
提交者:
GitHub
2月 09, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "Add mock capability to PerformanceOverlayLayer (#7537)" (#7765)
This reverts commit
5f3f3bd9
.
上级
d130f15a
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
11 addition
and
118 deletion
+11
-118
ci/licenses_golden/licenses_flutter
ci/licenses_golden/licenses_flutter
+0
-1
flow/BUILD.gn
flow/BUILD.gn
+0
-1
flow/layers/performance_overlay_layer.cc
flow/layers/performance_overlay_layer.cc
+10
-21
flow/layers/performance_overlay_layer.h
flow/layers/performance_overlay_layer.h
+1
-5
flow/layers/performance_overlay_layer_unittests.cc
flow/layers/performance_overlay_layer_unittests.cc
+0
-90
testing/resources/performance_overlay_gold.png
testing/resources/performance_overlay_gold.png
+0
-0
未找到文件。
ci/licenses_golden/licenses_flutter
浏览文件 @
693645e4
...
...
@@ -57,7 +57,6 @@ FILE: ../../../flutter/flow/layers/opacity_layer.cc
FILE: ../../../flutter/flow/layers/opacity_layer.h
FILE: ../../../flutter/flow/layers/performance_overlay_layer.cc
FILE: ../../../flutter/flow/layers/performance_overlay_layer.h
FILE: ../../../flutter/flow/layers/performance_overlay_layer_unittests.cc
FILE: ../../../flutter/flow/layers/physical_shape_layer.cc
FILE: ../../../flutter/flow/layers/physical_shape_layer.h
FILE: ../../../flutter/flow/layers/picture_layer.cc
...
...
flow/BUILD.gn
浏览文件 @
693645e4
...
...
@@ -95,7 +95,6 @@ executable("flow_unittests") {
sources = [
"matrix_decomposition_unittests.cc",
"raster_cache_unittests.cc",
"layers/performance_overlay_layer_unittests.cc",
]
deps = [
...
...
flow/layers/performance_overlay_layer.cc
浏览文件 @
693645e4
...
...
@@ -15,12 +15,8 @@ namespace {
void
DrawStatisticsText
(
SkCanvas
&
canvas
,
const
std
::
string
&
string
,
int
x
,
int
y
,
const
std
::
string
&
font_path
)
{
int
y
)
{
SkFont
font
;
if
(
font_path
!=
""
)
{
font
=
SkFont
(
SkTypeface
::
MakeFromFile
(
font_path
.
c_str
()));
}
font
.
setSize
(
15
);
font
.
setLinearMetrics
(
false
);
SkPaint
paint
;
...
...
@@ -37,8 +33,7 @@ void VisualizeStopWatch(SkCanvas& canvas,
SkScalar
height
,
bool
show_graph
,
bool
show_labels
,
const
std
::
string
&
label_prefix
,
const
std
::
string
&
font_path
)
{
const
std
::
string
&
label_prefix
)
{
const
int
label_x
=
8
;
// distance from x
const
int
label_y
=
-
10
;
// distance from y+height
...
...
@@ -56,20 +51,14 @@ void VisualizeStopWatch(SkCanvas& canvas,
stream
<<
label_prefix
<<
" "
<<
"max "
<<
max_ms_per_frame
<<
" ms/frame, "
<<
"avg "
<<
average_ms_per_frame
<<
" ms/frame"
;
DrawStatisticsText
(
canvas
,
stream
.
str
(),
x
+
label_x
,
y
+
height
+
label_y
,
font_path
);
DrawStatisticsText
(
canvas
,
stream
.
str
(),
x
+
label_x
,
y
+
height
+
label_y
);
}
}
}
// namespace
PerformanceOverlayLayer
::
PerformanceOverlayLayer
(
uint64_t
options
,
const
char
*
font_path
)
:
options_
(
options
)
{
if
(
font_path
!=
nullptr
)
{
font_path_
=
font_path
;
}
}
PerformanceOverlayLayer
::
PerformanceOverlayLayer
(
uint64_t
options
)
:
options_
(
options
)
{}
void
PerformanceOverlayLayer
::
Paint
(
PaintContext
&
context
)
const
{
const
int
padding
=
8
;
...
...
@@ -84,15 +73,15 @@ void PerformanceOverlayLayer::Paint(PaintContext& context) const {
SkScalar
height
=
paint_bounds
().
height
()
/
2
;
SkAutoCanvasRestore
save
(
context
.
leaf_nodes_canvas
,
true
);
VisualizeStopWatch
(
*
context
.
leaf_nodes_canvas
,
context
.
frame_time
,
x
,
y
,
width
,
height
-
padding
,
options_
&
kVisualizeRasterizerStatistics
,
options_
&
kDisplayRasterizerStatistics
,
"GPU"
,
font_path_
);
VisualizeStopWatch
(
*
context
.
leaf_nodes_canvas
,
context
.
frame_time
,
x
,
y
,
width
,
height
-
padding
,
options_
&
kVisualizeRasterizerStatistics
,
options_
&
kDisplayRasterizerStatistics
,
"GPU"
);
VisualizeStopWatch
(
*
context
.
leaf_nodes_canvas
,
context
.
engine_time
,
x
,
y
+
height
,
width
,
height
-
padding
,
options_
&
kVisualizeEngineStatistics
,
options_
&
kDisplayEngineStatistics
,
"UI"
,
font_path_
);
options_
&
kDisplayEngineStatistics
,
"UI"
);
}
}
// namespace flow
flow/layers/performance_overlay_layer.h
浏览文件 @
693645e4
...
...
@@ -5,8 +5,6 @@
#ifndef FLUTTER_FLOW_LAYERS_PERFORMANCE_OVERLAY_LAYER_H_
#define FLUTTER_FLOW_LAYERS_PERFORMANCE_OVERLAY_LAYER_H_
#include <string>
#include "flutter/flow/layers/layer.h"
#include "flutter/fml/macros.h"
...
...
@@ -19,14 +17,12 @@ const int kVisualizeEngineStatistics = 1 << 3;
class
PerformanceOverlayLayer
:
public
Layer
{
public:
explicit
PerformanceOverlayLayer
(
uint64_t
options
,
const
char
*
font_path
=
nullptr
);
explicit
PerformanceOverlayLayer
(
uint64_t
options
);
void
Paint
(
PaintContext
&
context
)
const
override
;
private:
int
options_
;
std
::
string
font_path_
;
FML_DISALLOW_COPY_AND_ASSIGN
(
PerformanceOverlayLayer
);
};
...
...
flow/layers/performance_overlay_layer_unittests.cc
已删除
100644 → 0
浏览文件 @
d130f15a
// Copyright 2013 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.
#include "flutter/flow/layers/performance_overlay_layer.h"
#include "flutter/flow/raster_cache.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/utils/SkBase64.h"
#include "gtest/gtest.h"
// To get the size of kMockedTimes in compile time.
template
<
class
T
,
std
::
size_t
N
>
constexpr
int
size
(
const
T
(
&
array
)[
N
])
noexcept
{
return
N
;
}
constexpr
int
kMockedTimes
[]
=
{
17
,
1
,
4
,
24
,
4
,
25
,
30
,
4
,
13
,
34
,
14
,
0
,
18
,
9
,
32
,
36
,
26
,
23
,
5
,
8
,
32
,
18
,
29
,
16
,
29
,
18
,
0
,
36
,
33
,
10
};
const
char
*
kGoldenFileName
=
"flutter/testing/resources/performance_overlay_gold.png"
;
const
char
*
kNewGoldenFileName
=
"flutter/testing/resources/performance_overlay_gold_new.png"
;
// Ensure the same font across different operation systems.
const
char
*
kFontFilePath
=
"flutter/third_party/txt/third_party/fonts/Roboto-Regular.ttf"
;
TEST
(
PerformanceOverlayLayer
,
Gold
)
{
flow
::
Stopwatch
mock_stopwatch
;
for
(
int
i
=
0
;
i
<
size
(
kMockedTimes
);
++
i
)
{
mock_stopwatch
.
SetLapTime
(
fml
::
TimeDelta
::
FromMilliseconds
(
kMockedTimes
[
i
]));
}
const
SkImageInfo
image_info
=
SkImageInfo
::
MakeN32Premul
(
1000
,
1000
);
sk_sp
<
SkSurface
>
surface
=
SkSurface
::
MakeRaster
(
image_info
);
ASSERT_TRUE
(
surface
!=
nullptr
);
flow
::
TextureRegistry
unused_texture_registry
;
flow
::
Layer
::
PaintContext
paintContext
=
{
nullptr
,
surface
->
getCanvas
(),
nullptr
,
mock_stopwatch
,
mock_stopwatch
,
unused_texture_registry
,
nullptr
,
false
};
flow
::
PerformanceOverlayLayer
layer
(
flow
::
kDisplayRasterizerStatistics
|
flow
::
kVisualizeRasterizerStatistics
|
flow
::
kDisplayEngineStatistics
|
flow
::
kVisualizeEngineStatistics
,
kFontFilePath
);
layer
.
set_paint_bounds
(
SkRect
::
MakeWH
(
1000
,
400
));
surface
->
getCanvas
()
->
clear
(
SK_ColorTRANSPARENT
);
layer
.
Paint
(
paintContext
);
sk_sp
<
SkImage
>
snapshot
=
surface
->
makeImageSnapshot
();
sk_sp
<
SkData
>
snapshot_data
=
snapshot
->
encodeToData
();
sk_sp
<
SkData
>
golden_data
=
SkData
::
MakeFromFileName
(
kGoldenFileName
);
EXPECT_TRUE
(
golden_data
!=
nullptr
)
<<
"Golden file not found: "
<<
kGoldenFileName
<<
".
\n
"
<<
"Please make sure that the unit test is run from the right directory "
<<
"(e.g., flutter/engine/src)"
;
const
bool
golden_data_matches
=
golden_data
->
equals
(
snapshot_data
.
get
());
if
(
!
golden_data_matches
)
{
SkFILEWStream
wstream
(
kNewGoldenFileName
);
wstream
.
write
(
snapshot_data
->
data
(),
snapshot_data
->
size
());
wstream
.
flush
();
size_t
b64_size
=
SkBase64
::
Encode
(
snapshot_data
->
data
(),
snapshot_data
->
size
(),
nullptr
);
char
*
b64_data
=
new
char
[
b64_size
];
SkBase64
::
Encode
(
snapshot_data
->
data
(),
snapshot_data
->
size
(),
b64_data
);
EXPECT_TRUE
(
golden_data_matches
)
<<
"Golden file mismatch. Please check "
<<
"the difference between "
<<
kGoldenFileName
<<
" and "
<<
kNewGoldenFileName
<<
", and replace the former "
<<
"with the latter if the difference looks good.
\n\n
"
<<
"See also the base64 encoded "
<<
kNewGoldenFileName
<<
":
\n
"
<<
b64_data
;
delete
[]
b64_data
;
}
}
testing/resources/performance_overlay_gold.png
已删除
100644 → 0
浏览文件 @
d130f15a
16.2 KB
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录