Diff
Modified: trunk/Source/WebCore/ChangeLog (286795 => 286796)
--- trunk/Source/WebCore/ChangeLog 2021-12-09 20:22:34 UTC (rev 286795)
+++ trunk/Source/WebCore/ChangeLog 2021-12-09 20:25:11 UTC (rev 286796)
@@ -1,3 +1,61 @@
+2021-12-09 Said Abou-Hallawa <[email protected]>
+
+ [GPU Process] [Filters] Add the encoding and decoding for LightSource
+ https://bugs.webkit.org/show_bug.cgi?id=234086
+
+ Reviewed by Wenson Hsieh.
+
+ This will allow encoding and decoding FEDiffuseLighting and FESpecularLighting.
+
+ The create() and the constructor of the LightSource super classes have
+ to be non-inline to overcome a "missing vtable" linking issue.
+
+ New constructors are added to FEDiffuseLighting and FESpecularLighting
+ to allow creating these super classes from the combined data members of
+ FELighting.
+
+ m_bufferPosition of PointLightSource and SpotLightSource are used to cache
+ the absolute value of m_userSpacePosition relative to the result FilterImage.
+ So it does not need to be encoded/decoded since it is initialized by
+ FELightingSoftwareApplier.
+
+ * Headers.cmake:
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/graphics/filters/DistantLightSource.cpp:
+ (WebCore::DistantLightSource::create):
+ (WebCore::DistantLightSource::DistantLightSource):
+ * platform/graphics/filters/DistantLightSource.h:
+ (WebCore::DistantLightSource::encode const):
+ (WebCore::DistantLightSource::decode):
+ (WebCore::DistantLightSource::create): Deleted.
+ (WebCore::DistantLightSource::DistantLightSource): Deleted.
+ * platform/graphics/filters/FEDiffuseLighting.cpp:
+ (WebCore::FEDiffuseLighting::create):
+ * platform/graphics/filters/FEDiffuseLighting.h:
+ * platform/graphics/filters/FELighting.h:
+ (WebCore::FELighting::encode const):
+ (WebCore::FELighting::decode):
+ * platform/graphics/filters/FESpecularLighting.cpp:
+ (WebCore::FESpecularLighting::create):
+ * platform/graphics/filters/FESpecularLighting.h:
+ * platform/graphics/filters/LightSource.h:
+ * platform/graphics/filters/PointLightSource.cpp:
+ (WebCore::PointLightSource::create):
+ (WebCore::PointLightSource::PointLightSource):
+ * platform/graphics/filters/PointLightSource.h:
+ (WebCore::PointLightSource::encode const):
+ (WebCore::PointLightSource::decode):
+ (WebCore::PointLightSource::create): Deleted.
+ (WebCore::PointLightSource::PointLightSource): Deleted.
+ * platform/graphics/filters/SpotLightSource.cpp:
+ (WebCore::SpotLightSource::create):
+ (WebCore::SpotLightSource::SpotLightSource):
+ * platform/graphics/filters/SpotLightSource.h:
+ (WebCore::SpotLightSource::encode const):
+ (WebCore::SpotLightSource::decode):
+ (WebCore::SpotLightSource::create): Deleted.
+ (WebCore::SpotLightSource::SpotLightSource): Deleted.
+
2021-12-09 Matt Woodrow <[email protected]>
Unprefix -webkit-mask
Modified: trunk/Source/WebCore/Headers.cmake (286795 => 286796)
--- trunk/Source/WebCore/Headers.cmake 2021-12-09 20:22:34 UTC (rev 286795)
+++ trunk/Source/WebCore/Headers.cmake 2021-12-09 20:25:11 UTC (rev 286796)
@@ -1574,6 +1574,7 @@
platform/graphics/cv/ImageTransferSessionVT.h
+ platform/graphics/filters/DistantLightSource.h
platform/graphics/filters/FEBlend.h
platform/graphics/filters/FEColorMatrix.h
platform/graphics/filters/FEComponentTransfer.h
@@ -1601,8 +1602,10 @@
platform/graphics/filters/FilterOperation.h
platform/graphics/filters/FilterOperations.h
platform/graphics/filters/LightSource.h
+ platform/graphics/filters/PointLightSource.h
platform/graphics/filters/SourceAlpha.h
platform/graphics/filters/SourceGraphic.h
+ platform/graphics/filters/SpotLightSource.h
platform/graphics/iso/ISOBox.h
platform/graphics/iso/ISOOriginalFormatBox.h
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (286795 => 286796)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-12-09 20:22:34 UTC (rev 286795)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-12-09 20:25:11 UTC (rev 286796)
@@ -2729,7 +2729,7 @@
845E72F80FD261EE00A87D79 /* Filter.h in Headers */ = {isa = PBXBuildFile; fileRef = 845E72F70FD261EE00A87D79 /* Filter.h */; settings = {ATTRIBUTES = (Private, ); }; };
845E72FC0FD2623900A87D79 /* SVGFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 845E72FA0FD2623900A87D79 /* SVGFilter.h */; settings = {ATTRIBUTES = (Private, ); }; };
84650E7E2387AD7D006266E2 /* MediaQueryListEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 84650E7C2387AD7C006266E2 /* MediaQueryListEvent.h */; };
- 84730D771248F0B300D3A9C9 /* DistantLightSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 84730D5A1248F0B300D3A9C9 /* DistantLightSource.h */; };
+ 84730D771248F0B300D3A9C9 /* DistantLightSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 84730D5A1248F0B300D3A9C9 /* DistantLightSource.h */; settings = {ATTRIBUTES = (Private, ); }; };
84730D791248F0B300D3A9C9 /* FEConvolveMatrix.h in Headers */ = {isa = PBXBuildFile; fileRef = 84730D5C1248F0B300D3A9C9 /* FEConvolveMatrix.h */; settings = {ATTRIBUTES = (Private, ); }; };
84730D7B1248F0B300D3A9C9 /* FEDiffuseLighting.h in Headers */ = {isa = PBXBuildFile; fileRef = 84730D5E1248F0B300D3A9C9 /* FEDiffuseLighting.h */; settings = {ATTRIBUTES = (Private, ); }; };
84730D7D1248F0B300D3A9C9 /* FEDisplacementMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 84730D601248F0B300D3A9C9 /* FEDisplacementMap.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -2742,8 +2742,8 @@
84730D8B1248F0B300D3A9C9 /* FETile.h in Headers */ = {isa = PBXBuildFile; fileRef = 84730D6E1248F0B300D3A9C9 /* FETile.h */; settings = {ATTRIBUTES = (Private, ); }; };
84730D8D1248F0B300D3A9C9 /* FETurbulence.h in Headers */ = {isa = PBXBuildFile; fileRef = 84730D701248F0B300D3A9C9 /* FETurbulence.h */; settings = {ATTRIBUTES = (Private, ); }; };
84730D911248F0B300D3A9C9 /* LightSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 84730D741248F0B300D3A9C9 /* LightSource.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 84730D921248F0B300D3A9C9 /* PointLightSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 84730D751248F0B300D3A9C9 /* PointLightSource.h */; };
- 84730D931248F0B300D3A9C9 /* SpotLightSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 84730D761248F0B300D3A9C9 /* SpotLightSource.h */; };
+ 84730D921248F0B300D3A9C9 /* PointLightSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 84730D751248F0B300D3A9C9 /* PointLightSource.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 84730D931248F0B300D3A9C9 /* SpotLightSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 84730D761248F0B300D3A9C9 /* SpotLightSource.h */; settings = {ATTRIBUTES = (Private, ); }; };
8476C9E611DF6A0B00555B02 /* SVGPathSegListBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 8476C9E411DF6A0B00555B02 /* SVGPathSegListBuilder.h */; };
8476C9EB11DF6A2900555B02 /* SVGPathBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 8476C9E811DF6A2900555B02 /* SVGPathBuilder.h */; };
8476C9EC11DF6A2900555B02 /* SVGPathConsumer.h in Headers */ = {isa = PBXBuildFile; fileRef = 8476C9E911DF6A2900555B02 /* SVGPathConsumer.h */; };
Modified: trunk/Source/WebCore/platform/graphics/filters/DistantLightSource.cpp (286795 => 286796)
--- trunk/Source/WebCore/platform/graphics/filters/DistantLightSource.cpp 2021-12-09 20:22:34 UTC (rev 286795)
+++ trunk/Source/WebCore/platform/graphics/filters/DistantLightSource.cpp 2021-12-09 20:25:11 UTC (rev 286796)
@@ -35,6 +35,18 @@
namespace WebCore {
+Ref<DistantLightSource> DistantLightSource::create(float azimuth, float elevation)
+{
+ return adoptRef(*new DistantLightSource(azimuth, elevation));
+}
+
+DistantLightSource::DistantLightSource(float azimuth, float elevation)
+ : LightSource(LS_DISTANT)
+ , m_azimuth(azimuth)
+ , m_elevation(elevation)
+{
+}
+
void DistantLightSource::initPaintingData(const Filter&, const FilterImage&, PaintingData& paintingData) const
{
float azimuth = deg2rad(m_azimuth);
Modified: trunk/Source/WebCore/platform/graphics/filters/DistantLightSource.h (286795 => 286796)
--- trunk/Source/WebCore/platform/graphics/filters/DistantLightSource.h 2021-12-09 20:22:34 UTC (rev 286795)
+++ trunk/Source/WebCore/platform/graphics/filters/DistantLightSource.h 2021-12-09 20:25:11 UTC (rev 286796)
@@ -29,10 +29,7 @@
class DistantLightSource : public LightSource {
public:
- static Ref<DistantLightSource> create(float azimuth, float elevation)
- {
- return adoptRef(*new DistantLightSource(azimuth, elevation));
- }
+ WEBCORE_EXPORT static Ref<DistantLightSource> create(float azimuth, float elevation);
// These are in degrees.
float azimuth() const { return m_azimuth; }
@@ -46,18 +43,39 @@
WTF::TextStream& externalRepresentation(WTF::TextStream&) const override;
+ template<class Encoder> void encode(Encoder&) const;
+ template<class Decoder> static std::optional<Ref<DistantLightSource>> decode(Decoder&);
+
private:
- DistantLightSource(float azimuth, float elevation)
- : LightSource(LS_DISTANT)
- , m_azimuth(azimuth)
- , m_elevation(elevation)
- {
- }
+ DistantLightSource(float azimuth, float elevation);
float m_azimuth;
float m_elevation;
};
+template<class Encoder>
+void DistantLightSource::encode(Encoder& encoder) const
+{
+ encoder << m_azimuth;
+ encoder << m_elevation;
+}
+
+template<class Decoder>
+std::optional<Ref<DistantLightSource>> DistantLightSource::decode(Decoder& decoder)
+{
+ std::optional<float> azimuth;
+ decoder >> azimuth;
+ if (!azimuth)
+ return std::nullopt;
+
+ std::optional<float> elevation;
+ decoder >> elevation;
+ if (!elevation)
+ return std::nullopt;
+
+ return DistantLightSource::create(*azimuth, *elevation);
+}
+
} // namespace WebCore
SPECIALIZE_TYPE_TRAITS_LIGHTSOURCE(DistantLightSource, LS_DISTANT)
Modified: trunk/Source/WebCore/platform/graphics/filters/FEDiffuseLighting.cpp (286795 => 286796)
--- trunk/Source/WebCore/platform/graphics/filters/FEDiffuseLighting.cpp 2021-12-09 20:22:34 UTC (rev 286795)
+++ trunk/Source/WebCore/platform/graphics/filters/FEDiffuseLighting.cpp 2021-12-09 20:25:11 UTC (rev 286796)
@@ -29,6 +29,11 @@
namespace WebCore {
+Ref<FEDiffuseLighting> FEDiffuseLighting::create(const Color& lightingColor, float surfaceScale, float diffuseConstant, float, float, float kernelUnitLengthX, float kernelUnitLengthY, Ref<LightSource>&& lightSource)
+{
+ return create(lightingColor, surfaceScale, diffuseConstant, kernelUnitLengthX, kernelUnitLengthY, WTFMove(lightSource));
+}
+
Ref<FEDiffuseLighting> FEDiffuseLighting::create(const Color& lightingColor, float surfaceScale, float diffuseConstant, float kernelUnitLengthX, float kernelUnitLengthY, Ref<LightSource>&& lightSource)
{
return adoptRef(*new FEDiffuseLighting(lightingColor, surfaceScale, diffuseConstant, kernelUnitLengthX, kernelUnitLengthY, WTFMove(lightSource)));
Modified: trunk/Source/WebCore/platform/graphics/filters/FEDiffuseLighting.h (286795 => 286796)
--- trunk/Source/WebCore/platform/graphics/filters/FEDiffuseLighting.h 2021-12-09 20:22:34 UTC (rev 286795)
+++ trunk/Source/WebCore/platform/graphics/filters/FEDiffuseLighting.h 2021-12-09 20:25:11 UTC (rev 286796)
@@ -30,6 +30,7 @@
class FEDiffuseLighting : public FELighting {
public:
+ WEBCORE_EXPORT static Ref<FEDiffuseLighting> create(const Color& lightingColor, float surfaceScale, float diffuseConstant, float, float, float kernelUnitLengthX, float kernelUnitLengthY, Ref<LightSource>&&);
static Ref<FEDiffuseLighting> create(const Color& lightingColor, float surfaceScale, float diffuseConstant, float kernelUnitLengthX, float kernelUnitLengthY, Ref<LightSource>&&);
float diffuseConstant() const { return m_diffuseConstant; }
Modified: trunk/Source/WebCore/platform/graphics/filters/FELighting.h (286795 => 286796)
--- trunk/Source/WebCore/platform/graphics/filters/FELighting.h 2021-12-09 20:22:34 UTC (rev 286795)
+++ trunk/Source/WebCore/platform/graphics/filters/FELighting.h 2021-12-09 20:25:11 UTC (rev 286796)
@@ -28,8 +28,10 @@
#pragma once
#include "Color.h"
+#include "DistantLightSource.h"
#include "FilterEffect.h"
-#include "LightSource.h"
+#include "PointLightSource.h"
+#include "SpotLightSource.h"
namespace WebCore {
@@ -90,7 +92,19 @@
encoder << m_specularExponent;
encoder << m_kernelUnitLengthX;
encoder << m_kernelUnitLengthY;
- // FIXME: encode m_lightSource.
+
+ encoder << m_lightSource->type();
+ switch (m_lightSource->type()) {
+ case LS_DISTANT:
+ downcast<DistantLightSource>(m_lightSource.get()).encode(encoder);
+ break;
+ case LS_POINT:
+ downcast<PointLightSource>(m_lightSource.get()).encode(encoder);
+ break;
+ case LS_SPOT:
+ downcast<SpotLightSource>(m_lightSource.get()).encode(encoder);
+ break;
+ }
}
template<class Decoder, class ClassName>
@@ -131,8 +145,28 @@
if (!kernelUnitLengthY)
return std::nullopt;
- // FIXME: decode m_lightSource.
- return std::nullopt;
+ std::optional<LightType> lightSourceType;
+ decoder >> lightSourceType;
+ if (!lightSourceType)
+ return std::nullopt;
+
+ std::optional<Ref<LightSource>> lightSource;
+ switch (*lightSourceType) {
+ case LS_DISTANT:
+ lightSource = DistantLightSource::decode(decoder);
+ break;
+ case LS_POINT:
+ lightSource = PointLightSource::decode(decoder);
+ break;
+ case LS_SPOT:
+ lightSource = SpotLightSource::decode(decoder);
+ break;
+ }
+
+ if (!lightSource)
+ return std::nullopt;
+
+ return ClassName::create(*lightingColor, *surfaceScale, *diffuseConstant, *specularConstant, *specularExponent, *kernelUnitLengthX, *kernelUnitLengthY, WTFMove(*lightSource));
}
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/filters/FESpecularLighting.cpp (286795 => 286796)
--- trunk/Source/WebCore/platform/graphics/filters/FESpecularLighting.cpp 2021-12-09 20:22:34 UTC (rev 286795)
+++ trunk/Source/WebCore/platform/graphics/filters/FESpecularLighting.cpp 2021-12-09 20:25:11 UTC (rev 286796)
@@ -29,6 +29,11 @@
namespace WebCore {
+Ref<FESpecularLighting> FESpecularLighting::create(const Color& lightingColor, float surfaceScale, float, float specularConstant, float specularExponent, float kernelUnitLengthX, float kernelUnitLengthY, Ref<LightSource>&& lightSource)
+{
+ return create(lightingColor, surfaceScale, specularConstant, specularExponent, kernelUnitLengthX, kernelUnitLengthY, WTFMove(lightSource));
+}
+
Ref<FESpecularLighting> FESpecularLighting::create(const Color& lightingColor, float surfaceScale, float specularConstant, float specularExponent, float kernelUnitLengthX, float kernelUnitLengthY, Ref<LightSource>&& lightSource)
{
return adoptRef(*new FESpecularLighting(lightingColor, surfaceScale, specularConstant, specularExponent, kernelUnitLengthX, kernelUnitLengthY, WTFMove(lightSource)));
Modified: trunk/Source/WebCore/platform/graphics/filters/FESpecularLighting.h (286795 => 286796)
--- trunk/Source/WebCore/platform/graphics/filters/FESpecularLighting.h 2021-12-09 20:22:34 UTC (rev 286795)
+++ trunk/Source/WebCore/platform/graphics/filters/FESpecularLighting.h 2021-12-09 20:25:11 UTC (rev 286796)
@@ -28,6 +28,7 @@
class FESpecularLighting : public FELighting {
public:
+ WEBCORE_EXPORT static Ref<FESpecularLighting> create(const Color& lightingColor, float surfaceScale, float, float specularConstant, float specularExponent, float kernelUnitLengthX, float kernelUnitLengthY, Ref<LightSource>&&);
static Ref<FESpecularLighting> create(const Color& lightingColor, float surfaceScale, float specularConstant, float specularExponent, float kernelUnitLengthX, float kernelUnitLengthY, Ref<LightSource>&&);
float specularConstant() const { return m_specularConstant; }
Modified: trunk/Source/WebCore/platform/graphics/filters/LightSource.h (286795 => 286796)
--- trunk/Source/WebCore/platform/graphics/filters/LightSource.h 2021-12-09 20:22:34 UTC (rev 286795)
+++ trunk/Source/WebCore/platform/graphics/filters/LightSource.h 2021-12-09 20:25:11 UTC (rev 286796)
@@ -93,6 +93,20 @@
} // namespace WebCore
+namespace WTF {
+
+template<> struct EnumTraits<WebCore::LightType> {
+ using values = EnumValues<
+ WebCore::LightType,
+
+ WebCore::LS_DISTANT,
+ WebCore::LS_POINT,
+ WebCore::LS_SPOT
+ >;
+};
+
+} // namespace WTF
+
#define SPECIALIZE_TYPE_TRAITS_LIGHTSOURCE(ClassName, Type) \
SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ClassName) \
static bool isType(const WebCore::LightSource& source) { return source.type() == WebCore::Type; } \
Modified: trunk/Source/WebCore/platform/graphics/filters/PointLightSource.cpp (286795 => 286796)
--- trunk/Source/WebCore/platform/graphics/filters/PointLightSource.cpp 2021-12-09 20:22:34 UTC (rev 286795)
+++ trunk/Source/WebCore/platform/graphics/filters/PointLightSource.cpp 2021-12-09 20:25:11 UTC (rev 286796)
@@ -38,6 +38,17 @@
namespace WebCore {
+Ref<PointLightSource> PointLightSource::create(const FloatPoint3D& position)
+{
+ return adoptRef(*new PointLightSource(position));
+}
+
+PointLightSource::PointLightSource(const FloatPoint3D& position)
+ : LightSource(LS_POINT)
+ , m_userSpacePosition(position)
+{
+}
+
void PointLightSource::initPaintingData(const Filter& filter, const FilterImage& result, PaintingData&) const
{
auto absolutePosition = filter.scaledByFilterScale(m_userSpacePosition.xy());
Modified: trunk/Source/WebCore/platform/graphics/filters/PointLightSource.h (286795 => 286796)
--- trunk/Source/WebCore/platform/graphics/filters/PointLightSource.h 2021-12-09 20:22:34 UTC (rev 286795)
+++ trunk/Source/WebCore/platform/graphics/filters/PointLightSource.h 2021-12-09 20:25:11 UTC (rev 286796)
@@ -30,10 +30,7 @@
class PointLightSource : public LightSource {
public:
- static Ref<PointLightSource> create(const FloatPoint3D& position)
- {
- return adoptRef(*new PointLightSource(position));
- }
+ WEBCORE_EXPORT static Ref<PointLightSource> create(const FloatPoint3D& position);
const FloatPoint3D& position() const { return m_userSpacePosition; }
bool setX(float) override;
@@ -45,17 +42,33 @@
WTF::TextStream& externalRepresentation(WTF::TextStream&) const override;
+ template<class Encoder> void encode(Encoder&) const;
+ template<class Decoder> static std::optional<Ref<PointLightSource>> decode(Decoder&);
+
private:
- PointLightSource(const FloatPoint3D& position)
- : LightSource(LS_POINT)
- , m_userSpacePosition(position)
- {
- }
+ PointLightSource(const FloatPoint3D& position);
FloatPoint3D m_userSpacePosition;
mutable FloatPoint3D m_bufferPosition;
};
+template<class Encoder>
+void PointLightSource::encode(Encoder& encoder) const
+{
+ encoder << m_userSpacePosition;
+}
+
+template<class Decoder>
+std::optional<Ref<PointLightSource>> PointLightSource::decode(Decoder& decoder)
+{
+ std::optional<FloatPoint3D> userSpacePosition;
+ decoder >> userSpacePosition;
+ if (!userSpacePosition)
+ return std::nullopt;
+
+ return PointLightSource::create(*userSpacePosition);
+}
+
} // namespace WebCore
SPECIALIZE_TYPE_TRAITS_LIGHTSOURCE(PointLightSource, LS_POINT)
Modified: trunk/Source/WebCore/platform/graphics/filters/SpotLightSource.cpp (286795 => 286796)
--- trunk/Source/WebCore/platform/graphics/filters/SpotLightSource.cpp 2021-12-09 20:22:34 UTC (rev 286795)
+++ trunk/Source/WebCore/platform/graphics/filters/SpotLightSource.cpp 2021-12-09 20:25:11 UTC (rev 286796)
@@ -43,6 +43,20 @@
// according to the SVG 1.1 SE light regression tests
static const float antialiasThreshold = 0.016f;
+Ref<SpotLightSource> SpotLightSource::create(const FloatPoint3D& position, const FloatPoint3D& direction, float specularExponent, float limitingConeAngle)
+{
+ return adoptRef(*new SpotLightSource(position, direction, specularExponent, limitingConeAngle));
+}
+
+SpotLightSource::SpotLightSource(const FloatPoint3D& position, const FloatPoint3D& direction, float specularExponent, float limitingConeAngle)
+ : LightSource(LS_SPOT)
+ , m_userSpacePosition(position)
+ , m_userSpacePointsAt(direction)
+ , m_specularExponent(specularExponent)
+ , m_limitingConeAngle(limitingConeAngle)
+{
+}
+
void SpotLightSource::initPaintingData(const Filter& filter, const FilterImage& result, PaintingData& paintingData) const
{
auto absolutePosition = filter.scaledByFilterScale(m_userSpacePosition.xy());
Modified: trunk/Source/WebCore/platform/graphics/filters/SpotLightSource.h (286795 => 286796)
--- trunk/Source/WebCore/platform/graphics/filters/SpotLightSource.h 2021-12-09 20:22:34 UTC (rev 286795)
+++ trunk/Source/WebCore/platform/graphics/filters/SpotLightSource.h 2021-12-09 20:25:11 UTC (rev 286796)
@@ -30,11 +30,7 @@
class SpotLightSource : public LightSource {
public:
- static Ref<SpotLightSource> create(const FloatPoint3D& position,
- const FloatPoint3D& direction, float specularExponent, float limitingConeAngle)
- {
- return adoptRef(*new SpotLightSource(position, direction, specularExponent, limitingConeAngle));
- }
+ WEBCORE_EXPORT static Ref<SpotLightSource> create(const FloatPoint3D& position, const FloatPoint3D& direction, float specularExponent, float limitingConeAngle);
const FloatPoint3D& position() const { return m_userSpacePosition; }
const FloatPoint3D& direction() const { return m_userSpacePointsAt; }
@@ -56,15 +52,11 @@
WTF::TextStream& externalRepresentation(WTF::TextStream&) const override;
+ template<class Encoder> void encode(Encoder&) const;
+ template<class Decoder> static std::optional<Ref<SpotLightSource>> decode(Decoder&);
+
private:
- SpotLightSource(const FloatPoint3D& position, const FloatPoint3D& direction, float specularExponent, float limitingConeAngle)
- : LightSource(LS_SPOT)
- , m_userSpacePosition(position)
- , m_userSpacePointsAt(direction)
- , m_specularExponent(specularExponent)
- , m_limitingConeAngle(limitingConeAngle)
- {
- }
+ SpotLightSource(const FloatPoint3D& position, const FloatPoint3D& direction, float specularExponent, float limitingConeAngle);
FloatPoint3D m_userSpacePosition;
FloatPoint3D m_userSpacePointsAt;
@@ -75,6 +67,41 @@
float m_limitingConeAngle;
};
+template<class Encoder>
+void SpotLightSource::encode(Encoder& encoder) const
+{
+ encoder << m_userSpacePosition;
+ encoder << m_userSpacePointsAt;
+ encoder << m_specularExponent;
+ encoder << m_limitingConeAngle;
+}
+
+template<class Decoder>
+std::optional<Ref<SpotLightSource>> SpotLightSource::decode(Decoder& decoder)
+{
+ std::optional<FloatPoint3D> userSpacePosition;
+ decoder >> userSpacePosition;
+ if (!userSpacePosition)
+ return std::nullopt;
+
+ std::optional<FloatPoint3D> userSpacePointsAt;
+ decoder >> userSpacePointsAt;
+ if (!userSpacePointsAt)
+ return std::nullopt;
+
+ std::optional<float> specularExponent;
+ decoder >> specularExponent;
+ if (!specularExponent)
+ return std::nullopt;
+
+ std::optional<float> limitingConeAngle;
+ decoder >> limitingConeAngle;
+ if (!limitingConeAngle)
+ return std::nullopt;
+
+ return SpotLightSource::create(*userSpacePosition, *userSpacePointsAt, *specularExponent, *limitingConeAngle);
+}
+
} // namespace WebCore
SPECIALIZE_TYPE_TRAITS_LIGHTSOURCE(SpotLightSource, LS_SPOT)