Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_34031325
engine
提交
ab927e23
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,发现更多精彩内容 >>
提交
ab927e23
编写于
9月 28, 2015
作者:
C
Chinmay Garde
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow displaying compositor statistics from Dart
上级
eb6f2f06
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
107 addition
and
38 deletion
+107
-38
sky/compositor/BUILD.gn
sky/compositor/BUILD.gn
+2
-0
sky/compositor/compositor_options.cc
sky/compositor/compositor_options.cc
+9
-0
sky/compositor/compositor_options.h
sky/compositor/compositor_options.h
+2
-0
sky/compositor/paint_context.cc
sky/compositor/paint_context.cc
+0
-30
sky/compositor/paint_context.h
sky/compositor/paint_context.h
+6
-6
sky/compositor/statistics_layer.cc
sky/compositor/statistics_layer.cc
+43
-0
sky/compositor/statistics_layer.h
sky/compositor/statistics_layer.h
+30
-0
sky/engine/core/compositing/SceneBuilder.cpp
sky/engine/core/compositing/SceneBuilder.cpp
+12
-2
sky/engine/core/compositing/SceneBuilder.h
sky/engine/core/compositing/SceneBuilder.h
+2
-0
sky/engine/core/compositing/SceneBuilder.idl
sky/engine/core/compositing/SceneBuilder.idl
+1
-0
未找到文件。
sky/compositor/BUILD.gn
浏览文件 @
ab927e23
...
...
@@ -32,6 +32,8 @@ source_set("compositor") {
"picture_layer.h",
"picture_serializer.cc",
"picture_serializer.h",
"statistics_layer.cc",
"statistics_layer.h",
"transform_layer.cc",
"transform_layer.h",
]
...
...
sky/compositor/compositor_options.cc
浏览文件 @
ab927e23
...
...
@@ -13,6 +13,15 @@ CompositorOptions::CompositorOptions() {
options_
.
resize
(
static_cast
<
OptionType
>
(
Option
::
TerminationSentinel
),
false
);
}
CompositorOptions
::
CompositorOptions
(
uint64_t
mask
)
:
CompositorOptions
()
{
OptionType
sentinel
=
static_cast
<
OptionType
>
(
Option
::
TerminationSentinel
);
for
(
OptionType
i
=
0
;
i
<
sentinel
;
i
++
)
{
if
((
1
<<
i
)
&
mask
)
{
setEnabled
(
static_cast
<
Option
>
(
i
),
true
);
}
}
}
bool
CompositorOptions
::
isEnabled
(
Option
option
)
const
{
if
(
option
>=
Option
::
TerminationSentinel
)
{
return
false
;
...
...
sky/compositor/compositor_options.h
浏览文件 @
ab927e23
...
...
@@ -21,6 +21,8 @@ class CompositorOptions {
};
CompositorOptions
();
CompositorOptions
(
uint64_t
mask
);
~
CompositorOptions
();
bool
isEnabled
(
Option
option
)
const
;
...
...
sky/compositor/paint_context.cc
浏览文件 @
ab927e23
...
...
@@ -21,36 +21,6 @@ void PaintContext::beginFrame(ScopedFrame& frame) {
void
PaintContext
::
endFrame
(
ScopedFrame
&
frame
)
{
frame_time_
.
stop
();
DisplayStatistics
(
frame
);
}
static
void
PaintContext_DrawStatisticsText
(
SkCanvas
&
canvas
,
const
std
::
string
&
string
,
int
x
,
int
y
)
{
SkPaint
paint
;
paint
.
setTextSize
(
14
);
paint
.
setLinearText
(
false
);
paint
.
setColor
(
SK_ColorRED
);
canvas
.
drawText
(
string
.
c_str
(),
string
.
size
(),
x
,
y
,
paint
);
}
void
PaintContext
::
DisplayStatistics
(
ScopedFrame
&
frame
)
{
// TODO: We just draw text text on the top left corner for now. Make this
// better
const
int
x
=
10
;
int
y
=
20
;
static
const
int
kLineSpacing
=
18
;
if
(
options_
.
isEnabled
(
CompositorOptions
::
Option
::
DisplayFrameStatistics
))
{
// Frame (2032): 3.26ms
std
::
stringstream
stream
;
stream
<<
"Frame ("
<<
frame_count_
.
count
()
<<
"): "
<<
frame_time_
.
lastLap
().
InMillisecondsF
()
<<
"ms"
;
PaintContext_DrawStatisticsText
(
frame
.
canvas
(),
stream
.
str
(),
x
,
y
);
y
+=
kLineSpacing
;
}
}
PaintContext
::
ScopedFrame
PaintContext
::
AcquireFrame
(
SkCanvas
&
canvas
)
{
...
...
sky/compositor/paint_context.h
浏览文件 @
ab927e23
...
...
@@ -9,7 +9,6 @@
#include "base/macros.h"
#include "base/logging.h"
#include "sky/compositor/compositor_options.h"
#include "sky/compositor/instrumentation.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkPictureRecorder.h"
...
...
@@ -24,6 +23,8 @@ class PaintContext {
public:
SkCanvas
&
canvas
()
{
return
*
canvas_
;
}
const
PaintContext
&
context
()
const
{
return
context_
;
};
ScopedFrame
(
ScopedFrame
&&
frame
);
~
ScopedFrame
();
...
...
@@ -48,22 +49,21 @@ class PaintContext {
PaintContext
();
~
PaintContext
();
CompositorOptions
&
options
()
{
return
options_
;
};
ScopedFrame
AcquireFrame
(
SkCanvas
&
canvas
);
ScopedFrame
AcquireFrame
(
const
std
::
string
&
trace_file_name
,
gfx
::
Size
frame_size
);
private:
CompositorOptions
options_
;
const
instrumentation
::
Counter
&
frame_count
()
const
{
return
frame_count_
;
}
const
instrumentation
::
Stopwatch
&
frame_time
()
const
{
return
frame_time_
;
}
private:
instrumentation
::
Counter
frame_count_
;
instrumentation
::
Stopwatch
frame_time_
;
void
beginFrame
(
ScopedFrame
&
frame
);
void
endFrame
(
ScopedFrame
&
frame
);
void
DisplayStatistics
(
ScopedFrame
&
frame
);
DISALLOW_COPY_AND_ASSIGN
(
PaintContext
);
};
...
...
sky/compositor/statistics_layer.cc
0 → 100644
浏览文件 @
ab927e23
// Copyright 2015 The Chromium 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 "sky/compositor/statistics_layer.h"
namespace
sky
{
namespace
compositor
{
StatisticsLayer
::
StatisticsLayer
(
uint64_t
enabledOptions
)
:
options_
(
enabledOptions
)
{
}
static
void
PaintContext_DrawStatisticsText
(
SkCanvas
&
canvas
,
const
std
::
string
&
string
,
int
x
,
int
y
)
{
SkPaint
paint
;
paint
.
setTextSize
(
14
);
paint
.
setLinearText
(
false
);
paint
.
setColor
(
SK_ColorRED
);
canvas
.
drawText
(
string
.
c_str
(),
string
.
size
(),
x
,
y
,
paint
);
}
void
StatisticsLayer
::
Paint
(
PaintContext
::
ScopedFrame
&
frame
)
{
const
int
x
=
10
;
int
y
=
20
;
static
const
int
kLineSpacing
=
18
;
const
PaintContext
&
context
=
frame
.
context
();
if
(
options_
.
isEnabled
(
CompositorOptions
::
Option
::
DisplayFrameStatistics
))
{
// Frame (2032): 3.26ms
std
::
stringstream
stream
;
stream
<<
"Frame ("
<<
context
.
frame_count
().
count
()
<<
"): "
<<
context
.
frame_time
().
lastLap
().
InMillisecondsF
()
<<
"ms"
;
PaintContext_DrawStatisticsText
(
frame
.
canvas
(),
stream
.
str
(),
x
,
y
);
y
+=
kLineSpacing
;
}
}
}
// namespace compositor
}
// namespace sky
sky/compositor/statistics_layer.h
0 → 100644
浏览文件 @
ab927e23
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SKY_COMPOSITOR_STATISTICS_LAYER_H_
#define SKY_COMPOSITOR_STATISTICS_LAYER_H_
#include "base/macros.h"
#include "sky/compositor/compositor_options.h"
#include "sky/compositor/layer.h"
namespace
sky
{
namespace
compositor
{
class
StatisticsLayer
:
public
Layer
{
public:
StatisticsLayer
(
uint64_t
enabledOptions
);
void
Paint
(
PaintContext
::
ScopedFrame
&
frame
)
override
;
private:
CompositorOptions
options_
;
DISALLOW_COPY_AND_ASSIGN
(
StatisticsLayer
);
};
}
// namespace compositor
}
// namespace sky
#endif // SKY_COMPOSITOR_STATISTICS_LAYER_H_
sky/engine/core/compositing/SceneBuilder.cpp
浏览文件 @
ab927e23
...
...
@@ -4,9 +4,8 @@
#include "sky/engine/core/compositing/SceneBuilder.h"
#include "sky/engine/core/painting/Matrix.h"
#include "third_party/skia/include/core/SkColorFilter.h"
#include "sky/
compositor/transform_layer
.h"
#include "sky/
engine/core/painting/Matrix
.h"
#include "sky/compositor/clip_path_layer.h"
#include "sky/compositor/clip_rect_layer.h"
#include "sky/compositor/clip_rrect_layer.h"
...
...
@@ -14,6 +13,8 @@
#include "sky/compositor/container_layer.h"
#include "sky/compositor/opacity_layer.h"
#include "sky/compositor/picture_layer.h"
#include "sky/compositor/statistics_layer.h"
#include "sky/compositor/transform_layer.h"
namespace
blink
{
...
...
@@ -110,6 +111,15 @@ void SceneBuilder::addPicture(const Offset& offset, Picture* picture, const Rect
m_currentLayer
->
Add
(
std
::
move
(
layer
));
}
void
SceneBuilder
::
pushStatistics
(
uint64_t
enabledOptions
,
const
Rect
&
bounds
)
{
if
(
!
m_currentLayer
)
return
;
std
::
unique_ptr
<
sky
::
compositor
::
StatisticsLayer
>
layer
(
new
sky
::
compositor
::
StatisticsLayer
(
enabledOptions
));
layer
->
set_paint_bounds
(
bounds
.
sk_rect
);
m_currentLayer
->
Add
(
std
::
move
(
layer
));
}
PassRefPtr
<
Scene
>
SceneBuilder
::
build
()
{
m_currentLayer
=
nullptr
;
...
...
sky/engine/core/compositing/SceneBuilder.h
浏览文件 @
ab927e23
...
...
@@ -40,6 +40,8 @@ public:
void
pushClipPath
(
const
CanvasPath
*
path
,
const
Rect
&
bounds
);
void
pushOpacity
(
int
alpha
,
const
Rect
&
bounds
);
void
pushColorFilter
(
SkColor
color
,
SkXfermode
::
Mode
transferMode
,
const
Rect
&
bounds
);
void
pushStatistics
(
uint64_t
enabledOptions
,
const
Rect
&
bounds
);
void
pop
();
void
addPicture
(
const
Offset
&
offset
,
Picture
*
picture
,
const
Rect
&
bounds
);
...
...
sky/engine/core/compositing/SceneBuilder.idl
浏览文件 @
ab927e23
...
...
@@ -11,6 +11,7 @@
void
pushClipPath
(
Path
path
,
Rect
bounds
)
;
void
pushOpacity
(
long
alpha
,
Rect
bounds
)
;
void
pushColorFilter
(
Color
color
,
TransferMode
transferMode
,
Rect
bounds
)
;
void
pushStatistics
(
unsigned
long
enabledOptions
,
Rect
bounds
)
;
void
pop
()
;
void
addPicture
(
Offset
offset
,
Picture
picture
,
Rect
bounds
)
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录