Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
7e38261e
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,发现更多精彩内容 >>
未验证
提交
7e38261e
编写于
6月 04, 2020
作者:
D
Dan Field
提交者:
GitHub
6月 04, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Record path memory usage in SkPictures (#18827)
上级
5efd2e82
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
31 addition
and
0 deletion
+31
-0
lib/ui/painting/canvas.cc
lib/ui/painting/canvas.cc
+3
-0
lib/ui/painting/path.cc
lib/ui/painting/path.cc
+7
-0
lib/ui/painting/path.h
lib/ui/painting/path.h
+2
-0
testing/dart/canvas_test.dart
testing/dart/canvas_test.dart
+19
-0
未找到文件。
lib/ui/painting/canvas.cc
浏览文件 @
7e38261e
...
@@ -181,6 +181,7 @@ void Canvas::clipPath(const CanvasPath* path, bool doAntiAlias) {
...
@@ -181,6 +181,7 @@ void Canvas::clipPath(const CanvasPath* path, bool doAntiAlias) {
if
(
!
path
)
if
(
!
path
)
Dart_ThrowException
(
Dart_ThrowException
(
ToDart
(
"Canvas.clipPath called with non-genuine Path."
));
ToDart
(
"Canvas.clipPath called with non-genuine Path."
));
external_allocation_size_
+=
path
->
path
().
approximateBytesUsed
();
canvas_
->
clipPath
(
path
->
path
(),
doAntiAlias
);
canvas_
->
clipPath
(
path
->
path
(),
doAntiAlias
);
}
}
...
@@ -280,6 +281,7 @@ void Canvas::drawPath(const CanvasPath* path,
...
@@ -280,6 +281,7 @@ void Canvas::drawPath(const CanvasPath* path,
if
(
!
path
)
if
(
!
path
)
Dart_ThrowException
(
Dart_ThrowException
(
ToDart
(
"Canvas.drawPath called with non-genuine Path."
));
ToDart
(
"Canvas.drawPath called with non-genuine Path."
));
external_allocation_size_
+=
path
->
path
().
approximateBytesUsed
();
canvas_
->
drawPath
(
path
->
path
(),
*
paint
.
paint
());
canvas_
->
drawPath
(
path
->
path
(),
*
paint
.
paint
());
}
}
...
@@ -425,6 +427,7 @@ void Canvas::drawShadow(const CanvasPath* path,
...
@@ -425,6 +427,7 @@ void Canvas::drawShadow(const CanvasPath* path,
ToDart
(
"Canvas.drawShader called with non-genuine Path."
));
ToDart
(
"Canvas.drawShader called with non-genuine Path."
));
SkScalar
dpr
=
SkScalar
dpr
=
UIDartState
::
Current
()
->
window
()
->
viewport_metrics
().
device_pixel_ratio
;
UIDartState
::
Current
()
->
window
()
->
viewport_metrics
().
device_pixel_ratio
;
external_allocation_size_
+=
path
->
path
().
approximateBytesUsed
();
flutter
::
PhysicalShapeLayer
::
DrawShadow
(
canvas_
,
path
->
path
(),
color
,
flutter
::
PhysicalShapeLayer
::
DrawShadow
(
canvas_
,
path
->
path
(),
color
,
elevation
,
transparentOccluder
,
dpr
);
elevation
,
transparentOccluder
,
dpr
);
}
}
...
...
lib/ui/painting/path.cc
浏览文件 @
7e38261e
...
@@ -297,4 +297,11 @@ void CanvasPath::clone(Dart_Handle path_handle) {
...
@@ -297,4 +297,11 @@ void CanvasPath::clone(Dart_Handle path_handle) {
path
->
path_
=
path_
;
path
->
path_
=
path_
;
}
}
// This is doomed to be called too early, since Paths are mutable.
// However, it can help for some of the clone/shift/transform type methods
// where the resultant path will initially have a meaningful size.
size_t
CanvasPath
::
GetAllocationSize
()
const
{
return
sizeof
(
CanvasPath
)
+
path_
.
approximateBytesUsed
();
}
}
// namespace flutter
}
// namespace flutter
lib/ui/painting/path.h
浏览文件 @
7e38261e
...
@@ -110,6 +110,8 @@ class CanvasPath : public RefCountedDartWrappable<CanvasPath> {
...
@@ -110,6 +110,8 @@ class CanvasPath : public RefCountedDartWrappable<CanvasPath> {
const
SkPath
&
path
()
const
{
return
path_
;
}
const
SkPath
&
path
()
const
{
return
path_
;
}
size_t
GetAllocationSize
()
const
override
;
static
void
RegisterNatives
(
tonic
::
DartLibraryNatives
*
natives
);
static
void
RegisterNatives
(
tonic
::
DartLibraryNatives
*
natives
);
private:
private:
...
...
testing/dart/canvas_test.dart
浏览文件 @
7e38261e
...
@@ -286,4 +286,23 @@ void main() {
...
@@ -286,4 +286,23 @@ void main() {
expect
(
picture2
.
approximateBytesUsed
,
greaterThan
(
minimumExpected
));
expect
(
picture2
.
approximateBytesUsed
,
greaterThan
(
minimumExpected
));
});
});
test
(
'Path reflected in picture size for drawPath, clipPath, and drawShadow'
,
()
async
{
final
PictureRecorder
recorder
=
PictureRecorder
();
final
Canvas
canvas
=
Canvas
(
recorder
);
final
Path
path
=
Path
();
for
(
int
i
=
0
;
i
<
10000
;
i
++)
{
path
.
lineTo
(
5
,
9
);
path
.
lineTo
(
i
.
toDouble
(),
i
.
toDouble
());
}
path
.
close
();
canvas
.
drawPath
(
path
,
Paint
());
canvas
.
drawShadow
(
path
,
const
Color
(
0xFF000000
),
5.0
,
false
);
canvas
.
clipPath
(
path
);
final
Picture
picture
=
recorder
.
endRecording
();
// Slightly fuzzy here to allow for platform specific differences
// Measurement on macOS: 541078
expect
(
picture
.
approximateBytesUsed
,
greaterThan
(
530000
));
});
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录