Bug 224314 - [GPU Process] Simplify DisplayList::Iterator part 7: Migrate ItemBufferReadingClient from ItemHandle to a const Variant&
Summary: [GPU Process] Simplify DisplayList::Iterator part 7: Migrate ItemBufferReadin...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Myles C. Maxfield
URL:
Keywords: InRadar
Depends on: 224270
Blocks: 223560 225579
  Show dependency treegraph
 
Reported: 2021-04-07 18:55 PDT by Myles C. Maxfield
Modified: 2021-05-09 15:14 PDT (History)
3 users (show)

See Also:


Attachments
Patch (23.90 KB, patch)
2021-04-07 18:58 PDT, Myles C. Maxfield
darin: review+
Details | Formatted Diff | Diff
Patch for committing (20.39 KB, patch)
2021-05-09 02:08 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch for committing (19.79 KB, patch)
2021-05-09 02:19 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch for committing (20.57 KB, patch)
2021-05-09 03:12 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Myles C. Maxfield 2021-04-07 18:55:15 PDT
[GPU Process] Simplify DisplayList::Iterator part 7: Migrate ItemBufferReadingClient from ItemHandle to a const Variant&
Comment 1 Myles C. Maxfield 2021-04-07 18:58:32 PDT
Created attachment 425469 [details]
Patch
Comment 2 Radar WebKit Bug Importer 2021-04-14 18:56:15 PDT
<rdar://problem/76678162>
Comment 3 Darin Adler 2021-04-17 22:08:17 PDT
Comment on attachment 425469 [details]
Patch

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

> Source/WebCore/platform/graphics/displaylists/DisplayList.cpp:397
> +        m_isValid = false;
> +        if (auto decodedItem = client->decodeItem(startOfData, dataLength, itemType)) {
> +            if (safeCopy(decodedItem.value(), ItemHandle { m_currentBufferForItem }))
> +                m_isValid = true;
> +        }

I often prefer the form *decodedItem to the form decodedItem.value().

Not sure I understand the meaning of the word "safe" in this function name.

Since we are setting a boolean, seems like we could stick with a single if statement instead of two.

> Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.h:85
> +bool safeCopy(const DisplayListItem& source, ItemHandle destination);

Copying from the left argument into the right argument goes against C tradition and functions like memcpy and strcpy.

> Source/WebCore/platform/graphics/displaylists/DisplayListItems.h:2285
> +using DisplayListItem = Variant<

It’s hard to keep this in "logical" order. I suggest alphabetical order instead when the list is this long. Like includes, with conditional sections at the bottom also in alphabetical order.
Comment 4 Myles C. Maxfield 2021-04-21 15:53:49 PDT
Comment on attachment 425469 [details]
Patch

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

>> Source/WebCore/platform/graphics/displaylists/DisplayList.cpp:397
>> +        }
> 
> I often prefer the form *decodedItem to the form decodedItem.value().
> 
> Not sure I understand the meaning of the word "safe" in this function name.
> 
> Since we are setting a boolean, seems like we could stick with a single if statement instead of two.

Do you mean like

if (auto decodedItem = client->decodeItem(startOfData, dataLength, itemType); safeCopy(decodedItem.value(), ItemHandle { m_currentBufferForItem }))
    m_isValid = true;

?
Comment 5 Darin Adler 2021-04-21 16:18:15 PDT
Comment on attachment 425469 [details]
Patch

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

>>> Source/WebCore/platform/graphics/displaylists/DisplayList.cpp:397
>>> +        }
>> 
>> I often prefer the form *decodedItem to the form decodedItem.value().
>> 
>> Not sure I understand the meaning of the word "safe" in this function name.
>> 
>> Since we are setting a boolean, seems like we could stick with a single if statement instead of two.
> 
> Do you mean like
> 
> if (auto decodedItem = client->decodeItem(startOfData, dataLength, itemType); safeCopy(decodedItem.value(), ItemHandle { m_currentBufferForItem }))
>     m_isValid = true;
> 
> ?

I actually meant this:

    if (auto decodedItem = client->decodeItem(startOfData, dataLength, itemType))
        m_isValid = safeCopy(*decodedItem, ItemHandle { m_currentBufferForItem });
Comment 6 Myles C. Maxfield 2021-05-09 01:48:17 PDT
Comment on attachment 425469 [details]
Patch

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

> Source/WebCore/platform/graphics/displaylists/DisplayList.cpp:395
> +            if (safeCopy(decodedItem.value(), ItemHandle { m_currentBufferForItem }))

I need to add a comment around this copy operation saying that it's temporary and will be removed in a later patch.
Comment 7 Myles C. Maxfield 2021-05-09 02:08:54 PDT
Created attachment 428119 [details]
Patch for committing
Comment 8 Myles C. Maxfield 2021-05-09 02:19:50 PDT
Created attachment 428120 [details]
Patch for committing
Comment 9 Myles C. Maxfield 2021-05-09 03:12:02 PDT
Created attachment 428122 [details]
Patch for committing
Comment 10 Myles C. Maxfield 2021-05-09 03:58:26 PDT
I'm going to wait to land this until https://bugs.webkit.org/show_bug.cgi?id=225579 is ready, so I can land them both together. This patch introduces an extra copy that will end up getting deleted in that patch, and I don't want to cause a regression.
Comment 11 Myles C. Maxfield 2021-05-09 15:14:42 PDT
Comment on attachment 428122 [details]
Patch for committing

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

> Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.cpp:629
> +        using I = typename WTF::RemoveCVAndReference<decltype(type)>::type::type;

We can apply the treatment from https://bugs.webkit.org/show_bug.cgi?id=225579#c8 here.