- Revision
- 253302
- Author
- [email protected]
- Date
- 2019-12-09 14:53:28 -0800 (Mon, 09 Dec 2019)
Log Message
Finish encoding/decoding support for DisplayList::SetState
https://bugs.webkit.org/show_bug.cgi?id=205018
Reviewed by Tim Horton.
Source/WebCore:
Finishes encoding and decoding support for the `SetState` display list item. See below for more details.
* platform/graphics/Gradient.h:
(WebCore::Gradient::ColorStop::encode const):
(WebCore::Gradient::ColorStop::decode):
(WebCore::Gradient::LinearData::encode const):
(WebCore::Gradient::LinearData::decode):
(WebCore::Gradient::RadialData::encode const):
(WebCore::Gradient::RadialData::decode):
(WebCore::Gradient::ConicData::encode const):
(WebCore::Gradient::ConicData::decode):
(WebCore::Gradient::encode const):
(WebCore::Gradient::decode):
Introduce encoding and decoding support for WebCore::Gradient, and all of its constituent data members.
* platform/graphics/GraphicsContext.h:
Remove ShadowColorChange, which was unused; instead, shadow color changes are indicated by the ShadowChange
flag, which also encompasses shadow offset and blur.
* platform/graphics/Image.h:
Move DisplayList::ImageHandle to ImageHandle in Image.h, so that it can be referenced in the encode/decode
methods of WebCore::Pattern.
* platform/graphics/Pattern.h:
(WebCore::Pattern::encode const):
(WebCore::Pattern::decode):
Introduce encoding and decoding support for WebCore::Pattern.
* platform/graphics/displaylists/DisplayListItems.cpp:
(WebCore::DisplayList::FillRectWithGradient::FillRectWithGradient):
Implement encode and decode for FillRectWithGradient, now that we're able to encode and decode Gradients.
* platform/graphics/displaylists/DisplayListItems.h:
(WebCore::DisplayList::SetState::encode const):
(WebCore::DisplayList::SetState::decode):
Encode the remaining data members of a GraphicsContextStateChange's state. These are: strokeGradient,
strokePattern, fillGradient, fillPattern, shadowOffset, shadowBlur, shadowColor (which was not previously being
encoded due to ShadowColorChange never being set), strokeThickness, textDrawingMode, strokeStyle, fillRule,
compositeOperator, blendMode, imageInterpolationQuality, shouldAntialias, shouldSmoothFonts,
shouldSubpixelQuantizeFonts and shadowsIgnoreTransforms.
(WebCore::DisplayList::FillRectWithGradient::encode const):
(WebCore::DisplayList::FillRectWithGradient::decode):
(WebCore::DisplayList::Item::encode const):
(WebCore::DisplayList::Item::decode):
(WebCore::DisplayList::FillRectWithGradient::FillRectWithGradient): Deleted.
Source/WebKit:
Replaces WebCore::DisplayList::ImageHandle with just WebCore::ImageHandle. See WebCore ChangeLog for more
details.
* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<ImageHandle>::encode):
(IPC::ArgumentCoder<ImageHandle>::decode):
(IPC::ArgumentCoder<DisplayList::ImageHandle>::encode): Deleted.
(IPC::ArgumentCoder<DisplayList::ImageHandle>::decode): Deleted.
* Shared/WebCoreArgumentCoders.h:
LayoutTests:
Rebaseline several display list layout tests.
* displaylists/layer-dispay-list-expected.txt:
* platform/mac-wk1/displaylists/extent-includes-shadow-expected.txt:
* platform/mac-wk1/displaylists/extent-includes-transforms-expected.txt:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (253301 => 253302)
--- trunk/LayoutTests/ChangeLog 2019-12-09 22:19:01 UTC (rev 253301)
+++ trunk/LayoutTests/ChangeLog 2019-12-09 22:53:28 UTC (rev 253302)
@@ -1,3 +1,16 @@
+2019-12-09 Wenson Hsieh <[email protected]>
+
+ Finish encoding/decoding support for DisplayList::SetState
+ https://bugs.webkit.org/show_bug.cgi?id=205018
+
+ Reviewed by Tim Horton.
+
+ Rebaseline several display list layout tests.
+
+ * displaylists/layer-dispay-list-expected.txt:
+ * platform/mac-wk1/displaylists/extent-includes-shadow-expected.txt:
+ * platform/mac-wk1/displaylists/extent-includes-transforms-expected.txt:
+
2019-12-09 Said Abou-Hallawa <[email protected]>
Throttling requestAnimationFrame should be controlled by RenderingUpdateScheduler
Modified: trunk/LayoutTests/displaylists/layer-dispay-list-expected.txt (253301 => 253302)
--- trunk/LayoutTests/displaylists/layer-dispay-list-expected.txt 2019-12-09 22:19:01 UTC (rev 253301)
+++ trunk/LayoutTests/displaylists/layer-dispay-list-expected.txt 2019-12-09 22:53:28 UTC (rev 253302)
@@ -9,7 +9,7 @@
(composite-operation source-over)
(blend-mode normal))
(set-state
- (change-flags 131456)
+ (change-flags 65920)
(fill-color #0000FF)
(stroke-style 0)
(should-antialias 0))
Modified: trunk/LayoutTests/platform/mac-wk1/displaylists/extent-includes-shadow-expected.txt (253301 => 253302)
--- trunk/LayoutTests/platform/mac-wk1/displaylists/extent-includes-shadow-expected.txt 2019-12-09 22:19:01 UTC (rev 253301)
+++ trunk/LayoutTests/platform/mac-wk1/displaylists/extent-includes-shadow-expected.txt 2019-12-09 22:53:28 UTC (rev 253302)
@@ -5,7 +5,7 @@
(save
(restore-index 4))
(set-state
- (change-flags 525312)
+ (change-flags 263168)
(shadow-blur 12.00)
(shadow-offset width=10 height=20)
(shadows-use-legacy-radius 0)
Modified: trunk/LayoutTests/platform/mac-wk1/displaylists/extent-includes-transforms-expected.txt (253301 => 253302)
--- trunk/LayoutTests/platform/mac-wk1/displaylists/extent-includes-transforms-expected.txt 2019-12-09 22:19:01 UTC (rev 253301)
+++ trunk/LayoutTests/platform/mac-wk1/displaylists/extent-includes-transforms-expected.txt 2019-12-09 22:53:28 UTC (rev 253302)
@@ -7,7 +7,7 @@
(save
(restore-index 5))
(set-state
- (change-flags 525312)
+ (change-flags 263168)
(shadow-blur 12.00)
(shadow-offset width=10 height=20)
(shadows-use-legacy-radius 0)
Modified: trunk/Source/WebCore/ChangeLog (253301 => 253302)
--- trunk/Source/WebCore/ChangeLog 2019-12-09 22:19:01 UTC (rev 253301)
+++ trunk/Source/WebCore/ChangeLog 2019-12-09 22:53:28 UTC (rev 253302)
@@ -1,3 +1,63 @@
+2019-12-09 Wenson Hsieh <[email protected]>
+
+ Finish encoding/decoding support for DisplayList::SetState
+ https://bugs.webkit.org/show_bug.cgi?id=205018
+
+ Reviewed by Tim Horton.
+
+ Finishes encoding and decoding support for the `SetState` display list item. See below for more details.
+
+ * platform/graphics/Gradient.h:
+ (WebCore::Gradient::ColorStop::encode const):
+ (WebCore::Gradient::ColorStop::decode):
+ (WebCore::Gradient::LinearData::encode const):
+ (WebCore::Gradient::LinearData::decode):
+ (WebCore::Gradient::RadialData::encode const):
+ (WebCore::Gradient::RadialData::decode):
+ (WebCore::Gradient::ConicData::encode const):
+ (WebCore::Gradient::ConicData::decode):
+ (WebCore::Gradient::encode const):
+ (WebCore::Gradient::decode):
+
+ Introduce encoding and decoding support for WebCore::Gradient, and all of its constituent data members.
+
+ * platform/graphics/GraphicsContext.h:
+
+ Remove ShadowColorChange, which was unused; instead, shadow color changes are indicated by the ShadowChange
+ flag, which also encompasses shadow offset and blur.
+
+ * platform/graphics/Image.h:
+
+ Move DisplayList::ImageHandle to ImageHandle in Image.h, so that it can be referenced in the encode/decode
+ methods of WebCore::Pattern.
+
+ * platform/graphics/Pattern.h:
+ (WebCore::Pattern::encode const):
+ (WebCore::Pattern::decode):
+
+ Introduce encoding and decoding support for WebCore::Pattern.
+
+ * platform/graphics/displaylists/DisplayListItems.cpp:
+ (WebCore::DisplayList::FillRectWithGradient::FillRectWithGradient):
+
+ Implement encode and decode for FillRectWithGradient, now that we're able to encode and decode Gradients.
+
+ * platform/graphics/displaylists/DisplayListItems.h:
+ (WebCore::DisplayList::SetState::encode const):
+ (WebCore::DisplayList::SetState::decode):
+
+ Encode the remaining data members of a GraphicsContextStateChange's state. These are: strokeGradient,
+ strokePattern, fillGradient, fillPattern, shadowOffset, shadowBlur, shadowColor (which was not previously being
+ encoded due to ShadowColorChange never being set), strokeThickness, textDrawingMode, strokeStyle, fillRule,
+ compositeOperator, blendMode, imageInterpolationQuality, shouldAntialias, shouldSmoothFonts,
+ shouldSubpixelQuantizeFonts and shadowsIgnoreTransforms.
+
+ (WebCore::DisplayList::FillRectWithGradient::encode const):
+ (WebCore::DisplayList::FillRectWithGradient::decode):
+ (WebCore::DisplayList::Item::encode const):
+ (WebCore::DisplayList::Item::decode):
+ (WebCore::DisplayList::FillRectWithGradient::FillRectWithGradient): Deleted.
+
2019-12-09 Zalan Bujtas <[email protected]>
[LFC][IFC] Add support for word-break: break-word (and overflow-wrap)
Modified: trunk/Source/WebCore/platform/graphics/Gradient.h (253301 => 253302)
--- trunk/Source/WebCore/platform/graphics/Gradient.h 2019-12-09 22:19:01 UTC (rev 253301)
+++ trunk/Source/WebCore/platform/graphics/Gradient.h 2019-12-09 22:53:28 UTC (rev 253302)
@@ -31,6 +31,7 @@
#include "Color.h"
#include "FloatPoint.h"
#include "GraphicsTypes.h"
+#include <wtf/EnumTraits.h>
#include <wtf/RefCounted.h>
#include <wtf/Variant.h>
#include <wtf/Vector.h>
@@ -69,6 +70,9 @@
, color(color)
{
}
+
+ template<class Encoder> void encode(Encoder&) const;
+ template<class Decoder> static Optional<ColorStop> decode(Decoder&);
};
using ColorStopVector = Vector<ColorStop, 2>;
@@ -76,6 +80,9 @@
struct LinearData {
FloatPoint point0;
FloatPoint point1;
+
+ template<class Encoder> void encode(Encoder&) const;
+ template<class Decoder> static Optional<LinearData> decode(Decoder&);
};
struct RadialData {
@@ -84,11 +91,17 @@
float startRadius;
float endRadius;
float aspectRatio; // For elliptical gradient, width / height.
+
+ template<class Encoder> void encode(Encoder&) const;
+ template<class Decoder> static Optional<RadialData> decode(Decoder&);
};
struct ConicData {
FloatPoint point0;
float angleRadians;
+
+ template<class Encoder> void encode(Encoder&) const;
+ template<class Decoder> static Optional<ConicData> decode(Decoder&);
};
using Data = "" RadialData, ConicData>;
@@ -95,13 +108,13 @@
enum class Type { Linear, Radial, Conic };
- static Ref<Gradient> create(LinearData&&);
- static Ref<Gradient> create(RadialData&&);
- static Ref<Gradient> create(ConicData&&);
+ WEBCORE_EXPORT static Ref<Gradient> create(LinearData&&);
+ WEBCORE_EXPORT static Ref<Gradient> create(RadialData&&);
+ WEBCORE_EXPORT static Ref<Gradient> create(ConicData&&);
WEBCORE_EXPORT ~Gradient();
- Type type() const;
+ WEBCORE_EXPORT Type type() const;
bool hasAlpha() const;
bool isZeroSize() const;
@@ -110,15 +123,15 @@
WEBCORE_EXPORT void addColorStop(const ColorStop&);
WEBCORE_EXPORT void addColorStop(float, const Color&);
- void setSortedColorStops(ColorStopVector&&);
+ WEBCORE_EXPORT void setSortedColorStops(ColorStopVector&&);
const ColorStopVector& stops() const { return m_stops; }
- void setSpreadMethod(GradientSpreadMethod);
+ WEBCORE_EXPORT void setSpreadMethod(GradientSpreadMethod);
GradientSpreadMethod spreadMethod() const { return m_spreadMethod; }
// CG needs to transform the gradient at draw time.
- void setGradientSpaceTransform(const AffineTransform& gradientSpaceTransformation);
+ WEBCORE_EXPORT void setGradientSpaceTransform(const AffineTransform& gradientSpaceTransformation);
const AffineTransform& gradientSpaceTransform() const { return m_gradientSpaceTransformation; }
void fill(GraphicsContext&, const FloatRect&);
@@ -136,6 +149,9 @@
PlatformGradient createPlatformGradient(float globalAlpha);
#endif
+ template<class Encoder> void encode(Encoder&) const;
+ template<class Decoder> static Optional<Ref<Gradient>> decode(Decoder&);
+
private:
Gradient(LinearData&&);
Gradient(RadialData&&);
@@ -163,4 +179,225 @@
PlatformGradient m_gradient;
};
+template<class Encoder>
+void Gradient::ColorStop::encode(Encoder& encoder) const
+{
+ encoder << offset;
+ encoder << color;
}
+
+template<class Decoder>
+Optional<Gradient::ColorStop> Gradient::ColorStop::decode(Decoder& decoder)
+{
+ Optional<float> offset;
+ decoder >> offset;
+ if (!offset)
+ return WTF::nullopt;
+
+ Optional<Color> color;
+ decoder >> color;
+ if (!color)
+ return WTF::nullopt;
+
+ return {{ *offset, *color }};
+}
+
+template<class Encoder>
+void Gradient::LinearData::encode(Encoder& encoder) const
+{
+ encoder << point0;
+ encoder << point1;
+}
+
+template<class Decoder>
+Optional<Gradient::LinearData> Gradient::LinearData::decode(Decoder& decoder)
+{
+ Optional<FloatPoint> point0;
+ decoder >> point0;
+ if (!point0)
+ return WTF::nullopt;
+
+ Optional<FloatPoint> point1;
+ decoder >> point1;
+ if (!point1)
+ return WTF::nullopt;
+
+ return {{ *point0, *point1 }};
+}
+
+template<class Encoder>
+void Gradient::RadialData::encode(Encoder& encoder) const
+{
+ encoder << point0;
+ encoder << point1;
+ encoder << startRadius;
+ encoder << endRadius;
+ encoder << aspectRatio;
+}
+
+template<class Decoder>
+Optional<Gradient::RadialData> Gradient::RadialData::decode(Decoder& decoder)
+{
+ Optional<FloatPoint> point0;
+ decoder >> point0;
+ if (!point0)
+ return WTF::nullopt;
+
+ Optional<FloatPoint> point1;
+ decoder >> point1;
+ if (!point1)
+ return WTF::nullopt;
+
+ Optional<float> startRadius;
+ decoder >> startRadius;
+ if (!startRadius)
+ return WTF::nullopt;
+
+ Optional<float> endRadius;
+ decoder >> endRadius;
+ if (!endRadius)
+ return WTF::nullopt;
+
+ Optional<float> aspectRatio;
+ decoder >> aspectRatio;
+ if (!aspectRatio)
+ return WTF::nullopt;
+
+ return {{ *point0, *point1, *startRadius, *endRadius, *aspectRatio }};
+}
+
+template<class Encoder>
+void Gradient::ConicData::encode(Encoder& encoder) const
+{
+ encoder << point0;
+ encoder << angleRadians;
+}
+
+template<class Decoder>
+Optional<Gradient::ConicData> Gradient::ConicData::decode(Decoder& decoder)
+{
+ Optional<FloatPoint> point0;
+ decoder >> point0;
+ if (!point0)
+ return WTF::nullopt;
+
+ Optional<float> angleRadians;
+ decoder >> angleRadians;
+ if (!angleRadians)
+ return WTF::nullopt;
+
+ return {{ *point0, *angleRadians }};
+}
+
+template<class Encoder>
+void Gradient::encode(Encoder& encoder) const
+{
+ auto type = this->type();
+ encoder << type;
+ switch (type) {
+ case Type::Linear:
+ encoder << WTF::get<Gradient::LinearData>(m_data);
+ break;
+ case Type::Radial:
+ encoder << WTF::get<Gradient::RadialData>(m_data);
+ break;
+ case Type::Conic:
+ encoder << WTF::get<Gradient::ConicData>(m_data);
+ break;
+ }
+ encoder << m_stops;
+ encoder << m_stopsSorted;
+ encoder.encodeEnum(m_spreadMethod);
+ encoder << m_gradientSpaceTransformation;
+}
+
+template<class Decoder>
+Optional<Ref<Gradient>> Gradient::decode(Decoder& decoder)
+{
+ Optional<Gradient::Type> type;
+ decoder >> type;
+ if (!type)
+ return WTF::nullopt;
+
+ RefPtr<Gradient> gradient;
+ switch (*type) {
+ case Type::Linear: {
+ Optional<LinearData> linearData;
+ decoder >> linearData;
+ if (!linearData)
+ return WTF::nullopt;
+
+ gradient = Gradient::create(WTFMove(*linearData));
+ break;
+ }
+ case Type::Radial: {
+ Optional<RadialData> radialData;
+ decoder >> radialData;
+ if (!radialData)
+ return WTF::nullopt;
+
+ gradient = Gradient::create(WTFMove(*radialData));
+ break;
+ }
+ case Type::Conic: {
+ Optional<ConicData> conicData;
+ decoder >> conicData;
+ if (!conicData)
+ return WTF::nullopt;
+
+ gradient = Gradient::create(WTFMove(*conicData));
+ break;
+ }
+ }
+
+ if (!gradient) {
+ ASSERT_NOT_REACHED();
+ return WTF::nullopt;
+ }
+
+ Optional<ColorStopVector> stops;
+ decoder >> stops;
+ if (!stops)
+ return WTF::nullopt;
+
+ Optional<bool> stopsSorted;
+ decoder >> stopsSorted;
+ if (!stopsSorted.hasValue())
+ return WTF::nullopt;
+
+ if (stopsSorted.value())
+ gradient->setSortedColorStops(WTFMove(*stops));
+ else {
+ for (auto& stop : *stops)
+ gradient->addColorStop(stop);
+ }
+
+ GradientSpreadMethod spreadMethod;
+ if (!decoder.decodeEnum(spreadMethod))
+ return WTF::nullopt;
+
+ gradient->setSpreadMethod(spreadMethod);
+
+ Optional<AffineTransform> gradientSpaceTransformation;
+ decoder >> gradientSpaceTransformation;
+ if (!gradientSpaceTransformation)
+ return WTF::nullopt;
+
+ gradient->setGradientSpaceTransform(WTFMove(*gradientSpaceTransformation));
+ return gradient.releaseNonNull();
+}
+
+} // namespace WebCore
+
+namespace WTF {
+
+template<> struct EnumTraits<WebCore::Gradient::Type> {
+ using values = EnumValues<
+ WebCore::Gradient::Type,
+ WebCore::Gradient::Type::Linear,
+ WebCore::Gradient::Type::Radial,
+ WebCore::Gradient::Type::Conic
+ >;
+};
+
+} // namespace WTF
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (253301 => 253302)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2019-12-09 22:19:01 UTC (rev 253301)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2019-12-09 22:53:28 UTC (rev 253302)
@@ -182,19 +182,18 @@
FillColorChange = 1 << 8,
FillRuleChange = 1 << 9,
ShadowChange = 1 << 10,
- ShadowColorChange = 1 << 11,
- ShadowsIgnoreTransformsChange = 1 << 12,
- AlphaChange = 1 << 13,
- CompositeOperationChange = 1 << 14,
- BlendModeChange = 1 << 15,
- TextDrawingModeChange = 1 << 16,
- ShouldAntialiasChange = 1 << 17,
- ShouldSmoothFontsChange = 1 << 18,
- ShouldSubpixelQuantizeFontsChange = 1 << 19,
- DrawLuminanceMaskChange = 1 << 20,
- ImageInterpolationQualityChange = 1 << 21,
+ ShadowsIgnoreTransformsChange = 1 << 11,
+ AlphaChange = 1 << 12,
+ CompositeOperationChange = 1 << 13,
+ BlendModeChange = 1 << 14,
+ TextDrawingModeChange = 1 << 15,
+ ShouldAntialiasChange = 1 << 16,
+ ShouldSmoothFontsChange = 1 << 17,
+ ShouldSubpixelQuantizeFontsChange = 1 << 18,
+ DrawLuminanceMaskChange = 1 << 19,
+ ImageInterpolationQualityChange = 1 << 20,
#if HAVE(OS_DARK_MODE_SUPPORT)
- UseDarkAppearanceChange = 1 << 22,
+ UseDarkAppearanceChange = 1 << 21,
#endif
};
typedef OptionSet<Change> StateChangeFlags;
Modified: trunk/Source/WebCore/platform/graphics/Image.h (253301 => 253302)
--- trunk/Source/WebCore/platform/graphics/Image.h 2019-12-09 22:19:01 UTC (rev 253301)
+++ trunk/Source/WebCore/platform/graphics/Image.h 2019-12-09 22:53:28 UTC (rev 253302)
@@ -199,6 +199,11 @@
std::unique_ptr<Timer> m_animationStartTimer;
};
+class ImageHandle {
+public:
+ RefPtr<Image> image;
+};
+
WTF::TextStream& operator<<(WTF::TextStream&, const Image&);
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/Pattern.h (253301 => 253302)
--- trunk/Source/WebCore/platform/graphics/Pattern.h 2019-12-09 22:19:01 UTC (rev 253301)
+++ trunk/Source/WebCore/platform/graphics/Pattern.h 2019-12-09 22:53:28 UTC (rev 253302)
@@ -54,10 +54,11 @@
class AffineTransform;
class GraphicsContext;
class Image;
+class ImageHandle;
class Pattern final : public RefCounted<Pattern> {
public:
- static Ref<Pattern> create(Ref<Image>&& tileImage, bool repeatX, bool repeatY);
+ WEBCORE_EXPORT static Ref<Pattern> create(Ref<Image>&& tileImage, bool repeatX, bool repeatY);
WEBCORE_EXPORT ~Pattern();
Image& tileImage() const { return m_tileImage.get(); }
@@ -68,11 +69,14 @@
#else
PlatformPatternPtr createPlatformPattern(const GraphicsContext&, float alpha, const AffineTransform& userSpaceTransformation) const;
#endif
- void setPatternSpaceTransform(const AffineTransform& patternSpaceTransformation);
+ WEBCORE_EXPORT void setPatternSpaceTransform(const AffineTransform& patternSpaceTransformation);
const AffineTransform& patternSpaceTransform() const { return m_patternSpaceTransformation; };
bool repeatX() const { return m_repeatX; }
bool repeatY() const { return m_repeatY; }
+ template<class Encoder> void encode(Encoder&) const;
+ template<class Decoder> static Optional<Ref<Pattern>> decode(Decoder&);
+
private:
Pattern(Ref<Image>&&, bool repeatX, bool repeatY);
@@ -82,5 +86,44 @@
bool m_repeatY;
};
+template<class Encoder>
+void Pattern::encode(Encoder& encoder) const
+{
+ ImageHandle imageHandle;
+ imageHandle.image = m_tileImage.ptr();
+ encoder << imageHandle;
+ encoder << m_patternSpaceTransformation;
+ encoder << m_repeatX;
+ encoder << m_repeatY;
+}
+
+template<class Decoder>
+Optional<Ref<Pattern>> Pattern::decode(Decoder& decoder)
+{
+ Optional<ImageHandle> imageHandle;
+ decoder >> imageHandle;
+ if (!imageHandle)
+ return WTF::nullopt;
+
+ Optional<AffineTransform> patternSpaceTransformation;
+ decoder >> patternSpaceTransformation;
+ if (!patternSpaceTransformation)
+ return WTF::nullopt;
+
+ Optional<bool> repeatX;
+ decoder >> repeatX;
+ if (!repeatX)
+ return WTF::nullopt;
+
+ Optional<bool> repeatY;
+ decoder >> repeatY;
+ if (!repeatY)
+ return WTF::nullopt;
+
+ auto pattern = Pattern::create(imageHandle->image.releaseNonNull(), *repeatX, *repeatY);
+ pattern->setPatternSpaceTransform(*patternSpaceTransformation);
+ return pattern;
+}
+
} //namespace
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp (253301 => 253302)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp 2019-12-09 22:19:01 UTC (rev 253301)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp 2019-12-09 22:53:28 UTC (rev 253302)
@@ -979,6 +979,15 @@
return ts;
}
+FillRectWithGradient::FillRectWithGradient(const FloatRect& rect, Gradient& gradient)
+ : DrawingItem(ItemType::FillRectWithGradient)
+ , m_rect(rect)
+ , m_gradient(gradient)
+{
+}
+
+FillRectWithGradient::~FillRectWithGradient() = default;
+
void FillRectWithGradient::apply(GraphicsContext& context) const
{
context.fillRect(m_rect, m_gradient.get());
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h (253301 => 253302)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h 2019-12-09 22:19:01 UTC (rev 253301)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h 2019-12-09 22:53:28 UTC (rev 253302)
@@ -32,6 +32,7 @@
#include "GlyphBuffer.h"
#include "GraphicsContext.h"
#include "Image.h"
+#include "Pattern.h"
#include <wtf/RefCounted.h>
#include <wtf/TypeCasts.h>
@@ -452,18 +453,85 @@
template<class Encoder>
void SetState::encode(Encoder& encoder) const
{
- encoder << m_state.m_changeFlags;
+ auto changeFlags = m_state.m_changeFlags;
+ encoder << changeFlags;
- // FIXME: Encode the other state changes.
+ auto& state = m_state.m_state;
- if (m_state.m_changeFlags.contains(GraphicsContextState::StrokeColorChange))
- encoder << m_state.m_state.strokeColor;
+ if (changeFlags.contains(GraphicsContextState::StrokeGradientChange)) {
+ encoder << !!state.strokeGradient;
+ if (state.strokeGradient)
+ encoder << *state.strokeGradient;
+ }
- if (m_state.m_changeFlags.contains(GraphicsContextState::FillColorChange))
- encoder << m_state.m_state.fillColor;
+ if (changeFlags.contains(GraphicsContextState::StrokePatternChange)) {
+ encoder << !!state.strokePattern;
+ if (state.strokePattern)
+ encoder << *state.strokePattern;
+ }
- if (m_state.m_changeFlags.contains(GraphicsContextState::AlphaChange))
- encoder << m_state.m_state.alpha;
+ if (changeFlags.contains(GraphicsContextState::FillGradientChange)) {
+ encoder << !!state.fillGradient;
+ if (state.fillGradient)
+ encoder << *state.fillGradient;
+ }
+
+ if (changeFlags.contains(GraphicsContextState::FillPatternChange)) {
+ encoder << !!state.fillPattern;
+ if (state.fillPattern)
+ encoder << *state.fillPattern;
+ }
+
+ if (changeFlags.contains(GraphicsContextState::ShadowChange)) {
+ encoder << state.shadowOffset;
+ encoder << state.shadowBlur;
+ encoder << state.shadowColor;
+#if USE(CG)
+ encoder << state.shadowsUseLegacyRadius;
+#endif // USE(CG)
+ }
+
+ if (changeFlags.contains(GraphicsContextState::StrokeThicknessChange))
+ encoder << state.strokeThickness;
+
+ if (changeFlags.contains(GraphicsContextState::TextDrawingModeChange))
+ encoder.encodeEnum(state.textDrawingMode);
+
+ if (changeFlags.contains(GraphicsContextState::StrokeColorChange))
+ encoder << state.strokeColor;
+
+ if (changeFlags.contains(GraphicsContextState::FillColorChange))
+ encoder << state.fillColor;
+
+ if (changeFlags.contains(GraphicsContextState::StrokeStyleChange))
+ encoder.encodeEnum(state.strokeStyle);
+
+ if (changeFlags.contains(GraphicsContextState::FillRuleChange))
+ encoder << state.fillRule;
+
+ if (changeFlags.contains(GraphicsContextState::CompositeOperationChange))
+ encoder << state.compositeOperator;
+
+ if (changeFlags.contains(GraphicsContextState::BlendModeChange))
+ encoder << state.blendMode;
+
+ if (changeFlags.contains(GraphicsContextState::ImageInterpolationQualityChange))
+ encoder << state.imageInterpolationQuality;
+
+ if (changeFlags.contains(GraphicsContextState::AlphaChange))
+ encoder << state.alpha;
+
+ if (changeFlags.contains(GraphicsContextState::ShouldAntialiasChange))
+ encoder << state.shouldAntialias;
+
+ if (changeFlags.contains(GraphicsContextState::ShouldSmoothFontsChange))
+ encoder << state.shouldSmoothFonts;
+
+ if (changeFlags.contains(GraphicsContextState::ShouldSubpixelQuantizeFontsChange))
+ encoder << state.shouldSubpixelQuantizeFonts;
+
+ if (changeFlags.contains(GraphicsContextState::ShadowsIgnoreTransformsChange))
+ encoder << state.shadowsIgnoreTransforms;
}
template<class Decoder>
@@ -477,6 +545,115 @@
GraphicsContextStateChange stateChange;
stateChange.m_changeFlags = *changeFlags;
+ if (stateChange.m_changeFlags.contains(GraphicsContextState::StrokeGradientChange)) {
+ Optional<bool> hasStrokeGradient;
+ decoder >> hasStrokeGradient;
+ if (!hasStrokeGradient.hasValue())
+ return WTF::nullopt;
+
+ if (hasStrokeGradient.value()) {
+ auto strokeGradient = Gradient::decode(decoder);
+ if (!strokeGradient)
+ return WTF::nullopt;
+
+ stateChange.m_state.strokeGradient = WTFMove(*strokeGradient);
+ }
+ }
+
+ if (stateChange.m_changeFlags.contains(GraphicsContextState::StrokePatternChange)) {
+ Optional<bool> hasStrokePattern;
+ decoder >> hasStrokePattern;
+ if (!hasStrokePattern.hasValue())
+ return WTF::nullopt;
+
+ if (hasStrokePattern.value()) {
+ auto strokePattern = Pattern::decode(decoder);
+ if (!strokePattern)
+ return WTF::nullopt;
+
+ stateChange.m_state.strokePattern = WTFMove(*strokePattern);
+ }
+ }
+
+ if (stateChange.m_changeFlags.contains(GraphicsContextState::FillGradientChange)) {
+ Optional<bool> hasFillGradient;
+ decoder >> hasFillGradient;
+ if (!hasFillGradient.hasValue())
+ return WTF::nullopt;
+
+ if (hasFillGradient.value()) {
+ auto fillGradient = Gradient::decode(decoder);
+ if (!fillGradient)
+ return WTF::nullopt;
+
+ stateChange.m_state.fillGradient = WTFMove(*fillGradient);
+ }
+ }
+
+ if (stateChange.m_changeFlags.contains(GraphicsContextState::FillPatternChange)) {
+ Optional<bool> hasFillPattern;
+ decoder >> hasFillPattern;
+ if (!hasFillPattern.hasValue())
+ return WTF::nullopt;
+
+ if (hasFillPattern.value()) {
+ auto fillPattern = Pattern::decode(decoder);
+ if (!fillPattern)
+ return WTF::nullopt;
+
+ stateChange.m_state.fillPattern = WTFMove(*fillPattern);
+ }
+ }
+
+ if (stateChange.m_changeFlags.contains(GraphicsContextState::ShadowChange)) {
+ Optional<FloatSize> shadowOffset;
+ decoder >> shadowOffset;
+ if (!shadowOffset)
+ return WTF::nullopt;
+
+ stateChange.m_state.shadowOffset = *shadowOffset;
+
+ Optional<float> shadowBlur;
+ decoder >> shadowBlur;
+ if (!shadowBlur)
+ return WTF::nullopt;
+
+ stateChange.m_state.shadowBlur = *shadowBlur;
+
+ Optional<Color> shadowColor;
+ decoder >> shadowColor;
+ if (!shadowColor)
+ return WTF::nullopt;
+
+ stateChange.m_state.shadowColor = *shadowColor;
+
+#if USE(CG)
+ Optional<bool> shadowsUseLegacyRadius;
+ decoder >> shadowsUseLegacyRadius;
+ if (!shadowsUseLegacyRadius)
+ return WTF::nullopt;
+
+ stateChange.m_state.shadowsUseLegacyRadius = *shadowsUseLegacyRadius;
+#endif // USE(CG)
+ }
+
+ if (stateChange.m_changeFlags.contains(GraphicsContextState::StrokeThicknessChange)) {
+ Optional<float> strokeThickness;
+ decoder >> strokeThickness;
+ if (!strokeThickness)
+ return WTF::nullopt;
+
+ stateChange.m_state.strokeThickness = *strokeThickness;
+ }
+
+ if (stateChange.m_changeFlags.contains(GraphicsContextState::TextDrawingModeChange)) {
+ TextDrawingModeFlags textDrawingMode;
+ if (!decoder.decodeEnum(textDrawingMode))
+ return WTF::nullopt;
+
+ stateChange.m_state.textDrawingMode = textDrawingMode;
+ }
+
if (stateChange.m_changeFlags.contains(GraphicsContextState::StrokeColorChange)) {
Optional<Color> strokeColor;
decoder >> strokeColor;
@@ -495,6 +672,50 @@
stateChange.m_state.fillColor = *fillColor;
}
+ if (stateChange.m_changeFlags.contains(GraphicsContextState::StrokeStyleChange)) {
+ StrokeStyle strokeStyle;
+ if (!decoder.decodeEnum(strokeStyle))
+ return WTF::nullopt;
+
+ stateChange.m_state.strokeStyle = strokeStyle;
+ }
+
+ if (stateChange.m_changeFlags.contains(GraphicsContextState::FillRuleChange)) {
+ Optional<WindRule> fillRule;
+ decoder >> fillRule;
+ if (!fillRule)
+ return WTF::nullopt;
+
+ stateChange.m_state.fillRule = *fillRule;
+ }
+
+ if (stateChange.m_changeFlags.contains(GraphicsContextState::CompositeOperationChange)) {
+ Optional<CompositeOperator> compositeOperator;
+ decoder >> compositeOperator;
+ if (!compositeOperator)
+ return WTF::nullopt;
+
+ stateChange.m_state.compositeOperator = *compositeOperator;
+ }
+
+ if (stateChange.m_changeFlags.contains(GraphicsContextState::BlendModeChange)) {
+ Optional<BlendMode> blendMode;
+ decoder >> blendMode;
+ if (!blendMode)
+ return WTF::nullopt;
+
+ stateChange.m_state.blendMode = *blendMode;
+ }
+
+ if (stateChange.m_changeFlags.contains(GraphicsContextState::ImageInterpolationQualityChange)) {
+ Optional<InterpolationQuality> imageInterpolationQuality;
+ decoder >> imageInterpolationQuality;
+ if (!imageInterpolationQuality)
+ return WTF::nullopt;
+
+ stateChange.m_state.imageInterpolationQuality = *imageInterpolationQuality;
+ }
+
if (stateChange.m_changeFlags.contains(GraphicsContextState::AlphaChange)) {
Optional<float> alpha;
decoder >> alpha;
@@ -504,6 +725,42 @@
stateChange.m_state.alpha = *alpha;
}
+ if (stateChange.m_changeFlags.contains(GraphicsContextState::ShouldAntialiasChange)) {
+ Optional<bool> shouldAntialias;
+ decoder >> shouldAntialias;
+ if (!shouldAntialias)
+ return WTF::nullopt;
+
+ stateChange.m_state.shouldAntialias = *shouldAntialias;
+ }
+
+ if (stateChange.m_changeFlags.contains(GraphicsContextState::ShouldSmoothFontsChange)) {
+ Optional<bool> shouldSmoothFonts;
+ decoder >> shouldSmoothFonts;
+ if (!shouldSmoothFonts)
+ return WTF::nullopt;
+
+ stateChange.m_state.shouldSmoothFonts = *shouldSmoothFonts;
+ }
+
+ if (stateChange.m_changeFlags.contains(GraphicsContextState::ShouldSubpixelQuantizeFontsChange)) {
+ Optional<bool> shouldSubpixelQuantizeFonts;
+ decoder >> shouldSubpixelQuantizeFonts;
+ if (!shouldSubpixelQuantizeFonts)
+ return WTF::nullopt;
+
+ stateChange.m_state.shouldSubpixelQuantizeFonts = *shouldSubpixelQuantizeFonts;
+ }
+
+ if (stateChange.m_changeFlags.contains(GraphicsContextState::ShadowsIgnoreTransformsChange)) {
+ Optional<bool> shadowsIgnoreTransforms;
+ decoder >> shadowsIgnoreTransforms;
+ if (!shadowsIgnoreTransforms)
+ return WTF::nullopt;
+
+ stateChange.m_state.shadowsIgnoreTransforms = *shadowsIgnoreTransforms;
+ }
+
return SetState::create(stateChange);
}
@@ -930,11 +1187,6 @@
ImagePaintingOptions m_imagePaintingOptions;
};
-class ImageHandle {
-public:
- RefPtr<Image> image;
-};
-
template<class Encoder>
void DrawImage::encode(Encoder& encoder) const
{
@@ -1862,15 +2114,15 @@
return adoptRef(*new FillRectWithGradient(rect, gradient));
}
+ WEBCORE_EXPORT virtual ~FillRectWithGradient();
+
FloatRect rect() const { return m_rect; }
+ template<class Encoder> void encode(Encoder&) const;
+ template<class Decoder> static Optional<Ref<FillRectWithGradient>> decode(Decoder&);
+
private:
- FillRectWithGradient(const FloatRect& rect, Gradient& gradient)
- : DrawingItem(ItemType::FillRectWithGradient)
- , m_rect(rect)
- , m_gradient(gradient)
- {
- }
+ WEBCORE_EXPORT FillRectWithGradient(const FloatRect&, Gradient&);
void apply(GraphicsContext&) const override;
Optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_rect; }
@@ -1879,6 +2131,28 @@
mutable Ref<Gradient> m_gradient; // FIXME: Make this not mutable
};
+template<class Encoder>
+void FillRectWithGradient::encode(Encoder& encoder) const
+{
+ encoder << m_rect;
+ encoder << m_gradient.get();
+}
+
+template<class Decoder>
+Optional<Ref<FillRectWithGradient>> FillRectWithGradient::decode(Decoder& decoder)
+{
+ Optional<FloatRect> rect;
+ decoder >> rect;
+ if (!rect)
+ return WTF::nullopt;
+
+ auto gradient = Gradient::decode(decoder);
+ if (!gradient)
+ return WTF::nullopt;
+
+ return FillRectWithGradient::create(*rect, gradient->get());
+}
+
class FillCompositedRect : public DrawingItem {
public:
static Ref<FillCompositedRect> create(const FloatRect& rect, const Color& color, CompositeOperator op, BlendMode blendMode)
@@ -2511,7 +2785,7 @@
encoder << downcast<FillRectWithColor>(*this);
break;
case ItemType::FillRectWithGradient:
- WTFLogAlways("DisplayList::Item::encode cannot yet encode FillRectWithGradient");
+ encoder << downcast<FillRectWithGradient>(*this);
break;
case ItemType::FillCompositedRect:
encoder << downcast<FillCompositedRect>(*this);
@@ -2698,7 +2972,8 @@
return static_reference_cast<Item>(WTFMove(*item));
break;
case ItemType::FillRectWithGradient:
- WTFLogAlways("DisplayList::Item::decode cannot yet decode FillRectWithGradient");
+ if (auto item = FillRectWithGradient::decode(decoder))
+ return static_reference_cast<Item>(WTFMove(*item));
break;
case ItemType::FillCompositedRect:
if (auto item = FillCompositedRect::decode(decoder))
Modified: trunk/Source/WebKit/ChangeLog (253301 => 253302)
--- trunk/Source/WebKit/ChangeLog 2019-12-09 22:19:01 UTC (rev 253301)
+++ trunk/Source/WebKit/ChangeLog 2019-12-09 22:53:28 UTC (rev 253302)
@@ -1,3 +1,20 @@
+2019-12-09 Wenson Hsieh <[email protected]>
+
+ Finish encoding/decoding support for DisplayList::SetState
+ https://bugs.webkit.org/show_bug.cgi?id=205018
+
+ Reviewed by Tim Horton.
+
+ Replaces WebCore::DisplayList::ImageHandle with just WebCore::ImageHandle. See WebCore ChangeLog for more
+ details.
+
+ * Shared/WebCoreArgumentCoders.cpp:
+ (IPC::ArgumentCoder<ImageHandle>::encode):
+ (IPC::ArgumentCoder<ImageHandle>::decode):
+ (IPC::ArgumentCoder<DisplayList::ImageHandle>::encode): Deleted.
+ (IPC::ArgumentCoder<DisplayList::ImageHandle>::decode): Deleted.
+ * Shared/WebCoreArgumentCoders.h:
+
2019-12-09 Said Abou-Hallawa <[email protected]>
Throttling requestAnimationFrame should be controlled by RenderingUpdateScheduler
Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp (253301 => 253302)
--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp 2019-12-09 22:19:01 UTC (rev 253301)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp 2019-12-09 22:53:28 UTC (rev 253302)
@@ -1028,12 +1028,12 @@
return decodeImage(decoder, image);
}
-void ArgumentCoder<DisplayList::ImageHandle>::encode(Encoder& encoder, const DisplayList::ImageHandle& imageHandle)
+void ArgumentCoder<ImageHandle>::encode(Encoder& encoder, const ImageHandle& imageHandle)
{
encodeOptionalImage(encoder, imageHandle.image.get());
}
-bool ArgumentCoder<DisplayList::ImageHandle>::decode(Decoder& decoder, DisplayList::ImageHandle& imageHandle)
+bool ArgumentCoder<ImageHandle>::decode(Decoder& decoder, ImageHandle& imageHandle)
{
if (!decodeOptionalImage(decoder, imageHandle.image))
return false;
Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h (253301 => 253302)
--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h 2019-12-09 22:19:01 UTC (rev 253301)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h 2019-12-09 22:53:28 UTC (rev 253302)
@@ -81,6 +81,7 @@
class FloatSize;
class FixedPositionViewportConstraints;
class HTTPHeaderMap;
+class ImageHandle;
class IntPoint;
class IntRect;
class IntSize;
@@ -189,10 +190,6 @@
struct Record;
}
-namespace DisplayList {
-class ImageHandle;
-}
-
} // namespace WebCore
namespace IPC {
@@ -381,9 +378,9 @@
static bool decode(Decoder&, WebCore::Cursor&);
};
-template<> struct ArgumentCoder<WebCore::DisplayList::ImageHandle> {
- static void encode(Encoder&, const WebCore::DisplayList::ImageHandle&);
- static bool decode(Decoder&, WebCore::DisplayList::ImageHandle&);
+template<> struct ArgumentCoder<WebCore::ImageHandle> {
+ static void encode(Encoder&, const WebCore::ImageHandle&);
+ static bool decode(Decoder&, WebCore::ImageHandle&);
};
template<> struct ArgumentCoder<WebCore::ResourceRequest> {