Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
2a0d3542
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,发现更多精彩内容 >>
未验证
提交
2a0d3542
编写于
3月 11, 2019
作者:
C
Chinmay Garde
提交者:
GitHub
3月 11, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add support for trace counters with variable arguments and instrument the raster cache. (#8094)
上级
56d8634c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
126 addition
and
19 deletion
+126
-19
flow/raster_cache.cc
flow/raster_cache.cc
+33
-2
flow/raster_cache.h
flow/raster_cache.h
+7
-0
fml/trace_event.cc
fml/trace_event.cc
+24
-12
fml/trace_event.h
fml/trace_event.h
+62
-5
未找到文件。
flow/raster_cache.cc
浏览文件 @
2a0d3542
...
...
@@ -97,6 +97,7 @@ static RasterCacheResult Rasterize(
bool
checkerboard
,
const
SkRect
&
logical_rect
,
std
::
function
<
void
(
SkCanvas
*
)
>
draw_function
)
{
TRACE_EVENT0
(
"flutter"
,
"RasterCachePopulate"
);
SkIRect
cache_rect
=
RasterCache
::
GetDeviceBounds
(
logical_rect
,
ctm
);
const
SkImageInfo
image_info
=
SkImageInfo
::
MakeN32Premul
(
...
...
@@ -129,8 +130,6 @@ RasterCacheResult RasterizePicture(SkPicture* picture,
const
SkMatrix
&
ctm
,
SkColorSpace
*
dst_color_space
,
bool
checkerboard
)
{
TRACE_EVENT0
(
"flutter"
,
"RasterCachePopulate"
);
return
Rasterize
(
context
,
ctm
,
dst_color_space
,
checkerboard
,
picture
->
cullRect
(),
[
=
](
SkCanvas
*
canvas
)
{
canvas
->
drawPicture
(
picture
);
});
...
...
@@ -240,6 +239,7 @@ void RasterCache::SweepAfterFrame() {
SweepOneCacheAfterFrame
<
PictureCache
,
PictureCache
::
iterator
>
(
picture_cache_
);
SweepOneCacheAfterFrame
<
LayerCache
,
LayerCache
::
iterator
>
(
layer_cache_
);
picture_cached_this_frame_
=
0
;
TraceStatsToTimeline
();
}
void
RasterCache
::
Clear
()
{
...
...
@@ -259,4 +259,35 @@ void RasterCache::SetCheckboardCacheImages(bool checkerboard) {
Clear
();
}
void
RasterCache
::
TraceStatsToTimeline
()
const
{
#if FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_RELEASE
size_t
layer_cache_count
=
0
;
size_t
layer_cache_bytes
=
0
;
size_t
picture_cache_count
=
0
;
size_t
picture_cache_bytes
=
0
;
for
(
const
auto
&
item
:
layer_cache_
)
{
const
auto
dimensions
=
item
.
second
.
image
.
image_dimensions
();
layer_cache_count
++
;
layer_cache_bytes
+=
dimensions
.
width
()
*
dimensions
.
height
()
*
4
;
}
for
(
const
auto
&
item
:
picture_cache_
)
{
const
auto
dimensions
=
item
.
second
.
image
.
image_dimensions
();
picture_cache_count
++
;
picture_cache_bytes
+=
dimensions
.
width
()
*
dimensions
.
height
()
*
4
;
}
FML_TRACE_COUNTER
(
"flutter"
,
"RasterCache"
,
reinterpret_cast
<
int64_t
>
(
this
),
//
"LayerCount"
,
layer_cache_count
,
//
"LayerMBytes"
,
layer_cache_bytes
*
1e-6
,
//
"PictureCount"
,
picture_cache_count
,
//
"PictureMBytes"
,
picture_cache_bytes
*
1e-6
//
);
#endif // FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_RELEASE
}
}
// namespace flow
flow/raster_cache.h
浏览文件 @
2a0d3542
...
...
@@ -33,6 +33,10 @@ class RasterCacheResult {
void
draw
(
SkCanvas
&
canvas
,
const
SkPaint
*
paint
=
nullptr
)
const
;
SkISize
image_dimensions
()
const
{
return
image_
?
image_
->
dimensions
()
:
SkISize
::
Make
(
0
,
0
);
};
private:
sk_sp
<
SkImage
>
image_
;
SkRect
logical_rect_
;
...
...
@@ -87,6 +91,7 @@ class RasterCache {
void
Prepare
(
PrerollContext
*
context
,
Layer
*
layer
,
const
SkMatrix
&
ctm
);
RasterCacheResult
Get
(
const
SkPicture
&
picture
,
const
SkMatrix
&
ctm
)
const
;
RasterCacheResult
Get
(
Layer
*
layer
,
const
SkMatrix
&
ctm
)
const
;
void
SweepAfterFrame
();
...
...
@@ -127,6 +132,8 @@ class RasterCache {
bool
checkerboard_images_
;
fml
::
WeakPtrFactory
<
RasterCache
>
weak_factory_
;
void
TraceStatsToTimeline
()
const
;
FML_DISALLOW_COPY_AND_ASSIGN
(
RasterCache
);
};
...
...
fml/trace_event.cc
浏览文件 @
2a0d3542
...
...
@@ -4,22 +4,34 @@
#include "flutter/fml/trace_event.h"
#include "
third_party/dart/runtime/include/dart_tools_api
.h"
#include "
flutter/fml/logging
.h"
namespace
fml
{
namespace
tracing
{
void
TraceCounter
(
TraceArg
category_group
,
TraceArg
name
,
TraceIDArg
count
)
{
auto
count_string
=
std
::
to_string
(
count
);
const
char
*
arg_names
[]
=
{
name
};
const
char
*
arg_values
[]
=
{
count_string
.
c_str
()};
Dart_TimelineEvent
(
name
,
// label
Dart_TimelineGetMicros
(),
// timestamp0
0
,
// timestamp1_or_async_id
Dart_Timeline_Event_Counter
,
// event type
1
,
// argument_count
arg_names
,
// argument_names
arg_values
// argument_values
void
TraceTimelineEvent
(
TraceArg
category_group
,
TraceArg
name
,
TraceIDArg
identifier
,
Dart_Timeline_Event_Type
type
,
const
std
::
vector
<
const
char
*>&
names
,
const
std
::
vector
<
std
::
string
>&
values
)
{
const
auto
argument_count
=
std
::
min
(
names
.
size
(),
values
.
size
());
std
::
vector
<
const
char
*>
c_values
;
c_values
.
resize
(
argument_count
,
nullptr
);
for
(
size_t
i
=
0
;
i
<
argument_count
;
i
++
)
{
c_values
[
i
]
=
values
[
i
].
c_str
();
}
Dart_TimelineEvent
(
name
,
// label
Dart_TimelineGetMicros
(),
// timestamp0
identifier
,
// timestamp1_or_async_id
type
,
// event type
argument_count
,
// argument_count
const_cast
<
const
char
**>
(
names
.
data
()),
// argument_names
const_cast
<
const
char
**>
(
c_values
.
data
())
// argument_values
);
}
...
...
fml/trace_event.h
浏览文件 @
2a0d3542
...
...
@@ -13,8 +13,6 @@
#include <trace/event.h>
#define FML_TRACE_COUNTER(category_group, name, count) \
TRACE_COUNTER(category_group, name, 0u, name, count)
#define TRACE_EVENT0(a, b) TRACE_DURATION(a, b)
#define TRACE_EVENT1(a, b, c, d) TRACE_DURATION(a, b, c, d)
#define TRACE_EVENT2(a, b, c, d, e, f) TRACE_DURATION(a, b, c, d, e, f)
...
...
@@ -28,8 +26,11 @@
#include <cstddef>
#include <cstdint>
#include <string>
#include <type_traits>
#include <vector>
#include "flutter/fml/macros.h"
#include "third_party/dart/runtime/include/dart_tools_api.h"
#if !defined(OS_FUCHSIA)
...
...
@@ -45,8 +46,8 @@
// from trace/event.h on Fuchsia.
//
// TODO(chinmaygarde): All macros here should have the FML prefix.
#define FML_TRACE_COUNTER(category_group, name, count) \
::fml::tracing::TraceCounter(category_group, name, count);
#define FML_TRACE_COUNTER(category_group, name, count
er_id, arg1, args...
) \
::fml::tracing::TraceCounter(category_group, name, count
er_id, arg1, ##args
);
#define TRACE_EVENT0(category_group, name) \
::fml::tracing::TraceEvent0(category_group, name); \
...
...
@@ -99,7 +100,63 @@ namespace tracing {
using
TraceArg
=
const
char
*
;
using
TraceIDArg
=
int64_t
;
void
TraceCounter
(
TraceArg
category_group
,
TraceArg
name
,
TraceIDArg
count
);
void
TraceTimelineEvent
(
TraceArg
category_group
,
TraceArg
name
,
TraceIDArg
id
,
Dart_Timeline_Event_Type
type
,
const
std
::
vector
<
const
char
*>&
names
,
const
std
::
vector
<
std
::
string
>&
values
);
inline
std
::
string
TraceToString
(
const
char
*
string
)
{
return
std
::
string
{
string
};
}
inline
std
::
string
TraceToString
(
std
::
string
string
)
{
return
string
;
}
template
<
typename
T
,
typename
=
std
::
enable_if_t
<
std
::
is_arithmetic
<
T
>
::
value
>>
std
::
string
TraceToString
(
T
string
)
{
return
std
::
to_string
(
string
);
}
inline
void
SplitArgumentsCollect
(
std
::
vector
<
const
char
*>&
keys
,
std
::
vector
<
std
::
string
>&
values
)
{}
template
<
typename
Key
,
typename
Value
,
typename
...
Args
>
void
SplitArgumentsCollect
(
std
::
vector
<
const
char
*>&
keys
,
std
::
vector
<
std
::
string
>&
values
,
Key
key
,
Value
value
,
Args
...
args
)
{
keys
.
emplace_back
(
key
);
values
.
emplace_back
(
TraceToString
(
value
));
SplitArgumentsCollect
(
keys
,
values
,
args
...);
}
inline
std
::
pair
<
std
::
vector
<
const
char
*>
,
std
::
vector
<
std
::
string
>>
SplitArguments
()
{
return
{};
}
template
<
typename
Key
,
typename
Value
,
typename
...
Args
>
std
::
pair
<
std
::
vector
<
const
char
*>
,
std
::
vector
<
std
::
string
>>
SplitArguments
(
Key
key
,
Value
value
,
Args
...
args
)
{
std
::
vector
<
const
char
*>
keys
;
std
::
vector
<
std
::
string
>
values
;
SplitArgumentsCollect
(
keys
,
values
,
key
,
value
,
args
...);
return
std
::
make_pair
(
std
::
move
(
keys
),
std
::
move
(
values
));
}
template
<
typename
...
Args
>
void
TraceCounter
(
TraceArg
category
,
TraceArg
name
,
TraceIDArg
identifier
,
Args
...
args
)
{
auto
split
=
SplitArguments
(
args
...);
TraceTimelineEvent
(
category
,
name
,
identifier
,
Dart_Timeline_Event_Counter
,
split
.
first
,
split
.
second
);
}
void
TraceEvent0
(
TraceArg
category_group
,
TraceArg
name
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录