Skip to content

Commit

Permalink
Simplify FEComponentTransfer coding
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=246908
<rdar://problem/101464975>

Reviewed by Said Abou-Hallawa.

* Source/WebCore/platform/graphics/filters/FEComponentTransfer.h:
(WebCore::FEComponentTransfer::encode const):
(WebCore::FEComponentTransfer::decode):

Canonical link: https://commits.webkit.org/255906@main
  • Loading branch information
heycam committed Oct 24, 2022
1 parent df1cf06 commit 355426c
Showing 1 changed file with 7 additions and 25 deletions.
32 changes: 7 additions & 25 deletions Source/WebCore/platform/graphics/filters/FEComponentTransfer.h
Expand Up @@ -58,8 +58,8 @@ using ComponentTransferFunctions = EnumeratedArray<ComponentTransferChannel, Com

class FEComponentTransfer : public FilterEffect {
public:
WEBCORE_EXPORT static Ref<FEComponentTransfer> create(const ComponentTransferFunction& redFunc, const ComponentTransferFunction& greenFunc, const ComponentTransferFunction& blueFunc, const ComponentTransferFunction& alphaFunc);
static Ref<FEComponentTransfer> create(ComponentTransferFunctions&&);
static Ref<FEComponentTransfer> create(const ComponentTransferFunction& redFunc, const ComponentTransferFunction& greenFunc, const ComponentTransferFunction& blueFunc, const ComponentTransferFunction& alphaFunc);
WEBCORE_EXPORT static Ref<FEComponentTransfer> create(ComponentTransferFunctions&&);

ComponentTransferFunction redFunction() const { return m_functions[ComponentTransferChannel::Red]; }
ComponentTransferFunction greenFunction() const { return m_functions[ComponentTransferChannel::Green]; }
Expand Down Expand Up @@ -146,36 +146,18 @@ std::optional<ComponentTransferFunction> ComponentTransferFunction::decode(Decod
template<class Encoder>
void FEComponentTransfer::encode(Encoder& encoder) const
{
encoder << m_functions[ComponentTransferChannel::Red];
encoder << m_functions[ComponentTransferChannel::Green];
encoder << m_functions[ComponentTransferChannel::Blue];
encoder << m_functions[ComponentTransferChannel::Alpha];
encoder << m_functions;
}

template<class Decoder>
std::optional<Ref<FEComponentTransfer>> FEComponentTransfer::decode(Decoder& decoder)
{
std::optional<ComponentTransferFunction> redFunction;
decoder >> redFunction;
if (!redFunction)
std::optional<ComponentTransferFunctions> functions;
decoder >> functions;
if (!functions)
return std::nullopt;

std::optional<ComponentTransferFunction> greenFunction;
decoder >> greenFunction;
if (!greenFunction)
return std::nullopt;

std::optional<ComponentTransferFunction> blueFunction;
decoder >> blueFunction;
if (!blueFunction)
return std::nullopt;

std::optional<ComponentTransferFunction> alphaFunction;
decoder >> alphaFunction;
if (!alphaFunction)
return std::nullopt;

return FEComponentTransfer::create(*redFunction, *greenFunction, *blueFunction, *alphaFunction);
return FEComponentTransfer::create(WTFMove(*functions));
}

} // namespace WebCore
Expand Down

0 comments on commit 355426c

Please sign in to comment.