Bug 240363 - Simplify the usage of DrawGlyphsRecorder
Summary: Simplify the usage of DrawGlyphsRecorder
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Text (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Simon Fraser (smfr)
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-05-12 16:33 PDT by Simon Fraser (smfr)
Modified: 2022-05-13 00:31 PDT (History)
9 users (show)

See Also:


Attachments
Patch (18.03 KB, patch)
2022-05-12 16:36 PDT, Simon Fraser (smfr)
mmaxfield: review+
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (18.71 KB, patch)
2022-05-12 16:49 PDT, Simon Fraser (smfr)
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (18.51 KB, patch)
2022-05-12 17:11 PDT, Simon Fraser (smfr)
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (19.48 KB, patch)
2022-05-12 20:59 PDT, Simon Fraser (smfr)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Fraser (smfr) 2022-05-12 16:33:00 PDT
Simplify the usage of DrawGlyphsRecorder
Comment 1 Simon Fraser (smfr) 2022-05-12 16:36:49 PDT
Created attachment 459258 [details]
Patch
Comment 2 Simon Fraser (smfr) 2022-05-12 16:49:08 PDT
Created attachment 459260 [details]
Patch
Comment 3 Myles C. Maxfield 2022-05-12 16:50:41 PDT
Comment on attachment 459258 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=459258&action=review

> Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp:168
> +        if (!m_drawGlyphsRecorder)
> +            m_drawGlyphsRecorder = makeUnique<DrawGlyphsRecorder>(*this, m_initialScale);

I still think an "ensure" function would make this more readable.

> Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h:50
> +enum class DeconstructDrawGlyphs : bool { No, Yes };

I generally like to put these things inside classes to not pollute the global namespace. This type is only meaningful inside the class anyway.

> Source/WebCore/platform/graphics/displaylists/DisplayListRecorderImpl.h:38
> -    WEBCORE_EXPORT RecorderImpl(DisplayList&, const GraphicsContextState&, const FloatRect& initialClip, const AffineTransform&, DrawGlyphsRecorder::DeconstructDrawGlyphs = DrawGlyphsRecorder::DeconstructDrawGlyphs::Yes);
> +    WEBCORE_EXPORT RecorderImpl(DisplayList&, const GraphicsContextState&, const FloatRect& initialClip, const AffineTransform&, DeconstructDrawGlyphs = DeconstructDrawGlyphs::No);

Changing the default value is suspicious. Surely the default option should be the one which is more secure, right?

> Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.cpp:53
> +    ASSERT(deconstructDrawGlyphs == DisplayList::DeconstructDrawGlyphs::Yes);

Why not just remove the parameter then?
Comment 4 Myles C. Maxfield 2022-05-12 16:51:30 PDT
Comment on attachment 459258 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=459258&action=review

>> Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h:50
>> +enum class DeconstructDrawGlyphs : bool { No, Yes };
> 
> I generally like to put these things inside classes to not pollute the global namespace. This type is only meaningful inside the class anyway.

s/inside the class/within the context of the class/
Comment 5 Simon Fraser (smfr) 2022-05-12 17:04:21 PDT
(In reply to Myles C. Maxfield from comment #3)
> Comment on attachment 459258 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=459258&action=review
> 
> > Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp:168
> > +        if (!m_drawGlyphsRecorder)
> > +            m_drawGlyphsRecorder = makeUnique<DrawGlyphsRecorder>(*this, m_initialScale);
> 
> I still think an "ensure" function would make this more readable.
> 
> > Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h:50
> > +enum class DeconstructDrawGlyphs : bool { No, Yes };
> 
> I generally like to put these things inside classes to not pollute the
> global namespace. This type is only meaningful inside the class anyway.

OK

> > Source/WebCore/platform/graphics/displaylists/DisplayListRecorderImpl.h:38
> > -    WEBCORE_EXPORT RecorderImpl(DisplayList&, const GraphicsContextState&, const FloatRect& initialClip, const AffineTransform&, DrawGlyphsRecorder::DeconstructDrawGlyphs = DrawGlyphsRecorder::DeconstructDrawGlyphs::Yes);
> > +    WEBCORE_EXPORT RecorderImpl(DisplayList&, const GraphicsContextState&, const FloatRect& initialClip, const AffineTransform&, DeconstructDrawGlyphs = DeconstructDrawGlyphs::No);
> 
> Changing the default value is suspicious. Surely the default option should
> be the one which is more secure, right?

But it's only relevant for the GPU Process. If it defaults to Yes, then we're doing the CGContext stuff when we don't need to in, WebKit1 for example.


> > Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.cpp:53
> > +    ASSERT(deconstructDrawGlyphs == DisplayList::DeconstructDrawGlyphs::Yes);
> 
> Why not just remove the parameter then?

Indeed.
Comment 6 Simon Fraser (smfr) 2022-05-12 17:11:46 PDT
Created attachment 459262 [details]
Patch
Comment 7 Simon Fraser (smfr) 2022-05-12 20:59:30 PDT
Created attachment 459272 [details]
Patch
Comment 8 EWS 2022-05-13 00:30:18 PDT
Committed r294145 (250515@main): <https://commits.webkit.org/250515@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 459272 [details].
Comment 9 Radar WebKit Bug Importer 2022-05-13 00:31:14 PDT
<rdar://problem/93230142>