Skip to content
Permalink
Browse files
Delete WebCore::DisplayList::SetInlineFillGradient
https://bugs.webkit.org/show_bug.cgi?id=231326

Reviewed by Simon Fraser.

Source/WebCore:

Remove this display list item, because:

-       It should never have been encoded and decoded as POD data in the first place, due to the fact that it
        indirectly contains Variants.

-       Deleting this item does not cause any significant performance impact when using streaming IPC for
        display lists.

* platform/graphics/displaylists/DisplayList.cpp:
(WebCore::DisplayList::DisplayList::append):
* platform/graphics/displaylists/DisplayListItemBuffer.cpp:
(WebCore::DisplayList::ItemHandle::apply):
(WebCore::DisplayList::ItemHandle::destroy):
(WebCore::DisplayList::ItemHandle::safeCopy const):
* platform/graphics/displaylists/DisplayListItemType.cpp:
(WebCore::DisplayList::sizeOfItemInBytes):
(WebCore::DisplayList::isDrawingItem):
(WebCore::DisplayList::isInlineItem):
* platform/graphics/displaylists/DisplayListItemType.h:
* platform/graphics/displaylists/DisplayListItems.cpp:
(WebCore::DisplayList::operator<<):
(WebCore::DisplayList::SetInlineFillGradient::SetInlineFillGradient): Deleted.
(WebCore::DisplayList::SetInlineFillGradient::gradient const): Deleted.
(WebCore::DisplayList::SetInlineFillGradient::apply const): Deleted.
(WebCore::DisplayList::SetInlineFillGradient::isInline): Deleted.
* platform/graphics/displaylists/DisplayListItems.h:
(WebCore::DisplayList::SetInlineFillGradient::isValid const): Deleted.
* platform/graphics/displaylists/DisplayListRecorder.cpp:
(WebCore::DisplayList::containsOnlyInlineStateChanges):
(WebCore::DisplayList::Recorder::appendStateChangeItem):

Source/WebKit:

See WebCore/ChangeLog for more details.

* GPUProcess/graphics/RemoteRenderingBackend.cpp:
(WebKit::RemoteRenderingBackend::decodeItem):


Canonical link: https://commits.webkit.org/242623@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@283697 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
whsieh committed Oct 7, 2021
1 parent 23df4ba commit bd50e608a8e6a8faa778138e33f0f3c7ac737a9c
Showing 10 changed files with 50 additions and 134 deletions.
@@ -1,3 +1,41 @@
2021-10-06 Wenson Hsieh <wenson_hsieh@apple.com>

Delete WebCore::DisplayList::SetInlineFillGradient
https://bugs.webkit.org/show_bug.cgi?id=231326

Reviewed by Simon Fraser.

Remove this display list item, because:

- It should never have been encoded and decoded as POD data in the first place, due to the fact that it
indirectly contains Variants.

- Deleting this item does not cause any significant performance impact when using streaming IPC for
display lists.

* platform/graphics/displaylists/DisplayList.cpp:
(WebCore::DisplayList::DisplayList::append):
* platform/graphics/displaylists/DisplayListItemBuffer.cpp:
(WebCore::DisplayList::ItemHandle::apply):
(WebCore::DisplayList::ItemHandle::destroy):
(WebCore::DisplayList::ItemHandle::safeCopy const):
* platform/graphics/displaylists/DisplayListItemType.cpp:
(WebCore::DisplayList::sizeOfItemInBytes):
(WebCore::DisplayList::isDrawingItem):
(WebCore::DisplayList::isInlineItem):
* platform/graphics/displaylists/DisplayListItemType.h:
* platform/graphics/displaylists/DisplayListItems.cpp:
(WebCore::DisplayList::operator<<):
(WebCore::DisplayList::SetInlineFillGradient::SetInlineFillGradient): Deleted.
(WebCore::DisplayList::SetInlineFillGradient::gradient const): Deleted.
(WebCore::DisplayList::SetInlineFillGradient::apply const): Deleted.
(WebCore::DisplayList::SetInlineFillGradient::isInline): Deleted.
* platform/graphics/displaylists/DisplayListItems.h:
(WebCore::DisplayList::SetInlineFillGradient::isValid const): Deleted.
* platform/graphics/displaylists/DisplayListRecorder.cpp:
(WebCore::DisplayList::containsOnlyInlineStateChanges):
(WebCore::DisplayList::Recorder::appendStateChangeItem):

