Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_34031325
engine
提交
418ed6f6
E
engine
项目概览
qq_34031325
/
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,发现更多精彩内容 >>
提交
418ed6f6
编写于
9月 30, 2015
作者:
C
Chinmay Garde
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow visualizing engine and rasterizer statistics simultaneously
上级
60176eb6
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
107 addition
and
31 deletion
+107
-31
sky/compositor/compositor_options.cc
sky/compositor/compositor_options.cc
+9
-0
sky/compositor/compositor_options.h
sky/compositor/compositor_options.h
+6
-2
sky/compositor/instrumentation.cc
sky/compositor/instrumentation.cc
+23
-11
sky/compositor/instrumentation.h
sky/compositor/instrumentation.h
+3
-2
sky/compositor/layer_tree.h
sky/compositor/layer_tree.h
+11
-0
sky/compositor/paint_context.h
sky/compositor/paint_context.h
+4
-1
sky/compositor/statistics_layer.cc
sky/compositor/statistics_layer.cc
+41
-13
sky/shell/gpu/rasterizer.cc
sky/shell/gpu/rasterizer.cc
+5
-0
sky/shell/ui/engine.cc
sky/shell/ui/engine.cc
+5
-2
未找到文件。
sky/compositor/compositor_options.cc
浏览文件 @
418ed6f6
...
...
@@ -36,6 +36,15 @@ void CompositorOptions::setEnabled(Option option, bool enabled) {
}
}
bool
CompositorOptions
::
anyEnabled
()
const
{
for
(
auto
enabled
:
options_
)
{
if
(
enabled
)
{
return
true
;
}
}
return
false
;
}
CompositorOptions
::~
CompositorOptions
()
{
}
...
...
sky/compositor/compositor_options.h
浏览文件 @
418ed6f6
...
...
@@ -16,8 +16,10 @@ class CompositorOptions {
public:
using
OptionType
=
unsigned
int
;
enum
class
Option
:
OptionType
{
DisplayFrameStatistics
,
VisualizeFrameStatistics
,
DisplayRasterizerStatistics
,
VisualizeRasterizerStatistics
,
DisplayEngineStatistics
,
VisualizeEngineStatistics
,
TerminationSentinel
,
};
...
...
@@ -29,6 +31,8 @@ class CompositorOptions {
bool
isEnabled
(
Option
option
)
const
;
bool
anyEnabled
()
const
;
void
setEnabled
(
Option
option
,
bool
enabled
);
private:
...
...
sky/compositor/instrumentation.cc
浏览文件 @
418ed6f6
...
...
@@ -3,6 +3,9 @@
// found in the LICENSE file.
#include "sky/compositor/instrumentation.h"
#include <algorithm>
#include "third_party/skia/include/core/SkPath.h"
namespace
sky
{
...
...
@@ -11,8 +14,7 @@ namespace instrumentation {
static
const
size_t
kMaxSamples
=
120
;
Stopwatch
::
Stopwatch
()
:
_start
(
base
::
TimeTicks
::
Now
()),
_lastLap
(),
_current_sample
(
0
)
{
Stopwatch
::
Stopwatch
()
:
_start
(
base
::
TimeTicks
::
Now
()),
_current_sample
(
0
)
{
const
base
::
TimeDelta
delta
;
_laps
.
resize
(
kMaxSamples
,
delta
);
}
...
...
@@ -23,8 +25,12 @@ void Stopwatch::start() {
}
void
Stopwatch
::
stop
()
{
_lastLap
=
base
::
TimeTicks
::
Now
()
-
_start
;
_laps
[
_current_sample
]
=
_lastLap
;
_laps
[
_current_sample
]
=
base
::
TimeTicks
::
Now
()
-
_start
;
}
void
Stopwatch
::
setLapTime
(
const
base
::
TimeDelta
&
delta
)
{
_current_sample
=
(
_current_sample
+
1
)
%
kMaxSamples
;
_laps
[
_current_sample
]
=
delta
;
}
static
inline
constexpr
double
UnitFrameInterval
(
double
frameTimeMS
)
{
...
...
@@ -32,8 +38,6 @@ static inline constexpr double UnitFrameInterval(double frameTimeMS) {
}
void
Stopwatch
::
visualize
(
SkCanvas
&
canvas
,
const
SkRect
&
rect
)
const
{
SkAutoCanvasRestore
save
(
&
canvas
,
false
);
SkPaint
paint
;
// Paint the background
...
...
@@ -45,15 +49,16 @@ void Stopwatch::visualize(SkCanvas& canvas, const SkRect& rect) const {
auto
width
=
rect
.
width
();
auto
height
=
rect
.
height
();
auto
unitHeight
=
(
1.0
-
UnitFrameInterval
(
_laps
[
0
].
InMillisecondsF
()));
auto
unitHeight
=
std
::
min
(
1.0
,
UnitFrameInterval
(
_laps
[
0
].
InMillisecondsF
()));
path
.
moveTo
(
0
,
height
);
path
.
lineTo
(
0
,
height
*
unitHeight
);
path
.
lineTo
(
0
,
height
*
(
1.0
-
unitHeight
)
);
for
(
size_t
i
=
0
;
i
<
kMaxSamples
;
i
++
)
{
double
unitWidth
=
(
static_cast
<
double
>
(
i
+
1
)
/
kMaxSamples
);
unitHeight
=
(
1.0
-
UnitFrameInterval
(
_laps
[
i
].
InMillisecondsF
()));
path
.
lineTo
(
width
*
unitWidth
,
height
*
unitHeight
);
unitHeight
=
std
::
min
(
1.0
,
UnitFrameInterval
(
_laps
[
i
].
InMillisecondsF
()));
path
.
lineTo
(
width
*
unitWidth
,
height
*
(
1.0
-
unitHeight
)
);
}
path
.
lineTo
(
width
,
height
);
...
...
@@ -64,7 +69,14 @@ void Stopwatch::visualize(SkCanvas& canvas, const SkRect& rect) const {
canvas
.
drawPath
(
path
,
paint
);
// Paint the marker
paint
.
setColor
(
0xFF00FF00
);
if
(
UnitFrameInterval
(
_laps
[
_current_sample
].
InMillisecondsF
())
>
1.0
)
{
// budget exceeded
paint
.
setColor
(
SK_ColorRED
);
}
else
{
// within budget
paint
.
setColor
(
SK_ColorGREEN
);
}
paint
.
setStrokeWidth
(
3
);
paint
.
setStyle
(
SkPaint
::
Style
::
kStroke_Style
);
auto
sampleX
=
width
*
(
static_cast
<
double
>
(
_current_sample
)
/
kMaxSamples
);
...
...
sky/compositor/instrumentation.h
浏览文件 @
418ed6f6
...
...
@@ -33,7 +33,7 @@ class Stopwatch {
explicit
Stopwatch
();
~
Stopwatch
();
const
base
::
TimeDelta
&
lastLap
()
const
{
return
_la
stLap
;
}
const
base
::
TimeDelta
&
lastLap
()
const
{
return
_la
ps
[
_current_sample
]
;
}
base
::
TimeDelta
currentLap
()
const
{
return
base
::
TimeTicks
::
Now
()
-
_start
;
}
...
...
@@ -43,10 +43,11 @@ class Stopwatch {
void
stop
();
void
setLapTime
(
const
base
::
TimeDelta
&
delta
);
private:
base
::
TimeTicks
_start
;
std
::
vector
<
base
::
TimeDelta
>
_laps
;
base
::
TimeDelta
_lastLap
;
size_t
_current_sample
;
DISALLOW_COPY_AND_ASSIGN
(
Stopwatch
);
...
...
sky/compositor/layer_tree.h
浏览文件 @
418ed6f6
...
...
@@ -8,6 +8,7 @@
#include <memory>
#include "base/macros.h"
#include "base/time/time.h"
#include "sky/compositor/layer.h"
#include "third_party/skia/include/core/SkSize.h"
...
...
@@ -29,10 +30,20 @@ class LayerTree {
void
set_frame_size
(
const
SkISize
&
frame_size
)
{
frame_size_
=
frame_size
;
}
void
set_construction_time
(
const
base
::
TimeDelta
&
delta
)
{
construction_time_
=
delta
;
}
const
base
::
TimeDelta
&
construction_time
()
const
{
return
construction_time_
;
}
private:
SkISize
frame_size_
;
// Physical pixels.
std
::
unique_ptr
<
Layer
>
root_layer_
;
base
::
TimeDelta
construction_time_
;
DISALLOW_COPY_AND_ASSIGN
(
LayerTree
);
};
...
...
sky/compositor/paint_context.h
浏览文件 @
418ed6f6
...
...
@@ -24,7 +24,7 @@ class PaintContext {
public:
SkCanvas
&
canvas
()
{
return
*
canvas_
;
}
const
PaintContext
&
context
()
const
{
return
context_
;
}
PaintContext
&
context
()
const
{
return
context_
;
}
ScopedFrame
(
ScopedFrame
&&
frame
);
...
...
@@ -59,9 +59,12 @@ class PaintContext {
const
instrumentation
::
Stopwatch
&
frame_time
()
const
{
return
frame_time_
;
}
instrumentation
::
Stopwatch
&
engine_time
()
{
return
engine_time_
;
};
private:
instrumentation
::
Counter
frame_count_
;
instrumentation
::
Stopwatch
frame_time_
;
instrumentation
::
Stopwatch
engine_time_
;
void
beginFrame
(
ScopedFrame
&
frame
);
void
endFrame
(
ScopedFrame
&
frame
);
...
...
sky/compositor/statistics_layer.cc
浏览文件 @
418ed6f6
...
...
@@ -26,29 +26,57 @@ static void PaintContext_DrawStatisticsText(SkCanvas& canvas,
canvas
.
drawText
(
string
.
c_str
(),
string
.
size
(),
x
,
y
,
paint
);
}
void
StatisticsLayer
::
Paint
(
PaintContext
::
ScopedFrame
&
frame
)
{
static
void
VisualizeStopWatch
(
SkCanvas
&
canvas
,
const
instrumentation
::
Stopwatch
&
stopwatch
,
SkScalar
width
,
bool
show_graph
,
bool
show_labels
,
std
::
string
label_prefix
)
{
const
int
x
=
8
;
int
y
=
70
;
static
const
int
kLineSpacing
=
18
;
const
PaintContext
&
context
=
frame
.
context
();
const
int
y
=
70
;
const
int
height
=
80
;
if
(
options_
.
isEnabled
(
CompositorOptions
::
Option
::
VisualizeFrameStatistics
)
)
{
SkRect
visualizationRect
=
SkRect
::
MakeWH
(
paint_bounds
().
width
(),
80
);
context
.
frame_time
().
visualize
(
frame
.
canvas
()
,
visualizationRect
);
if
(
show_graph
)
{
SkRect
visualizationRect
=
SkRect
::
MakeWH
(
width
,
height
);
stopwatch
.
visualize
(
canvas
,
visualizationRect
);
}
if
(
options_
.
isEnabled
(
CompositorOptions
::
Option
::
DisplayFrameStatistics
)
)
{
double
msPerFrame
=
context
.
frame_time
()
.
lastLap
().
InMillisecondsF
();
if
(
show_labels
)
{
double
msPerFrame
=
stopwatch
.
lastLap
().
InMillisecondsF
();
double
fps
=
1e3
/
msPerFrame
;
std
::
stringstream
stream
;
stream
.
setf
(
std
::
ios
::
fixed
|
std
::
ios
::
showpoint
);
stream
<<
std
::
setprecision
(
2
);
stream
<<
fps
<<
" FPS | "
<<
msPerFrame
<<
"ms/frame"
;
PaintContext_DrawStatisticsText
(
frame
.
canvas
(),
stream
.
str
(),
x
,
y
);
y
+=
kLineSpacing
;
stream
<<
label_prefix
<<
" "
<<
fps
<<
" FPS | "
<<
msPerFrame
<<
"ms/frame"
;
PaintContext_DrawStatisticsText
(
canvas
,
stream
.
str
(),
x
,
y
);
}
if
(
show_labels
||
show_graph
)
{
canvas
.
translate
(
0
,
height
);
}
}
void
StatisticsLayer
::
Paint
(
PaintContext
::
ScopedFrame
&
frame
)
{
if
(
!
options_
.
anyEnabled
())
{
return
;
}
using
Opt
=
CompositorOptions
::
Option
;
SkScalar
width
=
paint_bounds
().
width
();
SkAutoCanvasRestore
save
(
&
frame
.
canvas
(),
false
);
VisualizeStopWatch
(
frame
.
canvas
(),
frame
.
context
().
frame_time
(),
width
,
options_
.
isEnabled
(
Opt
::
VisualizeRasterizerStatistics
),
options_
.
isEnabled
(
Opt
::
DisplayRasterizerStatistics
),
"Rasterizer"
);
VisualizeStopWatch
(
frame
.
canvas
(),
frame
.
context
().
engine_time
(),
width
,
options_
.
isEnabled
(
Opt
::
VisualizeEngineStatistics
),
options_
.
isEnabled
(
Opt
::
DisplayEngineStatistics
),
"Engine"
);
}
}
// namespace compositor
...
...
sky/shell/gpu/rasterizer.cc
浏览文件 @
418ed6f6
...
...
@@ -52,6 +52,11 @@ void Rasterizer::Draw(scoped_ptr<compositor::LayerTree> layer_tree) {
if
(
surface_
->
GetSize
()
!=
size
)
surface_
->
Resize
(
size
);
// There is no way for the compositor to know how long the layer tree
// construction took. Fortunately, the layer tree does. Grab that time
// for instrumentation.
paint_context_
.
engine_time
().
setLapTime
(
layer_tree
->
construction_time
());
// Use the canvas from the Ganesh Surface to render the current frame into
{
EnsureGLContext
();
...
...
sky/shell/ui/engine.cc
浏览文件 @
418ed6f6
...
...
@@ -8,6 +8,7 @@
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/threading/worker_pool.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "mojo/data_pipe_utils/data_pipe_utils.h"
#include "mojo/public/cpp/application/connect.h"
...
...
@@ -102,11 +103,13 @@ std::unique_ptr<compositor::LayerTree> Engine::BeginFrame(
if
(
!
sky_view_
)
return
nullptr
;
auto
begin_time
=
base
::
TimeTicks
::
Now
();
std
::
unique_ptr
<
compositor
::
LayerTree
>
layer_tree
=
sky_view_
->
BeginFrame
(
frame_time
);
if
(
layer_tree
)
{
layer_tree
->
set_frame_size
(
SkISize
::
Make
(
physical_size_
.
width
(),
physical_size_
.
height
()));
layer_tree
->
set_frame_size
(
SkISize
::
Make
(
physical_size_
.
width
(),
physical_size_
.
height
()));
layer_tree
->
set_construction_time
(
base
::
TimeTicks
::
Now
()
-
begin_time
);
}
return
layer_tree
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录