Changeset 275587 in webkit
- Timestamp:
- Apr 6, 2021 10:56:24 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r275585 r275587 1 2021-04-06 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [GPU Process] Simplify DisplayList::Iterator part 5: Tweak the return type of DisplayList::Iterator::operator*() 4 https://bugs.webkit.org/show_bug.cgi?id=224148 5 6 Reviewed by Wenson Hsieh. 7 8 This patch migrates from 9 10 struct Value { 11 Optional<ItemHandle> item; 12 Optional<FloatRect> extent; 13 size_t itemSizeInBuffer { 0 }; 14 }; 15 Value operator*() const; 16 17 to 18 19 struct Value { 20 ItemHandle item; 21 Optional<FloatRect> extent; 22 size_t itemSizeInBuffer { 0 }; 23 }; 24 Optional<Value> operator*() const 25 26 There are two reasons for this: 27 1. Philosophically, if the item is nullopt, then all the stuff in the Value is also meaningless 28 2. Part of the iterator's API contract is that if the item is nullopt, you're not allowed to keep 29 iterating - doing this will lead to an infinite loop. Promoting the optional makes it more 30 likely that this API contract is followed in the future. 31 32 No new tests because there is no behavior change. 33 34 * platform/graphics/displaylists/DisplayList.cpp: 35 (WebCore::DisplayList::DisplayList::asText const): 36 (WebCore::DisplayList::DisplayList::dump const): 37 * platform/graphics/displaylists/DisplayList.h: 38 (WebCore::DisplayList::DisplayList::iterator::operator* const): 39 * platform/graphics/displaylists/DisplayListReplayer.cpp: 40 (WebCore::DisplayList::Replayer::replay): 41 1 42 2021-04-06 Zalan Bujtas <zalan@apple.com> 2 43 -
trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp
r275557 r275587 115 115 { 116 116 TextStream stream(TextStream::LineMode::MultipleLine, TextStream::Formatting::SVGStyleRect); 117 for (auto [item, extent, itemSizeInBuffer] : *this) { 118 if (!shouldDumpForFlags(flags, *item)) 117 for (auto displayListItem : *this) { 118 auto [item, extent, itemSizeInBuffer] = displayListItem.value(); 119 if (!shouldDumpForFlags(flags, item)) 119 120 continue; 120 121 121 122 TextStream::GroupScope group(stream); 122 123 stream << item; 123 if (item ->isDrawingItem())124 if (item.isDrawingItem()) 124 125 stream << " extent " << extent; 125 126 } … … 132 133 ts << "display list"; 133 134 134 for (auto [item, extent, itemSizeInBuffer] : *this) { 135 for (auto displayListItem : *this) { 136 auto [item, extent, itemSizeInBuffer] = displayListItem.value(); 135 137 TextStream::GroupScope group(ts); 136 138 ts << item; 137 if (item ->isDrawingItem())139 if (item.isDrawingItem()) 138 140 ts << " extent " << extent; 139 141 } -
trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.h
r275334 r275587 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016-2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 119 119 120 120 struct Value { 121 Optional<ItemHandle>item;121 ItemHandle item; 122 122 Optional<FloatRect> extent; 123 123 size_t itemSizeInBuffer { 0 }; 124 124 }; 125 125 126 Valueoperator*() const126 Optional<Value> operator*() const 127 127 { 128 return { 129 m_isValid ? makeOptional(ItemHandle { m_currentBufferForItem }) : WTF::nullopt, 128 if (!m_isValid) 129 return WTF::nullopt; 130 return {{ 131 ItemHandle { m_currentBufferForItem }, 130 132 m_currentExtent, 131 133 m_currentItemSizeInBuffer, 132 } ;134 }}; 133 135 } 134 136 -
trunk/Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.cpp
r275459 r275587 189 189 #endif 190 190 ReplayResult result; 191 for (auto [item, extent, itemSizeInBuffer] : m_displayList) { 191 for (auto displayListItem : m_displayList) { 192 if (!displayListItem) { 193 result.reasonForStopping = StopReplayReason::InvalidItemOrExtent; 194 break; 195 } 196 197 auto [item, extent, itemSizeInBuffer] = displayListItem.value(); 198 192 199 if (!initialClip.isZero() && extent && !extent->intersects(initialClip)) { 193 200 LOG_WITH_STREAM(DisplayLists, stream << "skipping " << i++ << " " << item); … … 196 203 } 197 204 198 if (!item) {199 result.reasonForStopping = StopReplayReason::InvalidItemOrExtent;200 break;201 }202 203 205 LOG_WITH_STREAM(DisplayLists, stream << "applying " << i++ << " " << item); 204 206 205 if (item ->is<MetaCommandChangeDestinationImageBuffer>()) {207 if (item.is<MetaCommandChangeDestinationImageBuffer>()) { 206 208 result.numberOfBytesRead += itemSizeInBuffer; 207 209 result.reasonForStopping = StopReplayReason::ChangeDestinationImageBuffer; 208 result.nextDestinationImageBuffer = item ->get<MetaCommandChangeDestinationImageBuffer>().identifier();210 result.nextDestinationImageBuffer = item.get<MetaCommandChangeDestinationImageBuffer>().identifier(); 209 211 break; 210 212 } 211 213 212 if (auto [reasonForStopping, missingCachedResourceIdentifier] = applyItem( *item); reasonForStopping) {214 if (auto [reasonForStopping, missingCachedResourceIdentifier] = applyItem(item); reasonForStopping) { 213 215 result.reasonForStopping = *reasonForStopping; 214 216 result.missingCachedResourceIdentifier = WTFMove(missingCachedResourceIdentifier); … … 219 221 220 222 if (UNLIKELY(trackReplayList)) { 221 replayList->append( *item);222 if (item ->isDrawingItem())223 replayList->append(item); 224 if (item.isDrawingItem()) 223 225 replayList->addDrawingItemExtent(WTFMove(extent)); 224 226 } -
trunk/Source/WebCore/platform/graphics/displaylists/InMemoryDisplayList.cpp
r275459 r275587 62 62 { 63 63 auto end = this->end(); 64 for (auto [item, extent, size] : *this) { 64 for (auto displayListItem : *this) { 65 auto item = displayListItem->item; 65 66 ASSERT(item); 66 67 if (!item) 67 68 break; 68 item ->destroy();69 item.destroy(); 69 70 } 70 71 } -
trunk/Tools/ChangeLog
r275581 r275587 1 2021-04-06 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [GPU Process] Simplify DisplayList::Iterator part 5: Tweak the return type of DisplayList::Iterator::operator*() 4 https://bugs.webkit.org/show_bug.cgi?id=224148 5 6 Reviewed by Wenson Hsieh. 7 8 * TestWebKitAPI/Tests/WebCore/DisplayListTests.cpp: 9 (TestWebKitAPI::TEST): 10 1 11 2021-04-06 Jean-Yves Avenard <jya@apple.com> 2 12 -
trunk/Tools/TestWebKitAPI/Tests/WebCore/DisplayListTests.cpp
r275459 r275587 80 80 81 81 bool observedUnexpectedItem = false; 82 for (auto [handle, extent, size] : list) { 83 switch (handle->type()) { 82 for (auto displayListItem : list) { 83 auto handle = displayListItem->item; 84 switch (handle.type()) { 84 85 case ItemType::SetStrokeThickness: { 85 EXPECT_FALSE(handle ->isDrawingItem());86 EXPECT_TRUE(handle ->is<SetStrokeThickness>());87 auto& item = handle ->get<SetStrokeThickness>();86 EXPECT_FALSE(handle.isDrawingItem()); 87 EXPECT_TRUE(handle.is<SetStrokeThickness>()); 88 auto& item = handle.get<SetStrokeThickness>(); 88 89 EXPECT_EQ(item.thickness(), 1.5); 89 90 break; 90 91 } 91 92 case ItemType::FillPath: { 92 EXPECT_TRUE(handle ->isDrawingItem());93 EXPECT_TRUE(handle ->is<FillPath>());94 auto& item = handle ->get<FillPath>();93 EXPECT_TRUE(handle.isDrawingItem()); 94 EXPECT_TRUE(handle.is<FillPath>()); 95 auto& item = handle.get<FillPath>(); 95 96 EXPECT_EQ(item.path().platformPath(), path.platformPath()); 96 97 break; 97 98 } 98 99 case ItemType::FillRectWithGradient: { 99 EXPECT_TRUE(handle ->isDrawingItem());100 EXPECT_TRUE(handle ->is<FillRectWithGradient>());101 auto& item = handle ->get<FillRectWithGradient>();100 EXPECT_TRUE(handle.isDrawingItem()); 101 EXPECT_TRUE(handle.is<FillRectWithGradient>()); 102 auto& item = handle.get<FillRectWithGradient>(); 102 103 EXPECT_EQ(item.rect(), FloatRect(1., 1., 10., 10.)); 103 104 EXPECT_EQ(&item.gradient(), gradient.ptr()); … … 105 106 } 106 107 case ItemType::SetInlineFillColor: { 107 EXPECT_FALSE(handle ->isDrawingItem());108 EXPECT_TRUE(handle ->is<SetInlineFillColor>());109 auto& item = handle ->get<SetInlineFillColor>();108 EXPECT_FALSE(handle.isDrawingItem()); 109 EXPECT_TRUE(handle.is<SetInlineFillColor>()); 110 auto& item = handle.get<SetInlineFillColor>(); 110 111 EXPECT_EQ(item.color(), Color::red); 111 112 break; … … 113 114 #if ENABLE(INLINE_PATH_DATA) 114 115 case ItemType::StrokeInlinePath: { 115 EXPECT_TRUE(handle ->isDrawingItem());116 EXPECT_TRUE(handle ->is<StrokeInlinePath>());117 auto& item = handle ->get<StrokeInlinePath>();116 EXPECT_TRUE(handle.isDrawingItem()); 117 EXPECT_TRUE(handle.is<StrokeInlinePath>()); 118 auto& item = handle.get<StrokeInlinePath>(); 118 119 const auto path = item.path(); 119 120 auto& line = path.inlineData<LineData>(); … … 149 150 list.append<FillRectWithColor>(FloatRect { 0, 0, 100, 100 }, Color::black); 150 151 151 for (auto [handle, extent, size] : list) { 152 EXPECT_EQ(handle->type(), ItemType::FillRectWithColor); 153 EXPECT_TRUE(handle->is<FillRectWithColor>()); 154 155 auto& item = handle->get<FillRectWithColor>(); 152 for (auto displayListItem : list) { 153 auto handle = displayListItem->item; 154 EXPECT_EQ(handle.type(), ItemType::FillRectWithColor); 155 EXPECT_TRUE(handle.is<FillRectWithColor>()); 156 157 auto& item = handle.get<FillRectWithColor>(); 156 158 EXPECT_EQ(*item.color().tryGetAsSRGBABytes(), Color::black); 157 159 EXPECT_EQ(item.rect(), FloatRect(0, 0, 100, 100)); … … 225 227 226 228 Vector<ItemType> itemTypes; 227 for (auto [handle, extent, size]: shallowCopy)228 itemTypes.append( handle->type());229 for (auto displayListItem : shallowCopy) 230 itemTypes.append(displayListItem->item.type()); 229 231 230 232 EXPECT_FALSE(shallowCopy.isEmpty());
Note: See TracChangeset
for help on using the changeset viewer.