2021-10-06 Jean-Yves Avenard <jya@apple.com>

Have SourceBufferPrivateAVJObjC use WorkQueue instead of dispatch_async
@@ -214,8 +214,6 @@ void DisplayList::append(ItemHandle item)
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:
@@ -66,9 +66,6 @@ void ItemHandle::apply(GraphicsContext& context)
case ItemType::SetCTM:
get<SetCTM>().apply(context);
return;
case ItemType::SetInlineFillGradient:
get<SetInlineFillGradient>().apply(context);
return;
case ItemType::SetInlineFillColor:
get<SetInlineFillColor>().apply(context);
return;
@@ -424,9 +421,6 @@ void ItemHandle::destroy()
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;
@@ -616,8 +610,6 @@ bool ItemHandle::safeCopy(ItemType itemType, ItemHandle destination) const
return copyInto<SetCTM>(itemOffset, *this);
case ItemType::SetInlineFillColor:
return copyInto<SetInlineFillColor>(itemOffset, *this);
case ItemType::SetInlineFillGradient:
return copyInto<SetInlineFillGradient>(itemOffset, *this);
case ItemType::SetInlineStrokeColor:
return copyInto<SetInlineStrokeColor>(itemOffset, *this);
case ItemType::SetLineCap:
@@ -48,8 +48,6 @@ static size_t sizeOfItemInBytes(ItemType type)
return sizeof(ConcatenateCTM);
case ItemType::SetCTM:
return sizeof(SetCTM);
case ItemType::SetInlineFillGradient:
return sizeof(SetInlineFillGradient);
case ItemType::SetInlineFillColor:
return sizeof(SetInlineFillColor);
case ItemType::SetInlineStrokeColor:
@@ -210,7 +208,6 @@ bool isDrawingItem(ItemType type)
case ItemType::Scale:
case ItemType::SetCTM:
case ItemType::SetInlineFillColor:
case ItemType::SetInlineFillGradient:
case ItemType::SetInlineStrokeColor:
case ItemType::SetLineCap:
case ItemType::SetLineDash:
@@ -357,7 +354,6 @@ bool isInlineItem(ItemType type)
case ItemType::Scale:
case ItemType::SetCTM:
case ItemType::SetInlineFillColor:
case ItemType::SetInlineFillGradient:
case ItemType::SetInlineStrokeColor:
case ItemType::SetLineCap:
case ItemType::SetLineJoin:
@@ -36,7 +36,6 @@ enum class ItemType : uint8_t {
Scale,
ConcatenateCTM,
SetCTM,
SetInlineFillGradient,
SetInlineFillColor,
SetInlineStrokeColor,
SetStrokeThickness,
@@ -114,83 +114,6 @@ static TextStream& operator<<(TextStream& ts, const ConcatenateCTM& item)
return ts;
}

SetInlineFillGradient::SetInlineFillGradient(const Gradient& gradient, const AffineTransform& gradientSpaceTransform)
: m_data(gradient.data())
, m_gradientSpaceTransform(gradientSpaceTransform)
, m_spreadMethod(gradient.spreadMethod())
, m_colorStopCount(static_cast<uint8_t>(gradient.stops().size()))
{
RELEASE_ASSERT(m_colorStopCount <= maxColorStopCount);
for (uint8_t i = 0; i < m_colorStopCount; ++i) {
m_offsets[i] = gradient.stops()[i].offset;
m_colors[i] = *gradient.stops()[i].color.tryGetAsSRGBABytes();
}
}

