Skip to content

Commit

Permalink
Merge r269588 - [TextureMapper] The top and left sides of drop-shadow…
Browse files Browse the repository at this point in the history
… are clipped

https://bugs.webkit.org/show_bug.cgi?id=218647

Reviewed by Don Olmstead.

Source/WebCore:

TextureMapperLayer::computeOverlapRegions incorrectly calculated
the local bounding rect for top and left of outsets.

The drop-shadow was incorrectly blended with the content.

Test: compositing/filters/drop-shadow.html

* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::computeOverlapRegions): Stopped
using std::max for the left and top of outsets. Stopped taking the
unite with unfilteredTargetRect because outsets are always
positive.
* platform/graphics/texmap/TextureMapperShaderProgram.cpp:
Fixed sourceOver().

LayoutTests:

* compositing/filters/drop-shadow-expected.html: Added.
* compositing/filters/drop-shadow.html: Added.
  • Loading branch information
fujii authored and carlosgcampos committed Nov 20, 2020
1 parent 66a605f commit 866dfa8
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 4 deletions.
10 changes: 10 additions & 0 deletions LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
2020-11-09 Fujii Hironori <Hironori.Fujii@sony.com>

[TextureMapper] The top and left sides of drop-shadow are clipped
https://bugs.webkit.org/show_bug.cgi?id=218647

Reviewed by Don Olmstead.

* compositing/filters/drop-shadow-expected.html: Added.
* compositing/filters/drop-shadow.html: Added.

2020-11-08 Fujii Hironori <Hironori.Fujii@sony.com>

TextureMapperLayer::computeOverlapRegions: Accumulate nested replica transform matrices recursively
Expand Down
40 changes: 40 additions & 0 deletions LayoutTests/compositing/filters/drop-shadow-expected.html
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html>
<head>
<style>
#x {
transform: translate(100px, 100px);
}
div div {
position: absolute;
width: 100px;
height: 100px;
background: green;
}
.a {
transform: translate(-60px, -60px);
filter: drop-shadow(-20px -20px 0px blue);
}
.b {
transform: translate(-60px, 60px);
filter: drop-shadow(-20px 20px 0px blue);
}
.c {
transform: translate(60px, -60px);
filter: drop-shadow(20px -20px 0px blue);
}
.d {
transform: translate(60px, 60px);
filter: drop-shadow(20px 20px 0px blue);
}
</style>
</head>
<body>
<div id=x>
<div class=a></div>
<div class=b></div>
<div class=c></div>
<div class=d></div>
</div>
</body>
</html>
41 changes: 41 additions & 0 deletions LayoutTests/compositing/filters/drop-shadow.html
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html>
<head>
<style>
#x {
transform: translate(100px, 100px);
}
div div {
position: absolute;
width: 100px;
height: 100px;
background: green;
will-change: transform;
}
.a {
transform: translate(-60px, -60px);
filter: drop-shadow(-20px -20px 0px blue);
}
.b {
transform: translate(-60px, 60px);
filter: drop-shadow(-20px 20px 0px blue);
}
.c {
transform: translate(60px, -60px);
filter: drop-shadow(20px -20px 0px blue);
}
.d {
transform: translate(60px, 60px);
filter: drop-shadow(20px 20px 0px blue);
}
</style>
</head>
<body>
<div id=x>
<div class=a></div>
<div class=b></div>
<div class=c></div>
<div class=d></div>
</div>
</body>
</html>
22 changes: 22 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,25 @@
2020-11-09 Fujii Hironori <Hironori.Fujii@sony.com>

[TextureMapper] The top and left sides of drop-shadow are clipped
https://bugs.webkit.org/show_bug.cgi?id=218647

Reviewed by Don Olmstead.

TextureMapperLayer::computeOverlapRegions incorrectly calculated
the local bounding rect for top and left of outsets.

The drop-shadow was incorrectly blended with the content.

Test: compositing/filters/drop-shadow.html

* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::computeOverlapRegions): Stopped
using std::max for the left and top of outsets. Stopped taking the
unite with unfilteredTargetRect because outsets are always
positive.
* platform/graphics/texmap/TextureMapperShaderProgram.cpp:
Fixed sourceOver().

2020-11-08 Fujii Hironori <Hironori.Fujii@sony.com>

TextureMapperLayer::computeOverlapRegions: Accumulate nested replica transform matrices recursively
Expand Down
Expand Up @@ -332,10 +332,8 @@ void TextureMapperLayer::computeOverlapRegions(ComputeOverlapRegionData& data, c

if (m_currentFilters.hasOutsets()) {
auto outsets = m_currentFilters.outsets();
IntRect unfilteredTargetRect(localBoundingRect);
localBoundingRect.move(std::max(0, -outsets.left()), std::max(0, -outsets.top()));
localBoundingRect.move(-outsets.left(), -outsets.top());
localBoundingRect.expand(outsets.left() + outsets.right(), outsets.top() + outsets.bottom());
localBoundingRect.unite(unfilteredTargetRect);
}

TransformationMatrix transform(accumulatedReplicaTransform);
Expand Down
Expand Up @@ -393,7 +393,7 @@ static const char* fragmentTemplateCommon =
color *= total;
}

vec4 sourceOver(vec4 src, vec4 dst) { return src + dst * (1. - dst.a); }
vec4 sourceOver(vec4 src, vec4 dst) { return src + dst * (1. - src.a); }

void applyContentTexture(inout vec4 color, vec2 texCoord)
{
Expand Down

0 comments on commit 866dfa8

Please sign in to comment.