WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Rebase on trunk (after r269503)
bug-218406-20201106091215.patch (text/plain), 372.01 KB, created by
Wenson Hsieh
on 2020-11-06 09:12:16 PST
(
hide
)
Description:
Rebase on trunk (after r269503)
Filename:
MIME Type:
Creator:
Wenson Hsieh
Created:
2020-11-06 09:12:16 PST
Size:
372.01 KB
patch
obsolete
>Subversion Revision: 269510 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 1cd3c8a1753a3767d5009dc4f223401e473da363..69a9990420ca085cc0c39830bda9977c1ba02350 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,713 @@ >+2020-11-03 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ [Concurrent display lists] Encode display list items directly into shared memory >+ https://bugs.webkit.org/show_bug.cgi?id=218406 >+ >+ Reviewed by Tim Horton. >+ >+ This patch refactors display lists (and display list items) in preparation for upcoming changes to allow the >+ GPU and web processes to concurrently read and write display list item data, which allows us to achieve >+ significant improvements in performance on many graphics benchmarks in MotionMark by removing overhead involved >+ in serializing and deserializing display list items over IPC. To implement this, rather than using IPC to encode >+ and decode each item, we will instead store display list items directly in memory shared between the web and GPU >+ processes. >+ >+ This strategy, of course, will not work for display list items that contain pointers. Unfortunately, this >+ affects all display list items at the moment, since all items are subclasses of `DisplayList::Item`, and >+ therefore contain vtable pointers, even if all members are plain data types. Thus, the first step towards being >+ able to read and write items directly in shared memory is to remove this vtable pointer by making display list >+ items no longer inherit from `DrawingItem` or `Item`. >+ >+ Currently, display lists are backed by `Vector<Ref<Item>>`; however, this no longer works once none of the >+ display list items are descended from a common base class. To address this, we introduce >+ `DisplayList::ItemBuffer`, which encapsulates logic to manage one or more data segments that contain display >+ list item data (i.e. display list items stacked adjacent to each other in memory). Display lists now append >+ inline display list items by constructing these items directly inside the item buffer using placement-new. >+ >+ However, many types of display list items do not consist entirely of inline data; some of these are obvious, >+ such as `DrawImage`, `DrawGlyphs`, or `StrokePath` (since a `Path` may be arbitrarily complex). Other out-of- >+ line item types are less obvious: for instance, `FillRoundedRect` is an out-of-line item due to the fact that >+ the color of the rect (`FillRoundedRect::m_color`) may be an extended color, which then contains a pointer. In >+ these cases, we can't simply encode the item in shared memory and read it in the GPU process, since the pointer >+ (if it pointed to anything other than null in the web process) will point to arbitrary memory in the GPU >+ process. Instead, we can leverage our existing IPC infrastructure here by encoding each of these out-of-line >+ items as data and decoding them from this data in the GPU process. To do this, we delegate out to WebKit2 to >+ encode out-of-line display list items using WebKit's `IPC::Encoder`, and pass back a `SharedBuffer` which we >+ then copy into the item buffer. This delegation happens through the `ItemBufferWritingClient` class, which has >+ an implementation in WebKit2. On the decoding side in the GPU process, we then ask `ItemBufferReadingClient` (if >+ set) to convert this encoded data back into a display list item. In WebKit2, we implement this interface and use >+ the corresponding `IPC::Decoder` to decode the data we serialized earlier. >+ >+ If no client is specified or the client does not require custom encoding/decoding for the given item type, we >+ fall back to constructing the item directly inside the writable item buffer data. >+ >+ To make it easier to reason about these new (inheritance-free) display list items, we additionally introduce >+ `ItemHandle`, which wraps a pointer to a display list item and provides several helper methods. The first byte >+ of each item handle always points to an `ItemType`, and the following `N` bytes contain the item itself, where >+ `N` is the size of the item class. Here are some examples of how to use an `ItemHandle`: >+ >+ `DisplayList::ItemType type = itemHandle.type();` (This matches the current inheritance model) >+ >+ `if (itemHandle.is<StrokePath>()) {...` (Replaces is<> in the current model) >+ >+ `auto& setStateItem = itemHandle.get<SetState>();` (Replaces downcast<> in the current model) >+ >+ `itemHandle.apply(myGraphicsContext);` (This matches the current inheritance model) >+ >+ `bool isDrawingItem = itemHandle.isDrawingItem();` (Replaces checks for `is<DrawingItem>(item)`) >+ >+ When writing display lists for the GPU process, the writing client (a `ItemBufferWritingClient`) will be asked >+ to provide `ItemBufferHandle`s where the item buffer will place item data (whether encoded, or as an inline >+ object). However, when using display lists outside of this context (e.g. in other parts of WebCore, such as the >+ glyph drawing cache), we don't have a `ItemBufferWritingClient`. To handle this, the item buffer instead >+ allocates its own (non-shared-memory) buffers, which it manages and deletes when it is done. If any out-of-line >+ items are constructed within these buffers, `ItemBuffer` will additionally call their destructors prior to >+ deleting these buffers. >+ >+ See per-change comments below for more details. >+ >+ * Headers.cmake: >+ * Sources.txt: >+ * WebCore.xcodeproj/project.pbxproj: >+ * platform/graphics/GraphicsContext.h: >+ * platform/graphics/displaylists/DisplayList.cpp: >+ (WebCore::DisplayList::DisplayList::DisplayList): >+ (WebCore::DisplayList::DisplayList::operator=): >+ >+ Implement the move assignment operator and move constructor by exchanging ownership of the item buffer. >+ >+ (WebCore::DisplayList::DisplayList::clear): >+ (WebCore::DisplayList::DisplayList::shouldDumpForFlags): >+ (WebCore::DisplayList::DisplayList::asText const): >+ (WebCore::DisplayList::DisplayList::dump const): >+ >+ Adjust the format when printing display lists to `TextStream`. Now that drawing item extents are tracked on the >+ display list rather than being on each drawing item, we print them out after each item (as opposed to being in >+ the middle of each item). >+ >+ (WebCore::DisplayList::DisplayList::sizeInBytes const): >+ >+ Tally up the size of the display list by taking the sum of the sizes of each readonly segment, as well as the >+ writable buffer size. >+ >+ (WebCore::DisplayList::DisplayList::isEmpty const): >+ >+ A DisplayList is empty if it contains no item data: in other words, there are no readonly buffer segments, and >+ there is also nothing written to the writable buffer segment. >+ >+ (WebCore::DisplayList::DisplayList::itemBuffer): >+ (WebCore::DisplayList::DisplayList::setItemBufferClient): >+ (WebCore::DisplayList::DisplayList::forEachItemBuffer const): >+ >+ Add a helper to iterate over each ItemBufferHandle in the display list. This includes all readonly handles, and >+ then the writable handle (if it exists). >+ >+ (WebCore::DisplayList::DisplayList::setTracksDrawingItemExtents): >+ >+ Add an option to allow the display list to track drawing item extents. Currently, display lists always track >+ extents for drawing items; however, when propagating display lists to the GPU process for playback, these >+ extents were never sent along with IPC, and so this ended up just being unnecessary work. Additionally, the >+ initial clip in the GPU process is also never set, so computing these extents never helped. >+ >+ That said, drawing item extents are still printed out for the purposes of testing, so we need to keep this >+ logic intact; this refactoring only disables extent computation for display lists being sent to the GPU process >+ via remote image buffers. In a future patch, we could refactor this so that drawing items contain extent rects >+ as inline data that can be consulted in the GPU process. >+ >+ (WebCore::DisplayList::DisplayList::append): >+ >+ Display list items are no longer constructed ahead of time, and then appended to the display list. Instead, >+ `append` now takes the type of the item to append as a template typename argument, as well as the arguments that >+ will be used to construct the item. >+ >+ (WebCore::DisplayList::DisplayList::iterator::atEnd const): >+ (WebCore::DisplayList::DisplayList::iterator::updateCurrentItem): >+ (WebCore::DisplayList::DisplayList::iterator::advance): >+ (WebCore::DisplayList::DisplayList::iterator::clearCurrentItem): >+ (WebCore::DisplayList::DisplayList::iterator::moveToEnd): >+ (WebCore::DisplayList::DisplayList::iterator::moveCursorToStartOfCurrentBuffer): >+ >+ Implement a C++ iterator for DisplayList. This makes it possible to write code like this: >+ ``` >+ // Suppose displayList is an instance of DisplayList::DisplayList. >+ for (auto [item, extent] : displayList) { >+ // Do things with item, which is a DisplayList::ItemHandle. >+ // Maybe do things with extent, which is an Optional<FloatRect>. >+ } >+ ``` >+ >+ * platform/graphics/displaylists/DisplayList.h: >+ (WebCore::DisplayList::DisplayList::tracksDrawingItemExtents const): >+ (WebCore::DisplayList::DisplayList::iterator::iterator): >+ (WebCore::DisplayList::DisplayList::iterator::~iterator): >+ (WebCore::DisplayList::DisplayList::iterator::operator==): >+ (WebCore::DisplayList::DisplayList::iterator::operator!=): >+ (WebCore::DisplayList::DisplayList::iterator::operator++): >+ (WebCore::DisplayList::DisplayList::iterator::operator* const): >+ (WebCore::DisplayList::DisplayList::begin const): >+ (WebCore::DisplayList::DisplayList::end const): >+ (WebCore::DisplayList::DisplayList::itemBufferIfExists const): >+ (WebCore::DisplayList::DisplayList::addDrawingItemExtent): >+ (WebCore::DisplayList::DisplayList::append): >+ (WebCore::DisplayList::Item::type const): Deleted. >+ (WebCore::DisplayList::Item::isDrawingItem const): Deleted. >+ (WebCore::DisplayList::DisplayList::list const): Deleted. >+ (WebCore::DisplayList::DisplayList::itemAt): Deleted. >+ (WebCore::DisplayList::DisplayList::isEmpty const): Deleted. >+ (WebCore::DisplayList::DisplayList::appendItem): Deleted. >+ (WebCore::DisplayList::DisplayList::list): Deleted. >+ (WebCore::DisplayList::DisplayList::encode const): Deleted. >+ (WebCore::DisplayList::DisplayList::decode): Deleted. >+ >+ Remove the ability to `encode` and `decode` display lists, for the time being. For the communication between the >+ web and GPU processes, we now use `SharedDisplayListHandle`. >+ >+ Unfortunately, this does mean that the extant `ClipToDrawingCommands` display list item will be broken for the >+ time being. In a followup patch, I plan to reimplement `DisplayList::encode` and `decode` in the new inline item >+ model by encoding each item (either as inline data or via `IPC::Encoder::encodeSingleObject`). However, this is >+ contingent on all display list item types (e.g. `DrawImage` and `DrawGlyph`) not relying on `IPC::Attachment` >+ for encoding, so support for `ClipToDrawingCommands` will need to wait until after fonts and images are working. >+ >+ * platform/graphics/displaylists/DisplayListDrawGlyphsRecorderCoreText.cpp: >+ (WebCore::DisplayList::DrawGlyphsRecorder::recordDrawGlyphs): >+ (WebCore::DisplayList::DrawGlyphsRecorder::recordDrawImage): >+ * platform/graphics/displaylists/DisplayListDrawGlyphsRecorderHarfBuzz.cpp: >+ (WebCore::DisplayList::DrawGlyphsRecorder::drawGlyphs): >+ * platform/graphics/displaylists/DisplayListDrawGlyphsRecorderWin.cpp: >+ (WebCore::DisplayList::DrawGlyphsRecorder::drawGlyphs): >+ >+ Change these to use the new templated `DisplayList::append` method. >+ >+ * platform/graphics/displaylists/DisplayListDrawingContext.h: >+ (WebCore::DisplayList::DrawingContext::takeDisplayList): >+ >+ Use `std::exchange` instead of `WTFMove`. This is actually necessary in order to ensure correctness (i.e. no >+ leaks or double-freeing), since the `DisplayList` instance that is being moved from needs to be empty so that it >+ does not try to call destructors on the items formerly inside of it. >+ >+ * platform/graphics/displaylists/DisplayListItemBuffer.cpp: Added. >+ (WebCore::DisplayList::ItemHandle::apply): >+ (WebCore::DisplayList::ItemHandle::destroy): >+ >+ Add helper methods to apply a display list item to a `GraphicsContext` and call the display list item's >+ destructor, respectively. >+ >+ (WebCore::DisplayList::ItemHandle::copyTo const): >+ >+ Add a helper method to copy the item into the destination handle (calling the copy constructor of the item type >+ in the process). This is used when copying a validated display list item into the temporary item buffer in >+ `DisplayList::iterator`. >+ >+ (WebCore::DisplayList::ItemBuffer::ItemBuffer): >+ (WebCore::DisplayList::ItemBuffer::~ItemBuffer): >+ (WebCore::DisplayList::m_allocatedBuffers): >+ >+ In the case where there is no `m_writingClient` (for instance, when using in-process `DisplayList`s to optimize >+ text painting), the display list item buffer is responsible for creating and managing data buffers. As such, it >+ needs to remember to free any buffers that it allocated when appending, and must also destroy any out-of-line >+ display list items (i.e. items with nontrivial destructors) when it is finished. >+ >+ (WebCore::DisplayList::m_readOnlyBuffers): >+ (WebCore::DisplayList::m_writableBuffer): >+ (WebCore::DisplayList::m_writtenNumberOfBytes): >+ >+ See main ChangeLog entry above for more details. >+ >+ (WebCore::DisplayList::ItemBuffer::operator=): >+ (WebCore::DisplayList::ItemBuffer::createItemBuffer): >+ (WebCore::DisplayList::ItemBuffer::forEachItemBuffer const): >+ (WebCore::DisplayList::ItemBuffer::clear): >+ (WebCore::DisplayList::ItemBuffer::swapWritableBufferIfNeeded): >+ (WebCore::DisplayList::ItemBuffer::appendDataAndLength): >+ * platform/graphics/displaylists/DisplayListItemBuffer.h: Added. >+ (WebCore::DisplayList::ItemBufferHandle::operator bool const): >+ (WebCore::DisplayList::ItemBufferHandle::operator! const): >+ (WebCore::DisplayList::ItemHandle::operator bool const): >+ (WebCore::DisplayList::ItemHandle::operator! const): >+ (WebCore::DisplayList::ItemHandle::type const): >+ (WebCore::DisplayList::ItemHandle::size const): >+ (WebCore::DisplayList::ItemHandle::is const): >+ (WebCore::DisplayList::ItemHandle::get const): >+ (WebCore::DisplayList::ItemBufferWritingClient::~ItemBufferWritingClient): >+ (WebCore::DisplayList::ItemBufferReadingClient::~ItemBufferReadingClient): >+ (WebCore::DisplayList::ItemBuffer::sizeInBytes const): >+ (WebCore::DisplayList::ItemBuffer::isEmpty const): >+ (WebCore::DisplayList::ItemBuffer::append): >+ (WebCore::DisplayList::ItemBuffer::setClient): >+ (WebCore::DisplayList::ItemBuffer::readOnlyBuffers const): >+ (WebCore::DisplayList::ItemBuffer::uncheckedAppend): >+ * platform/graphics/displaylists/DisplayListItems.cpp: >+ >+ The changes in this file make up most of the code churn in this patch, but the changes are mostly mechanical. In >+ summary, this patch: >+ - Add static constexprs for the `ItemType` of each display list item class, as well as whether or not each class >+ is inline, and also whether or not each class is a drawing item. >+ - Remove `encode` and `decode` methods from inline item classes. >+ - Remove all overridden methods; each class now implements individual methods to `apply`, compute >+ `globalBounds` (if applicable), and compute `localBounds` (again, if applicable). >+ - Adjusts textstream dumping helpers, so that they no longer dump as a `DrawingItem` before dumping each member. >+ >+ (WebCore::DisplayList::SetInlineFillGradient::SetInlineFillGradient): >+ (WebCore::DisplayList::SetState::SetState): >+ (WebCore::DisplayList::DrawGlyphs::DrawGlyphs): >+ (WebCore::DisplayList::DrawGlyphs::generateGlyphBuffer const): >+ (WebCore::DisplayList::DrawGlyphs::apply const): >+ (WebCore::DisplayList::operator<<): >+ (WebCore::DisplayList::DrawNativeImage::DrawNativeImage): >+ (WebCore::DisplayList::DrawPattern::DrawPattern): >+ (WebCore::DisplayList::DrawLinesForText::DrawLinesForText): >+ (WebCore::DisplayList::DrawFocusRingRects::DrawFocusRingRects): >+ (WebCore::DisplayList::FillRectWithGradient::FillRectWithGradient): >+ (WebCore::DisplayList::PutImageData::PutImageData): >+ (WebCore::DisplayList::PaintFrameForMedia::PaintFrameForMedia): >+ (WebCore::DisplayList::Item::Item): Deleted. >+ (WebCore::DisplayList::Item::sizeInBytes): Deleted. >+ (WebCore::DisplayList::DrawingItem::DrawingItem): Deleted. >+ (WebCore::DisplayList::Save::Save): Deleted. >+ (WebCore::DisplayList::Restore::Restore): Deleted. >+ (WebCore::DisplayList::Translate::Translate): Deleted. >+ (WebCore::DisplayList::Rotate::Rotate): Deleted. >+ (WebCore::DisplayList::Scale::Scale): Deleted. >+ (WebCore::DisplayList::SetCTM::SetCTM): Deleted. >+ (WebCore::DisplayList::ConcatenateCTM::ConcatenateCTM): Deleted. >+ (WebCore::DisplayList::SetInlineFillGradient::create): Deleted. >+ (WebCore::DisplayList::SetInlineFillColor::create): Deleted. >+ (WebCore::DisplayList::SetInlineStrokeColor::create): Deleted. >+ (WebCore::DisplayList::SetStrokeThickness::create): Deleted. >+ (WebCore::DisplayList::SetLineCap::SetLineCap): Deleted. >+ (WebCore::DisplayList::SetLineDash::SetLineDash): Deleted. >+ (WebCore::DisplayList::SetLineJoin::SetLineJoin): Deleted. >+ (WebCore::DisplayList::SetMiterLimit::SetMiterLimit): Deleted. >+ (WebCore::DisplayList::ClearShadow::ClearShadow): Deleted. >+ (WebCore::DisplayList::Clip::Clip): Deleted. >+ (WebCore::DisplayList::ClipOut::ClipOut): Deleted. >+ (WebCore::DisplayList::ClipOutToPath::ClipOutToPath): Deleted. >+ (WebCore::DisplayList::ClipPath::ClipPath): Deleted. >+ (WebCore::DisplayList::ClipToDrawingCommands::ClipToDrawingCommands): Deleted. >+ (WebCore::DisplayList::DrawGlyphs::localBounds const): Deleted. >+ (WebCore::DisplayList::DrawImage::DrawImage): Deleted. >+ (WebCore::DisplayList::DrawTiledImage::DrawTiledImage): Deleted. >+ (WebCore::DisplayList::DrawTiledScaledImage::DrawTiledScaledImage): Deleted. >+ (WebCore::DisplayList::DrawImageBuffer::DrawImageBuffer): Deleted. >+ (WebCore::DisplayList::DrawRect::DrawRect): Deleted. >+ (WebCore::DisplayList::DrawLine::DrawLine): Deleted. >+ (WebCore::DisplayList::DrawDotsForDocumentMarker::DrawDotsForDocumentMarker): Deleted. >+ (WebCore::DisplayList::DrawEllipse::DrawEllipse): Deleted. >+ (WebCore::DisplayList::DrawPath::DrawPath): Deleted. >+ (WebCore::DisplayList::DrawFocusRingPath::DrawFocusRingPath): Deleted. >+ (WebCore::DisplayList::FillRect::FillRect): Deleted. >+ (WebCore::DisplayList::FillRectWithColor::FillRectWithColor): Deleted. >+ (WebCore::DisplayList::FillCompositedRect::FillCompositedRect): Deleted. >+ (WebCore::DisplayList::FillRoundedRect::FillRoundedRect): Deleted. >+ (WebCore::DisplayList::FillRectWithRoundedHole::FillRectWithRoundedHole): Deleted. >+ (WebCore::DisplayList::FillInlinePath::FillInlinePath): Deleted. >+ (WebCore::DisplayList::FillPath::FillPath): Deleted. >+ (WebCore::DisplayList::FillEllipse::FillEllipse): Deleted. >+ (WebCore::DisplayList::PaintFrameForMedia::create): Deleted. >+ (WebCore::DisplayList::StrokeRect::StrokeRect): Deleted. >+ (WebCore::DisplayList::StrokeEllipse::StrokeEllipse): Deleted. >+ (WebCore::DisplayList::StrokeInlinePath::StrokeInlinePath): Deleted. >+ (WebCore::DisplayList::StrokePath::StrokePath): Deleted. >+ (WebCore::DisplayList::ClearRect::ClearRect): Deleted. >+ (WebCore::DisplayList::BeginTransparencyLayer::BeginTransparencyLayer): Deleted. >+ (WebCore::DisplayList::EndTransparencyLayer::EndTransparencyLayer): Deleted. >+ (WebCore::DisplayList::ApplyStrokePattern::ApplyStrokePattern): Deleted. >+ (WebCore::DisplayList::ApplyFillPattern::ApplyFillPattern): Deleted. >+ (WebCore::DisplayList::ApplyDeviceScaleFactor::ApplyDeviceScaleFactor): Deleted. >+ * platform/graphics/displaylists/DisplayListItems.h: >+ (WebCore::DisplayList::Save::localBounds const): >+ (WebCore::DisplayList::Save::globalBounds const): >+ (WebCore::DisplayList::Restore::localBounds const): >+ (WebCore::DisplayList::Restore::globalBounds const): >+ (WebCore::DisplayList::Translate::Translate): >+ (WebCore::DisplayList::Translate::localBounds const): >+ (WebCore::DisplayList::Translate::globalBounds const): >+ (WebCore::DisplayList::Rotate::Rotate): >+ (WebCore::DisplayList::Rotate::localBounds const): >+ (WebCore::DisplayList::Rotate::globalBounds const): >+ (WebCore::DisplayList::Scale::Scale): >+ (WebCore::DisplayList::Scale::localBounds const): >+ (WebCore::DisplayList::Scale::globalBounds const): >+ (WebCore::DisplayList::SetCTM::SetCTM): >+ (WebCore::DisplayList::SetCTM::localBounds const): >+ (WebCore::DisplayList::SetCTM::globalBounds const): >+ (WebCore::DisplayList::ConcatenateCTM::ConcatenateCTM): >+ (WebCore::DisplayList::ConcatenateCTM::localBounds const): >+ (WebCore::DisplayList::ConcatenateCTM::globalBounds const): >+ (WebCore::DisplayList::SetInlineFillGradient::localBounds const): >+ (WebCore::DisplayList::SetInlineFillGradient::globalBounds const): >+ (WebCore::DisplayList::SetInlineFillColor::SetInlineFillColor): >+ (WebCore::DisplayList::SetInlineFillColor::color const): >+ (WebCore::DisplayList::SetInlineFillColor::localBounds const): >+ (WebCore::DisplayList::SetInlineFillColor::globalBounds const): >+ (WebCore::DisplayList::SetInlineStrokeColor::SetInlineStrokeColor): >+ (WebCore::DisplayList::SetInlineStrokeColor::color const): >+ (WebCore::DisplayList::SetInlineStrokeColor::localBounds const): >+ (WebCore::DisplayList::SetInlineStrokeColor::globalBounds const): >+ (WebCore::DisplayList::SetStrokeThickness::SetStrokeThickness): >+ (WebCore::DisplayList::SetStrokeThickness::thickness const): >+ (WebCore::DisplayList::SetStrokeThickness::localBounds const): >+ (WebCore::DisplayList::SetStrokeThickness::globalBounds const): >+ (WebCore::DisplayList::SetState::localBounds const): >+ (WebCore::DisplayList::SetState::globalBounds const): >+ (WebCore::DisplayList::SetState::decode): >+ (WebCore::DisplayList::SetLineCap::SetLineCap): >+ (WebCore::DisplayList::SetLineCap::localBounds const): >+ (WebCore::DisplayList::SetLineCap::globalBounds const): >+ (WebCore::DisplayList::SetLineDash::SetLineDash): >+ (WebCore::DisplayList::SetLineDash::localBounds const): >+ (WebCore::DisplayList::SetLineDash::globalBounds const): >+ (WebCore::DisplayList::SetLineDash::decode): >+ (WebCore::DisplayList::SetLineJoin::SetLineJoin): >+ (WebCore::DisplayList::SetLineJoin::localBounds const): >+ (WebCore::DisplayList::SetLineJoin::globalBounds const): >+ (WebCore::DisplayList::SetMiterLimit::SetMiterLimit): >+ (WebCore::DisplayList::SetMiterLimit::localBounds const): >+ (WebCore::DisplayList::SetMiterLimit::globalBounds const): >+ (WebCore::DisplayList::ClearShadow::localBounds const): >+ (WebCore::DisplayList::ClearShadow::globalBounds const): >+ (WebCore::DisplayList::Clip::Clip): >+ (WebCore::DisplayList::Clip::rect const): >+ (WebCore::DisplayList::Clip::localBounds const): >+ (WebCore::DisplayList::Clip::globalBounds const): >+ (WebCore::DisplayList::ClipOut::ClipOut): >+ (WebCore::DisplayList::ClipOut::rect const): >+ (WebCore::DisplayList::ClipOut::localBounds const): >+ (WebCore::DisplayList::ClipOut::globalBounds const): >+ (WebCore::DisplayList::ClipOutToPath::ClipOutToPath): >+ (WebCore::DisplayList::ClipOutToPath::localBounds const): >+ (WebCore::DisplayList::ClipOutToPath::globalBounds const): >+ (WebCore::DisplayList::ClipOutToPath::decode): >+ (WebCore::DisplayList::ClipPath::ClipPath): >+ (WebCore::DisplayList::ClipPath::localBounds const): >+ (WebCore::DisplayList::ClipPath::globalBounds const): >+ (WebCore::DisplayList::ClipPath::decode): >+ (WebCore::DisplayList::ClipToDrawingCommands::ClipToDrawingCommands): >+ (WebCore::DisplayList::ClipToDrawingCommands::localBounds const): >+ (WebCore::DisplayList::ClipToDrawingCommands::globalBounds const): >+ (WebCore::DisplayList::ClipToDrawingCommands::encode const): >+ (WebCore::DisplayList::ClipToDrawingCommands::decode): >+ (WebCore::DisplayList::DrawGlyphs::globalBounds const): >+ (WebCore::DisplayList::DrawGlyphs::localBounds const): >+ (WebCore::DisplayList::DrawGlyphs::encode const): >+ (WebCore::DisplayList::DrawGlyphs::decode): >+ (WebCore::DisplayList::DrawImage::DrawImage): >+ (WebCore::DisplayList::DrawImage::globalBounds const): >+ (WebCore::DisplayList::DrawImage::localBounds const): >+ (WebCore::DisplayList::DrawImage::decode): >+ (WebCore::DisplayList::DrawTiledImage::DrawTiledImage): >+ (WebCore::DisplayList::DrawTiledImage::globalBounds const): >+ (WebCore::DisplayList::DrawTiledImage::localBounds const): >+ (WebCore::DisplayList::DrawTiledImage::decode): >+ (WebCore::DisplayList::DrawTiledScaledImage::DrawTiledScaledImage): >+ (WebCore::DisplayList::DrawTiledScaledImage::globalBounds const): >+ (WebCore::DisplayList::DrawTiledScaledImage::localBounds const): >+ (WebCore::DisplayList::DrawTiledScaledImage::decode): >+ (WebCore::DisplayList::DrawImageBuffer::DrawImageBuffer): >+ (WebCore::DisplayList::DrawImageBuffer::globalBounds const): >+ (WebCore::DisplayList::DrawImageBuffer::localBounds const): >+ (WebCore::DisplayList::DrawImageBuffer::decode): >+ (WebCore::DisplayList::DrawNativeImage::source const): >+ (WebCore::DisplayList::DrawNativeImage::destinationRect const): >+ (WebCore::DisplayList::DrawNativeImage::globalBounds const): >+ (WebCore::DisplayList::DrawNativeImage::localBounds const): >+ (WebCore::DisplayList::DrawNativeImage::decode): >+ (WebCore::DisplayList::DrawPattern::DrawPattern): >+ (WebCore::DisplayList::DrawPattern::globalBounds const): >+ (WebCore::DisplayList::DrawPattern::localBounds const): >+ (WebCore::DisplayList::DrawPattern::decode): >+ (WebCore::DisplayList::BeginTransparencyLayer::BeginTransparencyLayer): >+ (WebCore::DisplayList::BeginTransparencyLayer::localBounds const): >+ (WebCore::DisplayList::BeginTransparencyLayer::globalBounds const): >+ (WebCore::DisplayList::EndTransparencyLayer::localBounds const): >+ (WebCore::DisplayList::EndTransparencyLayer::globalBounds const): >+ (WebCore::DisplayList::DrawRect::DrawRect): >+ (WebCore::DisplayList::DrawRect::globalBounds const): >+ (WebCore::DisplayList::DrawRect::localBounds const): >+ (WebCore::DisplayList::DrawLine::DrawLine): >+ (WebCore::DisplayList::DrawLine::globalBounds const): >+ (WebCore::DisplayList::DrawLinesForText::globalBounds const): >+ (WebCore::DisplayList::DrawLinesForText::decode): >+ (WebCore::DisplayList::DrawDotsForDocumentMarker::DrawDotsForDocumentMarker): >+ (WebCore::DisplayList::DrawDotsForDocumentMarker::globalBounds const): >+ (WebCore::DisplayList::DrawEllipse::DrawEllipse): >+ (WebCore::DisplayList::DrawEllipse::rect const): >+ (WebCore::DisplayList::DrawEllipse::globalBounds const): >+ (WebCore::DisplayList::DrawEllipse::localBounds const): >+ (WebCore::DisplayList::DrawPath::DrawPath): >+ (WebCore::DisplayList::DrawPath::globalBounds const): >+ (WebCore::DisplayList::DrawPath::localBounds const): >+ (WebCore::DisplayList::DrawPath::decode): >+ (WebCore::DisplayList::DrawFocusRingPath::DrawFocusRingPath): >+ (WebCore::DisplayList::DrawFocusRingPath::globalBounds const): >+ (WebCore::DisplayList::DrawFocusRingPath::decode): >+ (WebCore::DisplayList::DrawFocusRingRects::globalBounds const): >+ (WebCore::DisplayList::DrawFocusRingRects::decode): >+ (WebCore::DisplayList::FillRect::FillRect): >+ (WebCore::DisplayList::FillRect::rect const): >+ (WebCore::DisplayList::FillRect::globalBounds const): >+ (WebCore::DisplayList::FillRect::localBounds const): >+ (WebCore::DisplayList::FillRectWithColor::FillRectWithColor): >+ (WebCore::DisplayList::FillRectWithColor::globalBounds const): >+ (WebCore::DisplayList::FillRectWithColor::localBounds const): >+ (WebCore::DisplayList::FillRectWithColor::decode): >+ (WebCore::DisplayList::FillRectWithGradient::rect const): >+ (WebCore::DisplayList::FillRectWithGradient::gradient const): >+ (WebCore::DisplayList::FillRectWithGradient::globalBounds const): >+ (WebCore::DisplayList::FillRectWithGradient::localBounds const): >+ (WebCore::DisplayList::FillRectWithGradient::decode): >+ (WebCore::DisplayList::FillCompositedRect::FillCompositedRect): >+ (WebCore::DisplayList::FillCompositedRect::globalBounds const): >+ (WebCore::DisplayList::FillCompositedRect::localBounds const): >+ (WebCore::DisplayList::FillCompositedRect::decode): >+ (WebCore::DisplayList::FillRoundedRect::FillRoundedRect): >+ (WebCore::DisplayList::FillRoundedRect::globalBounds const): >+ (WebCore::DisplayList::FillRoundedRect::localBounds const): >+ (WebCore::DisplayList::FillRoundedRect::decode): >+ (WebCore::DisplayList::FillRectWithRoundedHole::FillRectWithRoundedHole): >+ (WebCore::DisplayList::FillRectWithRoundedHole::globalBounds const): >+ (WebCore::DisplayList::FillRectWithRoundedHole::localBounds const): >+ (WebCore::DisplayList::FillRectWithRoundedHole::decode): >+ (WebCore::DisplayList::FillInlinePath::FillInlinePath): >+ (WebCore::DisplayList::FillInlinePath::globalBounds const): >+ (WebCore::DisplayList::FillInlinePath::localBounds const): >+ (WebCore::DisplayList::FillPath::FillPath): >+ (WebCore::DisplayList::FillPath::globalBounds const): >+ (WebCore::DisplayList::FillPath::localBounds const): >+ (WebCore::DisplayList::FillPath::decode): >+ (WebCore::DisplayList::FillEllipse::FillEllipse): >+ (WebCore::DisplayList::FillEllipse::globalBounds const): >+ (WebCore::DisplayList::FillEllipse::localBounds const): >+ (WebCore::DisplayList::PutImageData::imageData const): >+ (WebCore::DisplayList::PutImageData::localBounds const): >+ (WebCore::DisplayList::PutImageData::globalBounds const): >+ (WebCore::DisplayList::PutImageData::encode const): >+ (WebCore::DisplayList::PutImageData::decode): >+ (WebCore::DisplayList::PaintFrameForMedia::localBounds const): >+ (WebCore::DisplayList::PaintFrameForMedia::globalBounds const): >+ (WebCore::DisplayList::StrokeRect::StrokeRect): >+ (WebCore::DisplayList::StrokeRect::globalBounds const): >+ (WebCore::DisplayList::StrokeInlinePath::StrokeInlinePath): >+ (WebCore::DisplayList::StrokeInlinePath::globalBounds const): >+ (WebCore::DisplayList::StrokePath::StrokePath): >+ (WebCore::DisplayList::StrokePath::globalBounds const): >+ (WebCore::DisplayList::StrokePath::decode): >+ (WebCore::DisplayList::StrokeEllipse::StrokeEllipse): >+ (WebCore::DisplayList::StrokeEllipse::rect const): >+ (WebCore::DisplayList::StrokeEllipse::globalBounds const): >+ (WebCore::DisplayList::ClearRect::ClearRect): >+ (WebCore::DisplayList::ClearRect::rect const): >+ (WebCore::DisplayList::ClearRect::globalBounds const): >+ (WebCore::DisplayList::ClearRect::localBounds const): >+ (WebCore::DisplayList::ApplyStrokePattern::localBounds const): >+ (WebCore::DisplayList::ApplyStrokePattern::globalBounds const): >+ (WebCore::DisplayList::ApplyFillPattern::localBounds const): >+ (WebCore::DisplayList::ApplyFillPattern::globalBounds const): >+ (WebCore::DisplayList::ApplyDeviceScaleFactor::ApplyDeviceScaleFactor): >+ (WebCore::DisplayList::ApplyDeviceScaleFactor::localBounds const): >+ (WebCore::DisplayList::ApplyDeviceScaleFactor::globalBounds const): >+ (WebCore::DisplayList::DrawingItem::setExtent): Deleted. >+ (WebCore::DisplayList::DrawingItem::extent const): Deleted. >+ (WebCore::DisplayList::DrawingItem::extentKnown const): Deleted. >+ (WebCore::DisplayList::DrawingItem::localBounds const): Deleted. >+ (WebCore::DisplayList::DrawingItem::globalBounds const): Deleted. >+ (WebCore::DisplayList::Save::create): Deleted. >+ (WebCore::DisplayList::Save::encode const): Deleted. >+ (WebCore::DisplayList::Save::decode): Deleted. >+ (WebCore::DisplayList::Restore::create): Deleted. >+ (WebCore::DisplayList::Restore::encode const): Deleted. >+ (WebCore::DisplayList::Restore::decode): Deleted. >+ (WebCore::DisplayList::Translate::create): Deleted. >+ (WebCore::DisplayList::Translate::encode const): Deleted. >+ (WebCore::DisplayList::Translate::decode): Deleted. >+ (WebCore::DisplayList::Rotate::create): Deleted. >+ (WebCore::DisplayList::Rotate::encode const): Deleted. >+ (WebCore::DisplayList::Rotate::decode): Deleted. >+ (WebCore::DisplayList::Scale::create): Deleted. >+ (WebCore::DisplayList::Scale::encode const): Deleted. >+ (WebCore::DisplayList::Scale::decode): Deleted. >+ (WebCore::DisplayList::SetCTM::create): Deleted. >+ (WebCore::DisplayList::SetCTM::encode const): Deleted. >+ (WebCore::DisplayList::SetCTM::decode): Deleted. >+ (WebCore::DisplayList::ConcatenateCTM::create): Deleted. >+ (WebCore::DisplayList::ConcatenateCTM::encode const): Deleted. >+ (WebCore::DisplayList::ConcatenateCTM::decode): Deleted. >+ (WebCore::DisplayList::SetInlineFillGradient::create): Deleted. >+ (WebCore::DisplayList::SetInlineFillGradient::encode const): Deleted. >+ (WebCore::DisplayList::SetInlineFillGradient::decode): Deleted. >+ (WebCore::DisplayList::SetInlineFillColor::encode const): Deleted. >+ (WebCore::DisplayList::SetInlineFillColor::decode): Deleted. >+ (WebCore::DisplayList::SetInlineStrokeColor::encode const): Deleted. >+ (WebCore::DisplayList::SetInlineStrokeColor::decode): Deleted. >+ (WebCore::DisplayList::SetStrokeThickness::encode const): Deleted. >+ (WebCore::DisplayList::SetStrokeThickness::decode): Deleted. >+ (WebCore::DisplayList::SetState::create): Deleted. >+ (WebCore::DisplayList::SetLineCap::create): Deleted. >+ (WebCore::DisplayList::SetLineCap::encode const): Deleted. >+ (WebCore::DisplayList::SetLineCap::decode): Deleted. >+ (WebCore::DisplayList::SetLineDash::create): Deleted. >+ (WebCore::DisplayList::SetLineJoin::create): Deleted. >+ (WebCore::DisplayList::SetLineJoin::encode const): Deleted. >+ (WebCore::DisplayList::SetLineJoin::decode): Deleted. >+ (WebCore::DisplayList::SetMiterLimit::create): Deleted. >+ (WebCore::DisplayList::SetMiterLimit::encode const): Deleted. >+ (WebCore::DisplayList::SetMiterLimit::decode): Deleted. >+ (WebCore::DisplayList::ClearShadow::create): Deleted. >+ (WebCore::DisplayList::ClearShadow::encode const): Deleted. >+ (WebCore::DisplayList::ClearShadow::decode): Deleted. >+ (WebCore::DisplayList::Clip::create): Deleted. >+ (WebCore::DisplayList::Clip::encode const): Deleted. >+ (WebCore::DisplayList::Clip::decode): Deleted. >+ (WebCore::DisplayList::ClipOut::create): Deleted. >+ (WebCore::DisplayList::ClipOut::encode const): Deleted. >+ (WebCore::DisplayList::ClipOut::decode): Deleted. >+ (WebCore::DisplayList::ClipOutToPath::create): Deleted. >+ (WebCore::DisplayList::ClipPath::create): Deleted. >+ (WebCore::DisplayList::ClipToDrawingCommands::create): Deleted. >+ (WebCore::DisplayList::DrawGlyphs::create): Deleted. >+ (WebCore::DisplayList::DrawImage::create): Deleted. >+ (WebCore::DisplayList::DrawTiledImage::create): Deleted. >+ (WebCore::DisplayList::DrawTiledScaledImage::create): Deleted. >+ (WebCore::DisplayList::DrawImageBuffer::create): Deleted. >+ (WebCore::DisplayList::DrawNativeImage::create): Deleted. >+ (WebCore::DisplayList::DrawPattern::create): Deleted. >+ (WebCore::DisplayList::BeginTransparencyLayer::create): Deleted. >+ (WebCore::DisplayList::BeginTransparencyLayer::encode const): Deleted. >+ (WebCore::DisplayList::BeginTransparencyLayer::decode): Deleted. >+ (WebCore::DisplayList::EndTransparencyLayer::create): Deleted. >+ (WebCore::DisplayList::EndTransparencyLayer::encode const): Deleted. >+ (WebCore::DisplayList::EndTransparencyLayer::decode): Deleted. >+ (WebCore::DisplayList::DrawRect::create): Deleted. >+ (WebCore::DisplayList::DrawRect::encode const): Deleted. >+ (WebCore::DisplayList::DrawRect::decode): Deleted. >+ (WebCore::DisplayList::DrawLine::create): Deleted. >+ (WebCore::DisplayList::DrawLine::encode const): Deleted. >+ (WebCore::DisplayList::DrawLine::decode): Deleted. >+ (WebCore::DisplayList::DrawLinesForText::create): Deleted. >+ (WebCore::DisplayList::DrawDotsForDocumentMarker::create): Deleted. >+ (WebCore::DisplayList::DrawDotsForDocumentMarker::encode const): Deleted. >+ (WebCore::DisplayList::DrawDotsForDocumentMarker::decode): Deleted. >+ (WebCore::DisplayList::DrawEllipse::create): Deleted. >+ (WebCore::DisplayList::DrawEllipse::encode const): Deleted. >+ (WebCore::DisplayList::DrawEllipse::decode): Deleted. >+ (WebCore::DisplayList::DrawPath::create): Deleted. >+ (WebCore::DisplayList::DrawFocusRingPath::create): Deleted. >+ (WebCore::DisplayList::DrawFocusRingRects::create): Deleted. >+ (WebCore::DisplayList::FillRect::create): Deleted. >+ (WebCore::DisplayList::FillRect::encode const): Deleted. >+ (WebCore::DisplayList::FillRect::decode): Deleted. >+ (WebCore::DisplayList::FillRectWithColor::create): Deleted. >+ (WebCore::DisplayList::FillRectWithGradient::create): Deleted. >+ (WebCore::DisplayList::FillCompositedRect::create): Deleted. >+ (WebCore::DisplayList::FillRoundedRect::create): Deleted. >+ (WebCore::DisplayList::FillRectWithRoundedHole::create): Deleted. >+ (WebCore::DisplayList::FillInlinePath::create): Deleted. >+ (WebCore::DisplayList::FillInlinePath::encode const): Deleted. >+ (WebCore::DisplayList::FillInlinePath::decode): Deleted. >+ (WebCore::DisplayList::FillPath::create): Deleted. >+ (WebCore::DisplayList::FillEllipse::create): Deleted. >+ (WebCore::DisplayList::FillEllipse::encode const): Deleted. >+ (WebCore::DisplayList::FillEllipse::decode): Deleted. >+ (WebCore::DisplayList::PutImageData::create): Deleted. >+ (WebCore::DisplayList::PaintFrameForMedia::encode const): Deleted. >+ (WebCore::DisplayList::PaintFrameForMedia::decode): Deleted. >+ (WebCore::DisplayList::StrokeRect::create): Deleted. >+ (WebCore::DisplayList::StrokeRect::encode const): Deleted. >+ (WebCore::DisplayList::StrokeRect::decode): Deleted. >+ (WebCore::DisplayList::StrokeInlinePath::create): Deleted. >+ (WebCore::DisplayList::StrokeInlinePath::encode const): Deleted. >+ (WebCore::DisplayList::StrokeInlinePath::decode): Deleted. >+ (WebCore::DisplayList::StrokePath::create): Deleted. >+ (WebCore::DisplayList::StrokeEllipse::create): Deleted. >+ (WebCore::DisplayList::StrokeEllipse::encode const): Deleted. >+ (WebCore::DisplayList::StrokeEllipse::decode): Deleted. >+ (WebCore::DisplayList::ClearRect::create): Deleted. >+ (WebCore::DisplayList::ClearRect::encode const): Deleted. >+ (WebCore::DisplayList::ClearRect::decode): Deleted. >+ (WebCore::DisplayList::ApplyStrokePattern::create): Deleted. >+ (WebCore::DisplayList::ApplyStrokePattern::encode const): Deleted. >+ (WebCore::DisplayList::ApplyStrokePattern::decode): Deleted. >+ (WebCore::DisplayList::ApplyFillPattern::create): Deleted. >+ (WebCore::DisplayList::ApplyFillPattern::encode const): Deleted. >+ (WebCore::DisplayList::ApplyFillPattern::decode): Deleted. >+ (WebCore::DisplayList::ApplyDeviceScaleFactor::create): Deleted. >+ (WebCore::DisplayList::ApplyDeviceScaleFactor::encode const): Deleted. >+ (WebCore::DisplayList::ApplyDeviceScaleFactor::decode): Deleted. >+ (WebCore::DisplayList::Item::encode const): Deleted. >+ (WebCore::DisplayList::Item::decode): Deleted. >+ >+ Delete the generic `Item::encode` and `Item::decode` methods, since only out-of-line display list items have >+ encode and decode functions now. >+ >+ * platform/graphics/displaylists/DisplayListRecorder.cpp: >+ (WebCore::DisplayList::Recorder::putImageData): >+ (WebCore::DisplayList::Recorder::appendStateChangeItem): >+ (WebCore::DisplayList::Recorder::clearShadow): >+ (WebCore::DisplayList::Recorder::setLineCap): >+ (WebCore::DisplayList::Recorder::setLineDash): >+ (WebCore::DisplayList::Recorder::setLineJoin): >+ (WebCore::DisplayList::Recorder::setMiterLimit): >+ (WebCore::DisplayList::Recorder::drawImage): >+ (WebCore::DisplayList::Recorder::drawTiledImage): >+ (WebCore::DisplayList::Recorder::drawImageBuffer): >+ (WebCore::DisplayList::Recorder::drawNativeImage): >+ (WebCore::DisplayList::Recorder::drawPattern): >+ (WebCore::DisplayList::Recorder::save): >+ (WebCore::DisplayList::Recorder::restore): >+ (WebCore::DisplayList::Recorder::translate): >+ (WebCore::DisplayList::Recorder::rotate): >+ (WebCore::DisplayList::Recorder::scale): >+ (WebCore::DisplayList::Recorder::concatCTM): >+ (WebCore::DisplayList::Recorder::setCTM): >+ (WebCore::DisplayList::Recorder::beginTransparencyLayer): >+ (WebCore::DisplayList::Recorder::endTransparencyLayer): >+ (WebCore::DisplayList::Recorder::drawRect): >+ (WebCore::DisplayList::Recorder::drawLine): >+ (WebCore::DisplayList::Recorder::drawLinesForText): >+ (WebCore::DisplayList::Recorder::drawDotsForDocumentMarker): >+ (WebCore::DisplayList::Recorder::drawEllipse): >+ (WebCore::DisplayList::Recorder::drawPath): >+ (WebCore::DisplayList::Recorder::drawFocusRing): >+ (WebCore::DisplayList::Recorder::fillRect): >+ (WebCore::DisplayList::Recorder::fillRoundedRect): >+ (WebCore::DisplayList::Recorder::fillRectWithRoundedHole): >+ (WebCore::DisplayList::Recorder::fillPath): >+ (WebCore::DisplayList::Recorder::fillEllipse): >+ (WebCore::DisplayList::Recorder::strokeRect): >+ (WebCore::DisplayList::Recorder::strokePath): >+ (WebCore::DisplayList::Recorder::strokeEllipse): >+ (WebCore::DisplayList::Recorder::clearRect): >+ (WebCore::DisplayList::Recorder::applyStrokePattern): >+ (WebCore::DisplayList::Recorder::applyFillPattern): >+ (WebCore::DisplayList::Recorder::clip): >+ (WebCore::DisplayList::Recorder::clipOut): >+ (WebCore::DisplayList::Recorder::clipPath): >+ (WebCore::DisplayList::Recorder::clipToDrawingCommands): >+ (WebCore::DisplayList::Recorder::paintFrameForMedia): >+ (WebCore::DisplayList::Recorder::applyDeviceScaleFactor): >+ >+ Change these methods that append display list items en masse, such that they go from this: >+ >+ `m_displayList.append(Foo::create(arg1, arg2, arg3));` >+ >+ ...to this: >+ >+ `m_displayList.append<Foo>(arg1, arg2, arg3);` >+ >+ (WebCore::DisplayList::Recorder::extentFromLocalBounds const): >+ (WebCore::DisplayList::Recorder::appendItemAndUpdateExtent): Deleted. >+ (WebCore::DisplayList::Recorder::appendItem): Deleted. >+ (WebCore::DisplayList::Recorder::updateItemExtent const): Deleted. >+ >+ Extents are now automatically updated (unless otherwise specified) for any drawing items that are appended. >+ >+ * platform/graphics/displaylists/DisplayListRecorder.h: >+ (WebCore::DisplayList::Recorder::append): >+ * platform/graphics/displaylists/DisplayListReplayer.cpp: >+ (WebCore::DisplayList::Replayer::replay): >+ * platform/graphics/displaylists/DisplayListReplayer.h: >+ (WebCore::DisplayList::Replayer::Delegate::apply): >+ > 2020-11-06 Antti Koivisto <antti@apple.com> > > [LFC][Integration] localCaretOffset should use iterator >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index f963c08a5fa8abf4e09a08315772587b26cc89b3..aa9637ad6fddddd522b176736caf7df35dda6408 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,63 @@ >+2020-11-03 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ [Concurrent display lists] Encode display list items directly into shared memory >+ https://bugs.webkit.org/show_bug.cgi?id=218406 >+ >+ Reviewed by Tim Horton. >+ >+ Adjust for changes to display lists and display list items in WebCore (see Source/WebCore/ChangeLog for more >+ information). In particular, we implement the reading and writing client hooks consulted by ItemBuffer, and we >+ also add a temporary mechanism that allows RemoteRenderingBackendProxy (in the web process) to send display list >+ item data through shared memory to the RemoteRenderingBackend (in the GPU process). This temporary mechanism >+ does not attempt to make any reading or writing in shared memory concurrent between the GPU and web processes, >+ and exists only to make sure that rendering with the GPU process still works using these new display list items. >+ >+ In the next patch, I will add a simple concurrent reader/writer model for display list processing between the >+ web and GPU processes, and (in doing so) revert most of the changes in `RemoteRenderingBackend` and >+ `RemoteRenderingBackendProxy` below. >+ >+ See comments below for more detail. >+ >+ * GPUProcess/graphics/RemoteImageBuffer.h: >+ (WebKit::RemoteImageBuffer::decodeAndCreate): >+ * GPUProcess/graphics/RemoteRenderingBackend.cpp: >+ (WebKit::RemoteRenderingBackend::applyResourceItem): >+ (WebKit::RemoteRenderingBackend::applyMediaItem): >+ >+ Refactor these to take `WebCore::DisplayList::ItemHandle`. >+ >+ (WebKit::RemoteRenderingBackend::applyDisplayList): >+ (WebKit::RemoteRenderingBackend::flushDisplayList): >+ (WebKit::RemoteRenderingBackend::flushDisplayListAndCommit): >+ (WebKit::RemoteRenderingBackend::didCreateSharedItemData): >+ * GPUProcess/graphics/RemoteRenderingBackend.h: >+ * GPUProcess/graphics/RemoteRenderingBackend.messages.in: >+ * Scripts/webkit/messages.py: >+ * Shared/SharedDisplayListHandle.cpp: Added. >+ (WebKit::SharedDisplayListHandle::SharedDisplayListHandle): >+ (WebKit::SharedDisplayListHandle::createDisplayList const): >+ * Shared/SharedDisplayListHandle.h: Added. >+ >+ Add a WebKit2 helper class that represents display list data in shared memory that is propagated from the web >+ process to the GPU process. In the next patch, this class will be rewritten to support concurrent display list >+ reading and writing, with specialized subclasses in service of both the reader (i.e. the GPU process) and the >+ writer (i.e. the web process). >+ >+ (WebKit::SharedDisplayListHandle::SharedDisplayListHandle): >+ (WebKit::SharedDisplayListHandle::encode const): >+ (WebKit::SharedDisplayListHandle::decode): >+ * Sources.txt: >+ * WebKit.xcodeproj/project.pbxproj: >+ * WebProcess/GPU/graphics/RemoteImageBufferProxy.h: >+ (WebKit::RemoteImageBufferProxy::RemoteImageBufferProxy): >+ * WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp: >+ (WebKit::RemoteRenderingBackendProxy::flushDisplayList): >+ (WebKit::RemoteRenderingBackendProxy::flushDisplayListAndCommit): >+ (WebKit::RemoteRenderingBackendProxy::createItemBuffer): >+ * WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h: >+ * WebProcess/GPU/graphics/RemoteRenderingBackendProxy.messages.in: >+ * WebProcess/GPU/graphics/RemoteResourceCacheProxy.cpp: >+ > 2020-11-05 Wenson Hsieh <wenson_hsieh@apple.com> > > Encoding PutImageData should not serialize separate IPC attachments for the image data >diff --git a/Source/WebCore/Headers.cmake b/Source/WebCore/Headers.cmake >index b3515d3d5b7f73f79613960be04b37b457922981..a43c2058165e84593f894c6acbe6842e2bca5f37 100644 >--- a/Source/WebCore/Headers.cmake >+++ b/Source/WebCore/Headers.cmake >@@ -1253,6 +1253,7 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS > platform/graphics/displaylists/DisplayListDrawGlyphsRecorder.h > platform/graphics/displaylists/DisplayListDrawingContext.h > platform/graphics/displaylists/DisplayListImageBuffer.h >+ platform/graphics/displaylists/DisplayListItemBuffer.h > platform/graphics/displaylists/DisplayListItemType.h > platform/graphics/displaylists/DisplayListItems.h > platform/graphics/displaylists/DisplayListRecorder.h >diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt >index a4e7317b3309602dfa9b5570d356c8bbb33b8443..f743dda5b790deef5fa54eba5e518c30dacf7e86 100644 >--- a/Source/WebCore/Sources.txt >+++ b/Source/WebCore/Sources.txt >@@ -1963,6 +1963,7 @@ platform/graphics/cpu/arm/filters/FELightingNEON.cpp > platform/graphics/displaylists/DisplayList.cpp > platform/graphics/displaylists/DisplayListDrawingContext.cpp > platform/graphics/displaylists/DisplayListItems.cpp >+platform/graphics/displaylists/DisplayListItemBuffer.cpp > platform/graphics/displaylists/DisplayListItemType.cpp > platform/graphics/displaylists/DisplayListRecorder.cpp > platform/graphics/displaylists/DisplayListReplayer.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index 85d62e22131b2cd0d97194b5d9b4d0b6d7a77ba7..17b9c3d2cfbd3514ae19b98abae020fea3b70813 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -5202,6 +5202,7 @@ > F4C5F2072479E88200E9B4F5 /* ClipboardImageReader.h in Headers */ = {isa = PBXBuildFile; fileRef = F4C5F2052479E7EE00E9B4F5 /* ClipboardImageReader.h */; }; > F4D07558234D822D00881E73 /* ClipboardItemDataSource.h in Headers */ = {isa = PBXBuildFile; fileRef = F46C447A2346535E0039A79D /* ClipboardItemDataSource.h */; }; > F4D07559234D823300881E73 /* ClipboardItemPasteboardDataSource.h in Headers */ = {isa = PBXBuildFile; fileRef = F46C44802346547A0039A79D /* ClipboardItemPasteboardDataSource.h */; }; >+ F4D40BC9255463BF00721349 /* DisplayListItemBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = F422B8B5253F7065004E77E8 /* DisplayListItemBuffer.h */; settings = {ATTRIBUTES = (Private, ); }; }; > F4D43D662188038B00ECECAC /* SerializedAttachmentData.h in Headers */ = {isa = PBXBuildFile; fileRef = F4D43D64218802E600ECECAC /* SerializedAttachmentData.h */; settings = {ATTRIBUTES = (Private, ); }; }; > F4E57EDC213F3F5F004EA98E /* FontAttributeChanges.h in Headers */ = {isa = PBXBuildFile; fileRef = F4E57EDA213F3F5F004EA98E /* FontAttributeChanges.h */; settings = {ATTRIBUTES = (Private, ); }; }; > F4E57EE1213F434A004EA98E /* WebCoreNSFontManagerExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = F4E57EDF213F434A004EA98E /* WebCoreNSFontManagerExtras.h */; settings = {ATTRIBUTES = (Private, ); }; }; >@@ -16338,6 +16339,8 @@ > F3D461471161D53200CA0D09 /* JSErrorHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSErrorHandler.h; sourceTree = "<group>"; }; > F403E7852363B58C00044550 /* EnterKeyHint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EnterKeyHint.h; sourceTree = "<group>"; }; > F403E7862363B58C00044550 /* EnterKeyHint.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = EnterKeyHint.cpp; sourceTree = "<group>"; }; >+ F422B8B5253F7065004E77E8 /* DisplayListItemBuffer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayListItemBuffer.h; sourceTree = "<group>"; }; >+ F422B8B6253F7065004E77E8 /* DisplayListItemBuffer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayListItemBuffer.cpp; sourceTree = "<group>"; }; > F429261725264D4400007898 /* MediaPlayerIdentifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaPlayerIdentifier.h; sourceTree = "<group>"; }; > F42CEB54214031EE002DCA72 /* FontAttributeChangesCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FontAttributeChangesCocoa.mm; sourceTree = "<group>"; }; > F433E9021DBBDBA200EF0D14 /* StaticPasteboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StaticPasteboard.h; sourceTree = "<group>"; }; >@@ -17647,6 +17650,8 @@ > 55C0A29523FE2CE000F2CB93 /* DisplayListDrawingContext.cpp */, > 72EA09F923FCCC6A008504A5 /* DisplayListDrawingContext.h */, > 72EA09F723FCCB3D008504A5 /* DisplayListImageBuffer.h */, >+ F422B8B6253F7065004E77E8 /* DisplayListItemBuffer.cpp */, >+ F422B8B5253F7065004E77E8 /* DisplayListItemBuffer.h */, > 0FE5FBCC1C3DD51E0007A2CA /* DisplayListItems.cpp */, > 0FE5FBCD1C3DD51E0007A2CA /* DisplayListItems.h */, > F4377D562551C9C60080ABFE /* DisplayListItemType.cpp */, >@@ -35084,6 +35089,7 @@ > E1EE8B972413195000E794D6 /* XREye.h in Headers */, > E1EE8B8F2413195000E794D6 /* XRFrameRequestCallback.h in Headers */, > E1EE8B922413195000E794D6 /* XRHandedness.h in Headers */, >+ F4D40BC9255463BF00721349 /* DisplayListItemBuffer.h in Headers */, > E1EE8B9F2413195000E794D6 /* XRInputSourceEvent.h in Headers */, > E1EE8B992413195000E794D6 /* XRInputSourcesChangeEvent.h in Headers */, > E12A9F4A248A99E2003F06C8 /* XRInteractionMode.h in Headers */, >diff --git a/Source/WebCore/platform/graphics/GraphicsContext.h b/Source/WebCore/platform/graphics/GraphicsContext.h >index 96353adedff11ed5d415ad57fdfdb4b280d504dd..0b35ac64fa8b9ffe0c94485e973f24c2aa0f3490 100644 >--- a/Source/WebCore/platform/graphics/GraphicsContext.h >+++ b/Source/WebCore/platform/graphics/GraphicsContext.h >@@ -163,10 +163,10 @@ struct GraphicsContextState { > WEBCORE_EXPORT ~GraphicsContextState(); > > GraphicsContextState(const GraphicsContextState&); >- GraphicsContextState(GraphicsContextState&&); >+ WEBCORE_EXPORT GraphicsContextState(GraphicsContextState&&); > > GraphicsContextState& operator=(const GraphicsContextState&); >- GraphicsContextState& operator=(GraphicsContextState&&); >+ WEBCORE_EXPORT GraphicsContextState& operator=(GraphicsContextState&&); > > enum Change : uint32_t { > StrokeGradientChange = 1 << 0, >diff --git a/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp b/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp >index 424d9a04c16342d90696638a22cf37274e28e0e2..4061f8c28ae58a25e9a258db00b360a60ae6cd5f 100644 >--- a/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp >+++ b/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp >@@ -26,8 +26,10 @@ > #include "config.h" > #include "DisplayList.h" > >+#include "DisplayListItemBuffer.h" > #include "DisplayListItems.h" > #include "Logging.h" >+#include <wtf/FastMalloc.h> > #include <wtf/StdLibExtras.h> > #include <wtf/text/TextStream.h> > >@@ -48,18 +50,43 @@ void DisplayList::dump() const > } > #endif > >+DisplayList::DisplayList(DisplayList&& other) >+ : m_imageBuffers(std::exchange(other.m_imageBuffers, { })) >+ , m_items(std::exchange(other.m_items, nullptr)) >+ , m_drawingItemExtents(std::exchange(other.m_drawingItemExtents, { })) >+{ >+} >+ >+DisplayList::DisplayList(ItemBufferHandles&& handles) >+ : m_items(makeUnique<ItemBuffer>(WTFMove(handles))) >+{ >+} >+ >+DisplayList::DisplayList() = default; >+DisplayList::~DisplayList() = default; >+ >+DisplayList& DisplayList::operator=(DisplayList&& other) >+{ >+ m_imageBuffers = std::exchange(other.m_imageBuffers, { }); >+ m_items = std::exchange(other.m_items, nullptr); >+ m_drawingItemExtents = std::exchange(other.m_drawingItemExtents, { }); >+ return *this; >+} >+ > void DisplayList::clear() > { >- m_list.clear(); >+ if (m_items) >+ m_items->clear(); >+ m_drawingItemExtents.clear(); > m_imageBuffers.clear(); > } > >-bool DisplayList::shouldDumpForFlags(AsTextFlags flags, const Item& item) >+bool DisplayList::shouldDumpForFlags(AsTextFlags flags, ItemHandle item) > { > switch (item.type()) { > case ItemType::SetState: > if (!(flags & AsTextFlag::IncludesPlatformOperations)) { >- const auto& stateItem = downcast<SetState>(item); >+ const auto& stateItem = item.get<SetState>(); > // FIXME: for now, only drop the item if the only state-change flags are platform-specific. > if (stateItem.state().m_changeFlags == GraphicsContextState::ShouldSubpixelQuantizeFontsChange) > return false; >@@ -84,10 +111,14 @@ bool DisplayList::shouldDumpForFlags(AsTextFlags flags, const Item& item) > String DisplayList::asText(AsTextFlags flags) const > { > TextStream stream(TextStream::LineMode::MultipleLine, TextStream::Formatting::SVGStyleRect); >- for (auto& item : m_list) { >+ for (auto [item, extent] : *this) { > if (!shouldDumpForFlags(flags, item)) > continue; >+ >+ TextStream::GroupScope group(stream); > stream << item; >+ if (item.isDrawingItem()) >+ stream << " extent " << extent; > } > return stream.release(); > } >@@ -97,10 +128,11 @@ void DisplayList::dump(TextStream& ts) const > TextStream::GroupScope group(ts); > ts << "display list"; > >- size_t numItems = m_list.size(); >- for (size_t i = 0; i < numItems; ++i) { >- TextStream::GroupScope scope(ts); >- ts << i << " " << m_list[i].get(); >+ for (auto [item, extent] : *this) { >+ TextStream::GroupScope group(ts); >+ ts << item; >+ if (item.isDrawingItem()) >+ ts << " extent " << extent; > } > ts.startGroup(); > ts << "size in bytes: " << sizeInBytes(); >@@ -109,13 +141,275 @@ void DisplayList::dump(TextStream& ts) const > > size_t DisplayList::sizeInBytes() const > { >- size_t result = 0; >- for (auto& ref : m_list) >- result += Item::sizeInBytes(ref); >+ return m_items ? m_items->sizeInBytes() : 0; >+} >+ >+bool DisplayList::isEmpty() const >+{ >+ return !m_items || m_items->isEmpty(); >+} >+ >+ItemBuffer& DisplayList::itemBuffer() >+{ >+ if (!m_items) >+ m_items = makeUnique<ItemBuffer>(); >+ return *m_items; >+} >+ >+void DisplayList::setItemBufferClient(ItemBufferReadingClient* client) >+{ >+ itemBuffer().setClient(client); >+} >+ >+void DisplayList::setItemBufferClient(ItemBufferWritingClient* client) >+{ >+ itemBuffer().setClient(client); >+} >+ >+void DisplayList::forEachItemBuffer(Function<void(const ItemBufferHandle&)>&& mapFunction) const >+{ >+ if (m_items) >+ m_items->forEachItemBuffer(WTFMove(mapFunction)); >+} > >- return result; >+void DisplayList::setTracksDrawingItemExtents(bool value) >+{ >+ RELEASE_ASSERT(!m_items || m_items->isEmpty()); >+ m_tracksDrawingItemExtents = value; > } > >+void DisplayList::append(ItemHandle item) >+{ >+ switch (item.type()) { >+ case ItemType::Save: >+ return append<Save>(item.get<Save>()); >+ case ItemType::Restore: >+ return append<Restore>(item.get<Restore>()); >+ case ItemType::Translate: >+ return append<Translate>(item.get<Translate>()); >+ case ItemType::Rotate: >+ return append<Rotate>(item.get<Rotate>()); >+ case ItemType::Scale: >+ return append<Scale>(item.get<Scale>()); >+ case ItemType::ConcatenateCTM: >+ return append<ConcatenateCTM>(item.get<ConcatenateCTM>()); >+ case ItemType::SetCTM: >+ return append<SetCTM>(item.get<SetCTM>()); >+ case ItemType::SetInlineFillGradient: >+ return append<SetInlineFillGradient>(item.get<SetInlineFillGradient>()); >+ case ItemType::SetInlineFillColor: >+ return append<SetInlineFillColor>(item.get<SetInlineFillColor>()); >+ case ItemType::SetInlineStrokeColor: >+ return append<SetInlineStrokeColor>(item.get<SetInlineStrokeColor>()); >+ case ItemType::SetStrokeThickness: >+ return append<SetStrokeThickness>(item.get<SetStrokeThickness>()); >+ case ItemType::SetState: >+ return append<SetState>(item.get<SetState>()); >+ case ItemType::SetLineCap: >+ return append<SetLineCap>(item.get<SetLineCap>()); >+ case ItemType::SetLineDash: >+ return append<SetLineDash>(item.get<SetLineDash>()); >+ case ItemType::SetLineJoin: >+ return append<SetLineJoin>(item.get<SetLineJoin>()); >+ case ItemType::SetMiterLimit: >+ return append<SetMiterLimit>(item.get<SetMiterLimit>()); >+ case ItemType::ClearShadow: >+ return append<ClearShadow>(item.get<ClearShadow>()); >+ case ItemType::Clip: >+ return append<Clip>(item.get<Clip>()); >+ case ItemType::ClipOut: >+ return append<ClipOut>(item.get<ClipOut>()); >+ case ItemType::ClipOutToPath: >+ return append<ClipOutToPath>(item.get<ClipOutToPath>()); >+ case ItemType::ClipPath: >+ return append<ClipPath>(item.get<ClipPath>()); >+ case ItemType::ClipToDrawingCommands: { >+ ASSERT_NOT_REACHED(); >+ return; // FIXME: Support the ability to clone display lists (this is currently only used for display list tracking). >+ } >+ case ItemType::DrawGlyphs: >+ return append<DrawGlyphs>(item.get<DrawGlyphs>()); >+ case ItemType::DrawImage: >+ return append<DrawImage>(item.get<DrawImage>()); >+ case ItemType::DrawTiledImage: >+ return append<DrawTiledImage>(item.get<DrawTiledImage>()); >+ case ItemType::DrawTiledScaledImage: >+ return append<DrawTiledScaledImage>(item.get<DrawTiledScaledImage>()); >+ case ItemType::DrawImageBuffer: >+ return append<DrawImageBuffer>(item.get<DrawImageBuffer>()); >+ case ItemType::DrawNativeImage: >+ return append<DrawNativeImage>(item.get<DrawNativeImage>()); >+ case ItemType::DrawPattern: >+ return append<DrawPattern>(item.get<DrawPattern>()); >+ case ItemType::DrawRect: >+ return append<DrawRect>(item.get<DrawRect>()); >+ case ItemType::DrawLine: >+ return append<DrawLine>(item.get<DrawLine>()); >+ case ItemType::DrawLinesForText: >+ return append<DrawLinesForText>(item.get<DrawLinesForText>()); >+ case ItemType::DrawDotsForDocumentMarker: >+ return append<DrawDotsForDocumentMarker>(item.get<DrawDotsForDocumentMarker>()); >+ case ItemType::DrawEllipse: >+ return append<DrawEllipse>(item.get<DrawEllipse>()); >+ case ItemType::DrawPath: >+ return append<DrawPath>(item.get<DrawPath>()); >+ case ItemType::DrawFocusRingPath: >+ return append<DrawFocusRingPath>(item.get<DrawFocusRingPath>()); >+ case ItemType::DrawFocusRingRects: >+ return append<DrawFocusRingRects>(item.get<DrawFocusRingRects>()); >+ case ItemType::FillRect: >+ return append<FillRect>(item.get<FillRect>()); >+ case ItemType::FillRectWithColor: >+ return append<FillRectWithColor>(item.get<FillRectWithColor>()); >+ case ItemType::FillRectWithGradient: >+ return append<FillRectWithGradient>(item.get<FillRectWithGradient>()); >+ case ItemType::FillCompositedRect: >+ return append<FillCompositedRect>(item.get<FillCompositedRect>()); >+ case ItemType::FillRoundedRect: >+ return append<FillRoundedRect>(item.get<FillRoundedRect>()); >+ case ItemType::FillRectWithRoundedHole: >+ return append<FillRectWithRoundedHole>(item.get<FillRectWithRoundedHole>()); >+#if ENABLE(INLINE_PATH_DATA) >+ case ItemType::FillInlinePath: >+ return append<FillInlinePath>(item.get<FillInlinePath>()); >+#endif >+ case ItemType::FillPath: >+ return append<FillPath>(item.get<FillPath>()); >+ case ItemType::FillEllipse: >+ return append<FillEllipse>(item.get<FillEllipse>()); >+ case ItemType::PutImageData: >+ return append<PutImageData>(item.get<PutImageData>()); >+ case ItemType::PaintFrameForMedia: >+ return append<PaintFrameForMedia>(item.get<PaintFrameForMedia>()); >+ case ItemType::StrokeRect: >+ return append<StrokeRect>(item.get<StrokeRect>()); >+#if ENABLE(INLINE_PATH_DATA) >+ case ItemType::StrokeInlinePath: >+ return append<StrokeInlinePath>(item.get<StrokeInlinePath>()); >+#endif >+ case ItemType::StrokePath: >+ return append<StrokePath>(item.get<StrokePath>()); >+ case ItemType::StrokeEllipse: >+ return append<StrokeEllipse>(item.get<StrokeEllipse>()); >+ case ItemType::ClearRect: >+ return append<ClearRect>(item.get<ClearRect>()); >+ case ItemType::BeginTransparencyLayer: >+ return append<BeginTransparencyLayer>(item.get<BeginTransparencyLayer>()); >+ case ItemType::EndTransparencyLayer: >+ return append<EndTransparencyLayer>(item.get<EndTransparencyLayer>()); >+#if USE(CG) >+ case ItemType::ApplyStrokePattern: >+ return append<ApplyStrokePattern>(item.get<ApplyStrokePattern>()); >+ case ItemType::ApplyFillPattern: >+ return append<ApplyFillPattern>(item.get<ApplyFillPattern>()); >+#endif >+ case ItemType::ApplyDeviceScaleFactor: >+ return append<ApplyDeviceScaleFactor>(item.get<ApplyDeviceScaleFactor>()); >+ } >+} >+ >+bool DisplayList::iterator::atEnd() const >+{ >+ if (m_displayList.isEmpty()) >+ return true; >+ >+ auto& items = *m_displayList.m_items; >+ auto endCursor = items.m_writableBuffer.data + items.m_writtenNumberOfBytes; >+ return m_cursor == endCursor; >+} >+ >+void DisplayList::iterator::updateCurrentItem() >+{ >+ clearCurrentItem(); >+ >+ if (atEnd()) >+ return; >+ >+ auto& items = *m_displayList.m_items; >+ auto itemType = static_cast<ItemType>(m_cursor[0]); >+ if (isDrawingItem(itemType) && !m_displayList.m_drawingItemExtents.isEmpty()) { >+ m_currentExtent = m_displayList.m_drawingItemExtents[m_drawingItemIndex]; >+ m_drawingItemIndex++; >+ } else >+ m_currentExtent = WTF::nullopt; >+ >+ auto* client = items.m_readingClient; >+ auto sizeOfTypeAndItem = sizeOfItemInBytes(itemType) + sizeof(ItemType); >+ m_currentBufferForItem = sizeOfTypeAndItem <= sizeOfFixedBufferForCurrentItem ? m_fixedBufferForCurrentItem : reinterpret_cast<uint8_t*>(fastMalloc(sizeOfTypeAndItem)); >+ if (!isInlineItem(itemType) && client) { >+ auto sizeOfData = reinterpret_cast<size_t*>(m_cursor + sizeof(ItemType))[0]; >+ auto* startOfPadding = m_cursor + sizeof(ItemType) + sizeof(size_t); >+ size_t padding = (alignof(uint64_t) - reinterpret_cast<uintptr_t>(startOfPadding) % alignof(uint64_t)) % alignof(uint64_t); >+ auto decodedItemHandle = client->decodeItem(startOfPadding + padding, sizeOfData, itemType, m_currentBufferForItem); >+ if (!decodedItemHandle) { >+ // FIXME: Instead of crashing, this needs to fail gracefully and inform the caller. >+ // For the time being, this assertion makes bugs in item buffer encoding logic easier >+ // to catch by avoiding mysterious out-of-bounds reads and incorrectly aligned items >+ // down the line. >+ RELEASE_ASSERT_NOT_REACHED(); >+ } >+ m_currentBufferForItem[0] = static_cast<uint8_t>(itemType); >+ m_currentItemSizeInBuffer = sizeof(ItemType) + sizeof(size_t) + padding + sizeOfData; >+ } else { >+ ItemHandle { m_cursor }.copyTo({ m_currentBufferForItem }); >+ m_currentItemSizeInBuffer = sizeOfTypeAndItem; >+ } >+} >+ >+void DisplayList::iterator::advance() >+{ >+ if (atEnd()) >+ return; >+ >+ m_cursor += m_currentItemSizeInBuffer; >+ >+ if (m_cursor == m_currentEndOfBuffer && m_readOnlyBufferIndex < m_displayList.m_items->m_readOnlyBuffers.size()) { >+ m_readOnlyBufferIndex++; >+ moveCursorToStartOfCurrentBuffer(); >+ } >+ >+ updateCurrentItem(); >+} >+ >+void DisplayList::iterator::clearCurrentItem() >+{ >+ if (m_currentBufferForItem) { >+ ItemHandle { m_currentBufferForItem }.destroy(); >+ if (UNLIKELY(m_currentBufferForItem != m_fixedBufferForCurrentItem)) >+ fastFree(m_currentBufferForItem); >+ } >+ >+ m_currentItemSizeInBuffer = 0; >+ m_currentBufferForItem = nullptr; >+} >+ >+void DisplayList::iterator::moveToEnd() >+{ >+ if (auto& items = m_displayList.m_items) { >+ m_cursor = items->m_writableBuffer.data + items->m_writtenNumberOfBytes; >+ m_currentEndOfBuffer = m_cursor; >+ m_readOnlyBufferIndex = items->m_readOnlyBuffers.size(); >+ } >+} >+ >+void DisplayList::iterator::moveCursorToStartOfCurrentBuffer() >+{ >+ auto& items = m_displayList.m_items; >+ if (!items) >+ return; >+ >+ auto numberOfReadOnlyBuffers = items->m_readOnlyBuffers.size(); >+ if (m_readOnlyBufferIndex < numberOfReadOnlyBuffers) { >+ auto& nextBufferHandle = items->m_readOnlyBuffers[m_readOnlyBufferIndex]; >+ m_cursor = nextBufferHandle.data; >+ m_currentEndOfBuffer = m_cursor + nextBufferHandle.capacity; >+ } else if (m_readOnlyBufferIndex == numberOfReadOnlyBuffers) { >+ m_cursor = items->m_writableBuffer.data; >+ m_currentEndOfBuffer = m_cursor + items->m_writtenNumberOfBytes; >+ } >+} >+ >+ > } // namespace DisplayList > > TextStream& operator<<(TextStream& ts, const DisplayList::DisplayList& displayList) >diff --git a/Source/WebCore/platform/graphics/displaylists/DisplayList.h b/Source/WebCore/platform/graphics/displaylists/DisplayList.h >index 85d012a4750b2abeb0b8b35b83f02903802773d9..474ebf2797d8de0d55dc51463683dd438338500e 100644 >--- a/Source/WebCore/platform/graphics/displaylists/DisplayList.h >+++ b/Source/WebCore/platform/graphics/displaylists/DisplayList.h >@@ -25,6 +25,7 @@ > > #pragma once > >+#include "DisplayListItemBuffer.h" > #include "DisplayListItemType.h" > #include "FloatRect.h" > #include "GraphicsContext.h" >@@ -32,6 +33,8 @@ > #include <wtf/FastMalloc.h> > #include <wtf/HashSet.h> > #include <wtf/Noncopyable.h> >+#include <wtf/ObjectIdentifier.h> >+#include <wtf/Vector.h> > #include <wtf/text/WTFString.h> > > namespace WTF { >@@ -42,34 +45,6 @@ namespace WebCore { > > namespace DisplayList { > >-class Item : public RefCounted<Item> { >-public: >- Item() = delete; >- >- WEBCORE_EXPORT Item(ItemType); >- WEBCORE_EXPORT virtual ~Item(); >- >- ItemType type() const >- { >- return m_type; >- } >- >- virtual void apply(GraphicsContext&) const = 0; >- >- virtual bool isDrawingItem() const { return false; } >- >-#if !defined(NDEBUG) || !LOG_DISABLED >- WTF::CString description() const; >-#endif >- static size_t sizeInBytes(const Item&); >- >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<Item>> decode(Decoder&); >- >-private: >- ItemType m_type; >-}; >- > enum AsTextFlag { > None = 0, > IncludesPlatformOperations = 1 << 0, >@@ -82,48 +57,97 @@ class DisplayList { > friend class Recorder; > friend class Replayer; > public: >- DisplayList() = default; >- DisplayList(DisplayList&&) = default; >+ WEBCORE_EXPORT DisplayList(); >+ WEBCORE_EXPORT DisplayList(DisplayList&&); >+ WEBCORE_EXPORT DisplayList(ItemBufferHandles&&); > >- DisplayList& operator=(DisplayList&&) = default; >+ WEBCORE_EXPORT ~DisplayList(); > >- void dump(WTF::TextStream&) const; >+ WEBCORE_EXPORT DisplayList& operator=(DisplayList&&); > >- const Vector<Ref<Item>>& list() const { return m_list; } >- Item& itemAt(size_t index) >- { >- ASSERT(index < m_list.size()); >- return m_list[index].get(); >- } >+ void dump(WTF::TextStream&) const; > > WEBCORE_EXPORT void clear(); >+ WEBCORE_EXPORT bool isEmpty() const; >+ WEBCORE_EXPORT size_t sizeInBytes() const; > >- bool isEmpty() const { return m_list.isEmpty(); } >- size_t sizeInBytes() const; >- > String asText(AsTextFlags) const; > > const ImageBufferHashMap& imageBuffers() const { return m_imageBuffers; } > >+ WEBCORE_EXPORT void setItemBufferClient(ItemBufferReadingClient*); >+ WEBCORE_EXPORT void setItemBufferClient(ItemBufferWritingClient*); >+ > #if !defined(NDEBUG) || !LOG_DISABLED > WTF::CString description() const; > WEBCORE_EXPORT void dump() const; > #endif > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<DisplayList> decode(Decoder&); >+ WEBCORE_EXPORT void forEachItemBuffer(Function<void(const ItemBufferHandle&)>&&) const; >+ >+ template<typename T, class... Args> void append(Args&&... args); >+ void append(ItemHandle); >+ >+ bool tracksDrawingItemExtents() const { return m_tracksDrawingItemExtents; } >+ WEBCORE_EXPORT void setTracksDrawingItemExtents(bool); >+ >+ class iterator { >+ public: >+ enum class ImmediatelyMoveToEnd { No, Yes }; >+ iterator(const DisplayList& displayList, ImmediatelyMoveToEnd immediatelyMoveToEnd = ImmediatelyMoveToEnd::No) >+ : m_displayList(displayList) >+ { >+ if (immediatelyMoveToEnd == ImmediatelyMoveToEnd::Yes) >+ moveToEnd(); >+ else { >+ moveCursorToStartOfCurrentBuffer(); >+ updateCurrentItem(); >+ } >+ } >+ >+ ~iterator() >+ { >+ clearCurrentItem(); >+ } >+ >+ bool operator==(const iterator& other) { return &m_displayList == &other.m_displayList && m_cursor == other.m_cursor; } >+ bool operator!=(const iterator& other) { return !(*this == other); } >+ void operator++() { advance(); } >+ std::pair<ItemHandle, Optional<FloatRect>> operator*() const { return { ItemHandle { m_currentBufferForItem }, m_currentExtent }; } >+ >+ private: >+ static constexpr size_t sizeOfFixedBufferForCurrentItem = 256; >+ >+ WEBCORE_EXPORT void moveCursorToStartOfCurrentBuffer(); >+ WEBCORE_EXPORT void moveToEnd(); >+ WEBCORE_EXPORT void clearCurrentItem(); >+ WEBCORE_EXPORT void updateCurrentItem(); >+ WEBCORE_EXPORT void advance(); >+ bool atEnd() const; >+ >+ const DisplayList& m_displayList; >+ uint8_t* m_cursor { nullptr }; >+ size_t m_readOnlyBufferIndex { 0 }; >+ size_t m_drawingItemIndex { 0 }; >+ uint8_t* m_currentEndOfBuffer { nullptr }; >+ >+ uint8_t m_fixedBufferForCurrentItem[sizeOfFixedBufferForCurrentItem] { 0 }; >+ uint8_t* m_currentBufferForItem { nullptr }; >+ Optional<FloatRect> m_currentExtent; >+ size_t m_currentItemSizeInBuffer { 0 }; >+ }; >+ >+ iterator begin() const { return { *this }; } >+ iterator end() const { return { *this, iterator::ImmediatelyMoveToEnd::Yes }; } > > private: >- Item& append(Ref<Item>&& item) >- { >- m_list.append(WTFMove(item)); >- return m_list.last().get(); >- } >+ ItemBuffer* itemBufferIfExists() const { return m_items.get(); } >+ WEBCORE_EXPORT ItemBuffer& itemBuffer(); > >- // Less efficient append, only used for tracking replay. >- void appendItem(Item& item) >+ void addDrawingItemExtent(Optional<FloatRect>&& extent) > { >- m_list.append(item); >+ ASSERT(m_tracksDrawingItemExtents); >+ m_drawingItemExtents.append(WTFMove(extent)); > } > > void cacheImageBuffer(Ref<WebCore::ImageBuffer>&& imageBuffer) >@@ -131,44 +155,18 @@ private: > m_imageBuffers.add(imageBuffer->renderingResourceIdentifier(), WTFMove(imageBuffer)); > } > >- static bool shouldDumpForFlags(AsTextFlags, const Item&); >- >- Vector<Ref<Item>>& list() { return m_list; } >+ static bool shouldDumpForFlags(AsTextFlags, ItemHandle); > >- Vector<Ref<Item>> m_list; > ImageBufferHashMap m_imageBuffers; >+ std::unique_ptr<ItemBuffer> m_items; >+ Vector<Optional<FloatRect>> m_drawingItemExtents; >+ bool m_tracksDrawingItemExtents { true }; > }; > >- >-template<class Encoder> >-void DisplayList::encode(Encoder& encoder) const >+template<typename T, class... Args> >+void DisplayList::append(Args&&... args) > { >- encoder << static_cast<uint64_t>(m_list.size()); >- >- for (auto& item : m_list) >- encoder << item.get(); >-} >- >-template<class Decoder> >-Optional<DisplayList> DisplayList::decode(Decoder& decoder) >-{ >- Optional<uint64_t> itemCount; >- decoder >> itemCount; >- if (!itemCount) >- return WTF::nullopt; >- >- DisplayList displayList; >- >- for (uint64_t i = 0; i < *itemCount; i++) { >- auto item = Item::decode(decoder); >- // FIXME: Once we can decode all types, failing to decode an item should turn into a decode failure. >- // For now, we just have to ignore it. >- if (!item) >- continue; >- displayList.append(WTFMove(*item)); >- } >- >- return displayList; >+ itemBuffer().append<T>(std::forward<Args>(args)...); > } > > } // DisplayList >diff --git a/Source/WebCore/platform/graphics/displaylists/DisplayListDrawGlyphsRecorderCoreText.cpp b/Source/WebCore/platform/graphics/displaylists/DisplayListDrawGlyphsRecorderCoreText.cpp >index d5fec87fe0fe0161b33356b563feb5d78acdd5ab..4cd02a8e6a8d37a19e40301845308b9de2d46e2c 100644 >--- a/Source/WebCore/platform/graphics/displaylists/DisplayListDrawGlyphsRecorderCoreText.cpp >+++ b/Source/WebCore/platform/graphics/displaylists/DisplayListDrawGlyphsRecorderCoreText.cpp >@@ -334,7 +334,7 @@ void DrawGlyphsRecorder::recordDrawGlyphs(CGRenderingStateRef, CGGStateRef gstat > updateStrokeColor(CGGStateGetStrokeColor(gstate)); > updateShadow(CGGStateGetStyle(gstate)); > >- m_owner.appendItemAndUpdateExtent(DrawGlyphs::create(*m_originalFont, glyphs, computeAdvancesFromPositions(positions, count, currentTextMatrix).data(), count, currentTextMatrix.mapPoint(positions[0]), m_smoothingMode)); >+ m_owner.append<DrawGlyphs>(*m_originalFont, glyphs, computeAdvancesFromPositions(positions, count, currentTextMatrix).data(), count, currentTextMatrix.mapPoint(positions[0]), m_smoothingMode); > > m_owner.concatCTM(inverseCTMFixup); > } >@@ -353,7 +353,7 @@ void DrawGlyphsRecorder::recordDrawImage(CGRenderingStateRef, CGGStateRef gstate > m_owner.scale(FloatSize(1, -1)); > > auto image = BitmapImage::create(cgImage); >- m_owner.appendItemAndUpdateExtent(DrawImage::create(image, rect, {{ }, image->size()}, { ImageOrientation::OriginTopLeft })); >+ m_owner.append<DrawImage>(image, FloatRect(rect), FloatRect {{ }, image->size()}, ImagePaintingOptions { ImageOrientation::OriginTopLeft }); > > // Undo the above y-flip to restore the context. > m_owner.scale(FloatSize(1, -1)); >@@ -363,7 +363,7 @@ void DrawGlyphsRecorder::recordDrawImage(CGRenderingStateRef, CGGStateRef gstate > void DrawGlyphsRecorder::drawGlyphs(const Font& font, const GlyphBuffer& glyphBuffer, unsigned from, unsigned numGlyphs, const FloatPoint& startPoint, FontSmoothingMode smoothingMode) > { > if (m_drawGlyphsDeconstruction == DrawGlyphsDeconstruction::DontDeconstruct) { >- m_owner.appendItemAndUpdateExtent(DrawGlyphs::create(font, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs, startPoint, smoothingMode)); >+ m_owner.append<DrawGlyphs>(font, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs, startPoint, smoothingMode); > return; > } > >diff --git a/Source/WebCore/platform/graphics/displaylists/DisplayListDrawGlyphsRecorderHarfBuzz.cpp b/Source/WebCore/platform/graphics/displaylists/DisplayListDrawGlyphsRecorderHarfBuzz.cpp >index 0bb874432b4e68fbb44a8724929aa0e7ef9fb5bc..b1dd3e0902c2ac945a806cb77033d794fea1f08d 100644 >--- a/Source/WebCore/platform/graphics/displaylists/DisplayListDrawGlyphsRecorderHarfBuzz.cpp >+++ b/Source/WebCore/platform/graphics/displaylists/DisplayListDrawGlyphsRecorderHarfBuzz.cpp >@@ -43,7 +43,7 @@ DrawGlyphsRecorder::DrawGlyphsRecorder(Recorder& owner, DrawGlyphsDeconstruction > > void DrawGlyphsRecorder::drawGlyphs(const Font& font, const GlyphBuffer& glyphBuffer, unsigned from, unsigned numGlyphs, const FloatPoint& startPoint, FontSmoothingMode smoothingMode) > { >- m_owner.appendItemAndUpdateExtent(DrawGlyphs::create(font, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs, startPoint, smoothingMode)); >+ m_owner.append<DrawGlyphs>(font, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs, startPoint, smoothingMode); > } > > } // namespace DisplayList >diff --git a/Source/WebCore/platform/graphics/displaylists/DisplayListDrawGlyphsRecorderWin.cpp b/Source/WebCore/platform/graphics/displaylists/DisplayListDrawGlyphsRecorderWin.cpp >index 0bb874432b4e68fbb44a8724929aa0e7ef9fb5bc..b1dd3e0902c2ac945a806cb77033d794fea1f08d 100644 >--- a/Source/WebCore/platform/graphics/displaylists/DisplayListDrawGlyphsRecorderWin.cpp >+++ b/Source/WebCore/platform/graphics/displaylists/DisplayListDrawGlyphsRecorderWin.cpp >@@ -43,7 +43,7 @@ DrawGlyphsRecorder::DrawGlyphsRecorder(Recorder& owner, DrawGlyphsDeconstruction > > void DrawGlyphsRecorder::drawGlyphs(const Font& font, const GlyphBuffer& glyphBuffer, unsigned from, unsigned numGlyphs, const FloatPoint& startPoint, FontSmoothingMode smoothingMode) > { >- m_owner.appendItemAndUpdateExtent(DrawGlyphs::create(font, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs, startPoint, smoothingMode)); >+ m_owner.append<DrawGlyphs>(font, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs, startPoint, smoothingMode); > } > > } // namespace DisplayList >diff --git a/Source/WebCore/platform/graphics/displaylists/DisplayListDrawingContext.h b/Source/WebCore/platform/graphics/displaylists/DisplayListDrawingContext.h >index 22ed256e80ad293a052069b743088a1351f47cc0..96e4b1eff981e42279d746dc6bb39c8aa528e145 100644 >--- a/Source/WebCore/platform/graphics/displaylists/DisplayListDrawingContext.h >+++ b/Source/WebCore/platform/graphics/displaylists/DisplayListDrawingContext.h >@@ -39,7 +39,7 @@ public: > > GraphicsContext& context() const { return const_cast<DrawingContext&>(*this).m_context; } > WEBCORE_EXPORT Recorder& recorder(); >- DisplayList takeDisplayList() { return WTFMove(m_displayList); } >+ DisplayList takeDisplayList() { return std::exchange(m_displayList, { }); } > DisplayList& displayList() { return m_displayList; } > const DisplayList& displayList() const { return m_displayList; } > const DisplayList* replayedDisplayList() const { return m_replayedDisplayList.get(); } >diff --git a/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.cpp b/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..d214bc1e66f1b5f011e9ab644c78e420c4ebc43a >--- /dev/null >+++ b/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.cpp >@@ -0,0 +1,878 @@ >+/* >+ * Copyright (C) 2020 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "DisplayListItemBuffer.h" >+ >+#include "DisplayListItems.h" >+#include <wtf/FastMalloc.h> >+ >+namespace WebCore { >+namespace DisplayList { >+ >+#if !defined(NDEBUG) || !LOG_DISABLED >+CString ItemHandle::description() const >+{ >+ TextStream ts; >+ ts << *this; >+ return ts.release().utf8(); >+} >+#endif >+ >+void ItemHandle::apply(GraphicsContext& context) >+{ >+ switch (type()) { >+ case ItemType::Save: { >+ get<Save>().apply(context); >+ return; >+ } >+ case ItemType::Restore: { >+ get<Restore>().apply(context); >+ return; >+ } >+ case ItemType::Translate: { >+ get<Translate>().apply(context); >+ return; >+ } >+ case ItemType::Rotate: { >+ get<Rotate>().apply(context); >+ return; >+ } >+ case ItemType::Scale: { >+ get<Scale>().apply(context); >+ return; >+ } >+ case ItemType::ConcatenateCTM: { >+ get<ConcatenateCTM>().apply(context); >+ return; >+ } >+ case ItemType::SetCTM: { >+ get<SetCTM>().apply(context); >+ return; >+ } >+ case ItemType::SetInlineFillGradient: { >+ get<SetInlineFillGradient>().apply(context); >+ return; >+ } >+ case ItemType::SetInlineFillColor: { >+ get<SetInlineFillColor>().apply(context); >+ return; >+ } >+ case ItemType::SetInlineStrokeColor: { >+ get<SetInlineStrokeColor>().apply(context); >+ return; >+ } >+ case ItemType::SetStrokeThickness: { >+ get<SetStrokeThickness>().apply(context); >+ return; >+ } >+ case ItemType::SetState: { >+ get<SetState>().apply(context); >+ return; >+ } >+ case ItemType::SetLineCap: { >+ get<SetLineCap>().apply(context); >+ return; >+ } >+ case ItemType::SetLineDash: { >+ get<SetLineDash>().apply(context); >+ return; >+ } >+ case ItemType::SetLineJoin: { >+ get<SetLineJoin>().apply(context); >+ return; >+ } >+ case ItemType::SetMiterLimit: { >+ get<SetMiterLimit>().apply(context); >+ return; >+ } >+ case ItemType::ClearShadow: { >+ get<ClearShadow>().apply(context); >+ return; >+ } >+ case ItemType::Clip: { >+ get<Clip>().apply(context); >+ return; >+ } >+ case ItemType::ClipOut: { >+ get<ClipOut>().apply(context); >+ return; >+ } >+ case ItemType::ClipOutToPath: { >+ get<ClipOutToPath>().apply(context); >+ return; >+ } >+ case ItemType::ClipPath: { >+ get<ClipPath>().apply(context); >+ return; >+ } >+ case ItemType::ClipToDrawingCommands: { >+ get<ClipToDrawingCommands>().apply(context); >+ return; >+ } >+ case ItemType::DrawGlyphs: { >+ get<DrawGlyphs>().apply(context); >+ return; >+ } >+ case ItemType::DrawImage: { >+ get<DrawImage>().apply(context); >+ return; >+ } >+ case ItemType::DrawTiledImage: { >+ get<DrawTiledImage>().apply(context); >+ return; >+ } >+ case ItemType::DrawTiledScaledImage: { >+ get<DrawTiledScaledImage>().apply(context); >+ return; >+ } >+ case ItemType::DrawImageBuffer: { >+ get<DrawImageBuffer>().apply(context); >+ return; >+ } >+ case ItemType::DrawNativeImage: { >+ get<DrawNativeImage>().apply(context); >+ return; >+ } >+ case ItemType::DrawPattern: { >+ get<DrawPattern>().apply(context); >+ return; >+ } >+ case ItemType::DrawRect: { >+ get<DrawRect>().apply(context); >+ return; >+ } >+ case ItemType::DrawLine: { >+ get<DrawLine>().apply(context); >+ return; >+ } >+ case ItemType::DrawLinesForText: { >+ get<DrawLinesForText>().apply(context); >+ return; >+ } >+ case ItemType::DrawDotsForDocumentMarker: { >+ get<DrawDotsForDocumentMarker>().apply(context); >+ return; >+ } >+ case ItemType::DrawEllipse: { >+ get<DrawEllipse>().apply(context); >+ return; >+ } >+ case ItemType::DrawPath: { >+ get<DrawPath>().apply(context); >+ return; >+ } >+ case ItemType::DrawFocusRingPath: { >+ get<DrawFocusRingPath>().apply(context); >+ return; >+ } >+ case ItemType::DrawFocusRingRects: { >+ get<DrawFocusRingRects>().apply(context); >+ return; >+ } >+ case ItemType::FillRect: { >+ get<FillRect>().apply(context); >+ return; >+ } >+ case ItemType::FillRectWithColor: { >+ get<FillRectWithColor>().apply(context); >+ return; >+ } >+ case ItemType::FillRectWithGradient: { >+ get<FillRectWithGradient>().apply(context); >+ return; >+ } >+ case ItemType::FillCompositedRect: { >+ get<FillCompositedRect>().apply(context); >+ return; >+ } >+ case ItemType::FillRoundedRect: { >+ get<FillRoundedRect>().apply(context); >+ return; >+ } >+ case ItemType::FillRectWithRoundedHole: { >+ get<FillRectWithRoundedHole>().apply(context); >+ return; >+ } >+#if ENABLE(INLINE_PATH_DATA) >+ case ItemType::FillInlinePath: { >+ get<FillInlinePath>().apply(context); >+ return; >+ } >+#endif >+ case ItemType::FillPath: { >+ get<FillPath>().apply(context); >+ return; >+ } >+ case ItemType::FillEllipse: { >+ get<FillEllipse>().apply(context); >+ return; >+ } >+ case ItemType::PutImageData: { >+ get<PutImageData>().apply(context); >+ return; >+ } >+ case ItemType::PaintFrameForMedia: { >+ get<PaintFrameForMedia>().apply(context); >+ return; >+ } >+ case ItemType::StrokeRect: { >+ get<StrokeRect>().apply(context); >+ return; >+ } >+#if ENABLE(INLINE_PATH_DATA) >+ case ItemType::StrokeInlinePath: { >+ get<StrokeInlinePath>().apply(context); >+ return; >+ } >+#endif >+ case ItemType::StrokePath: { >+ get<StrokePath>().apply(context); >+ return; >+ } >+ case ItemType::StrokeEllipse: { >+ get<StrokeEllipse>().apply(context); >+ return; >+ } >+ case ItemType::ClearRect: { >+ get<ClearRect>().apply(context); >+ return; >+ } >+ case ItemType::BeginTransparencyLayer: { >+ get<BeginTransparencyLayer>().apply(context); >+ return; >+ } >+ case ItemType::EndTransparencyLayer: { >+ get<EndTransparencyLayer>().apply(context); >+ return; >+ } >+#if USE(CG) >+ case ItemType::ApplyStrokePattern: { >+ get<ApplyStrokePattern>().apply(context); >+ return; >+ } >+ case ItemType::ApplyFillPattern: { >+ get<ApplyFillPattern>().apply(context); >+ return; >+ } >+#endif >+ case ItemType::ApplyDeviceScaleFactor: { >+ get<ApplyDeviceScaleFactor>().apply(context); >+ return; >+ } >+ } >+} >+ >+void ItemHandle::destroy() >+{ >+ switch (type()) { >+ case ItemType::ClipOutToPath: { >+ get<ClipOutToPath>().~ClipOutToPath(); >+ return; >+ } >+ case ItemType::ClipPath: { >+ get<ClipPath>().~ClipPath(); >+ return; >+ } >+ case ItemType::ClipToDrawingCommands: { >+ get<ClipToDrawingCommands>().~ClipToDrawingCommands(); >+ return; >+ } >+ case ItemType::DrawFocusRingPath: { >+ get<DrawFocusRingPath>().~DrawFocusRingPath(); >+ return; >+ } >+ case ItemType::DrawFocusRingRects: { >+ get<DrawFocusRingRects>().~DrawFocusRingRects(); >+ return; >+ } >+ case ItemType::DrawGlyphs: { >+ get<DrawGlyphs>().~DrawGlyphs(); >+ return; >+ } >+ case ItemType::DrawImage: { >+ get<DrawImage>().~DrawImage(); >+ return; >+ } >+ case ItemType::DrawLinesForText: { >+ get<DrawLinesForText>().~DrawLinesForText(); >+ return; >+ } >+ case ItemType::DrawNativeImage: { >+ get<DrawNativeImage>().~DrawNativeImage(); >+ return; >+ } >+ case ItemType::DrawPath: { >+ get<DrawPath>().~DrawPath(); >+ return; >+ } >+ case ItemType::DrawPattern: { >+ get<DrawPattern>().~DrawPattern(); >+ return; >+ } >+ case ItemType::DrawTiledImage: { >+ get<DrawTiledImage>().~DrawTiledImage(); >+ return; >+ } >+ case ItemType::DrawTiledScaledImage: { >+ get<DrawTiledScaledImage>().~DrawTiledScaledImage(); >+ return; >+ } >+ case ItemType::FillCompositedRect: { >+ get<FillCompositedRect>().~FillCompositedRect(); >+ return; >+ } >+ case ItemType::FillPath: { >+ get<FillPath>().~FillPath(); >+ return; >+ } >+ case ItemType::FillRectWithColor: { >+ get<FillRectWithColor>().~FillRectWithColor(); >+ return; >+ } >+ case ItemType::FillRectWithGradient: { >+ get<FillRectWithGradient>().~FillRectWithGradient(); >+ return; >+ } >+ case ItemType::FillRectWithRoundedHole: { >+ get<FillRectWithRoundedHole>().~FillRectWithRoundedHole(); >+ return; >+ } >+ case ItemType::FillRoundedRect: { >+ get<FillRoundedRect>().~FillRoundedRect(); >+ return; >+ } >+ case ItemType::PutImageData: { >+ get<PutImageData>().~PutImageData(); >+ return; >+ } >+ case ItemType::SetLineDash: { >+ get<SetLineDash>().~SetLineDash(); >+ return; >+ } >+ case ItemType::SetState: { >+ get<SetState>().~SetState(); >+ return; >+ } >+ case ItemType::StrokePath: { >+ get<StrokePath>().~StrokePath(); >+ return; >+ } >+ case ItemType::ApplyDeviceScaleFactor: { >+ static_assert(std::is_trivially_destructible<ApplyDeviceScaleFactor>::value); >+ return; >+ } >+#if USE(CG) >+ case ItemType::ApplyFillPattern: { >+ static_assert(std::is_trivially_destructible<ApplyFillPattern>::value); >+ return; >+ } >+ case ItemType::ApplyStrokePattern: { >+ static_assert(std::is_trivially_destructible<ApplyStrokePattern>::value); >+ return; >+ } >+#endif >+ case ItemType::BeginTransparencyLayer: { >+ static_assert(std::is_trivially_destructible<BeginTransparencyLayer>::value); >+ return; >+ } >+ case ItemType::ClearRect: { >+ static_assert(std::is_trivially_destructible<ClearRect>::value); >+ return; >+ } >+ case ItemType::ClearShadow: { >+ static_assert(std::is_trivially_destructible<ClearShadow>::value); >+ return; >+ } >+ case ItemType::Clip: { >+ static_assert(std::is_trivially_destructible<Clip>::value); >+ return; >+ } >+ case ItemType::ClipOut: { >+ static_assert(std::is_trivially_destructible<ClipOut>::value); >+ return; >+ } >+ case ItemType::ConcatenateCTM: { >+ static_assert(std::is_trivially_destructible<ConcatenateCTM>::value); >+ return; >+ } >+ case ItemType::DrawDotsForDocumentMarker: { >+ static_assert(std::is_trivially_destructible<DrawDotsForDocumentMarker>::value); >+ return; >+ } >+ case ItemType::DrawEllipse: { >+ static_assert(std::is_trivially_destructible<DrawEllipse>::value); >+ return; >+ } >+ case ItemType::DrawImageBuffer: { >+ static_assert(std::is_trivially_destructible<DrawImageBuffer>::value); >+ return; >+ } >+ case ItemType::DrawLine: { >+ static_assert(std::is_trivially_destructible<DrawLine>::value); >+ return; >+ } >+ case ItemType::DrawRect: { >+ static_assert(std::is_trivially_destructible<DrawRect>::value); >+ return; >+ } >+ case ItemType::EndTransparencyLayer: { >+ static_assert(std::is_trivially_destructible<EndTransparencyLayer>::value); >+ return; >+ } >+ case ItemType::FillEllipse: { >+ static_assert(std::is_trivially_destructible<FillEllipse>::value); >+ return; >+ } >+#if ENABLE(INLINE_PATH_DATA) >+ case ItemType::FillInlinePath: { >+ static_assert(std::is_trivially_destructible<FillInlinePath>::value); >+ return; >+ } >+#endif >+ case ItemType::FillRect: { >+ static_assert(std::is_trivially_destructible<FillRect>::value); >+ return; >+ } >+ case ItemType::PaintFrameForMedia: { >+ static_assert(std::is_trivially_destructible<PaintFrameForMedia>::value); >+ return; >+ } >+ case ItemType::Restore: { >+ static_assert(std::is_trivially_destructible<Restore>::value); >+ return; >+ } >+ case ItemType::Rotate: { >+ static_assert(std::is_trivially_destructible<Rotate>::value); >+ return; >+ } >+ case ItemType::Save: { >+ static_assert(std::is_trivially_destructible<Save>::value); >+ return; >+ } >+ case ItemType::Scale: { >+ static_assert(std::is_trivially_destructible<Scale>::value); >+ return; >+ } >+ case ItemType::SetCTM: { >+ static_assert(std::is_trivially_destructible<SetCTM>::value); >+ return; >+ } >+ case ItemType::SetInlineFillColor: { >+ static_assert(std::is_trivially_destructible<SetInlineFillColor>::value); >+ return; >+ } >+ case ItemType::SetInlineFillGradient: { >+ static_assert(std::is_trivially_destructible<SetInlineFillGradient>::value); >+ return; >+ } >+ case ItemType::SetInlineStrokeColor: { >+ static_assert(std::is_trivially_destructible<SetInlineStrokeColor>::value); >+ return; >+ } >+ case ItemType::SetLineCap: { >+ static_assert(std::is_trivially_destructible<SetLineCap>::value); >+ return; >+ } >+ case ItemType::SetLineJoin: { >+ static_assert(std::is_trivially_destructible<SetLineJoin>::value); >+ return; >+ } >+ case ItemType::SetMiterLimit: { >+ static_assert(std::is_trivially_destructible<SetMiterLimit>::value); >+ return; >+ } >+ case ItemType::SetStrokeThickness: { >+ static_assert(std::is_trivially_destructible<SetStrokeThickness>::value); >+ return; >+ } >+ case ItemType::StrokeEllipse: { >+ static_assert(std::is_trivially_destructible<StrokeEllipse>::value); >+ return; >+ } >+#if ENABLE(INLINE_PATH_DATA) >+ case ItemType::StrokeInlinePath: { >+ static_assert(std::is_trivially_destructible<StrokeInlinePath>::value); >+ return; >+ } >+#endif >+ case ItemType::StrokeRect: { >+ static_assert(std::is_trivially_destructible<StrokeRect>::value); >+ return; >+ } >+ case ItemType::Translate: { >+ static_assert(std::is_trivially_destructible<Translate>::value); >+ return; >+ } >+ } >+} >+ >+void ItemHandle::copyTo(ItemHandle destination) const >+{ >+ auto itemType = type(); >+ destination.data[0] = static_cast<uint8_t>(itemType); >+ switch (itemType) { >+ case ItemType::ClipOutToPath: { >+ new (destination.data + sizeof(ItemType)) ClipOutToPath(get<ClipOutToPath>()); >+ return; >+ } >+ case ItemType::ClipPath: { >+ new (destination.data + sizeof(ItemType)) ClipPath(get<ClipPath>()); >+ return; >+ } >+ case ItemType::ClipToDrawingCommands: { >+ new (destination.data + sizeof(ItemType)) ClipToDrawingCommands(get<ClipToDrawingCommands>()); >+ return; >+ } >+ case ItemType::DrawFocusRingPath: { >+ new (destination.data + sizeof(ItemType)) DrawFocusRingPath(get<DrawFocusRingPath>()); >+ return; >+ } >+ case ItemType::DrawFocusRingRects: { >+ new (destination.data + sizeof(ItemType)) DrawFocusRingRects(get<DrawFocusRingRects>()); >+ return; >+ } >+ case ItemType::DrawGlyphs: { >+ new (destination.data + sizeof(ItemType)) DrawGlyphs(get<DrawGlyphs>()); >+ return; >+ } >+ case ItemType::DrawImage: { >+ new (destination.data + sizeof(ItemType)) DrawImage(get<DrawImage>()); >+ return; >+ } >+ case ItemType::DrawImageBuffer: { >+ new (destination.data + sizeof(ItemType)) DrawImageBuffer(get<DrawImageBuffer>()); >+ return; >+ } >+ case ItemType::DrawLinesForText: { >+ new (destination.data + sizeof(ItemType)) DrawLinesForText(get<DrawLinesForText>()); >+ return; >+ } >+ case ItemType::DrawNativeImage: { >+ new (destination.data + sizeof(ItemType)) DrawNativeImage(get<DrawNativeImage>()); >+ return; >+ } >+ case ItemType::DrawPath: { >+ new (destination.data + sizeof(ItemType)) DrawPath(get<DrawPath>()); >+ return; >+ } >+ case ItemType::DrawPattern: { >+ new (destination.data + sizeof(ItemType)) DrawPattern(get<DrawPattern>()); >+ return; >+ } >+ case ItemType::DrawTiledImage: { >+ new (destination.data + sizeof(ItemType)) DrawTiledImage(get<DrawTiledImage>()); >+ return; >+ } >+ case ItemType::DrawTiledScaledImage: { >+ new (destination.data + sizeof(ItemType)) DrawTiledScaledImage(get<DrawTiledScaledImage>()); >+ return; >+ } >+ case ItemType::FillCompositedRect: { >+ new (destination.data + sizeof(ItemType)) FillCompositedRect(get<FillCompositedRect>()); >+ return; >+ } >+ case ItemType::FillPath: { >+ new (destination.data + sizeof(ItemType)) FillPath(get<FillPath>()); >+ return; >+ } >+ case ItemType::FillRectWithColor: { >+ new (destination.data + sizeof(ItemType)) FillRectWithColor(get<FillRectWithColor>()); >+ return; >+ } >+ case ItemType::FillRectWithGradient: { >+ new (destination.data + sizeof(ItemType)) FillRectWithGradient(get<FillRectWithGradient>()); >+ return; >+ } >+ case ItemType::FillRectWithRoundedHole: { >+ new (destination.data + sizeof(ItemType)) FillRectWithRoundedHole(get<FillRectWithRoundedHole>()); >+ return; >+ } >+ case ItemType::FillRoundedRect: { >+ new (destination.data + sizeof(ItemType)) FillRoundedRect(get<FillRoundedRect>()); >+ return; >+ } >+ case ItemType::PutImageData: { >+ new (destination.data + sizeof(ItemType)) PutImageData(get<PutImageData>()); >+ return; >+ } >+ case ItemType::SetLineDash: { >+ new (destination.data + sizeof(ItemType)) SetLineDash(get<SetLineDash>()); >+ return; >+ } >+ case ItemType::SetState: { >+ new (destination.data + sizeof(ItemType)) SetState(get<SetState>()); >+ return; >+ } >+ case ItemType::StrokePath: { >+ new (destination.data + sizeof(ItemType)) StrokePath(get<StrokePath>()); >+ return; >+ } >+ case ItemType::ApplyDeviceScaleFactor: { >+ new (destination.data + sizeof(ItemType)) ApplyDeviceScaleFactor(get<ApplyDeviceScaleFactor>()); >+ return; >+ } >+#if USE(CG) >+ case ItemType::ApplyFillPattern: { >+ new (destination.data + sizeof(ItemType)) ApplyFillPattern(get<ApplyFillPattern>()); >+ return; >+ } >+ case ItemType::ApplyStrokePattern: { >+ new (destination.data + sizeof(ItemType)) ApplyStrokePattern(get<ApplyStrokePattern>()); >+ return; >+ } >+#endif >+ case ItemType::BeginTransparencyLayer: { >+ new (destination.data + sizeof(ItemType)) BeginTransparencyLayer(get<BeginTransparencyLayer>()); >+ return; >+ } >+ case ItemType::ClearRect: { >+ new (destination.data + sizeof(ItemType)) ClearRect(get<ClearRect>()); >+ return; >+ } >+ case ItemType::ClearShadow: { >+ new (destination.data + sizeof(ItemType)) ClearShadow(get<ClearShadow>()); >+ return; >+ } >+ case ItemType::Clip: { >+ new (destination.data + sizeof(ItemType)) Clip(get<Clip>()); >+ return; >+ } >+ case ItemType::ClipOut: { >+ new (destination.data + sizeof(ItemType)) ClipOut(get<ClipOut>()); >+ return; >+ } >+ case ItemType::ConcatenateCTM: { >+ new (destination.data + sizeof(ItemType)) ConcatenateCTM(get<ConcatenateCTM>()); >+ return; >+ } >+ case ItemType::DrawDotsForDocumentMarker: { >+ new (destination.data + sizeof(ItemType)) DrawDotsForDocumentMarker(get<DrawDotsForDocumentMarker>()); >+ return; >+ } >+ case ItemType::DrawEllipse: { >+ new (destination.data + sizeof(ItemType)) DrawEllipse(get<DrawEllipse>()); >+ return; >+ } >+ case ItemType::DrawLine: { >+ new (destination.data + sizeof(ItemType)) DrawLine(get<DrawLine>()); >+ return; >+ } >+ case ItemType::DrawRect: { >+ new (destination.data + sizeof(ItemType)) DrawRect(get<DrawRect>()); >+ return; >+ } >+ case ItemType::EndTransparencyLayer: { >+ new (destination.data + sizeof(ItemType)) EndTransparencyLayer(get<EndTransparencyLayer>()); >+ return; >+ } >+ case ItemType::FillEllipse: { >+ new (destination.data + sizeof(ItemType)) FillEllipse(get<FillEllipse>()); >+ return; >+ } >+#if ENABLE(INLINE_PATH_DATA) >+ case ItemType::FillInlinePath: { >+ new (destination.data + sizeof(ItemType)) FillInlinePath(get<FillInlinePath>()); >+ return; >+ } >+#endif >+ case ItemType::FillRect: { >+ new (destination.data + sizeof(ItemType)) FillRect(get<FillRect>()); >+ return; >+ } >+ case ItemType::PaintFrameForMedia: { >+ new (destination.data + sizeof(ItemType)) PaintFrameForMedia(get<PaintFrameForMedia>()); >+ return; >+ } >+ case ItemType::Restore: { >+ new (destination.data + sizeof(ItemType)) Restore(get<Restore>()); >+ return; >+ } >+ case ItemType::Rotate: { >+ new (destination.data + sizeof(ItemType)) Rotate(get<Rotate>()); >+ return; >+ } >+ case ItemType::Save: { >+ new (destination.data + sizeof(ItemType)) Save(get<Save>()); >+ return; >+ } >+ case ItemType::Scale: { >+ new (destination.data + sizeof(ItemType)) Scale(get<Scale>()); >+ return; >+ } >+ case ItemType::SetCTM: { >+ new (destination.data + sizeof(ItemType)) SetCTM(get<SetCTM>()); >+ return; >+ } >+ case ItemType::SetInlineFillColor: { >+ new (destination.data + sizeof(ItemType)) SetInlineFillColor(get<SetInlineFillColor>()); >+ return; >+ } >+ case ItemType::SetInlineFillGradient: { >+ new (destination.data + sizeof(ItemType)) SetInlineFillGradient(get<SetInlineFillGradient>()); >+ return; >+ } >+ case ItemType::SetInlineStrokeColor: { >+ new (destination.data + sizeof(ItemType)) SetInlineStrokeColor(get<SetInlineStrokeColor>()); >+ return; >+ } >+ case ItemType::SetLineCap: { >+ new (destination.data + sizeof(ItemType)) SetLineCap(get<SetLineCap>()); >+ return; >+ } >+ case ItemType::SetLineJoin: { >+ new (destination.data + sizeof(ItemType)) SetLineJoin(get<SetLineJoin>()); >+ return; >+ } >+ case ItemType::SetMiterLimit: { >+ new (destination.data + sizeof(ItemType)) SetMiterLimit(get<SetMiterLimit>()); >+ return; >+ } >+ case ItemType::SetStrokeThickness: { >+ new (destination.data + sizeof(ItemType)) SetStrokeThickness(get<SetStrokeThickness>()); >+ return; >+ } >+ case ItemType::StrokeEllipse: { >+ new (destination.data + sizeof(ItemType)) StrokeEllipse(get<StrokeEllipse>()); >+ return; >+ } >+#if ENABLE(INLINE_PATH_DATA) >+ case ItemType::StrokeInlinePath: { >+ new (destination.data + sizeof(ItemType)) StrokeInlinePath(get<StrokeInlinePath>()); >+ return; >+ } >+#endif >+ case ItemType::StrokeRect: { >+ new (destination.data + sizeof(ItemType)) StrokeRect(get<StrokeRect>()); >+ return; >+ } >+ case ItemType::Translate: { >+ new (destination.data + sizeof(ItemType)) Translate(get<Translate>()); >+ return; >+ } >+ } >+} >+ >+ItemBuffer::ItemBuffer(ItemBufferHandles&& handles) >+ : m_readOnlyBuffers(WTFMove(handles)) >+{ >+} >+ >+ItemBuffer::ItemBuffer() = default; >+ >+ItemBuffer::~ItemBuffer() >+{ >+ clear(); >+} >+ >+ItemBuffer::ItemBuffer(ItemBuffer&& other) >+ : m_readingClient(std::exchange(other.m_readingClient, nullptr)) >+ , m_writingClient(std::exchange(other.m_writingClient, nullptr)) >+ , m_itemsToDestroyInAllocatedBuffers(std::exchange(other.m_itemsToDestroyInAllocatedBuffers, { })) >+ , m_allocatedBuffers(std::exchange(other.m_allocatedBuffers, { })) >+ , m_readOnlyBuffers(std::exchange(other.m_readOnlyBuffers, { })) >+ , m_writableBuffer(std::exchange(other.m_writableBuffer, { })) >+ , m_writtenNumberOfBytes(std::exchange(other.m_writtenNumberOfBytes, 0)) >+{ >+} >+ >+ItemBuffer& ItemBuffer::operator=(ItemBuffer&& other) >+{ >+ m_readingClient = std::exchange(other.m_readingClient, nullptr); >+ m_writingClient = std::exchange(other.m_writingClient, nullptr); >+ m_itemsToDestroyInAllocatedBuffers = std::exchange(other.m_itemsToDestroyInAllocatedBuffers, { }); >+ m_allocatedBuffers = std::exchange(other.m_allocatedBuffers, { }); >+ m_readOnlyBuffers = std::exchange(other.m_readOnlyBuffers, { }); >+ m_writableBuffer = std::exchange(other.m_writableBuffer, { }); >+ m_writtenNumberOfBytes = std::exchange(other.m_writtenNumberOfBytes, 0); >+ return *this; >+} >+ >+ItemBufferHandle ItemBuffer::createItemBuffer(size_t capacity) >+{ >+ if (m_writingClient) { >+ if (auto handle = m_writingClient->createItemBuffer(capacity)) >+ return handle; >+ } >+ >+ constexpr size_t defaultItemBufferCapacity = 1 << 10; >+ >+ auto newBufferCapacity = std::max(capacity, defaultItemBufferCapacity); >+ auto* buffer = reinterpret_cast<uint8_t*>(fastMalloc(newBufferCapacity)); >+ m_allocatedBuffers.append(buffer); >+ return { ItemBufferIdentifier::generate(), buffer, newBufferCapacity }; >+} >+ >+void ItemBuffer::forEachItemBuffer(Function<void(const ItemBufferHandle&)>&& mapFunction) const >+{ >+ for (auto& handle : m_readOnlyBuffers) >+ mapFunction(handle); >+ >+ if (m_writableBuffer && m_writtenNumberOfBytes) >+ mapFunction({ m_writableBuffer.identifier, m_writableBuffer.data, m_writtenNumberOfBytes }); >+} >+ >+void ItemBuffer::clear() >+{ >+ for (auto item : std::exchange(m_itemsToDestroyInAllocatedBuffers, { })) >+ item.destroy(); >+ >+ for (auto* buffer : std::exchange(m_allocatedBuffers, { })) >+ fastFree(buffer); >+ >+ m_readOnlyBuffers.clear(); >+ m_writableBuffer = { }; >+ m_writtenNumberOfBytes = 0; >+} >+ >+void ItemBuffer::swapWritableBufferIfNeeded(size_t numberOfBytes) >+{ >+ if (m_writtenNumberOfBytes + numberOfBytes <= m_writableBuffer.capacity) >+ return; >+ >+ auto nextBuffer = createItemBuffer(numberOfBytes); >+ bool hadPreviousBuffer = m_writableBuffer; >+ auto previousBuffer = std::exchange(m_writableBuffer, { }); >+ previousBuffer.capacity = std::exchange(m_writtenNumberOfBytes, 0); >+ if (hadPreviousBuffer) >+ m_readOnlyBuffers.append(WTFMove(previousBuffer)); >+ >+ m_writableBuffer = WTFMove(nextBuffer); >+} >+ >+void ItemBuffer::appendDataAndLength(Ref<SharedBuffer>&& data, uint8_t* location) >+{ >+ reinterpret_cast<size_t*>(location)[0] = data->size(); >+ >+ auto* startOfPadding = location + sizeof(size_t); >+ size_t padding = (alignof(uint64_t) - reinterpret_cast<uintptr_t>(startOfPadding) % alignof(uint64_t)) % alignof(uint64_t); >+ auto* startOfData = startOfPadding + padding; >+ memcpy(startOfData, data->dataAsUInt8Ptr(), data->size()); >+ >+ m_writtenNumberOfBytes += sizeof(ItemType) + sizeof(size_t) + padding + data->size(); >+} >+ >+} // namespace DisplayList >+} // namespace WebCore >diff --git a/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.h b/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.h >new file mode 100644 >index 0000000000000000000000000000000000000000..7b482e0e8b3a47e05b1c836d66e3dc6728ccf4d6 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.h >@@ -0,0 +1,197 @@ >+/* >+ * Copyright (C) 2020 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include "DisplayListItemType.h" >+#include "SharedBuffer.h" >+#include <wtf/FastMalloc.h> >+#include <wtf/ObjectIdentifier.h> >+ >+namespace WebCore { >+ >+class GraphicsContext; >+ >+namespace DisplayList { >+ >+class DisplayList; >+ >+enum ItemBufferIdentifierType { }; >+using ItemBufferIdentifier = ObjectIdentifier<ItemBufferIdentifierType>; >+ >+// An ItemBufferHandle wraps a pointer to a buffer that contains display list item data. >+struct ItemBufferHandle { >+ ItemBufferIdentifier identifier; >+ uint8_t* data { nullptr }; >+ size_t capacity { 0 }; >+ >+ operator bool() const { return !!(*this); } >+ bool operator!() const { return !data; } >+}; >+ >+using ItemBufferHandles = Vector<ItemBufferHandle, 2>; >+ >+// An ItemHandle wraps a pointer to an ItemType, followed immediately by an item of that type. >+struct ItemHandle { >+ uint8_t* data { nullptr }; >+ >+ void apply(GraphicsContext&); >+ void destroy(); >+ bool isDrawingItem() const { return WebCore::DisplayList::isDrawingItem(type()); } >+ >+ operator bool() const { return !!(*this); } >+ bool operator!() const { return !data; } >+ >+#if !defined(NDEBUG) || !LOG_DISABLED >+ CString description() const; >+#endif >+ >+ ItemType type() const { return static_cast<ItemType>(data[0]); } >+ size_t size() const { return sizeof(ItemType) + sizeOfItemInBytes(type()); } >+ >+ template<typename T> bool is() const { return type() == T::itemType; } >+ template<typename T> T& get() const >+ { >+ ASSERT(is<T>()); >+ return *reinterpret_cast<T*>(&data[sizeof(ItemType)]); >+ } >+ >+ void copyTo(ItemHandle destination) const; >+}; >+ >+class ItemBufferWritingClient { >+public: >+ virtual ~ItemBufferWritingClient() { } >+ >+ virtual ItemBufferHandle createItemBuffer(size_t) = 0; >+ virtual RefPtr<SharedBuffer> encodeItem(ItemHandle) const = 0; >+}; >+ >+class ItemBufferReadingClient { >+public: >+ virtual ~ItemBufferReadingClient() { } >+ >+ virtual Optional<ItemHandle> WARN_UNUSED_RETURN decodeItem(const uint8_t* data, size_t dataLength, ItemType, uint8_t* handleLocation) = 0; >+}; >+ >+// An ItemBuffer contains display list item data, and consists of a readwrite ItemBufferHandle (to which display >+// list items are appended) as well as a number of readonly ItemBufferHandles. Items are appended to the readwrite >+// buffer until all available capacity is exhausted, at which point we will move this writable handle to the list >+// of readonly handles. >+class ItemBuffer { >+ WTF_MAKE_NONCOPYABLE(ItemBuffer); WTF_MAKE_FAST_ALLOCATED; >+public: >+ friend class DisplayList; >+ >+ WEBCORE_EXPORT ItemBuffer(); >+ WEBCORE_EXPORT ~ItemBuffer(); >+ ItemBuffer(ItemBufferHandles&&); >+ >+ WEBCORE_EXPORT ItemBuffer(ItemBuffer&&); >+ WEBCORE_EXPORT ItemBuffer& operator=(ItemBuffer&&); >+ >+ size_t sizeInBytes() const >+ { >+ size_t result = 0; >+ for (auto buffer : m_readOnlyBuffers) >+ result += buffer.capacity; >+ result += m_writtenNumberOfBytes; >+ return result; >+ } >+ >+ void clear(); >+ >+ bool isEmpty() const >+ { >+ return !m_writtenNumberOfBytes && m_readOnlyBuffers.isEmpty(); >+ } >+ >+ WEBCORE_EXPORT ItemBufferHandle createItemBuffer(size_t); >+ >+ // ItemBuffer::append<T>(...) appends a display list item of type T to the end of the current >+ // writable buffer handle; if remaining buffer capacity is insufficient to store the item, a >+ // new buffer will be allocated (either by the ItemBufferWritingClient, if set, or by the item >+ // buffer itself if there is no client). Items are placed back-to-back in these item buffers, >+ // with an ItemType separating each item. >+ // >+ // If a writing client is present and requires custom encoding for the given item type T, the >+ // item buffer will ask the client for an opaque SharedBuffer containing encoded data for the >+ // item. This encoded data is then appended to the item buffer, with padding to ensure that >+ // the start of this data is aligned to 8 bytes, if necessary. When consuming encoded item >+ // data, a corresponding ItemBufferReadingClient will be required to convert this encoded data >+ // back into an item of type T. >+ template<typename T, class... Args> void append(Args&&... args) >+ { >+ static_assert(std::is_trivially_destructible<T>::value || !T::isInlineItem); >+ constexpr auto sizeOfTypeAndItem = sizeof(ItemType) + sizeof(T); >+ >+ if (!T::isInlineItem && m_writingClient) { >+ static uint8_t itemBuffer[sizeOfTypeAndItem]; >+ itemBuffer[0] = static_cast<uint8_t>(T::itemType); >+ new (itemBuffer + sizeof(ItemType)) T(std::forward<Args>(args)...); >+ if (auto sharedBuffer = m_writingClient->encodeItem({ itemBuffer })) { >+ swapWritableBufferIfNeeded(sharedBuffer->size() + sizeof(ItemType) + sizeof(size_t) + alignof(uint64_t)); >+ m_writableBuffer.data[m_writtenNumberOfBytes] = static_cast<uint8_t>(T::itemType); >+ appendDataAndLength(sharedBuffer.releaseNonNull(), m_writableBuffer.data + m_writtenNumberOfBytes + sizeof(ItemType)); >+ } >+ return; >+ } >+ >+ swapWritableBufferIfNeeded(sizeOfTypeAndItem); >+ >+ if (!std::is_trivially_destructible<T>::value) >+ m_itemsToDestroyInAllocatedBuffers.append({ &m_writableBuffer.data[m_writtenNumberOfBytes] }); >+ >+ uncheckedAppend<T>(std::forward<Args>(args)...); >+ } >+ >+ void setClient(ItemBufferWritingClient* client) { m_writingClient = client; } >+ void setClient(ItemBufferReadingClient* client) { m_readingClient = client; } >+ >+private: >+ const ItemBufferHandles& readOnlyBuffers() const { return m_readOnlyBuffers; } >+ void forEachItemBuffer(Function<void(const ItemBufferHandle&)>&&) const; >+ >+ WEBCORE_EXPORT void swapWritableBufferIfNeeded(size_t numberOfBytes); >+ WEBCORE_EXPORT void appendDataAndLength(Ref<SharedBuffer>&&, uint8_t*); >+ template<typename T, class... Args> void uncheckedAppend(Args&&... args) >+ { >+ auto* startOfItem = &m_writableBuffer.data[m_writtenNumberOfBytes]; >+ startOfItem[0] = static_cast<uint8_t>(T::itemType); >+ new (startOfItem + sizeof(ItemType)) T(std::forward<Args>(args)...); >+ m_writtenNumberOfBytes += sizeof(ItemType) + sizeOfItemInBytes(T::itemType); >+ } >+ >+ ItemBufferReadingClient* m_readingClient { nullptr }; >+ ItemBufferWritingClient* m_writingClient { nullptr }; >+ Vector<ItemHandle> m_itemsToDestroyInAllocatedBuffers; >+ Vector<uint8_t*> m_allocatedBuffers; >+ ItemBufferHandles m_readOnlyBuffers; >+ ItemBufferHandle m_writableBuffer; >+ size_t m_writtenNumberOfBytes { 0 }; >+}; >+ >+} // namespace DisplayList >+} // namespace WebCore >diff --git a/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp b/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp >index 68770360aee460a585deafc2a456a4857bed5f85..ee9f69968953767e6d4f9834ebb0114bc78765f4 100644 >--- a/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp >+++ b/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp >@@ -44,204 +44,16 @@ namespace DisplayList { > // Should match RenderTheme::platformFocusRingWidth() > static const float platformFocusRingWidth = 3; > >-#if !defined(NDEBUG) || !LOG_DISABLED >-WTF::CString Item::description() const >-{ >- TextStream ts; >- ts << *this; >- return ts.release().utf8(); >-} >-#endif >- >-Item::Item(ItemType type) >- : m_type(type) >-{ >-} >- >-Item::~Item() = default; >- >-size_t Item::sizeInBytes(const Item& item) >-{ >- switch (item.type()) { >- case ItemType::Save: >- return sizeof(downcast<Save>(item)); >- case ItemType::Restore: >- return sizeof(downcast<Restore>(item)); >- case ItemType::Translate: >- return sizeof(downcast<Translate>(item)); >- case ItemType::Rotate: >- return sizeof(downcast<Rotate>(item)); >- case ItemType::Scale: >- return sizeof(downcast<Scale>(item)); >- case ItemType::SetCTM: >- return sizeof(downcast<SetCTM>(item)); >- case ItemType::ConcatenateCTM: >- return sizeof(downcast<ConcatenateCTM>(item)); >- case ItemType::SetInlineFillGradient: >- return sizeof(downcast<SetInlineFillGradient>(item)); >- case ItemType::SetInlineFillColor: >- return sizeof(downcast<SetInlineFillColor>(item)); >- case ItemType::SetInlineStrokeColor: >- return sizeof(downcast<SetInlineStrokeColor>(item)); >- case ItemType::SetStrokeThickness: >- return sizeof(downcast<SetStrokeThickness>(item)); >- case ItemType::SetState: >- return sizeof(downcast<SetState>(item)); >- case ItemType::SetLineCap: >- return sizeof(downcast<SetLineCap>(item)); >- case ItemType::SetLineDash: >- return sizeof(downcast<SetLineDash>(item)); >- case ItemType::SetLineJoin: >- return sizeof(downcast<SetLineJoin>(item)); >- case ItemType::SetMiterLimit: >- return sizeof(downcast<SetMiterLimit>(item)); >- case ItemType::ClearShadow: >- return sizeof(downcast<ClearShadow>(item)); >- case ItemType::Clip: >- return sizeof(downcast<Clip>(item)); >- case ItemType::ClipOut: >- return sizeof(downcast<ClipOut>(item)); >- case ItemType::ClipOutToPath: >- return sizeof(downcast<ClipOutToPath>(item)); >- case ItemType::ClipPath: >- return sizeof(downcast<ClipPath>(item)); >- case ItemType::ClipToDrawingCommands: >- return sizeof(downcast<ClipToDrawingCommands>(item)); >- case ItemType::DrawGlyphs: >- return sizeof(downcast<DrawGlyphs>(item)); >- case ItemType::DrawImage: >- return sizeof(downcast<DrawImage>(item)); >- case ItemType::DrawTiledImage: >- return sizeof(downcast<DrawTiledImage>(item)); >- case ItemType::DrawTiledScaledImage: >- return sizeof(downcast<DrawTiledScaledImage>(item)); >- case ItemType::DrawImageBuffer: >- return sizeof(downcast<DrawImageBuffer>(item)); >- case ItemType::DrawNativeImage: >- return sizeof(downcast<DrawNativeImage>(item)); >- case ItemType::DrawPattern: >- return sizeof(downcast<DrawPattern>(item)); >- case ItemType::DrawRect: >- return sizeof(downcast<DrawRect>(item)); >- case ItemType::DrawLine: >- return sizeof(downcast<DrawLine>(item)); >- case ItemType::DrawLinesForText: >- return sizeof(downcast<DrawLinesForText>(item)); >- case ItemType::DrawDotsForDocumentMarker: >- return sizeof(downcast<DrawDotsForDocumentMarker>(item)); >- case ItemType::DrawEllipse: >- return sizeof(downcast<DrawEllipse>(item)); >- case ItemType::DrawPath: >- return sizeof(downcast<DrawPath>(item)); >- case ItemType::DrawFocusRingPath: >- return sizeof(downcast<DrawFocusRingPath>(item)); >- case ItemType::DrawFocusRingRects: >- return sizeof(downcast<DrawFocusRingRects>(item)); >- case ItemType::FillRect: >- return sizeof(downcast<FillRect>(item)); >- case ItemType::FillRectWithColor: >- return sizeof(downcast<FillRectWithColor>(item)); >- case ItemType::FillRectWithGradient: >- return sizeof(downcast<FillRectWithGradient>(item)); >- case ItemType::FillCompositedRect: >- return sizeof(downcast<FillCompositedRect>(item)); >- case ItemType::FillRoundedRect: >- return sizeof(downcast<FillRoundedRect>(item)); >- case ItemType::FillRectWithRoundedHole: >- return sizeof(downcast<FillRectWithRoundedHole>(item)); >-#if ENABLE(INLINE_PATH_DATA) >- case ItemType::FillInlinePath: >- return sizeof(downcast<FillInlinePath>(item)); >-#endif >- case ItemType::FillPath: >- return sizeof(downcast<FillPath>(item)); >- case ItemType::FillEllipse: >- return sizeof(downcast<FillEllipse>(item)); >- case ItemType::PutImageData: >- return sizeof(downcast<PutImageData>(item)); >- case ItemType::PaintFrameForMedia: >- return sizeof(downcast<PaintFrameForMedia>(item)); >- case ItemType::StrokeRect: >- return sizeof(downcast<StrokeRect>(item)); >-#if ENABLE(INLINE_PATH_DATA) >- case ItemType::StrokeInlinePath: >- return sizeof(downcast<StrokeInlinePath>(item)); >-#endif >- case ItemType::StrokePath: >- return sizeof(downcast<StrokePath>(item)); >- case ItemType::StrokeEllipse: >- return sizeof(downcast<StrokeEllipse>(item)); >- case ItemType::ClearRect: >- return sizeof(downcast<ClearRect>(item)); >- case ItemType::BeginTransparencyLayer: >- return sizeof(downcast<BeginTransparencyLayer>(item)); >- case ItemType::EndTransparencyLayer: >- return sizeof(downcast<EndTransparencyLayer>(item)); >-#if USE(CG) >- case ItemType::ApplyStrokePattern: >- return sizeof(downcast<ApplyStrokePattern>(item)); >- case ItemType::ApplyFillPattern: >- return sizeof(downcast<ApplyFillPattern>(item)); >-#endif >- case ItemType::ApplyDeviceScaleFactor: >- return sizeof(downcast<ApplyDeviceScaleFactor>(item)); >- } >- return 0; >-} >- >-static TextStream& operator<<(TextStream& ts, const DrawingItem& item) >-{ >- ts.startGroup(); >- ts << "extent "; >- if (item.extentKnown()) >- ts << item.extent(); >- else >- ts << "unknown"; >- >- ts.endGroup(); >- return ts; >-} >- >-DrawingItem::DrawingItem(ItemType type) >- : Item(type) >-{ >-} >- >-DrawingItem::~DrawingItem() = default; >- >-Save::Save() >- : Item(ItemType::Save) >-{ >-} >- >-Save::~Save() = default; >- > void Save::apply(GraphicsContext& context) const > { > context.save(); > } > >-Restore::Restore() >- : Item(ItemType::Restore) >-{ >-} >- >-Restore::~Restore() = default; >- > void Restore::apply(GraphicsContext& context) const > { > context.restore(); > } > >-Translate::Translate(float x, float y) >- : Item(ItemType::Translate) >- , m_x(x) >- , m_y(y) >-{ >-} >- >-Translate::~Translate() = default; >- > void Translate::apply(GraphicsContext& context) const > { > context.translate(m_x, m_y); >@@ -255,14 +67,6 @@ static TextStream& operator<<(TextStream& ts, const Translate& item) > return ts; > } > >-Rotate::Rotate(float angle) >- : Item(ItemType::Rotate) >- , m_angle(angle) >-{ >-} >- >-Rotate::~Rotate() = default; >- > void Rotate::apply(GraphicsContext& context) const > { > context.rotate(m_angle); >@@ -275,14 +79,6 @@ static TextStream& operator<<(TextStream& ts, const Rotate& item) > return ts; > } > >-Scale::Scale(const FloatSize& size) >- : Item(ItemType::Scale) >- , m_size(size) >-{ >-} >- >-Scale::~Scale() = default; >- > void Scale::apply(GraphicsContext& context) const > { > context.scale(m_size); >@@ -295,14 +91,6 @@ static TextStream& operator<<(TextStream& ts, const Scale& item) > return ts; > } > >-SetCTM::SetCTM(const AffineTransform& transform) >- : Item(ItemType::SetCTM) >- , m_transform(transform) >-{ >-} >- >-SetCTM::~SetCTM() = default; >- > void SetCTM::apply(GraphicsContext& context) const > { > context.setCTM(m_transform); >@@ -315,14 +103,6 @@ static TextStream& operator<<(TextStream& ts, const SetCTM& item) > return ts; > } > >-ConcatenateCTM::ConcatenateCTM(const AffineTransform& transform) >- : Item(ItemType::ConcatenateCTM) >- , m_transform(transform) >-{ >-} >- >-ConcatenateCTM::~ConcatenateCTM() = default; >- > void ConcatenateCTM::apply(GraphicsContext& context) const > { > context.concatCTM(m_transform); >@@ -336,8 +116,7 @@ static TextStream& operator<<(TextStream& ts, const ConcatenateCTM& item) > } > > SetInlineFillGradient::SetInlineFillGradient(const Gradient& gradient) >- : Item(ItemType::SetInlineFillGradient) >- , m_data(gradient.data()) >+ : m_data(gradient.data()) > , m_gradientSpaceTransformation(gradient.gradientSpaceTransform()) > , m_spreadMethod(gradient.spreadMethod()) > , m_colorStopCount(static_cast<uint8_t>(gradient.stops().size())) >@@ -359,14 +138,8 @@ Ref<Gradient> SetInlineFillGradient::gradient() const > return gradient; > } > >-Ref<SetInlineFillGradient> SetInlineFillGradient::create(const Gradient& gradient) >-{ >- return adoptRef(*new SetInlineFillGradient(gradient)); >-} >- > SetInlineFillGradient::SetInlineFillGradient(float offsets[maxColorStopCount], SRGBA<uint8_t> colors[maxColorStopCount], const Gradient::Data& data, const AffineTransform& gradientSpaceTransformation, GradientSpreadMethod spreadMethod, uint8_t colorStopCount) >- : Item(ItemType::SetInlineFillGradient) >- , m_data(data) >+ : m_data(data) > , m_gradientSpaceTransformation(gradientSpaceTransformation) > , m_spreadMethod(spreadMethod) > , m_colorStopCount(colorStopCount) >@@ -378,8 +151,6 @@ SetInlineFillGradient::SetInlineFillGradient(float offsets[maxColorStopCount], S > } > } > >-SetInlineFillGradient::~SetInlineFillGradient() = default; >- > void SetInlineFillGradient::apply(GraphicsContext& context) const > { > if (m_colorStopCount <= maxColorStopCount) >@@ -405,13 +176,6 @@ static TextStream& operator<<(TextStream& ts, const SetInlineFillGradient&) > return ts; > } > >-Ref<SetInlineFillColor> SetInlineFillColor::create(SRGBA<uint8_t> colorData) >-{ >- return adoptRef(*new SetInlineFillColor(colorData)); >-} >- >-SetInlineFillColor::~SetInlineFillColor() = default; >- > void SetInlineFillColor::apply(GraphicsContext& context) const > { > context.setFillColor(color()); >@@ -423,13 +187,6 @@ static TextStream& operator<<(TextStream& ts, const SetInlineFillColor& state) > return ts; > } > >-Ref<SetInlineStrokeColor> SetInlineStrokeColor::create(SRGBA<uint8_t> colorData) >-{ >- return adoptRef(*new SetInlineStrokeColor(colorData)); >-} >- >-SetInlineStrokeColor::~SetInlineStrokeColor() = default; >- > void SetInlineStrokeColor::apply(GraphicsContext& context) const > { > context.setStrokeColor(color()); >@@ -441,13 +198,6 @@ static TextStream& operator<<(TextStream& ts, const SetInlineStrokeColor& state) > return ts; > } > >-Ref<SetStrokeThickness> SetStrokeThickness::create(float thickness) >-{ >- return adoptRef(*new SetStrokeThickness(thickness)); >-} >- >-SetStrokeThickness::~SetStrokeThickness() = default; >- > void SetStrokeThickness::apply(GraphicsContext& context) const > { > context.setStrokeThickness(m_thickness); >@@ -460,19 +210,15 @@ static TextStream& operator<<(TextStream& ts, const SetStrokeThickness& state) > } > > SetState::SetState(const GraphicsContextState& state, GraphicsContextState::StateChangeFlags flags) >- : Item(ItemType::SetState) >- , m_state(state, flags) >+ : m_state(state, flags) > { > } > > SetState::SetState(const GraphicsContextStateChange& stateChange) >- : Item(ItemType::SetState) >- , m_state(stateChange) >+ : m_state(stateChange) > { > } > >-SetState::~SetState() = default; >- > void SetState::apply(GraphicsContext& context) const > { > m_state.apply(context); >@@ -484,14 +230,6 @@ static TextStream& operator<<(TextStream& ts, const SetState& state) > return ts; > } > >-SetLineCap::SetLineCap(LineCap lineCap) >- : Item(ItemType::SetLineCap) >- , m_lineCap(lineCap) >-{ >-} >- >-SetLineCap::~SetLineCap() = default; >- > void SetLineCap::apply(GraphicsContext& context) const > { > context.setLineCap(m_lineCap); >@@ -503,15 +241,6 @@ static TextStream& operator<<(TextStream& ts, const SetLineCap& lineCap) > return ts; > } > >-SetLineDash::SetLineDash(const DashArray& dashArray, float dashOffset) >- : Item(ItemType::SetLineDash) >- , m_dashArray(dashArray) >- , m_dashOffset(dashOffset) >-{ >-} >- >-SetLineDash::~SetLineDash() = default; >- > void SetLineDash::apply(GraphicsContext& context) const > { > context.setLineDash(m_dashArray, m_dashOffset); >@@ -524,14 +253,6 @@ static TextStream& operator<<(TextStream& ts, const SetLineDash& lineDash) > return ts; > } > >-SetLineJoin::SetLineJoin(LineJoin lineJoin) >- : Item(ItemType::SetLineJoin) >- , m_lineJoin(lineJoin) >-{ >-} >- >-SetLineJoin::~SetLineJoin() = default; >- > void SetLineJoin::apply(GraphicsContext& context) const > { > context.setLineJoin(m_lineJoin); >@@ -543,14 +264,6 @@ static TextStream& operator<<(TextStream& ts, const SetLineJoin& lineJoin) > return ts; > } > >-SetMiterLimit::SetMiterLimit(float miterLimit) >- : Item(ItemType::SetMiterLimit) >- , m_miterLimit(miterLimit) >-{ >-} >- >-SetMiterLimit::~SetMiterLimit() = default; >- > void SetMiterLimit::apply(GraphicsContext& context) const > { > context.setMiterLimit(m_miterLimit); >@@ -562,26 +275,11 @@ static TextStream& operator<<(TextStream& ts, const SetMiterLimit& miterLimit) > return ts; > } > >-ClearShadow::ClearShadow() >- : Item(ItemType::ClearShadow) >-{ >-} >- >-ClearShadow::~ClearShadow() = default; >- > void ClearShadow::apply(GraphicsContext& context) const > { > context.clearShadow(); > } > >-Clip::Clip(const FloatRect& rect) >- : Item(ItemType::Clip) >- , m_rect(rect) >-{ >-} >- >-Clip::~Clip() = default; >- > void Clip::apply(GraphicsContext& context) const > { > context.clip(m_rect); >@@ -593,14 +291,6 @@ static TextStream& operator<<(TextStream& ts, const Clip& item) > return ts; > } > >-ClipOut::ClipOut(const FloatRect& rect) >- : Item(ItemType::ClipOut) >- , m_rect(rect) >-{ >-} >- >-ClipOut::~ClipOut() = default; >- > void ClipOut::apply(GraphicsContext& context) const > { > context.clipOut(m_rect); >@@ -612,14 +302,6 @@ static TextStream& operator<<(TextStream& ts, const ClipOut& item) > return ts; > } > >-ClipOutToPath::ClipOutToPath(const Path& path) >- : Item(ItemType::ClipOutToPath) >- , m_path(path) >-{ >-} >- >-ClipOutToPath::~ClipOutToPath() = default; >- > void ClipOutToPath::apply(GraphicsContext& context) const > { > context.clipOut(m_path); >@@ -631,15 +313,6 @@ static TextStream& operator<<(TextStream& ts, const ClipOutToPath& item) > return ts; > } > >-ClipPath::ClipPath(const Path& path, WindRule windRule) >- : Item(ItemType::ClipPath) >- , m_path(path) >- , m_windRule(windRule) >-{ >-} >- >-ClipPath::~ClipPath() = default; >- > void ClipPath::apply(GraphicsContext& context) const > { > context.clipPath(m_path, m_windRule); >@@ -652,16 +325,6 @@ static TextStream& operator<<(TextStream& ts, const ClipPath& item) > return ts; > } > >-ClipToDrawingCommands::ClipToDrawingCommands(const FloatRect& destination, ColorSpace colorSpace, DisplayList&& drawingCommands) >- : Item(ItemType::ClipToDrawingCommands) >- , m_destination(destination) >- , m_colorSpace(colorSpace) >- , m_drawingCommands(WTFMove(drawingCommands)) >-{ >-} >- >-ClipToDrawingCommands::~ClipToDrawingCommands() = default; >- > void ClipToDrawingCommands::apply(GraphicsContext& context) const > { > context.clipToDrawingCommands(m_destination, m_colorSpace, [&] (GraphicsContext& clippingContext) { >@@ -678,8 +341,7 @@ static TextStream& operator<<(TextStream& ts, const ClipToDrawingCommands& item) > } > > DrawGlyphs::DrawGlyphs(const Font& font, Vector<GlyphBufferGlyph, 128>&& glyphs, Vector<GlyphBufferAdvance, 128>&& advances, const FloatPoint& localAnchor, FontSmoothingMode smoothingMode) >- : DrawingItem(ItemType::DrawGlyphs) >- , m_font(const_cast<Font&>(font)) >+ : m_font(makeRefPtr(const_cast<Font&>(font))) > , m_glyphs(WTFMove(glyphs)) > , m_advances(WTFMove(advances)) > , m_localAnchor(localAnchor) >@@ -689,8 +351,7 @@ DrawGlyphs::DrawGlyphs(const Font& font, Vector<GlyphBufferGlyph, 128>&& glyphs, > } > > DrawGlyphs::DrawGlyphs(const Font& font, const GlyphBufferGlyph* glyphs, const GlyphBufferAdvance* advances, unsigned count, const FloatPoint& localAnchor, FontSmoothingMode smoothingMode) >- : DrawingItem(ItemType::DrawGlyphs) >- , m_font(const_cast<Font&>(font)) >+ : m_font(makeRefPtr(const_cast<Font&>(font))) > , m_localAnchor(localAnchor) > , m_smoothingMode(smoothingMode) > { >@@ -703,19 +364,17 @@ DrawGlyphs::DrawGlyphs(const Font& font, const GlyphBufferGlyph* glyphs, const G > computeBounds(); > } > >-DrawGlyphs::~DrawGlyphs() = default; >- > inline GlyphBuffer DrawGlyphs::generateGlyphBuffer() const > { > GlyphBuffer result; > for (size_t i = 0; i < m_glyphs.size(); ++i) >- result.add(m_glyphs[i], m_font.get(), m_advances[i], GlyphBuffer::noOffset); >+ result.add(m_glyphs[i], *m_font, m_advances[i], GlyphBuffer::noOffset); > return result; > } > > void DrawGlyphs::apply(GraphicsContext& context) const > { >- context.drawGlyphs(m_font, generateGlyphBuffer(), 0, m_glyphs.size(), anchorPoint(), m_smoothingMode); >+ context.drawGlyphs(*m_font, generateGlyphBuffer(), 0, m_glyphs.size(), anchorPoint(), m_smoothingMode); > } > > void DrawGlyphs::computeBounds() >@@ -735,14 +394,8 @@ void DrawGlyphs::computeBounds() > } > } > >-Optional<FloatRect> DrawGlyphs::localBounds(const GraphicsContext&) const >-{ >- return m_bounds; >-} >- > static TextStream& operator<<(TextStream& ts, const DrawGlyphs& item) > { >- ts << static_cast<const DrawingItem&>(item); > // FIXME: dump more stuff. > ts.dumpProperty("local-anchor", item.localAnchor()); > ts.dumpProperty("anchor-point", item.anchorPoint()); >@@ -751,17 +404,6 @@ static TextStream& operator<<(TextStream& ts, const DrawGlyphs& item) > return ts; > } > >-DrawImage::DrawImage(Image& image, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& imagePaintingOptions) >- : DrawingItem(ItemType::DrawImage) >- , m_image(image) >- , m_destination(destination) >- , m_source(source) >- , m_imagePaintingOptions(imagePaintingOptions) >-{ >-} >- >-DrawImage::~DrawImage() = default; >- > void DrawImage::apply(GraphicsContext& context) const > { > context.drawImage(m_image.get(), m_destination, m_source, m_imagePaintingOptions); >@@ -769,26 +411,12 @@ void DrawImage::apply(GraphicsContext& context) const > > static TextStream& operator<<(TextStream& ts, const DrawImage& item) > { >- ts << static_cast<const DrawingItem&>(item); > ts.dumpProperty("image", item.image()); > ts.dumpProperty("source-rect", item.source()); > ts.dumpProperty("dest-rect", item.destination()); > return ts; > } > >-DrawTiledImage::DrawTiledImage(Image& image, const FloatRect& destination, const FloatPoint& source, const FloatSize& tileSize, const FloatSize& spacing, const ImagePaintingOptions& imagePaintingOptions) >- : DrawingItem(ItemType::DrawTiledImage) >- , m_image(image) >- , m_destination(destination) >- , m_source(source) >- , m_tileSize(tileSize) >- , m_spacing(spacing) >- , m_imagePaintingOptions(imagePaintingOptions) >-{ >-} >- >-DrawTiledImage::~DrawTiledImage() = default; >- > void DrawTiledImage::apply(GraphicsContext& context) const > { > context.drawTiledImage(m_image.get(), m_destination, m_source, m_tileSize, m_spacing, m_imagePaintingOptions); >@@ -796,7 +424,6 @@ void DrawTiledImage::apply(GraphicsContext& context) const > > static TextStream& operator<<(TextStream& ts, const DrawTiledImage& item) > { >- ts << static_cast<const DrawingItem&>(item); > ts.dumpProperty("image", item.image()); > ts.dumpProperty("source-point", item.source()); > ts.dumpProperty("dest-rect", item.destination()); >@@ -805,20 +432,6 @@ static TextStream& operator<<(TextStream& ts, const DrawTiledImage& item) > return ts; > } > >-DrawTiledScaledImage::DrawTiledScaledImage(Image& image, const FloatRect& destination, const FloatRect& source, const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRule, const ImagePaintingOptions& imagePaintingOptions) >- : DrawingItem(ItemType::DrawTiledScaledImage) >- , m_image(image) >- , m_destination(destination) >- , m_source(source) >- , m_tileScaleFactor(tileScaleFactor) >- , m_hRule(hRule) >- , m_vRule(vRule) >- , m_imagePaintingOptions(imagePaintingOptions) >-{ >-} >- >-DrawTiledScaledImage::~DrawTiledScaledImage() = default; >- > void DrawTiledScaledImage::apply(GraphicsContext& context) const > { > context.drawTiledImage(m_image.get(), m_destination, m_source, m_tileScaleFactor, m_hRule, m_vRule, m_imagePaintingOptions); >@@ -826,25 +439,12 @@ void DrawTiledScaledImage::apply(GraphicsContext& context) const > > static TextStream& operator<<(TextStream& ts, const DrawTiledScaledImage& item) > { >- ts << static_cast<const DrawingItem&>(item); > ts.dumpProperty("image", item.image()); > ts.dumpProperty("source-rect", item.source()); > ts.dumpProperty("dest-rect", item.destination()); > return ts; > } > >-DrawImageBuffer::DrawImageBuffer(RenderingResourceIdentifier renderingResourceIdentifier, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) >- : DrawingItem(ItemType::DrawImageBuffer) >- , m_renderingResourceIdentifier(renderingResourceIdentifier) >- , m_destinationRect(destRect) >- , m_srcRect(srcRect) >- , m_options(options) >-{ >- ASSERT(m_renderingResourceIdentifier); >-} >- >-DrawImageBuffer::~DrawImageBuffer() = default; >- > void DrawImageBuffer::apply(GraphicsContext&) const > { > ASSERT_NOT_REACHED(); >@@ -857,16 +457,14 @@ void DrawImageBuffer::apply(GraphicsContext& context, WebCore::ImageBuffer& imag > > static TextStream& operator<<(TextStream& ts, const DrawImageBuffer& item) > { >- ts << static_cast<const DrawingItem&>(item); >- ts.dumpProperty("remote-resource-identifier", item.renderingResourceIdentifier()); >+ ts.dumpProperty("rendering-resource-identifier", item.renderingResourceIdentifier()); > ts.dumpProperty("source-rect", item.source()); > ts.dumpProperty("dest-rect", item.destinationRect()); > return ts; > } > > DrawNativeImage::DrawNativeImage(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) >- : DrawingItem(ItemType::DrawNativeImage) >- , m_image(image) >+ : m_image(image) > , m_imageSize(imageSize) > , m_destinationRect(destRect) > , m_srcRect(srcRect) >@@ -874,8 +472,6 @@ DrawNativeImage::DrawNativeImage(const NativeImagePtr& image, const FloatSize& i > { > } > >-DrawNativeImage::~DrawNativeImage() = default; >- > void DrawNativeImage::apply(GraphicsContext& context) const > { > context.drawNativeImage(m_image, m_imageSize, m_destinationRect, m_srcRect, m_options); >@@ -883,7 +479,6 @@ void DrawNativeImage::apply(GraphicsContext& context) const > > static TextStream& operator<<(TextStream& ts, const DrawNativeImage& item) > { >- ts << static_cast<const DrawingItem&>(item); > // FIXME: dump more stuff. > ts.dumpProperty("source-rect", item.source()); > ts.dumpProperty("dest-rect", item.destinationRect()); >@@ -891,8 +486,7 @@ static TextStream& operator<<(TextStream& ts, const DrawNativeImage& item) > } > > DrawPattern::DrawPattern(Image& image, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options) >- : DrawingItem(ItemType::DrawPattern) >- , m_image(image) >+ : m_image(image) > , m_patternTransform(patternTransform) > , m_tileRect(tileRect) > , m_destination(destRect) >@@ -902,8 +496,6 @@ DrawPattern::DrawPattern(Image& image, const FloatRect& destRect, const FloatRec > { > } > >-DrawPattern::~DrawPattern() = default; >- > void DrawPattern::apply(GraphicsContext& context) const > { > context.drawPattern(m_image.get(), m_destination, m_tileRect, m_patternTransform, m_phase, m_spacing, m_options); >@@ -911,7 +503,6 @@ void DrawPattern::apply(GraphicsContext& context) const > > static TextStream& operator<<(TextStream& ts, const DrawPattern& item) > { >- ts << static_cast<const DrawingItem&>(item); > ts.dumpProperty("image", item.image()); > ts.dumpProperty("pattern-transform", item.patternTransform()); > ts.dumpProperty("tile-rect", item.tileRect()); >@@ -921,15 +512,6 @@ static TextStream& operator<<(TextStream& ts, const DrawPattern& item) > return ts; > } > >-DrawRect::DrawRect(const FloatRect& rect, float borderThickness) >- : DrawingItem(ItemType::DrawRect) >- , m_rect(rect) >- , m_borderThickness(borderThickness) >-{ >-} >- >-DrawRect::~DrawRect() = default; >- > void DrawRect::apply(GraphicsContext& context) const > { > context.drawRect(m_rect, m_borderThickness); >@@ -937,21 +519,11 @@ void DrawRect::apply(GraphicsContext& context) const > > static TextStream& operator<<(TextStream& ts, const DrawRect& item) > { >- ts << static_cast<const DrawingItem&>(item); > ts.dumpProperty("rect", item.rect()); > ts.dumpProperty("border-thickness", item.borderThickness()); > return ts; > } > >-DrawLine::DrawLine(const FloatPoint& point1, const FloatPoint& point2) >- : DrawingItem(ItemType::DrawLine) >- , m_point1(point1) >- , m_point2(point2) >-{ >-} >- >-DrawLine::~DrawLine() = default; >- > Optional<FloatRect> DrawLine::localBounds(const GraphicsContext&) const > { > FloatRect bounds; >@@ -966,15 +538,13 @@ void DrawLine::apply(GraphicsContext& context) const > > static TextStream& operator<<(TextStream& ts, const DrawLine& item) > { >- ts << static_cast<const DrawingItem&>(item); > ts.dumpProperty("point-1", item.point1()); > ts.dumpProperty("point-2", item.point2()); > return ts; > } > > DrawLinesForText::DrawLinesForText(const FloatPoint& blockLocation, const FloatSize& localAnchor, float thickness, const DashArray& widths, bool printing, bool doubleLines) >- : DrawingItem(ItemType::DrawLinesForText) >- , m_blockLocation(blockLocation) >+ : m_blockLocation(blockLocation) > , m_localAnchor(localAnchor) > , m_widths(widths) > , m_thickness(thickness) >@@ -983,8 +553,6 @@ DrawLinesForText::DrawLinesForText(const FloatPoint& blockLocation, const FloatS > { > } > >-DrawLinesForText::~DrawLinesForText() = default; >- > void DrawLinesForText::apply(GraphicsContext& context) const > { > context.drawLinesForText(point(), m_thickness, m_widths, m_printing, m_doubleLines); >@@ -1004,7 +572,6 @@ Optional<FloatRect> DrawLinesForText::localBounds(const GraphicsContext&) const > > static TextStream& operator<<(TextStream& ts, const DrawLinesForText& item) > { >- ts << static_cast<const DrawingItem&>(item); > ts.dumpProperty("block-location", item.blockLocation()); > ts.dumpProperty("local-anchor", item.localAnchor()); > ts.dumpProperty("point", item.point()); >@@ -1016,15 +583,6 @@ static TextStream& operator<<(TextStream& ts, const DrawLinesForText& item) > return ts; > } > >-DrawDotsForDocumentMarker::DrawDotsForDocumentMarker(const FloatRect& rect, DocumentMarkerLineStyle style) >- : DrawingItem(ItemType::DrawDotsForDocumentMarker) >- , m_rect(rect) >- , m_style(style) >-{ >-} >- >-DrawDotsForDocumentMarker::~DrawDotsForDocumentMarker() = default; >- > void DrawDotsForDocumentMarker::apply(GraphicsContext& context) const > { > context.drawDotsForDocumentMarker(m_rect, m_style); >@@ -1037,19 +595,10 @@ Optional<FloatRect> DrawDotsForDocumentMarker::localBounds(const GraphicsContext > > static TextStream& operator<<(TextStream& ts, const DrawDotsForDocumentMarker& item) > { >- ts << static_cast<const DrawingItem&>(item); > ts.dumpProperty("rect", item.rect()); > return ts; > } > >-DrawEllipse::DrawEllipse(const FloatRect& rect) >- : DrawingItem(ItemType::DrawEllipse) >- , m_rect(rect) >-{ >-} >- >-DrawEllipse::~DrawEllipse() = default; >- > void DrawEllipse::apply(GraphicsContext& context) const > { > context.drawEllipse(m_rect); >@@ -1061,14 +610,6 @@ static TextStream& operator<<(TextStream& ts, const DrawEllipse& item) > return ts; > } > >-DrawPath::DrawPath(const Path& path) >- : DrawingItem(ItemType::DrawPath) >- , m_path(path) >-{ >-} >- >-DrawPath::~DrawPath() = default; >- > void DrawPath::apply(GraphicsContext& context) const > { > #if USE(CG) >@@ -1078,24 +619,12 @@ void DrawPath::apply(GraphicsContext& context) const > #endif > } > >-static TextStream& operator<<(TextStream& ts, const DrawPath& item) >+static TextStream& operator<<(TextStream& ts, const DrawPath&) > { >- ts << static_cast<const DrawingItem&>(item); >-// ts.dumpProperty("path", item.path()); // FIXME: add logging for paths. >+ // FIXME: add logging for paths. > return ts; > } > >-DrawFocusRingPath::DrawFocusRingPath(const Path& path, float width, float offset, const Color& color) >- : DrawingItem(ItemType::DrawFocusRingPath) >- , m_path(path) >- , m_width(width) >- , m_offset(offset) >- , m_color(color) >-{ >-} >- >-DrawFocusRingPath::~DrawFocusRingPath() = default; >- > void DrawFocusRingPath::apply(GraphicsContext& context) const > { > context.drawFocusRing(m_path, m_width, m_offset, m_color); >@@ -1110,7 +639,6 @@ Optional<FloatRect> DrawFocusRingPath::localBounds(const GraphicsContext&) const > > static TextStream& operator<<(TextStream& ts, const DrawFocusRingPath& item) > { >- ts << static_cast<const DrawingItem&>(item); > // ts.dumpProperty("path", item.path()); // FIXME: add logging for paths. > ts.dumpProperty("width", item.width()); > ts.dumpProperty("offset", item.offset()); >@@ -1119,16 +647,13 @@ static TextStream& operator<<(TextStream& ts, const DrawFocusRingPath& item) > } > > DrawFocusRingRects::DrawFocusRingRects(const Vector<FloatRect>& rects, float width, float offset, const Color& color) >- : DrawingItem(ItemType::DrawFocusRingRects) >- , m_rects(rects) >+ : m_rects(rects) > , m_width(width) > , m_offset(offset) > , m_color(color) > { > } > >-DrawFocusRingRects::~DrawFocusRingRects() = default; >- > void DrawFocusRingRects::apply(GraphicsContext& context) const > { > context.drawFocusRing(m_rects, m_width, m_offset, m_color); >@@ -1145,7 +670,6 @@ Optional<FloatRect> DrawFocusRingRects::localBounds(const GraphicsContext&) cons > > static TextStream& operator<<(TextStream& ts, const DrawFocusRingRects& item) > { >- ts << static_cast<const DrawingItem&>(item); > ts.dumpProperty("rects", item.rects()); > ts.dumpProperty("width", item.width()); > ts.dumpProperty("offset", item.offset()); >@@ -1153,14 +677,6 @@ static TextStream& operator<<(TextStream& ts, const DrawFocusRingRects& item) > return ts; > } > >-FillRect::FillRect(const FloatRect& rect) >- : DrawingItem(ItemType::FillRect) >- , m_rect(rect) >-{ >-} >- >-FillRect::~FillRect() = default; >- > void FillRect::apply(GraphicsContext& context) const > { > context.fillRect(m_rect); >@@ -1168,20 +684,10 @@ void FillRect::apply(GraphicsContext& context) const > > static TextStream& operator<<(TextStream& ts, const FillRect& item) > { >- ts << static_cast<const DrawingItem&>(item); > ts.dumpProperty("rect", item.rect()); > return ts; > } > >-FillRectWithColor::FillRectWithColor(const FloatRect& rect, const Color& color) >- : DrawingItem(ItemType::FillRectWithColor) >- , m_rect(rect) >- , m_color(color) >-{ >-} >- >-FillRectWithColor::~FillRectWithColor() = default; >- > void FillRectWithColor::apply(GraphicsContext& context) const > { > context.fillRect(m_rect, m_color); >@@ -1189,21 +695,17 @@ void FillRectWithColor::apply(GraphicsContext& context) const > > static TextStream& operator<<(TextStream& ts, const FillRectWithColor& item) > { >- ts << static_cast<const DrawingItem&>(item); > ts.dumpProperty("rect", item.rect()); > ts.dumpProperty("color", item.color()); > return ts; > } > > FillRectWithGradient::FillRectWithGradient(const FloatRect& rect, Gradient& gradient) >- : DrawingItem(ItemType::FillRectWithGradient) >- , m_rect(rect) >+ : m_rect(rect) > , m_gradient(gradient) > { > } > >-FillRectWithGradient::~FillRectWithGradient() = default; >- > void FillRectWithGradient::apply(GraphicsContext& context) const > { > context.fillRect(m_rect, m_gradient.get()); >@@ -1211,23 +713,11 @@ void FillRectWithGradient::apply(GraphicsContext& context) const > > static TextStream& operator<<(TextStream& ts, const FillRectWithGradient& item) > { >- ts << static_cast<const DrawingItem&>(item); > // FIXME: log gradient. > ts.dumpProperty("rect", item.rect()); > return ts; > } > >-FillCompositedRect::FillCompositedRect(const FloatRect& rect, const Color& color, CompositeOperator op, BlendMode blendMode) >- : DrawingItem(ItemType::FillCompositedRect) >- , m_rect(rect) >- , m_color(color) >- , m_op(op) >- , m_blendMode(blendMode) >-{ >-} >- >-FillCompositedRect::~FillCompositedRect() = default; >- > void FillCompositedRect::apply(GraphicsContext& context) const > { > context.fillRect(m_rect, m_color, m_op, m_blendMode); >@@ -1235,7 +725,6 @@ void FillCompositedRect::apply(GraphicsContext& context) const > > static TextStream& operator<<(TextStream& ts, const FillCompositedRect& item) > { >- ts << static_cast<const DrawingItem&>(item); > ts.dumpProperty("rect", item.rect()); > ts.dumpProperty("color", item.color()); > ts.dumpProperty("composite-operation", item.compositeOperator()); >@@ -1243,16 +732,6 @@ static TextStream& operator<<(TextStream& ts, const FillCompositedRect& item) > return ts; > } > >-FillRoundedRect::FillRoundedRect(const FloatRoundedRect& rect, const Color& color, BlendMode blendMode) >- : DrawingItem(ItemType::FillRoundedRect) >- , m_rect(rect) >- , m_color(color) >- , m_blendMode(blendMode) >-{ >-} >- >-FillRoundedRect::~FillRoundedRect() = default; >- > void FillRoundedRect::apply(GraphicsContext& context) const > { > context.fillRoundedRect(m_rect, m_color, m_blendMode); >@@ -1260,23 +739,12 @@ void FillRoundedRect::apply(GraphicsContext& context) const > > static TextStream& operator<<(TextStream& ts, const FillRoundedRect& item) > { >- ts << static_cast<const DrawingItem&>(item); > ts.dumpProperty("rect", item.roundedRect()); > ts.dumpProperty("color", item.color()); > ts.dumpProperty("blend-mode", item.blendMode()); > return ts; > } > >-FillRectWithRoundedHole::FillRectWithRoundedHole(const FloatRect& rect, const FloatRoundedRect& roundedHoleRect, const Color& color) >- : DrawingItem(ItemType::FillRectWithRoundedHole) >- , m_rect(rect) >- , m_roundedHoleRect(roundedHoleRect) >- , m_color(color) >-{ >-} >- >-FillRectWithRoundedHole::~FillRectWithRoundedHole() = default; >- > void FillRectWithRoundedHole::apply(GraphicsContext& context) const > { > context.fillRectWithRoundedHole(m_rect, m_roundedHoleRect, m_color); >@@ -1284,7 +752,6 @@ void FillRectWithRoundedHole::apply(GraphicsContext& context) const > > static TextStream& operator<<(TextStream& ts, const FillRectWithRoundedHole& item) > { >- ts << static_cast<const DrawingItem&>(item); > ts.dumpProperty("rect", item.rect()); > ts.dumpProperty("rounded-hole-rect", item.roundedHoleRect()); > ts.dumpProperty("color", item.color()); >@@ -1293,14 +760,6 @@ static TextStream& operator<<(TextStream& ts, const FillRectWithRoundedHole& ite > > #if ENABLE(INLINE_PATH_DATA) > >-FillInlinePath::FillInlinePath(const InlinePathData& pathData) >- : DrawingItem(ItemType::FillInlinePath) >- , m_pathData(pathData) >-{ >-} >- >-FillInlinePath::~FillInlinePath() = default; >- > void FillInlinePath::apply(GraphicsContext& context) const > { > context.fillPath(path()); >@@ -1308,21 +767,12 @@ void FillInlinePath::apply(GraphicsContext& context) const > > static TextStream& operator<<(TextStream& ts, const FillInlinePath& item) > { >- ts << static_cast<const DrawingItem&>(item); > ts.dumpProperty("path", item.path()); > return ts; > } > > #endif // ENABLE(INLINE_PATH_DATA) > >-FillPath::FillPath(const Path& path) >- : DrawingItem(ItemType::FillPath) >- , m_path(path) >-{ >-} >- >-FillPath::~FillPath() = default; >- > void FillPath::apply(GraphicsContext& context) const > { > context.fillPath(m_path); >@@ -1330,19 +780,10 @@ void FillPath::apply(GraphicsContext& context) const > > static TextStream& operator<<(TextStream& ts, const FillPath& item) > { >- ts << static_cast<const DrawingItem&>(item); > ts.dumpProperty("path", item.path()); > return ts; > } > >-FillEllipse::FillEllipse(const FloatRect& rect) >- : DrawingItem(ItemType::FillEllipse) >- , m_rect(rect) >-{ >-} >- >-FillEllipse::~FillEllipse() = default; >- > void FillEllipse::apply(GraphicsContext& context) const > { > context.fillEllipse(m_rect); >@@ -1350,14 +791,12 @@ void FillEllipse::apply(GraphicsContext& context) const > > static TextStream& operator<<(TextStream& ts, const FillEllipse& item) > { >- ts << static_cast<const DrawingItem&>(item); > ts.dumpProperty("rect", item.rect()); > return ts; > } > > PutImageData::PutImageData(AlphaPremultiplication inputFormat, const ImageData& imageData, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) >- : DrawingItem(ItemType::PutImageData) >- , m_srcRect(srcRect) >+ : m_srcRect(srcRect) > , m_destPoint(destPoint) > , m_imageData(imageData.deepClone()) // This copy is actually required to preserve the semantics of putImageData(). > , m_inputFormat(inputFormat) >@@ -1366,8 +805,7 @@ PutImageData::PutImageData(AlphaPremultiplication inputFormat, const ImageData& > } > > PutImageData::PutImageData(AlphaPremultiplication inputFormat, Ref<ImageData>&& imageData, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) >- : DrawingItem(ItemType::PutImageData) >- , m_srcRect(srcRect) >+ : m_srcRect(srcRect) > , m_destPoint(destPoint) > , m_imageData(WTFMove(imageData)) > , m_inputFormat(inputFormat) >@@ -1375,9 +813,7 @@ PutImageData::PutImageData(AlphaPremultiplication inputFormat, Ref<ImageData>&& > { > } > >-PutImageData::~PutImageData() = default; >- >-void PutImageData::apply(GraphicsContext&) const >+NO_RETURN_DUE_TO_ASSERT void PutImageData::apply(GraphicsContext&) const > { > // Should be handled by the delegate. > ASSERT_NOT_REACHED(); >@@ -1385,7 +821,6 @@ void PutImageData::apply(GraphicsContext&) const > > static TextStream& operator<<(TextStream& ts, const PutImageData& item) > { >- ts << static_cast<const DrawingItem&>(item); > ts.dumpProperty("inputFormat", item.inputFormat()); > ts.dumpProperty("imageDataSize", item.imageData().size()); > ts.dumpProperty("srcRect", item.srcRect()); >@@ -1394,33 +829,13 @@ static TextStream& operator<<(TextStream& ts, const PutImageData& item) > return ts; > } > >-Ref<PaintFrameForMedia> PaintFrameForMedia::create(MediaPlayer& player, const FloatRect& destination) >-{ >- return adoptRef(*new PaintFrameForMedia(player, destination)); >-} >- >-Ref<PaintFrameForMedia> PaintFrameForMedia::create(MediaPlayerIdentifier identifier, const FloatRect& destination) >-{ >- return adoptRef(*new PaintFrameForMedia(identifier, destination)); >-} >- > PaintFrameForMedia::PaintFrameForMedia(MediaPlayer& player, const FloatRect& destination) >- : DrawingItem(ItemType::PaintFrameForMedia) >- , m_identifier(player.identifier()) >- , m_destination(destination) >-{ >-} >- >-PaintFrameForMedia::PaintFrameForMedia(MediaPlayerIdentifier identifier, const FloatRect& destination) >- : DrawingItem(ItemType::PaintFrameForMedia) >- , m_identifier(identifier) >+ : m_identifier(player.identifier()) > , m_destination(destination) > { > } > >-PaintFrameForMedia::~PaintFrameForMedia() = default; >- >-void PaintFrameForMedia::apply(GraphicsContext&) const >+NO_RETURN_DUE_TO_ASSERT void PaintFrameForMedia::apply(GraphicsContext&) const > { > // Should be handled by the delegate. > ASSERT_NOT_REACHED(); >@@ -1428,20 +843,10 @@ void PaintFrameForMedia::apply(GraphicsContext&) const > > static TextStream& operator<<(TextStream& ts, const PaintFrameForMedia& item) > { >- ts << static_cast<const DrawingItem&>(item); > ts.dumpProperty("destination", item.destination()); > return ts; > } > >-StrokeRect::StrokeRect(const FloatRect& rect, float lineWidth) >- : DrawingItem(ItemType::StrokeRect) >- , m_rect(rect) >- , m_lineWidth(lineWidth) >-{ >-} >- >-StrokeRect::~StrokeRect() = default; >- > Optional<FloatRect> StrokeRect::localBounds(const GraphicsContext&) const > { > FloatRect bounds = m_rect; >@@ -1456,7 +861,6 @@ void StrokeRect::apply(GraphicsContext& context) const > > static TextStream& operator<<(TextStream& ts, const StrokeRect& item) > { >- ts << static_cast<const DrawingItem&>(item); > ts.dumpProperty("rect", item.rect()); > ts.dumpProperty("line-width", item.lineWidth()); > return ts; >@@ -1479,19 +883,10 @@ void StrokePath::apply(GraphicsContext& context) const > > static TextStream& operator<<(TextStream& ts, const StrokePath& item) > { >- ts << static_cast<const DrawingItem&>(item); > ts.dumpProperty("path", item.path()); > return ts; > } > >-StrokeEllipse::StrokeEllipse(const FloatRect& rect) >- : DrawingItem(ItemType::StrokeEllipse) >- , m_rect(rect) >-{ >-} >- >-StrokeEllipse::~StrokeEllipse() = default; >- > Optional<FloatRect> StrokeEllipse::localBounds(const GraphicsContext& context) const > { > float strokeThickness = context.strokeThickness(); >@@ -1508,7 +903,6 @@ void StrokeEllipse::apply(GraphicsContext& context) const > > static TextStream& operator<<(TextStream& ts, const StrokeEllipse& item) > { >- ts << static_cast<const DrawingItem&>(item); > ts.dumpProperty("rect", item.rect()); > return ts; > } >@@ -1532,37 +926,12 @@ void StrokeInlinePath::apply(GraphicsContext& context) const > > static TextStream& operator<<(TextStream& ts, const StrokeInlinePath& item) > { >- ts << static_cast<const DrawingItem&>(item); > ts.dumpProperty("path", item.path()); > return ts; > } > >-StrokeInlinePath::StrokeInlinePath(const InlinePathData& pathData) >- : DrawingItem(ItemType::StrokeInlinePath) >- , m_pathData(pathData) >-{ >-} >- >-StrokeInlinePath::~StrokeInlinePath() = default; >- > #endif // ENABLE(INLINE_PATH_DATA) > >-StrokePath::StrokePath(const Path& path) >- : DrawingItem(ItemType::StrokePath) >- , m_path(path) >-{ >-} >- >-StrokePath::~StrokePath() = default; >- >-ClearRect::ClearRect(const FloatRect& rect) >- : DrawingItem(ItemType::ClearRect) >- , m_rect(rect) >-{ >-} >- >-ClearRect::~ClearRect() = default; >- > void ClearRect::apply(GraphicsContext& context) const > { > context.clearRect(m_rect); >@@ -1570,19 +939,10 @@ void ClearRect::apply(GraphicsContext& context) const > > static TextStream& operator<<(TextStream& ts, const ClearRect& item) > { >- ts << static_cast<const DrawingItem&>(item); > ts.dumpProperty("rect", item.rect()); > return ts; > } > >-BeginTransparencyLayer::BeginTransparencyLayer(float opacity) >- : DrawingItem(ItemType::BeginTransparencyLayer) >- , m_opacity(opacity) >-{ >-} >- >-BeginTransparencyLayer::~BeginTransparencyLayer() = default; >- > void BeginTransparencyLayer::apply(GraphicsContext& context) const > { > context.beginTransparencyLayer(m_opacity); >@@ -1590,57 +950,28 @@ void BeginTransparencyLayer::apply(GraphicsContext& context) const > > static TextStream& operator<<(TextStream& ts, const BeginTransparencyLayer& item) > { >- ts << static_cast<const DrawingItem&>(item); > ts.dumpProperty("opacity", item.opacity()); > return ts; > } > >-EndTransparencyLayer::EndTransparencyLayer() >- : DrawingItem(ItemType::EndTransparencyLayer) >-{ >-} >- >-EndTransparencyLayer::~EndTransparencyLayer() = default; >- > void EndTransparencyLayer::apply(GraphicsContext& context) const > { > context.endTransparencyLayer(); > } > > #if USE(CG) >-ApplyStrokePattern::ApplyStrokePattern() >- : Item(ItemType::ApplyStrokePattern) >-{ >-} >- >-ApplyStrokePattern::~ApplyStrokePattern() = default; > > void ApplyStrokePattern::apply(GraphicsContext& context) const > { > context.applyStrokePattern(); > } > >-ApplyFillPattern::ApplyFillPattern() >- : Item(ItemType::ApplyFillPattern) >-{ >-} >- >-ApplyFillPattern::~ApplyFillPattern() = default; >- > void ApplyFillPattern::apply(GraphicsContext& context) const > { > context.applyFillPattern(); > } > #endif > >-ApplyDeviceScaleFactor::ApplyDeviceScaleFactor(float scaleFactor) >- : Item(ItemType::ApplyDeviceScaleFactor) >- , m_scaleFactor(scaleFactor) >-{ >-} >- >-ApplyDeviceScaleFactor::~ApplyDeviceScaleFactor() = default; >- > void ApplyDeviceScaleFactor::apply(GraphicsContext& context) const > { > context.applyDeviceScaleFactor(m_scaleFactor); >@@ -1652,7 +983,7 @@ static TextStream& operator<<(TextStream& ts, const ApplyDeviceScaleFactor& item > return ts; > } > >-static TextStream& operator<<(TextStream& ts, const ItemType& type) >+static TextStream& operator<<(TextStream& ts, ItemType type) > { > switch (type) { > case ItemType::Save: ts << "save"; break; >@@ -1723,172 +1054,170 @@ static TextStream& operator<<(TextStream& ts, const ItemType& type) > return ts; > } > >-TextStream& operator<<(TextStream& ts, const Item& item) >+TextStream& operator<<(TextStream& ts, ItemHandle item) > { >- TextStream::GroupScope group(ts); > ts << item.type(); > >- // FIXME: Make a macro which takes a macro for all these enumeration switches > switch (item.type()) { > case ItemType::Translate: >- ts << downcast<Translate>(item); >+ ts << item.get<Translate>(); > break; > case ItemType::Rotate: >- ts << downcast<Rotate>(item); >+ ts << item.get<Rotate>(); > break; > case ItemType::Scale: >- ts << downcast<Scale>(item); >+ ts << item.get<Scale>(); > break; > case ItemType::SetCTM: >- ts << downcast<SetCTM>(item); >+ ts << item.get<SetCTM>(); > break; > case ItemType::ConcatenateCTM: >- ts << downcast<ConcatenateCTM>(item); >+ ts << item.get<ConcatenateCTM>(); > break; > case ItemType::SetInlineFillGradient: >- ts << downcast<SetInlineFillGradient>(item); >+ ts << item.get<SetInlineFillGradient>(); > break; > case ItemType::SetInlineFillColor: >- ts << downcast<SetInlineFillColor>(item); >+ ts << item.get<SetInlineFillColor>(); > break; > case ItemType::SetInlineStrokeColor: >- ts << downcast<SetInlineStrokeColor>(item); >+ ts << item.get<SetInlineStrokeColor>(); > break; > case ItemType::SetStrokeThickness: >- ts << downcast<SetStrokeThickness>(item); >+ ts << item.get<SetStrokeThickness>(); > break; > case ItemType::SetState: >- ts << downcast<SetState>(item); >+ ts << item.get<SetState>(); > break; > case ItemType::SetLineCap: >- ts << downcast<SetLineCap>(item); >+ ts << item.get<SetLineCap>(); > break; > case ItemType::SetLineDash: >- ts << downcast<SetLineDash>(item); >+ ts << item.get<SetLineDash>(); > break; > case ItemType::SetLineJoin: >- ts << downcast<SetLineJoin>(item); >+ ts << item.get<SetLineJoin>(); > break; > case ItemType::SetMiterLimit: >- ts << downcast<SetMiterLimit>(item); >+ ts << item.get<SetMiterLimit>(); > break; > case ItemType::Clip: >- ts << downcast<Clip>(item); >+ ts << item.get<Clip>(); > break; > case ItemType::ClipOut: >- ts << downcast<ClipOut>(item); >+ ts << item.get<ClipOut>(); > break; > case ItemType::ClipOutToPath: >- ts << downcast<ClipOutToPath>(item); >+ ts << item.get<ClipOutToPath>(); > break; > case ItemType::ClipPath: >- ts << downcast<ClipPath>(item); >+ ts << item.get<ClipPath>(); > break; > case ItemType::ClipToDrawingCommands: >- ts << downcast<ClipToDrawingCommands>(item); >+ ts << item.get<ClipToDrawingCommands>(); > break; > case ItemType::DrawGlyphs: >- ts << downcast<DrawGlyphs>(item); >+ ts << item.get<DrawGlyphs>(); > break; > case ItemType::DrawImage: >- ts << downcast<DrawImage>(item); >+ ts << item.get<DrawImage>(); > break; > case ItemType::DrawTiledImage: >- ts << downcast<DrawTiledImage>(item); >+ ts << item.get<DrawTiledImage>(); > break; > case ItemType::DrawTiledScaledImage: >- ts << downcast<DrawTiledScaledImage>(item); >+ ts << item.get<DrawTiledScaledImage>(); > break; > case ItemType::DrawImageBuffer: >- ts << downcast<DrawImageBuffer>(item); >+ ts << item.get<DrawImageBuffer>(); > break; > case ItemType::DrawNativeImage: >- ts << downcast<DrawNativeImage>(item); >+ ts << item.get<DrawNativeImage>(); > break; > case ItemType::DrawPattern: >- ts << downcast<DrawPattern>(item); >+ ts << item.get<DrawPattern>(); > break; > case ItemType::DrawRect: >- ts << downcast<DrawRect>(item); >+ ts << item.get<DrawRect>(); > break; > case ItemType::DrawLine: >- ts << downcast<DrawLine>(item); >+ ts << item.get<DrawLine>(); > break; > case ItemType::DrawLinesForText: >- ts << downcast<DrawLinesForText>(item); >+ ts << item.get<DrawLinesForText>(); > break; > case ItemType::DrawDotsForDocumentMarker: >- ts << downcast<DrawDotsForDocumentMarker>(item); >+ ts << item.get<DrawDotsForDocumentMarker>(); > break; > case ItemType::DrawEllipse: >- ts << downcast<DrawEllipse>(item); >+ ts << item.get<DrawEllipse>(); > break; > case ItemType::DrawPath: >- ts << downcast<DrawPath>(item); >+ ts << item.get<DrawPath>(); > break; > case ItemType::DrawFocusRingPath: >- ts << downcast<DrawFocusRingPath>(item); >+ ts << item.get<DrawFocusRingPath>(); > break; > case ItemType::DrawFocusRingRects: >- ts << downcast<DrawFocusRingRects>(item); >+ ts << item.get<DrawFocusRingRects>(); > break; > case ItemType::FillRect: >- ts << downcast<FillRect>(item); >+ ts << item.get<FillRect>(); > break; > case ItemType::FillRectWithColor: >- ts << downcast<FillRectWithColor>(item); >+ ts << item.get<FillRectWithColor>(); > break; > case ItemType::FillRectWithGradient: >- ts << downcast<FillRectWithGradient>(item); >+ ts << item.get<FillRectWithGradient>(); > break; > case ItemType::FillCompositedRect: >- ts << downcast<FillCompositedRect>(item); >+ ts << item.get<FillCompositedRect>(); > break; > case ItemType::FillRoundedRect: >- ts << downcast<FillRoundedRect>(item); >+ ts << item.get<FillRoundedRect>(); > break; > case ItemType::FillRectWithRoundedHole: >- ts << downcast<FillRectWithRoundedHole>(item); >+ ts << item.get<FillRectWithRoundedHole>(); > break; > #if ENABLE(INLINE_PATH_DATA) > case ItemType::FillInlinePath: >- ts << downcast<FillInlinePath>(item); >+ ts << item.get<FillInlinePath>(); > break; > #endif > case ItemType::FillPath: >- ts << downcast<FillPath>(item); >+ ts << item.get<FillPath>(); > break; > case ItemType::FillEllipse: >- ts << downcast<FillEllipse>(item); >+ ts << item.get<FillEllipse>(); > break; > case ItemType::PutImageData: >- ts << downcast<PutImageData>(item); >+ ts << item.get<PutImageData>(); > break; > case ItemType::PaintFrameForMedia: >- ts << downcast<PaintFrameForMedia>(item); >+ ts << item.get<PaintFrameForMedia>(); > break; > case ItemType::StrokeRect: >- ts << downcast<StrokeRect>(item); >+ ts << item.get<StrokeRect>(); > break; > #if ENABLE(INLINE_PATH_DATA) > case ItemType::StrokeInlinePath: >- ts << downcast<StrokeInlinePath>(item); >+ ts << item.get<StrokeInlinePath>(); > break; > #endif > case ItemType::StrokePath: >- ts << downcast<StrokePath>(item); >+ ts << item.get<StrokePath>(); > break; > case ItemType::StrokeEllipse: >- ts << downcast<StrokeEllipse>(item); >+ ts << item.get<StrokeEllipse>(); > break; > case ItemType::ClearRect: >- ts << downcast<ClearRect>(item); >+ ts << item.get<ClearRect>(); > break; > case ItemType::BeginTransparencyLayer: >- ts << downcast<BeginTransparencyLayer>(item); >+ ts << item.get<BeginTransparencyLayer>(); > break; > case ItemType::ApplyDeviceScaleFactor: >- ts << downcast<ApplyDeviceScaleFactor>(item); >+ ts << item.get<ApplyDeviceScaleFactor>(); > break; > > // Items with no additional data. >diff --git a/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h b/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h >index 797598e721d56231dff0649aa5731743a2ceb035..2a518bb2e004b13da3d19e6fa6d85e91f5399689 100644 >--- a/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h >+++ b/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h >@@ -51,320 +51,163 @@ struct ImagePaintingOptions; > > namespace DisplayList { > >-class DrawingItem : public Item { >+class Save { > public: >- WEBCORE_EXPORT explicit DrawingItem(ItemType); >+ static constexpr ItemType itemType = ItemType::Save; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = false; > >- WEBCORE_EXPORT virtual ~DrawingItem(); >+ void apply(GraphicsContext&) const; > >- void setExtent(const FloatRect& r) { m_extent = r; } >- const FloatRect& extent() const { return m_extent.value(); } >- >- bool extentKnown() const { return static_cast<bool>(m_extent); } >- >- // Return bounds of this drawing operation in local coordinates. >- // Does not include effets of transform, shadow etc in the state. >- virtual Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >- >- // Some operations (e.g. putImageData) operate in global bounds. For these operations, override this method. >- // If applicable, the return value needs to include the effects of shadows, clipping, etc. >- virtual Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >- >-private: >- bool isDrawingItem() const override { return true; } >- >- Optional<FloatRect> m_extent; // In base coordinates, taking shadows and transforms into account. >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } > }; > >-class Save : public Item { >+class Restore { > public: >- static Ref<Save> create() >- { >- return adoptRef(*new Save); >- } >+ static constexpr ItemType itemType = ItemType::Restore; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = false; > >- WEBCORE_EXPORT virtual ~Save(); >+ void apply(GraphicsContext&) const; > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<Save>> decode(Decoder&); >- >-private: >- WEBCORE_EXPORT Save(); >- >- void apply(GraphicsContext&) const override; >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } > }; > >-template<class Encoder> >-void Save::encode(Encoder&) const >-{ >-} >- >-template<class Decoder> >-Optional<Ref<Save>> Save::decode(Decoder&) >-{ >- return Save::create(); >-} >- >-class Restore : public Item { >+class Translate { > public: >- static Ref<Restore> create() >- { >- return adoptRef(*new Restore); >- } >- >- WEBCORE_EXPORT virtual ~Restore(); >- >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<Restore>> decode(Decoder&); >- >-private: >- WEBCORE_EXPORT Restore(); >- >- void apply(GraphicsContext&) const override; >-}; >- >-template<class Encoder> >-void Restore::encode(Encoder&) const >-{ >-} >- >-template<class Decoder> >-Optional<Ref<Restore>> Restore::decode(Decoder&) >-{ >- return Restore::create(); >-} >+ static constexpr ItemType itemType = ItemType::Translate; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = false; > >-class Translate : public Item { >-public: >- static Ref<Translate> create(float x, float y) >+ Translate(float x, float y) >+ : m_x(x) >+ , m_y(y) > { >- return adoptRef(*new Translate(x, y)); > } > >- WEBCORE_EXPORT virtual ~Translate(); >- > float x() const { return m_x; } > float y() const { return m_y; } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<Translate>> decode(Decoder&); >- >-private: >- WEBCORE_EXPORT Translate(float x, float y); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } > >- float m_x; >- float m_y; >+private: >+ float m_x { 0 }; >+ float m_y { 0 }; > }; > >-template<class Encoder> >-void Translate::encode(Encoder& encoder) const >-{ >- encoder << m_x; >- encoder << m_y; >-} >- >-template<class Decoder> >-Optional<Ref<Translate>> Translate::decode(Decoder& decoder) >-{ >- Optional<float> x; >- decoder >> x; >- if (!x) >- return WTF::nullopt; >- >- Optional<float> y; >- decoder >> y; >- if (!y) >- return WTF::nullopt; >- >- return Translate::create(*x, *y); >-} >- >-class Rotate : public Item { >+class Rotate { > public: >- static Ref<Rotate> create(float angleInRadians) >+ static constexpr ItemType itemType = ItemType::Rotate; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = false; >+ >+ Rotate(float angle) >+ : m_angle(angle) > { >- return adoptRef(*new Rotate(angleInRadians)); > } > >- WEBCORE_EXPORT virtual ~Rotate(); >- > float angle() const { return m_angle; } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<Rotate>> decode(Decoder&); >- >-private: >- WEBCORE_EXPORT Rotate(float angle); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } > >- float m_angle; // In radians. >+private: >+ float m_angle { 0 }; // In radians. > }; > >-template<class Encoder> >-void Rotate::encode(Encoder& encoder) const >-{ >- encoder << m_angle; >-} >- >-template<class Decoder> >-Optional<Ref<Rotate>> Rotate::decode(Decoder& decoder) >-{ >- Optional<float> angle; >- decoder >> angle; >- if (!angle) >- return WTF::nullopt; >- >- return Rotate::create(*angle); >-} >- >-class Scale : public Item { >+class Scale { > public: >- static Ref<Scale> create(const FloatSize& size) >+ static constexpr ItemType itemType = ItemType::Scale; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = false; >+ >+ Scale(const FloatSize& size) >+ : m_size(size) > { >- return adoptRef(*new Scale(size)); > } > >- WEBCORE_EXPORT virtual ~Scale(); >- > const FloatSize& amount() const { return m_size; } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<Scale>> decode(Decoder&); >- >-private: >- WEBCORE_EXPORT Scale(const FloatSize&); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } > >+private: > FloatSize m_size; > }; > >-template<class Encoder> >-void Scale::encode(Encoder& encoder) const >-{ >- encoder << m_size; >-} >- >-template<class Decoder> >-Optional<Ref<Scale>> Scale::decode(Decoder& decoder) >-{ >- Optional<FloatSize> scale; >- decoder >> scale; >- if (!scale) >- return WTF::nullopt; >- >- return Scale::create(*scale); >-} >- >-class SetCTM : public Item { >+class SetCTM { > public: >- static Ref<SetCTM> create(const AffineTransform& matrix) >+ static constexpr ItemType itemType = ItemType::SetCTM; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = false; >+ >+ SetCTM(const AffineTransform& transform) >+ : m_transform(transform) > { >- return adoptRef(*new SetCTM(matrix)); > } > >- WEBCORE_EXPORT virtual ~SetCTM(); >- > const AffineTransform& transform() const { return m_transform; } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<SetCTM>> decode(Decoder&); >- >-private: >- WEBCORE_EXPORT SetCTM(const AffineTransform&); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } > >+private: > AffineTransform m_transform; > }; > >-template<class Encoder> >-void SetCTM::encode(Encoder& encoder) const >-{ >- encoder << m_transform; >-} >- >-template<class Decoder> >-Optional<Ref<SetCTM>> SetCTM::decode(Decoder& decoder) >-{ >- Optional<AffineTransform> transform; >- decoder >> transform; >- if (!transform) >- return WTF::nullopt; >- >- return SetCTM::create(*transform); >-} >- >-class ConcatenateCTM : public Item { >+class ConcatenateCTM { > public: >- static Ref<ConcatenateCTM> create(const AffineTransform& matrix) >+ static constexpr ItemType itemType = ItemType::ConcatenateCTM; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = false; >+ >+ ConcatenateCTM(const AffineTransform& transform) >+ : m_transform(transform) > { >- return adoptRef(*new ConcatenateCTM(matrix)); > } > >- WEBCORE_EXPORT virtual ~ConcatenateCTM(); >- > const AffineTransform& transform() const { return m_transform; } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<ConcatenateCTM>> decode(Decoder&); >- >-private: >- WEBCORE_EXPORT ConcatenateCTM(const AffineTransform&); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } > >+private: > AffineTransform m_transform; > }; > >-template<class Encoder> >-void ConcatenateCTM::encode(Encoder& encoder) const >-{ >- encoder << m_transform; >-} >- >-template<class Decoder> >-Optional<Ref<ConcatenateCTM>> ConcatenateCTM::decode(Decoder& decoder) >-{ >- Optional<AffineTransform> transform; >- decoder >> transform; >- if (!transform) >- return WTF::nullopt; >- >- return ConcatenateCTM::create(*transform); >-} >- >-class SetInlineFillGradient : public Item { >+class SetInlineFillGradient { > public: >+ static constexpr ItemType itemType = ItemType::SetInlineFillGradient; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = false; > static constexpr uint8_t maxColorStopCount = 4; > >- static Ref<SetInlineFillGradient> create(const Gradient&); >- static bool isInline(const Gradient&); >- >- virtual ~SetInlineFillGradient(); >- >- Ref<Gradient> gradient() const; >- >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<SetInlineFillGradient>> decode(Decoder&); >- >-private: >- static Ref<SetInlineFillGradient> create(float offsets[maxColorStopCount], SRGBA<uint8_t> colors[maxColorStopCount], >- const Gradient::Data& data, const AffineTransform& gradientSpaceTransformation, GradientSpreadMethod spreadMethod, uint8_t colorStopCount) >- { >- return adoptRef(*new SetInlineFillGradient(offsets, colors, data, gradientSpaceTransformation, spreadMethod, colorStopCount)); >- } >- >+ SetInlineFillGradient(const Gradient&); > WEBCORE_EXPORT SetInlineFillGradient(float offsets[maxColorStopCount], SRGBA<uint8_t> colors[maxColorStopCount], const Gradient::Data&, > const AffineTransform& gradientSpaceTransformation, GradientSpreadMethod, uint8_t colorStopCount); > >- SetInlineFillGradient(const Gradient&); >+ static bool isInline(const Gradient&); >+ Ref<Gradient> gradient() const; > >- void apply(GraphicsContext&) const override; >+ void apply(GraphicsContext&) const; > >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ >+private: > float m_offsets[maxColorStopCount]; > SRGBA<uint8_t> m_colors[maxColorStopCount]; > Gradient::Data m_data; >@@ -373,198 +216,79 @@ private: > uint8_t m_colorStopCount { 0 }; > }; > >-template<class Encoder> >-void SetInlineFillGradient::encode(Encoder& encoder) const >-{ >- encoder << m_colorStopCount; >- for (uint8_t i = 0; i < m_colorStopCount; ++i) { >- encoder << m_offsets[i]; >- encoder << PackedColor::RGBA { m_colors[i] }.value; >- } >- encoder << m_data; >- encoder << m_gradientSpaceTransformation; >- encoder << m_spreadMethod; >-} >- >-template<class Decoder> >-Optional<Ref<SetInlineFillGradient>> SetInlineFillGradient::decode(Decoder& decoder) >-{ >- Optional<uint8_t> colorStopCount; >- decoder >> colorStopCount; >- if (!colorStopCount) >- return WTF::nullopt; >- >- if (*colorStopCount > maxColorStopCount) >- return WTF::nullopt; >- >- float offsets[maxColorStopCount]; >- SRGBA<uint8_t> colors[maxColorStopCount]; >- for (uint8_t i = 0; i < *colorStopCount; ++i) { >- Optional<float> offset; >- decoder >> offset; >- if (!offset) >- return WTF::nullopt; >- >- Optional<uint32_t> color; >- decoder >> color; >- if (!color) >- return WTF::nullopt; >- >- colors[i] = asSRGBA(PackedColor::RGBA { *color }); >- offsets[i] = *offset; >- } >- >- Optional<Gradient::Data> data; >- decoder >> data; >- if (!data) >- return WTF::nullopt; >- >- Optional<AffineTransform> gradientSpaceTransformation; >- decoder >> gradientSpaceTransformation; >- if (!gradientSpaceTransformation) >- return WTF::nullopt; >- >- Optional<GradientSpreadMethod> spreadMethod; >- decoder >> spreadMethod; >- if (!spreadMethod) >- return WTF::nullopt; >- >- return { SetInlineFillGradient::create(offsets, colors, *data, *gradientSpaceTransformation, *spreadMethod, *colorStopCount) }; >-} >- >-class SetInlineFillColor : public Item { >+class SetInlineFillColor { > public: >- WEBCORE_EXPORT static Ref<SetInlineFillColor> create(SRGBA<uint8_t>); >+ static constexpr ItemType itemType = ItemType::SetInlineFillColor; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = false; > >- WEBCORE_EXPORT virtual ~SetInlineFillColor(); >- >- Color color() const { return { m_colorData }; } >- >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<SetInlineFillColor>> decode(Decoder&); >- >-private: > SetInlineFillColor(SRGBA<uint8_t> colorData) >- : Item(ItemType::SetInlineFillColor) >- , m_colorData(colorData) >+ : m_colorData(colorData) > { > } > >- void apply(GraphicsContext&) const override; >+ Color color() const { return { m_colorData }; } >+ void apply(GraphicsContext&) const; >+ >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } > >+private: > SRGBA<uint8_t> m_colorData; > }; > >-template<class Encoder> >-void SetInlineFillColor::encode(Encoder& encoder) const >-{ >- encoder << PackedColor::RGBA { m_colorData }.value; >-} >- >-template<class Decoder> >-Optional<Ref<SetInlineFillColor>> SetInlineFillColor::decode(Decoder& decoder) >-{ >- Optional<uint32_t> value; >- decoder >> value; >- if (!value) >- return WTF::nullopt; >- >- return SetInlineFillColor::create(asSRGBA(PackedColor::RGBA { *value })); >-} >- >-class SetInlineStrokeColor : public Item { >+class SetInlineStrokeColor { > public: >- WEBCORE_EXPORT static Ref<SetInlineStrokeColor> create(SRGBA<uint8_t>); >- >- WEBCORE_EXPORT virtual ~SetInlineStrokeColor(); >- >- Color color() const { return { m_colorData }; } >- >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<SetInlineStrokeColor>> decode(Decoder&); >+ static constexpr ItemType itemType = ItemType::SetInlineStrokeColor; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = false; > >-private: > SetInlineStrokeColor(SRGBA<uint8_t> colorData) >- : Item(ItemType::SetInlineStrokeColor) >- , m_colorData(colorData) >+ : m_colorData(colorData) > { > } > >- void apply(GraphicsContext&) const override; >- >- SRGBA<uint8_t> m_colorData; >-}; >+ Color color() const { return { m_colorData }; } > >-template<class Encoder> >-void SetInlineStrokeColor::encode(Encoder& encoder) const >-{ >- encoder << PackedColor::RGBA { m_colorData }.value; >-} >+ void apply(GraphicsContext&) const; > >-template<class Decoder> >-Optional<Ref<SetInlineStrokeColor>> SetInlineStrokeColor::decode(Decoder& decoder) >-{ >- Optional<uint32_t> value; >- decoder >> value; >- if (!value) >- return WTF::nullopt; >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } > >- return SetInlineStrokeColor::create(asSRGBA(PackedColor::RGBA { *value })); >-} >+private: >+ SRGBA<uint8_t> m_colorData; >+}; > >-class SetStrokeThickness : public Item { >+class SetStrokeThickness { > public: >- WEBCORE_EXPORT static Ref<SetStrokeThickness> create(float thickness); >- >- WEBCORE_EXPORT virtual ~SetStrokeThickness(); >+ static constexpr ItemType itemType = ItemType::SetStrokeThickness; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = false; > >- float thickness() const { return m_thickness; } >- >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<SetStrokeThickness>> decode(Decoder&); >- >-private: > SetStrokeThickness(float thickness) >- : Item(ItemType::SetStrokeThickness) >- , m_thickness(thickness) >+ : m_thickness(thickness) > { > } > >- void apply(GraphicsContext&) const override; >- >- float m_thickness { 0 }; >-}; >+ float thickness() const { return m_thickness; } > >-template<class Encoder> >-void SetStrokeThickness::encode(Encoder& encoder) const >-{ >- encoder << m_thickness; >-} >+ void apply(GraphicsContext&) const; > >-template<class Decoder> >-Optional<Ref<SetStrokeThickness>> SetStrokeThickness::decode(Decoder& decoder) >-{ >- Optional<float> thickness; >- decoder >> thickness; >- if (!thickness) >- return WTF::nullopt; >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } > >- return SetStrokeThickness::create(*thickness); >-} >+private: >+ float m_thickness { 0 }; >+}; > >-class SetState : public Item { >+class SetState { > public: >- static Ref<SetState> create(const GraphicsContextState& state, GraphicsContextState::StateChangeFlags flags) >- { >- return adoptRef(*new SetState(state, flags)); >- } >- >- static Ref<SetState> create(const GraphicsContextStateChange& stateChange) >- { >- return adoptRef(*new SetState(stateChange)); >- } >+ static constexpr ItemType itemType = ItemType::SetState; >+ static constexpr bool isInlineItem = false; >+ static constexpr bool isDrawingItem = false; > >- WEBCORE_EXPORT virtual ~SetState(); >+ WEBCORE_EXPORT SetState(const GraphicsContextState&, GraphicsContextState::StateChangeFlags); >+ WEBCORE_EXPORT SetState(const GraphicsContextStateChange&); > > const GraphicsContextStateChange& state() const { return m_state; } > >@@ -573,14 +297,14 @@ public: > static void dumpStateChanges(WTF::TextStream&, const GraphicsContextState&, GraphicsContextState::StateChangeFlags); > > template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<SetState>> decode(Decoder&); >+ template<class Decoder> static Optional<SetState> decode(Decoder&); > >-private: >- WEBCORE_EXPORT SetState(const GraphicsContextState&, GraphicsContextState::StateChangeFlags); >- WEBCORE_EXPORT SetState(const GraphicsContextStateChange&); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } > >+private: > GraphicsContextStateChange m_state; > }; > >@@ -669,7 +393,7 @@ void SetState::encode(Encoder& encoder) const > } > > template<class Decoder> >-Optional<Ref<SetState>> SetState::decode(Decoder& decoder) >+Optional<SetState> SetState::decode(Decoder& decoder) > { > Optional<GraphicsContextState::StateChangeFlags> changeFlags; > decoder >> changeFlags; >@@ -896,68 +620,55 @@ Optional<Ref<SetState>> SetState::decode(Decoder& decoder) > stateChange.m_state.shadowsIgnoreTransforms = *shadowsIgnoreTransforms; > } > >- return SetState::create(stateChange); >+ return { stateChange }; > } > >-class SetLineCap : public Item { >+class SetLineCap { > public: >- static Ref<SetLineCap> create(LineCap lineCap) >+ static constexpr ItemType itemType = ItemType::SetLineCap; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = false; >+ >+ SetLineCap(LineCap lineCap) >+ : m_lineCap(lineCap) > { >- return adoptRef(*new SetLineCap(lineCap)); > } > >- WEBCORE_EXPORT virtual ~SetLineCap(); >- > LineCap lineCap() const { return m_lineCap; } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<SetLineCap>> decode(Decoder&); >- >-private: >- WEBCORE_EXPORT SetLineCap(LineCap); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } > >+private: > LineCap m_lineCap; > }; > >-template<class Encoder> >-void SetLineCap::encode(Encoder& encoder) const >-{ >- encoder << m_lineCap; >-} >- >-template<class Decoder> >-Optional<Ref<SetLineCap>> SetLineCap::decode(Decoder& decoder) >-{ >- Optional<LineCap> lineCap; >- decoder >> lineCap; >- if (!lineCap) >- return WTF::nullopt; >- >- return SetLineCap::create(*lineCap); >-} >- >-class SetLineDash : public Item { >+class SetLineDash { > public: >- static Ref<SetLineDash> create(const DashArray& dashArray, float dashOffset) >+ static constexpr ItemType itemType = ItemType::SetLineDash; >+ static constexpr bool isInlineItem = false; >+ static constexpr bool isDrawingItem = false; >+ >+ SetLineDash(const DashArray& dashArray, float dashOffset) >+ : m_dashArray(dashArray) >+ , m_dashOffset(dashOffset) > { >- return adoptRef(*new SetLineDash(dashArray, dashOffset)); > } > >- WEBCORE_EXPORT virtual ~SetLineDash(); >- > const DashArray& dashArray() const { return m_dashArray; } > float dashOffset() const { return m_dashOffset; } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<SetLineDash>> decode(Decoder&); >+ void apply(GraphicsContext&) const; > >-private: >- WEBCORE_EXPORT SetLineDash(const DashArray&, float dashOffset); >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } > >- void apply(GraphicsContext&) const override; >+ template<class Encoder> void encode(Encoder&) const; >+ template<class Decoder> static Optional<SetLineDash> decode(Decoder&); > >+private: > DashArray m_dashArray; > float m_dashOffset; > }; >@@ -970,7 +681,7 @@ void SetLineDash::encode(Encoder& encoder) const > } > > template<class Decoder> >-Optional<Ref<SetLineDash>> SetLineDash::decode(Decoder& decoder) >+Optional<SetLineDash> SetLineDash::decode(Decoder& decoder) > { > Optional<DashArray> dashArray; > decoder >> dashArray; >@@ -982,215 +693,138 @@ Optional<Ref<SetLineDash>> SetLineDash::decode(Decoder& decoder) > if (!dashOffset) > return WTF::nullopt; > >- return SetLineDash::create(*dashArray, *dashOffset); >+ return {{ *dashArray, *dashOffset }}; > } > >-class SetLineJoin : public Item { >+class SetLineJoin { > public: >- static Ref<SetLineJoin> create(LineJoin lineJoin) >+ static constexpr ItemType itemType = ItemType::SetLineJoin; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = false; >+ >+ SetLineJoin(LineJoin lineJoin) >+ : m_lineJoin(lineJoin) > { >- return adoptRef(*new SetLineJoin(lineJoin)); > } > >- WEBCORE_EXPORT virtual ~SetLineJoin(); >- > LineJoin lineJoin() const { return m_lineJoin; } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<SetLineJoin>> decode(Decoder&); >- >-private: >- WEBCORE_EXPORT SetLineJoin(LineJoin); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } > >+private: > LineJoin m_lineJoin; > }; > >-template<class Encoder> >-void SetLineJoin::encode(Encoder& encoder) const >-{ >- encoder << m_lineJoin; >-} >- >-template<class Decoder> >-Optional<Ref<SetLineJoin>> SetLineJoin::decode(Decoder& decoder) >-{ >- Optional<LineJoin> lineJoin; >- decoder >> lineJoin; >- if (!lineJoin) >- return WTF::nullopt; >- >- return SetLineJoin::create(*lineJoin); >-} >- >-class SetMiterLimit : public Item { >+class SetMiterLimit { > public: >- static Ref<SetMiterLimit> create(float limit) >+ static constexpr ItemType itemType = ItemType::SetMiterLimit; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = false; >+ >+ SetMiterLimit(float miterLimit) >+ : m_miterLimit(miterLimit) > { >- return adoptRef(*new SetMiterLimit(limit)); > } > >- WEBCORE_EXPORT virtual ~SetMiterLimit(); >- > float miterLimit() const { return m_miterLimit; } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<SetMiterLimit>> decode(Decoder&); >- >-private: >- WEBCORE_EXPORT SetMiterLimit(float); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } > >+private: > float m_miterLimit; > }; > >-template<class Encoder> >-void SetMiterLimit::encode(Encoder& encoder) const >-{ >- encoder << m_miterLimit; >-} >- >-template<class Decoder> >-Optional<Ref<SetMiterLimit>> SetMiterLimit::decode(Decoder& decoder) >-{ >- Optional<float> miterLimit; >- decoder >> miterLimit; >- if (!miterLimit) >- return WTF::nullopt; >- >- return SetMiterLimit::create(*miterLimit); >-} >- >-class ClearShadow : public Item { >+class ClearShadow { > public: >- static Ref<ClearShadow> create() >- { >- return adoptRef(*new ClearShadow); >- } >- >- WEBCORE_EXPORT virtual ~ClearShadow(); >- >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<ClearShadow>> decode(Decoder&); >+ static constexpr ItemType itemType = ItemType::ClearShadow; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = false; > >-private: >- WEBCORE_EXPORT ClearShadow(); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } > }; > >-template<class Encoder> >-void ClearShadow::encode(Encoder&) const >-{ >-} >- >-template<class Decoder> >-Optional<Ref<ClearShadow>> ClearShadow::decode(Decoder&) >-{ >- return ClearShadow::create(); >-} >- >-// FIXME: treat as DrawingItem? >-class Clip : public Item { >+// FIXME: treat as drawing item? >+class Clip { > public: >- static Ref<Clip> create(const FloatRect& rect) >+ static constexpr ItemType itemType = ItemType::Clip; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = false; >+ >+ Clip(const FloatRect& rect) >+ : m_rect(rect) > { >- return adoptRef(*new Clip(rect)); > } > >- WEBCORE_EXPORT virtual ~Clip(); >+ const FloatRect& rect() const { return m_rect; } > >- FloatRect rect() const { return m_rect; } >+ void apply(GraphicsContext&) const; > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<Clip>> decode(Decoder&); >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } > > private: >- WEBCORE_EXPORT Clip(const FloatRect&); >- >- void apply(GraphicsContext&) const override; >- > FloatRect m_rect; > }; > >-template<class Encoder> >-void Clip::encode(Encoder& encoder) const >-{ >- encoder << m_rect; >-} >- >-template<class Decoder> >-Optional<Ref<Clip>> Clip::decode(Decoder& decoder) >-{ >- Optional<FloatRect> rect; >- decoder >> rect; >- if (!rect) >- return WTF::nullopt; >- >- return Clip::create(*rect); >-} >- >-class ClipOut : public Item { >+class ClipOut { > public: >- static Ref<ClipOut> create(const FloatRect& rect) >+ static constexpr ItemType itemType = ItemType::ClipOut; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = false; >+ >+ ClipOut(const FloatRect& rect) >+ : m_rect(rect) > { >- return adoptRef(*new ClipOut(rect)); > } > >- WEBCORE_EXPORT virtual ~ClipOut(); >+ const FloatRect& rect() const { return m_rect; } > >- FloatRect rect() const { return m_rect; } >+ void apply(GraphicsContext&) const; > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<ClipOut>> decode(Decoder&); >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } > > private: >- WEBCORE_EXPORT ClipOut(const FloatRect&); >- >- void apply(GraphicsContext&) const override; >- > FloatRect m_rect; > }; > >-template<class Encoder> >-void ClipOut::encode(Encoder& encoder) const >-{ >- encoder << m_rect; >-} >- >-template<class Decoder> >-Optional<Ref<ClipOut>> ClipOut::decode(Decoder& decoder) >-{ >- Optional<FloatRect> rect; >- decoder >> rect; >- if (!rect) >- return WTF::nullopt; >- >- return ClipOut::create(*rect); >-} >- >-class ClipOutToPath : public Item { >+class ClipOutToPath { > public: >- static Ref<ClipOutToPath> create(const Path& path) >+ static constexpr ItemType itemType = ItemType::ClipOutToPath; >+ static constexpr bool isInlineItem = false; >+ static constexpr bool isDrawingItem = false; >+ >+ ClipOutToPath(Path&& path) >+ : m_path(WTFMove(path)) > { >- return adoptRef(*new ClipOutToPath(path)); > } > >- WEBCORE_EXPORT virtual ~ClipOutToPath(); >+ ClipOutToPath(const Path& path) >+ : m_path(path) >+ { >+ } > > const Path& path() const { return m_path; } > > template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<ClipOutToPath>> decode(Decoder&); >+ template<class Decoder> static Optional<ClipOutToPath> decode(Decoder&); > >-private: >- WEBCORE_EXPORT ClipOutToPath(const Path&); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } > >- const Path m_path; >+private: >+ Path m_path; > }; > > template<class Encoder> >@@ -1200,37 +834,47 @@ void ClipOutToPath::encode(Encoder& encoder) const > } > > template<class Decoder> >-Optional<Ref<ClipOutToPath>> ClipOutToPath::decode(Decoder& decoder) >+Optional<ClipOutToPath> ClipOutToPath::decode(Decoder& decoder) > { > Optional<Path> path; > decoder >> path; > if (!path) > return WTF::nullopt; > >- return ClipOutToPath::create(*path); >+ return {{ WTFMove(*path) }}; > } > >-class ClipPath : public Item { >+class ClipPath { > public: >- static Ref<ClipPath> create(const Path& path, WindRule windRule) >+ static constexpr ItemType itemType = ItemType::ClipPath; >+ static constexpr bool isInlineItem = false; >+ static constexpr bool isDrawingItem = false; >+ >+ ClipPath(Path&& path, WindRule windRule) >+ : m_path(WTFMove(path)) >+ , m_windRule(windRule) > { >- return adoptRef(*new ClipPath(path, windRule)); > } > >- WEBCORE_EXPORT ~ClipPath(); >+ ClipPath(const Path& path, WindRule windRule) >+ : m_path(path) >+ , m_windRule(windRule) >+ { >+ } > > const Path& path() const { return m_path; } > WindRule windRule() const { return m_windRule; } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<ClipPath>> decode(Decoder&); >+ void apply(GraphicsContext&) const; > >-private: >- WEBCORE_EXPORT ClipPath(const Path&, WindRule); >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } > >- void apply(GraphicsContext&) const override; >+ template<class Encoder> void encode(Encoder&) const; >+ template<class Decoder> static Optional<ClipPath> decode(Decoder&); > >- const Path m_path; >+private: >+ Path m_path; > WindRule m_windRule; > }; > >@@ -1242,7 +886,7 @@ void ClipPath::encode(Encoder& encoder) const > } > > template<class Decoder> >-Optional<Ref<ClipPath>> ClipPath::decode(Decoder& decoder) >+Optional<ClipPath> ClipPath::decode(Decoder& decoder) > { > Optional<Path> path; > decoder >> path; >@@ -1254,30 +898,50 @@ Optional<Ref<ClipPath>> ClipPath::decode(Decoder& decoder) > if (!windRule) > return WTF::nullopt; > >- return ClipPath::create(*path, *windRule); >+ return {{ WTFMove(*path), *windRule }}; > } > >-class ClipToDrawingCommands : public Item { >+class ClipToDrawingCommands { > public: >- static Ref<ClipToDrawingCommands> create(const FloatRect& destination, ColorSpace colorSpace, DisplayList&& drawingCommands) >+ static constexpr ItemType itemType = ItemType::ClipToDrawingCommands; >+ static constexpr bool isInlineItem = false; >+ static constexpr bool isDrawingItem = false; >+ >+ ClipToDrawingCommands(const FloatRect& destination, ColorSpace colorSpace, DisplayList&& drawingCommands) >+ : m_destination(destination) >+ , m_colorSpace(colorSpace) >+ , m_drawingCommands(WTFMove(drawingCommands)) >+ { >+ } >+ >+ ClipToDrawingCommands(const ClipToDrawingCommands& other) >+ : m_destination(other.m_destination) >+ , m_colorSpace(other.m_colorSpace) > { >- return adoptRef(*new ClipToDrawingCommands(destination, colorSpace, WTFMove(drawingCommands))); >+ // FIXME: Copy m_drawingCommands. > } > >- WEBCORE_EXPORT ~ClipToDrawingCommands(); >+ ClipToDrawingCommands& operator=(const ClipToDrawingCommands& other) >+ { >+ m_destination = other.m_destination; >+ m_colorSpace = other.m_colorSpace; >+ // FIXME: Copy m_drawingCommands. >+ return *this; >+ } > > const FloatRect& destination() const { return m_destination; } > ColorSpace colorSpace() const { return m_colorSpace; } > const DisplayList& drawingCommands() const { return m_drawingCommands; } > > template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<ClipToDrawingCommands>> decode(Decoder&); >+ template<class Decoder> static Optional<ClipToDrawingCommands> decode(Decoder&); > >-private: >- WEBCORE_EXPORT ClipToDrawingCommands(const FloatRect& destination, ColorSpace, DisplayList&& drawingCommands); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } > >+private: > FloatRect m_destination; > ColorSpace m_colorSpace; > DisplayList m_drawingCommands; >@@ -1288,11 +952,11 @@ void ClipToDrawingCommands::encode(Encoder& encoder) const > { > encoder << m_destination; > encoder << m_colorSpace; >- encoder << m_drawingCommands; >+ // FIXME: Implement a way to encode in-memory display lists. > } > > template<class Decoder> >-Optional<Ref<ClipToDrawingCommands>> ClipToDrawingCommands::decode(Decoder& decoder) >+Optional<ClipToDrawingCommands> ClipToDrawingCommands::decode(Decoder& decoder) > { > Optional<FloatRect> destination; > decoder >> destination; >@@ -1304,27 +968,16 @@ Optional<Ref<ClipToDrawingCommands>> ClipToDrawingCommands::decode(Decoder& deco > if (!colorSpace) > return WTF::nullopt; > >- Optional<DisplayList> drawingCommands; >- decoder >> drawingCommands; >- if (!drawingCommands) >- return WTF::nullopt; >- >- return ClipToDrawingCommands::create(*destination, *colorSpace, WTFMove(*drawingCommands)); >+ // FIXME: Implement a way to decode in-memory display lists. >+ DisplayList drawingCommands; >+ return {{ *destination, *colorSpace, WTFMove(drawingCommands) }}; > } > >-class DrawGlyphs : public DrawingItem { >+class DrawGlyphs { > public: >- static Ref<DrawGlyphs> create(const Font& font, const GlyphBufferGlyph* glyphs, const GlyphBufferAdvance* advances, unsigned count, const FloatPoint& localAnchor, FontSmoothingMode smoothingMode) >- { >- return adoptRef(*new DrawGlyphs(font, glyphs, advances, count, localAnchor, smoothingMode)); >- } >- >- static Ref<DrawGlyphs> create(const Font& font, Vector<GlyphBufferGlyph, 128>&& glyphs, Vector<GlyphBufferAdvance, 128>&& advances, const FloatPoint& localAnchor, FontSmoothingMode smoothingMode) >- { >- return adoptRef(*new DrawGlyphs(font, WTFMove(glyphs), WTFMove(advances), localAnchor, smoothingMode)); >- } >- >- WEBCORE_EXPORT virtual ~DrawGlyphs(); >+ static constexpr ItemType itemType = ItemType::DrawGlyphs; >+ static constexpr bool isInlineItem = false; >+ static constexpr bool isDrawingItem = true; > > const FloatPoint& localAnchor() const { return m_localAnchor; } > >@@ -1333,21 +986,21 @@ public: > const Vector<GlyphBufferGlyph, 128>& glyphs() const { return m_glyphs; } > > template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<DrawGlyphs>> decode(Decoder&); >+ template<class Decoder> static Optional<DrawGlyphs> decode(Decoder&); > >-private: > DrawGlyphs(const Font&, const GlyphBufferGlyph*, const GlyphBufferAdvance*, unsigned count, const FloatPoint& localAnchor, FontSmoothingMode); > WEBCORE_EXPORT DrawGlyphs(const Font&, Vector<GlyphBufferGlyph, 128>&&, Vector<GlyphBufferAdvance, 128>&&, const FloatPoint& localAnchor, FontSmoothingMode); > >- void computeBounds(); >- >- void apply(GraphicsContext&) const override; >+ void apply(GraphicsContext&) const; > >- Optional<FloatRect> localBounds(const GraphicsContext&) const override; >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return m_bounds; } > >+private: >+ void computeBounds(); > GlyphBuffer generateGlyphBuffer() const; > >- Ref<Font> m_font; >+ RefPtr<Font> m_font; > Vector<GlyphBufferGlyph, 128> m_glyphs; > Vector<GlyphBufferAdvance, 128> m_advances; > FloatRect m_bounds; >@@ -1358,7 +1011,7 @@ private: > template<class Encoder> > void DrawGlyphs::encode(Encoder& encoder) const > { >- encoder << m_font; >+ encoder << makeRef(*m_font); > encoder << m_glyphs; > encoder << m_advances; > encoder << m_localAnchor; >@@ -1366,7 +1019,7 @@ void DrawGlyphs::encode(Encoder& encoder) const > } > > template<class Decoder> >-Optional<Ref<DrawGlyphs>> DrawGlyphs::decode(Decoder& decoder) >+Optional<DrawGlyphs> DrawGlyphs::decode(Decoder& decoder) > { > Optional<Ref<Font>> font; > decoder >> font; >@@ -1396,32 +1049,36 @@ Optional<Ref<DrawGlyphs>> DrawGlyphs::decode(Decoder& decoder) > if (!smoothingMode) > return WTF::nullopt; > >- return DrawGlyphs::create(font->get(), WTFMove(*glyphs), WTFMove(*advances), *localAnchor, *smoothingMode); >+ return {{ font->get(), WTFMove(*glyphs), WTFMove(*advances), *localAnchor, *smoothingMode }}; > } > >-class DrawImage : public DrawingItem { >+class DrawImage { > public: >- static Ref<DrawImage> create(Image& image, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& imagePaintingOptions) >+ static constexpr ItemType itemType = ItemType::DrawImage; >+ static constexpr bool isInlineItem = false; >+ static constexpr bool isDrawingItem = true; >+ >+ DrawImage(Image& image, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& imagePaintingOptions) >+ : m_image(image) >+ , m_destination(destination) >+ , m_source(source) >+ , m_imagePaintingOptions(imagePaintingOptions) > { >- return adoptRef(*new DrawImage(image, destination, source, imagePaintingOptions)); > } > >- WEBCORE_EXPORT virtual ~DrawImage(); >- > const Image& image() const { return m_image.get(); } > FloatRect source() const { return m_source; } > FloatRect destination() const { return m_destination; } > > template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<DrawImage>> decode(Decoder&); >- >-private: >- WEBCORE_EXPORT DrawImage(Image&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions&); >+ template<class Decoder> static Optional<DrawImage> decode(Decoder&); > >- void apply(GraphicsContext&) const override; >+ void apply(GraphicsContext&) const; > >- Optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_destination; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return m_destination; } > >+private: > mutable Ref<Image> m_image; // FIXME: Drawing images can cause their animations to progress. This shouldn't have to be mutable. > FloatRect m_destination; > FloatRect m_source; >@@ -1441,7 +1098,7 @@ void DrawImage::encode(Encoder& encoder) const > } > > template<class Decoder> >-Optional<Ref<DrawImage>> DrawImage::decode(Decoder& decoder) >+Optional<DrawImage> DrawImage::decode(Decoder& decoder) > { > Optional<ImageHandle> imageHandle; > decoder >> imageHandle; >@@ -1463,17 +1120,14 @@ Optional<Ref<DrawImage>> DrawImage::decode(Decoder& decoder) > if (!imagePaintingOptions) > return WTF::nullopt; > >- return DrawImage::create(*imageHandle->image, *destination, *source, *imagePaintingOptions); >+ return {{ *imageHandle->image, *destination, *source, *imagePaintingOptions }}; > } > >-class DrawTiledImage : public DrawingItem { >+class DrawTiledImage { > public: >- static Ref<DrawTiledImage> create(Image& image, const FloatRect& destination, const FloatPoint& source, const FloatSize& tileSize, const FloatSize& spacing, const ImagePaintingOptions& imagePaintingOptions) >- { >- return adoptRef(*new DrawTiledImage(image, destination, source, tileSize, spacing, imagePaintingOptions)); >- } >- >- WEBCORE_EXPORT virtual ~DrawTiledImage(); >+ static constexpr ItemType itemType = ItemType::DrawTiledImage; >+ static constexpr bool isInlineItem = false; >+ static constexpr bool isDrawingItem = true; > > const Image& image() const { return m_image.get(); } > FloatPoint source() const { return m_source; } >@@ -1482,16 +1136,25 @@ public: > FloatSize tileSize() const { return m_tileSize; } > FloatSize spacing() const { return m_spacing; } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<DrawTiledImage>> decode(Decoder&); >+ DrawTiledImage(Image& image, const FloatRect& destination, const FloatPoint& source, const FloatSize& tileSize, const FloatSize& spacing, const ImagePaintingOptions& imagePaintingOptions) >+ : m_image(image) >+ , m_destination(destination) >+ , m_source(source) >+ , m_tileSize(tileSize) >+ , m_spacing(spacing) >+ , m_imagePaintingOptions(imagePaintingOptions) >+ { >+ } > >-private: >- WEBCORE_EXPORT DrawTiledImage(Image&, const FloatRect& destination, const FloatPoint& source, const FloatSize& tileSize, const FloatSize& spacing, const ImagePaintingOptions&); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return m_destination; } > >- Optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_destination; } >+ template<class Encoder> void encode(Encoder&) const; >+ template<class Decoder> static Optional<DrawTiledImage> decode(Decoder&); > >+private: > mutable Ref<Image> m_image; // FIXME: Drawing images can cause their animations to progress. This shouldn't have to be mutable. > FloatRect m_destination; > FloatPoint m_source; >@@ -1514,7 +1177,7 @@ void DrawTiledImage::encode(Encoder& encoder) const > } > > template<class Decoder> >-Optional<Ref<DrawTiledImage>> DrawTiledImage::decode(Decoder& decoder) >+Optional<DrawTiledImage> DrawTiledImage::decode(Decoder& decoder) > { > Optional<ImageHandle> imageHandle; > decoder >> imageHandle; >@@ -1546,32 +1209,39 @@ Optional<Ref<DrawTiledImage>> DrawTiledImage::decode(Decoder& decoder) > if (!imagePaintingOptions) > return WTF::nullopt; > >- return DrawTiledImage::create(*imageHandle->image, *destination, *source, *tileSize, *spacing, *imagePaintingOptions); >+ return {{ *imageHandle->image, *destination, *source, *tileSize, *spacing, *imagePaintingOptions }}; > } > >-class DrawTiledScaledImage : public DrawingItem { >+class DrawTiledScaledImage { > public: >- static Ref<DrawTiledScaledImage> create(Image& image, const FloatRect& destination, const FloatRect& source, const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRule, const ImagePaintingOptions& imagePaintingOptions) >+ static constexpr ItemType itemType = ItemType::DrawTiledScaledImage; >+ static constexpr bool isInlineItem = false; >+ static constexpr bool isDrawingItem = true; >+ >+ DrawTiledScaledImage(Image& image, const FloatRect& destination, const FloatRect& source, const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRule, const ImagePaintingOptions& imagePaintingOptions) >+ : m_image(image) >+ , m_destination(destination) >+ , m_source(source) >+ , m_tileScaleFactor(tileScaleFactor) >+ , m_hRule(hRule) >+ , m_vRule(vRule) >+ , m_imagePaintingOptions(imagePaintingOptions) > { >- return adoptRef(*new DrawTiledScaledImage(image, destination, source, tileScaleFactor, hRule, vRule, imagePaintingOptions)); > } > >- WEBCORE_EXPORT virtual ~DrawTiledScaledImage(); >- > const Image& image() const { return m_image.get(); } > FloatRect source() const { return m_source; } > FloatRect destination() const { return m_destination; } > > template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<DrawTiledScaledImage>> decode(Decoder&); >+ template<class Decoder> static Optional<DrawTiledScaledImage> decode(Decoder&); > >-private: >- WEBCORE_EXPORT DrawTiledScaledImage(Image&, const FloatRect& destination, const FloatRect& source, const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRule, const ImagePaintingOptions&); >- >- void apply(GraphicsContext&) const override; >+ void apply(GraphicsContext&) const; > >- Optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_destination; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return m_destination; } > >+private: > mutable Ref<Image> m_image; // FIXME: Drawing images can cause their animations to progress. This shouldn't have to be mutable. > FloatRect m_destination; > FloatRect m_source; >@@ -1596,7 +1266,7 @@ void DrawTiledScaledImage::encode(Encoder& encoder) const > } > > template<class Decoder> >-Optional<Ref<DrawTiledScaledImage>> DrawTiledScaledImage::decode(Decoder& decoder) >+Optional<DrawTiledScaledImage> DrawTiledScaledImage::decode(Decoder& decoder) > { > Optional<ImageHandle> imageHandle; > decoder >> imageHandle; >@@ -1631,18 +1301,23 @@ Optional<Ref<DrawTiledScaledImage>> DrawTiledScaledImage::decode(Decoder& decode > if (!imagePaintingOptions) > return WTF::nullopt; > >- return DrawTiledScaledImage::create(*imageHandle->image, *destination, *source, *tileScaleFactor, hRule, vRule, *imagePaintingOptions); >+ return {{ *imageHandle->image, *destination, *source, *tileScaleFactor, hRule, vRule, *imagePaintingOptions }}; > } > >-class DrawImageBuffer : public DrawingItem { >+class DrawImageBuffer { > public: >- static Ref<DrawImageBuffer> create(RenderingResourceIdentifier renderingResourceIdentifier, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& options) >+ static constexpr ItemType itemType = ItemType::DrawImageBuffer; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = true; >+ >+ DrawImageBuffer(RenderingResourceIdentifier renderingResourceIdentifier, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) >+ : m_renderingResourceIdentifier(renderingResourceIdentifier) >+ , m_destinationRect(destRect) >+ , m_srcRect(srcRect) >+ , m_options(options) > { >- return adoptRef(*new DrawImageBuffer(renderingResourceIdentifier, destination, source, options)); > } > >- WEBCORE_EXPORT virtual ~DrawImageBuffer(); >- > RenderingResourceIdentifier renderingResourceIdentifier() const { return m_renderingResourceIdentifier; } > FloatRect source() const { return m_srcRect; } > FloatRect destinationRect() const { return m_destinationRect; } >@@ -1653,76 +1328,38 @@ public: > template<class Encoder> void encode(Encoder&) const; > template<class Decoder> static Optional<Ref<DrawImageBuffer>> decode(Decoder&); > >-private: >- WEBCORE_EXPORT DrawImageBuffer(RenderingResourceIdentifier, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions&); >- >- void apply(GraphicsContext&) const override; >+ void apply(GraphicsContext&) const; > >- Optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_destinationRect; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return m_destinationRect; } > >+private: > RenderingResourceIdentifier m_renderingResourceIdentifier; > FloatRect m_destinationRect; > FloatRect m_srcRect; > ImagePaintingOptions m_options; > }; > >-template<class Encoder> >-void DrawImageBuffer::encode(Encoder& encoder) const >-{ >- encoder << m_renderingResourceIdentifier; >- encoder << m_destinationRect; >- encoder << m_srcRect; >- encoder << m_options; >-} >- >-template<class Decoder> >-Optional<Ref<DrawImageBuffer>> DrawImageBuffer::decode(Decoder& decoder) >-{ >- Optional<RenderingResourceIdentifier> renderingResourceIdentifier; >- decoder >> renderingResourceIdentifier; >- if (!renderingResourceIdentifier) >- return WTF::nullopt; >- >- Optional<FloatRect> destination; >- decoder >> destination; >- if (!destination) >- return WTF::nullopt; >- >- Optional<FloatRect> source; >- decoder >> source; >- if (!source) >- return WTF::nullopt; >- >- Optional<ImagePaintingOptions> options; >- decoder >> options; >- if (!options) >- return WTF::nullopt; >+class DrawNativeImage { >+public: >+ static constexpr ItemType itemType = ItemType::DrawNativeImage; >+ static constexpr bool isInlineItem = false; >+ static constexpr bool isDrawingItem = true; > >- return DrawImageBuffer::create(*renderingResourceIdentifier, *destination, *source, *options); >-} >+ WEBCORE_EXPORT DrawNativeImage(const NativeImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&); > >-class DrawNativeImage : public DrawingItem { >-public: >- static Ref<DrawNativeImage> create(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) >- { >- return adoptRef(*new DrawNativeImage(image, imageSize, destRect, srcRect, options)); >- } >+ const FloatRect& source() const { return m_srcRect; } >+ const FloatRect& destinationRect() const { return m_destinationRect; } > >- WEBCORE_EXPORT virtual ~DrawNativeImage(); >+ void apply(GraphicsContext&) const; > >- FloatRect source() const { return m_srcRect; } >- FloatRect destinationRect() const { return m_destinationRect; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return m_destinationRect; } > > template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<DrawNativeImage>> decode(Decoder&); >+ template<class Decoder> static Optional<DrawNativeImage> decode(Decoder&); > > private: >- WEBCORE_EXPORT DrawNativeImage(const NativeImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&); >- >- void apply(GraphicsContext&) const override; >- >- Optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_destinationRect; } >- > NativeImagePtr m_image; > FloatSize m_imageSize; > FloatRect m_destinationRect; >@@ -1741,7 +1378,7 @@ void DrawNativeImage::encode(Encoder& encoder) const > } > > template<class Decoder> >-Optional<Ref<DrawNativeImage>> DrawNativeImage::decode(Decoder& decoder) >+Optional<DrawNativeImage> DrawNativeImage::decode(Decoder& decoder) > { > Optional<NativeImagePtr> image; > decoder >> image; >@@ -1768,17 +1405,16 @@ Optional<Ref<DrawNativeImage>> DrawNativeImage::decode(Decoder& decoder) > if (!options) > return WTF::nullopt; > >- return DrawNativeImage::create(*image, *imageSize, *destinationRect, *srcRect, *options); >+ return {{ *image, *imageSize, *destinationRect, *srcRect, *options }}; > } > >-class DrawPattern : public DrawingItem { >+class DrawPattern { > public: >- static Ref<DrawPattern> create(Image& image, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options) >- { >- return adoptRef(*new DrawPattern(image, destRect, tileRect, patternTransform, phase, spacing, options)); >- } >+ static constexpr ItemType itemType = ItemType::DrawPattern; >+ static constexpr bool isInlineItem = false; >+ static constexpr bool isDrawingItem = true; > >- WEBCORE_EXPORT virtual ~DrawPattern(); >+ WEBCORE_EXPORT DrawPattern(Image&, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& = { }); > > const Image& image() const { return m_image.get(); } > const AffineTransform& patternTransform() const { return m_patternTransform; } >@@ -1787,16 +1423,15 @@ public: > FloatPoint phase() const { return m_phase; } > FloatSize spacing() const { return m_spacing; } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<DrawPattern>> decode(Decoder&); >- >-private: >- WEBCORE_EXPORT DrawPattern(Image&, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& = { }); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return m_destination; } > >- Optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_destination; } >+ template<class Encoder> void encode(Encoder&) const; >+ template<class Decoder> static Optional<DrawPattern> decode(Decoder&); > >+private: > mutable Ref<Image> m_image; // FIXME: Drawing images can cause their animations to progress. This shouldn't have to be mutable. > AffineTransform m_patternTransform; > FloatRect m_tileRect; >@@ -1821,7 +1456,7 @@ void DrawPattern::encode(Encoder& encoder) const > } > > template<class Decoder> >-Optional<Ref<DrawPattern>> DrawPattern::decode(Decoder& decoder) >+Optional<DrawPattern> DrawPattern::decode(Decoder& decoder) > { > Optional<ImageHandle> imageHandle; > decoder >> imageHandle; >@@ -1858,182 +1493,100 @@ Optional<Ref<DrawPattern>> DrawPattern::decode(Decoder& decoder) > if (!options) > return WTF::nullopt; > >- return DrawPattern::create(*imageHandle->image, *destination, *tileRect, *patternTransform, *phase, *spacing, *options); >+ return {{ *imageHandle->image, *destination, *tileRect, *patternTransform, *phase, *spacing, *options }}; > } > >-// Is DrawingItem because the size of the transparency layer is implicitly the clip bounds. >-class BeginTransparencyLayer : public DrawingItem { >+class BeginTransparencyLayer { > public: >- static Ref<BeginTransparencyLayer> create(float opacity) >+ static constexpr ItemType itemType = ItemType::BeginTransparencyLayer; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = true; // Is drawing item because the size of the transparency layer is implicitly the clip bounds. >+ >+ BeginTransparencyLayer(float opacity) >+ : m_opacity(opacity) > { >- return adoptRef(*new BeginTransparencyLayer(opacity)); > } > >- WEBCORE_EXPORT virtual ~BeginTransparencyLayer(); >- > float opacity() const { return m_opacity; } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<BeginTransparencyLayer>> decode(Decoder&); >- >-private: >- WEBCORE_EXPORT BeginTransparencyLayer(float opacity); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } > >+private: > float m_opacity; > }; > >-template<class Encoder> >-void BeginTransparencyLayer::encode(Encoder& encoder) const >-{ >- encoder << m_opacity; >-} >- >-template<class Decoder> >-Optional<Ref<BeginTransparencyLayer>> BeginTransparencyLayer::decode(Decoder& decoder) >-{ >- Optional<float> opacity; >- decoder >> opacity; >- if (!opacity) >- return WTF::nullopt; >- >- return BeginTransparencyLayer::create(*opacity); >-} >- >-class EndTransparencyLayer : public DrawingItem { >+class EndTransparencyLayer { > public: >- static Ref<EndTransparencyLayer> create() >- { >- return adoptRef(*new EndTransparencyLayer); >- } >- >- WEBCORE_EXPORT virtual ~EndTransparencyLayer(); >+ static constexpr ItemType itemType = ItemType::EndTransparencyLayer; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = true; > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<EndTransparencyLayer>> decode(Decoder&); >- >-private: >- WEBCORE_EXPORT EndTransparencyLayer(); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } > }; > >-template<class Encoder> >-void EndTransparencyLayer::encode(Encoder&) const >-{ >-} >- >-template<class Decoder> >-Optional<Ref<EndTransparencyLayer>> EndTransparencyLayer::decode(Decoder&) >-{ >- return EndTransparencyLayer::create(); >-} >- >-class DrawRect : public DrawingItem { >+class DrawRect { > public: >- static Ref<DrawRect> create(const FloatRect& rect, float borderThickness) >+ static constexpr ItemType itemType = ItemType::DrawRect; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = true; >+ >+ DrawRect(FloatRect rect, float borderThickness) >+ : m_rect(rect) >+ , m_borderThickness(borderThickness) > { >- return adoptRef(*new DrawRect(rect, borderThickness)); > } > >- WEBCORE_EXPORT virtual ~DrawRect(); >- > FloatRect rect() const { return m_rect; } > float borderThickness() const { return m_borderThickness; } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<DrawRect>> decode(Decoder&); >- >-private: >- WEBCORE_EXPORT DrawRect(const FloatRect&, float borderThickness); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >- Optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_rect; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return m_rect; } > >+private: > FloatRect m_rect; > float m_borderThickness; > }; > >-template<class Encoder> >-void DrawRect::encode(Encoder& encoder) const >-{ >- encoder << m_rect; >- encoder << m_borderThickness; >-} >- >-template<class Decoder> >-Optional<Ref<DrawRect>> DrawRect::decode(Decoder& decoder) >-{ >- Optional<FloatRect> rect; >- decoder >> rect; >- if (!rect) >- return WTF::nullopt; >- >- Optional<float> borderThickness; >- decoder >> borderThickness; >- if (!borderThickness) >- return WTF::nullopt; >- >- return DrawRect::create(*rect, *borderThickness); >-} >- >-class DrawLine : public DrawingItem { >+class DrawLine { > public: >- static Ref<DrawLine> create(const FloatPoint& point1, const FloatPoint& point2) >+ static constexpr ItemType itemType = ItemType::DrawLine; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = true; >+ >+ DrawLine(FloatPoint point1, FloatPoint point2) >+ : m_point1(point1) >+ , m_point2(point2) > { >- return adoptRef(*new DrawLine(point1, point2)); > } > >- WEBCORE_EXPORT virtual ~DrawLine(); >- > FloatPoint point1() const { return m_point1; } > FloatPoint point2() const { return m_point2; } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<DrawLine>> decode(Decoder&); >- >-private: >- WEBCORE_EXPORT DrawLine(const FloatPoint&, const FloatPoint&); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >- Optional<FloatRect> localBounds(const GraphicsContext&) const override; >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const; > >+private: > FloatPoint m_point1; > FloatPoint m_point2; > }; > >-template<class Encoder> >-void DrawLine::encode(Encoder& encoder) const >-{ >- encoder << m_point1; >- encoder << m_point2; >-} >- >-template<class Decoder> >-Optional<Ref<DrawLine>> DrawLine::decode(Decoder& decoder) >-{ >- Optional<FloatPoint> point1; >- decoder >> point1; >- if (!point1) >- return WTF::nullopt; >- >- Optional<FloatPoint> point2; >- decoder >> point2; >- if (!point2) >- return WTF::nullopt; >+class DrawLinesForText { >+public: >+ static constexpr ItemType itemType = ItemType::DrawLinesForText; >+ static constexpr bool isInlineItem = false; >+ static constexpr bool isDrawingItem = true; > >- return DrawLine::create(*point1, *point2); >-} >- >-class DrawLinesForText : public DrawingItem { >-public: >- static Ref<DrawLinesForText> create(const FloatPoint& blockLocation, const FloatSize& localAnchor, float thickness, const DashArray& widths, bool printing, bool doubleLines) >- { >- return adoptRef(*new DrawLinesForText(blockLocation, localAnchor, thickness, widths, printing, doubleLines)); >- } >- >- WEBCORE_EXPORT virtual ~DrawLinesForText(); >+ WEBCORE_EXPORT DrawLinesForText(const FloatPoint& blockLocation, const FloatSize& localAnchor, float thickness, const DashArray& widths, bool printing, bool doubleLines); > > void setBlockLocation(const FloatPoint& blockLocation) { m_blockLocation = blockLocation; } > const FloatPoint& blockLocation() const { return m_blockLocation; } >@@ -2044,16 +1597,15 @@ public: > bool isPrinting() const { return m_printing; } > bool doubleLines() const { return m_doubleLines; } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<DrawLinesForText>> decode(Decoder&); >- >-private: >- WEBCORE_EXPORT DrawLinesForText(const FloatPoint& blockLocation, const FloatSize& localAnchor, float thickness, const DashArray& widths, bool printing, bool doubleLines); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const; > >- Optional<FloatRect> localBounds(const GraphicsContext&) const override; >+ template<class Encoder> void encode(Encoder&) const; >+ template<class Decoder> static Optional<DrawLinesForText> decode(Decoder&); > >+private: > FloatPoint m_blockLocation; > FloatSize m_localAnchor; > DashArray m_widths; >@@ -2074,7 +1626,7 @@ void DrawLinesForText::encode(Encoder& encoder) const > } > > template<class Decoder> >-Optional<Ref<DrawLinesForText>> DrawLinesForText::decode(Decoder& decoder) >+Optional<DrawLinesForText> DrawLinesForText::decode(Decoder& decoder) > { > Optional<FloatPoint> blockLocation; > decoder >> blockLocation; >@@ -2106,119 +1658,83 @@ Optional<Ref<DrawLinesForText>> DrawLinesForText::decode(Decoder& decoder) > if (!doubleLines) > return WTF::nullopt; > >- return DrawLinesForText::create(*blockLocation, *localAnchor, *thickness, *widths, *printing, *doubleLines); >+ return {{ *blockLocation, *localAnchor, *thickness, *widths, *printing, *doubleLines }}; > } > >-class DrawDotsForDocumentMarker : public DrawingItem { >+class DrawDotsForDocumentMarker { > public: >- static Ref<DrawDotsForDocumentMarker> create(const FloatRect& rect, DocumentMarkerLineStyle style) >+ static constexpr ItemType itemType = ItemType::DrawDotsForDocumentMarker; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = true; >+ >+ DrawDotsForDocumentMarker(const FloatRect& rect, DocumentMarkerLineStyle style) >+ : m_rect(rect) >+ , m_style(style) > { >- return adoptRef(*new DrawDotsForDocumentMarker(rect, style)); > } > >- WEBCORE_EXPORT virtual ~DrawDotsForDocumentMarker(); >- > FloatRect rect() const { return m_rect; } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<DrawDotsForDocumentMarker>> decode(Decoder&); >- >-private: >- WEBCORE_EXPORT DrawDotsForDocumentMarker(const FloatRect&, DocumentMarkerLineStyle); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >- >- Optional<FloatRect> localBounds(const GraphicsContext&) const override; >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const; > >+private: > FloatRect m_rect; > DocumentMarkerLineStyle m_style; > }; > >-template<class Encoder> >-void DrawDotsForDocumentMarker::encode(Encoder& encoder) const >-{ >- encoder << m_rect; >- encoder << m_style; >-} >- >-template<class Decoder> >-Optional<Ref<DrawDotsForDocumentMarker>> DrawDotsForDocumentMarker::decode(Decoder& decoder) >-{ >- Optional<FloatRect> rect; >- decoder >> rect; >- if (!rect) >- return WTF::nullopt; >- >- Optional<DocumentMarkerLineStyle> style; >- decoder >> style; >- if (!style) >- return WTF::nullopt; >- >- return DrawDotsForDocumentMarker::create(*rect, *style); >-} >- >-class DrawEllipse : public DrawingItem { >+class DrawEllipse { > public: >- static Ref<DrawEllipse> create(const FloatRect& rect) >+ static constexpr ItemType itemType = ItemType::DrawEllipse; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = true; >+ >+ DrawEllipse(const FloatRect& rect) >+ : m_rect(rect) > { >- return adoptRef(*new DrawEllipse(rect)); > } > >- WEBCORE_EXPORT ~DrawEllipse(); >- > FloatRect rect() const { return m_rect; } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<DrawEllipse>> decode(Decoder&); >- >-private: >- WEBCORE_EXPORT DrawEllipse(const FloatRect&); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >- Optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_rect; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return m_rect; } > >+private: > FloatRect m_rect; > }; > >-template<class Encoder> >-void DrawEllipse::encode(Encoder& encoder) const >-{ >- encoder << m_rect; >-} >- >-template<class Decoder> >-Optional<Ref<DrawEllipse>> DrawEllipse::decode(Decoder& decoder) >-{ >- Optional<FloatRect> rect; >- decoder >> rect; >- if (!rect) >- return WTF::nullopt; >- >- return DrawEllipse::create(*rect); >-} >- >-class DrawPath : public DrawingItem { >+class DrawPath { > public: >- static Ref<DrawPath> create(const Path& path) >+ static constexpr ItemType itemType = ItemType::DrawPath; >+ static constexpr bool isInlineItem = false; >+ static constexpr bool isDrawingItem = true; >+ >+ DrawPath(const Path& path) >+ : m_path(path) > { >- return adoptRef(*new DrawPath(path)); > } > >- WEBCORE_EXPORT virtual ~DrawPath(); >+ DrawPath(Path&& path) >+ : m_path(WTFMove(path)) >+ { >+ } > > const Path& path() const { return m_path; } > > template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<DrawPath>> decode(Decoder&); >+ template<class Decoder> static Optional<DrawPath> decode(Decoder&); > >-private: >- WEBCORE_EXPORT DrawPath(const Path&); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return m_path.fastBoundingRect(); } > >- Optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_path.fastBoundingRect(); } >- >- const Path m_path; >+private: >+ Path m_path; > }; > > template<class Encoder> >@@ -2228,24 +1744,37 @@ void DrawPath::encode(Encoder& encoder) const > } > > template<class Decoder> >-Optional<Ref<DrawPath>> DrawPath::decode(Decoder& decoder) >+Optional<DrawPath> DrawPath::decode(Decoder& decoder) > { > Optional<Path> path; > decoder >> path; > if (!path) > return WTF::nullopt; > >- return DrawPath::create(*path); >+ return {{ WTFMove(*path) }}; > } > >-class DrawFocusRingPath : public DrawingItem { >+class DrawFocusRingPath { > public: >- static Ref<DrawFocusRingPath> create(const Path& path, float width, float offset, const Color& color) >+ static constexpr ItemType itemType = ItemType::DrawFocusRingPath; >+ static constexpr bool isInlineItem = false; >+ static constexpr bool isDrawingItem = true; >+ >+ DrawFocusRingPath(Path&& path, float width, float offset, Color color) >+ : m_path(WTFMove(path)) >+ , m_width(width) >+ , m_offset(offset) >+ , m_color(color) > { >- return adoptRef(*new DrawFocusRingPath(path, width, offset, color)); > } > >- WEBCORE_EXPORT virtual ~DrawFocusRingPath(); >+ DrawFocusRingPath(const Path& path, float width, float offset, Color color) >+ : m_path(path) >+ , m_width(width) >+ , m_offset(offset) >+ , m_color(color) >+ { >+ } > > const Path& path() const { return m_path; } > float width() const { return m_width; } >@@ -2253,16 +1782,15 @@ public: > const Color& color() const { return m_color; } > > template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<DrawFocusRingPath>> decode(Decoder&); >- >-private: >- WEBCORE_EXPORT DrawFocusRingPath(const Path&, float width, float offset, const Color&); >+ template<class Decoder> static Optional<DrawFocusRingPath> decode(Decoder&); > >- void apply(GraphicsContext&) const override; >+ void apply(GraphicsContext&) const; > >- Optional<FloatRect> localBounds(const GraphicsContext&) const override; >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const; > >- const Path m_path; >+private: >+ Path m_path; > float m_width; > float m_offset; > Color m_color; >@@ -2278,7 +1806,7 @@ void DrawFocusRingPath::encode(Encoder& encoder) const > } > > template<class Decoder> >-Optional<Ref<DrawFocusRingPath>> DrawFocusRingPath::decode(Decoder& decoder) >+Optional<DrawFocusRingPath> DrawFocusRingPath::decode(Decoder& decoder) > { > Optional<Path> path; > decoder >> path; >@@ -2300,33 +1828,31 @@ Optional<Ref<DrawFocusRingPath>> DrawFocusRingPath::decode(Decoder& decoder) > if (!color) > return WTF::nullopt; > >- return DrawFocusRingPath::create(*path, *width, *offset, *color); >+ return {{ WTFMove(*path), *width, *offset, *color }}; > } > >-class DrawFocusRingRects : public DrawingItem { >+class DrawFocusRingRects { > public: >- static Ref<DrawFocusRingRects> create(const Vector<FloatRect>& rects, float width, float offset, const Color& color) >- { >- return adoptRef(*new DrawFocusRingRects(rects, width, offset, color)); >- } >+ static constexpr ItemType itemType = ItemType::DrawFocusRingRects; >+ static constexpr bool isInlineItem = false; >+ static constexpr bool isDrawingItem = true; > >- WEBCORE_EXPORT virtual ~DrawFocusRingRects(); >+ WEBCORE_EXPORT DrawFocusRingRects(const Vector<FloatRect>&, float width, float offset, const Color&); > > const Vector<FloatRect> rects() const { return m_rects; } > float width() const { return m_width; } > float offset() const { return m_offset; } > const Color& color() const { return m_color; } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<DrawFocusRingRects>> decode(Decoder&); >+ void apply(GraphicsContext&) const; > >-private: >- WEBCORE_EXPORT DrawFocusRingRects(const Vector<FloatRect>&, float width, float offset, const Color&); >- >- void apply(GraphicsContext&) const override; >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const; > >- Optional<FloatRect> localBounds(const GraphicsContext&) const override; >+ template<class Encoder> void encode(Encoder&) const; >+ template<class Decoder> static Optional<DrawFocusRingRects> decode(Decoder&); > >+private: > Vector<FloatRect> m_rects; > float m_width; > float m_offset; >@@ -2343,7 +1869,7 @@ void DrawFocusRingRects::encode(Encoder& encoder) const > } > > template<class Decoder> >-Optional<Ref<DrawFocusRingRects>> DrawFocusRingRects::decode(Decoder& decoder) >+Optional<DrawFocusRingRects> DrawFocusRingRects::decode(Decoder& decoder) > { > Optional<Vector<FloatRect>> rects; > decoder >> rects; >@@ -2365,71 +1891,55 @@ Optional<Ref<DrawFocusRingRects>> DrawFocusRingRects::decode(Decoder& decoder) > if (!color) > return WTF::nullopt; > >- return DrawFocusRingRects::create(*rects, *width, *offset, *color); >+ return {{ *rects, *width, *offset, *color }}; > } > >-class FillRect : public DrawingItem { >+class FillRect { > public: >- static Ref<FillRect> create(const FloatRect& rect) >+ static constexpr ItemType itemType = ItemType::FillRect; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = true; >+ >+ FillRect(const FloatRect& rect) >+ : m_rect(rect) > { >- return adoptRef(*new FillRect(rect)); > } > >- WEBCORE_EXPORT virtual ~FillRect(); >+ const FloatRect& rect() const { return m_rect; } > >- FloatRect rect() const { return m_rect; } >+ void apply(GraphicsContext&) const; > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<FillRect>> decode(Decoder&); >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return m_rect; } > > private: >- WEBCORE_EXPORT FillRect(const FloatRect&); >- >- void apply(GraphicsContext&) const override; >- Optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_rect; } >- > FloatRect m_rect; > }; > >-template<class Encoder> >-void FillRect::encode(Encoder& encoder) const >-{ >- encoder << m_rect; >-} >- >-template<class Decoder> >-Optional<Ref<FillRect>> FillRect::decode(Decoder& decoder) >-{ >- Optional<FloatRect> rect; >- decoder >> rect; >- if (!rect) >- return WTF::nullopt; >- >- return FillRect::create(*rect); >-} >- >-// FIXME: Make these inherit from FillRect proper. >-class FillRectWithColor : public DrawingItem { >+class FillRectWithColor { > public: >- static Ref<FillRectWithColor> create(const FloatRect& rect, const Color& color) >+ static constexpr ItemType itemType = ItemType::FillRectWithColor; >+ static constexpr bool isInlineItem = false; >+ static constexpr bool isDrawingItem = true; >+ >+ FillRectWithColor(const FloatRect& rect, const Color& color) >+ : m_rect(rect) >+ , m_color(color) > { >- return adoptRef(*new FillRectWithColor(rect, color)); > } > >- WEBCORE_EXPORT virtual ~FillRectWithColor(); >- > FloatRect rect() const { return m_rect; } > const Color& color() const { return m_color; } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<FillRectWithColor>> decode(Decoder&); >+ void apply(GraphicsContext&) const; > >-private: >- WEBCORE_EXPORT FillRectWithColor(const FloatRect&, const Color&); >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return m_rect; } > >- void apply(GraphicsContext&) const override; >- Optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_rect; } >+ template<class Encoder> void encode(Encoder&) const; >+ template<class Decoder> static Optional<FillRectWithColor> decode(Decoder&); > >+private: > FloatRect m_rect; > Color m_color; > }; >@@ -2442,7 +1952,7 @@ void FillRectWithColor::encode(Encoder& encoder) const > } > > template<class Decoder> >-Optional<Ref<FillRectWithColor>> FillRectWithColor::decode(Decoder& decoder) >+Optional<FillRectWithColor> FillRectWithColor::decode(Decoder& decoder) > { > Optional<FloatRect> rect; > decoder >> rect; >@@ -2454,29 +1964,29 @@ Optional<Ref<FillRectWithColor>> FillRectWithColor::decode(Decoder& decoder) > if (!color) > return WTF::nullopt; > >- return FillRectWithColor::create(*rect, *color); >+ return {{ *rect, *color }}; > } > >-class FillRectWithGradient : public DrawingItem { >+class FillRectWithGradient { > public: >- static Ref<FillRectWithGradient> create(const FloatRect& rect, Gradient& gradient) >- { >- return adoptRef(*new FillRectWithGradient(rect, gradient)); >- } >+ static constexpr ItemType itemType = ItemType::FillRectWithGradient; >+ static constexpr bool isInlineItem = false; >+ static constexpr bool isDrawingItem = true; > >- WEBCORE_EXPORT virtual ~FillRectWithGradient(); >+ WEBCORE_EXPORT FillRectWithGradient(const FloatRect&, Gradient&); > >- FloatRect rect() const { return m_rect; } >+ const FloatRect& rect() const { return m_rect; } >+ const Gradient& gradient() const { return m_gradient.get(); } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<FillRectWithGradient>> decode(Decoder&); >+ void apply(GraphicsContext&) const; > >-private: >- WEBCORE_EXPORT FillRectWithGradient(const FloatRect&, Gradient&); >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return m_rect; } > >- void apply(GraphicsContext&) const override; >- Optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_rect; } >+ template<class Encoder> void encode(Encoder&) const; >+ template<class Decoder> static Optional<FillRectWithGradient> decode(Decoder&); > >+private: > FloatRect m_rect; > mutable Ref<Gradient> m_gradient; // FIXME: Make this not mutable > }; >@@ -2489,7 +1999,7 @@ void FillRectWithGradient::encode(Encoder& encoder) const > } > > template<class Decoder> >-Optional<Ref<FillRectWithGradient>> FillRectWithGradient::decode(Decoder& decoder) >+Optional<FillRectWithGradient> FillRectWithGradient::decode(Decoder& decoder) > { > Optional<FloatRect> rect; > decoder >> rect; >@@ -2500,32 +2010,37 @@ Optional<Ref<FillRectWithGradient>> FillRectWithGradient::decode(Decoder& decode > if (!gradient) > return WTF::nullopt; > >- return FillRectWithGradient::create(*rect, gradient->get()); >+ return {{ *rect, gradient->get() }}; > } > >-class FillCompositedRect : public DrawingItem { >+class FillCompositedRect { > public: >- static Ref<FillCompositedRect> create(const FloatRect& rect, const Color& color, CompositeOperator op, BlendMode blendMode) >+ static constexpr ItemType itemType = ItemType::FillCompositedRect; >+ static constexpr bool isInlineItem = false; >+ static constexpr bool isDrawingItem = true; >+ >+ FillCompositedRect(const FloatRect& rect, const Color& color, CompositeOperator op, BlendMode blendMode) >+ : m_rect(rect) >+ , m_color(color) >+ , m_op(op) >+ , m_blendMode(blendMode) > { >- return adoptRef(*new FillCompositedRect(rect, color, op, blendMode)); > } > >- WEBCORE_EXPORT virtual ~FillCompositedRect(); >- > FloatRect rect() const { return m_rect; } > const Color& color() const { return m_color; } > CompositeOperator compositeOperator() const { return m_op; } > BlendMode blendMode() const { return m_blendMode; } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<FillCompositedRect>> decode(Decoder&); >+ void apply(GraphicsContext&) const; > >-private: >- WEBCORE_EXPORT FillCompositedRect(const FloatRect&, const Color&, CompositeOperator, BlendMode); >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return m_rect; } > >- void apply(GraphicsContext&) const override; >- Optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_rect; } >+ template<class Encoder> void encode(Encoder&) const; >+ template<class Decoder> static Optional<FillCompositedRect> decode(Decoder&); > >+private: > FloatRect m_rect; > Color m_color; > CompositeOperator m_op; >@@ -2542,7 +2057,7 @@ void FillCompositedRect::encode(Encoder& encoder) const > } > > template<class Decoder> >-Optional<Ref<FillCompositedRect>> FillCompositedRect::decode(Decoder& decoder) >+Optional<FillCompositedRect> FillCompositedRect::decode(Decoder& decoder) > { > Optional<FloatRect> rect; > decoder >> rect; >@@ -2564,31 +2079,35 @@ Optional<Ref<FillCompositedRect>> FillCompositedRect::decode(Decoder& decoder) > if (!blendMode) > return WTF::nullopt; > >- return FillCompositedRect::create(*rect, *color, *op, *blendMode); >+ return {{ *rect, *color, *op, *blendMode }}; > } > >-class FillRoundedRect : public DrawingItem { >+class FillRoundedRect { > public: >- static Ref<FillRoundedRect> create(const FloatRoundedRect& rect, const Color& color, BlendMode blendMode) >+ static constexpr ItemType itemType = ItemType::FillRoundedRect; >+ static constexpr bool isInlineItem = false; >+ static constexpr bool isDrawingItem = true; >+ >+ FillRoundedRect(const FloatRoundedRect& rect, const Color& color, BlendMode blendMode) >+ : m_rect(rect) >+ , m_color(color) >+ , m_blendMode(blendMode) > { >- return adoptRef(*new FillRoundedRect(rect, color, blendMode)); > } > >- WEBCORE_EXPORT virtual ~FillRoundedRect(); >- > const FloatRoundedRect& roundedRect() const { return m_rect; } > const Color& color() const { return m_color; } > BlendMode blendMode() const { return m_blendMode; } > > template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<FillRoundedRect>> decode(Decoder&); >+ template<class Decoder> static Optional<FillRoundedRect> decode(Decoder&); > >-private: >- WEBCORE_EXPORT FillRoundedRect(const FloatRoundedRect&, const Color&, BlendMode); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >- Optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_rect.rect(); } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return m_rect.rect(); } > >+private: > FloatRoundedRect m_rect; > Color m_color; > BlendMode m_blendMode; >@@ -2603,7 +2122,7 @@ void FillRoundedRect::encode(Encoder& encoder) const > } > > template<class Decoder> >-Optional<Ref<FillRoundedRect>> FillRoundedRect::decode(Decoder& decoder) >+Optional<FillRoundedRect> FillRoundedRect::decode(Decoder& decoder) > { > Optional<FloatRoundedRect> rect; > decoder >> rect; >@@ -2620,31 +2139,35 @@ Optional<Ref<FillRoundedRect>> FillRoundedRect::decode(Decoder& decoder) > if (!blendMode) > return WTF::nullopt; > >- return FillRoundedRect::create(*rect, *color, *blendMode); >+ return {{ *rect, *color, *blendMode }}; > } > >-class FillRectWithRoundedHole : public DrawingItem { >+class FillRectWithRoundedHole { > public: >- static Ref<FillRectWithRoundedHole> create(const FloatRect& rect, const FloatRoundedRect& roundedHoleRect, const Color& color) >+ static constexpr ItemType itemType = ItemType::FillRectWithRoundedHole; >+ static constexpr bool isInlineItem = false; >+ static constexpr bool isDrawingItem = true; >+ >+ FillRectWithRoundedHole(const FloatRect& rect, const FloatRoundedRect& roundedHoleRect, const Color& color) >+ : m_rect(rect) >+ , m_roundedHoleRect(roundedHoleRect) >+ , m_color(color) > { >- return adoptRef(*new FillRectWithRoundedHole(rect, roundedHoleRect, color)); > } > >- WEBCORE_EXPORT virtual ~FillRectWithRoundedHole(); >- > const FloatRect& rect() const { return m_rect; } > const FloatRoundedRect& roundedHoleRect() const { return m_roundedHoleRect; } > const Color& color() const { return m_color; } > > template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<FillRectWithRoundedHole>> decode(Decoder&); >+ template<class Decoder> static Optional<FillRectWithRoundedHole> decode(Decoder&); > >-private: >- WEBCORE_EXPORT FillRectWithRoundedHole(const FloatRect&, const FloatRoundedRect&, const Color&); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >- Optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_rect; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return m_rect; } > >+private: > FloatRect m_rect; > FloatRoundedRect m_roundedHoleRect; > Color m_color; >@@ -2659,7 +2182,7 @@ void FillRectWithRoundedHole::encode(Encoder& encoder) const > } > > template<class Decoder> >-Optional<Ref<FillRectWithRoundedHole>> FillRectWithRoundedHole::decode(Decoder& decoder) >+Optional<FillRectWithRoundedHole> FillRectWithRoundedHole::decode(Decoder& decoder) > { > Optional<FloatRect> rect; > decoder >> rect; >@@ -2676,74 +2199,63 @@ Optional<Ref<FillRectWithRoundedHole>> FillRectWithRoundedHole::decode(Decoder& > if (!color) > return WTF::nullopt; > >- return FillRectWithRoundedHole::create(*rect, *roundedHoleRect, *color); >+ return {{ *rect, *roundedHoleRect, *color }}; > } > > #if ENABLE(INLINE_PATH_DATA) > >-class FillInlinePath : public DrawingItem { >+class FillInlinePath { > public: >- static Ref<FillInlinePath> create(const InlinePathData& pathData) >+ static constexpr ItemType itemType = ItemType::FillInlinePath; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = true; >+ >+ FillInlinePath(const InlinePathData& pathData) >+ : m_pathData(pathData) > { >- return adoptRef(*new FillInlinePath(pathData)); > } > >- WEBCORE_EXPORT virtual ~FillInlinePath(); >- > Path path() const { return Path::from(m_pathData); } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<FillInlinePath>> decode(Decoder&); >- >-private: >- WEBCORE_EXPORT FillInlinePath(const InlinePathData&); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >- Optional<FloatRect> localBounds(const GraphicsContext&) const override { return path().fastBoundingRect(); } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return path().fastBoundingRect(); } > >+private: > InlinePathData m_pathData; > }; > >-template<class Encoder> >-void FillInlinePath::encode(Encoder& encoder) const >-{ >- encoder << m_pathData; >-} >- >-template<class Decoder> >-Optional<Ref<FillInlinePath>> FillInlinePath::decode(Decoder& decoder) >-{ >- Optional<InlinePathData> pathData; >- decoder >> pathData; >- if (!pathData) >- return WTF::nullopt; >- >- return FillInlinePath::create(WTFMove(*pathData)); >-} >- > #endif // ENABLE(INLINE_PATH_DATA) > >-class FillPath : public DrawingItem { >+class FillPath { > public: >- static Ref<FillPath> create(const Path& path) >+ static constexpr ItemType itemType = ItemType::FillPath; >+ static constexpr bool isInlineItem = false; >+ static constexpr bool isDrawingItem = true; >+ >+ FillPath(Path&& path) >+ : m_path(WTFMove(path)) > { >- return adoptRef(*new FillPath(path)); > } > >- WEBCORE_EXPORT virtual ~FillPath(); >+ FillPath(const Path& path) >+ : m_path(path) >+ { >+ } > > const Path& path() const { return m_path; } > > template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<FillPath>> decode(Decoder&); >+ template<class Decoder> static Optional<FillPath> decode(Decoder&); > >-private: >- WEBCORE_EXPORT FillPath(const Path&); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >- Optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_path.fastBoundingRect(); } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return m_path.fastBoundingRect(); } > >- const Path m_path; >+private: >+ Path m_path; > }; > > template<class Encoder> >@@ -2753,90 +2265,65 @@ void FillPath::encode(Encoder& encoder) const > } > > template<class Decoder> >-Optional<Ref<FillPath>> FillPath::decode(Decoder& decoder) >+Optional<FillPath> FillPath::decode(Decoder& decoder) > { > Optional<Path> path; > decoder >> path; > if (!path) > return WTF::nullopt; > >- return FillPath::create(*path); >+ return {{ WTFMove(*path) }}; > } > >-class FillEllipse : public DrawingItem { >+class FillEllipse { > public: >- static Ref<FillEllipse> create(const FloatRect& rect) >+ static constexpr ItemType itemType = ItemType::FillEllipse; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = true; >+ >+ FillEllipse(const FloatRect& rect) >+ : m_rect(rect) > { >- return adoptRef(*new FillEllipse(rect)); > } > >- WEBCORE_EXPORT virtual ~FillEllipse(); >- > FloatRect rect() const { return m_rect; } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<FillEllipse>> decode(Decoder&); >- >-private: >- WEBCORE_EXPORT FillEllipse(const FloatRect&); >- >- void apply(GraphicsContext&) const override; >+ void apply(GraphicsContext&) const; > >- Optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_rect; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return m_rect; } > >+private: > FloatRect m_rect; > }; > >-template<class Encoder> >-void FillEllipse::encode(Encoder& encoder) const >-{ >- encoder << m_rect; >-} >- >-template<class Decoder> >-Optional<Ref<FillEllipse>> FillEllipse::decode(Decoder& decoder) >-{ >- Optional<FloatRect> rect; >- decoder >> rect; >- if (!rect) >- return WTF::nullopt; >- >- return FillEllipse::create(*rect); >-} >- >-class PutImageData : public DrawingItem { >+class PutImageData { > public: >- static Ref<PutImageData> create(AlphaPremultiplication inputFormat, const ImageData& imageData, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) >- { >- return adoptRef(*new PutImageData(inputFormat, imageData, srcRect, destPoint, destFormat)); >- } >- static Ref<PutImageData> create(AlphaPremultiplication inputFormat, Ref<ImageData>&& imageData, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) >- { >- return adoptRef(*new PutImageData(inputFormat, WTFMove(imageData), srcRect, destPoint, destFormat)); >- } >+ static constexpr ItemType itemType = ItemType::PutImageData; >+ static constexpr bool isInlineItem = false; >+ static constexpr bool isDrawingItem = true; > >- WEBCORE_EXPORT virtual ~PutImageData(); >+ WEBCORE_EXPORT PutImageData(AlphaPremultiplication inputFormat, const ImageData&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat); >+ WEBCORE_EXPORT PutImageData(AlphaPremultiplication inputFormat, Ref<ImageData>&&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat); > > AlphaPremultiplication inputFormat() const { return m_inputFormat; } >- ImageData& imageData() const { return m_imageData; } >+ ImageData& imageData() const { return *m_imageData; } > IntRect srcRect() const { return m_srcRect; } > IntPoint destPoint() const { return m_destPoint; } > AlphaPremultiplication destFormat() const { return m_destFormat; } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<PutImageData>> decode(Decoder&); >- >-private: >- WEBCORE_EXPORT PutImageData(AlphaPremultiplication inputFormat, const ImageData&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat); >- WEBCORE_EXPORT PutImageData(AlphaPremultiplication inputFormat, Ref<ImageData>&&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return {{ m_destPoint, m_srcRect.size() }}; } > >- Optional<FloatRect> globalBounds() const override { return FloatRect(m_destPoint, m_srcRect.size()); } >+ template<class Encoder> void encode(Encoder&) const; >+ template<class Decoder> static Optional<PutImageData> decode(Decoder&); > >+private: > IntRect m_srcRect; > IntPoint m_destPoint; >- Ref<ImageData> m_imageData; >+ RefPtr<ImageData> m_imageData; > AlphaPremultiplication m_inputFormat; > AlphaPremultiplication m_destFormat; > }; >@@ -2845,14 +2332,14 @@ template<class Encoder> > void PutImageData::encode(Encoder& encoder) const > { > encoder << m_inputFormat; >- encoder << m_imageData; >+ encoder << makeRef(*m_imageData); > encoder << m_srcRect; > encoder << m_destPoint; > encoder << m_destFormat; > } > > template<class Decoder> >-Optional<Ref<PutImageData>> PutImageData::decode(Decoder& decoder) >+Optional<PutImageData> PutImageData::decode(Decoder& decoder) > { > Optional<AlphaPremultiplication> inputFormat; > Optional<Ref<ImageData>> imageData; >@@ -2880,169 +2367,109 @@ Optional<Ref<PutImageData>> PutImageData::decode(Decoder& decoder) > if (!destFormat) > return WTF::nullopt; > >- return PutImageData::create(*inputFormat, WTFMove(*imageData), *srcRect, *destPoint, *destFormat); >+ return {{ *inputFormat, WTFMove(*imageData), *srcRect, *destPoint, *destFormat }}; > } > >-class PaintFrameForMedia : public DrawingItem { >+class PaintFrameForMedia { > public: >- static Ref<PaintFrameForMedia> create(MediaPlayer&, const FloatRect& destination); >+ static constexpr ItemType itemType = ItemType::PaintFrameForMedia; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = true; > >- WEBCORE_EXPORT virtual ~PaintFrameForMedia(); >+ PaintFrameForMedia(MediaPlayer&, const FloatRect& destination); > > const FloatRect& destination() const { return m_destination; } > MediaPlayerIdentifier identifier() const { return m_identifier; } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<PaintFrameForMedia>> decode(Decoder&); >+ void apply(GraphicsContext&) const; > >-private: >- WEBCORE_EXPORT static Ref<PaintFrameForMedia> create(MediaPlayerIdentifier, const FloatRect& destination); >- >- PaintFrameForMedia(MediaPlayer&, const FloatRect& destination); >- PaintFrameForMedia(MediaPlayerIdentifier, const FloatRect& destination); >- >- void apply(GraphicsContext&) const override; >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return { m_destination }; } > >+private: > MediaPlayerIdentifier m_identifier; > FloatRect m_destination; > }; > >-template<class Encoder> >-void PaintFrameForMedia::encode(Encoder& encoder) const >-{ >- encoder << m_identifier; >- encoder << m_destination; >-} >- >-template<class Decoder> >-Optional<Ref<PaintFrameForMedia>> PaintFrameForMedia::decode(Decoder& decoder) >-{ >- Optional<MediaPlayerIdentifier> identifier; >- decoder >> identifier; >- if (!identifier) >- return WTF::nullopt; >- >- Optional<FloatRect> destination; >- decoder >> destination; >- if (!destination) >- return WTF::nullopt; >- >- return PaintFrameForMedia::create(*identifier, *destination); >-} >- >-class StrokeRect : public DrawingItem { >+class StrokeRect { > public: >- static Ref<StrokeRect> create(const FloatRect& rect, float lineWidth) >+ static constexpr ItemType itemType = ItemType::StrokeRect; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = true; >+ >+ StrokeRect(const FloatRect& rect, float lineWidth) >+ : m_rect(rect) >+ , m_lineWidth(lineWidth) > { >- return adoptRef(*new StrokeRect(rect, lineWidth)); > } > >- WEBCORE_EXPORT virtual ~StrokeRect(); >- > FloatRect rect() const { return m_rect; } > float lineWidth() const { return m_lineWidth; } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<StrokeRect>> decode(Decoder&); >+ void apply(GraphicsContext&) const; > >-private: >- WEBCORE_EXPORT StrokeRect(const FloatRect&, float); >- >- void apply(GraphicsContext&) const override; >- Optional<FloatRect> localBounds(const GraphicsContext&) const override; >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const; > >+private: > FloatRect m_rect; > float m_lineWidth; > }; > >-template<class Encoder> >-void StrokeRect::encode(Encoder& encoder) const >-{ >- encoder << m_rect; >- encoder << m_lineWidth; >-} >- >-template<class Decoder> >-Optional<Ref<StrokeRect>> StrokeRect::decode(Decoder& decoder) >-{ >- Optional<FloatRect> rect; >- decoder >> rect; >- if (!rect) >- return WTF::nullopt; >- >- Optional<float> lineWidth; >- decoder >> lineWidth; >- if (!lineWidth) >- return WTF::nullopt; >- >- return StrokeRect::create(*rect, *lineWidth); >-} >- > #if ENABLE(INLINE_PATH_DATA) > >-class StrokeInlinePath : public DrawingItem { >+class StrokeInlinePath { > public: >- static Ref<StrokeInlinePath> create(const InlinePathData& pathData) >+ static constexpr ItemType itemType = ItemType::StrokeInlinePath; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = true; >+ >+ StrokeInlinePath(const InlinePathData& pathData) >+ : m_pathData(pathData) > { >- return adoptRef(*new StrokeInlinePath(pathData)); > } > >- WEBCORE_EXPORT virtual ~StrokeInlinePath(); >- > Path path() const { return Path::from(m_pathData); } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<StrokeInlinePath>> decode(Decoder&); >+ void apply(GraphicsContext&) const; > >-private: >- WEBCORE_EXPORT StrokeInlinePath(const InlinePathData&); >- >- void apply(GraphicsContext&) const override; >- Optional<FloatRect> localBounds(const GraphicsContext&) const override; >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const; > >+private: > InlinePathData m_pathData; > }; > >-template<class Encoder> >-void StrokeInlinePath::encode(Encoder& encoder) const >-{ >- encoder << m_pathData; >-} >- >-template<class Decoder> >-Optional<Ref<StrokeInlinePath>> StrokeInlinePath::decode(Decoder& decoder) >-{ >- Optional<InlinePathData> pathData; >- decoder >> pathData; >- if (!pathData) >- return WTF::nullopt; >- >- return StrokeInlinePath::create(WTFMove(*pathData)); >-} >- > #endif // ENABLE(INLINE_PATH_DATA) > >-class StrokePath : public DrawingItem { >+class StrokePath { > public: >- static Ref<StrokePath> create(const Path& path) >+ static constexpr ItemType itemType = ItemType::StrokePath; >+ static constexpr bool isInlineItem = false; >+ static constexpr bool isDrawingItem = true; >+ >+ StrokePath(Path&& path) >+ : m_path(WTFMove(path)) > { >- return adoptRef(*new StrokePath(path)); > } > >- WEBCORE_EXPORT virtual ~StrokePath(); >+ StrokePath(const Path& path) >+ : m_path(path) >+ { >+ } > > const Path& path() const { return m_path; } > > template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<StrokePath>> decode(Decoder&); >+ template<class Decoder> static Optional<StrokePath> decode(Decoder&); > >-private: >- WEBCORE_EXPORT StrokePath(const Path&); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >- Optional<FloatRect> localBounds(const GraphicsContext&) const override; >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const; > >- const Path m_path; >+private: >+ Path m_path; > }; > > template<class Encoder> >@@ -3052,721 +2479,115 @@ void StrokePath::encode(Encoder& encoder) const > } > > template<class Decoder> >-Optional<Ref<StrokePath>> StrokePath::decode(Decoder& decoder) >+Optional<StrokePath> StrokePath::decode(Decoder& decoder) > { > Optional<Path> path; > decoder >> path; > if (!path) > return WTF::nullopt; > >- return StrokePath::create(*path); >+ return {{ WTFMove(*path) }}; > } > >-class StrokeEllipse : public DrawingItem { >+class StrokeEllipse { > public: >- static Ref<StrokeEllipse> create(const FloatRect& rect) >+ static constexpr ItemType itemType = ItemType::StrokeEllipse; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = true; >+ >+ StrokeEllipse(const FloatRect& rect) >+ : m_rect(rect) > { >- return adoptRef(*new StrokeEllipse(rect)); > } > >- WEBCORE_EXPORT ~StrokeEllipse(); >+ const FloatRect& rect() const { return m_rect; } > >- FloatRect rect() const { return m_rect; } >+ void apply(GraphicsContext&) const; > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<StrokeEllipse>> decode(Decoder&); >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const; > > private: >- WEBCORE_EXPORT StrokeEllipse(const FloatRect&); >- >- void apply(GraphicsContext&) const override; >- Optional<FloatRect> localBounds(const GraphicsContext&) const override; >- > FloatRect m_rect; > }; > >-template<class Encoder> >-void StrokeEllipse::encode(Encoder& encoder) const >-{ >- encoder << m_rect; >-} >- >-template<class Decoder> >-Optional<Ref<StrokeEllipse>> StrokeEllipse::decode(Decoder& decoder) >-{ >- Optional<FloatRect> rect; >- decoder >> rect; >- if (!rect) >- return WTF::nullopt; >- >- return StrokeEllipse::create(*rect); >-} >- >-class ClearRect : public DrawingItem { >+class ClearRect { > public: >- static Ref<ClearRect> create(const FloatRect& rect) >+ static constexpr ItemType itemType = ItemType::ClearRect; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = true; >+ >+ ClearRect(const FloatRect& rect) >+ : m_rect(rect) > { >- return adoptRef(*new ClearRect(rect)); > } > >- WEBCORE_EXPORT virtual ~ClearRect(); >+ const FloatRect& rect() const { return m_rect; } > >- FloatRect rect() const { return m_rect; } >+ void apply(GraphicsContext&) const; > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<ClearRect>> decode(Decoder&); >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return m_rect; } > > private: >- WEBCORE_EXPORT ClearRect(const FloatRect&); >- >- void apply(GraphicsContext&) const override; >- Optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_rect; } >- > FloatRect m_rect; > }; > >-template<class Encoder> >-void ClearRect::encode(Encoder& encoder) const >-{ >- encoder << m_rect; >-} >- >-template<class Decoder> >-Optional<Ref<ClearRect>> ClearRect::decode(Decoder& decoder) >-{ >- Optional<FloatRect> rect; >- decoder >> rect; >- if (!rect) >- return WTF::nullopt; >- >- return ClearRect::create(*rect); >-} >- > #if USE(CG) >-class ApplyStrokePattern : public Item { >-public: >- static Ref<ApplyStrokePattern> create() >- { >- return adoptRef(*new ApplyStrokePattern); >- } >- >- WEBCORE_EXPORT virtual ~ApplyStrokePattern(); > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<ApplyStrokePattern>> decode(Decoder&); >+class ApplyStrokePattern { >+public: >+ static constexpr ItemType itemType = ItemType::ApplyStrokePattern; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = false; > >-private: >- WEBCORE_EXPORT ApplyStrokePattern(); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } > }; > >-template<class Encoder> >-void ApplyStrokePattern::encode(Encoder&) const >-{ >-} >- >-template<class Decoder> >-Optional<Ref<ApplyStrokePattern>> ApplyStrokePattern::decode(Decoder&) >-{ >- return ApplyStrokePattern::create(); >-} >- >-class ApplyFillPattern : public Item { >+class ApplyFillPattern { > public: >- static Ref<ApplyFillPattern> create() >- { >- return adoptRef(*new ApplyFillPattern); >- } >- >- WEBCORE_EXPORT virtual ~ApplyFillPattern(); >+ static constexpr ItemType itemType = ItemType::ApplyFillPattern; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = false; > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<ApplyFillPattern>> decode(Decoder&); >- >-private: >- WEBCORE_EXPORT ApplyFillPattern(); >+ void apply(GraphicsContext&) const; > >- void apply(GraphicsContext&) const override; >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } > }; > >-template<class Encoder> >-void ApplyFillPattern::encode(Encoder&) const >-{ >-} >- >-template<class Decoder> >-Optional<Ref<ApplyFillPattern>> ApplyFillPattern::decode(Decoder&) >-{ >- return ApplyFillPattern::create(); >-} > #endif > >-class ApplyDeviceScaleFactor : public Item { >+class ApplyDeviceScaleFactor { > public: >- static Ref<ApplyDeviceScaleFactor> create(float scaleFactor) >+ static constexpr ItemType itemType = ItemType::ApplyDeviceScaleFactor; >+ static constexpr bool isInlineItem = true; >+ static constexpr bool isDrawingItem = false; >+ >+ ApplyDeviceScaleFactor(float scaleFactor) >+ : m_scaleFactor(scaleFactor) > { >- return adoptRef(*new ApplyDeviceScaleFactor(scaleFactor)); > } > >- WEBCORE_EXPORT virtual ~ApplyDeviceScaleFactor(); >- > float scaleFactor() const { return m_scaleFactor; } > >- template<class Encoder> void encode(Encoder&) const; >- template<class Decoder> static Optional<Ref<ApplyDeviceScaleFactor>> decode(Decoder&); >+ void apply(GraphicsContext&) const; > >-private: >- WEBCORE_EXPORT ApplyDeviceScaleFactor(float scaleFactor); >+ Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; } >+ Optional<FloatRect> globalBounds() const { return WTF::nullopt; } > >- void apply(GraphicsContext&) const override; >- >- float m_scaleFactor; >+private: >+ float m_scaleFactor { 1 }; > }; > >-template<class Encoder> >-void ApplyDeviceScaleFactor::encode(Encoder& encoder) const >-{ >- encoder << m_scaleFactor; >-} >- >-template<class Decoder> >-Optional<Ref<ApplyDeviceScaleFactor>> ApplyDeviceScaleFactor::decode(Decoder& decoder) >-{ >- Optional<float> scaleFactor; >- decoder >> scaleFactor; >- if (!scaleFactor) >- return WTF::nullopt; >- >- return ApplyDeviceScaleFactor::create(*scaleFactor); >-} >- >- >-WTF::TextStream& operator<<(WTF::TextStream&, const Item&); >- >-template<class Encoder> >-void Item::encode(Encoder& encoder) const >-{ >- encoder << m_type; >- >- switch (m_type) { >- case ItemType::Save: >- encoder << downcast<Save>(*this); >- break; >- case ItemType::Restore: >- encoder << downcast<Restore>(*this); >- break; >- case ItemType::Translate: >- encoder << downcast<Translate>(*this); >- break; >- case ItemType::Rotate: >- encoder << downcast<Rotate>(*this); >- break; >- case ItemType::Scale: >- encoder << downcast<Scale>(*this); >- break; >- case ItemType::SetCTM: >- encoder << downcast<SetCTM>(*this); >- break; >- case ItemType::ConcatenateCTM: >- encoder << downcast<ConcatenateCTM>(*this); >- break; >- case ItemType::SetInlineFillGradient: >- encoder << downcast<SetInlineFillGradient>(*this); >- break; >- case ItemType::SetInlineFillColor: >- encoder << downcast<SetInlineFillColor>(*this); >- break; >- case ItemType::SetInlineStrokeColor: >- encoder << downcast<SetInlineStrokeColor>(*this); >- break; >- case ItemType::SetStrokeThickness: >- encoder << downcast<SetStrokeThickness>(*this); >- break; >- case ItemType::SetState: >- encoder << downcast<SetState>(*this); >- break; >- case ItemType::SetLineCap: >- encoder << downcast<SetLineCap>(*this); >- break; >- case ItemType::SetLineDash: >- encoder << downcast<SetLineDash>(*this); >- break; >- case ItemType::SetLineJoin: >- encoder << downcast<SetLineJoin>(*this); >- break; >- case ItemType::SetMiterLimit: >- encoder << downcast<SetMiterLimit>(*this); >- break; >- case ItemType::ClearShadow: >- encoder << downcast<ClearShadow>(*this); >- break; >- case ItemType::Clip: >- encoder << downcast<Clip>(*this); >- break; >- case ItemType::ClipOut: >- encoder << downcast<ClipOut>(*this); >- break; >- case ItemType::ClipOutToPath: >- encoder << downcast<ClipOutToPath>(*this); >- break; >- case ItemType::ClipPath: >- encoder << downcast<ClipPath>(*this); >- break; >- case ItemType::ClipToDrawingCommands: >- encoder << downcast<ClipToDrawingCommands>(*this); >- break; >- case ItemType::DrawGlyphs: >- encoder << downcast<DrawGlyphs>(*this); >- break; >- case ItemType::DrawImage: >- encoder << downcast<DrawImage>(*this); >- break; >- case ItemType::DrawTiledImage: >- encoder << downcast<DrawTiledImage>(*this); >- break; >- case ItemType::DrawTiledScaledImage: >- encoder << downcast<DrawTiledScaledImage>(*this); >- break; >- case ItemType::DrawImageBuffer: >- encoder << downcast<DrawImageBuffer>(*this); >- break; >- case ItemType::DrawNativeImage: >- encoder << downcast<DrawNativeImage>(*this); >- break; >- case ItemType::DrawPattern: >- encoder << downcast<DrawPattern>(*this); >- break; >- case ItemType::DrawRect: >- encoder << downcast<DrawRect>(*this); >- break; >- case ItemType::DrawLine: >- encoder << downcast<DrawLine>(*this); >- break; >- case ItemType::DrawLinesForText: >- encoder << downcast<DrawLinesForText>(*this); >- break; >- case ItemType::DrawDotsForDocumentMarker: >- encoder << downcast<DrawDotsForDocumentMarker>(*this); >- break; >- case ItemType::DrawEllipse: >- encoder << downcast<DrawEllipse>(*this); >- break; >- case ItemType::DrawPath: >- encoder << downcast<DrawPath>(*this); >- break; >- case ItemType::DrawFocusRingPath: >- encoder << downcast<DrawFocusRingPath>(*this); >- break; >- case ItemType::DrawFocusRingRects: >- encoder << downcast<DrawFocusRingRects>(*this); >- break; >- case ItemType::FillRect: >- encoder << downcast<FillRect>(*this); >- break; >- case ItemType::FillRectWithColor: >- encoder << downcast<FillRectWithColor>(*this); >- break; >- case ItemType::FillRectWithGradient: >- encoder << downcast<FillRectWithGradient>(*this); >- break; >- case ItemType::FillCompositedRect: >- encoder << downcast<FillCompositedRect>(*this); >- break; >- case ItemType::FillRoundedRect: >- encoder << downcast<FillRoundedRect>(*this); >- break; >- case ItemType::FillRectWithRoundedHole: >- encoder << downcast<FillRectWithRoundedHole>(*this); >- break; >-#if ENABLE(INLINE_PATH_DATA) >- case ItemType::FillInlinePath: >- encoder << downcast<FillInlinePath>(*this); >- break; >-#endif >- case ItemType::FillPath: >- encoder << downcast<FillPath>(*this); >- break; >- case ItemType::FillEllipse: >- encoder << downcast<FillEllipse>(*this); >- break; >- case ItemType::PutImageData: >- encoder << downcast<PutImageData>(*this); >- break; >- case ItemType::PaintFrameForMedia: >- encoder << downcast<PaintFrameForMedia>(*this); >- break; >- case ItemType::StrokeRect: >- encoder << downcast<StrokeRect>(*this); >- break; >-#if ENABLE(INLINE_PATH_DATA) >- case ItemType::StrokeInlinePath: >- encoder << downcast<StrokeInlinePath>(*this); >- break; >-#endif >- case ItemType::StrokePath: >- encoder << downcast<StrokePath>(*this); >- break; >- case ItemType::StrokeEllipse: >- encoder << downcast<StrokeEllipse>(*this); >- break; >- case ItemType::ClearRect: >- encoder << downcast<ClearRect>(*this); >- break; >- case ItemType::BeginTransparencyLayer: >- encoder << downcast<BeginTransparencyLayer>(*this); >- break; >- case ItemType::EndTransparencyLayer: >- encoder << downcast<EndTransparencyLayer>(*this); >- break; >-#if USE(CG) >- case ItemType::ApplyStrokePattern: >- encoder << downcast<ApplyStrokePattern>(*this); >- break; >- case ItemType::ApplyFillPattern: >- encoder << downcast<ApplyFillPattern>(*this); >- break; >-#endif >- case ItemType::ApplyDeviceScaleFactor: >- encoder << downcast<ApplyDeviceScaleFactor>(*this); >- break; >- } >-} >- >-template<class Decoder> >-Optional<Ref<Item>> Item::decode(Decoder& decoder) >-{ >- Optional<ItemType> itemType; >- decoder >> itemType; >- if (!itemType) >- return WTF::nullopt; >- >- switch (*itemType) { >- case ItemType::Save: >- if (auto item = Save::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::Restore: >- if (auto item = Restore::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::Translate: >- if (auto item = Translate::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::Rotate: >- if (auto item = Rotate::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::Scale: >- if (auto item = Scale::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::SetCTM: >- if (auto item = SetCTM::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::ConcatenateCTM: >- if (auto item = ConcatenateCTM::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::SetInlineFillGradient: { >- if (auto item = SetInlineFillGradient::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- } >- case ItemType::SetInlineFillColor: >- if (auto item = SetInlineFillColor::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::SetInlineStrokeColor: >- if (auto item = SetInlineStrokeColor::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::SetStrokeThickness: >- if (auto item = SetStrokeThickness::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::SetState: >- if (auto item = SetState::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::SetLineCap: >- if (auto item = SetLineCap::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::SetLineDash: >- if (auto item = SetLineDash::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::SetLineJoin: >- if (auto item = SetLineJoin::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::SetMiterLimit: >- if (auto item = SetMiterLimit::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::ClearShadow: >- if (auto item = ClearShadow::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::Clip: >- if (auto item = Clip::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::ClipOut: >- if (auto item = ClipOut::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::ClipOutToPath: >- if (auto item = ClipOutToPath::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::ClipPath: >- if (auto item = ClipPath::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::ClipToDrawingCommands: >- if (auto item = ClipToDrawingCommands::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::DrawGlyphs: >- if (auto item = DrawGlyphs::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::DrawImage: >- if (auto item = DrawImage::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::DrawTiledImage: >- if (auto item = DrawTiledImage::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::DrawTiledScaledImage: >- if (auto item = DrawTiledScaledImage::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::DrawImageBuffer: >- if (auto item = DrawImageBuffer::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::DrawNativeImage: >- if (auto item = DrawNativeImage::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::DrawPattern: >- if (auto item = DrawPattern::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::DrawRect: >- if (auto item = DrawRect::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::DrawLine: >- if (auto item = DrawLine::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::DrawLinesForText: >- if (auto item = DrawLinesForText::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::DrawDotsForDocumentMarker: >- if (auto item = DrawDotsForDocumentMarker::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::DrawEllipse: >- if (auto item = DrawEllipse::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::DrawPath: >- if (auto item = DrawPath::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::DrawFocusRingPath: >- if (auto item = DrawFocusRingPath::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::DrawFocusRingRects: >- if (auto item = DrawFocusRingRects::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::FillRect: >- if (auto item = FillRect::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::FillRectWithColor: >- if (auto item = FillRectWithColor::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::FillRectWithGradient: >- if (auto item = FillRectWithGradient::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::FillCompositedRect: >- if (auto item = FillCompositedRect::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::FillRoundedRect: >- if (auto item = FillRoundedRect::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::FillRectWithRoundedHole: >- if (auto item = FillRectWithRoundedHole::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >-#if ENABLE(INLINE_PATH_DATA) >- case ItemType::FillInlinePath: >- if (auto item = FillInlinePath::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >-#endif >- case ItemType::FillPath: >- if (auto item = FillPath::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::FillEllipse: >- if (auto item = FillEllipse::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::PutImageData: >- if (auto item = PutImageData::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::PaintFrameForMedia: >- if (auto item = PaintFrameForMedia::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::StrokeRect: >- if (auto item = StrokeRect::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >-#if ENABLE(INLINE_PATH_DATA) >- case ItemType::StrokeInlinePath: >- if (auto item = StrokeInlinePath::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >-#endif >- case ItemType::StrokePath: >- if (auto item = StrokePath::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::StrokeEllipse: >- if (auto item = StrokeEllipse::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::ClearRect: >- if (auto item = ClearRect::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::BeginTransparencyLayer: >- if (auto item = BeginTransparencyLayer::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::EndTransparencyLayer: >- if (auto item = EndTransparencyLayer::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >-#if USE(CG) >- case ItemType::ApplyStrokePattern: >- if (auto item = ApplyStrokePattern::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- case ItemType::ApplyFillPattern: >- if (auto item = ApplyFillPattern::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >-#endif >- case ItemType::ApplyDeviceScaleFactor: >- if (auto item = ApplyDeviceScaleFactor::decode(decoder)) >- return static_reference_cast<Item>(WTFMove(*item)); >- break; >- } >- >- return WTF::nullopt; >-} >+TextStream& operator<<(TextStream&, ItemHandle); > > } // namespace DisplayList > } // namespace WebCore > >- >-#define SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_DRAWINGITEM(ToValueTypeName, predicate) \ >-SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::DisplayList::ToValueTypeName) \ >- static bool isType(const WebCore::DisplayList::Item& object) { return object.predicate; } \ >-SPECIALIZE_TYPE_TRAITS_END() >- >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_DRAWINGITEM(DrawingItem, isDrawingItem()) >- >-#define SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(ToValueTypeName) \ >-SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::DisplayList::ToValueTypeName) \ >- static bool isType(const WebCore::DisplayList::Item& item) { return item.type() == WebCore::DisplayList::ItemType::ToValueTypeName; } \ >-SPECIALIZE_TYPE_TRAITS_END() >- >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(Save) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(Restore) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(Translate) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(Rotate) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(Scale) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(SetCTM) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(ConcatenateCTM) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(SetInlineFillGradient) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(SetInlineFillColor) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(SetInlineStrokeColor) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(SetStrokeThickness) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(SetState) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(SetLineCap) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(SetLineDash) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(SetLineJoin) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(SetMiterLimit) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(Clip) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(ClipOut) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(ClipOutToPath) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(ClipPath) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(ClipToDrawingCommands) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawGlyphs) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawImage) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawTiledImage) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawTiledScaledImage) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawImageBuffer) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawNativeImage) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawPattern) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawRect) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawLine) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawLinesForText) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawDotsForDocumentMarker) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawEllipse) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawPath) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawFocusRingPath) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawFocusRingRects) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(FillRect) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(FillRectWithColor) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(FillRectWithGradient) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(FillCompositedRect) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(FillRoundedRect) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(FillRectWithRoundedHole) >-#if ENABLE(INLINE_PATH_DATA) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(FillInlinePath) >-#endif >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(FillPath) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(FillEllipse) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(PutImageData) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(PaintFrameForMedia) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(StrokeRect) >-#if ENABLE(INLINE_PATH_DATA) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(StrokeInlinePath) >-#endif >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(StrokePath) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(StrokeEllipse) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(ClearRect) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(BeginTransparencyLayer) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(EndTransparencyLayer) >-#if USE(CG) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(ApplyStrokePattern) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(ApplyFillPattern) >-#endif >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(ApplyDeviceScaleFactor) >-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(ClearShadow) >- > namespace WTF { > > template<> struct EnumTraits<WebCore::DisplayList::ItemType> { >diff --git a/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp b/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp >index 9025a34da8673dff4cda69e39e772e9dfe08c2fa..2a07c34fdd85cc880696a40bb5e155257970a5a6 100644 >--- a/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp >+++ b/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp >@@ -56,7 +56,7 @@ Recorder::~Recorder() > > void Recorder::putImageData(WebCore::AlphaPremultiplication inputFormat, const WebCore::ImageData& imageData, const WebCore::IntRect& srcRect, const WebCore::IntPoint& destPoint, WebCore::AlphaPremultiplication destFormat) > { >- appendItem(WebCore::DisplayList::PutImageData::create(inputFormat, imageData, srcRect, destPoint, destFormat)); >+ append<PutImageData>(inputFormat, imageData, srcRect, destPoint, destFormat); > } > > static bool containsOnlyInlineStateChanges(const GraphicsContextStateChange& changes, GraphicsContextState::StateChangeFlags changeFlags) >@@ -87,21 +87,21 @@ static bool containsOnlyInlineStateChanges(const GraphicsContextStateChange& cha > void Recorder::appendStateChangeItem(const GraphicsContextStateChange& changes, GraphicsContextState::StateChangeFlags changeFlags) > { > if (!containsOnlyInlineStateChanges(changes, changeFlags)) { >- m_displayList.appendItem(SetState::create(changes.m_state, changeFlags)); >+ append<SetState>(changes.m_state, changeFlags); > return; > } > > if (changeFlags.contains(GraphicsContextState::StrokeColorChange)) >- m_displayList.appendItem(SetInlineStrokeColor::create(changes.m_state.strokeColor.asInline())); >+ append<SetInlineStrokeColor>(changes.m_state.strokeColor.asInline()); > > if (changeFlags.contains(GraphicsContextState::StrokeThicknessChange)) >- m_displayList.appendItem(SetStrokeThickness::create(changes.m_state.strokeThickness)); >+ append<SetStrokeThickness>(changes.m_state.strokeThickness); > > if (changeFlags.contains(GraphicsContextState::FillColorChange)) >- m_displayList.appendItem(SetInlineFillColor::create(changes.m_state.fillColor.asInline())); >+ append<SetInlineFillColor>(changes.m_state.fillColor.asInline()); > > if (changeFlags.contains(GraphicsContextState::FillGradientChange)) >- m_displayList.appendItem(SetInlineFillGradient::create(*changes.m_state.fillGradient)); >+ append<SetInlineFillGradient>(*changes.m_state.fillGradient); > } > > void Recorder::willAppendItemOfType(ItemType type) >@@ -139,27 +139,27 @@ void Recorder::updateState(const GraphicsContextState& state, GraphicsContextSta > > void Recorder::clearShadow() > { >- appendItem(ClearShadow::create()); >+ append<ClearShadow>(); > } > > void Recorder::setLineCap(LineCap lineCap) > { >- appendItem(SetLineCap::create(lineCap)); >+ append<SetLineCap>(lineCap); > } > > void Recorder::setLineDash(const DashArray& dashArray, float dashOffset) > { >- appendItem(SetLineDash::create(dashArray, dashOffset)); >+ append<SetLineDash>(dashArray, dashOffset); > } > > void Recorder::setLineJoin(LineJoin lineJoin) > { >- appendItem(SetLineJoin::create(lineJoin)); >+ append<SetLineJoin>(lineJoin); > } > > void Recorder::setMiterLimit(float miterLimit) > { >- appendItem(SetMiterLimit::create(miterLimit)); >+ append<SetMiterLimit>(miterLimit); > } > > void Recorder::drawGlyphs(const Font& font, const GlyphBuffer& glyphBuffer, unsigned from, unsigned numGlyphs, const FloatPoint& startPoint, FontSmoothingMode smoothingMode) >@@ -169,19 +169,19 @@ void Recorder::drawGlyphs(const Font& font, const GlyphBuffer& glyphBuffer, unsi > > ImageDrawResult Recorder::drawImage(Image& image, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& imagePaintingOptions) > { >- appendItemAndUpdateExtent(DrawImage::create(image, destination, source, imagePaintingOptions)); >+ append<DrawImage>(image, destination, source, imagePaintingOptions); > return ImageDrawResult::DidRecord; > } > > ImageDrawResult Recorder::drawTiledImage(Image& image, const FloatRect& destination, const FloatPoint& source, const FloatSize& tileSize, const FloatSize& spacing, const ImagePaintingOptions& imagePaintingOptions) > { >- appendItemAndUpdateExtent(DrawTiledImage::create(image, destination, source, tileSize, spacing, imagePaintingOptions)); >+ append<DrawTiledImage>(image, destination, source, tileSize, spacing, imagePaintingOptions); > return ImageDrawResult::DidRecord; > } > > ImageDrawResult Recorder::drawTiledImage(Image& image, const FloatRect& destination, const FloatRect& source, const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRule, const ImagePaintingOptions& imagePaintingOptions) > { >- appendItemAndUpdateExtent(DrawTiledScaledImage::create(image, destination, source, tileScaleFactor, hRule, vRule, imagePaintingOptions)); >+ append<DrawTiledScaledImage>(image, destination, source, tileScaleFactor, hRule, vRule, imagePaintingOptions); > return ImageDrawResult::DidRecord; > } > >@@ -189,22 +189,22 @@ void Recorder::drawImageBuffer(WebCore::ImageBuffer& imageBuffer, const FloatRec > { > imageBuffer.flushDrawingContext(); > m_displayList.cacheImageBuffer(makeRef(imageBuffer)); >- appendItemAndUpdateExtent(DrawImageBuffer::create(imageBuffer.renderingResourceIdentifier(), destRect, srcRect, options)); >+ append<DrawImageBuffer>(imageBuffer.renderingResourceIdentifier(), destRect, srcRect, options); > } > > void Recorder::drawNativeImage(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) > { >- appendItemAndUpdateExtent(DrawNativeImage::create(image, imageSize, destRect, srcRect, options)); >+ append<DrawNativeImage>(image, imageSize, destRect, srcRect, options); > } > > void Recorder::drawPattern(Image& image, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options) > { >- appendItemAndUpdateExtent(DrawPattern::create(image, destRect, tileRect, patternTransform, phase, spacing, options)); >+ append<DrawPattern>(image, destRect, tileRect, patternTransform, phase, spacing, options); > } > > void Recorder::save() > { >- appendItem(Save::create()); >+ append<Save>(); > m_stateStack.append(m_stateStack.last().cloneForSave()); > } > >@@ -219,25 +219,25 @@ void Recorder::restore() > // Have to avoid eliding nested Save/Restore when a descendant state contains drawing items. > currentState().wasUsedForDrawing |= stateUsedForDrawing; > >- appendItem(Restore::create()); >+ append<Restore>(); > } > > void Recorder::translate(float x, float y) > { > currentState().translate(x, y); >- appendItem(Translate::create(x, y)); >+ append<Translate>(x, y); > } > > void Recorder::rotate(float angleInRadians) > { > currentState().rotate(angleInRadians); >- appendItem(Rotate::create(angleInRadians)); >+ append<Rotate>(angleInRadians); > } > > void Recorder::scale(const FloatSize& size) > { > currentState().scale(size); >- appendItem(Scale::create(size)); >+ append<Scale>(size); > } > > void Recorder::concatCTM(const AffineTransform& transform) >@@ -246,13 +246,13 @@ void Recorder::concatCTM(const AffineTransform& transform) > return; > > currentState().concatCTM(transform); >- appendItem(ConcatenateCTM::create(transform)); >+ append<ConcatenateCTM>(transform); > } > > void Recorder::setCTM(const AffineTransform& transform) > { > currentState().setCTM(transform); >- appendItem(SetCTM::create(transform)); >+ append<SetCTM>(transform); > } > > AffineTransform Recorder::getCTM(GraphicsContext::IncludeDeviceScale) >@@ -263,158 +263,158 @@ AffineTransform Recorder::getCTM(GraphicsContext::IncludeDeviceScale) > > void Recorder::beginTransparencyLayer(float opacity) > { >- appendItemAndUpdateExtent(BeginTransparencyLayer::create(opacity)); >+ append<BeginTransparencyLayer>(opacity); > } > > void Recorder::endTransparencyLayer() > { >- appendItem(EndTransparencyLayer::create()); >+ append<EndTransparencyLayer>(); > } > > void Recorder::drawRect(const FloatRect& rect, float borderThickness) > { >- appendItemAndUpdateExtent(DrawRect::create(rect, borderThickness)); >+ append<DrawRect>(rect, borderThickness); > } > > void Recorder::drawLine(const FloatPoint& point1, const FloatPoint& point2) > { >- appendItemAndUpdateExtent(DrawLine::create(point1, point2)); >+ append<DrawLine>(point1, point2); > } > > void Recorder::drawLinesForText(const FloatPoint& point, float thickness, const DashArray& widths, bool printing, bool doubleLines) > { >- appendItemAndUpdateExtent(DrawLinesForText::create(FloatPoint(), toFloatSize(point), thickness, widths, printing, doubleLines)); >+ append<DrawLinesForText>(FloatPoint(), toFloatSize(point), thickness, widths, printing, doubleLines); > } > > void Recorder::drawDotsForDocumentMarker(const FloatRect& rect, DocumentMarkerLineStyle style) > { >- appendItemAndUpdateExtent(DrawDotsForDocumentMarker::create(rect, style)); >+ append<DrawDotsForDocumentMarker>(rect, style); > } > > void Recorder::drawEllipse(const FloatRect& rect) > { >- appendItemAndUpdateExtent(DrawEllipse::create(rect)); >+ append<DrawEllipse>(rect); > } > > void Recorder::drawPath(const Path& path) > { >- appendItemAndUpdateExtent(DrawPath::create(path)); >+ append<DrawPath>(path); > } > > void Recorder::drawFocusRing(const Path& path, float width, float offset, const Color& color) > { >- appendItemAndUpdateExtent(DrawFocusRingPath::create(path, width, offset, color)); >+ append<DrawFocusRingPath>(path, width, offset, color); > } > > void Recorder::drawFocusRing(const Vector<FloatRect>& rects, float width, float offset, const Color& color) > { >- appendItemAndUpdateExtent(DrawFocusRingRects::create(rects, width, offset, color)); >+ append<DrawFocusRingRects>(rects, width, offset, color); > } > > void Recorder::fillRect(const FloatRect& rect) > { >- appendItemAndUpdateExtent(FillRect::create(rect)); >+ append<FillRect>(rect); > } > > void Recorder::fillRect(const FloatRect& rect, const Color& color) > { >- appendItemAndUpdateExtent(FillRectWithColor::create(rect, color)); >+ append<FillRectWithColor>(rect, color); > } > > void Recorder::fillRect(const FloatRect& rect, Gradient& gradient) > { >- appendItemAndUpdateExtent(FillRectWithGradient::create(rect, gradient)); >+ append<FillRectWithGradient>(rect, gradient); > } > > void Recorder::fillRect(const FloatRect& rect, const Color& color, CompositeOperator op, BlendMode blendMode) > { >- appendItemAndUpdateExtent(FillCompositedRect::create(rect, color, op, blendMode)); >+ append<FillCompositedRect>(rect, color, op, blendMode); > } > > void Recorder::fillRoundedRect(const FloatRoundedRect& rect, const Color& color, BlendMode blendMode) > { >- appendItemAndUpdateExtent(FillRoundedRect::create(rect, color, blendMode)); >+ append<FillRoundedRect>(rect, color, blendMode); > } > > void Recorder::fillRectWithRoundedHole(const FloatRect& rect, const FloatRoundedRect& roundedHoleRect, const Color& color) > { >- appendItemAndUpdateExtent(FillRectWithRoundedHole::create(rect, roundedHoleRect, color)); >+ append<FillRectWithRoundedHole>(rect, roundedHoleRect, color); > } > > void Recorder::fillPath(const Path& path) > { > #if ENABLE(INLINE_PATH_DATA) > if (path.hasInlineData()) { >- appendItemAndUpdateExtent(FillInlinePath::create(path.inlineData())); >+ append<FillInlinePath>(path.inlineData()); > return; > } > #endif >- appendItemAndUpdateExtent(FillPath::create(path)); >+ append<FillPath>(path); > } > > void Recorder::fillEllipse(const FloatRect& rect) > { >- appendItemAndUpdateExtent(FillEllipse::create(rect)); >+ append<FillEllipse>(rect); > } > > void Recorder::strokeRect(const FloatRect& rect, float lineWidth) > { >- appendItemAndUpdateExtent(StrokeRect::create(rect, lineWidth)); >+ append<StrokeRect>(rect, lineWidth); > } > > void Recorder::strokePath(const Path& path) > { > #if ENABLE(INLINE_PATH_DATA) > if (path.hasInlineData()) { >- appendItemAndUpdateExtent(StrokeInlinePath::create(path.inlineData())); >+ append<StrokeInlinePath>(path.inlineData()); > return; > } > #endif >- appendItemAndUpdateExtent(StrokePath::create(path)); >+ append<StrokePath>(path); > } > > void Recorder::strokeEllipse(const FloatRect& rect) > { >- appendItemAndUpdateExtent(StrokeEllipse::create(rect)); >+ append<StrokeEllipse>(rect); > } > > void Recorder::clearRect(const FloatRect& rect) > { >- appendItemAndUpdateExtent(ClearRect::create(rect)); >+ append<ClearRect>(rect); > } > > #if USE(CG) > void Recorder::applyStrokePattern() > { >- appendItem(ApplyStrokePattern::create()); >+ append<ApplyStrokePattern>(); > } > > void Recorder::applyFillPattern() > { >- appendItem(ApplyFillPattern::create()); >+ append<ApplyFillPattern>(); > } > #endif > > void Recorder::clip(const FloatRect& rect) > { > currentState().clipBounds.intersect(rect); >- appendItem(Clip::create(rect)); >+ append<Clip>(rect); > } > > void Recorder::clipOut(const FloatRect& rect) > { >- appendItem(ClipOut::create(rect)); >+ append<ClipOut>(rect); > } > > void Recorder::clipOut(const Path& path) > { >- appendItem(ClipOutToPath::create(path)); >+ append<ClipOutToPath>(path); > } > > void Recorder::clipPath(const Path& path, WindRule windRule) > { > currentState().clipBounds.intersect(path.fastBoundingRect()); >- appendItem(ClipPath::create(path, windRule)); >+ append<ClipPath>(path, windRule); > } > > IntRect Recorder::clipBounds() >@@ -442,19 +442,19 @@ void Recorder::clipToDrawingCommands(const FloatRect& destination, ColorSpace co > > auto recordingContext = makeUnique<DrawingContext>(destination.size(), initialCTM); > drawingFunction(recordingContext->context()); >- appendItem(ClipToDrawingCommands::create(destination, colorSpace, recordingContext->takeDisplayList())); >+ append<ClipToDrawingCommands>(destination, colorSpace, recordingContext->takeDisplayList()); > } > > void Recorder::paintFrameForMedia(MediaPlayer& player, const FloatRect& destination) > { >- appendItem(PaintFrameForMedia::create(player, destination)); >+ append<PaintFrameForMedia>(player, destination); > } > > void Recorder::applyDeviceScaleFactor(float deviceScaleFactor) > { > // FIXME: this changes the baseCTM, which will invalidate all of our cached extents. > // Assert that it's only called early on? >- appendItem(ApplyDeviceScaleFactor::create(deviceScaleFactor)); >+ append<ApplyDeviceScaleFactor>(deviceScaleFactor); > } > > FloatRect Recorder::roundToDevicePixels(const FloatRect& rect, GraphicsContext::RoundingMode) >@@ -463,30 +463,6 @@ FloatRect Recorder::roundToDevicePixels(const FloatRect& rect, GraphicsContext:: > return rect; > } > >-void Recorder::appendItemAndUpdateExtent(Ref<DrawingItem>&& item) >-{ >- DrawingItem& newItem = item.get(); >- appendItem(WTFMove(item)); >- updateItemExtent(newItem); >-} >- >-void Recorder::appendItem(Ref<Item>&& item) >-{ >- Item& newItem = item.get(); >- auto type = newItem.type(); >- willAppendItemOfType(type); >- m_displayList.append(WTFMove(item)); >- didAppendItemOfType(type); >-} >- >-void Recorder::updateItemExtent(DrawingItem& item) const >-{ >- if (Optional<FloatRect> rect = item.localBounds(graphicsContext())) >- item.setExtent(extentFromLocalBounds(rect.value())); >- else if (Optional<FloatRect> rect = item.globalBounds()) >- item.setExtent(rect.value()); >-} >- > // FIXME: share with ShadowData > static inline float shadowPaintingExtent(float blurRadius) > { >@@ -506,7 +482,7 @@ FloatRect Recorder::extentFromLocalBounds(const FloatRect& rect) const > float shadowRadius; > Color shadowColor; > if (graphicsContext().getShadow(shadowOffset, shadowRadius, shadowColor)) { >- FloatRect shadowExtent= bounds; >+ FloatRect shadowExtent = bounds; > shadowExtent.move(shadowOffset); > shadowExtent.inflate(shadowPaintingExtent(shadowRadius)); > bounds.unite(shadowExtent); >diff --git a/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h b/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h >index 7b8613c5f29631e5de94394332d89dfd53f31fdd..f951cfaa2cacc96d4c1a18a25fa58960792246d4 100644 >--- a/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h >+++ b/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h >@@ -27,6 +27,7 @@ > > #include "DisplayList.h" > #include "DisplayListDrawGlyphsRecorder.h" >+#include "DisplayListItems.h" > #include "GraphicsContextImpl.h" > #include "Image.h" // For Image::TileRule. > #include "TextFlags.h" >@@ -48,8 +49,6 @@ struct ImagePaintingOptions; > > namespace DisplayList { > >-class DrawingItem; >- > class Recorder : public GraphicsContextImpl { > WTF_MAKE_FAST_ALLOCATED; > WTF_MAKE_NONCOPYABLE(Recorder); >@@ -147,15 +146,34 @@ private: > > FloatRect roundToDevicePixels(const FloatRect&, GraphicsContext::RoundingMode) override; > >- void appendItem(Ref<Item>&&); >+ template<typename T, class... Args> >+ void append(Args&&... args) >+ { >+ willAppendItemOfType(T::itemType); >+ m_displayList.append<T>(std::forward<Args>(args)...); >+ didAppendItemOfType(T::itemType); >+ >+ if (!T::isDrawingItem) >+ return; >+ >+ if (LIKELY(!m_displayList.tracksDrawingItemExtents())) >+ return; >+ >+ auto item = T(std::forward<Args>(args)...); >+ if (auto rect = item.localBounds(graphicsContext())) >+ m_displayList.addDrawingItemExtent(extentFromLocalBounds(*rect)); >+ else if (auto rect = item.globalBounds()) >+ m_displayList.addDrawingItemExtent(*rect); >+ else >+ m_displayList.addDrawingItemExtent(WTF::nullopt); >+ } >+ > void willAppendItemOfType(ItemType); > void didAppendItemOfType(ItemType); >- void appendItemAndUpdateExtent(Ref<DrawingItem>&&); > > void appendStateChangeItem(const GraphicsContextStateChange&, GraphicsContextState::StateChangeFlags); > > FloatRect extentFromLocalBounds(const FloatRect&) const; >- void updateItemExtent(DrawingItem&) const; > > const AffineTransform& ctm() const; > const FloatRect& clipBounds() const; >diff --git a/Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.cpp b/Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.cpp >index 8288380431a290c040c19d1aeece9424ff57735a..e46e56895d4c35f7e2114f802149568227bde8a4 100644 >--- a/Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.cpp >+++ b/Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.cpp >@@ -44,18 +44,18 @@ Replayer::Replayer(GraphicsContext& context, const DisplayList& displayList, con > > Replayer::~Replayer() = default; > >-void Replayer::applyItem(Item& item) >+void Replayer::applyItem(ItemHandle item) > { > if (m_delegate && m_delegate->apply(item, m_context)) > return; >- >- if (item.type() == ItemType::DrawImageBuffer) { >- auto& drawItem = static_cast<DrawImageBuffer&>(item); >+ >+ if (item.is<DrawImageBuffer>()) { >+ auto& drawItem = item.get<DrawImageBuffer>(); > if (auto* imageBuffer = m_imageBuffers.get(drawItem.renderingResourceIdentifier())) > drawItem.apply(m_context, *imageBuffer); > return; > } >- >+ > item.apply(m_context); > } > >@@ -68,25 +68,25 @@ std::unique_ptr<DisplayList> Replayer::replay(const FloatRect& initialClip, bool > if (UNLIKELY(trackReplayList)) > replayList = makeUnique<DisplayList>(); > >- auto& items = m_displayList.list(); >- for (size_t i = 0; i < items.size(); ++i) { >- auto& item = items[i].get(); >- >- if (!initialClip.isZero() && is<DrawingItem>(item)) { >- const DrawingItem& drawingItem = downcast<DrawingItem>(item); >- if (drawingItem.extentKnown() && !drawingItem.extent().intersects(initialClip)) { >- LOG_WITH_STREAM(DisplayLists, stream << "skipping " << i << " " << item); >- continue; >- } >+#if !LOG_DISABLED >+ size_t i = 0; >+#endif >+ for (auto [item, extent] : m_displayList) { >+ if (!initialClip.isZero() && extent && !extent->intersects(initialClip)) { >+ LOG_WITH_STREAM(DisplayLists, stream << "skipping " << i++ << " " << item); >+ continue; > } > > LOG_WITH_STREAM(DisplayLists, stream << "applying " << i << " " << item); > applyItem(item); > >- if (UNLIKELY(trackReplayList)) >- replayList->appendItem(const_cast<Item&>(item)); >+ if (UNLIKELY(trackReplayList)) { >+ replayList->append(item); >+ if (item.isDrawingItem()) >+ replayList->addDrawingItemExtent(WTFMove(extent)); >+ } > } >- >+ > return replayList; > } > >diff --git a/Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.h b/Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.h >index dc74f7d67a136fe6964690ad1c059c0162af654d..92ec6889c35ef86d3f9e94bec666e7a78ae597cf 100644 >--- a/Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.h >+++ b/Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.h >@@ -50,11 +50,11 @@ public: > class Delegate { > public: > virtual ~Delegate() { } >- virtual bool apply(Item&, GraphicsContext&) { return false; } >+ virtual bool apply(ItemHandle, GraphicsContext&) { return false; } > }; > > private: >- void applyItem(Item&); >+ void applyItem(ItemHandle); > > GraphicsContext& m_context; > const DisplayList& m_displayList; >diff --git a/Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h b/Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h >index cb61ad2617c9dc42918e366051b8d7016c68d6ac..78a4723ea11277ad6ac2c62f1196080428e31ff6 100644 >--- a/Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h >+++ b/Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h >@@ -27,14 +27,17 @@ > > #if ENABLE(GPU_PROCESS) > >+#include "Decoder.h" > #include "GPUConnectionToWebProcess.h" > #include <WebCore/ConcreteImageBuffer.h> >+#include <WebCore/DisplayList.h> >+#include <WebCore/DisplayListItems.h> > #include <WebCore/DisplayListReplayer.h> > > namespace WebKit { > > template<typename BackendType> >-class RemoteImageBuffer : public WebCore::ConcreteImageBuffer<BackendType>, public WebCore::DisplayList::Replayer::Delegate { >+class RemoteImageBuffer : public WebCore::ConcreteImageBuffer<BackendType>, public WebCore::DisplayList::Replayer::Delegate, public WebCore::DisplayList::ItemBufferReadingClient { > using BaseConcreteImageBuffer = WebCore::ConcreteImageBuffer<BackendType>; > using BaseConcreteImageBuffer::context; > using BaseConcreteImageBuffer::m_backend; >@@ -71,10 +74,10 @@ private: > } > } > >- bool apply(WebCore::DisplayList::Item& item, WebCore::GraphicsContext& context) override >+ bool apply(WebCore::DisplayList::ItemHandle item, WebCore::GraphicsContext& context) override > { >- if (item.type() == WebCore::DisplayList::ItemType::PutImageData) { >- auto& putImageDataItem = static_cast<WebCore::DisplayList::PutImageData&>(item); >+ if (item.is<WebCore::DisplayList::PutImageData>()) { >+ auto& putImageDataItem = item.get<WebCore::DisplayList::PutImageData>(); > putImageData(putImageDataItem.inputFormat(), putImageDataItem.imageData(), putImageDataItem.srcRect(), putImageDataItem.destPoint(), putImageDataItem.destFormat()); > return true; > } >@@ -82,6 +85,114 @@ private: > return m_remoteRenderingBackend.applyMediaItem(item, context); > } > >+ Optional<WebCore::DisplayList::ItemHandle> WARN_UNUSED_RETURN decodeItem(const uint8_t* data, size_t length, WebCore::DisplayList::ItemType type, uint8_t* handleLocation) override >+ { >+ switch (type) { >+ case WebCore::DisplayList::ItemType::ClipOutToPath: >+ return decodeAndCreate<WebCore::DisplayList::ClipOutToPath>(data, length, handleLocation); >+ case WebCore::DisplayList::ItemType::ClipPath: >+ return decodeAndCreate<WebCore::DisplayList::ClipPath>(data, length, handleLocation); >+ case WebCore::DisplayList::ItemType::ClipToDrawingCommands: >+ return decodeAndCreate<WebCore::DisplayList::ClipToDrawingCommands>(data, length, handleLocation); >+ case WebCore::DisplayList::ItemType::DrawFocusRingPath: >+ return decodeAndCreate<WebCore::DisplayList::DrawFocusRingPath>(data, length, handleLocation); >+ case WebCore::DisplayList::ItemType::DrawFocusRingRects: >+ return decodeAndCreate<WebCore::DisplayList::DrawFocusRingRects>(data, length, handleLocation); >+ case WebCore::DisplayList::ItemType::DrawGlyphs: >+ return decodeAndCreate<WebCore::DisplayList::DrawGlyphs>(data, length, handleLocation); >+ case WebCore::DisplayList::ItemType::DrawImage: >+ return decodeAndCreate<WebCore::DisplayList::DrawImage>(data, length, handleLocation); >+ case WebCore::DisplayList::ItemType::DrawLinesForText: >+ return decodeAndCreate<WebCore::DisplayList::DrawLinesForText>(data, length, handleLocation); >+ case WebCore::DisplayList::ItemType::DrawNativeImage: >+ return decodeAndCreate<WebCore::DisplayList::DrawNativeImage>(data, length, handleLocation); >+ case WebCore::DisplayList::ItemType::DrawPath: >+ return decodeAndCreate<WebCore::DisplayList::DrawPath>(data, length, handleLocation); >+ case WebCore::DisplayList::ItemType::DrawPattern: >+ return decodeAndCreate<WebCore::DisplayList::DrawPattern>(data, length, handleLocation); >+ case WebCore::DisplayList::ItemType::DrawTiledImage: >+ return decodeAndCreate<WebCore::DisplayList::DrawTiledImage>(data, length, handleLocation); >+ case WebCore::DisplayList::ItemType::DrawTiledScaledImage: >+ return decodeAndCreate<WebCore::DisplayList::DrawTiledScaledImage>(data, length, handleLocation); >+ case WebCore::DisplayList::ItemType::FillCompositedRect: >+ return decodeAndCreate<WebCore::DisplayList::FillCompositedRect>(data, length, handleLocation); >+ case WebCore::DisplayList::ItemType::FillPath: >+ return decodeAndCreate<WebCore::DisplayList::FillPath>(data, length, handleLocation); >+ case WebCore::DisplayList::ItemType::FillRectWithColor: >+ return decodeAndCreate<WebCore::DisplayList::FillRectWithColor>(data, length, handleLocation); >+ case WebCore::DisplayList::ItemType::FillRectWithGradient: >+ return decodeAndCreate<WebCore::DisplayList::FillRectWithGradient>(data, length, handleLocation); >+ case WebCore::DisplayList::ItemType::FillRectWithRoundedHole: >+ return decodeAndCreate<WebCore::DisplayList::FillRectWithRoundedHole>(data, length, handleLocation); >+ case WebCore::DisplayList::ItemType::FillRoundedRect: >+ return decodeAndCreate<WebCore::DisplayList::FillRoundedRect>(data, length, handleLocation); >+ case WebCore::DisplayList::ItemType::PutImageData: >+ return decodeAndCreate<WebCore::DisplayList::PutImageData>(data, length, handleLocation); >+ case WebCore::DisplayList::ItemType::SetLineDash: >+ return decodeAndCreate<WebCore::DisplayList::SetLineDash>(data, length, handleLocation); >+ case WebCore::DisplayList::ItemType::SetState: >+ return decodeAndCreate<WebCore::DisplayList::SetState>(data, length, handleLocation); >+ case WebCore::DisplayList::ItemType::StrokePath: >+ return decodeAndCreate<WebCore::DisplayList::StrokePath>(data, length, handleLocation); >+ case WebCore::DisplayList::ItemType::ApplyDeviceScaleFactor: >+#if USE(CG) >+ case WebCore::DisplayList::ItemType::ApplyFillPattern: >+ case WebCore::DisplayList::ItemType::ApplyStrokePattern: >+#endif >+ case WebCore::DisplayList::ItemType::BeginTransparencyLayer: >+ case WebCore::DisplayList::ItemType::ClearRect: >+ case WebCore::DisplayList::ItemType::ClearShadow: >+ case WebCore::DisplayList::ItemType::Clip: >+ case WebCore::DisplayList::ItemType::ClipOut: >+ case WebCore::DisplayList::ItemType::ConcatenateCTM: >+ case WebCore::DisplayList::ItemType::DrawDotsForDocumentMarker: >+ case WebCore::DisplayList::ItemType::DrawEllipse: >+ case WebCore::DisplayList::ItemType::DrawImageBuffer: >+ case WebCore::DisplayList::ItemType::DrawLine: >+ case WebCore::DisplayList::ItemType::DrawRect: >+ case WebCore::DisplayList::ItemType::EndTransparencyLayer: >+ case WebCore::DisplayList::ItemType::FillEllipse: >+#if ENABLE(INLINE_PATH_DATA) >+ case WebCore::DisplayList::ItemType::FillInlinePath: >+#endif >+ case WebCore::DisplayList::ItemType::FillRect: >+ case WebCore::DisplayList::ItemType::PaintFrameForMedia: >+ case WebCore::DisplayList::ItemType::Restore: >+ case WebCore::DisplayList::ItemType::Rotate: >+ case WebCore::DisplayList::ItemType::Save: >+ case WebCore::DisplayList::ItemType::Scale: >+ case WebCore::DisplayList::ItemType::SetCTM: >+ case WebCore::DisplayList::ItemType::SetInlineFillColor: >+ case WebCore::DisplayList::ItemType::SetInlineFillGradient: >+ case WebCore::DisplayList::ItemType::SetInlineStrokeColor: >+ case WebCore::DisplayList::ItemType::SetLineCap: >+ case WebCore::DisplayList::ItemType::SetLineJoin: >+ case WebCore::DisplayList::ItemType::SetMiterLimit: >+ case WebCore::DisplayList::ItemType::SetStrokeThickness: >+ case WebCore::DisplayList::ItemType::StrokeEllipse: >+#if ENABLE(INLINE_PATH_DATA) >+ case WebCore::DisplayList::ItemType::StrokeInlinePath: >+#endif >+ case WebCore::DisplayList::ItemType::StrokeRect: >+ case WebCore::DisplayList::ItemType::Translate: { >+ ASSERT_NOT_REACHED(); >+ break; >+ } >+ } >+ ASSERT_NOT_REACHED(); >+ return WTF::nullopt; >+ } >+ >+ template<typename T> >+ Optional<WebCore::DisplayList::ItemHandle> WARN_UNUSED_RETURN decodeAndCreate(const uint8_t* data, size_t length, uint8_t* handleLocation) >+ { >+ if (auto item = IPC::Decoder::decodeSingleObject<T>(data, length)) { >+ new (handleLocation + sizeof(WebCore::DisplayList::ItemType)) T(WTFMove(*item)); >+ return {{ handleLocation }}; >+ } >+ return WTF::nullopt; >+ } >+ > RemoteRenderingBackend& m_remoteRenderingBackend; > }; > >diff --git a/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp b/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp >index b6ef24ed73e4ba2bce3ea24d6373d3f8345a6d9f..233436e0a21dfec1c88aa8299e8975994e1541fc 100644 >--- a/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp >+++ b/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp >@@ -72,13 +72,12 @@ uint64_t RemoteRenderingBackend::messageSenderDestinationID() const > return m_renderingBackendIdentifier.toUInt64(); > } > >-bool RemoteRenderingBackend::applyMediaItem(const DisplayList::Item& item, GraphicsContext& context) >+bool RemoteRenderingBackend::applyMediaItem(DisplayList::ItemHandle item, GraphicsContext& context) > { >- if (item.type() != WebCore::DisplayList::ItemType::PaintFrameForMedia) >+ if (!item.is<DisplayList::PaintFrameForMedia>()) > return false; > >- auto& mediaItem = static_cast<const DisplayList::PaintFrameForMedia&>(item); >- >+ auto& mediaItem = item.get<DisplayList::PaintFrameForMedia>(); > auto process = gpuConnectionToWebProcess(); > if (!process) > return false; >@@ -125,19 +124,45 @@ void RemoteRenderingBackend::createImageBuffer(const FloatSize& logicalSize, Ren > m_remoteResourceCache.cacheImageBuffer(makeRef(*imageBuffer)); > } > >-void RemoteRenderingBackend::flushDisplayList(const DisplayList::DisplayList& displayList, RenderingResourceIdentifier renderingResourceIdentifier) >+void RemoteRenderingBackend::applyDisplayList(const SharedDisplayListHandle& handle, RenderingResourceIdentifier renderingResourceIdentifier, ShouldFlushContext flushContext) > { >- if (auto imageBuffer = m_remoteResourceCache.cachedImageBuffer(renderingResourceIdentifier)) >- imageBuffer->flushDisplayList(displayList); >+ auto displayList = handle.createDisplayList([&] (WebCore::DisplayList::ItemBufferIdentifier identifier) -> uint8_t* { >+ if (auto sharedMemory = m_sharedItemBuffers.take(identifier)) >+ return reinterpret_cast<uint8_t*>(sharedMemory->data()); >+ return nullptr; >+ }); >+ >+ if (!displayList) { >+ // FIXME: Add a message check to terminate the web process. >+ return; >+ } >+ >+ auto imageBuffer = m_remoteResourceCache.cachedImageBuffer(renderingResourceIdentifier); >+ if (!imageBuffer) { >+ // FIXME: Add a message check to terminate the web process. >+ return; >+ } >+ >+ if (imageBuffer->isAccelerated()) >+ displayList->setItemBufferClient(static_cast<AcceleratedRemoteImageBuffer*>(imageBuffer)); >+ else >+ displayList->setItemBufferClient(static_cast<UnacceleratedRemoteImageBuffer*>(imageBuffer)); >+ >+ imageBuffer->flushDisplayList(*displayList); >+ >+ if (flushContext == ShouldFlushContext::Yes) >+ imageBuffer->flushContext(); > } > >-void RemoteRenderingBackend::flushDisplayListAndCommit(const DisplayList::DisplayList& displayList, DisplayListFlushIdentifier flushIdentifier, RenderingResourceIdentifier renderingResourceIdentifier) >+void RemoteRenderingBackend::flushDisplayList(const SharedDisplayListHandle& handle, RenderingResourceIdentifier renderingResourceIdentifier) > { >- if (auto imageBuffer = m_remoteResourceCache.cachedImageBuffer(renderingResourceIdentifier)) { >- imageBuffer->flushDisplayList(displayList); >- imageBuffer->flushContext(); >- flushDisplayListWasCommitted(flushIdentifier, renderingResourceIdentifier); >- } >+ applyDisplayList(handle, renderingResourceIdentifier, ShouldFlushContext::No); >+} >+ >+void RemoteRenderingBackend::flushDisplayListAndCommit(const SharedDisplayListHandle& handle, DisplayListFlushIdentifier flushIdentifier, RenderingResourceIdentifier renderingResourceIdentifier) >+{ >+ applyDisplayList(handle, renderingResourceIdentifier, ShouldFlushContext::Yes); >+ flushDisplayListWasCommitted(flushIdentifier, renderingResourceIdentifier); > } > > void RemoteRenderingBackend::getImageData(AlphaPremultiplication outputFormat, IntRect srcRect, RenderingResourceIdentifier renderingResourceIdentifier, CompletionHandler<void(IPC::ImageDataReference&&)>&& completionHandler) >@@ -153,6 +178,12 @@ void RemoteRenderingBackend::releaseRemoteResource(RenderingResourceIdentifier r > m_remoteResourceCache.releaseRemoteResource(renderingResourceIdentifier); > } > >+void RemoteRenderingBackend::didCreateSharedItemData(DisplayList::ItemBufferIdentifier identifier, const SharedMemory::IPCHandle& handle) >+{ >+ if (auto sharedMemory = SharedMemory::map(handle.handle, SharedMemory::Protection::ReadOnly)) >+ m_sharedItemBuffers.set(identifier, WTFMove(sharedMemory)); >+} >+ > } // namespace WebKit > > #endif // ENABLE(GPU_PROCESS) >diff --git a/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h b/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h >index 3df6f774e1521b814b7b6c5c203b2765c6ac790f..821c3418b8051e7d371cbf1d945aee69d40b4e6a 100644 >--- a/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h >+++ b/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h >@@ -35,7 +35,9 @@ > #include "MessageSender.h" > #include "RemoteResourceCache.h" > #include "RenderingBackendIdentifier.h" >+#include "SharedDisplayListHandle.h" > #include <WebCore/ColorSpace.h> >+#include <WebCore/DisplayList.h> > #include <WebCore/DisplayListItems.h> > #include <wtf/WeakPtr.h> > >@@ -64,7 +66,7 @@ public: > RemoteResourceCache& remoteResourceCache() { return m_remoteResourceCache; } > > // Rendering operations. >- bool applyMediaItem(const WebCore::DisplayList::Item&, WebCore::GraphicsContext&); >+ bool applyMediaItem(WebCore::DisplayList::ItemHandle, WebCore::GraphicsContext&); > > // Messages to be sent. > void imageBufferBackendWasCreated(const WebCore::FloatSize& logicalSize, const WebCore::IntSize& backendSize, float resolutionScale, WebCore::ColorSpace, ImageBufferBackendHandle, WebCore::RenderingResourceIdentifier); >@@ -73,6 +75,9 @@ public: > private: > RemoteRenderingBackend(GPUConnectionToWebProcess&, RenderingBackendIdentifier); > >+ enum class ShouldFlushContext : bool { No, Yes }; >+ void applyDisplayList(const SharedDisplayListHandle&, WebCore::RenderingResourceIdentifier, ShouldFlushContext); >+ > // IPC::MessageSender. > IPC::Connection* messageSenderConnection() const override; > uint64_t messageSenderDestinationID() const override; >@@ -83,14 +88,16 @@ private: > > // Messages to be received. > void createImageBuffer(const WebCore::FloatSize& logicalSize, WebCore::RenderingMode, float resolutionScale, WebCore::ColorSpace, WebCore::RenderingResourceIdentifier); >- void flushDisplayList(const WebCore::DisplayList::DisplayList&, WebCore::RenderingResourceIdentifier); >- void flushDisplayListAndCommit(const WebCore::DisplayList::DisplayList&, DisplayListFlushIdentifier, WebCore::RenderingResourceIdentifier); >+ void flushDisplayList(const SharedDisplayListHandle&, WebCore::RenderingResourceIdentifier); >+ void flushDisplayListAndCommit(const SharedDisplayListHandle&, DisplayListFlushIdentifier, WebCore::RenderingResourceIdentifier); > void getImageData(WebCore::AlphaPremultiplication outputFormat, WebCore::IntRect srcRect, WebCore::RenderingResourceIdentifier, CompletionHandler<void(IPC::ImageDataReference&&)>&&); > void releaseRemoteResource(WebCore::RenderingResourceIdentifier); >+ void didCreateSharedItemData(WebCore::DisplayList::ItemBufferIdentifier, const SharedMemory::IPCHandle&); > > RemoteResourceCache m_remoteResourceCache; > WeakPtr<GPUConnectionToWebProcess> m_gpuConnectionToWebProcess; > RenderingBackendIdentifier m_renderingBackendIdentifier; >+ HashMap<WebCore::DisplayList::ItemBufferIdentifier, RefPtr<SharedMemory>> m_sharedItemBuffers; > }; > > } // namespace WebKit >diff --git a/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.messages.in b/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.messages.in >index a88e0fb626249189d8f5b3a39b9b66428622cad3..bb915ab195ad377720b69150a3bec0c993c5ac85 100644 >--- a/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.messages.in >+++ b/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.messages.in >@@ -23,11 +23,12 @@ > #if ENABLE(GPU_PROCESS) > > messages -> RemoteRenderingBackend NotRefCounted { >- void CreateImageBuffer(WebCore::FloatSize logicalSize, WebCore::RenderingMode renderingMode, float resolutionScale, WebCore::ColorSpace colorSpace, WebCore::RenderingResourceIdentifier renderingResourceIdentifier) >- void FlushDisplayList(WebCore::DisplayList::DisplayList displayList, WebCore::RenderingResourceIdentifier renderingResourceIdentifier) >- void FlushDisplayListAndCommit(WebCore::DisplayList::DisplayList displayList, WebKit::DisplayListFlushIdentifier flushIdentifier, WebCore::RenderingResourceIdentifier renderingResourceIdentifier) >+ CreateImageBuffer(WebCore::FloatSize logicalSize, WebCore::RenderingMode renderingMode, float resolutionScale, WebCore::ColorSpace colorSpace, WebCore::RenderingResourceIdentifier renderingResourceIdentifier) >+ FlushDisplayList(WebKit::SharedDisplayListHandle displayList, WebCore::RenderingResourceIdentifier renderingResourceIdentifier) >+ FlushDisplayListAndCommit(WebKit::SharedDisplayListHandle displayList, WebKit::DisplayListFlushIdentifier flushIdentifier, WebCore::RenderingResourceIdentifier renderingResourceIdentifier) > GetImageData(enum:uint8_t WebCore::AlphaPremultiplication outputFormat, WebCore::IntRect srcRect, WebCore::RenderingResourceIdentifier renderingResourceIdentifier) -> (IPC::ImageDataReference imageData) Synchronous >- void ReleaseRemoteResource(WebCore::RenderingResourceIdentifier renderingResourceIdentifier) >+ DidCreateSharedItemData(WebCore::DisplayList::ItemBufferIdentifier identifier, WebKit::SharedMemory::IPCHandle handle) >+ ReleaseRemoteResource(WebCore::RenderingResourceIdentifier renderingResourceIdentifier) > } > > #endif // ENABLE(GPU_PROCESS) >diff --git a/Source/WebKit/Scripts/webkit/messages.py b/Source/WebKit/Scripts/webkit/messages.py >index c1ae96c7ca295c3e5ebeb75b3c3c342695141740..124f48f1c41afffe36cdd352b4b9d1b88b10397b 100644 >--- a/Source/WebKit/Scripts/webkit/messages.py >+++ b/Source/WebKit/Scripts/webkit/messages.py >@@ -208,6 +208,7 @@ def types_that_cannot_be_forward_declared(): > 'String', > 'WebCore::ColorSpace', > 'WebCore::DictationContext', >+ 'WebCore::DisplayList::ItemBufferIdentifier', > 'WebCore::DragApplicationFlags', > 'WebCore::DocumentIdentifier', > 'WebCore::DocumentOrWorkerIdentifier', >@@ -587,6 +588,7 @@ def headers_for_type(type): > 'JSC::MessageSource': ['<JavaScriptCore/ConsoleTypes.h>'], > 'Inspector::InspectorTargetType': ['<JavaScriptCore/InspectorTarget.h>'], > 'Inspector::FrontendChannel::ConnectionType': ['<JavaScriptCore/InspectorFrontendChannel.h>'], >+ 'WebCore::DisplayList::ItemBufferIdentifier': ['<WebCore/DisplayList.h>'], > 'MediaTime': ['<wtf/MediaTime.h>'], > 'MonotonicTime': ['<wtf/MonotonicTime.h>'], > 'Seconds': ['<wtf/Seconds.h>'], >diff --git a/Source/WebKit/Shared/SharedDisplayListHandle.cpp b/Source/WebKit/Shared/SharedDisplayListHandle.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..1aa74d615abd3f4a3186252ff0fdcb871e70fa50 >--- /dev/null >+++ b/Source/WebKit/Shared/SharedDisplayListHandle.cpp >@@ -0,0 +1,53 @@ >+/* >+ * Copyright (C) 2020 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "SharedDisplayListHandle.h" >+ >+namespace WebKit { >+using namespace WebCore; >+ >+SharedDisplayListHandle::SharedDisplayListHandle(const DisplayList::DisplayList& displayList) >+{ >+ displayList.forEachItemBuffer([&] (auto& handle) { >+ m_buffers.append({ handle.identifier, handle.capacity }); >+ }); >+} >+ >+std::unique_ptr<DisplayList::DisplayList> SharedDisplayListHandle::createDisplayList(ItemBufferProvider&& bufferProvider) const >+{ >+ DisplayList::ItemBufferHandles handles; >+ handles.reserveInitialCapacity(m_buffers.size()); >+ for (auto& [identifier, capacity] : m_buffers) { >+ auto* data = bufferProvider(identifier); >+ if (!data) >+ return nullptr; >+ >+ handles.uncheckedAppend({ identifier, data, capacity }); >+ } >+ return makeUnique<DisplayList::DisplayList>(WTFMove(handles)); >+} >+ >+} // namespace WebKit >diff --git a/Source/WebKit/Shared/SharedDisplayListHandle.h b/Source/WebKit/Shared/SharedDisplayListHandle.h >new file mode 100644 >index 0000000000000000000000000000000000000000..d175e114f23bc8fb8e57cd90f64a33be262e1f31 >--- /dev/null >+++ b/Source/WebKit/Shared/SharedDisplayListHandle.h >@@ -0,0 +1,66 @@ >+/* >+ * Copyright (C) 2020 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include <WebCore/DisplayList.h> >+ >+namespace WebKit { >+ >+class SharedDisplayListHandle { >+public: >+ using ItemBufferProvider = Function<uint8_t*(WebCore::DisplayList::ItemBufferIdentifier)>; >+ >+ SharedDisplayListHandle(const WebCore::DisplayList::DisplayList&); >+ std::unique_ptr<WebCore::DisplayList::DisplayList> createDisplayList(ItemBufferProvider&&) const; >+ >+ template<class Encoder> void encode(Encoder&) const; >+ template<class Decoder> static Optional<SharedDisplayListHandle> decode(Decoder&); >+ >+private: >+ SharedDisplayListHandle(Vector<std::pair<WebCore::DisplayList::ItemBufferIdentifier, size_t>>&& buffers) >+ : m_buffers(WTFMove(buffers)) >+ { >+ } >+ >+ Vector<std::pair<WebCore::DisplayList::ItemBufferIdentifier, size_t>> m_buffers; >+}; >+ >+template<class Encoder> void SharedDisplayListHandle::encode(Encoder& encoder) const >+{ >+ encoder << m_buffers; >+} >+ >+template<class Decoder> Optional<SharedDisplayListHandle> SharedDisplayListHandle::decode(Decoder& decoder) >+{ >+ Optional<Vector<std::pair<WebCore::DisplayList::ItemBufferIdentifier, size_t>>> buffers; >+ decoder >> buffers; >+ if (!buffers) >+ return WTF::nullopt; >+ >+ return {{ WTFMove(*buffers) }}; >+} >+ >+} // namespace WebKit >diff --git a/Source/WebKit/Sources.txt b/Source/WebKit/Sources.txt >index 351af4278c985959aecfb15dbf0ab7cb5e204b75..6952967451a69d2533eac9665beac4569cd1d65a 100644 >--- a/Source/WebKit/Sources.txt >+++ b/Source/WebKit/Sources.txt >@@ -174,6 +174,7 @@ Shared/ServiceWorkerInitializationData.cpp > Shared/SessionState.cpp > Shared/ShareableBitmap.cpp @no-unify > Shared/ShareableResource.cpp >+Shared/SharedDisplayListHandle.cpp > Shared/SharedStringHashStore.cpp > Shared/SharedStringHashTableReadOnly.cpp > Shared/SharedStringHashTable.cpp >diff --git a/Source/WebKit/WebKit.xcodeproj/project.pbxproj b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >index 8aca60525fb3b93390be72247f92ed6b229cef7d..f5c38ec6c150d1b1ac46a1f59870a3737204bfd4 100644 >--- a/Source/WebKit/WebKit.xcodeproj/project.pbxproj >+++ b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >@@ -1890,6 +1890,7 @@ > F44DFEB21E9E752F0038D196 /* WebIconUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = F44DFEB01E9E752F0038D196 /* WebIconUtilities.h */; }; > F48D2A8521583A7E00C6752B /* AppKitSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = F48D2A8421583A0200C6752B /* AppKitSPI.h */; }; > F496A4311F58A272004C1757 /* DragDropInteractionState.h in Headers */ = {isa = PBXBuildFile; fileRef = F496A42F1F58A272004C1757 /* DragDropInteractionState.h */; }; >+ F4A6D6BC254CA3E900B65FAA /* SharedDisplayListHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = F4A6D6BB254CA3E900B65FAA /* SharedDisplayListHandle.h */; }; > F4CB09E5225D5A0900891487 /* WebsiteMediaSourcePolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = F4CB09E4225D5A0300891487 /* WebsiteMediaSourcePolicy.h */; }; > F4D5F51D206087A10038BBA8 /* WKTextInputListViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = F4D5F519206087A00038BBA8 /* WKTextInputListViewController.h */; }; > F4D5F51F206087A10038BBA8 /* WKQuickboardListViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = F4D5F51B206087A10038BBA8 /* WKQuickboardListViewController.h */; }; >@@ -5507,6 +5508,8 @@ > F48D2A8421583A0200C6752B /* AppKitSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppKitSPI.h; sourceTree = "<group>"; }; > F496A42F1F58A272004C1757 /* DragDropInteractionState.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DragDropInteractionState.h; path = ios/DragDropInteractionState.h; sourceTree = "<group>"; }; > F496A4301F58A272004C1757 /* DragDropInteractionState.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = DragDropInteractionState.mm; path = ios/DragDropInteractionState.mm; sourceTree = "<group>"; }; >+ F4A6D6BB254CA3E900B65FAA /* SharedDisplayListHandle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SharedDisplayListHandle.h; sourceTree = "<group>"; }; >+ F4A6D6BD254CA52200B65FAA /* SharedDisplayListHandle.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SharedDisplayListHandle.cpp; sourceTree = "<group>"; }; > F4AC655E22A3140E00A05607 /* WebPreferencesDefaultValuesIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebPreferencesDefaultValuesIOS.mm; path = ios/WebPreferencesDefaultValuesIOS.mm; sourceTree = "<group>"; }; > F4B378D021DDBBAB0095A378 /* WebUndoStepID.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebUndoStepID.h; sourceTree = "<group>"; }; > F4CB09E4225D5A0300891487 /* WebsiteMediaSourcePolicy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebsiteMediaSourcePolicy.h; sourceTree = "<group>"; }; >@@ -6216,6 +6219,8 @@ > 1A6420E312DCE2FF00CAAE2C /* ShareableBitmap.h */, > 5121745E164C20E30037A5C1 /* ShareableResource.cpp */, > 5121745F164C20E30037A5C1 /* ShareableResource.h */, >+ F4A6D6BD254CA52200B65FAA /* SharedDisplayListHandle.cpp */, >+ F4A6D6BB254CA3E900B65FAA /* SharedDisplayListHandle.h */, > 8313F7EA1F7DAE0400B944EB /* SharedStringHashStore.cpp */, > 8313F7E91F7DAE0300B944EB /* SharedStringHashStore.h */, > 8313F7E81F7DAE0300B944EB /* SharedStringHashTable.cpp */, >@@ -11398,6 +11403,7 @@ > 51217461164C20E30037A5C1 /* ShareableResource.h in Headers */, > A183494224EF467800BDC9A8 /* SharedBufferCopy.h in Headers */, > 2DC18FF6EF2A3130C1301767 /* SharedBufferDataReference.h in Headers */, >+ F4A6D6BC254CA3E900B65FAA /* SharedDisplayListHandle.h in Headers */, > 1A24BED5120894D100FBB059 /* SharedMemory.h in Headers */, > CD4B4D9D1E765E0000D27092 /* SharedRingBufferStorage.h in Headers */, > 8313F7EC1F7DAE0800B944EB /* SharedStringHashStore.h in Headers */, >diff --git a/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h b/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h >index 923b4cbc6aef62dc76a9fa33ab7337e2ff5c1b07..3dbd8e3c2f23c36ba41f41e0aba2f0aea38625b2 100644 >--- a/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h >+++ b/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h >@@ -27,6 +27,10 @@ > > #if ENABLE(GPU_PROCESS) > >+#include "Encoder.h" >+#include "RemoteRenderingBackendProxy.h" >+#include "SharedMemory.h" >+#include <WebCore/DisplayList.h> > #include <WebCore/DisplayListImageBuffer.h> > #include <WebCore/DisplayListItems.h> > #include <WebCore/DisplayListRecorder.h> >@@ -36,7 +40,7 @@ namespace WebKit { > class RemoteRenderingBackend; > > template<typename BackendType> >-class RemoteImageBufferProxy : public WebCore::DisplayList::ImageBuffer<BackendType>, public WebCore::DisplayList::Recorder::Delegate { >+class RemoteImageBufferProxy : public WebCore::DisplayList::ImageBuffer<BackendType>, public WebCore::DisplayList::Recorder::Delegate, public WebCore::DisplayList::ItemBufferWritingClient { > using BaseDisplayListImageBuffer = WebCore::DisplayList::ImageBuffer<BackendType>; > using BaseDisplayListImageBuffer::m_backend; > using BaseDisplayListImageBuffer::m_drawingContext; >@@ -76,6 +80,8 @@ protected: > , m_remoteRenderingBackendProxy(makeWeakPtr(remoteRenderingBackendProxy)) > { > ASSERT(m_remoteRenderingBackendProxy); >+ m_drawingContext.displayList().setItemBufferClient(this); >+ m_drawingContext.displayList().setTracksDrawingItemExtents(false); > } > > bool isPendingFlush() const { return m_sentFlushIdentifier != m_receivedFlushIdentifier; } >@@ -173,6 +179,109 @@ protected: > displayList.clear(); > } > >+ WebCore::DisplayList::ItemBufferHandle createItemBuffer(size_t capacity) override >+ { >+ if (m_remoteRenderingBackendProxy) >+ return m_remoteRenderingBackendProxy->createItemBuffer(capacity); >+ >+ ASSERT_NOT_REACHED(); >+ return { }; >+ } >+ >+ RefPtr<WebCore::SharedBuffer> encodeItem(WebCore::DisplayList::ItemHandle item) const override >+ { >+ switch (item.type()) { >+ case WebCore::DisplayList::ItemType::ClipOutToPath: >+ return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::ClipOutToPath>(item.get<WebCore::DisplayList::ClipOutToPath>()); >+ case WebCore::DisplayList::ItemType::ClipPath: >+ return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::ClipPath>(item.get<WebCore::DisplayList::ClipPath>()); >+ case WebCore::DisplayList::ItemType::ClipToDrawingCommands: >+ return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::ClipToDrawingCommands>(item.get<WebCore::DisplayList::ClipToDrawingCommands>()); >+ case WebCore::DisplayList::ItemType::DrawFocusRingPath: >+ return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::DrawFocusRingPath>(item.get<WebCore::DisplayList::DrawFocusRingPath>()); >+ case WebCore::DisplayList::ItemType::DrawFocusRingRects: >+ return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::DrawFocusRingRects>(item.get<WebCore::DisplayList::DrawFocusRingRects>()); >+ case WebCore::DisplayList::ItemType::DrawGlyphs: >+ return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::DrawGlyphs>(item.get<WebCore::DisplayList::DrawGlyphs>()); >+ case WebCore::DisplayList::ItemType::DrawImage: >+ return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::DrawImage>(item.get<WebCore::DisplayList::DrawImage>()); >+ case WebCore::DisplayList::ItemType::DrawLinesForText: >+ return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::DrawLinesForText>(item.get<WebCore::DisplayList::DrawLinesForText>()); >+ case WebCore::DisplayList::ItemType::DrawNativeImage: >+ return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::DrawNativeImage>(item.get<WebCore::DisplayList::DrawNativeImage>()); >+ case WebCore::DisplayList::ItemType::DrawPath: >+ return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::DrawPath>(item.get<WebCore::DisplayList::DrawPath>()); >+ case WebCore::DisplayList::ItemType::DrawPattern: >+ return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::DrawPattern>(item.get<WebCore::DisplayList::DrawPattern>()); >+ case WebCore::DisplayList::ItemType::DrawTiledImage: >+ return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::DrawTiledImage>(item.get<WebCore::DisplayList::DrawTiledImage>()); >+ case WebCore::DisplayList::ItemType::DrawTiledScaledImage: >+ return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::DrawTiledScaledImage>(item.get<WebCore::DisplayList::DrawTiledScaledImage>()); >+ case WebCore::DisplayList::ItemType::FillCompositedRect: >+ return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::FillCompositedRect>(item.get<WebCore::DisplayList::FillCompositedRect>()); >+ case WebCore::DisplayList::ItemType::FillPath: >+ return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::FillPath>(item.get<WebCore::DisplayList::FillPath>()); >+ case WebCore::DisplayList::ItemType::FillRectWithColor: >+ return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::FillRectWithColor>(item.get<WebCore::DisplayList::FillRectWithColor>()); >+ case WebCore::DisplayList::ItemType::FillRectWithGradient: >+ return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::FillRectWithGradient>(item.get<WebCore::DisplayList::FillRectWithGradient>()); >+ case WebCore::DisplayList::ItemType::FillRectWithRoundedHole: >+ return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::FillRectWithRoundedHole>(item.get<WebCore::DisplayList::FillRectWithRoundedHole>()); >+ case WebCore::DisplayList::ItemType::FillRoundedRect: >+ return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::FillRoundedRect>(item.get<WebCore::DisplayList::FillRoundedRect>()); >+ case WebCore::DisplayList::ItemType::PutImageData: >+ return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::PutImageData>(item.get<WebCore::DisplayList::PutImageData>()); >+ case WebCore::DisplayList::ItemType::SetLineDash: >+ return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::SetLineDash>(item.get<WebCore::DisplayList::SetLineDash>()); >+ case WebCore::DisplayList::ItemType::SetState: >+ return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::SetState>(item.get<WebCore::DisplayList::SetState>()); >+ case WebCore::DisplayList::ItemType::StrokePath: >+ return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::StrokePath>(item.get<WebCore::DisplayList::StrokePath>()); >+ case WebCore::DisplayList::ItemType::ApplyDeviceScaleFactor: >+#if USE(CG) >+ case WebCore::DisplayList::ItemType::ApplyFillPattern: >+ case WebCore::DisplayList::ItemType::ApplyStrokePattern: >+#endif >+ case WebCore::DisplayList::ItemType::BeginTransparencyLayer: >+ case WebCore::DisplayList::ItemType::ClearRect: >+ case WebCore::DisplayList::ItemType::ClearShadow: >+ case WebCore::DisplayList::ItemType::Clip: >+ case WebCore::DisplayList::ItemType::ClipOut: >+ case WebCore::DisplayList::ItemType::ConcatenateCTM: >+ case WebCore::DisplayList::ItemType::DrawDotsForDocumentMarker: >+ case WebCore::DisplayList::ItemType::DrawEllipse: >+ case WebCore::DisplayList::ItemType::DrawImageBuffer: >+ case WebCore::DisplayList::ItemType::DrawLine: >+ case WebCore::DisplayList::ItemType::DrawRect: >+ case WebCore::DisplayList::ItemType::EndTransparencyLayer: >+ case WebCore::DisplayList::ItemType::FillEllipse: >+#if ENABLE(INLINE_PATH_DATA) >+ case WebCore::DisplayList::ItemType::FillInlinePath: >+#endif >+ case WebCore::DisplayList::ItemType::FillRect: >+ case WebCore::DisplayList::ItemType::PaintFrameForMedia: >+ case WebCore::DisplayList::ItemType::Restore: >+ case WebCore::DisplayList::ItemType::Rotate: >+ case WebCore::DisplayList::ItemType::Save: >+ case WebCore::DisplayList::ItemType::Scale: >+ case WebCore::DisplayList::ItemType::SetCTM: >+ case WebCore::DisplayList::ItemType::SetInlineFillColor: >+ case WebCore::DisplayList::ItemType::SetInlineFillGradient: >+ case WebCore::DisplayList::ItemType::SetInlineStrokeColor: >+ case WebCore::DisplayList::ItemType::SetLineCap: >+ case WebCore::DisplayList::ItemType::SetLineJoin: >+ case WebCore::DisplayList::ItemType::SetMiterLimit: >+ case WebCore::DisplayList::ItemType::SetStrokeThickness: >+ case WebCore::DisplayList::ItemType::StrokeEllipse: >+#if ENABLE(INLINE_PATH_DATA) >+ case WebCore::DisplayList::ItemType::StrokeInlinePath: >+#endif >+ case WebCore::DisplayList::ItemType::StrokeRect: >+ case WebCore::DisplayList::ItemType::Translate: >+ RELEASE_ASSERT_NOT_REACHED(); >+ } >+ } >+ > void didAppendItemOfType(WebCore::DisplayList::ItemType type) override > { > if (type == WebCore::DisplayList::ItemType::DrawImageBuffer) >diff --git a/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp b/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp >index f31efaf87310ff8ef520c0925166db6cd302b037..8a8057c59d2bd5d62aaf81fffafa8ecba2ff0673 100644 >--- a/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp >+++ b/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp >@@ -34,6 +34,8 @@ > #include "PlatformRemoteImageBufferProxy.h" > #include "RemoteRenderingBackendMessages.h" > #include "RemoteRenderingBackendProxyMessages.h" >+#include "SharedDisplayListHandle.h" >+#include "SharedMemory.h" > #include "WebProcess.h" > > namespace WebKit { >@@ -115,13 +117,15 @@ RefPtr<ImageData> RemoteRenderingBackendProxy::getImageData(AlphaPremultiplicati > > void RemoteRenderingBackendProxy::flushDisplayList(const DisplayList::DisplayList& displayList, RenderingResourceIdentifier renderingResourceIdentifier) > { >- send(Messages::RemoteRenderingBackend::FlushDisplayList(displayList, renderingResourceIdentifier), m_renderingBackendIdentifier); >+ send(Messages::RemoteRenderingBackend::FlushDisplayList({ displayList }, renderingResourceIdentifier), m_renderingBackendIdentifier); >+ m_sharedItemBuffers.clear(); > } > > DisplayListFlushIdentifier RemoteRenderingBackendProxy::flushDisplayListAndCommit(const DisplayList::DisplayList& displayList, RenderingResourceIdentifier renderingResourceIdentifier) > { > DisplayListFlushIdentifier sentFlushIdentifier = DisplayListFlushIdentifier::generate(); >- send(Messages::RemoteRenderingBackend::FlushDisplayListAndCommit(displayList, sentFlushIdentifier, renderingResourceIdentifier), m_renderingBackendIdentifier); >+ send(Messages::RemoteRenderingBackend::FlushDisplayListAndCommit({ displayList }, sentFlushIdentifier, renderingResourceIdentifier), m_renderingBackendIdentifier); >+ m_sharedItemBuffers.clear(); > return sentFlushIdentifier; > } > >@@ -155,6 +159,23 @@ void RemoteRenderingBackendProxy::flushDisplayListWasCommitted(DisplayListFlushI > downcast<UnacceleratedRemoteImageBufferProxy>(*imageBuffer).commitFlushDisplayList(flushIdentifier); > } > >+DisplayList::ItemBufferHandle RemoteRenderingBackendProxy::createItemBuffer(size_t capacity) >+{ >+ static constexpr size_t defaultSharedItemBufferSize = 1 << 16; >+ >+ auto sharedMemory = SharedMemory::allocate(std::max(defaultSharedItemBufferSize, capacity)); >+ if (!sharedMemory) >+ return { }; >+ >+ auto identifier = DisplayList::ItemBufferIdentifier::generate(); >+ SharedMemory::Handle sharedMemoryHandle; >+ sharedMemory->createHandle(sharedMemoryHandle, SharedMemory::Protection::ReadOnly); >+ send(Messages::RemoteRenderingBackend::DidCreateSharedItemData(identifier, { WTFMove(sharedMemoryHandle), sharedMemory->size() }), m_renderingBackendIdentifier); >+ m_sharedItemBuffers.set(identifier, sharedMemory.copyRef()); >+ >+ return { identifier, reinterpret_cast<uint8_t*>(sharedMemory->data()), sharedMemory->size() }; >+} >+ > } // namespace WebKit > > #endif // ENABLE(GPU_PROCESS) >diff --git a/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h b/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h >index ca055fd36fce1a12bb25bfe6d59351694bcdfade..d36c3eea836863d90fce79099c43e04d98d0dbc0 100644 >--- a/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h >+++ b/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h >@@ -33,6 +33,7 @@ > #include "MessageSender.h" > #include "RemoteResourceCacheProxy.h" > #include "RenderingBackendIdentifier.h" >+#include <WebCore/DisplayList.h> > #include <WebCore/RenderingResourceIdentifier.h> > #include <wtf/WeakPtr.h> > >@@ -60,6 +61,7 @@ public: > ~RemoteRenderingBackendProxy(); > > RemoteResourceCacheProxy& remoteResourceCacheProxy() { return m_remoteResourceCacheProxy; } >+ WebCore::DisplayList::ItemBufferHandle createItemBuffer(size_t); > > // IPC::MessageSender. > IPC::Connection* messageSenderConnection() const override; >@@ -86,6 +88,7 @@ private: > void flushDisplayListWasCommitted(DisplayListFlushIdentifier, WebCore::RenderingResourceIdentifier); > > RemoteResourceCacheProxy m_remoteResourceCacheProxy; >+ HashMap<WebCore::DisplayList::ItemBufferIdentifier, RefPtr<SharedMemory>> m_sharedItemBuffers; > RenderingBackendIdentifier m_renderingBackendIdentifier { RenderingBackendIdentifier::generate() }; > }; > >diff --git a/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.messages.in b/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.messages.in >index 8f24585635f47083d1db27a5b396665f315ebcb0..9f26a230cf68b0bf880928b7cefbbd87f85344df 100644 >--- a/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.messages.in >+++ b/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.messages.in >@@ -23,8 +23,8 @@ > #if ENABLE(GPU_PROCESS) > > messages -> RemoteRenderingBackendProxy NotRefCounted { >- void ImageBufferBackendWasCreated(WebCore::FloatSize logicalSize, WebCore::IntSize backendSize, float resolutionScale, WebCore::ColorSpace colorSpace, WebKit::ImageBufferBackendHandle handle, WebCore::RenderingResourceIdentifier renderingResourceIdentifier) >- void FlushDisplayListWasCommitted(WebKit::DisplayListFlushIdentifier flushIdentifier, WebCore::RenderingResourceIdentifier renderingResourceIdentifier) >+ ImageBufferBackendWasCreated(WebCore::FloatSize logicalSize, WebCore::IntSize backendSize, float resolutionScale, WebCore::ColorSpace colorSpace, WebKit::ImageBufferBackendHandle handle, WebCore::RenderingResourceIdentifier renderingResourceIdentifier) >+ FlushDisplayListWasCommitted(WebKit::DisplayListFlushIdentifier flushIdentifier, WebCore::RenderingResourceIdentifier renderingResourceIdentifier) > } > > #endif // ENABLE(GPU_PROCESS) >diff --git a/Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.cpp b/Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.cpp >index 82504217be7615b487a0cd32f7df187724672eb2..faff92a04ddfcbbd58386ec9bfaad9e1355a556f 100644 >--- a/Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.cpp >+++ b/Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.cpp >@@ -28,6 +28,9 @@ > > #if ENABLE(GPU_PROCESS) > >+#include "RemoteRenderingBackendProxy.h" >+#include <WebCore/ImageBuffer.h> >+ > namespace WebKit { > using namespace WebCore; > >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 6757b8e087c7f697d397536d10c695d9792359d9..01c769959ec97e736aaa77e92f93a28639404f8e 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,20 @@ >+2020-10-30 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ [Concurrent display lists] Encode display list items directly into shared memory >+ https://bugs.webkit.org/show_bug.cgi?id=218406 >+ >+ Reviewed by Tim Horton. >+ >+ Rebaseline several existing (non-GPU-process) display list tests to account for a slight tweak in the format in >+ which display lists are dumped as text. More specifically, drawing item extents are now dumped after each >+ drawing item, rather than before. >+ >+ * displaylists/canvas-display-list-expected.txt: >+ * displaylists/extent-includes-shadow-expected.txt: >+ * displaylists/extent-includes-transforms-expected.txt: >+ * displaylists/layer-dispay-list-expected.txt: >+ * displaylists/replay-skip-clipped-rect-expected.txt: >+ > 2020-11-06 Diego Pino Garcia <dpino@igalia.com> > > [WPE] Unreviewed test gardening. Gardened several flaky failures reported by the bot. >diff --git a/LayoutTests/displaylists/canvas-display-list-expected.txt b/LayoutTests/displaylists/canvas-display-list-expected.txt >index 3288480627019d5402d9425fc4a1313770ecb31a..1451b19253c3238928bbd9f5e5debb9274c50d57 100644 >--- a/LayoutTests/displaylists/canvas-display-list-expected.txt >+++ b/LayoutTests/displaylists/canvas-display-list-expected.txt >@@ -6,10 +6,8 @@ > (fill-color #C80000) > (shadows-ignore-transforms 1)) > (fill-rect >- (extent at (10,140) size 55x50) >- (rect at (10,10) size 55x50)) >+ (rect at (10,10) size 55x50) extent at (10,140) size 55x50) > (set-inline-fill-color > (color #0000C880)) > (fill-rect >- (extent at (30,120) size 55x50) >- (rect at (30,30) size 55x50)) >+ (rect at (30,30) size 55x50) extent at (30,120) size 55x50) >diff --git a/LayoutTests/displaylists/extent-includes-shadow-expected.txt b/LayoutTests/displaylists/extent-includes-shadow-expected.txt >index e9f540417bd6e5dc778615e5f3794976e4195f8d..590b93f5c892cae37f424609a8fe48033e668368 100644 >--- a/LayoutTests/displaylists/extent-includes-shadow-expected.txt >+++ b/LayoutTests/displaylists/extent-includes-shadow-expected.txt >@@ -9,9 +9,8 @@ > (shadow-offset width=10 height=20) > (shadows-use-legacy-radius 0)) > (fill-composited-rect >- (extent at (43,50) size 134x137) > (rect at (50,50) size 100x100) > (color #0000FF) > (composite-operation source-over) >- (blend-mode normal)) >+ (blend-mode normal) extent at (43,50) size 134x137) > (restore) >diff --git a/LayoutTests/displaylists/extent-includes-transforms-expected.txt b/LayoutTests/displaylists/extent-includes-transforms-expected.txt >index e0452a173a1afe237f728d30bc27ec60eec9623d..28ccf4c01859de190b0a9a27fa2fec0063ed8e1c 100644 >--- a/LayoutTests/displaylists/extent-includes-transforms-expected.txt >+++ b/LayoutTests/displaylists/extent-includes-transforms-expected.txt >@@ -11,11 +11,10 @@ > (shadow-offset width=10 height=20) > (shadows-use-legacy-radius 0)) > (fill-composited-rect >- (extent at (7.14,0.20) size 184.55x185.65) > (rect at (0,0) size 100x100) > (color #0000FF) > (composite-operation source-over) >- (blend-mode normal)) >+ (blend-mode normal) extent at (7.14,0.20) size 184.55x185.65) > (restore) > (set-ctm > (set-ctm {m=((1.00,0.00)(0.00,1.00)) t=(0.00,22.00)})) >diff --git a/LayoutTests/displaylists/layer-dispay-list-expected.txt b/LayoutTests/displaylists/layer-dispay-list-expected.txt >index bd876df403a4add0bc391f7c62ac2b4c3bcf7da0..bc17b511499f8256c99290dae8614d4894caf9cc 100644 >--- a/LayoutTests/displaylists/layer-dispay-list-expected.txt >+++ b/LayoutTests/displaylists/layer-dispay-list-expected.txt >@@ -3,29 +3,24 @@ > (x 0.00) > (y 0.00)) > (fill-composited-rect >- (extent at (0,0) size 104x104) > (rect at (0,0) size 104x104) > (color #008000) > (composite-operation source-over) >- (blend-mode normal)) >+ (blend-mode normal) extent at (0,0) size 104x104) > (set-state > (change-flags 32960) > (fill-color #0000FF) > (stroke-style 0) > (should-antialias 0)) > (draw-rect >- (extent at (0,0) size 104x2) > (rect at (0,0) size 104x2) >- (border-thickness 1.00)) >+ (border-thickness 1.00) extent at (0,0) size 104x2) > (draw-rect >- (extent at (0,102) size 104x2) > (rect at (0,102) size 104x2) >- (border-thickness 1.00)) >+ (border-thickness 1.00) extent at (0,102) size 104x2) > (draw-rect >- (extent at (0,0) size 2x104) > (rect at (0,0) size 2x104) >- (border-thickness 1.00)) >+ (border-thickness 1.00) extent at (0,0) size 2x104) > (draw-rect >- (extent at (102,0) size 2x104) > (rect at (102,0) size 2x104) >- (border-thickness 1.00)) >+ (border-thickness 1.00) extent at (102,0) size 2x104) >diff --git a/LayoutTests/displaylists/replay-skip-clipped-rect-expected.txt b/LayoutTests/displaylists/replay-skip-clipped-rect-expected.txt >index addd2ca4250c24a0c9ee2255d4275a76f6043eed..bb593d20f6da6486292d36c0220e2a9d872f82b9 100644 >--- a/LayoutTests/displaylists/replay-skip-clipped-rect-expected.txt >+++ b/LayoutTests/displaylists/replay-skip-clipped-rect-expected.txt >@@ -3,11 +3,10 @@ recorded: > (x 0.00) > (y 0.00)) > (fill-composited-rect >- (extent at (412,0) size 100x100) > (rect at (412,0) size 100x100) > (color #0000FF) > (composite-operation source-over) >- (blend-mode normal)) >+ (blend-mode normal) extent at (412,0) size 100x100) > > replayed: > (
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
ews-feeder
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 218406
:
412811
|
412979
|
412985
|
412987
|
412991
|
412993
|
413116
|
413130
|
413131
|
413343
|
413362
|
413436
|
413437