SetInlineFillGradient::SetInlineFillGradient(float offsets[maxColorStopCount], SRGBA<uint8_t> colors[maxColorStopCount], const Gradient::Data& data, const AffineTransform& gradientSpaceTransform, GradientSpreadMethod spreadMethod, uint8_t colorStopCount)
: m_data(data)
, m_gradientSpaceTransform(gradientSpaceTransform)
, m_spreadMethod(spreadMethod)
, m_colorStopCount(colorStopCount)
{
RELEASE_ASSERT(m_colorStopCount <= maxColorStopCount);
for (uint8_t i = 0; i < m_colorStopCount; ++i) {
m_offsets[i] = offsets[i];
m_colors[i] = colors[i];
}
}

SetInlineFillGradient::SetInlineFillGradient(const SetInlineFillGradient& other)
{
if (WTF::holds_alternative<Gradient::RadialData>(other.m_data) || WTF::holds_alternative<Gradient::LinearData>(other.m_data) || WTF::holds_alternative<Gradient::ConicData>(other.m_data)) {
m_data = other.m_data;
m_gradientSpaceTransform = other.m_gradientSpaceTransform;
m_spreadMethod = other.m_spreadMethod;
m_colorStopCount = other.m_colorStopCount;
if (m_colorStopCount > maxColorStopCount)
m_colorStopCount = 0;
for (uint8_t i = 0; i < m_colorStopCount; ++i) {
m_offsets[i] = other.m_offsets[i];
m_colors[i] = other.m_colors[i];
}
} else
m_isValid = false;
}

Ref<Gradient> SetInlineFillGradient::gradient() const
{
auto gradient = Gradient::create(Gradient::Data(m_data));
for (uint8_t i = 0; i < m_colorStopCount; ++i)
gradient->addColorStop({ m_offsets[i], Color(m_colors[i]) });
gradient->setSpreadMethod(m_spreadMethod);
return gradient;
}

void SetInlineFillGradient::apply(GraphicsContext& context) const
{
if (m_colorStopCount <= maxColorStopCount)
context.setFillGradient(gradient(), m_gradientSpaceTransform);
}

bool SetInlineFillGradient::isInline(const Gradient& gradient)
{
if (gradient.stops().size() > SetInlineFillGradient::maxColorStopCount)
return false;

for (auto& colorStop : gradient.stops()) {
if (!colorStop.color.tryGetAsSRGBABytes())
return false;
}

return true;
}

static TextStream& operator<<(TextStream& ts, const SetInlineFillGradient&)
{
// FIXME: Dump gradient data.
return ts;
}

void SetInlineFillColor::apply(GraphicsContext& context) const
{
context.setFillColor(color());
@@ -1133,7 +1056,6 @@ static TextStream& operator<<(TextStream& ts, ItemType type)
case ItemType::Scale: ts << "scale"; break;
case ItemType::SetCTM: ts << "set-ctm"; break;
case ItemType::ConcatenateCTM: ts << "concatentate-ctm"; break;
case ItemType::SetInlineFillGradient: ts << "set-inline-fill-gradient"; break;
case ItemType::SetInlineFillColor: ts << "set-inline-fill-color"; break;
case ItemType::SetInlineStrokeColor: ts << "set-inline-stroke-color"; break;
case ItemType::SetStrokeThickness: ts << "set-stroke-thickness"; break;
@@ -1225,9 +1147,6 @@ TextStream& operator<<(TextStream& ts, ItemHandle item)
case ItemType::ConcatenateCTM:
ts << item.get<ConcatenateCTM>();
break;
case ItemType::SetInlineFillGradient:
ts << item.get<SetInlineFillGradient>();
break;
case ItemType::SetInlineFillColor:
ts << item.get<SetInlineFillColor>();
break;
@@ -182,33 +182,6 @@ class ConcatenateCTM {
AffineTransform m_transform;
};

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;

SetInlineFillGradient(const Gradient&, const AffineTransform& gradientSpaceTransform);
WEBCORE_EXPORT SetInlineFillGradient(float offsets[maxColorStopCount], SRGBA<uint8_t> colors[maxColorStopCount], const Gradient::Data&, const AffineTransform& gradientSpaceTransform, GradientSpreadMethod, uint8_t colorStopCount);
SetInlineFillGradient(const SetInlineFillGradient&);
bool isValid() const { return m_isValid; }

static bool isInline(const Gradient&);
Ref<Gradient> gradient() const;

void apply(GraphicsContext&) const;

private:
float m_offsets[maxColorStopCount];
SRGBA<uint8_t> m_colors[maxColorStopCount];
Gradient::Data m_data;
AffineTransform m_gradientSpaceTransform;
GradientSpreadMethod m_spreadMethod { GradientSpreadMethod::Pad };
uint8_t m_colorStopCount { 0 };
bool m_isValid { true };
};

