Skip to content

Commit b8faeec

Browse files
committed
[GPU Process] Several tests in canvas/philip/tests are failing with text diffs
https://bugs.webkit.org/show_bug.cgi?id=216800 Reviewed by Darin Adler. When using the GPU process to render canvas elements, we currently fail the 7 tests in `canvas/philip/tests` below, due to gradient and pattern fill/stroke styles lingering on the 2D graphics context state after a fill or stroke color is set, respectively. This happens when: 1. The fill color is set to a color `C`. 2. A fill pattern or gradient is applied. 3. The fill color is set to the color `C` again. In this case, after step (2), we propagate a graphics context state change indicating that the fill pattern has changed, but we leave the fill color unchanged (i.e., it remains equal to `C`). In step (3), we then set the fill color to `C` again, which doesn't propagate a state change to the GPU process, since the fill color is the same (`C`). As such, the state in the GPU process keeps its fill gradient, and we end up filling with this old gradient instead of the fill color `C`. To fix this, we simply revert `fillColor` and `strokeColor` to the invalid color when setting a gradient or pattern in the same way that we currently clear out the fill/stroke gradient and pattern when setting a fill/ stroke color, which ensures that a state change will be sent to the GPU process during step (3). Fixes the following canvas-related layout tests when using the GPU process: - canvas/philip/tests/2d.gradient.radial.cone.shape2.html - canvas/philip/tests/2d.pattern.basic.nocontext.html - canvas/philip/tests/2d.pattern.paint.norepeat.coord3.html - canvas/philip/tests/2d.pattern.paint.repeatx.coord1.html - canvas/philip/tests/2d.pattern.paint.repeatx.outside.html - canvas/philip/tests/2d.pattern.paint.repeaty.coord1.html - canvas/philip/tests/2d.pattern.paint.repeaty.outside.html The entire canvas/ directory is currently skipped when enabling the GPU process for canvas rendering, but once we're down to a smaller number of failures, I intend to unskip these directories for GPU process, and individually track any remaining test failures. * platform/graphics/GraphicsContext.cpp: (WebCore::GraphicsContext::setStrokePattern): (WebCore::GraphicsContext::setFillPattern): (WebCore::GraphicsContext::setStrokeGradient): (WebCore::GraphicsContext::setFillGradient): Canonical link: https://commits.webkit.org/229596@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267382 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent a083f1a commit b8faeec

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

Source/WebCore/ChangeLog

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,48 @@
1+
2020-09-21 Wenson Hsieh <wenson_hsieh@apple.com>
2+
3+
[GPU Process] Several tests in canvas/philip/tests are failing with text diffs
4+
https://bugs.webkit.org/show_bug.cgi?id=216800
5+
6+
Reviewed by Darin Adler.
7+
8+
When using the GPU process to render canvas elements, we currently fail the 7 tests in `canvas/philip/tests`
9+
below, due to gradient and pattern fill/stroke styles lingering on the 2D graphics context state after a fill or
10+
stroke color is set, respectively.
11+
12+
This happens when:
13+
1. The fill color is set to a color `C`.
14+
2. A fill pattern or gradient is applied.
15+
3. The fill color is set to the color `C` again.
16+
17+
In this case, after step (2), we propagate a graphics context state change indicating that the fill pattern has
18+
changed, but we leave the fill color unchanged (i.e., it remains equal to `C`). In step (3), we then set the
19+
fill color to `C` again, which doesn't propagate a state change to the GPU process, since the fill color is the
20+
same (`C`). As such, the state in the GPU process keeps its fill gradient, and we end up filling with this old
21+
gradient instead of the fill color `C`.
22+
23+
To fix this, we simply revert `fillColor` and `strokeColor` to the invalid color when setting a gradient or
24+
pattern in the same way that we currently clear out the fill/stroke gradient and pattern when setting a fill/
25+
stroke color, which ensures that a state change will be sent to the GPU process during step (3).
26+
27+
Fixes the following canvas-related layout tests when using the GPU process:
28+
- canvas/philip/tests/2d.gradient.radial.cone.shape2.html
29+
- canvas/philip/tests/2d.pattern.basic.nocontext.html
30+
- canvas/philip/tests/2d.pattern.paint.norepeat.coord3.html
31+
- canvas/philip/tests/2d.pattern.paint.repeatx.coord1.html
32+
- canvas/philip/tests/2d.pattern.paint.repeatx.outside.html
33+
- canvas/philip/tests/2d.pattern.paint.repeaty.coord1.html
34+
- canvas/philip/tests/2d.pattern.paint.repeaty.outside.html
35+
36+
The entire canvas/ directory is currently skipped when enabling the GPU process for canvas rendering, but once
37+
we're down to a smaller number of failures, I intend to unskip these directories for GPU process, and
38+
individually track any remaining test failures.
39+
40+
* platform/graphics/GraphicsContext.cpp:
41+
(WebCore::GraphicsContext::setStrokePattern):
42+
(WebCore::GraphicsContext::setFillPattern):
43+
(WebCore::GraphicsContext::setStrokeGradient):
44+
(WebCore::GraphicsContext::setFillGradient):
45+
146
2020-09-21 Chris Dumez <cdumez@apple.com>
247

348
Properly handle AudioParam.setTargetAtTime() followed by a ramp

Source/WebCore/platform/graphics/GraphicsContext.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,7 @@ void GraphicsContext::setImageInterpolationQuality(InterpolationQuality imageInt
602602

603603
void GraphicsContext::setStrokePattern(Ref<Pattern>&& pattern)
604604
{
605+
m_state.strokeColor = { };
605606
m_state.strokeGradient = nullptr;
606607
m_state.strokePattern = WTFMove(pattern);
607608
if (m_impl)
@@ -610,6 +611,7 @@ void GraphicsContext::setStrokePattern(Ref<Pattern>&& pattern)
610611

611612
void GraphicsContext::setFillPattern(Ref<Pattern>&& pattern)
612613
{
614+
m_state.fillColor = { };
613615
m_state.fillGradient = nullptr;
614616
m_state.fillPattern = WTFMove(pattern);
615617
if (m_impl)
@@ -618,6 +620,7 @@ void GraphicsContext::setFillPattern(Ref<Pattern>&& pattern)
618620

619621
void GraphicsContext::setStrokeGradient(Ref<Gradient>&& gradient)
620622
{
623+
m_state.strokeColor = { };
621624
m_state.strokeGradient = WTFMove(gradient);
622625
m_state.strokePattern = nullptr;
623626
if (m_impl)
@@ -633,6 +636,7 @@ void GraphicsContext::setFillRule(WindRule fillRule)
633636

634637
void GraphicsContext::setFillGradient(Ref<Gradient>&& gradient)
635638
{
639+
m_state.fillColor = { };
636640
m_state.fillGradient = WTFMove(gradient);
637641
m_state.fillPattern = nullptr;
638642
if (m_impl)

0 commit comments

Comments
 (0)