Skip to content

Commit f066186

Browse files
committed
REGRESSION (296827@main): Opacity/filter render incorrectly.
https://bugs.webkit.org/show_bug.cgi?id=299270 <rdar://problem/161130683> Reviewed by Said Abou-Hallawa. The canPaintTransparencyWithSetOpacity optimization only works if we have a single bitmap paint that the opacity can be passed to. When combined with a filter effect that pushes a transparency layer, it no longer has any effect. Test: css3/filters/filter-and-opacity-on-bitmap.html * LayoutTests/css3/filters/filter-and-opacity-on-bitmap-expected.html: Added. * LayoutTests/css3/filters/filter-and-opacity-on-bitmap.html: Added. * LayoutTests/css3/filters/filter-and-opacity-on-bitmap-2-expected.html: Added. * LayoutTests/css3/filters/filter-and-opacity-on-bitmap-2.html: Added. * Source/WebCore/rendering/RenderLayerInlines.h: (WebCore::RenderLayer::canPaintTransparencyWithSetOpacity const): Canonical link: https://commits.webkit.org/300549@main
1 parent 435b354 commit f066186

File tree

5 files changed

+99
-1
lines changed

5 files changed

+99
-1
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<style>
5+
.box {
6+
display: block;
7+
margin: 10px;
8+
width: 200px;
9+
height: 200px;
10+
}
11+
.control {
12+
filter: url(#erode);
13+
}
14+
.container {
15+
opacity: 0.5;
16+
}
17+
</style>
18+
</head>
19+
<body>
20+
<svg width="0" height="0">
21+
<filter id="erode" filterUnits="userSpaceOnUse">
22+
<feMorphology operator="erode" radius="2" />
23+
</filter>
24+
</svg>
25+
<div class="container">
26+
<img class="control box" src="resources/reference.png">
27+
</div>
28+
</body>
29+
</html>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<style>
5+
.box {
6+
display: block;
7+
margin: 10px;
8+
width: 200px;
9+
height: 200px;
10+
}
11+
.test {
12+
filter: url(#erode);
13+
opacity: 0.5;
14+
}
15+
</style>
16+
</head>
17+
<body>
18+
<svg width="0" height="0">
19+
<filter id="erode" filterUnits="userSpaceOnUse">
20+
<feMorphology operator="erode" radius="2" />
21+
</filter>
22+
</svg>
23+
<img class="test box" src="resources/reference.png">
24+
</body>
25+
</html>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<style>
5+
.box {
6+
display: block;
7+
margin: 10px;
8+
width: 200px;
9+
height: 200px;
10+
}
11+
.control {
12+
filter: saturate(0);
13+
}
14+
.container {
15+
opacity: 0.5;
16+
}
17+
</style>
18+
</head>
19+
<body>
20+
<div class="container">
21+
<img class="control box" src="resources/reference.png">
22+
</div>
23+
</body>
24+
</html>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<style>
5+
.box {
6+
display: block;
7+
margin: 10px;
8+
width: 200px;
9+
height: 200px;
10+
}
11+
.test {
12+
filter: saturate(0);
13+
opacity: 0.5;
14+
}
15+
</style>
16+
</head>
17+
<body>
18+
<img class="test box" src="resources/reference.png">
19+
</body>
20+
</html>

Source/WebCore/rendering/RenderLayerInlines.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
namespace WebCore {
3131

32-
inline bool RenderLayer::canPaintTransparencyWithSetOpacity() const { return isBitmapOnly() && !hasNonOpacityTransparency(); }
32+
inline bool RenderLayer::canPaintTransparencyWithSetOpacity() const { return isBitmapOnly() && !hasNonOpacityTransparency() && !hasFilter(); }
3333
inline bool RenderLayer::hasBackdropFilter() const { return renderer().hasBackdropFilter(); }
3434
inline bool RenderLayer::hasFilter() const { return renderer().hasFilter(); }
3535
inline bool RenderLayer::hasPerspective() const { return renderer().style().hasPerspective(); }

0 commit comments

Comments
 (0)