Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
cdb5b2af
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,发现更多精彩内容 >>
未验证
提交
cdb5b2af
编写于
11月 11, 2020
作者:
Y
Yegor
提交者:
GitHub
11月 11, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove double-referencing from CkImage to SkImage (#22415)
上级
5419f70f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
43 addition
and
42 deletion
+43
-42
lib/web_ui/lib/src/engine/canvaskit/image.dart
lib/web_ui/lib/src/engine/canvaskit/image.dart
+18
-25
lib/web_ui/lib/src/engine/canvaskit/shader.dart
lib/web_ui/lib/src/engine/canvaskit/shader.dart
+3
-3
lib/web_ui/lib/src/engine/canvaskit/skia_object_cache.dart
lib/web_ui/lib/src/engine/canvaskit/skia_object_cache.dart
+9
-8
lib/web_ui/test/canvaskit/skia_objects_cache_test.dart
lib/web_ui/test/canvaskit/skia_objects_cache_test.dart
+13
-6
未找到文件。
lib/web_ui/lib/src/engine/canvaskit/image.dart
浏览文件 @
cdb5b2af
...
...
@@ -46,22 +46,18 @@ Future<ui.Codec> skiaInstantiateWebImageCodec(
/// A wrapper for `SkAnimatedImage`.
class
CkAnimatedImage
implements
ui
.
Image
{
final
SkAnimatedImage
_skAnimatedImage
;
// Use a box because `SkImage` may be deleted either due to this object
// being garbage-collected, or by an explicit call to [delete].
late
final
SkiaObjectBox
box
;
late
final
SkiaObjectBox
<
SkAnimatedImage
>
box
;
CkAnimatedImage
(
SkAnimatedImage
skAnimatedImage
)
:
this
.
_
(
skAnimatedImage
,
null
);
SkAnimatedImage
get
_skAnimatedImage
=>
box
.
skObject
;
CkAnimatedImage
.
_
(
this
.
_skAnimatedImage
,
SkiaObjectBox
?
boxToClone
)
{
if
(
boxToClone
!=
null
)
{
assert
(
boxToClone
.
skObject
==
_skAnimatedImage
);
box
=
boxToClone
.
clone
(
this
);
}
else
{
box
=
SkiaObjectBox
(
this
,
_skAnimatedImage
as
SkDeletable
);
}
CkAnimatedImage
(
SkAnimatedImage
skAnimatedImage
)
{
box
=
SkiaObjectBox
<
SkAnimatedImage
>(
this
,
skAnimatedImage
);
}
CkAnimatedImage
.
cloneOf
(
SkiaObjectBox
<
SkAnimatedImage
>
boxToClone
)
{
box
=
boxToClone
.
clone
(
this
);
}
bool
_disposed
=
false
;
...
...
@@ -80,7 +76,7 @@ class CkAnimatedImage implements ui.Image {
'Image.debugDisposed is only available when asserts are enabled.'
);
}
ui
.
Image
clone
()
=>
CkAnimatedImage
.
_
(
_skAnimatedImage
,
box
);
ui
.
Image
clone
()
=>
CkAnimatedImage
.
cloneOf
(
box
);
@override
bool
isCloneOf
(
ui
.
Image
other
)
{
...
...
@@ -143,21 +139,18 @@ class CkAnimatedImage implements ui.Image {
/// A [ui.Image] backed by an `SkImage` from Skia.
class
CkImage
implements
ui
.
Image
{
final
SkImage
skImage
;
// Use a box because `SkImage` may be deleted either due to this object
// being garbage-collected, or by an explicit call to [delete].
late
final
SkiaObjectBox
box
;
late
final
SkiaObjectBox
<
SkImage
>
box
;
CkImage
(
SkImage
skImage
)
:
this
.
_
(
skImage
,
null
)
;
SkImage
get
skImage
=>
box
.
skObject
;
CkImage
.
_
(
this
.
skImage
,
SkiaObjectBox
?
boxToClone
)
{
if
(
boxToClone
!=
null
)
{
assert
(
boxToClone
.
skObject
==
skImage
);
box
=
boxToClone
.
clone
(
this
);
}
else
{
box
=
SkiaObjectBox
(
this
,
skImage
as
SkDeletable
);
}
CkImage
(
SkImage
skImage
)
{
box
=
SkiaObjectBox
<
SkImage
>(
this
,
skImage
);
}
CkImage
.
cloneOf
(
SkiaObjectBox
<
SkImage
>
boxToClone
)
{
box
=
boxToClone
.
clone
(
this
);
}
bool
_disposed
=
false
;
...
...
@@ -180,7 +173,7 @@ class CkImage implements ui.Image {
}
@override
ui
.
Image
clone
()
=>
CkImage
.
_
(
skImage
,
box
);
ui
.
Image
clone
()
=>
CkImage
.
cloneOf
(
box
);
@override
bool
isCloneOf
(
ui
.
Image
other
)
{
...
...
lib/web_ui/lib/src/engine/canvaskit/shader.dart
浏览文件 @
cdb5b2af
...
...
@@ -162,15 +162,15 @@ class CkGradientConical extends CkShader implements ui.Gradient {
class
CkImageShader
extends
CkShader
implements
ui
.
ImageShader
{
CkImageShader
(
ui
.
Image
image
,
this
.
tileModeX
,
this
.
tileModeY
,
this
.
matrix4
)
:
_
skI
mage
=
image
as
CkImage
;
:
_
i
mage
=
image
as
CkImage
;
final
ui
.
TileMode
tileModeX
;
final
ui
.
TileMode
tileModeY
;
final
Float64List
matrix4
;
final
CkImage
_
skI
mage
;
final
CkImage
_
i
mage
;
@override
SkShader
createDefault
()
=>
_
skI
mage
.
skImage
.
makeShader
(
SkShader
createDefault
()
=>
_
i
mage
.
skImage
.
makeShader
(
toSkTileMode
(
tileModeX
),
toSkTileMode
(
tileModeY
),
toSkMatrixFromFloat64
(
matrix4
),
...
...
lib/web_ui/lib/src/engine/canvaskit/skia_object_cache.dart
浏览文件 @
cdb5b2af
...
...
@@ -250,11 +250,11 @@ abstract class OneShotSkiaObject<T extends Object> extends SkiaObject<T> {
///
/// The [delete] method may be called any number of times. The box
/// will only delete the object once.
class
SkiaObjectBox
{
SkiaObjectBox
(
Object
wrapper
,
SkDeletable
skObject
)
:
this
.
_
(
wrapper
,
skObject
,
<
SkiaObjectBox
>{});
class
SkiaObjectBox
<
T
>
{
SkiaObjectBox
(
Object
wrapper
,
T
skObject
)
:
this
.
_
(
wrapper
,
skObject
,
skObject
as
SkDeletable
,
<
SkiaObjectBox
>{});
SkiaObjectBox
.
_
(
Object
wrapper
,
this
.
skObject
,
this
.
_refs
)
{
SkiaObjectBox
.
_
(
Object
wrapper
,
this
.
skObject
,
this
.
_
skDeletable
,
this
.
_
refs
)
{
if
(
assertionsEnabled
)
{
_debugStackTrace
=
StackTrace
.
current
;
}
...
...
@@ -280,7 +280,8 @@ class SkiaObjectBox {
}
/// The Skia object whose lifecycle is being managed.
final
SkDeletable
skObject
;
final
T
skObject
;
final
SkDeletable
_skDeletable
;
/// Whether this object has been deleted.
bool
get
isDeleted
=>
_isDeleted
;
...
...
@@ -295,10 +296,10 @@ class SkiaObjectBox {
/// Returns a clone of this object, which increases its reference count.
///
/// Clones must be [dispose]d when finished.
SkiaObjectBox
clone
(
Object
wrapper
)
{
SkiaObjectBox
<
T
>
clone
(
Object
wrapper
)
{
assert
(!
_isDeleted
,
'Cannot clone from a deleted handle.'
);
assert
(
_refs
.
isNotEmpty
);
return
SkiaObjectBox
.
_
(
wrapper
,
skObject
,
_refs
);
return
SkiaObjectBox
<
T
>.
_
(
wrapper
,
skObject
,
_skDeletable
,
_refs
);
}
/// Decrements the reference count for the [skObject].
...
...
@@ -316,7 +317,7 @@ class SkiaObjectBox {
assert
(
removed
);
_isDeleted
=
true
;
if
(
_refs
.
isEmpty
)
{
_scheduleSkObjectCollection
(
skObject
);
_scheduleSkObjectCollection
(
_skDeletable
);
}
}
}
...
...
lib/web_ui/test/canvaskit/skia_objects_cache_test.dart
浏览文件 @
cdb5b2af
...
...
@@ -155,13 +155,11 @@ void _tests() {
});
});
group
(
SkiaObjectBox
,
()
{
test
(
'Records stack traces and respects refcounts'
,
()
async
{
TestOneShotSkiaObject
.
deleteCount
=
0
;
final
TestOneShotSkiaObject
skObject
=
TestOneShotSkiaObject
();
TestSkDeletable
.
deleteCount
=
0
;
final
Object
wrapper
=
Object
();
final
SkiaObjectBox
box
=
SkiaObjectBox
(
wrapper
,
skObject
);
final
SkiaObjectBox
<
TestSkDeletable
>
box
=
SkiaObjectBox
<
TestSkDeletable
>(
wrapper
,
TestSkDeletable
()
);
expect
(
box
.
debugGetStackTraces
().
length
,
1
);
...
...
@@ -178,7 +176,7 @@ void _tests() {
// Let any timers elapse.
await
Future
<
void
>.
delayed
(
Duration
.
zero
);
expect
(
Test
OneShotSkiaObject
.
deleteCount
,
0
);
expect
(
Test
SkDeletable
.
deleteCount
,
0
);
expect
(
clone
.
debugGetStackTraces
().
length
,
1
);
expect
(
box
.
debugGetStackTraces
().
length
,
1
);
...
...
@@ -188,7 +186,7 @@ void _tests() {
// Let any timers elapse.
await
Future
<
void
>.
delayed
(
Duration
.
zero
);
expect
(
Test
OneShotSkiaObject
.
deleteCount
,
1
);
expect
(
Test
SkDeletable
.
deleteCount
,
1
);
expect
(
clone
.
debugGetStackTraces
().
length
,
0
);
expect
(
box
.
debugGetStackTraces
().
length
,
0
);
...
...
@@ -196,6 +194,15 @@ void _tests() {
});
}
class
TestSkDeletable
implements
SkDeletable
{
static
int
deleteCount
=
0
;
@override
void
delete
()
{
deleteCount
++;
}
}
class
TestOneShotSkiaObject
extends
OneShotSkiaObject
<
SkPaint
>
implements
SkDeletable
{
static
int
deleteCount
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录