Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_34031325
engine
提交
802bd151
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,发现更多精彩内容 >>
未验证
提交
802bd151
编写于
7月 08, 2019
作者:
C
Chris Yang
提交者:
GitHub
7月 08, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
iOS platform view opacity (#9667)
上级
3b6265b7
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
58 addition
and
2 deletion
+58
-2
flow/embedded_views.cc
flow/embedded_views.cc
+5
-0
flow/embedded_views.h
flow/embedded_views.h
+11
-1
flow/layers/opacity_layer.cc
flow/layers/opacity_layer.cc
+5
-0
flow/mutators_stack_unittests.cc
flow/mutators_stack_unittests.cc
+33
-1
shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm
...tform/darwin/ios/framework/Source/FlutterPlatformViews.mm
+4
-0
未找到文件。
flow/embedded_views.cc
浏览文件 @
802bd151
...
...
@@ -30,6 +30,11 @@ void MutatorsStack::PushTransform(const SkMatrix& matrix) {
vector_
.
push_back
(
element
);
};
void
MutatorsStack
::
PushOpacity
(
const
int
&
alpha
)
{
std
::
shared_ptr
<
Mutator
>
element
=
std
::
make_shared
<
Mutator
>
(
alpha
);
vector_
.
push_back
(
element
);
};
void
MutatorsStack
::
Pop
()
{
vector_
.
pop_back
();
};
...
...
flow/embedded_views.h
浏览文件 @
802bd151
...
...
@@ -17,7 +17,7 @@
namespace
flutter
{
enum
MutatorType
{
clip_rect
,
clip_rrect
,
clip_path
,
transform
};
enum
MutatorType
{
clip_rect
,
clip_rrect
,
clip_path
,
transform
,
opacity
};
// Stores mutation information like clipping or transform.
//
...
...
@@ -42,6 +42,9 @@ class Mutator {
case
transform
:
matrix_
=
other
.
matrix_
;
break
;
case
opacity
:
alpha_
=
other
.
alpha_
;
break
;
default:
break
;
}
...
...
@@ -53,12 +56,15 @@ class Mutator {
:
type_
(
clip_path
),
path_
(
new
SkPath
(
path
))
{}
explicit
Mutator
(
const
SkMatrix
&
matrix
)
:
type_
(
transform
),
matrix_
(
matrix
)
{}
explicit
Mutator
(
const
int
&
alpha
)
:
type_
(
opacity
),
alpha_
(
alpha
)
{}
const
MutatorType
&
GetType
()
const
{
return
type_
;
}
const
SkRect
&
GetRect
()
const
{
return
rect_
;
}
const
SkRRect
&
GetRRect
()
const
{
return
rrect_
;
}
const
SkPath
&
GetPath
()
const
{
return
*
path_
;
}
const
SkMatrix
&
GetMatrix
()
const
{
return
matrix_
;
}
const
int
&
GetAlpha
()
const
{
return
alpha_
;
}
float
GetAlphaFloat
()
const
{
return
(
alpha_
/
255.0
);
}
bool
operator
==
(
const
Mutator
&
other
)
const
{
if
(
type_
!=
other
.
type_
)
{
...
...
@@ -73,6 +79,8 @@ class Mutator {
return
*
path_
==
*
other
.
path_
;
case
transform
:
return
matrix_
==
other
.
matrix_
;
case
opacity
:
return
alpha_
==
other
.
alpha_
;
}
return
false
;
...
...
@@ -98,6 +106,7 @@ class Mutator {
SkRRect
rrect_
;
SkMatrix
matrix_
;
SkPath
*
path_
;
int
alpha_
;
};
};
// Mutator
...
...
@@ -119,6 +128,7 @@ class MutatorsStack {
void
PushClipRRect
(
const
SkRRect
&
rrect
);
void
PushClipPath
(
const
SkPath
&
path
);
void
PushTransform
(
const
SkMatrix
&
matrix
);
void
PushOpacity
(
const
int
&
alpha
);
// Removes the `Mutator` on the top of the stack
// and destroys it.
...
...
flow/layers/opacity_layer.cc
浏览文件 @
802bd151
...
...
@@ -37,7 +37,12 @@ void OpacityLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
EnsureSingleChild
();
SkMatrix
child_matrix
=
matrix
;
child_matrix
.
postTranslate
(
offset_
.
fX
,
offset_
.
fY
);
context
->
mutators_stack
.
PushTransform
(
SkMatrix
::
MakeTrans
(
offset_
.
fX
,
offset_
.
fY
));
context
->
mutators_stack
.
PushOpacity
(
alpha_
);
ContainerLayer
::
Preroll
(
context
,
child_matrix
);
context
->
mutators_stack
.
Pop
();
context
->
mutators_stack
.
Pop
();
set_paint_bounds
(
paint_bounds
().
makeOffset
(
offset_
.
fX
,
offset_
.
fY
));
// See |EnsureSingleChild|.
FML_DCHECK
(
layers
().
size
()
==
1
);
...
...
flow/mutators_stack_unittests.cc
浏览文件 @
802bd151
...
...
@@ -42,7 +42,7 @@ TEST(MutatorsStack, PushClipRRect) {
}
TEST
(
MutatorsStack
,
PushClipPath
)
{
flutter
::
MutatorsStack
stack
;
MutatorsStack
stack
;
SkPath
path
;
stack
.
PushClipPath
(
path
);
auto
iter
=
stack
.
Bottom
();
...
...
@@ -60,6 +60,15 @@ TEST(MutatorsStack, PushTransform) {
ASSERT_TRUE
(
iter
->
get
()
->
GetMatrix
()
==
matrix
);
}
TEST
(
MutatorsStack
,
PushOpacity
)
{
MutatorsStack
stack
;
int
alpha
=
240
;
stack
.
PushOpacity
(
alpha
);
auto
iter
=
stack
.
Bottom
();
ASSERT_TRUE
(
iter
->
get
()
->
GetType
()
==
MutatorType
::
opacity
);
ASSERT_TRUE
(
iter
->
get
()
->
GetAlpha
()
==
240
);
}
TEST
(
MutatorsStack
,
Pop
)
{
MutatorsStack
stack
;
SkMatrix
matrix
;
...
...
@@ -113,6 +122,8 @@ TEST(MutatorsStack, Equality) {
stack
.
PushClipRRect
(
rrect
);
SkPath
path
;
stack
.
PushClipPath
(
path
);
int
alpha
=
240
;
stack
.
PushOpacity
(
alpha
);
MutatorsStack
stackOther
;
SkMatrix
matrixOther
=
SkMatrix
::
MakeScale
(
1
,
1
);
...
...
@@ -123,6 +134,8 @@ TEST(MutatorsStack, Equality) {
stackOther
.
PushClipRRect
(
rrectOther
);
SkPath
otherPath
;
stackOther
.
PushClipPath
(
otherPath
);
int
otherAlpha
=
240
;
stackOther
.
PushOpacity
(
otherAlpha
);
ASSERT_TRUE
(
stack
==
stackOther
);
}
...
...
@@ -148,6 +161,10 @@ TEST(Mutator, Initialization) {
Mutator
mutator4
=
Mutator
(
matrix
);
ASSERT_TRUE
(
mutator4
.
GetType
()
==
MutatorType
::
transform
);
ASSERT_TRUE
(
mutator4
.
GetMatrix
()
==
matrix
);
int
alpha
=
240
;
Mutator
mutator5
=
Mutator
(
alpha
);
ASSERT_TRUE
(
mutator5
.
GetType
()
==
MutatorType
::
opacity
);
}
TEST
(
Mutator
,
CopyConstructor
)
{
...
...
@@ -171,6 +188,11 @@ TEST(Mutator, CopyConstructor) {
Mutator
mutator4
=
Mutator
(
matrix
);
Mutator
copy4
=
Mutator
(
mutator4
);
ASSERT_TRUE
(
mutator4
==
copy4
);
int
alpha
=
240
;
Mutator
mutator5
=
Mutator
(
alpha
);
Mutator
copy5
=
Mutator
(
mutator5
);
ASSERT_TRUE
(
mutator5
==
copy5
);
}
TEST
(
Mutator
,
Equality
)
{
...
...
@@ -195,6 +217,10 @@ TEST(Mutator, Equality) {
flutter
::
Mutator
otherMutator4
=
flutter
::
Mutator
(
path
);
ASSERT_TRUE
(
mutator4
==
otherMutator4
);
ASSERT_FALSE
(
mutator2
==
mutator
);
int
alpha
=
240
;
Mutator
mutator5
=
Mutator
(
alpha
);
Mutator
otherMutator5
=
Mutator
(
alpha
);
ASSERT_TRUE
(
mutator5
==
otherMutator5
);
}
TEST
(
Mutator
,
UnEquality
)
{
...
...
@@ -204,6 +230,12 @@ TEST(Mutator, UnEquality) {
matrix
.
setIdentity
();
Mutator
notEqualMutator
=
Mutator
(
matrix
);
ASSERT_TRUE
(
notEqualMutator
!=
mutator
);
int
alpha
=
240
;
int
alpha2
=
241
;
Mutator
mutator2
=
Mutator
(
alpha
);
Mutator
otherMutator2
=
Mutator
(
alpha2
);
ASSERT_TRUE
(
mutator2
!=
otherMutator2
);
}
}
// namespace testing
...
...
shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm
浏览文件 @
802bd151
...
...
@@ -278,6 +278,9 @@ void FlutterPlatformViewsController::ApplyMutators(const MutatorsStack& mutators
head
=
clipView
;
break
;
}
case
opacity
:
embedded_view
.
alpha
=
(
*
iter
)
->
GetAlphaFloat
()
*
embedded_view
.
alpha
;
break
;
}
++
iter
;
}
...
...
@@ -299,6 +302,7 @@ void FlutterPlatformViewsController::CompositeWithParams(int view_id,
UIView
*
touchInterceptor
=
touch_interceptors_
[
view_id
].
get
();
touchInterceptor
.
layer
.
transform
=
CATransform3DIdentity
;
touchInterceptor
.
frame
=
frame
;
touchInterceptor
.
alpha
=
1
;
int
currentClippingCount
=
CountClips
(
params
.
mutatorsStack
);
int
previousClippingCount
=
clip_count_
[
view_id
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录