Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
2b994d5d
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
2b994d5d
编写于
1月 20, 2021
作者:
F
Ferhat
提交者:
GitHub
1月 20, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[web] Fix shadow rendering using boxshadow due to webkit repaint area bug (#23769)
上级
6dec8063
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
67 addition
and
5 deletion
+67
-5
lib/web_ui/dev/goldens_lock.yaml
lib/web_ui/dev/goldens_lock.yaml
+1
-1
lib/web_ui/lib/src/engine/dom_canvas.dart
lib/web_ui/lib/src/engine/dom_canvas.dart
+23
-3
lib/web_ui/test/golden_tests/engine/dom_mask_filter_test.dart
...web_ui/test/golden_tests/engine/dom_mask_filter_test.dart
+42
-0
lib/web_ui/test/golden_tests/engine/recording_canvas_golden_test.dart
...est/golden_tests/engine/recording_canvas_golden_test.dart
+1
-1
未找到文件。
lib/web_ui/dev/goldens_lock.yaml
浏览文件 @
2b994d5d
repository
:
https://github.com/flutter/goldens.git
revision
:
ee03ff97af36cbf9bd2627ef4e32f5a45676f96f
revision
:
510c545ee4dd94f7d620cdc51a9027fdd8e521bc
lib/web_ui/lib/src/engine/dom_canvas.dart
浏览文件 @
2b994d5d
...
...
@@ -135,6 +135,17 @@ class DomCanvas extends EngineCanvas with SaveElementStackTracking {
}
}
/// Converts a shadow color specified by the framework to the color that should
/// actually be applied when rendering the element.
///
/// Returns a color for box-shadow based on blur filter at sigma.
ui
.
Color
blurColor
(
ui
.
Color
color
,
double
sigma
)
{
final
double
strength
=
math
.
min
(
math
.
sqrt
(
sigma
)
/
(
math
.
pi
*
2.0
),
1.0
);
final
int
reducedAlpha
=
((
1.0
-
strength
)
*
color
.
alpha
).
round
();
return
ui
.
Color
((
reducedAlpha
&
0xff
)
<<
24
|
(
color
.
value
&
0x00ffffff
));
}
html
.
HtmlElement
_buildDrawRectElement
(
ui
.
Rect
rect
,
SurfacePaintData
paint
,
String
tagName
,
Matrix4
transform
)
{
assert
(
paint
.
shader
==
null
);
...
...
@@ -175,11 +186,20 @@ html.HtmlElement _buildDrawRectElement(ui.Rect rect, SurfacePaintData paint, Str
..
transformOrigin
=
'0 0 0'
..
transform
=
effectiveTransform
;
final
String
cssColor
=
paint
.
color
==
null
?
'#000000'
:
colorToCssString
(
paint
.
color
)!;
String
cssColor
=
paint
.
color
==
null
?
'#000000'
:
colorToCssString
(
paint
.
color
)!;
if
(
paint
.
maskFilter
!=
null
)
{
style
.
filter
=
'blur(
${paint.maskFilter!.webOnlySigma}
px)'
;
final
double
sigma
=
paint
.
maskFilter
!.
webOnlySigma
;
if
(
browserEngine
==
BrowserEngine
.
webkit
&&
!
isStroke
)
{
// A bug in webkit leaves artifacts when this element is animated
// with filter: blur, we use boxShadow instead.
style
.
boxShadow
=
'0px 0px
${sigma * 2.0}
px
$cssColor
'
;
cssColor
=
colorToCssString
(
blurColor
(
paint
.
color
??
const
ui
.
Color
(
0xFF000000
),
sigma
))!;
}
else
{
style
.
filter
=
'blur(
${sigma}
px)'
;
}
}
if
(
isStroke
)
{
...
...
lib/web_ui/test/golden_tests/engine/dom_mask_filter_test.dart
0 → 100644
浏览文件 @
2b994d5d
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import
'package:test/bootstrap/browser.dart'
;
import
'package:test/test.dart'
;
import
'package:ui/ui.dart'
hide
TextStyle
;
import
'package:ui/src/engine.dart'
;
import
'screenshot.dart'
;
void
main
(
)
{
internalBootstrapBrowserTest
(()
=>
testMain
);
}
void
testMain
(
)
async
{
const
double
screenWidth
=
500.0
;
const
double
screenHeight
=
500.0
;
const
Rect
screenRect
=
Rect
.
fromLTWH
(
0
,
0
,
screenWidth
,
screenHeight
);
setUp
(()
async
{
debugEmulateFlutterTesterEnvironment
=
true
;
await
webOnlyInitializePlatform
();
webOnlyFontCollection
.
debugRegisterTestFonts
();
await
webOnlyFontCollection
.
ensureFontsLoaded
();
});
test
(
'Should blur rectangles based on sigma.'
,
()
async
{
final
RecordingCanvas
rc
=
RecordingCanvas
(
const
Rect
.
fromLTRB
(
0
,
0
,
500
,
500
));
for
(
int
blurSigma
=
1
;
blurSigma
<
10
;
blurSigma
+=
2
)
{
final
Paint
paint
=
Paint
()
..
color
=
Color
(
0xFF2fdfd2
)
..
maskFilter
=
MaskFilter
.
blur
(
BlurStyle
.
normal
,
blurSigma
.
toDouble
());
rc
.
drawRect
(
Rect
.
fromLTWH
(
15.0
,
15.0
+
blurSigma
*
40
,
200
,
20
),
paint
);
}
await
canvasScreenshot
(
rc
,
'dom_mask_filter_blur'
,
region:
screenRect
,
maxDiffRatePercent:
0.01
);
});
}
lib/web_ui/test/golden_tests/engine/recording_canvas_golden_test.dart
浏览文件 @
2b994d5d
...
...
@@ -679,7 +679,7 @@ void testMain() async {
await
matchGoldenFile
(
'paint_spread_bounds.png'
,
region:
const
Rect
.
fromLTRB
(
0
,
0
,
250
,
600
),
maxDiffRatePercent:
0.2
,
maxDiffRatePercent:
0.2
1
,
pixelComparison:
PixelComparison
.
precise
,
);
}
finally
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录