class SetInlineFillColor {
public:
static constexpr ItemType itemType = ItemType::SetInlineFillColor;
@@ -2499,7 +2472,6 @@ using DisplayListItem = Variant
, Scale
, SetCTM
, SetInlineFillColor
, SetInlineFillGradient
, SetInlineStrokeColor
, SetLineCap
, SetLineDash
@@ -2553,7 +2525,6 @@ template<> struct EnumTraits<WebCore::DisplayList::ItemType> {
WebCore::DisplayList::ItemType::Scale,
WebCore::DisplayList::ItemType::SetCTM,
WebCore::DisplayList::ItemType::ConcatenateCTM,
WebCore::DisplayList::ItemType::SetInlineFillGradient,
WebCore::DisplayList::ItemType::SetInlineFillColor,
WebCore::DisplayList::ItemType::SetInlineStrokeColor,
WebCore::DisplayList::ItemType::SetStrokeThickness,
@@ -82,7 +82,6 @@ static bool containsOnlyInlineStateChanges(const GraphicsContextStateChange& cha
GraphicsContextState::StrokeThicknessChange,
GraphicsContextState::StrokeColorChange,
GraphicsContextState::FillColorChange,
GraphicsContextState::FillGradientChange,
};

if (changeFlags != (changeFlags & inlineStateChangeFlags))
@@ -94,10 +93,6 @@ static bool containsOnlyInlineStateChanges(const GraphicsContextStateChange& cha
if (changeFlags.contains(GraphicsContextState::FillColorChange) && !changes.m_state.fillColor.tryGetAsSRGBABytes())
return false;

if (changeFlags.contains(GraphicsContextState::FillGradientChange)
&& (!changes.m_state.fillGradient || !SetInlineFillGradient::isInline(*changes.m_state.fillGradient)))
return false;

return true;
}

@@ -127,9 +122,6 @@ void Recorder::appendStateChangeItem(const GraphicsContextStateChange& changes,

if (changeFlags.contains(GraphicsContextState::FillColorChange))
append<SetInlineFillColor>(*changes.m_state.fillColor.tryGetAsSRGBABytes());

if (changeFlags.contains(GraphicsContextState::FillGradientChange))
append<SetInlineFillGradient>(*changes.m_state.fillGradient, changes.m_state.fillGradientSpaceTransform);
}

bool Recorder::canAppendItemOfType(ItemType type) const
@@ -1,3 +1,15 @@
2021-10-06 Wenson Hsieh <wenson_hsieh@apple.com>

Delete WebCore::DisplayList::SetInlineFillGradient
https://bugs.webkit.org/show_bug.cgi?id=231326

Reviewed by Simon Fraser.

See WebCore/ChangeLog for more details.

* GPUProcess/graphics/RemoteRenderingBackend.cpp:
(WebKit::RemoteRenderingBackend::decodeItem):

2021-10-06 Wenson Hsieh <wenson_hsieh@apple.com>

Add a configurable wake up message hysteresis to IPC::StreamClientConnection
@@ -647,7 +647,6 @@ std::optional<DisplayList::ItemHandle> WARN_UNUSED_RETURN RemoteRenderingBackend
case DisplayList::ItemType::Scale:
case DisplayList::ItemType::SetCTM:
case DisplayList::ItemType::SetInlineFillColor:
case DisplayList::ItemType::SetInlineFillGradient:
case DisplayList::ItemType::SetInlineStrokeColor:
case DisplayList::ItemType::SetLineCap:
case DisplayList::ItemType::SetLineJoin:

0 comments on commit bd50e60

Please sign in to comment.