Commit 19fb3bc
SVG text with gradient fill is rendered very slow
https://bugs.webkit.org/show_bug.cgi?id=285799#
rdar://73203473
Reviewed by Simon Fraser.
Refactor applying the SVG gradient resource into two appliers: one for text
(TextGradientClipper) and the other for PathOrShape (PathOrShapeGradientApplier).
TextGradientClipper draws the text into a mask ImageBuffer. Then GraphicsContext
is clipped to this ImageBuffer before the targetRect is filled with gradient.
PathOrShapeGradientApplier fills or strokes the path (or the shape) with the
gradient resource.
Add the new text applier TextGradientCompositor which draws the text into a
transparency layer with SourceIn. Then it fills the targetRect with the gradient
into another transparency layer with SourceOver. Then these two layers are
composited to GraphicsContext.
TextGradientCompositor will be used for all cases except when rendering to a
PDFDocument because PDF context does not support some CompositeOperation. In this
case TextGradientClipper will be used to draw the text.
* LayoutTests/imported/blink/svg/text/obb-paintserver.html:
* LayoutTests/imported/mozilla/svg/text-scale-02.svg:
* LayoutTests/imported/mozilla/svg/text/simple-fill-gradient.svg:
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResource.cpp:
(WebCore::LegacyRenderSVGResource::fillAndStrokePathOrShape):
(WebCore::LegacyRenderSVGResource::fillAndStrokePathOrShape const): Deleted.
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResource.h:
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceGradient.cpp:
(WebCore::LegacyRenderSVGResourceGradient::gradientDataForRenderer):
(WebCore::applyGradientResource):
(WebCore::PathOrShapeGradientApplier::applyResource):
(WebCore::PathOrShapeGradientApplier::postApplyResource):
(WebCore::calculateGradientGeometry):
(WebCore::calculateGradientUserspaceTransform):
(WebCore::TextGradientClipper::applyResource):
(WebCore::TextGradientClipper::postApplyResource):
(WebCore::TextGradientCompositor::applyResource):
(WebCore::TextGradientCompositor::postApplyResource):
(WebCore::LegacyRenderSVGResourceGradient::applyResource):
(WebCore::LegacyRenderSVGResourceGradient::postApplyResource):
(WebCore::createMaskAndSwapContextForTextGradient): Deleted.
(WebCore::clipToTextMask): Deleted.
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceGradient.h:
Canonical link: https://commits.webkit.org/288788@main1 parent 6a6a2c8 commit 19fb3bc
File tree
7 files changed
+232
-123
lines changed- LayoutTests/imported
- blink/svg/text
- mozilla/svg
- text
- Source/WebCore/rendering/svg/legacy
7 files changed
+232
-123
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
Loading
Lines changed: 1 addition & 1 deletion
Loading
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
264 | 264 | | |
265 | 265 | | |
266 | 266 | | |
267 | | - | |
| 267 | + | |
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
86 | | - | |
87 | | - | |
| 87 | + | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| |||
0 commit comments