Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
d0123377
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,发现更多精彩内容 >>
提交
d0123377
编写于
10月 06, 2015
作者:
C
Chinmay Garde
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add markers for each frame interval while rendering statistics and scale the graph
上级
6c78e664
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
47 addition
and
8 deletion
+47
-8
sky/compositor/instrumentation.cc
sky/compositor/instrumentation.cc
+45
-8
sky/compositor/instrumentation.h
sky/compositor/instrumentation.h
+2
-0
未找到文件。
sky/compositor/instrumentation.cc
浏览文件 @
d0123377
...
...
@@ -13,6 +13,7 @@ namespace compositor {
namespace
instrumentation
{
static
const
size_t
kMaxSamples
=
120
;
static
const
double
kOneFrameMS
=
1e3
/
60.0
;
Stopwatch
::
Stopwatch
()
:
_start
(
base
::
TimeTicks
::
Now
()),
_current_sample
(
0
)
{
const
base
::
TimeDelta
delta
;
...
...
@@ -41,6 +42,16 @@ static inline constexpr double UnitFrameInterval(double frameTimeMS) {
return
frameTimeMS
*
60.0
*
1e-3
;
}
base
::
TimeDelta
Stopwatch
::
maxDelta
()
const
{
base
::
TimeDelta
maxDelta
;
for
(
size_t
i
=
0
;
i
<
kMaxSamples
;
i
++
)
{
if
(
_laps
[
i
]
>
maxDelta
)
{
maxDelta
=
_laps
[
i
];
}
}
return
maxDelta
;
}
void
Stopwatch
::
visualize
(
SkCanvas
&
canvas
,
const
SkRect
&
rect
)
const
{
SkPaint
paint
;
...
...
@@ -50,18 +61,30 @@ void Stopwatch::visualize(SkCanvas& canvas, const SkRect& rect) const {
// Paint the graph
SkPath
path
;
auto
width
=
rect
.
width
();
auto
height
=
rect
.
height
();
const
SkScalar
width
=
rect
.
width
();
const
SkScalar
height
=
rect
.
height
();
// Find the max delta. We use this to scale the graph
auto
unitHeight
=
std
::
min
(
1.0
,
UnitFrameInterval
(
_laps
[
0
].
InMillisecondsF
()));
double
maxInterval
=
maxDelta
().
InMillisecondsF
();
if
(
maxInterval
<
kOneFrameMS
)
{
maxInterval
=
kOneFrameMS
;
}
const
double
maxUnitInterval
=
UnitFrameInterval
(
maxInterval
);
// Draw the path
double
unitHeight
=
UnitFrameInterval
(
_laps
[
0
].
InMillisecondsF
())
/
maxUnitInterval
;
path
.
moveTo
(
0
,
height
);
path
.
lineTo
(
0
,
height
*
(
1.0
-
unitHeight
));
for
(
size_t
i
=
0
;
i
<
kMaxSamples
;
i
++
)
{
double
unitWidth
=
(
static_cast
<
double
>
(
i
+
1
)
/
kMaxSamples
);
unitHeight
=
std
::
min
(
1.0
,
UnitFrameInterval
(
_laps
[
i
].
InMillisecondsF
()));
unitHeight
=
UnitFrameInterval
(
_laps
[
i
].
InMillisecondsF
())
/
maxUnitInterval
;
path
.
lineTo
(
width
*
unitWidth
,
height
*
(
1.0
-
unitHeight
));
}
...
...
@@ -72,7 +95,22 @@ void Stopwatch::visualize(SkCanvas& canvas, const SkRect& rect) const {
paint
.
setColor
(
0xAA0000FF
);
canvas
.
drawPath
(
path
,
paint
);
// Paint the marker
paint
.
setStrokeWidth
(
1
);
paint
.
setStyle
(
SkPaint
::
Style
::
kStroke_Style
);
paint
.
setColor
(
SK_ColorWHITE
);
if
(
maxInterval
>
kOneFrameMS
)
{
// Paint the horizontal markers
for
(
size_t
frameIndex
=
1
;
(
frameIndex
*
kOneFrameMS
)
<
maxInterval
;
frameIndex
++
)
{
const
double
frameHeight
=
height
*
(
1.0
-
(
UnitFrameInterval
(
frameIndex
*
kOneFrameMS
)
/
maxUnitInterval
));
canvas
.
drawLine
(
0
,
frameHeight
,
width
,
frameHeight
,
paint
);
}
}
// Paint the vertical marker
if
(
UnitFrameInterval
(
lastLap
().
InMillisecondsF
())
>
1.0
)
{
// budget exceeded
paint
.
setColor
(
SK_ColorRED
);
...
...
@@ -81,9 +119,8 @@ void Stopwatch::visualize(SkCanvas& canvas, const SkRect& rect) const {
paint
.
setColor
(
SK_ColorGREEN
);
}
double
sampleX
=
width
*
(
static_cast
<
double
>
(
_current_sample
)
/
kMaxSamples
);
paint
.
setStrokeWidth
(
3
);
paint
.
setStyle
(
SkPaint
::
Style
::
kStroke_Style
);
auto
sampleX
=
width
*
(
static_cast
<
double
>
(
_current_sample
)
/
kMaxSamples
);
canvas
.
drawLine
(
sampleX
,
0
,
sampleX
,
height
,
paint
);
}
...
...
sky/compositor/instrumentation.h
浏览文件 @
d0123377
...
...
@@ -50,6 +50,8 @@ class Stopwatch {
std
::
vector
<
base
::
TimeDelta
>
_laps
;
size_t
_current_sample
;
base
::
TimeDelta
maxDelta
()
const
;
DISALLOW_COPY_AND_ASSIGN
(
Stopwatch
);
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录